From d4d595fa7fb12903db9227d33d48b2b00120dbd1 Mon Sep 17 00:00:00 2001 From: William Joye Date: Thu, 27 Oct 2016 14:59:29 -0400 Subject: Initial commit --- tksao/Makefile.in | 524 ++ tksao/aclocal.m4 | 9 + tksao/colorbar/cbgrid.C | 210 + tksao/colorbar/cbgrid.h | 33 + tksao/colorbar/colorbar.C | 880 +++ tksao/colorbar/colorbar.h | 94 + tksao/colorbar/colorbarbase.C | 1103 +++ tksao/colorbar/colorbarbase.h | 200 + tksao/colorbar/colorbarrgb.C | 490 ++ tksao/colorbar/colorbarrgb.h | 55 + tksao/colorbar/colorbarrgbtruecolor16.C | 294 + tksao/colorbar/colorbarrgbtruecolor16.h | 20 + tksao/colorbar/colorbarrgbtruecolor24.C | 531 ++ tksao/colorbar/colorbarrgbtruecolor24.h | 24 + tksao/colorbar/colorbarrgbtruecolor8.C | 200 + tksao/colorbar/colorbarrgbtruecolor8.h | 20 + tksao/colorbar/colorbartruecolor16.C | 215 + tksao/colorbar/colorbartruecolor16.h | 20 + tksao/colorbar/colorbartruecolor24.C | 335 + tksao/colorbar/colorbartruecolor24.h | 24 + tksao/colorbar/colorbartruecolor8.C | 169 + tksao/colorbar/colorbartruecolor8.h | 20 + tksao/colorbar/colormap.C | 44 + tksao/colorbar/colormap.h | 68 + tksao/colorbar/colortag.C | 78 + tksao/colorbar/colortag.h | 62 + tksao/colorbar/default.C | 586 ++ tksao/colorbar/default.h | 104 + tksao/colorbar/lex.C | 2070 ++++++ tksao/colorbar/lex.L | 127 + tksao/colorbar/lut.C | 174 + tksao/colorbar/lut.h | 76 + tksao/colorbar/lutlex.C | 1699 +++++ tksao/colorbar/lutlex.L | 106 + tksao/colorbar/lutparser.C | 1632 +++++ tksao/colorbar/lutparser.H | 89 + tksao/colorbar/lutparser.Y | 75 + tksao/colorbar/parser.C | 2215 ++++++ tksao/colorbar/parser.H | 182 + tksao/colorbar/parser.Y | 249 + tksao/colorbar/sao.C | 209 + tksao/colorbar/sao.h | 85 + tksao/colorbar/saolex.C | 1754 +++++ tksao/colorbar/saolex.L | 111 + tksao/colorbar/saoparser.C | 1674 +++++ tksao/colorbar/saoparser.H | 99 + tksao/colorbar/saoparser.Y | 98 + tksao/configure | 10781 ++++++++++++++++++++++++++++ tksao/configure.in | 411 ++ tksao/fitsy++/alloc.C | 25 + tksao/fitsy++/alloc.h | 51 + tksao/fitsy++/allocgz.C | 25 + tksao/fitsy++/allocgz.h | 46 + tksao/fitsy++/analysis.C | 56 + tksao/fitsy++/analysis.h | 16 + tksao/fitsy++/block.C | 269 + tksao/fitsy++/block.h | 30 + tksao/fitsy++/card.C | 288 + tksao/fitsy++/card.h | 69 + tksao/fitsy++/channel.C | 21 + tksao/fitsy++/channel.h | 55 + tksao/fitsy++/column.C | 649 ++ tksao/fitsy++/column.h | 198 + tksao/fitsy++/compress.C | 875 +++ tksao/fitsy++/compress.h | 94 + tksao/fitsy++/envi.C | 141 + tksao/fitsy++/envi.h | 35 + tksao/fitsy++/envilex.C | 2223 ++++++ tksao/fitsy++/envilex.L | 194 + tksao/fitsy++/enviparser.C | 2017 ++++++ tksao/fitsy++/enviparser.H | 179 + tksao/fitsy++/enviparser.Y | 271 + tksao/fitsy++/file.C | 517 ++ tksao/fitsy++/file.h | 230 + tksao/fitsy++/gzip.C | 339 + tksao/fitsy++/gzip.h | 19 + tksao/fitsy++/hcompress.C | 120 + tksao/fitsy++/hcompress.h | 22 + tksao/fitsy++/hdecompress.c | 2619 +++++++ tksao/fitsy++/hdu.C | 323 + tksao/fitsy++/hdu.h | 109 + tksao/fitsy++/head.C | 643 ++ tksao/fitsy++/head.h | 133 + tksao/fitsy++/hist.C | 662 ++ tksao/fitsy++/hist.h | 59 + tksao/fitsy++/hpx.C | 579 ++ tksao/fitsy++/hpx.h | 37 + tksao/fitsy++/iis.C | 79 + tksao/fitsy++/iis.h | 20 + tksao/fitsy++/lex.C | 1959 ++++++ tksao/fitsy++/lex.L | 156 + tksao/fitsy++/map.C | 417 ++ tksao/fitsy++/map.h | 69 + tksao/fitsy++/mapincr.C | 599 ++ tksao/fitsy++/mapincr.h | 67 + tksao/fitsy++/mmap.C | 68 + tksao/fitsy++/mmap.h | 47 + tksao/fitsy++/mmapincr.C | 53 + tksao/fitsy++/mmapincr.h | 41 + tksao/fitsy++/nrrd.C | 80 + tksao/fitsy++/nrrd.h | 36 + tksao/fitsy++/nrrdgzip.C | 84 + tksao/fitsy++/nrrdgzip.h | 19 + tksao/fitsy++/nrrdlex.C | 2462 +++++++ tksao/fitsy++/nrrdlex.L | 215 + tksao/fitsy++/nrrdparser.C | 2196 ++++++ tksao/fitsy++/nrrdparser.H | 259 + tksao/fitsy++/nrrdparser.Y | 398 ++ tksao/fitsy++/order.C | 267 + tksao/fitsy++/order.h | 21 + tksao/fitsy++/outchannel.C | 30 + tksao/fitsy++/outchannel.h | 20 + tksao/fitsy++/outfile.C | 63 + tksao/fitsy++/outfile.h | 33 + tksao/fitsy++/outfits.C | 59 + tksao/fitsy++/outfits.h | 27 + tksao/fitsy++/outsocket.C | 199 + tksao/fitsy++/outsocket.h | 38 + tksao/fitsy++/parser.C | 2194 ++++++ tksao/fitsy++/parser.H | 133 + tksao/fitsy++/parser.Y | 292 + tksao/fitsy++/photo.C | 153 + tksao/fitsy++/photo.h | 31 + tksao/fitsy++/plio.C | 90 + tksao/fitsy++/plio.h | 19 + tksao/fitsy++/pliocomp.c | 331 + tksao/fitsy++/rice.C | 157 + tksao/fitsy++/rice.h | 24 + tksao/fitsy++/ricecomp.c | 1386 ++++ tksao/fitsy++/savefits.C | 412 ++ tksao/fitsy++/share.C | 102 + tksao/fitsy++/share.h | 98 + tksao/fitsy++/shmload.C | 84 + tksao/fitsy++/smap.C | 187 + tksao/fitsy++/smap.h | 49 + tksao/fitsy++/smmap.C | 105 + tksao/fitsy++/smmap.h | 33 + tksao/fitsy++/socket.C | 27 + tksao/fitsy++/socket.h | 51 + tksao/fitsy++/socketgz.C | 141 + tksao/fitsy++/socketgz.h | 48 + tksao/fitsy++/sshare.C | 148 + tksao/fitsy++/sshare.h | 44 + tksao/fitsy++/strm.C | 803 +++ tksao/fitsy++/strm.h | 89 + tksao/fitsy++/var.C | 53 + tksao/fitsy++/var.h | 53 + tksao/frame/annulus.C | 392 ++ tksao/frame/annulus.h | 54 + tksao/frame/base.C | 2268 ++++++ tksao/frame/base.h | 1707 +++++ tksao/frame/basebox.C | 313 + tksao/frame/basebox.h | 72 + tksao/frame/basecommand.C | 3210 +++++++++ tksao/frame/baseellipse.C | 768 ++ tksao/frame/baseellipse.h | 92 + tksao/frame/baseline.C | 124 + tksao/frame/baseline.h | 60 + tksao/frame/basemarker.C | 347 + tksao/frame/basemarker.h | 67 + tksao/frame/basepolygon.C | 314 + tksao/frame/basepolygon.h | 59 + tksao/frame/box.C | 424 ++ tksao/frame/box.h | 43 + tksao/frame/boxannulus.C | 461 ++ tksao/frame/boxannulus.h | 58 + tksao/frame/bpanda.C | 765 ++ tksao/frame/bpanda.h | 80 + tksao/frame/callback.C | 59 + tksao/frame/callback.h | 49 + tksao/frame/ciaolex.C | 1898 +++++ tksao/frame/ciaolex.L | 146 + tksao/frame/ciaoparser.C | 2031 ++++++ tksao/frame/ciaoparser.H | 118 + tksao/frame/ciaoparser.Y | 295 + tksao/frame/circle.C | 358 + tksao/frame/circle.h | 47 + tksao/frame/colorscale.C | 207 + tksao/frame/colorscale.h | 78 + tksao/frame/colorscalergb.C | 120 + tksao/frame/colorscalergb.h | 63 + tksao/frame/colorscaletrue16.C | 129 + tksao/frame/colorscaletrue16.h | 89 + tksao/frame/colorscaletrue24.C | 129 + tksao/frame/colorscaletrue24.h | 89 + tksao/frame/colorscaletrue32.C | 138 + tksao/frame/colorscaletrue32.h | 89 + tksao/frame/colorscaletrue8.C | 108 + tksao/frame/colorscaletrue8.h | 89 + tksao/frame/compass.C | 645 ++ tksao/frame/compass.h | 90 + tksao/frame/composite.C | 317 + tksao/frame/composite.h | 67 + tksao/frame/context.C | 3178 +++++++++ tksao/frame/context.h | 273 + tksao/frame/contour.C | 298 + tksao/frame/contour.h | 103 + tksao/frame/contourlex.C | 2449 +++++++ tksao/frame/contourlex.L | 244 + tksao/frame/contourparser.C | 2486 +++++++ tksao/frame/contourparser.H | 206 + tksao/frame/contourparser.Y | 434 ++ tksao/frame/coord.C | 405 ++ tksao/frame/coord.h | 54 + tksao/frame/cpanda.C | 782 +++ tksao/frame/cpanda.h | 85 + tksao/frame/ds9lex.C | 3488 ++++++++++ tksao/frame/ds9lex.L | 323 + tksao/frame/ds9parser.C | 5140 ++++++++++++++ tksao/frame/ds9parser.H | 320 + tksao/frame/ds9parser.Y | 1566 +++++ tksao/frame/ellipse.C | 388 ++ tksao/frame/ellipse.h | 42 + tksao/frame/ellipseannulus.C | 429 ++ tksao/frame/ellipseannulus.h | 59 + tksao/frame/epanda.C | 735 ++ tksao/frame/epanda.h | 79 + tksao/frame/fitsanalysis.C | 231 + tksao/frame/fitsbin.C | 307 + tksao/frame/fitsblock.C | 194 + tksao/frame/fitscompress.C | 130 + tksao/frame/fitsdata.C | 2373 +++++++ tksao/frame/fitsdata.h | 173 + tksao/frame/fitsenvi.C | 74 + tksao/frame/fitshealpix.C | 79 + tksao/frame/fitsimage.C | 4049 +++++++++++ tksao/frame/fitsimage.h | 910 +++ tksao/frame/fitsmap.C | 393 ++ tksao/frame/fitsmask.C | 50 + tksao/frame/fitsmask.h | 53 + tksao/frame/fitsnrrd.C | 47 + tksao/frame/fr3dcommand.C | 615 ++ tksao/frame/fr3dmap.C | 107 + tksao/frame/frame.C | 783 +++ tksao/frame/frame.h | 69 + tksao/frame/frame3d.C | 1329 ++++ tksao/frame/frame3d.h | 119 + tksao/frame/frame3dbase.C | 1277 ++++ tksao/frame/frame3dbase.h | 228 + tksao/frame/frame3dtruecolor16.C | 165 + tksao/frame/frame3dtruecolor16.h | 24 + tksao/frame/frame3dtruecolor24.C | 231 + tksao/frame/frame3dtruecolor24.h | 26 + tksao/frame/frame3dtruecolor8.C | 162 + tksao/frame/frame3dtruecolor8.h | 25 + tksao/frame/framebase.C | 252 + tksao/frame/framebase.h | 114 + tksao/frame/framergb.C | 1722 +++++ tksao/frame/framergb.h | 150 + tksao/frame/framergbtruecolor16.C | 114 + tksao/frame/framergbtruecolor16.h | 23 + tksao/frame/framergbtruecolor24.C | 114 + tksao/frame/framergbtruecolor24.h | 23 + tksao/frame/framergbtruecolor8.C | 113 + tksao/frame/framergbtruecolor8.h | 23 + tksao/frame/frametruecolor16.C | 165 + tksao/frame/frametruecolor16.h | 24 + tksao/frame/frametruecolor24.C | 231 + tksao/frame/frametruecolor24.h | 26 + tksao/frame/frametruecolor8.C | 160 + tksao/frame/frametruecolor8.h | 24 + tksao/frame/frblt.C | 1029 +++ tksao/frame/frcommand.C | 499 ++ tksao/frame/frload.C | 756 ++ tksao/frame/frmap.C | 161 + tksao/frame/frmarker.C | 6759 ++++++++++++++++++ tksao/frame/frmarkerxml.C | 1118 +++ tksao/frame/frsave.C | 571 ++ tksao/frame/frscale.C | 310 + tksao/frame/frscale.h | 118 + tksao/frame/fvcontour.C | 575 ++ tksao/frame/fvcontour.h | 82 + tksao/frame/grid.C | 24 + tksao/frame/grid.h | 44 + tksao/frame/grid25d.C | 141 + tksao/frame/grid25d.h | 35 + tksao/frame/grid2d.C | 157 + tksao/frame/grid2d.h | 35 + tksao/frame/grid3d.C | 214 + tksao/frame/grid3d.h | 35 + tksao/frame/inversescale.C | 204 + tksao/frame/inversescale.h | 75 + tksao/frame/lex.C | 4373 ++++++++++++ tksao/frame/lex.L | 444 ++ tksao/frame/line.C | 318 + tksao/frame/line.h | 55 + tksao/frame/marker.C | 2157 ++++++ tksao/frame/marker.h | 366 + tksao/frame/parser.C | 11193 ++++++++++++++++++++++++++++++ tksao/frame/parser.H | 747 ++ tksao/frame/parser.Y | 2875 ++++++++ tksao/frame/point.C | 942 +++ tksao/frame/point.h | 110 + tksao/frame/polygon.C | 571 ++ tksao/frame/polygon.h | 64 + tksao/frame/projection.C | 434 ++ tksao/frame/projection.h | 68 + tksao/frame/proslex.C | 2244 ++++++ tksao/frame/proslex.L | 192 + tksao/frame/prosparser.C | 2335 +++++++ tksao/frame/prosparser.H | 128 + tksao/frame/prosparser.Y | 479 ++ tksao/frame/raytrace.C | 53 + tksao/frame/raytrace.h | 36 + tksao/frame/ruler.C | 544 ++ tksao/frame/ruler.h | 73 + tksao/frame/saolex.C | 1803 +++++ tksao/frame/saolex.L | 129 + tksao/frame/saoparser.C | 2036 ++++++ tksao/frame/saoparser.H | 100 + tksao/frame/saoparser.Y | 329 + tksao/frame/segment.C | 173 + tksao/frame/segment.h | 47 + tksao/frame/sigbus.h | 44 + tksao/frame/tag.C | 37 + tksao/frame/tag.h | 33 + tksao/frame/text.C | 324 + tksao/frame/text.h | 66 + tksao/frame/tnglex.C | 2209 ++++++ tksao/frame/tnglex.L | 170 + tksao/frame/tngparser.C | 2252 ++++++ tksao/frame/tngparser.H | 156 + tksao/frame/tngparser.Y | 397 ++ tksao/frame/vect.C | 146 + tksao/frame/vect.h | 44 + tksao/frame/xml.h | 12 + tksao/frame/xylex.C | 2047 ++++++ tksao/frame/xylex.L | 130 + tksao/frame/xyparser.C | 2149 ++++++ tksao/frame/xyparser.H | 176 + tksao/frame/xyparser.Y | 275 + tksao/list/list.C | 398 ++ tksao/list/list.h | 52 + tksao/magnifier/lex.C | 1708 +++++ tksao/magnifier/lex.L | 65 + tksao/magnifier/magnifier.C | 114 + tksao/magnifier/magnifier.h | 40 + tksao/magnifier/magnifiertrue.C | 117 + tksao/magnifier/magnifiertrue.h | 18 + tksao/magnifier/parser.C | 1670 +++++ tksao/magnifier/parser.H | 109 + tksao/magnifier/parser.Y | 79 + tksao/panner/lex.C | 1832 +++++ tksao/panner/lex.L | 84 + tksao/panner/panner.C | 434 ++ tksao/panner/panner.h | 79 + tksao/panner/pannertrue.C | 119 + tksao/panner/pannertrue.h | 19 + tksao/panner/parser.C | 1923 +++++ tksao/panner/parser.H | 135 + tksao/panner/parser.Y | 154 + tksao/pkgIndex.tcl.in | 5 + tksao/saotk.C | 100 + tksao/tclconfig/ChangeLog | 980 +++ tksao/tclconfig/README.txt | 26 + tksao/tclconfig/install-sh | 528 ++ tksao/tclconfig/tcl.m4 | 4150 +++++++++++ tksao/util/FlexLexer.h | 208 + tksao/util/attribute.C | 193 + tksao/util/attribute.h | 62 + tksao/util/fdstream.hpp | 184 + tksao/util/fuzzy.h | 38 + tksao/util/grf.C | 642 ++ tksao/util/grf3d.C | 516 ++ tksao/util/grid25dbase.C | 191 + tksao/util/grid25dbase.h | 26 + tksao/util/grid2dbase.C | 175 + tksao/util/grid2dbase.h | 26 + tksao/util/grid3dbase.C | 241 + tksao/util/grid3dbase.h | 35 + tksao/util/gridbase.C | 461 ++ tksao/util/gridbase.h | 67 + tksao/util/ps.C | 377 + tksao/util/ps.h | 171 + tksao/util/smooth.C | 67 + tksao/util/smooth.h | 12 + tksao/util/util.C | 486 ++ tksao/util/util.h | 125 + tksao/vector/vector.C | 413 ++ tksao/vector/vector.h | 372 + tksao/vector/vector3d.C | 473 ++ tksao/vector/vector3d.h | 395 ++ tksao/vector/vectorold.C | 884 +++ tksao/vector/vectorold.h | 248 + tksao/wcssubs/COPYING | 460 ++ tksao/wcssubs/Files | 179 + tksao/wcssubs/Makefile | 36 + tksao/wcssubs/NEWS | 478 ++ tksao/wcssubs/Readme | 36 + tksao/wcssubs/cel.c | 474 ++ tksao/wcssubs/dateutil.c | 4554 ++++++++++++ tksao/wcssubs/distort.c | 407 ++ tksao/wcssubs/dsspos.c | 318 + tksao/wcssubs/fileutil.c | 867 +++ tksao/wcssubs/fitsfile.c | 2325 +++++++ tksao/wcssubs/fitsfile.h | 1293 ++++ tksao/wcssubs/fitshead.h | 438 ++ tksao/wcssubs/hget.c | 1921 +++++ tksao/wcssubs/hput.c | 1316 ++++ tksao/wcssubs/iget.c | 531 ++ tksao/wcssubs/imhfile.c | 1941 ++++++ tksao/wcssubs/imio.c | 1544 +++++ tksao/wcssubs/imio.h | 64 + tksao/wcssubs/lin.c | 448 ++ tksao/wcssubs/platepos.c | 391 ++ tksao/wcssubs/poly.c | 914 +++ tksao/wcssubs/proj.c | 4527 ++++++++++++ tksao/wcssubs/slasubs.c | 364 + tksao/wcssubs/sph.c | 234 + tksao/wcssubs/tnxpos.c | 1234 ++++ tksao/wcssubs/wcs.c | 2994 ++++++++ tksao/wcssubs/wcs.h | 969 +++ tksao/wcssubs/wcscon.c | 2328 +++++++ tksao/wcssubs/wcsinit.c | 1616 +++++ tksao/wcssubs/wcslib.c | 1334 ++++ tksao/wcssubs/wcslib.h | 476 ++ tksao/wcssubs/wcstrig.c | 189 + tksao/wcssubs/worldpos.c | 693 ++ tksao/wcssubs/zpxpos.c | 735 ++ tksao/widget/truecolor16.C | 148 + tksao/widget/truecolor16.h | 42 + tksao/widget/truecolor24.C | 292 + tksao/widget/truecolor24.h | 47 + tksao/widget/truecolor8.C | 71 + tksao/widget/truecolor8.h | 42 + tksao/widget/widget.C | 813 +++ tksao/widget/widget.h | 203 + 427 files changed, 243516 insertions(+) create mode 100755 tksao/Makefile.in create mode 100755 tksao/aclocal.m4 create mode 100644 tksao/colorbar/cbgrid.C create mode 100644 tksao/colorbar/cbgrid.h create mode 100644 tksao/colorbar/colorbar.C create mode 100644 tksao/colorbar/colorbar.h create mode 100644 tksao/colorbar/colorbarbase.C create mode 100644 tksao/colorbar/colorbarbase.h create mode 100644 tksao/colorbar/colorbarrgb.C create mode 100644 tksao/colorbar/colorbarrgb.h create mode 100644 tksao/colorbar/colorbarrgbtruecolor16.C create mode 100644 tksao/colorbar/colorbarrgbtruecolor16.h create mode 100644 tksao/colorbar/colorbarrgbtruecolor24.C create mode 100644 tksao/colorbar/colorbarrgbtruecolor24.h create mode 100644 tksao/colorbar/colorbarrgbtruecolor8.C create mode 100644 tksao/colorbar/colorbarrgbtruecolor8.h create mode 100644 tksao/colorbar/colorbartruecolor16.C create mode 100644 tksao/colorbar/colorbartruecolor16.h create mode 100644 tksao/colorbar/colorbartruecolor24.C create mode 100644 tksao/colorbar/colorbartruecolor24.h create mode 100644 tksao/colorbar/colorbartruecolor8.C create mode 100644 tksao/colorbar/colorbartruecolor8.h create mode 100644 tksao/colorbar/colormap.C create mode 100644 tksao/colorbar/colormap.h create mode 100644 tksao/colorbar/colortag.C create mode 100644 tksao/colorbar/colortag.h create mode 100644 tksao/colorbar/default.C create mode 100644 tksao/colorbar/default.h create mode 100644 tksao/colorbar/lex.C create mode 100644 tksao/colorbar/lex.L create mode 100644 tksao/colorbar/lut.C create mode 100644 tksao/colorbar/lut.h create mode 100644 tksao/colorbar/lutlex.C create mode 100644 tksao/colorbar/lutlex.L create mode 100644 tksao/colorbar/lutparser.C create mode 100644 tksao/colorbar/lutparser.H create mode 100644 tksao/colorbar/lutparser.Y create mode 100644 tksao/colorbar/parser.C create mode 100644 tksao/colorbar/parser.H create mode 100644 tksao/colorbar/parser.Y create mode 100644 tksao/colorbar/sao.C create mode 100644 tksao/colorbar/sao.h create mode 100644 tksao/colorbar/saolex.C create mode 100644 tksao/colorbar/saolex.L create mode 100644 tksao/colorbar/saoparser.C create mode 100644 tksao/colorbar/saoparser.H create mode 100644 tksao/colorbar/saoparser.Y create mode 100755 tksao/configure create mode 100755 tksao/configure.in create mode 100644 tksao/fitsy++/alloc.C create mode 100644 tksao/fitsy++/alloc.h create mode 100644 tksao/fitsy++/allocgz.C create mode 100644 tksao/fitsy++/allocgz.h create mode 100644 tksao/fitsy++/analysis.C create mode 100644 tksao/fitsy++/analysis.h create mode 100644 tksao/fitsy++/block.C create mode 100644 tksao/fitsy++/block.h create mode 100644 tksao/fitsy++/card.C create mode 100644 tksao/fitsy++/card.h create mode 100644 tksao/fitsy++/channel.C create mode 100644 tksao/fitsy++/channel.h create mode 100644 tksao/fitsy++/column.C create mode 100644 tksao/fitsy++/column.h create mode 100644 tksao/fitsy++/compress.C create mode 100644 tksao/fitsy++/compress.h create mode 100644 tksao/fitsy++/envi.C create mode 100644 tksao/fitsy++/envi.h create mode 100644 tksao/fitsy++/envilex.C create mode 100644 tksao/fitsy++/envilex.L create mode 100644 tksao/fitsy++/enviparser.C create mode 100644 tksao/fitsy++/enviparser.H create mode 100644 tksao/fitsy++/enviparser.Y create mode 100644 tksao/fitsy++/file.C create mode 100644 tksao/fitsy++/file.h create mode 100644 tksao/fitsy++/gzip.C create mode 100644 tksao/fitsy++/gzip.h create mode 100644 tksao/fitsy++/hcompress.C create mode 100644 tksao/fitsy++/hcompress.h create mode 100644 tksao/fitsy++/hdecompress.c create mode 100644 tksao/fitsy++/hdu.C create mode 100644 tksao/fitsy++/hdu.h create mode 100644 tksao/fitsy++/head.C create mode 100644 tksao/fitsy++/head.h create mode 100644 tksao/fitsy++/hist.C create mode 100644 tksao/fitsy++/hist.h create mode 100644 tksao/fitsy++/hpx.C create mode 100644 tksao/fitsy++/hpx.h create mode 100644 tksao/fitsy++/iis.C create mode 100644 tksao/fitsy++/iis.h create mode 100644 tksao/fitsy++/lex.C create mode 100644 tksao/fitsy++/lex.L create mode 100644 tksao/fitsy++/map.C create mode 100644 tksao/fitsy++/map.h create mode 100644 tksao/fitsy++/mapincr.C create mode 100644 tksao/fitsy++/mapincr.h create mode 100644 tksao/fitsy++/mmap.C create mode 100644 tksao/fitsy++/mmap.h create mode 100644 tksao/fitsy++/mmapincr.C create mode 100644 tksao/fitsy++/mmapincr.h create mode 100644 tksao/fitsy++/nrrd.C create mode 100644 tksao/fitsy++/nrrd.h create mode 100644 tksao/fitsy++/nrrdgzip.C create mode 100644 tksao/fitsy++/nrrdgzip.h create mode 100644 tksao/fitsy++/nrrdlex.C create mode 100644 tksao/fitsy++/nrrdlex.L create mode 100644 tksao/fitsy++/nrrdparser.C create mode 100644 tksao/fitsy++/nrrdparser.H create mode 100644 tksao/fitsy++/nrrdparser.Y create mode 100644 tksao/fitsy++/order.C create mode 100644 tksao/fitsy++/order.h create mode 100644 tksao/fitsy++/outchannel.C create mode 100644 tksao/fitsy++/outchannel.h create mode 100644 tksao/fitsy++/outfile.C create mode 100644 tksao/fitsy++/outfile.h create mode 100644 tksao/fitsy++/outfits.C create mode 100644 tksao/fitsy++/outfits.h create mode 100644 tksao/fitsy++/outsocket.C create mode 100644 tksao/fitsy++/outsocket.h create mode 100644 tksao/fitsy++/parser.C create mode 100644 tksao/fitsy++/parser.H create mode 100644 tksao/fitsy++/parser.Y create mode 100644 tksao/fitsy++/photo.C create mode 100644 tksao/fitsy++/photo.h create mode 100644 tksao/fitsy++/plio.C create mode 100644 tksao/fitsy++/plio.h create mode 100644 tksao/fitsy++/pliocomp.c create mode 100644 tksao/fitsy++/rice.C create mode 100644 tksao/fitsy++/rice.h create mode 100644 tksao/fitsy++/ricecomp.c create mode 100644 tksao/fitsy++/savefits.C create mode 100644 tksao/fitsy++/share.C create mode 100644 tksao/fitsy++/share.h create mode 100644 tksao/fitsy++/shmload.C create mode 100644 tksao/fitsy++/smap.C create mode 100644 tksao/fitsy++/smap.h create mode 100644 tksao/fitsy++/smmap.C create mode 100644 tksao/fitsy++/smmap.h create mode 100644 tksao/fitsy++/socket.C create mode 100644 tksao/fitsy++/socket.h create mode 100644 tksao/fitsy++/socketgz.C create mode 100644 tksao/fitsy++/socketgz.h create mode 100644 tksao/fitsy++/sshare.C create mode 100644 tksao/fitsy++/sshare.h create mode 100644 tksao/fitsy++/strm.C create mode 100644 tksao/fitsy++/strm.h create mode 100644 tksao/fitsy++/var.C create mode 100644 tksao/fitsy++/var.h create mode 100644 tksao/frame/annulus.C create mode 100644 tksao/frame/annulus.h create mode 100644 tksao/frame/base.C create mode 100644 tksao/frame/base.h create mode 100644 tksao/frame/basebox.C create mode 100644 tksao/frame/basebox.h create mode 100644 tksao/frame/basecommand.C create mode 100644 tksao/frame/baseellipse.C create mode 100644 tksao/frame/baseellipse.h create mode 100644 tksao/frame/baseline.C create mode 100644 tksao/frame/baseline.h create mode 100644 tksao/frame/basemarker.C create mode 100644 tksao/frame/basemarker.h create mode 100644 tksao/frame/basepolygon.C create mode 100644 tksao/frame/basepolygon.h create mode 100644 tksao/frame/box.C create mode 100644 tksao/frame/box.h create mode 100644 tksao/frame/boxannulus.C create mode 100644 tksao/frame/boxannulus.h create mode 100644 tksao/frame/bpanda.C create mode 100644 tksao/frame/bpanda.h create mode 100644 tksao/frame/callback.C create mode 100644 tksao/frame/callback.h create mode 100644 tksao/frame/ciaolex.C create mode 100644 tksao/frame/ciaolex.L create mode 100644 tksao/frame/ciaoparser.C create mode 100644 tksao/frame/ciaoparser.H create mode 100644 tksao/frame/ciaoparser.Y create mode 100644 tksao/frame/circle.C create mode 100644 tksao/frame/circle.h create mode 100644 tksao/frame/colorscale.C create mode 100644 tksao/frame/colorscale.h create mode 100644 tksao/frame/colorscalergb.C create mode 100644 tksao/frame/colorscalergb.h create mode 100644 tksao/frame/colorscaletrue16.C create mode 100644 tksao/frame/colorscaletrue16.h create mode 100644 tksao/frame/colorscaletrue24.C create mode 100644 tksao/frame/colorscaletrue24.h create mode 100644 tksao/frame/colorscaletrue32.C create mode 100644 tksao/frame/colorscaletrue32.h create mode 100644 tksao/frame/colorscaletrue8.C create mode 100644 tksao/frame/colorscaletrue8.h create mode 100644 tksao/frame/compass.C create mode 100644 tksao/frame/compass.h create mode 100644 tksao/frame/composite.C create mode 100644 tksao/frame/composite.h create mode 100644 tksao/frame/context.C create mode 100644 tksao/frame/context.h create mode 100644 tksao/frame/contour.C create mode 100644 tksao/frame/contour.h create mode 100644 tksao/frame/contourlex.C create mode 100644 tksao/frame/contourlex.L create mode 100644 tksao/frame/contourparser.C create mode 100644 tksao/frame/contourparser.H create mode 100644 tksao/frame/contourparser.Y create mode 100644 tksao/frame/coord.C create mode 100644 tksao/frame/coord.h create mode 100644 tksao/frame/cpanda.C create mode 100644 tksao/frame/cpanda.h create mode 100644 tksao/frame/ds9lex.C create mode 100644 tksao/frame/ds9lex.L create mode 100644 tksao/frame/ds9parser.C create mode 100644 tksao/frame/ds9parser.H create mode 100644 tksao/frame/ds9parser.Y create mode 100644 tksao/frame/ellipse.C create mode 100644 tksao/frame/ellipse.h create mode 100644 tksao/frame/ellipseannulus.C create mode 100644 tksao/frame/ellipseannulus.h create mode 100644 tksao/frame/epanda.C create mode 100644 tksao/frame/epanda.h create mode 100644 tksao/frame/fitsanalysis.C create mode 100644 tksao/frame/fitsbin.C create mode 100644 tksao/frame/fitsblock.C create mode 100644 tksao/frame/fitscompress.C create mode 100644 tksao/frame/fitsdata.C create mode 100644 tksao/frame/fitsdata.h create mode 100644 tksao/frame/fitsenvi.C create mode 100644 tksao/frame/fitshealpix.C create mode 100644 tksao/frame/fitsimage.C create mode 100644 tksao/frame/fitsimage.h create mode 100644 tksao/frame/fitsmap.C create mode 100644 tksao/frame/fitsmask.C create mode 100644 tksao/frame/fitsmask.h create mode 100644 tksao/frame/fitsnrrd.C create mode 100644 tksao/frame/fr3dcommand.C create mode 100644 tksao/frame/fr3dmap.C create mode 100644 tksao/frame/frame.C create mode 100644 tksao/frame/frame.h create mode 100644 tksao/frame/frame3d.C create mode 100644 tksao/frame/frame3d.h create mode 100644 tksao/frame/frame3dbase.C create mode 100644 tksao/frame/frame3dbase.h create mode 100644 tksao/frame/frame3dtruecolor16.C create mode 100644 tksao/frame/frame3dtruecolor16.h create mode 100644 tksao/frame/frame3dtruecolor24.C create mode 100644 tksao/frame/frame3dtruecolor24.h create mode 100644 tksao/frame/frame3dtruecolor8.C create mode 100644 tksao/frame/frame3dtruecolor8.h create mode 100644 tksao/frame/framebase.C create mode 100644 tksao/frame/framebase.h create mode 100644 tksao/frame/framergb.C create mode 100644 tksao/frame/framergb.h create mode 100644 tksao/frame/framergbtruecolor16.C create mode 100644 tksao/frame/framergbtruecolor16.h create mode 100644 tksao/frame/framergbtruecolor24.C create mode 100644 tksao/frame/framergbtruecolor24.h create mode 100644 tksao/frame/framergbtruecolor8.C create mode 100644 tksao/frame/framergbtruecolor8.h create mode 100644 tksao/frame/frametruecolor16.C create mode 100644 tksao/frame/frametruecolor16.h create mode 100644 tksao/frame/frametruecolor24.C create mode 100644 tksao/frame/frametruecolor24.h create mode 100644 tksao/frame/frametruecolor8.C create mode 100644 tksao/frame/frametruecolor8.h create mode 100644 tksao/frame/frblt.C create mode 100644 tksao/frame/frcommand.C create mode 100644 tksao/frame/frload.C create mode 100644 tksao/frame/frmap.C create mode 100644 tksao/frame/frmarker.C create mode 100644 tksao/frame/frmarkerxml.C create mode 100644 tksao/frame/frsave.C create mode 100644 tksao/frame/frscale.C create mode 100644 tksao/frame/frscale.h create mode 100644 tksao/frame/fvcontour.C create mode 100644 tksao/frame/fvcontour.h create mode 100644 tksao/frame/grid.C create mode 100644 tksao/frame/grid.h create mode 100644 tksao/frame/grid25d.C create mode 100644 tksao/frame/grid25d.h create mode 100644 tksao/frame/grid2d.C create mode 100644 tksao/frame/grid2d.h create mode 100644 tksao/frame/grid3d.C create mode 100644 tksao/frame/grid3d.h create mode 100644 tksao/frame/inversescale.C create mode 100644 tksao/frame/inversescale.h create mode 100644 tksao/frame/lex.C create mode 100644 tksao/frame/lex.L create mode 100644 tksao/frame/line.C create mode 100644 tksao/frame/line.h create mode 100644 tksao/frame/marker.C create mode 100644 tksao/frame/marker.h create mode 100644 tksao/frame/parser.C create mode 100644 tksao/frame/parser.H create mode 100644 tksao/frame/parser.Y create mode 100644 tksao/frame/point.C create mode 100644 tksao/frame/point.h create mode 100644 tksao/frame/polygon.C create mode 100644 tksao/frame/polygon.h create mode 100644 tksao/frame/projection.C create mode 100644 tksao/frame/projection.h create mode 100644 tksao/frame/proslex.C create mode 100644 tksao/frame/proslex.L create mode 100644 tksao/frame/prosparser.C create mode 100644 tksao/frame/prosparser.H create mode 100644 tksao/frame/prosparser.Y create mode 100644 tksao/frame/raytrace.C create mode 100644 tksao/frame/raytrace.h create mode 100644 tksao/frame/ruler.C create mode 100644 tksao/frame/ruler.h create mode 100644 tksao/frame/saolex.C create mode 100644 tksao/frame/saolex.L create mode 100644 tksao/frame/saoparser.C create mode 100644 tksao/frame/saoparser.H create mode 100644 tksao/frame/saoparser.Y create mode 100644 tksao/frame/segment.C create mode 100644 tksao/frame/segment.h create mode 100644 tksao/frame/sigbus.h create mode 100644 tksao/frame/tag.C create mode 100644 tksao/frame/tag.h create mode 100644 tksao/frame/text.C create mode 100644 tksao/frame/text.h create mode 100644 tksao/frame/tnglex.C create mode 100644 tksao/frame/tnglex.L create mode 100644 tksao/frame/tngparser.C create mode 100644 tksao/frame/tngparser.H create mode 100644 tksao/frame/tngparser.Y create mode 100644 tksao/frame/vect.C create mode 100644 tksao/frame/vect.h create mode 100644 tksao/frame/xml.h create mode 100644 tksao/frame/xylex.C create mode 100644 tksao/frame/xylex.L create mode 100644 tksao/frame/xyparser.C create mode 100644 tksao/frame/xyparser.H create mode 100644 tksao/frame/xyparser.Y create mode 100644 tksao/list/list.C create mode 100644 tksao/list/list.h create mode 100644 tksao/magnifier/lex.C create mode 100644 tksao/magnifier/lex.L create mode 100644 tksao/magnifier/magnifier.C create mode 100644 tksao/magnifier/magnifier.h create mode 100644 tksao/magnifier/magnifiertrue.C create mode 100644 tksao/magnifier/magnifiertrue.h create mode 100644 tksao/magnifier/parser.C create mode 100644 tksao/magnifier/parser.H create mode 100644 tksao/magnifier/parser.Y create mode 100644 tksao/panner/lex.C create mode 100644 tksao/panner/lex.L create mode 100644 tksao/panner/panner.C create mode 100644 tksao/panner/panner.h create mode 100644 tksao/panner/pannertrue.C create mode 100644 tksao/panner/pannertrue.h create mode 100644 tksao/panner/parser.C create mode 100644 tksao/panner/parser.H create mode 100644 tksao/panner/parser.Y create mode 100755 tksao/pkgIndex.tcl.in create mode 100644 tksao/saotk.C create mode 100644 tksao/tclconfig/ChangeLog create mode 100644 tksao/tclconfig/README.txt create mode 100755 tksao/tclconfig/install-sh create mode 100644 tksao/tclconfig/tcl.m4 create mode 100644 tksao/util/FlexLexer.h create mode 100644 tksao/util/attribute.C create mode 100644 tksao/util/attribute.h create mode 100644 tksao/util/fdstream.hpp create mode 100644 tksao/util/fuzzy.h create mode 100644 tksao/util/grf.C create mode 100644 tksao/util/grf3d.C create mode 100644 tksao/util/grid25dbase.C create mode 100644 tksao/util/grid25dbase.h create mode 100644 tksao/util/grid2dbase.C create mode 100644 tksao/util/grid2dbase.h create mode 100644 tksao/util/grid3dbase.C create mode 100644 tksao/util/grid3dbase.h create mode 100644 tksao/util/gridbase.C create mode 100644 tksao/util/gridbase.h create mode 100644 tksao/util/ps.C create mode 100644 tksao/util/ps.h create mode 100644 tksao/util/smooth.C create mode 100644 tksao/util/smooth.h create mode 100644 tksao/util/util.C create mode 100644 tksao/util/util.h create mode 100644 tksao/vector/vector.C create mode 100644 tksao/vector/vector.h create mode 100644 tksao/vector/vector3d.C create mode 100644 tksao/vector/vector3d.h create mode 100644 tksao/vector/vectorold.C create mode 100644 tksao/vector/vectorold.h create mode 100644 tksao/wcssubs/COPYING create mode 100644 tksao/wcssubs/Files create mode 100644 tksao/wcssubs/Makefile create mode 100644 tksao/wcssubs/NEWS create mode 100644 tksao/wcssubs/Readme create mode 100644 tksao/wcssubs/cel.c create mode 100644 tksao/wcssubs/dateutil.c create mode 100644 tksao/wcssubs/distort.c create mode 100644 tksao/wcssubs/dsspos.c create mode 100644 tksao/wcssubs/fileutil.c create mode 100644 tksao/wcssubs/fitsfile.c create mode 100644 tksao/wcssubs/fitsfile.h create mode 100644 tksao/wcssubs/fitshead.h create mode 100644 tksao/wcssubs/hget.c create mode 100644 tksao/wcssubs/hput.c create mode 100644 tksao/wcssubs/iget.c create mode 100644 tksao/wcssubs/imhfile.c create mode 100644 tksao/wcssubs/imio.c create mode 100644 tksao/wcssubs/imio.h create mode 100644 tksao/wcssubs/lin.c create mode 100644 tksao/wcssubs/platepos.c create mode 100644 tksao/wcssubs/poly.c create mode 100644 tksao/wcssubs/proj.c create mode 100644 tksao/wcssubs/slasubs.c create mode 100644 tksao/wcssubs/sph.c create mode 100644 tksao/wcssubs/tnxpos.c create mode 100644 tksao/wcssubs/wcs.c create mode 100644 tksao/wcssubs/wcs.h create mode 100644 tksao/wcssubs/wcscon.c create mode 100644 tksao/wcssubs/wcsinit.c create mode 100644 tksao/wcssubs/wcslib.c create mode 100644 tksao/wcssubs/wcslib.h create mode 100644 tksao/wcssubs/wcstrig.c create mode 100644 tksao/wcssubs/worldpos.c create mode 100644 tksao/wcssubs/zpxpos.c create mode 100644 tksao/widget/truecolor16.C create mode 100644 tksao/widget/truecolor16.h create mode 100644 tksao/widget/truecolor24.C create mode 100644 tksao/widget/truecolor24.h create mode 100644 tksao/widget/truecolor8.C create mode 100644 tksao/widget/truecolor8.h create mode 100644 tksao/widget/widget.C create mode 100644 tksao/widget/widget.h diff --git a/tksao/Makefile.in b/tksao/Makefile.in new file mode 100755 index 0000000..3478050 --- /dev/null +++ b/tksao/Makefile.in @@ -0,0 +1,524 @@ +# Makefile.in -- +# +# This file is a Makefile for Sample TEA Extension. If it has the name +# "Makefile.in" then it is a template for a Makefile; to generate the +# actual Makefile, run "./configure", which is a configuration script +# generated by the "autoconf" program (constructs like "@foo@" will get +# replaced in the actual Makefile. +# +# Copyright (c) 1999 Scriptics Corporation. +# Copyright (c) 2002-2005 ActiveState Corporation. +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. + +#======================================================================== +# Add additional lines to handle any additional AC_SUBST cases that +# have been added in a customized configure script. +#======================================================================== + +#SAMPLE_NEW_VAR = @SAMPLE_NEW_VAR@ + +#======================================================================== +# Nothing of the variables below this line should need to be changed. +# Please check the TARGETS section below to make sure the make targets +# are correct. +#======================================================================== + +#======================================================================== +# The names of the source files is defined in the configure script. +# The object files are used for linking into the final library. +# This will be used when a dist target is added to the Makefile. +# It is not important to specify the directory, as long as it is the +# $(srcdir) or in the generic, win or unix subdirectory. +#======================================================================== + +PKG_SOURCES = @PKG_SOURCES@ +PKG_OBJECTS = @PKG_OBJECTS@ + +PKG_STUB_SOURCES = @PKG_STUB_SOURCES@ +PKG_STUB_OBJECTS = @PKG_STUB_OBJECTS@ + +#======================================================================== +# PKG_TCL_SOURCES identifies Tcl runtime files that are associated with +# this package that need to be installed, if any. +#======================================================================== + +PKG_TCL_SOURCES = @PKG_TCL_SOURCES@ + +#======================================================================== +# This is a list of public header files to be installed, if any. +#======================================================================== + +PKG_HEADERS = @PKG_HEADERS@ + +#======================================================================== +# "PKG_LIB_FILE" refers to the library (dynamic or static as per +# configuration options) composed of the named objects. +#======================================================================== + +PKG_LIB_FILE = @PKG_LIB_FILE@ +PKG_STUB_LIB_FILE = @PKG_STUB_LIB_FILE@ + +lib_BINARIES = $(PKG_LIB_FILE) +BINARIES = $(lib_BINARIES) + +SHELL = @SHELL@ + +srcdir = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +libdir = @libdir@ +includedir = @includedir@ +datarootdir = @datarootdir@ +datadir = @datadir@ +mandir = @mandir@ + +DESTDIR = + +PKG_DIR = $(PACKAGE_NAME)$(PACKAGE_VERSION) +pkgdatadir = $(datadir)/$(PKG_DIR) +pkglibdir = $(libdir)/$(PKG_DIR) +pkgincludedir = $(includedir)/$(PKG_DIR) + +top_builddir = . + +INSTALL_OPTIONS = +INSTALL = $(SHELL) $(srcdir)/tclconfig/install-sh -c ${INSTALL_OPTIONS} +INSTALL_DATA_DIR = ${INSTALL} -d -m 755 +INSTALL_PROGRAM = ${INSTALL} -m 555 +INSTALL_DATA = ${INSTALL} -m 444 +INSTALL_SCRIPT = ${INSTALL_PROGRAM} +INSTALL_LIBRARY = ${INSTALL} -m 644 + +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +CC = @CC@ +CFLAGS_DEFAULT = @CFLAGS_DEFAULT@ +CFLAGS_WARNING = @CFLAGS_WARNING@ +EXEEXT = @EXEEXT@ +LDFLAGS_DEFAULT = @LDFLAGS_DEFAULT@ +MAKE_LIB = @MAKE_LIB@ +MAKE_SHARED_LIB = @MAKE_SHARED_LIB@ +MAKE_STATIC_LIB = @MAKE_STATIC_LIB@ +MAKE_STUB_LIB = @MAKE_STUB_LIB@ +OBJEXT = @OBJEXT@ +RANLIB = @RANLIB@ +RANLIB_STUB = @RANLIB_STUB@ +SHLIB_CFLAGS = @SHLIB_CFLAGS@ +SHLIB_LD = @SHLIB_LD@ +SHLIB_LD_LIBS = @SHLIB_LD_LIBS@ +STLIB_LD = @STLIB_LD@ +#TCL_DEFS = @TCL_DEFS@ +TCL_BIN_DIR = @TCL_BIN_DIR@ +TCL_SRC_DIR = @TCL_SRC_DIR@ +#TK_BIN_DIR = @TK_BIN_DIR@ +#TK_SRC_DIR = @TK_SRC_DIR@ + +# Not used, but retained for reference of what libs Tcl required +#TCL_LIBS = @TCL_LIBS@ + +#======================================================================== +# TCLLIBPATH seeds the auto_path in Tcl's init.tcl so we can test our +# package without installing. The other environment variables allow us +# to test against an uninstalled Tcl. Add special env vars that you +# require for testing here (like TCLX_LIBRARY). +#======================================================================== + +EXTRA_PATH = $(top_builddir):$(TCL_BIN_DIR) +#EXTRA_PATH = $(top_builddir):$(TCL_BIN_DIR):$(TK_BIN_DIR) +TCLLIBPATH = $(top_builddir) +TCLSH_ENV = TCL_LIBRARY=`@CYGPATH@ $(TCL_SRC_DIR)/library` +PKG_ENV = @LD_LIBRARY_PATH_VAR@="$(EXTRA_PATH):$(@LD_LIBRARY_PATH_VAR@)" \ + PATH="$(EXTRA_PATH):$(PATH)" \ + TCLLIBPATH="$(TCLLIBPATH)" + +TCLSH_PROG = @TCLSH_PROG@ +TCLSH = $(PKG_ENV) $(TCLSH_ENV) $(TCLSH_PROG) + +#WISH_ENV = TK_LIBRARY=`@CYGPATH@ $(TK_SRC_DIR)/library` +#WISH_PROG = @WISH_PROG@ +#WISH = $(PKG_ENV) $(TCLSH_ENV) $(WISH_ENV) $(WISH_PROG) + +SHARED_BUILD = @SHARED_BUILD@ + +#INCLUDES = @PKG_INCLUDES@ @TCL_INCLUDES@ +INCLUDES = @PKG_INCLUDES@ @TCL_INCLUDES@ @TK_INCLUDES@ @TK_XINCLUDES@ + +PKG_CFLAGS = @PKG_CFLAGS@ + +# TCL_DEFS is not strictly need here, but if you remove it, then you +# must make sure that configure.in checks for the necessary components +# that your library may use. TCL_DEFS can actually be a problem if +# you do not compile with a similar machine setup as the Tcl core was +# compiled with. +#DEFS = $(TCL_DEFS) @DEFS@ $(PKG_CFLAGS) +DEFS = @DEFS@ $(PKG_CFLAGS) + +# Move pkgIndex.tcl to 'BINARIES' var if it is generated in the Makefile +CONFIG_CLEAN_FILES = Makefile pkgIndex.tcl +CLEANFILES = @CLEANFILES@ + +CPPFLAGS = @CPPFLAGS@ +LIBS = @PKG_LIBS@ @LIBS@ +AR = @AR@ +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) + +.SUFFIXES: .c .C .$(OBJEXT) + +#======================================================================== +# Start of user-definable TARGETS section +#======================================================================== + +#======================================================================== +# TEA TARGETS. Please note that the "libraries:" target refers to platform +# independent files, and the "binaries:" target includes executable programs and +# platform-dependent libraries. Modify these targets so that they install +# the various pieces of your package. The make and install rules +# for the BINARIES that you specified above have already been done. +#======================================================================== + +all: binaries libraries #doc + +#======================================================================== +# The binaries target builds executable programs, Windows .dll's, unix +# shared/static libraries, and any other platform-dependent files. +# The list of targets to build for "binaries:" is specified at the top +# of the Makefile, in the "BINARIES" variable. +#======================================================================== + +binaries: $(BINARIES) + +libraries: + +parsers : cbparsers fitsyparsers frparsers magparser panparser + +cbparsers : cbparser cblutparser cbsaoparser + +fitsyparsers : fitsyparser nrrdparser enviparser + +frparsers : parser ciaoparser ds9parser prosparser saoparser tngparser xyparser contourparser + +cbparser : + bison -d -p cb -o colorbar/parser.C colorbar/parser.Y + flex -Pcb -ocolorbar/lex.C colorbar/lex.L + +cblutparser: + bison -d -p rgb -o colorbar/lutparser.C colorbar/lutparser.Y + flex -Prgb -ocolorbar/lutlex.C colorbar/lutlex.L + +cbsaoparser: + bison -d -p li -o colorbar/saoparser.C colorbar/saoparser.Y + flex -Pli -ocolorbar/saolex.C colorbar/saolex.L + +fitsyparser : + bison -d -p ff -o fitsy++/parser.C fitsy++/parser.Y + flex -Pff -ofitsy++/lex.C fitsy++/lex.L + +nrrdparser : + bison -d -p nrrd -o fitsy++/nrrdparser.C fitsy++/nrrdparser.Y + flex -Pnrrd -ofitsy++/nrrdlex.C fitsy++/nrrdlex.L + +enviparser : + bison -d -p envi -o fitsy++/enviparser.C fitsy++/enviparser.Y + flex -Penvi -ofitsy++/envilex.C fitsy++/envilex.L + +ciaoparser : + bison -d -p ciao -o frame/ciaoparser.C frame/ciaoparser.Y + flex -Pciao -oframe/ciaolex.C frame/ciaolex.L + +ds9parser : + bison -d -p mk -o frame/ds9parser.C frame/ds9parser.Y + flex -Pmk -oframe/ds9lex.C frame/ds9lex.L + +parser : + bison -d -p fr -o frame/parser.C frame/parser.Y + flex -Pfr -oframe/lex.C frame/lex.L + +prosparser : + bison -d -p pros -o frame/prosparser.C frame/prosparser.Y + flex -Ppros -oframe/proslex.C frame/proslex.L + +saoparser : + bison -d -p sao -o frame/saoparser.C frame/saoparser.Y + flex -Psao -oframe/saolex.C frame/saolex.L + +tngparser : + bison -d -p tng -o frame/tngparser.C frame/tngparser.Y + flex -Ptng -oframe/tnglex.C frame/tnglex.L + +xyparser : + bison -d -p xy -o frame/xyparser.C frame/xyparser.Y + flex -Pxy -oframe/xylex.C frame/xylex.L + +contourparser : + bison -d -p ct -o frame/contourparser.C frame/contourparser.Y + flex -Pct -oframe/contourlex.C frame/contourlex.L + +magparser : + bison -d -p mg -o magnifier/parser.C magnifier/parser.Y + flex -Pmg -omagnifier/lex.C magnifier/lex.L + +panparser : + bison -d -p pn -o panner/parser.C panner/parser.Y + flex -Ppn -opanner/lex.C panner/lex.L + +#======================================================================== +# Your doc target should differentiate from doc builds (by the developer) +# and doc installs (see install-doc), which just install the docs on the +# end user machine when building from source. +#======================================================================== + +doc: + @echo "If you have documentation to create, place the commands to" + @echo "build the docs in the 'doc:' target. For example:" + @echo " xml2nroff sample.xml > sample.n" + @echo " xml2html sample.xml > sample.html" + +install: all install-binaries install-libraries #install-doc + +install-binaries: binaries install-lib-binaries install-bin-binaries + +#======================================================================== +# This rule installs platform-independent files, such as header files. +# The list=...; for p in $$list handles the empty list case x-platform. +#======================================================================== + +install-libraries: libraries + @$(INSTALL_DATA_DIR) $(DESTDIR)$(includedir) + @echo "Installing header files in $(DESTDIR)$(includedir)" + @list='$(PKG_HEADERS)'; for i in $$list; do \ + echo "Installing $(srcdir)/$$i" ; \ + $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir) ; \ + done; + +#======================================================================== +# Install documentation. Unix manpages should go in the $(mandir) +# directory. +#======================================================================== + +install-doc: doc + @$(INSTALL_DATA_DIR) $(DESTDIR)$(mandir)/mann + @echo "Installing documentation in $(DESTDIR)$(mandir)" + @list='$(srcdir)/doc/*.n'; for i in $$list; do \ + echo "Installing $$i"; \ + $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/mann ; \ + done + +test: binaries libraries + $(TCLSH) `@CYGPATH@ $(srcdir)/tests/all.tcl` $(TESTFLAGS) \ + -load "package ifneeded ${PACKAGE_NAME} ${PACKAGE_VERSION} \ + [list load `@CYGPATH@ $(PKG_LIB_FILE)` $(PACKAGE_NAME)]" + +shell: binaries libraries + @$(TCLSH) $(SCRIPT) + +gdb: + $(TCLSH_ENV) gdb $(TCLSH_PROG) $(SCRIPT) + +VALGRINDARGS = --tool=memcheck --num-callers=8 --leak-resolution=high \ + --leak-check=yes --show-reachable=yes -v + +valgrind: binaries libraries + $(TCLSH_ENV) valgrind $(VALGRINDARGS) $(TCLSH_PROG) \ + `@CYGPATH@ $(srcdir)/tests/all.tcl` $(TESTFLAGS) + +valgrindshell: binaries libraries + $(TCLSH_ENV) valgrind $(VALGRINDARGS) $(TCLSH_PROG) $(SCRIPT) + +depend: + +#======================================================================== +# $(PKG_LIB_FILE) should be listed as part of the BINARIES variable +# mentioned above. That will ensure that this target is built when you +# run "make binaries". +# +# The $(PKG_OBJECTS) objects are created and linked into the final +# library. In most cases these object files will correspond to the +# source files above. +#======================================================================== + +$(PKG_LIB_FILE): $(PKG_OBJECTS) + -rm -f $(PKG_LIB_FILE) + ${MAKE_LIB} + $(RANLIB) $(PKG_LIB_FILE) + +$(PKG_STUB_LIB_FILE): $(PKG_STUB_OBJECTS) + -rm -f $(PKG_STUB_LIB_FILE) + ${MAKE_STUB_LIB} + $(RANLIB_STUB) $(PKG_STUB_LIB_FILE) + +#======================================================================== +# We need to enumerate the list of .c to .o lines here. +# +# In the following lines, $(srcdir) refers to the toplevel directory +# containing your extension. If your sources are in a subdirectory, +# you will have to modify the paths to reflect this: +# +# sample.$(OBJEXT): $(srcdir)/generic/sample.c +# $(COMPILE) -c `@CYGPATH@ $(srcdir)/generic/sample.c` -o $@ +# +# Setting the VPATH variable to a list of paths will cause the makefile +# to look into these paths when resolving .c to .obj dependencies. +# As necessary, add $(srcdir):$(srcdir)/compat:.... +#======================================================================== + +VPATH = $(srcdir):$(srcdir)/generic:$(srcdir)/unix:$(srcdir)/win:$(srcdir)/macosx + +.c.@OBJEXT@: + $(COMPILE) -c `@CYGPATH@ $<` -o $@ + +.C.@OBJEXT@: + $(COMPILE) -c `@CYGPATH@ $<` -o $@ + +#======================================================================== +# Distribution creation +# You may need to tweak this target to make it work correctly. +#======================================================================== + +#COMPRESS = tar cvf $(PKG_DIR).tar $(PKG_DIR); compress $(PKG_DIR).tar +COMPRESS = tar zcvf $(PKG_DIR).tar.gz $(PKG_DIR) +DIST_ROOT = /tmp/dist +DIST_DIR = $(DIST_ROOT)/$(PKG_DIR) + +dist-clean: + rm -rf $(DIST_DIR) $(DIST_ROOT)/$(PKG_DIR).tar.* + +dist: dist-clean + $(INSTALL_DATA_DIR) $(DIST_DIR) + cp -p $(srcdir)/ChangeLog $(srcdir)/README* $(srcdir)/license* \ + $(srcdir)/aclocal.m4 $(srcdir)/configure $(srcdir)/*.in \ + $(DIST_DIR)/ + chmod 664 $(DIST_DIR)/Makefile.in $(DIST_DIR)/aclocal.m4 + chmod 775 $(DIST_DIR)/configure $(DIST_DIR)/configure.in + + for i in $(srcdir)/*.[ch]; do \ + if [ -f $$i ]; then \ + cp -p $$i $(DIST_DIR)/ ; \ + fi; \ + done; + + $(INSTALL_DATA_DIR) $(DIST_DIR)/tclconfig + cp $(srcdir)/tclconfig/install-sh $(srcdir)/tclconfig/tcl.m4 \ + $(DIST_DIR)/tclconfig/ + chmod 664 $(DIST_DIR)/tclconfig/tcl.m4 + chmod +x $(DIST_DIR)/tclconfig/install-sh + + list='demos doc generic library mac tests unix win'; \ + for p in $$list; do \ + if test -d $(srcdir)/$$p ; then \ + $(INSTALL_DATA_DIR) $(DIST_DIR)/$$p; \ + cp -p $(srcdir)/$$p/*.* $(DIST_DIR)/$$p/; \ + fi; \ + done + + (cd $(DIST_ROOT); $(COMPRESS);) + +#======================================================================== +# End of user-definable section +#======================================================================== + +#======================================================================== +# Don't modify the file to clean here. Instead, set the "CLEANFILES" +# variable in configure.in +#======================================================================== + +clean: + -test -z "$(BINARIES)" || rm -f $(BINARIES) + -rm -f $(PKG_OBJECTS) *.$(OBJEXT) core *.core + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean: clean + -rm -f *.tab.c + -rm -f $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log config.status + +#======================================================================== +# Install binary object libraries. On Windows this includes both .dll and +# .lib files. Because the .lib files are not explicitly listed anywhere, +# we need to deduce their existence from the .dll file of the same name. +# Library files go into the lib directory. +# In addition, this will generate the pkgIndex.tcl +# file in the install location (assuming it can find a usable tclsh shell) +# +# You should not have to modify this target. +#======================================================================== + +install-lib-binaries: binaries + @$(INSTALL_DATA_DIR) $(DESTDIR)$(pkglibdir) + @list='$(lib_BINARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_LIBRARY) $$p $(DESTDIR)$(pkglibdir)/$$p"; \ + $(INSTALL_LIBRARY) $$p $(DESTDIR)$(pkglibdir)/$$p; \ + stub=`echo $$p|sed -e "s/.*\(stub\).*/\1/"`; \ + if test "x$$stub" = "xstub"; then \ + echo " $(RANLIB_STUB) $(DESTDIR)$(pkglibdir)/$$p"; \ + $(RANLIB_STUB) $(DESTDIR)$(pkglibdir)/$$p; \ + else \ + echo " $(RANLIB) $(DESTDIR)$(pkglibdir)/$$p"; \ + $(RANLIB) $(DESTDIR)$(pkglibdir)/$$p; \ + fi; \ + ext=`echo $$p|sed -e "s/.*\.//"`; \ + if test "x$$ext" = "xdll"; then \ + lib=`basename $$p|sed -e 's/.[^.]*$$//'`.lib; \ + if test -f $$lib; then \ + echo " $(INSTALL_DATA) $$lib $(DESTDIR)$(pkglibdir)/$$lib"; \ + $(INSTALL_DATA) $$lib $(DESTDIR)$(pkglibdir)/$$lib; \ + fi; \ + fi; \ + fi; \ + done + @list='$(PKG_TCL_SOURCES)'; for p in $$list; do \ + if test -f $(srcdir)/$$p; then \ + destp=`basename $$p`; \ + echo " Install $$destp $(DESTDIR)$(pkglibdir)/$$destp"; \ + $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkglibdir)/$$destp; \ + fi; \ + done + @if test "x$(SHARED_BUILD)" = "x1"; then \ + echo " Install pkgIndex.tcl $(DESTDIR)$(pkglibdir)"; \ + $(INSTALL_DATA) pkgIndex.tcl $(DESTDIR)$(pkglibdir); \ + fi + +#======================================================================== +# Install binary executables (e.g. .exe files and dependent .dll files) +# This is for files that must go in the bin directory (located next to +# wish and tclsh), like dependent .dll files on Windows. +# +# You should not have to modify this target, except to define bin_BINARIES +# above if necessary. +#======================================================================== + +install-bin-binaries: binaries + @$(INSTALL_DATA_DIR) $(DESTDIR)$(bindir) + @list='$(bin_BINARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$p"; \ + $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$p; \ + fi; \ + done + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status + +uninstall-binaries: + list='$(lib_BINARIES)'; for p in $$list; do \ + rm -f $(DESTDIR)$(pkglibdir)/$$p; \ + done + list='$(PKG_TCL_SOURCES)'; for p in $$list; do \ + p=`basename $$p`; \ + rm -f $(DESTDIR)$(pkglibdir)/$$p; \ + done + list='$(bin_BINARIES)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/$$p; \ + done + +.PHONY: all binaries clean depend distclean doc install libraries test + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/tksao/aclocal.m4 b/tksao/aclocal.m4 new file mode 100755 index 0000000..0b05739 --- /dev/null +++ b/tksao/aclocal.m4 @@ -0,0 +1,9 @@ +# +# Include the TEA standard macro set +# + +builtin(include,tclconfig/tcl.m4) + +# +# Add here whatever m4 macros you want to define for your package +# diff --git a/tksao/colorbar/cbgrid.C b/tksao/colorbar/cbgrid.C new file mode 100644 index 0000000..48bfb52 --- /dev/null +++ b/tksao/colorbar/cbgrid.C @@ -0,0 +1,210 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "cbgrid.h" +#include "colorbarbase.h" +#include "util.h" + +extern "C" { + #include "ast.h" +} + +extern Grid2dBase* astGrid2dPtr; + +CBGrid::CBGrid(Widget* p, int cc, double* ll) + : Grid2dBase(p), cnt_(cc), lut_(ll) +{ + ColorbarBaseOptions* opts = + (ColorbarBaseOptions*)(((ColorbarBase*)parent_)->options); + + ostringstream str; + + // basics + str << "Grid=0, DrawAxes=0, MinTickLen(1)=0, MinTickLen(2)=0, Colour(ticks)=0, Width(ticks)=.5, Style(ticks)=0, Border=1, Colour(border)=0, Width(border)=.5, Style(border)=0, Labelling=exterior, Colour(numlab)=0, TextLab=0, DrawTitle=0"; + + if (!opts->orientation) { + // horizontal + str << ", Edge(1)=top, Edge(2)=left, LabelUp(1)=1, MajTickLen(1)=-.15, MajTickLen(2)=0, NumLab(1)=1, NumLab(2)=0, NumLabGap(1)=.5"; + } + else { + // vertical + str << ", Edge(1)=bottom, Edge(2)=right, LabelUp(2)=1, MajTickLen(1)=0, MajTickLen(2)=-.15, NumLab(1)=0, NumLab(2)=1, NumLabGap(2)=.5"; + } + + // font + { + char* fn = opts->font; + int fz = opts->fontSize; + char* fw = opts->fontWeight; + char* fs = opts->fontSlant; + int ff; + if (!(strncmp(fn,"times",4) || strncmp(fw,"normal",4) || strncmp(fs,"roman",4))) + ff = 1; + else if (!(strncmp(fn,"helvetica",4) || strncmp(fw,"normal",4) || strncmp(fs,"roman",4))) + ff = 2; + else if (!(strncmp(fn,"courier",4) || strncmp(fw,"normal",4) || strncmp(fs,"roman",4))) + ff = 4; + else if (!(strncmp(fn,"times",4) || strncmp(fw,"bold",4) || strncmp(fs,"roman",4))) + ff = 11; + else if (!(strncmp(fn,"helvetica",4) || strncmp(fw,"bold",4) || strncmp(fs,"roman",4))) + ff = 12; + else if (!(strncmp(fn,"courier",4) || strncmp(fw,"bold",4) || strncmp(fs,"roman",4))) + ff = 14; + else if (!(strncmp(fn,"times",4) || strncmp(fw,"normal",4) || strncmp(fs,"italic",4))) + ff = 21; + else if (!(strncmp(fn,"helvetica",4) || strncmp(fw,"normal",4) || strncmp(fs,"italic",4))) + ff = 22; + else if (!(strncmp(fn,"courier",4) || strncmp(fw,"normal",4) || strncmp(fs,"italic",4))) + ff = 24; + else if (!(strncmp(fn,"times",4) || strncmp(fw,"bold",4) || strncmp(fs,"italic",4))) + ff = 31; + else if (!(strncmp(fn,"helvetica",4) || strncmp(fw,"bold",4) || strncmp(fs,"italic",4))) + ff = 32; + else if (!(strncmp(fn,"courier",4) || strncmp(fw,"bold",4) || strncmp(fs,"italic",4))) + ff = 34; + else + ff = 1; + str << ", Font(numlab)=" << ff << ", Size(numlab)=" << fz << ends; + } + + option_ = dupstr(str.str().c_str()); +} + +int CBGrid::render() +{ + pixmap_ = ((ColorbarBase*)parent_)->pixmap; + return doit(X11); +} + +int CBGrid::ps(int mode, int x, int y) +{ + matrix_ = Translate(x,y); + mode_ = mode; + + return doit(PS); +} + +#ifdef MAC_OSX_TK +int CBGrid::macosx(int x, int y) +{ + matrix_ = Translate(x,y); + + return doit(MACOSX); +} +#endif + +#ifdef __WIN32 +int CBGrid::win32(int x, int y) +{ + matrix_ = Translate(x,y); + + return doit(GWIN32); +} +#endif + +int CBGrid::doit(RenderMode rm) +{ + ColorbarBaseOptions* opts = + (ColorbarBaseOptions*)(((ColorbarBase*)parent_)->options); + + astClearStatus; // just to make sure + astBegin; // start memory management + + AstFrameSet* frameSet = NULL; + AstCmpMap* cmp = NULL; + AstLutMap* aa = NULL; + AstUnitMap* bb = NULL; + AstPlot* plot = NULL; + + if (!(frameSet = astFrameSet(astFrame(2,"Domain=WIDGET"),""))) + goto error; + + if (!(bb = astUnitMap(1,""))) + goto error; + + if (!opts->orientation) { + if (!(aa = astLutMap(cnt_, lut_, 0, double(opts->width)/(cnt_-1), ""))) + goto error; + if (!(cmp = astCmpMap(aa, bb, 0, ""))) + goto error; + } + else { + if (!(aa = astLutMap(cnt_, lut_, 0, double(opts->height)/(cnt_-1), ""))) + goto error; + if (!(cmp = astCmpMap(bb, aa, 0, ""))) + goto error; + } + + astAddFrame(frameSet, AST__CURRENT, cmp, astFrame(2, "Domain=LUT")); + + astSet(frameSet,"Title=%s", " "); + + if (0) { + int status = astStatus; + astClearStatus; + astShow(frameSet); + astSetStatus(status); + } + + // create astPlot + float gbox[4]; + double pbox[4]; + + int ww,hh,zz; + if (!opts->orientation) { + ww = opts->width; + hh = opts->size; + } + else { + ww = opts->size; + hh = opts->height; + } + zz =0; + + switch (rm) { + case X11: + ww -= 1; + hh -= 1; + break; + case PS: + zz = 1; + break; + case MACOSX: + break; + case GWIN32: + break; + } + + if (!opts->orientation) { + gbox[0] = pbox[0] = 0; + gbox[1] = pbox[1] = zz; + gbox[2] = pbox[2] = ww; + gbox[3] = pbox[3] = hh; + } + else { + gbox[0] = 0; + gbox[1] = zz; + gbox[2] = ww; + gbox[3] = hh; + + pbox[0] = zz; + pbox[1] = hh; + pbox[2] = ww; + pbox[3] = 0; + } + + plot = astPlot(frameSet, gbox, pbox, option_); + + // and now create astGrid + astGrid2dPtr = this; + renderMode_ = rm; + astGrid(plot); + + astEnd; // now, clean up memory + return 1; + +error: + astEnd; + return 0; +} diff --git a/tksao/colorbar/cbgrid.h b/tksao/colorbar/cbgrid.h new file mode 100644 index 0000000..bffc6e8 --- /dev/null +++ b/tksao/colorbar/cbgrid.h @@ -0,0 +1,33 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __cbgrid_h__ +#define __cbgrid_h__ + +#include + +#include "grid2dbase.h" +#include "vector.h" + +class CBGrid : public Grid2dBase { + private: + int cnt_; + double* lut_; + + int doit(RenderMode); + + public: + CBGrid(Widget*, int, double*); + + int render(); + int ps(int, int, int); +#ifdef MAC_OSX_TK + int macosx(int, int); +#endif +#ifdef __WIN32 + int win32(int, int); +#endif +}; + +#endif diff --git a/tksao/colorbar/colorbar.C b/tksao/colorbar/colorbar.C new file mode 100644 index 0000000..2d439be --- /dev/null +++ b/tksao/colorbar/colorbar.C @@ -0,0 +1,880 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "colorbar.h" +#include "util.h" +#include "ps.h" + +#include "lut.h" +#include "sao.h" +#include "default.h" + +Colorbar::Colorbar(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : ColorbarBase(i,c,item) +{ + bias = .5; + contrast = 1.0; + + tag =NULL; + tagaction =NONE; + taginit =0; +} + +Colorbar::~Colorbar() +{ +} + +int Colorbar::calcContrastBias(int i) +{ + // if default (contrast = 1.0 && bias = .5) return + if (fabs(bias - 0.5) < 0.0001 && fabs(contrast - 1.0) < 0.0001) + return i; + + // map i to range of 0 to 1.0 + // shift by bias (if invert, bias = 1-bias) + // multiply by contrast + // shift to center of region + // expand back to number of dynamic colors + float b = invert ? 1-bias : bias; + int r = (int)(((((float)i / colorCount) - b) * contrast + .5 ) * colorCount); + + // clip to bounds if out of range + if (r < 0) + return 0; + else if (r >= colorCount) + return colorCount-1; + else + return r; +} + +void Colorbar::loadDefaultCMaps() +{ + cmaps.append(new GreyColorMap(this)); + cmaps.append(new RedColorMap(this)); + cmaps.append(new GreenColorMap(this)); + cmaps.append(new BlueColorMap(this)); + cmaps.append(new AColorMap(this)); + cmaps.append(new BColorMap(this)); + cmaps.append(new BBColorMap(this)); + cmaps.append(new HEColorMap(this)); + cmaps.append(new I8ColorMap(this)); + cmaps.append(new AIPSColorMap(this)); + cmaps.append(new SLSColorMap(this)); + cmaps.append(new HSVColorMap(this)); + cmaps.append(new HeatColorMap(this)); + cmaps.append(new CoolColorMap(this)); + cmaps.append(new RainbowColorMap(this)); + cmaps.append(new StandardColorMap(this)); + cmaps.append(new StaircaseColorMap(this)); + cmaps.append(new ColorColorMap(this)); + + cmaps.head(); +} + +ColorMapInfo* Colorbar::newColorMap(const char* fn, const char* type) +{ + // determine colormap type + char* tmp = dupstr(fn); // tmp memory, we will mangle it + char* ptr = tmp; + while (*ptr++); // walk forward till end of string + ptr--; // backup one + while (ptr != tmp && *ptr != '.') // march backward looking for '.' + ptr--; + if (ptr != tmp) { // are we at '.' or start of string + *ptr = '\0'; // mark end of string at '.' + ptr++; + } + + // Create ColorMap + ColorMapInfo* map = NULL; + + // if type specified, use it, otherwise, use file extension + if (type) + ptr = (char*)type; + + if (strncmp(ptr, "lut", 3) == 0) + map = new LUTColorMap(this); + else + map = new SAOColorMap(this); + + // Bail out if we don't have a new ColorMap + if (!map) + return NULL; + + // Extract a name from the file name. Any extension has already been removed. + ptr = tmp; + while (*ptr++); // walk forward till end of string + while (ptr != tmp && *ptr != '/') // march backward looking for '/' + ptr--; + if (ptr != tmp) // see if we found '/' or at begining of string + ptr++; + + map->setName(ptr); + map->setFileName(fn); + + delete [] tmp; // clean up + return map; +} + +void Colorbar::psHorz(ostream& str, Filter& filter, int width, int height) +{ + for (int jj=0; jjgetBlueChar(index, colorCount); + colorCells[i*3+1] = cmaps.current()->getGreenChar(index, colorCount); + colorCells[i*3+2] = cmaps.current()->getRedChar(index, colorCount); + } + + ctags.head(); + while (ctags.current()) { + for (int ii=ctags.current()->start(); iistop(); ii++) { + colorCells[ii*3] = ctags.current()->colorBlue(); + colorCells[ii*3+1] = ctags.current()->colorGreen(); + colorCells[ii*3+2] = ctags.current()->colorRed(); + } + ctags.next(); + } +} + +// Commands + +void Colorbar::adjustCmd(float c, float b) +{ + contrast = c; + bias = b; + updateColors(); +} + +void Colorbar::getBiasCmd() +{ + ostringstream str; + str << bias << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Colorbar::getColorbarCmd() +{ + if (cmaps.current()) { + ostringstream str; + str << cmaps.current()->getID() << ' ' + << bias << ' ' + << contrast << ' ' + << invert << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + else + result = TCL_ERROR; +} + +void Colorbar::getColormapCmd() +{ + if (cmaps.current()) { + ostringstream str; + str << cmaps.current()->getID() << ' ' + << bias << ' ' + << contrast << ' ' + << invert << ' ' + << (unsigned short*)colorCells << ' ' + << colorCount << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + else + result = TCL_ERROR; +} + +void Colorbar::getColormapNameCmd(int id) +{ + ColorMapInfo* ptr = cmaps.begin(); + while (ptr) { + if (ptr->getID() == id) { + Tcl_AppendResult(interp, (char*)ptr->getName(), NULL); + return; + } + ptr = ptr->next(); + } + + // if we got this far, we did not find it, bail out + Tcl_AppendResult(interp, " colormap not found.", NULL); + result = TCL_ERROR; +} + +void Colorbar::getColormapFileNameCmd(int id) +{ + ColorMapInfo* ptr = cmaps.begin(); + while (ptr) { + if (ptr->getID() == id) { + Tcl_AppendResult(interp, (char*)ptr->getFileName(), NULL); + return; + } + ptr = ptr->next(); + } + + // if we got this far, we did not find it, bail out + Tcl_AppendResult(interp, " colormap not found.", NULL); + result = TCL_ERROR; +} + +void Colorbar::getContrastCmd() +{ + ostringstream str; + str << contrast << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Colorbar::getCurrentIDCmd() +{ + if (cmaps.current()) { + ostringstream str; + str << cmaps.current()->getID() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + else + result = TCL_ERROR; +} + +void Colorbar::getCurrentNameCmd() +{ + if (cmaps.current()) + Tcl_AppendElement(interp, (char*)cmaps.current()->getName()); + else + result = TCL_ERROR; +} + +void Colorbar::getCurrentFileNameCmd() +{ + if (cmaps.current()) + Tcl_AppendElement(interp, (char*)cmaps.current()->getFileName()); + else + result = TCL_ERROR; +} + +void Colorbar::getTagCmd() +{ + ostringstream str; + ctags.head(); + while (ctags.current()) { + str << ctags.current()->start() << ' ' + << ctags.current()->stop() << ' ' + << ctags.current()->colorname() << ' '; + ctags.next(); + } + str << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Colorbar::getTagCmd(int xx, int yy) +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + int rr,ss; + if (!opts->orientation) { + rr = xx; + ss = float(rr)/opts->width * colorCount; + } + else { + rr = yy; + ss = (1-float(rr)/opts->height) * colorCount; + } + + ctags.head(); + while (ctags.current()) { + if (ss>ctags.current()->start() && ssstop()) { + int startid = float(ctags.current()->start())/colorCount * cnt; + int stopid = float(ctags.current()->stop())/colorCount * cnt; + if (startid<0) + startid = 0; + if (startid>=cnt) + startid = cnt-1; + if (stopid<0) + stopid = 0; + if (stopid>=cnt) + stopid = cnt-1; + + ostringstream str; + str << ctags.current()->id() << ' ' + << lut[startid] << ' ' + << lut[stopid] << ' ' + << ctags.current()->colorname() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + return; + } + ctags.next(); + } +} + +void Colorbar::getRGBChannelCmd() +{ + Tcl_AppendResult(interp, "red", NULL); +} + +void Colorbar::listIDCmd() +{ + + ColorMapInfo* ptr = cmaps.begin(); + while (ptr) { + ostringstream str; + str << ptr->getID() << ends; + Tcl_AppendElement(interp, str.str().c_str()); + + ptr = ptr->next(); + } +} + +void Colorbar::listNameCmd() +{ + ColorMapInfo* ptr = cmaps.begin(); + while (ptr) { + Tcl_AppendElement(interp, (char*)ptr->getName()); + ptr = ptr->next(); + } +} + +void Colorbar::loadCmd(const char* fn, const char* type) +{ + ColorMapInfo* map = newColorMap(fn, type); + + if (map && map->load()) { + // add new colormap to end of the list + cmaps.append(map); + reset(); + } + else { + // something has gone wrong, clean up, and bail out + delete map; + Tcl_AppendResult(interp, " unable to load colormap: ", fn, NULL); + result = TCL_ERROR; + } +} + +void Colorbar::loadCmd(const char* fn, const char* type, const char* var) +{ + ColorMapInfo* map = newColorMap(fn, type); + + if (map && map->load(var)) { + // add new colormap to end of the list + cmaps.append(map); + reset(); + } + else { + // something has gone wrong, clean up, and bail out + delete map; + Tcl_AppendResult(interp, " unable to load colormap: ", fn, NULL); + result = TCL_ERROR; + } +} + +void Colorbar::mapCmd(char* which) +{ + char* a = toLower(which); + cmaps.head(); + do { + char* b = toLower(cmaps.current()->getName()); + if (!strcmp(a,b)) { + reset(); + delete [] a; + delete [] b; + return; + } + delete [] b; + } + while (cmaps.next()); + + // if we got this far, we did not find it, bail out + cmaps.head(); + delete [] a; + result = TCL_ERROR; +} + +void Colorbar::mapCmd(int id) +{ + cmaps.head(); + do { + if (cmaps.current()->getID() == id) { + reset(); + return; + } + } + while (cmaps.next()); + + // if we got this far, we did not find it, bail out + cmaps.head(); + result = TCL_ERROR; +} + +void Colorbar::saveCmd(const char* fn) +{ + cmaps.current()->save(fn); +} + +void Colorbar::saveCmd(int id, const char* fn) +{ + ColorMapInfo* ptr = cmaps.begin(); + while (ptr) { + if (ptr->getID() == id) { + ptr->save(fn); + return; + } + ptr = ptr->next(); + } + + result = TCL_ERROR; +} + +void Colorbar::setColorbarCmd(int id, float b, float c, int i) +{ + cmaps.head(); + while (cmaps.current()) { + if (cmaps.current()->getID() == id) { + bias = b; + contrast = c; + invert = i; + updateColors(); + return; + } + cmaps.next(); + } + + // if we got this far, we did not find it, bail out + cmaps.head(); + result = TCL_ERROR; +} + +void Colorbar::tagCmd(const char* txt) +{ + ctags.deleteAll(); + + istringstream str(txt); + while (!str.eof()) { + int aa =0; + int bb =0; + char color[32]; + *color ='\0'; + + str >> aa >> bb >> color; + + if (aa && bb && *color) + ctags.append(new ColorTag(this,aa,bb,color)); + } + updateColors(); +} + +void Colorbar::tagCmd(int id, const Vector& v, const char* color) +{ + Vector vv = v; + int mm=0; + int nn=0; + ctags.head(); + while (ctags.current()) { + if (ctags.current()->id() == id) { + // special case + if (vv[0]>lut[cnt-1] && vv[1]>lut[cnt-1]) + return; + else if (vv[0]=0; ii--) + if (vv[1]>lut[ii]) { + nn=ii; + break; + } + + Vector rr = Vector(mm,nn)/cnt*colorCount; + ctags.current()->set(rr[0],rr[1],color); + updateColors(); + return; + } + ctags.next(); + } +} + +void Colorbar::tagDeleteCmd() +{ + ctags.deleteAll(); + updateColors(); +} + +void Colorbar::tagDeleteCmd(int xx, int yy) +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + int rr,ss; + if (!opts->orientation) { + rr = xx; + ss = float(rr)/opts->width * colorCount; + } + else { + rr = yy; + ss = (1-float(rr)/opts->height) * colorCount; + } + + ctags.head(); + while (ctags.current()) { + if (ss>ctags.current()->start() && ssstop()) { + ColorTag* ct = ctags.extract(); + if (ct) + delete ct; + + updateColors(); + return; + } + ctags.next(); + } +} + +void Colorbar::tagEditBeginCmd(int xx, int yy, const char* color) +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + tag= NULL; + tagaction =NONE; + taginit =0; + + int rr,ss; + if (!opts->orientation) { + rr = xx; + ss = float(rr)/opts->width * colorCount; + } + else { + rr = yy; + ss = (1-float(rr)/opts->height) * colorCount; + } + + ctags.head(); + while (ctags.current()) { + int start = ctags.current()->start(); + int stop = ctags.current()->stop(); + if (ss>start && ssstop-10 && ssstart && ssorientation) { + rr = xx; + ss = float(rr)/opts->width * colorCount; + tt = float(taginit)/opts->width *colorCount; + } + else { + rr = yy; + ss = (1-float(rr)/opts->height) * colorCount; + tt = (1-float(taginit)/opts->height) *colorCount; + } + + switch (tagaction) { + case NONE: + break; + case CREATE: + tagaction =STOP; + tag->move(0,ss-tt); + break; + case START: + tag->move(ss-tt,0); + break; + case STOP: + tag->move(0,ss-tt); + break; + case MOVE: + tag->move(ss-tt,ss-tt); + break; + } + taginit = rr; + + updateColors(); + } +} + +void Colorbar::tagEditEndCmd(int xx, int yy) +{ + if (tag) { + switch (tagaction) { + case NONE: + break; + case CREATE: + tag->width(100); + break; + case START: + break; + case STOP: + break; + case MOVE: + break; + } + + updateColors(); + } +} + +void Colorbar::tagLoadCmd(const char* fn) +{ + ifstream str(fn); + + if (str) { + ctags.deleteAll(); + + while (!str.eof()) { + int mm=0; + int nn=0; + double aa =0; + double bb =0; + char color[32]; + *color ='\0'; + + str >> aa >> bb >> color; + + if (aa && bb && *color) { + // special case + if (aa>lut[cnt-1] && bb>lut[cnt-1]) + continue; + else if (aa=0; ii--) + if (bb>lut[ii]) { + nn=ii; + break; + } + + Vector rr = Vector(mm,nn)/cnt*colorCount; + ctags.append(new ColorTag(this,rr[0],rr[1],color)); + } + } + + updateColors(); + } +} + +void Colorbar::tagSaveCmd(const char* fn) +{ + ofstream str(fn); + if (str) { + ctags.head(); + while (ctags.current()) { + int startid = float(ctags.current()->start())/colorCount * cnt; + int stopid = float(ctags.current()->stop())/colorCount * cnt; + if (startid<0) + startid = 0; + if (startid>=cnt) + startid = cnt-1; + if (stopid<0) + stopid = 0; + if (stopid>=cnt) + stopid = cnt-1; + + str << lut[startid] << ' ' << lut[stopid] << ' ' + << ctags.current()->colorname() << endl; + ctags.next(); + } + } +} + +#ifdef MAC_OSX_TK +void Colorbar::macosx(float scale, int width, int height, + const Vector& v, const Vector& s) +{ + if (!colorCells) + return; + + // destination + unsigned char* dst = new unsigned char[width*height*4]; + unsigned char* dptr = dst; + + if (!((ColorbarBaseOptions*)options)->orientation) { + for (int jj=0; jjorientation) { + for (int jj=0; jj cmaps; + List ctags; + float bias; + float contrast; + + ColorTag* tag; + ColorTagAction tagaction; + int taginit; + + private: + ColorMapInfo* newColorMap(const char*, const char*); + + void psHorz(ostream&, Filter&, int, int); + void psVert(ostream&, Filter&, int, int); + + protected: + int calcContrastBias(int); + void loadDefaultCMaps(); + void reset(); + void updateColorCells(); + +#ifdef MAC_OSX_TK + void macosx(float, int, int, const Vector&, const Vector&); +#endif +#ifdef __WIN32 + void win32(float, int, int, const Vector&, const Vector&); +#endif + + public: + Colorbar(Tcl_Interp*, Tk_Canvas, Tk_Item*); + virtual ~Colorbar(); + + // commands + + void adjustCmd(float, float); + void getBiasCmd(); + void getColorbarCmd(); + void getColormapCmd(); + void getColormapNameCmd(int); + void getColormapFileNameCmd(int); + void getContrastCmd(); + void getCurrentFileNameCmd(); + void getCurrentIDCmd(); + void getCurrentNameCmd(); + void listIDCmd(); + void listNameCmd(); + void loadCmd(const char*, const char*); + void loadCmd(const char*, const char*, const char*); + void mapCmd(char*); + void mapCmd(int); + void saveCmd(const char*); + void saveCmd(int, const char*); + void setColorbarCmd(int, float, float, int); + + void getTagCmd(); + void getTagCmd(int,int); + void tagCmd(const char*); + void tagCmd(int, const Vector&, const char*); + void tagDeleteCmd(); + void tagDeleteCmd(int,int); + void tagEditBeginCmd(int,int,const char*); + void tagEditMotionCmd(int,int); + void tagEditEndCmd(int,int); + void tagLoadCmd(const char*); + void tagSaveCmd(const char*); + + void getRGBChannelCmd(); +}; + +#endif diff --git a/tksao/colorbar/colorbarbase.C b/tksao/colorbar/colorbarbase.C new file mode 100644 index 0000000..e454468 --- /dev/null +++ b/tksao/colorbar/colorbarbase.C @@ -0,0 +1,1103 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "colorbarbase.h" +#include "util.h" +#include "cbgrid.h" +#include "ps.h" + +#define TICKLEN 3 +#define TICKGAP 7 + +// Parser Stuff +#undef yyFlexLexer +#define yyFlexLexer cbFlexLexer +#include + +void* cblval; +extern int cbparse(ColorbarBase*, cbFlexLexer*); + +int cblex(void* vval, cbFlexLexer* ll) +{ + cblval = vval; + return ll ? ll->yylex() : 0; +} + +void cberror(ColorbarBase* cb, cbFlexLexer* ll, const char* m) +{ + cb->error(m); + const char* cmd = ll ? ll->YYText() : (const char*)NULL; + if (cmd && cmd[0] != '\n') { + cb->error(": "); + cb->error(cmd); + } +} + +// Public Member Functions + +ColorbarBase::ColorbarBase(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : Widget(i,c,item) +{ + // this is needed because of a problem with Tk_ConfigureWidget + ((ColorbarBaseOptions*)options)->font = NULL; + ((ColorbarBaseOptions*)options)->fontWeight = NULL; + ((ColorbarBaseOptions*)options)->fontSlant = NULL; + + xmap = NULL; + colorCells = NULL; + colorCount = 0; + + grid = NULL; + + cnt = 0; + lut = NULL; + + invert = 0; + + ticktxt = NULL; + tickcnt =0; + skipcnt =0; +} + +ColorbarBase::~ColorbarBase() +{ + if (xmap) + XDestroyImage(xmap); + + if (colorCells) + delete [] colorCells; + + if (grid) + delete grid; + + if (lut) + delete [] lut; + + if (ticktxt) { + for (int ii=0; iifontSize*getDisplayRatio()); +#else + int fz = opts->fontSize; +#endif + + if (!strncmp(opts->font,"helvetica",4)) + fstr << '{' << opts->helvetica << '}' << ' ' << fz << ' ' + << opts->fontWeight << ' ' << opts->fontSlant << ends; + else if (!strncmp(opts->font,"courier",4)) + fstr << '{' << opts->courier << '}' << ' ' << fz << ' ' + << opts->fontWeight << ' ' << opts->fontSlant << ends; + else if (!strncmp(opts->font,"times",4)) + fstr << '{' << opts->times << '}' << ' ' << fz << ' ' + << opts->fontWeight << ' ' << opts->fontSlant << ends; + else + fstr << '{' << opts->helvetica << '}' << ' ' << fz << ' ' + << opts->fontWeight << ' ' << opts->fontSlant << ends; + + return Tk_GetFont(interp, tkwin, fstr.str().c_str()); +} + +void ColorbarBase::lutToText(Tk_Font font) +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + // init + if (ticktxt) + for (int ii=0; iiticks; + ticktxt = new char*[opts->ticks]; + for (int ii=0; iiticks; ii++) + ticktxt[ii] = NULL; + skipcnt =0; + + // first estimate of prec + int prec; + { + int aa = (int)(log10(fabs(lut[0]))); + int bb = (int)(log10(fabs(lut[cnt-1]))); + if (aa != bb) + prec = aa>bb ? aa : bb; + else + prec = 1; + } + + // up to three tries + for (int jj=0; jj<3; jj++) { + // render text + for (int ii=0; iiticks; ii++) { + int id = ii/double(opts->ticks-1)*cnt; + // the last one will be one over + if (id>=cnt) + id = cnt-1; + + ostringstream str; + if (prec < -2) + str << scientific << setprecision(2+jj) << lut[id] << ends; + else if (prec < 0) + str << fixed << setprecision(abs(prec)+3+jj) << lut[id] << ends; + else if (prec < 2) + str << setprecision(2+jj) << lut[id] << ends; + else if (prec < 5) + str << fixed << setprecision(0+jj) << lut[id] << ends; + else + str << scientific << setprecision(2+jj) << lut[id] << ends; + + if (ticktxt[ii]) + delete [] ticktxt[ii]; + ticktxt[ii] = new char[strlen(str.str().c_str())+1]; + strcpy(ticktxt[ii],str.str().c_str()); + } + + // now see if all is unique + int ok=1; + for (int ii=1; iiticks; ii++) { + if (!strcmp(ticktxt[ii-1],ticktxt[ii])) + ok=0; + } + + if (ok) + break; + } + + // determine skipcnt + Tk_FontMetrics metrics; + Tk_GetFontMetrics(font, &metrics); + + if (!opts->orientation) { + // horizontal + int ww =0; + for (int ii=0; iiticks; ii++) { + if (ticktxt[ii]) { + int aa = Tk_TextWidth(font, ticktxt[ii], strlen(ticktxt[ii])); + if (aa>ww) + ww = aa; + } + } + skipcnt = (ww+2)*opts->ticks/opts->width; + } + else { + // vertical + int total = (metrics.linespace+1)*opts->ticks; + skipcnt = total/opts->height; + } +} + +int ColorbarBase::initColormap() +{ + colorCount = (((ColorbarBaseOptions*)options)->colors); + colorCells = new unsigned char[colorCount*3]; + + // needed to initialize colorCells + reset(); + + return TCL_OK; +} + +void ColorbarBase::updateColors() +{ + updateColorCells(); + + // fill in xmap + // make sure we have a pixmap + if (!pixmap || !xmap) + return; + + if (!((ColorbarBaseOptions*)options)->orientation) { + updateColorsHorz(); + TkPutImage(NULL,0,display, pixmap, widgetGC, xmap, 0, 0, 1, 1, + options->width-2, ((ColorbarBaseOptions*)options)->size-2); + } + else { + updateColorsVert(); + TkPutImage(NULL,0,display, pixmap, widgetGC, xmap, 0, 0, 1, 1, + ((ColorbarBaseOptions*)options)->size-2, options->height-2); + } + + redraw(); +} + +// X11 + +int ColorbarBase::updatePixmap(const BBox& bb) +{ + if (!widgetGC) + widgetGC = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + if (pixmap) + return TCL_OK; + + // create a valid pixmap + // assume if no pixmap, no xmap + // bb is in canvas coords + + if (!(pixmap = Tk_GetPixmap(display, Tk_WindowId(tkwin), options->width, + options->height, depth))) { + internalError("Colorbar: Unable to Create Pixmap"); + return TCL_OK; + } + + XSetForeground(display, widgetGC, getColor("white")); + XFillRectangle(display, pixmap, widgetGC, 0, 0, options->width,options->height); + + if (!opts->orientation) { + if (!(xmap = XGetImage(display, pixmap, 1, 1, + options->width-2, + opts->size-2, + AllPlanes, ZPixmap))){ + internalError("Colorbar: Unable to Create XImage"); + return TCL_OK; + } + } + else { + if (!(xmap = XGetImage(display, pixmap, 1, 1, + opts->size-2, + options->height-2, + AllPlanes, ZPixmap))){ + internalError("Colorbar: Unable to Create XImage"); + return TCL_OK; + } + } + + updateColors(); + + if (opts->numerics && opts->space) { + renderGridAST(); + return TCL_OK; + } + + // we want a border, even with no numerics + renderGrid(); + return TCL_OK; +} + +void ColorbarBase::renderGrid() +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + // box + XSetForeground(display, widgetGC, getColor("black")); + if (!opts->orientation) + XDrawRectangle(display, pixmap, widgetGC, 0, 0, + options->width-1, opts->size-1); + else + XDrawRectangle(display, pixmap, widgetGC, 0, 0, + opts->size-1, options->height-1); + + if (opts->numerics && lut) + renderGridNumerics(); +} + +void ColorbarBase::renderGridNumerics() +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + // font + Tk_Font font = getFont(); + if (!font) + return; // bad font, we're done + Tk_FontMetrics metrics; + Tk_GetFontMetrics(font, &metrics); + + // set font + XSetFont(display, widgetGC, Tk_FontId(font)); + + // generate text + lutToText(font); + + // tick marks + int incrcnt=0; + for (int ii=1; iiticks-1; ii++) { + if (!opts->orientation) { + // horizontal + int ww = (int)(ii/double(opts->ticks-1)*opts->width); + int h = opts->size-1; + int hh = opts->size-1 + TICKLEN; + XDrawLine(display, pixmap, widgetGC, ww, h, ww, hh); + + if (!incrcnt) { + int txtwidth = Tk_TextWidth(font, ticktxt[ii], strlen(ticktxt[ii])); + int www = ww - txtwidth/2.; + int hhh = hh + TICKGAP + metrics.ascent; + Tk_DrawChars(display, pixmap, widgetGC, font, ticktxt[ii], + strlen(ticktxt[ii]), www, hhh); + } + } + else { + // vertical + int w = opts->size-1; + int ww = opts->size-1 + TICKLEN; + int hh = opts->height - (int)(ii/double(opts->ticks-1)*opts->height); + XDrawLine(display, pixmap, widgetGC, w, hh, ww, hh); + + if (!incrcnt) { + int www = ww + TICKGAP; + int hhh = hh + (metrics.ascent-metrics.descent)/2.; + Tk_DrawChars(display, pixmap, widgetGC, font, ticktxt[ii], + strlen(ticktxt[ii]), www, hhh); + } + } + + if (incrcnt1 && lut) { + grid = new CBGrid(this, cnt, lut); + if (grid) + grid->render(); + } +} + +// PS + +int ColorbarBase::postscriptProc(int prepass) +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + if (!visible) + return TCL_OK; + + if (prepass) + return TCL_OK; + + // bar + Tcl_AppendResult(interp, "gsave\n", NULL); + ps(); + Tcl_AppendResult(interp, "grestore\n", NULL); + + // numerics + Tcl_AppendResult(interp, "gsave\n", NULL); + + if (opts->numerics && opts->space && grid) { + psGridAST(); + Tcl_AppendResult(interp, "grestore\n", NULL); + return TCL_OK; + } + + // we want a border, even if no numerics + psGrid(); + Tcl_AppendResult(interp, "grestore\n", NULL); + return TCL_OK; +} + +void ColorbarBase::ps() +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + int& width = options->width; + int& height = options->height; + int& size = opts->size; + + // image + int ww = !opts->orientation ? width : size; + int hh = !opts->orientation ? size : height; + Vector org = psOrigin(); + if (!opts->orientation) + org += Vector(0,height-size); + + ostringstream str; + str << org << " translate " << 1 << ' ' << 1 << " scale" << endl; + + switch (psLevel) { + case 1: + { + psHead1(str, ww, hh); + NoCompressAsciiHex filter(psLevel); + psHV(str, filter, ww, hh); + } + break; + case 2: + { + psHead2(str, ww, hh, "RunLength", "ASCII85"); + RLEAscii85 filter(psLevel); + psHV(str, filter, ww, hh); + } + break; + case 3: + { + psHead2(str, ww, hh, "Flate", "ASCII85"); + GZIPAscii85 filter(psLevel); + psHV(str, filter, ww, hh); + } + break; + } + + str << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void ColorbarBase::psHV(ostream& str, Filter& filter, int width, int height) +{ + if (!((ColorbarBaseOptions*)options)->orientation) + psHorz(str, filter, width, height); + else + psVert(str, filter, width, height); + + filter.flush(str); +} + +void ColorbarBase::psGrid() +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + int& width = options->width; + int& height = options->height; + int& size = opts->size; + + // box + int ww,hh; + Vector org = psOrigin(); + if (!opts->orientation) { + ww = width; + hh = size; + org += Vector(0,height-size); + } + else { + ww = size; + hh = height; + } + + Vector ll = Vector(0,0); + Vector lr = Vector(ww,0); + Vector ur = Vector(ww,hh); + Vector ul = Vector(0,hh); + + ostringstream str; + str << org << " translate " << endl + << "newpath " << endl + << ll << " moveto" << endl + << lr << " lineto" << endl + << ur << " lineto" << endl + << ul << " lineto" << endl + << ll << " lineto" << endl + << "closepath" << endl + << .5 << " setlinewidth" << endl + << "stroke" << endl << ends; + + Tcl_AppendResult(interp, str.str().c_str(), NULL); + + // numerics + if (opts->numerics && lut) + psGridNumerics(); +} + +void ColorbarBase::psGridNumerics() +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + // font + Tk_Font font = NULL; + { + ostringstream fstr; + fstr << opts->font << ' ' << opts->fontSize << ' ' + << opts->fontWeight << ' ' << opts->fontSlant << ends; + font = Tk_GetFont(interp, tkwin, fstr.str().c_str()); + if (!font) + return; // bad font, we're done + } + + // set font + { + ostringstream str; + str << '/' << psFontName(opts->font, opts->fontWeight, opts->fontSlant) + << " findfont " << int(opts->fontSize*getDisplayRatio()) + << " scalefont setfont" << endl; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + + // generate text + lutToText(font); + + // tick marks + int incrcnt=0; + for (int ii=0; iiticks; ii++) { + if (!opts->orientation) { + // horizontal + int ww = (int)(ii/double(opts->ticks-1)*opts->width); + int h = 0; + int hh = h-TICKLEN; + + ostringstream str; + str << "newpath " << endl + << Vector(ww,h) << " moveto " << endl + << Vector(ww,hh) << " lineto " << endl + << "closepath " << endl + << .5 << " setlinewidth" << endl + << "stroke" << endl << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + + if (!incrcnt) { + ostringstream str; + Vector tt = Vector(ww,hh-TICKGAP); + str << "newpath " << endl + << tt << " moveto" << endl + << '(' << psQuote(ticktxt[ii]) << ')' + << "dup true charpath pathbbox " << endl + << "closepath " << endl + << "3 -1 roll sub 1.2 mul neg " << endl + << "3 1 roll sub 2 div exch " << endl + << tt << " moveto rmoveto show " << endl; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + } + else { + // vertical + int w = opts->size; + int ww = opts->size + TICKLEN; + int hh = (int)(ii/double(opts->ticks-1)*opts->height); + + ostringstream str; + str << "newpath " << endl + << Vector(w,hh) << " moveto " << endl + << Vector(ww,hh) << " lineto " << endl + << "closepath " << endl + << .5 << " setlinewidth" << endl + << "stroke" << endl << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + + if (!incrcnt) { + ostringstream str; + Vector tt = Vector(ww+TICKGAP,hh); + str << "newpath " << endl + << tt << " moveto" << endl + << '(' << psQuote(ticktxt[ii]) << ')' + << "dup true charpath pathbbox " << endl + << "closepath " << endl + << "3 -1 roll sub 2 div neg " << endl + << "3 1 roll pop pop 0 exch " << endl + << tt << " moveto rmoveto show " << endl; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + } + + if (incrcntwidth, options->height); + float delta = 4*opts->fontSize; + + // clip rect (to remove ticks on inside) + if (!opts->orientation) { + oo += Vector(-delta,-.5); + uu += Vector(2*delta,-.75); + } + else { + oo += Vector(-.25,-delta); + uu += Vector(0,2*delta); + } + + Matrix mm = Translate(psOrigin()); + Vector ll = oo*mm; + Vector lr = Vector(uu[0],oo[1])*mm; + Vector ur = uu*mm; + Vector ul = Vector(oo[0],uu[1])*mm; + + ostringstream str; + str << "newpath " << endl + << ll << " moveto " << endl + << lr << " lineto " << endl + << ur << " lineto " << endl + << ul << " lineto " << endl + << ll << " lineto " << endl + << "closepath clip" << endl << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + + // grid + if (grid) + grid->ps(psColorSpace, originX, originY); +} + +// Commands + +void ColorbarBase::getInvertCmd() +{ + if (invert) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void ColorbarBase::getValueCmd(int x, int y) +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + if (lut && cnt) { + int id =0; + ostringstream str; + if (!opts->orientation) { + // horizontal + id = (int)(x/float(options->width) * cnt); + } + else { + // vertical + id = (int)((options->height -y)/float(options->height) * cnt); + } + + if (id<0) + id = 0; + if (id>=cnt) + id = cnt-1; + + str << lut[id] << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + else + Tcl_AppendResult(interp, NULL); +} + +void ColorbarBase::invertCmd(int ii) +{ + invert = ii ? 1 : 0; + updateColors(); +} + +void ColorbarBase::setColormapLevelCmd() +{ + if (lut) + delete [] lut; + lut = NULL; + cnt = 0; + + invalidPixmap(); + redraw(); +} + +void ColorbarBase::setColormapLevelCmd(int cc, double* ff) +{ + // check for the same + if (cnt == cc) { + int same = 1; + for (int ii=0; iiorientation) { + ww = options->width; + hh = opts->size; + } + else { + ww = opts->size; + hh = options->height; + } + + // image + macosx(1, ww, hh, Vector(originX,originY), Vector(ww,hh)); + + // grid + if (opts->numerics && opts->space && grid) { + macosxGridAST(); + macosxEnd(); + return; + } + + // we want a border, even if no numerics + macosxGrid(); + macosxEnd(); +} + +void ColorbarBase::macosxGrid() +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + int& width = options->width; + int& height = options->height; + int& size = opts->size; + + Matrix mm = Translate(originX, originY); + + macosxColor(getXColor("black")); + macosxDash(NULL,0); + macosxWidth(.5); + + // Box + int ww,hh; + if (!opts->orientation) { + ww = width; + hh = size; + } + else { + ww = size; + hh = height; + } + + Vector v[5]; + v[0] = Vector(0,0) * mm; + v[1] = Vector(ww,0) * mm; + v[2] = Vector(ww,hh) * mm; + v[3] = Vector(0,hh) * mm; + v[4] = Vector(0,0) * mm; + macosxDrawLines(v,5); + + // numerics + if (opts->numerics && lut) + macosxGridNumerics(); +} + +void ColorbarBase::macosxGridNumerics() +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + Matrix mm = Translate(originX, originY); + + // font + Tk_Font font = getFont(); + if (!font) + return; // bad font, we're done + Tk_FontMetrics metrics; + Tk_GetFontMetrics(font, &metrics); + + // set font + Tcl_DString psFont; + Tcl_DStringInit(&psFont); + int psSize = Tk_PostscriptFontName(font, &psFont); + macosxFont(Tcl_DStringValue(&psFont), psSize); + Tcl_DStringFree(&psFont); + + // generate text + lutToText(font); + + // tick marks + int incrcnt=0; + for (int ii=0; iiticks; ii++) { + if (!opts->orientation) { + // horizontal + int ww = (int)(ii/double(opts->ticks-1)*opts->width); + int h = opts->size; + int hh = opts->size + TICKLEN; + Vector vv[2]; + vv[0] = Vector(ww,h)*mm; + vv[1] = Vector(ww,hh)*mm; + macosxDrawLines(vv,2); + + if (!incrcnt) { + int txtwidth = Tk_TextWidth(font, ticktxt[ii], strlen(ticktxt[ii])); + int www = ww - txtwidth/2.; + int hhh = hh + TICKGAP + metrics.ascent; + macosxDrawText(Vector(www,hhh)*mm, 0, ticktxt[ii]); + } + } + else { + // vertical + int w = opts->size; + int ww = opts->size + TICKLEN; + int hh = opts->height - (int)(ii/double(opts->ticks-1)*opts->height); + Vector vv[2]; + vv[0] = Vector(w,hh)*mm; + vv[1] = Vector(ww,hh)*mm; + macosxDrawLines(vv,2); + + if (!incrcnt) { + int www = ww + TICKGAP; + int hhh = hh + (metrics.ascent-metrics.descent)/2.; + macosxDrawText(Vector(www,hhh)*mm, 0, ticktxt[ii]); + } + } + + if (incrcntwidth, options->height); + float delta = 4*opts->fontSize; + + if (!opts->orientation) { + oo += Vector(-delta,-.2); + uu += Vector(2*delta,-.2); + } + else { + oo += Vector(-.2,-delta); + uu += Vector(0,2*delta); + } + macosxClip(oo,uu); + + if (grid) + grid->macosx(originX, originY); +} + +#endif + +// WIN32 + +#ifdef __WIN32 +void ColorbarBase::win32PrintCmd() +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + if (!visible) + return; + + // init + win32Begin(); + + int ww,hh; + if (!opts->orientation) { + ww = options->width; + hh = opts->size; + } + else { + ww = opts->size; + hh = options->height; + } + + // image + win32(1, ww, hh, Vector(originX,originY), Vector(ww,hh)); + + // grid + if (opts->numerics && opts->space && grid) { + win32GridAST(); + win32End(); + } + + // we want a border, even if no numerics + win32Grid(); + win32End(); +} + +void ColorbarBase::win32Grid() +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + + int& width = options->width; + int& height = options->height; + int& size = opts->size; + + Matrix mm = Translate(originX, originY); + + win32Color(getXColor("black")); + win32Dash(NULL,0); + win32Width(.5); + + // box + int ww,hh; + if (!opts->orientation) { + ww = width; + hh = size; + } + else { + ww = size; + hh = height; + } + + Vector v[5]; + v[0] = Vector(0,0) * mm; + v[1] = Vector(ww,0) * mm; + v[2] = Vector(ww,hh) * mm; + v[3] = Vector(0,hh) * mm; + v[4] = Vector(0,0) * mm; + win32DrawLines(v,5); + + // numerics + if (opts->numerics && lut) + win32GridNumerics(); +} + +void ColorbarBase::win32GridNumerics() +{ + ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options; + Matrix mm = Translate(originX, originY); + + // font + Tk_Font font = getFont(); + if (!font) + return; // bad font, we're done + Tk_FontMetrics metrics; + Tk_GetFontMetrics(font, &metrics); + + win32Font(font); + + // generate text + lutToText(font); + + // tick marks + int incrcnt=0; + for (int ii=0; iiticks; ii++) { + if (!opts->orientation) { + // horizontal + int ww = ii/double(opts->ticks-1)*opts->width; + int h = opts->size; + int hh = opts->size + TICKLEN; + Vector vv[2]; + vv[0] = Vector(ww,h)*mm; + vv[1] = Vector(ww,hh)*mm; + win32DrawLines(vv,2); + + if (!incrcnt) { + int txtwidth = Tk_TextWidth(font, ticktxt[ii], strlen(ticktxt[ii])); + int www = ww - txtwidth/2.; + int hhh = hh + TICKGAP + metrics.ascent; + win32DrawText(Vector(www,hhh)*mm, 0, ticktxt[ii]); + } + } + else { + // vertical + int w = opts->size; + int ww = opts->size + TICKLEN; + int hh = opts->height - (int)(ii/double(opts->ticks-1)*opts->height); + Vector vv[2]; + vv[0] = Vector(w,hh)*mm; + vv[1] = Vector(ww,hh)*mm; + win32DrawLines(vv,2); + + if (!incrcnt) { + int www = ww + TICKGAP; + int hhh = hh + (metrics.ascent-metrics.descent)/2.; + win32DrawText(Vector(www,hhh)*mm, 0, ticktxt[ii]); + } + } + + if (incrcntwidth, options->height); + float delta = 4*opts->fontSize; + + if (!opts->orientation) { + oo += Vector(-delta,-.2); + uu += Vector(2*delta,-.2); + } + else { + oo += Vector(-.2,-delta); + uu += Vector(0,2*delta); + } + win32Clip(oo,uu); + + if (grid) + grid->win32(originX, originY); +} + +#endif + + diff --git a/tksao/colorbar/colorbarbase.h b/tksao/colorbar/colorbarbase.h new file mode 100644 index 0000000..91cea8c --- /dev/null +++ b/tksao/colorbar/colorbarbase.h @@ -0,0 +1,200 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __colorbarbase_h__ +#define __colorbarbase_h__ + +#include "widget.h" + +#include +#include + +// Widget ConfigSpecs Defines + +#define CONFIGORIENTATION 7 +#define CONFIGSIZE 8 +#define CONFIGFONT 9 +#define CONFIGFONTSTYLE 10 +#define CONFIGFONTSIZE 11 +#define CONFIGNUMERICS 12 +#define CONFIGSPACE 13 +#define CONFIGTICKS 14 + +// ColorbarBase + +class CBGrid; +class Filter; +class ColorTag; + +struct ColorbarBaseOptions { + Tk_Item item; // required by tk + int x, y; // Coordinates of positioning point on canvas + int width; // widget width + int height; // widget height + Tk_Anchor anchor; // Where to anchor widget relative to x,y + char* cmdName; // Suggested Tcl command name + + char* helvetica; // name of X11 font + char* courier; // name of X11 font + char* times; // name of X11 font + + Widget* widget; // pointer to widget class + + int orientation; // 0-horizontal, 1-vertical + int size; + + char* font; + int fontSize; + char* fontWeight; + char* fontSlant; + + int numerics; + int space; // 0-distance (linear), 1-value (AST) + int ticks; + + int colors; + int minColors; + int maxColors; + int privateCmap; + int privateColors; +}; + +class ColorbarBase : public Widget { + friend class CBGrid; + friend class ColorTag; + + protected: + XImage* xmap; + unsigned char* colorCells; + int colorCount; + + CBGrid* grid; + + int cnt; + double* lut; + + int invert; + + char** ticktxt; + int tickcnt; + int skipcnt; + + private: + int initColormap(); + + Tk_Font getFont(); + void lutToText(Tk_Font); + + void renderGrid(); + void renderGridNumerics(); + void renderGridAST(); + + void ps(); + void psHV(ostream&, Filter&, int, int); + void psGrid(); + void psGridNumerics(); + void psGridAST(); + +#ifdef MAC_OSX_TK + void macosxGrid(); + void macosxGridNumerics(); + void macosxGridAST(); +#endif + +#ifdef __WIN32 + void win32Grid(); + void win32GridNumerics(); + void win32GridAST(); +#endif + + protected: + void invalidPixmap(); + + int postscriptProc(int); // generate postscript + virtual void psHorz(ostream&, Filter&, int, int) =0; + virtual void psVert(ostream&, Filter&, int, int) =0; + + virtual void reset() =0; + + void updateColors(); + virtual void updateColorCells() =0; + virtual void updateColorsHorz() =0; + virtual void updateColorsVert() =0; + + int updatePixmap(const BBox&); + +#ifdef MAC_OSX_TK + virtual void macosx(float, int, int, const Vector&, const Vector&) =0; +#endif + +#ifdef __WIN32 + virtual void win32(float, int, int, const Vector&, const Vector&) =0; +#endif + + public: + ColorbarBase(Tcl_Interp*, Tk_Canvas, Tk_Item*); + virtual ~ColorbarBase(); + + virtual void adjustCmd(float, float) =0; + + int configure(int, const char* [], int); + + virtual void getBiasCmd() =0; + virtual void getColorbarCmd() =0; + virtual void getColormapCmd() =0; + virtual void getColormapNameCmd(int) =0; + virtual void getColormapFileNameCmd(int) =0; + virtual void getContrastCmd() =0; + virtual void getCurrentFileNameCmd() =0; + virtual void getCurrentIDCmd() =0; + virtual void getCurrentNameCmd() =0; + void getInvertCmd(); + void getNumericsCmd(); + virtual void getRGBChannelCmd() =0; + void getValueCmd(int,int); + + void invertCmd(int); + + virtual void listIDCmd() {} + virtual void listNameCmd() {} + virtual void loadCmd(const char*, const char*) {} + virtual void loadCmd(const char*, const char*, const char*) {} + + virtual void mapCmd(char*) {} + virtual void mapCmd(int) {} + + int parse(istringstream&); + + virtual void saveCmd(const char*) {} + virtual void saveCmd(int, const char*) {} + virtual void setColorbarCmd(int, float, float, int) {} + virtual void setColorbarCmd(float, float, float, float, float, float, int) {} + void setColormapLevelCmd(); + void setColormapLevelCmd(int, double*); + virtual void setColormapWindowCmd(char*) {} + virtual void setRGBChannelCmd(const char*) {} + + virtual void getTagCmd() {} + virtual void getTagCmd(int,int) {} + virtual void tagCmd(const char*) {} + virtual void tagCmd(int, const Vector&, const char*) {} + virtual void tagDeleteCmd() {} + virtual void tagDeleteCmd(int,int) {} + virtual void tagEditBeginCmd(int,int,const char*) {} + virtual void tagEditMotionCmd(int,int) {} + virtual void tagEditEndCmd(int,int) {} + virtual void tagLoadCmd(const char*) {} + virtual void tagSaveCmd(const char*) {} + +#ifdef MAC_OSX_TK + void macosxPrintCmd(); +#endif + +#ifdef __WIN32 + void win32PrintCmd(); +#endif +}; + +#endif + diff --git a/tksao/colorbar/colorbarrgb.C b/tksao/colorbar/colorbarrgb.C new file mode 100644 index 0000000..83cbd70 --- /dev/null +++ b/tksao/colorbar/colorbarrgb.C @@ -0,0 +1,490 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "colorbarrgb.h" +#include "util.h" +#include "ps.h" + +ColorbarRGB::ColorbarRGB(Tcl_Interp* i,Tk_Canvas c,Tk_Item* item) + : ColorbarBase(i,c,item) +{ + channel = 0; + + for (int i=0; i<3; i++) { + bias[i] = .5; + contrast[i] = 1.0; + } +} + +int ColorbarRGB::calcContrastBias(int i, float bb, float cc) +{ + // if default (contrast = 1.0 && bias = .5) return + if (fabs(bb - 0.5) < 0.0001 && fabs(cc - 1.0) < 0.0001) + return i; + + // map i to range of 0 to 1.0 + // shift by bias (if invert, bias = 1-bias) + // multiply by contrast + // shift to center of region + // expand back to number of dynamic colors + float b = invert ? 1-bb : bb; + int r = (int)(((((float)i / colorCount) - b) * cc + .5 ) * colorCount); + + // clip to bounds if out of range + + if (r < 0) + return 0; + else if (r >= colorCount) + return colorCount-1; + else + return r; +} + +void ColorbarRGB::psHorz(ostream& str, Filter& filter, int width, int height) +{ + // red + for (int jj=0; jj<(int)(height/3.); jj++) { + for (int ii=0; iiorientation) { + // blue + for (int jj=0; jj<(int)(height/3.); jj++) + for (int ii=0; iiorientation) { + // blue + for (int jj=0; jj<(int)(height/3.); jj++) { + for (int ii=0; iiconfigure(argc, (const char**)argv, 0) != TCL_OK) { + delete colorbar; + Tcl_AppendResult(interp, " error occured while creating colorbar.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// ColorbarRGBTrueColor16 + +ColorbarRGBTrueColor16::ColorbarRGBTrueColor16(Tcl_Interp* i, Tk_Canvas c, + Tk_Item* item) + : ColorbarRGB(i,c,item), TrueColor16(visual) +{ + configSpecs = colorbarRGBTrueColor16Specs; // colorbar configure options +} + +void ColorbarRGBTrueColor16::updateColorsHorz() +{ + int width = options->width-2; + int height = ((ColorbarBaseOptions*)options)->size-2; + char* data = xmap->data; + + // if we have cross platforms, we need to byte swap + unsigned char row[xmap->bytes_per_line]; + if ((!xmap->byte_order && lsb()) || (xmap->byte_order && !lsb())) { + // red + for (int ii=0; ii0 ? ((r & rm_) << rs_) : ((r & rm_) >> -rs_); + memcpy(row+ii*2, &a, 2); + } + for (int jj=0; jj<(int)(height/3.); jj++) + memcpy(data+(jj*xmap->bytes_per_line), row, xmap->bytes_per_line); + + // green + for (int ii=0; ii0 ? ((g & gm_) << gs_) : ((g & gm_) >> -gs_); + memcpy(row+ii*2, &a, 2); + } + for (int jj=(int)(height/3.); jj<(int)(height*2/3.); jj++) + memcpy(data+(jj*xmap->bytes_per_line), row, xmap->bytes_per_line); + + // blue + for (int ii=0; ii0 ? ((b & bm_) << bs_) : ((b & bm_) >> -bs_); + memcpy(row+ii*2, &a, 2); + } + for (int jj=(int)(height*2/3.); jjbytes_per_line), row, xmap->bytes_per_line); + + } + else { + // red + for (int ii=0; ii0 ? ((r & rm_) << rs_) : ((r & rm_) >> -rs_); + unsigned char* rr = (unsigned char*)(&a); + *(row+ii*2) = *(rr+1); + *(row+ii*2+1) = *(rr); + } + for (int jj=0; jj<(int)(height/3.); jj++) + memcpy(data+(jj*xmap->bytes_per_line), row, xmap->bytes_per_line); + + // green + for (int ii=0; ii0 ? ((g & gm_) << gs_) : ((g & gm_) >> -gs_); + unsigned char* rr = (unsigned char*)(&a); + *(row+ii*2) = *(rr+1); + *(row+ii*2+1) = *(rr); + } + for (int jj=(int)(height/3.); jj<(int)(height*2/3.); jj++) + memcpy(data+(jj*xmap->bytes_per_line), row, xmap->bytes_per_line); + + // blue + for (int ii=0; ii0 ? ((b & bm_) << bs_) : ((b & bm_) >> -bs_); + unsigned char* rr = (unsigned char*)(&a); + *(row+ii*2) = *(rr+1); + *(row+ii*2+1) = *(rr); + } + for (int jj=(int)(height*2/3.); jjbytes_per_line), row, xmap->bytes_per_line); + } +} + +void ColorbarRGBTrueColor16::updateColorsVert() +{ + int width = ((ColorbarBaseOptions*)options)->size-2; + int height = options->height-2; + char* data = xmap->data; + + // if we have cross platforms, we need to byte swap + if ((!xmap->byte_order && lsb()) || (xmap->byte_order && !lsb())) { + for (int jj=height-1; jj>=0; jj--, data+=xmap->bytes_per_line) { + + // red + { + unsigned short r = colorCells[((int)(double(jj)/height*colorCount))*3]; + unsigned short a = 0; + a |= rs_>0 ? ((r & rm_) << rs_) : ((r & rm_) >> -rs_); + for (int ii=0; ii<(int)(width/3.); ii++) + memcpy(data+ii*2, &a, 2); + } + + // green + { + unsigned short g =colorCells[((int)(double(jj)/height*colorCount))*3+1]; + unsigned short a = 0; + a |= gs_>0 ? ((g & gm_) << gs_) : ((g & gm_) >> -gs_); + for (int ii=(int)(width/3.); ii<(int)(width*2/3.); ii++) + memcpy(data+ii*2, &a, 2); + } + + // blue + { + unsigned short b =colorCells[((int)(double(jj)/height*colorCount))*3+2]; + unsigned short a = 0; + a |= bs_>0 ? ((b & bm_) << bs_) : ((b & bm_) >> -bs_); + for (int ii=(int)(width*2/3.); ii=0; jj--, data+=xmap->bytes_per_line) { + + // red + { + unsigned short r = colorCells[((int)(double(jj)/height*colorCount))*3]; + unsigned short a = 0; + a |= rs_>0 ? ((r & rm_) << rs_) : ((r & rm_) >> -rs_); + unsigned char* rr = (unsigned char*)(&a); + for (int ii=0; ii<(int)(width/3.); ii++) { + *(data+ii*2) = *(rr+1); + *(data+ii*2+1) = *(rr); + } + } + + // green + { + unsigned short g =colorCells[((int)(double(jj)/height*colorCount))*3+1]; + unsigned short a = 0; + a |= gs_>0 ? ((g & gm_) << gs_) : ((g & gm_) >> -gs_); + unsigned char* rr = (unsigned char*)(&a); + for (int ii=(int)(width/3.); ii<(int)(width*2/3.); ii++) { + *(data+ii*2) = *(rr+1); + *(data+ii*2+1) = *(rr); + } + } + + // blue + { + unsigned short b =colorCells[((int)(double(jj)/height*colorCount))*3+2]; + unsigned short a = 0; + a |= bs_>0 ? ((b & bm_) << bs_) : ((b & bm_) >> -bs_); + unsigned char* rr = (unsigned char*)(&a); + for (int ii=(int)(width*2/3.); iiconfigure(argc, (const char**)argv, 0) != TCL_OK) { + delete colorbar; + Tcl_AppendResult(interp, " error occured while creating colorbar.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// ColorbarRGBTrueColor24 + +ColorbarRGBTrueColor24::ColorbarRGBTrueColor24(Tcl_Interp* i, Tk_Canvas c, + Tk_Item* item) + : ColorbarRGB(i,c,item), TrueColor24(visual) +{ + configSpecs = colorbarRGBTrueColor24Specs; // colorbar configure options +} + +void ColorbarRGBTrueColor24::updateColorsHorz() +{ + int width = options->width-2; + int height = ((ColorbarBaseOptions*)options)->size-2; + char* data = xmap->data; + + switch (xmap->bits_per_pixel) { + case 32: + updateColors32Horz(width, height, data); + break; + case 24: + updateColors24Horz(width, height, data); + break; + default: + internalError("Colorbar: bad bits/pixel"); + return; + } +} + +void ColorbarRGBTrueColor24::updateColorsVert() +{ + int width = ((ColorbarBaseOptions*)options)->size-2; + int height = options->height-2; + char* data = xmap->data; + + switch (xmap->bits_per_pixel) { + case 32: + updateColors32Vert(width, height, data); + break; + case 24: + updateColors24Vert(width, height, data); + break; + default: + internalError("Colorbar: bad bits/pixel"); + return; + } +} + +void ColorbarRGBTrueColor24::updateColors24Horz(int width, int height, + char* data) +{ + // if we have cross platforms, we need to byte swap + unsigned char row[xmap->bytes_per_line]; + if ((!xmap->byte_order && lsb()) || (xmap->byte_order && !lsb())) { + // red + for (int ii=0; iibytes_per_line), row, xmap->bytes_per_line); + + // green + for (int ii=0; iibytes_per_line), row, xmap->bytes_per_line); + + // blue + for (int ii=0; iibytes_per_line), row, xmap->bytes_per_line); + + } + else { + // red + for (int ii=0; iibytes_per_line), row, xmap->bytes_per_line); + + // green + for (int ii=0; iibytes_per_line), row, xmap->bytes_per_line); + + // blue + for (int ii=0; iibytes_per_line), row, xmap->bytes_per_line); + } +} + +void ColorbarRGBTrueColor24::updateColors24Vert(int width, int height, + char* data) +{ + // if we have cross platforms, we need to byte swap + if ((!xmap->byte_order && lsb()) || (xmap->byte_order && !lsb())) { + for (int jj=height-1; jj>=0; jj--, data+=xmap->bytes_per_line) { + + // red + { + unsigned int r = colorCells[(int)(double(jj)/height*colorCount)*3]; + unsigned int a = 0; + a |= r << rs_; + for (int ii=0; ii<(int)(width/3.); ii++) + memcpy(data+ii*3, &a, 3); + } + + // green + { + unsigned int g = colorCells[(int)(double(jj)/height*colorCount)*3+1]; + unsigned int a = 0; + a |= g << gs_; + for (int ii=(int)(width/3.); ii<(int)(width*2/3.); ii++) + memcpy(data+ii*3, &a, 3); + } + + // blue + { + unsigned int b = colorCells[(int)(double(jj)/height*colorCount)*3+2]; + unsigned int a = 0; + a |= b << bs_; + for (int ii=(int)(width*2/3.); ii=0; jj--, data+=xmap->bytes_per_line) { + + // red + { + unsigned int r = colorCells[(int)(double(jj)/height*colorCount)*3]; + unsigned int a = 0; + a |= r << rs_; + unsigned char* rr = (unsigned char*)(&a); + for (int ii=0; ii<(int)(width/3.); ii++) { + *(data+ii*3) = *(rr+3); + *(data+ii*3+1) = *(rr+2); + *(data+ii*3+2) = *(rr+1); + } + } + + // green + { + unsigned int g = colorCells[(int)(double(jj)/width*colorCount)*3+1]; + unsigned int a = 0; + a |= g << gs_; + unsigned char* rr = (unsigned char*)(&a); + for (int ii=(int)(width/3.); ii<(int)(width*2/3.); ii++) { + *(data+ii*3) = *(rr+3); + *(data+ii*3+1) = *(rr+2); + *(data+ii*3+2) = *(rr+1); + } + } + + // blue + { + unsigned int b = colorCells[(int)(double(jj)/width*colorCount)*3+2]; + unsigned int a = 0; + a |= b << bs_; + unsigned char* rr = (unsigned char*)(&a); + for (int ii=(int)(width*2/3.); iibytes_per_line]; + if ((!xmap->byte_order && lsb()) || (xmap->byte_order && !lsb())) { + + // red + for (int ii=0; iibytes_per_line), row, xmap->bytes_per_line); + + // green + for (int ii=0; iibytes_per_line), row, xmap->bytes_per_line); + + // blue + for (int ii=0; iibytes_per_line), row, xmap->bytes_per_line); + + } + else { + // red + for (int i=0; ibytes_per_line), row, xmap->bytes_per_line); + + // green + for (int i=0; ibytes_per_line), row, xmap->bytes_per_line); + + // blue + for (int i=0; ibytes_per_line), row, xmap->bytes_per_line); + } +} + +void ColorbarRGBTrueColor24::updateColors32Vert(int width, int height, + char* data) +{ + // if we have cross platforms, we need to byte swap + if ((!xmap->byte_order && lsb()) || (xmap->byte_order && !lsb())) { + for (int jj=height-1; jj>=0; jj--, data+=xmap->bytes_per_line) { + + // red + { + unsigned int r = colorCells[(int)(double(jj)/height*colorCount)*3]; + unsigned int a = 0; +#ifdef MAC_OSX_TK + a |= 0xff << 24; +#endif + a |= r << rs_; + for (int ii=0; ii<(int)(width/3.); ii++) + memcpy(data+ii*4, &a, 4); + } + + // green + { + unsigned int g = colorCells[(int)(double(jj)/height*colorCount)*3+1]; + unsigned int a = 0; +#ifdef MAC_OSX_TK + a |= 0xff << 24; +#endif + a |= g << gs_; + for (int ii=(int)(width/3.); ii<(int)(width*2/3.); ii++) + memcpy(data+ii*4, &a, 4); + } + + // blue + { + unsigned int b = colorCells[(int)(double(jj)/height*colorCount)*3+2]; + unsigned int a = 0; +#ifdef MAC_OSX_TK + a |= 0xff << 24; +#endif + a |= b << bs_; + for (int ii=(int)(width*2/3.); ii=0; jj--, data+=xmap->bytes_per_line) { + + // red + { + unsigned int r = colorCells[(int)(double(jj)/height*colorCount)*3]; + unsigned int a = 0; +#ifdef MAC_OSX_TK + a |= 0xff << 24; +#endif + a |= r << rs_; + unsigned char* rr = (unsigned char*)(&a); + for (int ii=0; ii<(int)(width/3.); ii++) { + *(data+ii*4) = *(rr+3); + *(data+ii*4+1) = *(rr+2); + *(data+ii*4+2) = *(rr+1); + *(data+ii*4+3) = *(rr); + } + } + + // green + { + unsigned int g = colorCells[(int)(double(jj)/height*colorCount)*3+1]; + unsigned int a = 0; +#ifdef MAC_OSX_TK + a |= 0xff << 24; +#endif + a |= g << gs_; + unsigned char* rr = (unsigned char*)(&a); + for (int ii=(int)(width/3.); ii<(int)(width*2/3.); ii++) { + *(data+ii*4) = *(rr+3); + *(data+ii*4+1) = *(rr+2); + *(data+ii*4+2) = *(rr+1); + *(data+ii*4+3) = *(rr); + } + } + + // blue + { + unsigned int b = colorCells[(int)(double(jj)/height*colorCount)*3+2]; + unsigned int a = 0; +#ifdef MAC_OSX_TK + a |= 0xff << 24; +#endif + a |= b << bs_; + unsigned char* rr = (unsigned char*)(&a); + for (int ii=(int)(width*2/3.); iiconfigure(argc, (const char**)argv, 0) != TCL_OK) { + delete colorbar; + Tcl_AppendResult(interp, " error occured while creating colorbar.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// ColorbarRGBTrueColor8 + +ColorbarRGBTrueColor8::ColorbarRGBTrueColor8(Tcl_Interp* i, Tk_Canvas c, + Tk_Item* item) + : ColorbarRGB(i,c,item), TrueColor8(visual) +{ + configSpecs = colorbarRGBTrueColor8Specs; // colorbar configure options +} + +void ColorbarRGBTrueColor8::updateColorsHorz() +{ + int width = options->width-2; + int height = ((ColorbarBaseOptions*)options)->size-2; + char* data = xmap->data; + + unsigned char row[xmap->bytes_per_line]; + + // red + for (int ii=0; ii> rs_; + } + for (int jj=0; jj<(int)(height/3.); jj++) + memcpy(data+(jj*xmap->bytes_per_line), row, xmap->bytes_per_line); + + // green + for (int ii=0; ii> gs_; + } + for (int jj=(int)(height/3.); jj<(int)(height*2/3.); jj++) + memcpy(data+(jj*xmap->bytes_per_line), row, xmap->bytes_per_line); + + // blue + for (int ii=0; ii> bs_; + } + for (int jj=(int)(height*2/3.); jjbytes_per_line), row, xmap->bytes_per_line); +} + +void ColorbarRGBTrueColor8::updateColorsVert() +{ + int width = ((ColorbarBaseOptions*)options)->size-2; + int height = options->height-2; + char* data = xmap->data; + + for (int jj=height-1; jj>=0; jj--, data+=xmap->bytes_per_line) { + + // red + { + char r = colorCells[((int)(double(jj)/height*colorCount))*3]; + char a = (r & rm_) >> rs_; + for (int ii=0; ii<(int)(width/3.); ii++) + data[ii] = a; + } + + // green + { + char g = colorCells[((int)(double(jj)/height*colorCount))*3+1]; + char a = (g & gm_) >> gs_; + for (int ii=(int)(width/3.); ii<(int)(width*2/3.); ii++) + data[ii] = a; + } + + // blue + { + char b =colorCells[((int)(double(jj)/height*colorCount))*3+2]; + char a = (b & bm_) >> bs_; + for (int ii=(int)(width*2/3.); iiconfigure(argc, (const char**)argv, 0) != TCL_OK) { + delete colorbar; + Tcl_AppendResult(interp, " error occured while creating colorbar.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// ColorbarTrueColor16 + +ColorbarTrueColor16::ColorbarTrueColor16(Tcl_Interp* i, Tk_Canvas c, + Tk_Item* item) + : Colorbar(i,c,item), TrueColor16(visual) +{ + configSpecs = colorbarTrueColor16Specs; // colorbar configure options + + loadDefaultCMaps(); +} + +void ColorbarTrueColor16::updateColorsHorz() +{ + int width = options->width-2; + int height = ((ColorbarBaseOptions*)options)->size-2; + char* data = xmap->data; + + // if we have cross platforms, we need to byte swap + if ((!xmap->byte_order && lsb()) || (xmap->byte_order && !lsb())) { + for (int ii=0; ii0 ? ((r & rm_) << rs_) : ((r & rm_) >> -rs_); + a |= gs_>0 ? ((g & gm_) << gs_) : ((g & gm_) >> -gs_); + a |= bs_>0 ? ((b & bm_) << bs_) : ((b & bm_) >> -bs_); + + memcpy(data+ii*2, &a, 2); + } + } + else { + for (int ii=0; ii0 ? ((r & rm_) << rs_) : ((r & rm_) >> -rs_); + a |= gs_>0 ? ((g & gm_) << gs_) : ((g & gm_) >> -gs_); + a |= bs_>0 ? ((b & bm_) << bs_) : ((b & bm_) >> -bs_); + + unsigned char* rr = (unsigned char*)(&a); + *(data+ii*2) = *(rr+1); + *(data+ii*2+1) = *(rr); + } + } + + // --and duplicate for remaining rows + for (int jj=1; jjbytes_per_line), data, xmap->bytes_per_line); +} + +void ColorbarTrueColor16::updateColorsVert() +{ + int width = ((ColorbarBaseOptions*)options)->size-2; + int height = options->height-2; + char* data = xmap->data; + + // if we have cross platforms, we need to byte swap + if ((!xmap->byte_order && lsb()) || (xmap->byte_order && !lsb())) { + for (int jj=height-1; jj>=0; jj--, data+=xmap->bytes_per_line) { + unsigned short r = colorCells[((int)(double(jj)/height*colorCount))*3+2]; + unsigned short g = colorCells[((int)(double(jj)/height*colorCount))*3+1]; + unsigned short b = colorCells[((int)(double(jj)/height*colorCount))*3]; + unsigned short a = 0; + a |= rs_>0 ? ((r & rm_) << rs_) : ((r & rm_) >> -rs_); + a |= gs_>0 ? ((g & gm_) << gs_) : ((g & gm_) >> -gs_); + a |= bs_>0 ? ((b & bm_) << bs_) : ((b & bm_) >> -bs_); + + for (int ii=0; ii=0; jj--, data+=xmap->bytes_per_line) { + unsigned short r = colorCells[((int)(double(jj)/height*colorCount))*3+2]; + unsigned short g = colorCells[((int)(double(jj)/height*colorCount))*3+1]; + unsigned short b = colorCells[((int)(double(jj)/height*colorCount))*3]; + unsigned short a = 0; + a |= rs_>0 ? ((r & rm_) << rs_) : ((r & rm_) >> -rs_); + a |= gs_>0 ? ((g & gm_) << gs_) : ((g & gm_) >> -gs_); + a |= bs_>0 ? ((b & bm_) << bs_) : ((b & bm_) >> -bs_); + + unsigned char* rr = (unsigned char*)(&a); + for (int ii=0; iiconfigure(argc, (const char**)argv, 0) != TCL_OK) { + delete colorbar; + Tcl_AppendResult(interp, " error occured while creating colorbar.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// ColorbarTrueColor24 + +ColorbarTrueColor24::ColorbarTrueColor24(Tcl_Interp* i, Tk_Canvas c, + Tk_Item* item) + : Colorbar(i,c,item), TrueColor24(visual) +{ + configSpecs = colorbarTrueColor24Specs; // colorbar configure options + + loadDefaultCMaps(); +} + +void ColorbarTrueColor24::updateColorsHorz() +{ + int width = options->width-2; + int height = ((ColorbarBaseOptions*)options)->size-2; + char* data = xmap->data; + + switch (xmap->bits_per_pixel) { + case 32: + updateColors32Horz(width, height, data); + break; + case 24: + updateColors24Horz(width, height, data); + break; + default: + internalError("Colorbar: bad bits/pixel"); + return; + } +} + +void ColorbarTrueColor24::updateColorsVert() +{ + int width = ((ColorbarBaseOptions*)options)->size-2; + int height = options->height-2; + char* data = xmap->data; + + switch (xmap->bits_per_pixel) { + case 32: + updateColors32Vert(width, height, data); + break; + case 24: + updateColors24Vert(width, height, data); + break; + default: + internalError("Colorbar: bad bits/pixel"); + return; + } +} + +void ColorbarTrueColor24::updateColors24Horz(int width, int height, char* data) +{ + // if we have cross platforms, we need to byte swap + if ((!xmap->byte_order && lsb()) || (xmap->byte_order && !lsb())) { + for (int ii=0; iibytes_per_line), data, xmap->bytes_per_line); +} + +void ColorbarTrueColor24::updateColors24Vert(int width, int height, char* data) +{ + // if we have cross platforms, we need to byte swap + if ((!xmap->byte_order && lsb()) || (xmap->byte_order && !lsb())) { + for (int jj=height-1; jj>=0; jj--, data+=xmap->bytes_per_line) { + unsigned int r = colorCells[(int)(double(jj)/height*colorCount)*3+2]; + unsigned int g = colorCells[(int)(double(jj)/height*colorCount)*3+1]; + unsigned int b = colorCells[(int)(double(jj)/height*colorCount)*3]; + unsigned int a = 0; + a |= r << rs_; + a |= g << gs_; + a |= b << bs_; + + for (int ii=0; ii=0; jj--, data+=xmap->bytes_per_line) { + unsigned int r = colorCells[(int)(double(jj)/height*colorCount)*3+2]; + unsigned int g = colorCells[(int)(double(jj)/height*colorCount)*3+1]; + unsigned int b = colorCells[(int)(double(jj)/height*colorCount)*3]; + unsigned int a = 0; + a |= r << rs_; + a |= g << gs_; + a |= b << bs_; + + unsigned char* rr = (unsigned char*)(&a); + for (int ii=0; iibyte_order && lsb()) || (xmap->byte_order && !lsb())) { + for (int ii=0; iibytes_per_line), data, xmap->bytes_per_line); +} + +void ColorbarTrueColor24::updateColors32Vert(int width, int height, char* data) +{ + // if we have cross platforms, we need to byte swap + if ((!xmap->byte_order && lsb()) || (xmap->byte_order && !lsb())) { + for (int jj=height-1; jj>=0; jj--, data+=xmap->bytes_per_line) { + unsigned int r = colorCells[(int)(double(jj)/height*colorCount)*3+2]; + unsigned int g = colorCells[(int)(double(jj)/height*colorCount)*3+1]; + unsigned int b = colorCells[(int)(double(jj)/height*colorCount)*3]; + unsigned int a = 0; +#ifdef MAC_OSX_TK + a |= 0xff << 24; +#endif + a |= r << rs_; + a |= g << gs_; + a |= b << bs_; + + for (int ii=0; ii=0; jj--, data+=xmap->bytes_per_line) { + unsigned int r = colorCells[(int)(double(jj)/height*colorCount)*3+2]; + unsigned int g = colorCells[(int)(double(jj)/height*colorCount)*3+1]; + unsigned int b = colorCells[(int)(double(jj)/height*colorCount)*3]; + unsigned int a = 0; +#ifdef MAC_OSX_TK + a |= 0xff << 24; +#endif + a |= r << rs_; + a |= g << gs_; + a |= b << bs_; + + unsigned char* rr = (unsigned char*)(&a); + for (int ii=0; iiconfigure(argc, (const char**)argv, 0) != TCL_OK) { + delete colorbar; + Tcl_AppendResult(interp, " error occured while creating colorbar.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// ColorbarTrueColor8 + +ColorbarTrueColor8::ColorbarTrueColor8(Tcl_Interp* i, Tk_Canvas c, + Tk_Item* item) + : Colorbar(i,c,item), TrueColor8(visual) +{ + configSpecs = colorbarTrueColor8Specs; // colorbar configure options + + loadDefaultCMaps(); +} + +void ColorbarTrueColor8::updateColorsHorz() +{ + int width = options->width-2; + int height = ((ColorbarBaseOptions*)options)->size-2; + char* data = xmap->data; + + for (int ii=0; ii> bs_) | + ((colorCells[((int)(double(ii)/width*colorCount))*3+1] & gm_) >> gs_) | + ((colorCells[((int)(double(ii)/width*colorCount))*3+2] & rm_) >> rs_); + + // --and duplicate for remaining rows + for (int jj=1; jjbytes_per_line), data, xmap->bytes_per_line); +} + +void ColorbarTrueColor8::updateColorsVert() +{ + int width = ((ColorbarBaseOptions*)options)->size-2; + int height = options->height-2; + char* data = xmap->data; + + for (int jj=height-1; jj>=0; jj--, data+=xmap->bytes_per_line) { + char a = + ((colorCells[((int)(double(jj)/height*colorCount))*3] & bm_) >> bs_) | + ((colorCells[((int)(double(jj)/height*colorCount))*3+1] & gm_) >> gs_) | + ((colorCells[((int)(double(jj)/height*colorCount))*3+2] & rm_) >> rs_); + + for (int ii=0; ii +#include +#include + +#include +#include +#include +#include +using namespace std; + +class Colorbar; + +// ColorMapInfo + +class ColorMapInfo { +protected: + Colorbar* parent_; + + int id; + char* name; + char* fileName; + ColorMapInfo* next_; + ColorMapInfo* previous_; + +public: + ColorMapInfo(Colorbar* p); + virtual ~ColorMapInfo(); + + Colorbar* parent() {return parent_;} + + const char* getName() {return name;} + int getID() {return id;} + void setName(const char*); + const char* getFileName() {return fileName;} + void setFileName(const char*); + + ColorMapInfo* next() + {return next_;} + ColorMapInfo* previous() + {return previous_;} + void setNext(ColorMapInfo* n) + {next_ = n;} + void setPrevious(ColorMapInfo* p) + {previous_=p;} + + virtual ColorMapInfo* dup() =0; + virtual int load() =0; + virtual int load(const char*) =0; + virtual void save(const char*) =0; + + virtual unsigned char getRedChar(int, int) =0; + virtual unsigned char getGreenChar(int, int) =0; + virtual unsigned char getBlueChar(int, int) =0; + + virtual unsigned short getRedShrt(int, int) =0; + virtual unsigned short getGreenShrt(int, int) =0; + virtual unsigned short getBlueShrt(int, int) =0; +}; + +#endif + diff --git a/tksao/colorbar/colortag.C b/tksao/colorbar/colortag.C new file mode 100644 index 0000000..3975cd8 --- /dev/null +++ b/tksao/colorbar/colortag.C @@ -0,0 +1,78 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "colortag.h" +#include "colorbar.h" +#include "util.h" + +static int colorTagSeqID = 1; + +ColorTag::ColorTag(Colorbar* p, int b, int e, const char* clr) + : parent_(p), start_(b), stop_(e) +{ + id_ = colorTagSeqID++; + + colorname_ = dupstr(clr); + color_ = parent_->getXColor(colorname_); + + next_ =NULL; + previous_ =NULL; +} + +ColorTag::~ColorTag() +{ + if (colorname_) + delete [] colorname_; +} + +void ColorTag::move(int xx, int yy) +{ + int aa = start_+xx; + int bb = stop_+yy; + + if (aa>=bb-20) + bb = aa+20; + + if (bb>parent_->colorCount) { + bb = parent_->colorCount; + aa = parent_->colorCount - (stop_-start_); + } + + if (aa<0) { + aa = 0; + bb = stop_-start_; + } + + start_ =aa; + stop_ =bb; +} + +void ColorTag::set(int start, int stop, const char* color) +{ + start_ = start; + stop_ = stop; + if (colorname_) + delete [] colorname_; + colorname_ = dupstr(color); + color_ = parent_->getXColor(colorname_); +} + +void ColorTag::width(int size) +{ + int aa = start_-size/2; + int bb = stop_+size/2; + + if (bb>parent_->colorCount) { + bb = parent_->colorCount; + aa = parent_->colorCount - size; + } + + if (aa<0) { + aa = 0; + bb = size; + } + + start_ =aa; + stop_ =bb; +} diff --git a/tksao/colorbar/colortag.h b/tksao/colorbar/colortag.h new file mode 100644 index 0000000..4ade91a --- /dev/null +++ b/tksao/colorbar/colortag.h @@ -0,0 +1,62 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __colortag_h__ +#define __colortag_h__ + +#include +#include +#include + +#include +#include +#include +#include +using namespace std; + +#include +#include + +class Colorbar; + +class ColorTag { +protected: + int id_; + Colorbar* parent_; + + const char* colorname_; + XColor* color_; + + int start_; + int stop_; + + ColorTag* next_; + ColorTag* previous_; + +public: + ColorTag(Colorbar*, int, int, const char*); + virtual ~ColorTag(); + + int id() {return id_;} + Colorbar* parent() {return parent_;} + + int start() {return start_;} + int stop() {return stop_;} + const char* colorname() {return colorname_;} + void move(int,int); + void set(int,int,const char*); + void width(int); + + unsigned short colorRed() {return color_ ? color_->red : 0;} + unsigned short colorGreen() {return color_ ? color_->green : 0;} + unsigned short colorBlue() {return color_ ? color_->blue : 0;} + + ColorTag* next() {return next_;} + ColorTag* previous() {return previous_;} + void setNext(ColorTag* n) {next_ = n;} + void setPrevious(ColorTag* p) {previous_=p;} +}; + +#endif + diff --git a/tksao/colorbar/default.C b/tksao/colorbar/default.C new file mode 100644 index 0000000..ce93a63 --- /dev/null +++ b/tksao/colorbar/default.C @@ -0,0 +1,586 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "default.h" +#include "util.h" + +GreyColorMap::GreyColorMap(Colorbar* p) : SAOColorMap(p) +{ + name = dupstr("grey"); + fileName = dupstr("grey.sao"); + + red.append(new LIColor(0,0)); + red.append(new LIColor(1,1)); + + green.append(new LIColor(0,0)); + green.append(new LIColor(1,1)); + + blue.append(new LIColor(0,0)); + blue.append(new LIColor(1,1)); +} + +RedColorMap::RedColorMap(Colorbar* p) : SAOColorMap(p) +{ + name = dupstr("red"); + fileName = dupstr("red.sao"); + + red.append(new LIColor(0,0)); + red.append(new LIColor(1,1)); + + green.append(new LIColor(0,0)); + green.append(new LIColor(0,0)); + + blue.append(new LIColor(0,0)); + blue.append(new LIColor(0,0)); +} + +GreenColorMap::GreenColorMap(Colorbar* p) : SAOColorMap(p) +{ + name = dupstr("green"); + fileName = dupstr("green.sao"); + + red.append(new LIColor(0,0)); + red.append(new LIColor(0,0)); + + green.append(new LIColor(0,0)); + green.append(new LIColor(1,1)); + + blue.append(new LIColor(0,0)); + blue.append(new LIColor(0,0)); +} + +BlueColorMap::BlueColorMap(Colorbar* p) : SAOColorMap(p) +{ + name = dupstr("blue"); + fileName = dupstr("blue.sao"); + + red.append(new LIColor(0,0)); + red.append(new LIColor(0,0)); + + green.append(new LIColor(0,0)); + green.append(new LIColor(0,0)); + + blue.append(new LIColor(0,0)); + blue.append(new LIColor(1,1)); +} + +AColorMap::AColorMap(Colorbar* p) : SAOColorMap(p) +{ + name = dupstr("a"); + fileName = dupstr("a.sao"); + + red.append(new LIColor(0,0)); + red.append(new LIColor(.25,0)); + red.append(new LIColor(.5,1)); + red.append(new LIColor(1,1)); + + green.append(new LIColor(0,0)); + green.append(new LIColor(.25,1)); + green.append(new LIColor(.5,0)); + green.append(new LIColor(.77,0)); + green.append(new LIColor(1,1)); + + blue.append(new LIColor(0,0)); + blue.append(new LIColor(.125,0)); + blue.append(new LIColor(.5,1)); + blue.append(new LIColor(.64,.5)); + blue.append(new LIColor(.77,0)); + blue.append(new LIColor(1,0)); +} + +BColorMap::BColorMap(Colorbar* p) : SAOColorMap(p) +{ + name = dupstr("b"); + fileName = dupstr("b.sao"); + + red.append(new LIColor(0,0)); + red.append(new LIColor(.25,0)); + red.append(new LIColor(.5,1)); + red.append(new LIColor(1,1)); + + green.append(new LIColor(0,0)); + green.append(new LIColor(.5,0)); + green.append(new LIColor(.75,1)); + green.append(new LIColor(1,1)); + + blue.append(new LIColor(0,0)); + blue.append(new LIColor(.25,1)); + blue.append(new LIColor(.5,0)); + blue.append(new LIColor(.75,0)); + blue.append(new LIColor(1,1)); +} + +BBColorMap::BBColorMap(Colorbar* p) : SAOColorMap(p) +{ + name = dupstr("bb"); + fileName = dupstr("bb.sao"); + + red.append(new LIColor(0,0)); + red.append(new LIColor(.5,1)); + red.append(new LIColor(1,1)); + + green.append(new LIColor(0,0)); + green.append(new LIColor(.25,0)); + green.append(new LIColor(.75,1)); + green.append(new LIColor(1,1)); + + blue.append(new LIColor(0,0)); + blue.append(new LIColor(.5,0)); + blue.append(new LIColor(1,1)); +} + +HEColorMap::HEColorMap(Colorbar* p) : SAOColorMap(p) +{ + name = dupstr("he"); + fileName = dupstr("he.sao"); + + red.append(new LIColor(0,0)); + red.append(new LIColor(.015,.5)); + red.append(new LIColor(.25,.5)); + red.append(new LIColor(.5,.75)); + red.append(new LIColor(1,1)); + + green.append(new LIColor(0,0)); + green.append(new LIColor(.065,0)); + green.append(new LIColor(.125,.5)); + green.append(new LIColor(.25,.75)); + green.append(new LIColor(.5,.81)); + green.append(new LIColor(1,1)); + + blue.append(new LIColor(0,0)); + blue.append(new LIColor(.015,.125)); + blue.append(new LIColor(.03,.375)); + blue.append(new LIColor(.065,.625)); + blue.append(new LIColor(.25,.25)); + blue.append(new LIColor(1,1)); +} + +I8ColorMap::I8ColorMap(Colorbar* p) : LUTColorMap(p) +{ + name = dupstr("i8"); + fileName = dupstr("i8.lut"); + + colors.append(new RGBColor(0,0,0)); + colors.append(new RGBColor(0,1,0)); + colors.append(new RGBColor(0,0,1)); + colors.append(new RGBColor(0,1,1)); + colors.append(new RGBColor(1,0,0)); + colors.append(new RGBColor(1,1,0)); + colors.append(new RGBColor(1,0,1)); + colors.append(new RGBColor(1,1,1)); +} + +AIPSColorMap::AIPSColorMap(Colorbar* p) : LUTColorMap(p) +{ + name = dupstr("aips0"); + fileName = dupstr("aips0.lut"); + + colors.append(new RGBColor(.196,.196,.196)); + colors.append(new RGBColor(.475,.000,.608)); + colors.append(new RGBColor(.000,.000,.785)); + colors.append(new RGBColor(.373,.655,.925)); + colors.append(new RGBColor(.000,.596,.000)); + colors.append(new RGBColor(.000,.965,.000)); + colors.append(new RGBColor(1.00,1.00,.000)); + colors.append(new RGBColor(1.00,.694,.000)); + colors.append(new RGBColor(1.00,.000,.000)); +} + +HeatColorMap::HeatColorMap(Colorbar* p) : SAOColorMap(p) +{ + name = dupstr("heat"); + fileName = dupstr("heat.sao"); + + red.append(new LIColor(0,0)); + red.append(new LIColor(.34,1)); + red.append(new LIColor(1,1)); + + green.append(new LIColor(0,0)); + green.append(new LIColor(1,1)); + + blue.append(new LIColor(0,0)); + blue.append(new LIColor(.65,0)); + blue.append(new LIColor(.98,1)); + blue.append(new LIColor(1,1)); +} + +CoolColorMap::CoolColorMap(Colorbar* p) : SAOColorMap(p) +{ + name = dupstr("cool"); + fileName = dupstr("cool.sao"); + + red.append(new LIColor(0,0)); + red.append(new LIColor(.29,0)); + red.append(new LIColor(.76,.1)); + red.append(new LIColor(1,1)); + + green.append(new LIColor(0,0)); + green.append(new LIColor(.22,0)); + green.append(new LIColor(.96,1)); + green.append(new LIColor(1,1)); + + blue.append(new LIColor(0,0)); + blue.append(new LIColor(.53,1)); + blue.append(new LIColor(1,1)); +} + +RainbowColorMap::RainbowColorMap(Colorbar* p) : SAOColorMap(p) +{ + name = dupstr("rainbow"); + fileName = dupstr("rainbow.sao"); + + red.append(new LIColor(0,1)); + red.append(new LIColor(.2,0)); + red.append(new LIColor(.6,0)); + red.append(new LIColor(.8,1)); + red.append(new LIColor(1,1)); + + green.append(new LIColor(0,0)); + green.append(new LIColor(.2,0)); + green.append(new LIColor(.4,1)); + green.append(new LIColor(.8,1)); + green.append(new LIColor(1,0)); + + blue.append(new LIColor(0,1)); + blue.append(new LIColor(.4,1)); + blue.append(new LIColor(.6,0)); + blue.append(new LIColor(1,0)); +} + +StandardColorMap::StandardColorMap(Colorbar* p) : SAOColorMap(p) +{ + name = dupstr("standard"); + fileName = dupstr("standard.sao"); + + red.append(new LIColor(0,0)); + red.append(new LIColor(.333,.3)); + red.append(new LIColor(.333,0)); + red.append(new LIColor(.666,.3)); + red.append(new LIColor(.666,.3)); + red.append(new LIColor(1,1)); + + green.append(new LIColor(0,0)); + green.append(new LIColor(.333,.3)); + green.append(new LIColor(.333,.3)); + green.append(new LIColor(.666,1)); + green.append(new LIColor(.666,0)); + green.append(new LIColor(1,.3)); + + blue.append(new LIColor(0,0)); + blue.append(new LIColor(.333,1)); + blue.append(new LIColor(.333,0)); + blue.append(new LIColor(.666,.3)); + blue.append(new LIColor(.666,0)); + blue.append(new LIColor(1,.3)); +} + +StaircaseColorMap::StaircaseColorMap(Colorbar* p) : LUTColorMap(p) +{ + name = dupstr("staircase"); + fileName = dupstr("staircase.lut"); + + for (int ii=1; ii<=5; ii++) { + float kk = ii/5.; + colors.append(new RGBColor(kk*.3,kk*.3,kk*1)); + } + + for (int ii=1; ii<=5; ii++) { + float kk = ii/5.; + colors.append(new RGBColor(kk*.3,kk*1,kk*.3)); + } + + for (int ii=1; ii<=5; ii++) { + float kk = ii/5.; + colors.append(new RGBColor(kk*1,kk*.3,kk*.3)); + } +} + +ColorColorMap::ColorColorMap(Colorbar* p) : LUTColorMap(p) +{ + name = dupstr("color"); + fileName = dupstr("color.lut"); + + colors.append(new RGBColor(0,0,0)); + colors.append(new RGBColor(0.18431, 0.18431, 0.18431)); + colors.append(new RGBColor(0.37255, 0.37255, 0.37255)); + colors.append(new RGBColor(0.56078, 0.56078, 0.56078)); + colors.append(new RGBColor(0.74902, 0.74902, 0.74902)); + colors.append(new RGBColor(0.93725, 0.93725, 0.93725)); + colors.append(new RGBColor(0.00000, 0.18431, 0.93725)); + colors.append(new RGBColor(0.00000, 0.37255, 0.74902)); + colors.append(new RGBColor(0.00000, 0.49804, 0.49804)); + colors.append(new RGBColor(0.00000, 0.74902, 0.30980)); + colors.append(new RGBColor(0.00000, 0.93725, 0.00000)); + colors.append(new RGBColor(0.30980, 0.62353, 0.00000)); + colors.append(new RGBColor(0.49804, 0.49804, 0.00000)); + colors.append(new RGBColor(0.62353, 0.30980, 0.00000)); + colors.append(new RGBColor(0.93725, 0.00000, 0.00000)); + colors.append(new RGBColor(0.74902, 0.00000, 0.30980)); +} + +SLSColorMap::SLSColorMap(Colorbar* p) : LUTColorMap(p) +{ + name = dupstr("sls"); + fileName = dupstr("sls.lut"); + + colors.append(new RGBColor(0.000000, 0.000000, 0.000000)); + colors.append(new RGBColor(0.043442, 0.000000, 0.052883)); + colors.append(new RGBColor(0.086883, 0.000000, 0.105767)); + colors.append(new RGBColor(0.130325, 0.000000, 0.158650)); + colors.append(new RGBColor(0.173767, 0.000000, 0.211533)); + colors.append(new RGBColor(0.217208, 0.000000, 0.264417)); + colors.append(new RGBColor(0.260650, 0.000000, 0.317300)); + colors.append(new RGBColor(0.304092, 0.000000, 0.370183)); + colors.append(new RGBColor(0.347533, 0.000000, 0.423067)); + colors.append(new RGBColor(0.390975, 0.000000, 0.475950)); + colors.append(new RGBColor(0.434417, 0.000000, 0.528833)); + colors.append(new RGBColor(0.477858, 0.000000, 0.581717)); + colors.append(new RGBColor(0.521300, 0.000000, 0.634600)); + colors.append(new RGBColor(0.506742, 0.000000, 0.640217)); + colors.append(new RGBColor(0.492183, 0.000000, 0.645833)); + colors.append(new RGBColor(0.477625, 0.000000, 0.651450)); + colors.append(new RGBColor(0.463067, 0.000000, 0.657067)); + colors.append(new RGBColor(0.448508, 0.000000, 0.662683)); + colors.append(new RGBColor(0.433950, 0.000000, 0.668300)); + colors.append(new RGBColor(0.419392, 0.000000, 0.673917)); + colors.append(new RGBColor(0.404833, 0.000000, 0.679533)); + colors.append(new RGBColor(0.390275, 0.000000, 0.685150)); + colors.append(new RGBColor(0.375717, 0.000000, 0.690767)); + colors.append(new RGBColor(0.361158, 0.000000, 0.696383)); + colors.append(new RGBColor(0.346600, 0.000000, 0.702000)); + colors.append(new RGBColor(0.317717, 0.000000, 0.712192)); + colors.append(new RGBColor(0.288833, 0.000000, 0.722383)); + colors.append(new RGBColor(0.259950, 0.000000, 0.732575)); + colors.append(new RGBColor(0.231067, 0.000000, 0.742767)); + colors.append(new RGBColor(0.202183, 0.000000, 0.752958)); + colors.append(new RGBColor(0.173300, 0.000000, 0.763150)); + colors.append(new RGBColor(0.144417, 0.000000, 0.773342)); + colors.append(new RGBColor(0.115533, 0.000000, 0.783533)); + colors.append(new RGBColor(0.086650, 0.000000, 0.793725)); + colors.append(new RGBColor(0.057767, 0.000000, 0.803917)); + colors.append(new RGBColor(0.028883, 0.000000, 0.814108)); + colors.append(new RGBColor(0.000000, 0.000000, 0.824300)); + colors.append(new RGBColor(0.000000, 0.019817, 0.838942)); + colors.append(new RGBColor(0.000000, 0.039633, 0.853583)); + colors.append(new RGBColor(0.000000, 0.059450, 0.868225)); + colors.append(new RGBColor(0.000000, 0.079267, 0.882867)); + colors.append(new RGBColor(0.000000, 0.099083, 0.897508)); + colors.append(new RGBColor(0.000000, 0.118900, 0.912150)); + colors.append(new RGBColor(0.000000, 0.138717, 0.926792)); + colors.append(new RGBColor(0.000000, 0.158533, 0.941433)); + colors.append(new RGBColor(0.000000, 0.178350, 0.956075)); + colors.append(new RGBColor(0.000000, 0.198167, 0.970717)); + colors.append(new RGBColor(0.000000, 0.217983, 0.985358)); + colors.append(new RGBColor(0.000000, 0.237800, 1.000000)); + colors.append(new RGBColor(0.000000, 0.268533, 1.000000)); + colors.append(new RGBColor(0.000000, 0.299267, 1.000000)); + colors.append(new RGBColor(0.000000, 0.330000, 1.000000)); + colors.append(new RGBColor(0.000000, 0.360733, 1.000000)); + colors.append(new RGBColor(0.000000, 0.391467, 1.000000)); + colors.append(new RGBColor(0.000000, 0.422200, 1.000000)); + colors.append(new RGBColor(0.000000, 0.452933, 1.000000)); + colors.append(new RGBColor(0.000000, 0.483667, 1.000000)); + colors.append(new RGBColor(0.000000, 0.514400, 1.000000)); + colors.append(new RGBColor(0.000000, 0.545133, 1.000000)); + colors.append(new RGBColor(0.000000, 0.575867, 1.000000)); + colors.append(new RGBColor(0.000000, 0.606600, 1.000000)); + colors.append(new RGBColor(0.000000, 0.631733, 0.975300)); + colors.append(new RGBColor(0.000000, 0.656867, 0.950600)); + colors.append(new RGBColor(0.000000, 0.682000, 0.925900)); + colors.append(new RGBColor(0.000000, 0.707133, 0.901200)); + colors.append(new RGBColor(0.000000, 0.732267, 0.876500)); + colors.append(new RGBColor(0.000000, 0.757400, 0.851800)); + colors.append(new RGBColor(0.000000, 0.782533, 0.827100)); + colors.append(new RGBColor(0.000000, 0.807667, 0.802400)); + colors.append(new RGBColor(0.000000, 0.832800, 0.777700)); + colors.append(new RGBColor(0.000000, 0.857933, 0.753000)); + colors.append(new RGBColor(0.000000, 0.883067, 0.728300)); + colors.append(new RGBColor(0.000000, 0.908200, 0.703600)); + colors.append(new RGBColor(0.000000, 0.901908, 0.676675)); + colors.append(new RGBColor(0.000000, 0.895617, 0.649750)); + colors.append(new RGBColor(0.000000, 0.889325, 0.622825)); + colors.append(new RGBColor(0.000000, 0.883033, 0.595900)); + colors.append(new RGBColor(0.000000, 0.876742, 0.568975)); + colors.append(new RGBColor(0.000000, 0.870450, 0.542050)); + colors.append(new RGBColor(0.000000, 0.864158, 0.515125)); + colors.append(new RGBColor(0.000000, 0.857867, 0.488200)); + colors.append(new RGBColor(0.000000, 0.851575, 0.461275)); + colors.append(new RGBColor(0.000000, 0.845283, 0.434350)); + colors.append(new RGBColor(0.000000, 0.838992, 0.407425)); + colors.append(new RGBColor(0.000000, 0.832700, 0.380500)); + colors.append(new RGBColor(0.000000, 0.832308, 0.354858)); + colors.append(new RGBColor(0.000000, 0.831917, 0.329217)); + colors.append(new RGBColor(0.000000, 0.831525, 0.303575)); + colors.append(new RGBColor(0.000000, 0.831133, 0.277933)); + colors.append(new RGBColor(0.000000, 0.830742, 0.252292)); + colors.append(new RGBColor(0.000000, 0.830350, 0.226650)); + colors.append(new RGBColor(0.000000, 0.829958, 0.201008)); + colors.append(new RGBColor(0.000000, 0.829567, 0.175367)); + colors.append(new RGBColor(0.000000, 0.829175, 0.149725)); + colors.append(new RGBColor(0.000000, 0.828783, 0.124083)); + colors.append(new RGBColor(0.000000, 0.828392, 0.098442)); + colors.append(new RGBColor(0.000000, 0.828000, 0.072800)); + colors.append(new RGBColor(0.033167, 0.834167, 0.066733)); + colors.append(new RGBColor(0.066333, 0.840333, 0.060667)); + colors.append(new RGBColor(0.099500, 0.846500, 0.054600)); + colors.append(new RGBColor(0.132667, 0.852667, 0.048533)); + colors.append(new RGBColor(0.165833, 0.858833, 0.042467)); + colors.append(new RGBColor(0.199000, 0.865000, 0.036400)); + colors.append(new RGBColor(0.232167, 0.871167, 0.030333)); + colors.append(new RGBColor(0.265333, 0.877333, 0.024267)); + colors.append(new RGBColor(0.298500, 0.883500, 0.018200)); + colors.append(new RGBColor(0.331667, 0.889667, 0.012133)); + colors.append(new RGBColor(0.364833, 0.895833, 0.006067)); + colors.append(new RGBColor(0.398000, 0.902000, 0.000000)); + colors.append(new RGBColor(0.430950, 0.902000, 0.000000)); + colors.append(new RGBColor(0.463900, 0.902000, 0.000000)); + colors.append(new RGBColor(0.496850, 0.902000, 0.000000)); + colors.append(new RGBColor(0.529800, 0.902000, 0.000000)); + colors.append(new RGBColor(0.562750, 0.902000, 0.000000)); + colors.append(new RGBColor(0.595700, 0.902000, 0.000000)); + colors.append(new RGBColor(0.628650, 0.902000, 0.000000)); + colors.append(new RGBColor(0.661600, 0.902000, 0.000000)); + colors.append(new RGBColor(0.694550, 0.902000, 0.000000)); + colors.append(new RGBColor(0.727500, 0.902000, 0.000000)); + colors.append(new RGBColor(0.760450, 0.902000, 0.000000)); + colors.append(new RGBColor(0.793400, 0.902000, 0.000000)); + colors.append(new RGBColor(0.810617, 0.897133, 0.003983)); + colors.append(new RGBColor(0.827833, 0.892267, 0.007967)); + colors.append(new RGBColor(0.845050, 0.887400, 0.011950)); + colors.append(new RGBColor(0.862267, 0.882533, 0.015933)); + colors.append(new RGBColor(0.879483, 0.877667, 0.019917)); + colors.append(new RGBColor(0.896700, 0.872800, 0.023900)); + colors.append(new RGBColor(0.913917, 0.867933, 0.027883)); + colors.append(new RGBColor(0.931133, 0.863067, 0.031867)); + colors.append(new RGBColor(0.948350, 0.858200, 0.035850)); + colors.append(new RGBColor(0.965567, 0.853333, 0.039833)); + colors.append(new RGBColor(0.982783, 0.848467, 0.043817)); + colors.append(new RGBColor(1.000000, 0.843600, 0.047800)); + colors.append(new RGBColor(0.995725, 0.824892, 0.051600)); + colors.append(new RGBColor(0.991450, 0.806183, 0.055400)); + colors.append(new RGBColor(0.987175, 0.787475, 0.059200)); + colors.append(new RGBColor(0.982900, 0.768767, 0.063000)); + colors.append(new RGBColor(0.978625, 0.750058, 0.066800)); + colors.append(new RGBColor(0.974350, 0.731350, 0.070600)); + colors.append(new RGBColor(0.970075, 0.712642, 0.074400)); + colors.append(new RGBColor(0.965800, 0.693933, 0.078200)); + colors.append(new RGBColor(0.961525, 0.675225, 0.082000)); + colors.append(new RGBColor(0.957250, 0.656517, 0.085800)); + colors.append(new RGBColor(0.952975, 0.637808, 0.089600)); + colors.append(new RGBColor(0.948700, 0.619100, 0.093400)); + colors.append(new RGBColor(0.952975, 0.600408, 0.085617)); + colors.append(new RGBColor(0.957250, 0.581717, 0.077833)); + colors.append(new RGBColor(0.961525, 0.563025, 0.070050)); + colors.append(new RGBColor(0.965800, 0.544333, 0.062267)); + colors.append(new RGBColor(0.970075, 0.525642, 0.054483)); + colors.append(new RGBColor(0.974350, 0.506950, 0.046700)); + colors.append(new RGBColor(0.978625, 0.488258, 0.038917)); + colors.append(new RGBColor(0.982900, 0.469567, 0.031133)); + colors.append(new RGBColor(0.987175, 0.450875, 0.023350)); + colors.append(new RGBColor(0.991450, 0.432183, 0.015567)); + colors.append(new RGBColor(0.995725, 0.413492, 0.007783)); + colors.append(new RGBColor(1.000000, 0.394800, 0.000000)); + colors.append(new RGBColor(0.998342, 0.361900, 0.000000)); + colors.append(new RGBColor(0.996683, 0.329000, 0.000000)); + colors.append(new RGBColor(0.995025, 0.296100, 0.000000)); + colors.append(new RGBColor(0.993367, 0.263200, 0.000000)); + colors.append(new RGBColor(0.991708, 0.230300, 0.000000)); + colors.append(new RGBColor(0.990050, 0.197400, 0.000000)); + colors.append(new RGBColor(0.988392, 0.164500, 0.000000)); + colors.append(new RGBColor(0.986733, 0.131600, 0.000000)); + colors.append(new RGBColor(0.985075, 0.098700, 0.000000)); + colors.append(new RGBColor(0.983417, 0.065800, 0.000000)); + colors.append(new RGBColor(0.981758, 0.032900, 0.000000)); + colors.append(new RGBColor(0.980100, 0.000000, 0.000000)); + colors.append(new RGBColor(0.955925, 0.000000, 0.000000)); + colors.append(new RGBColor(0.931750, 0.000000, 0.000000)); + colors.append(new RGBColor(0.907575, 0.000000, 0.000000)); + colors.append(new RGBColor(0.883400, 0.000000, 0.000000)); + colors.append(new RGBColor(0.859225, 0.000000, 0.000000)); + colors.append(new RGBColor(0.835050, 0.000000, 0.000000)); + colors.append(new RGBColor(0.810875, 0.000000, 0.000000)); + colors.append(new RGBColor(0.786700, 0.000000, 0.000000)); + colors.append(new RGBColor(0.762525, 0.000000, 0.000000)); + colors.append(new RGBColor(0.738350, 0.000000, 0.000000)); + colors.append(new RGBColor(0.714175, 0.000000, 0.000000)); + colors.append(new RGBColor(0.690000, 0.000000, 0.000000)); + colors.append(new RGBColor(0.715833, 0.083333, 0.083333)); + colors.append(new RGBColor(0.741667, 0.166667, 0.166667)); + colors.append(new RGBColor(0.767500, 0.250000, 0.250000)); + colors.append(new RGBColor(0.793333, 0.333333, 0.333333)); + colors.append(new RGBColor(0.819167, 0.416667, 0.416667)); + colors.append(new RGBColor(0.845000, 0.500000, 0.500000)); + colors.append(new RGBColor(0.870833, 0.583333, 0.583333)); + colors.append(new RGBColor(0.896667, 0.666667, 0.666667)); + colors.append(new RGBColor(0.922500, 0.750000, 0.750000)); + colors.append(new RGBColor(0.948333, 0.833333, 0.833333)); + colors.append(new RGBColor(0.974167, 0.916667, 0.916667)); + colors.append(new RGBColor(1.000000, 1.000000, 1.000000)); + colors.append(new RGBColor(1.000000, 1.000000, 1.000000)); + colors.append(new RGBColor(1.000000, 1.000000, 1.000000)); + colors.append(new RGBColor(1.000000, 1.000000, 1.000000)); + colors.append(new RGBColor(1.000000, 1.000000, 1.000000)); + colors.append(new RGBColor(1.000000, 1.000000, 1.000000)); + colors.append(new RGBColor(1.000000, 1.000000, 1.000000)); + colors.append(new RGBColor(1.000000, 1.000000, 1.000000)); +} + +HSVColorMap::HSVColorMap(Colorbar* p) : LUTColorMap(p) +{ + /* HSV: hue varies uniformly from 270 to 360 and back to 270. + * Value varies from zero to one using a cube root relation + * which causes the value to approach 1.0 rapidly away from zero. + * Saturation is zero near the endpoints, causing the curve + * to range from black to white at the endpoints, but ranges + * to 1.0 at the halfway point, causing nearly saturated colors + * in the middle of the range. + */ + + name = dupstr("hsv"); + fileName = dupstr("hsv.lut"); + int size = 200; + + for (int i=0; i= 360.0) + h -= 360.0; + + h /= 60.0; + int ii = (int)h; + float f = h - ii; + float p = v * (1 - s); + float q = v * (1 - s*f); + float t = v * (1 - s * (1.0 - f)); + + switch (ii) { + case 0: + colors.append(new RGBColor(v,t,p)); + break; + case 1: + colors.append(new RGBColor(q,v,p)); + break; + case 2: + colors.append(new RGBColor(p,v,t)); + break; + case 3: + colors.append(new RGBColor(p,q,v)); + break; + case 4: + colors.append(new RGBColor(t,p,v)); + break; + case 5: + colors.append(new RGBColor(v,p,q)); + break; + } + } +} diff --git a/tksao/colorbar/default.h b/tksao/colorbar/default.h new file mode 100644 index 0000000..a8e6393 --- /dev/null +++ b/tksao/colorbar/default.h @@ -0,0 +1,104 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __default_h__ +#define __default_h__ + +#include "sao.h" +#include "lut.h" + +class Colorbar; + +class GreyColorMap : public SAOColorMap { +public: + GreyColorMap(Colorbar*); +}; + +class RedColorMap : public SAOColorMap { +public: + RedColorMap(Colorbar*); +}; + +class GreenColorMap : public SAOColorMap { +public: + GreenColorMap(Colorbar*); +}; + +class BlueColorMap : public SAOColorMap { +public: + BlueColorMap(Colorbar*); +}; + +class AColorMap : public SAOColorMap { +public: + AColorMap(Colorbar*); +}; + +class BColorMap : public SAOColorMap { +public: + BColorMap(Colorbar*); +}; + +class BBColorMap : public SAOColorMap { +public: + BBColorMap(Colorbar*); +}; + +class HEColorMap : public SAOColorMap { +public: + HEColorMap(Colorbar*); +}; + +class I8ColorMap : public LUTColorMap { +public: + I8ColorMap(Colorbar*); +}; + +class AIPSColorMap : public LUTColorMap { +public: + AIPSColorMap(Colorbar*); +}; + +class HeatColorMap : public SAOColorMap { +public: + HeatColorMap(Colorbar*); +}; + +class CoolColorMap : public SAOColorMap { +public: + CoolColorMap(Colorbar*); +}; + +class RainbowColorMap : public SAOColorMap { +public: + RainbowColorMap(Colorbar*); +}; + +class StandardColorMap : public SAOColorMap { +public: + StandardColorMap(Colorbar*); +}; + +class StaircaseColorMap : public LUTColorMap { +public: + StaircaseColorMap(Colorbar*); +}; + +class ColorColorMap : public LUTColorMap { +public: + ColorColorMap(Colorbar*); +}; + +class SLSColorMap : public LUTColorMap { +public: + SLSColorMap(Colorbar*); +}; + +class HSVColorMap : public LUTColorMap { +public: + HSVColorMap(Colorbar*); +}; + +#endif + diff --git a/tksao/colorbar/lex.C b/tksao/colorbar/lex.C new file mode 100644 index 0000000..29c74d7 --- /dev/null +++ b/tksao/colorbar/lex.C @@ -0,0 +1,2070 @@ +#line 2 "colorbar/lex.C" + +#line 4 "colorbar/lex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer cbFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *cballoc (yy_size_t ); +void *cbrealloc (void *,yy_size_t ); +void cbfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 64 +#define YY_END_OF_BUFFER 65 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[244] = + { 0, + 0, 0, 65, 63, 62, 64, 63, 63, 63, 63, + 63, 54, 54, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 31, 63, 63, 63, 63, 63, + 63, 63, 63, 52, 63, 62, 61, 0, 61, 58, + 0, 61, 59, 61, 54, 56, 55, 61, 61, 61, + 61, 61, 4, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 22, 61, 61, 61, + 61, 61, 61, 61, 61, 33, 61, 35, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 0, 61, 60, 58, 59, 61, 61, 55, 57, + + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 15, 61, 61, 16, 61, 61, 61, 61, 24, + 61, 61, 61, 61, 29, 61, 61, 34, 61, 61, + 61, 61, 41, 61, 61, 44, 61, 61, 47, 61, + 61, 61, 53, 60, 61, 56, 61, 61, 3, 61, + 6, 61, 61, 61, 61, 61, 14, 61, 19, 17, + 61, 21, 61, 61, 26, 27, 61, 61, 32, 61, + 61, 61, 61, 61, 42, 43, 45, 61, 61, 61, + 61, 61, 61, 2, 61, 61, 61, 61, 12, 61, + 18, 61, 61, 25, 61, 61, 61, 37, 38, 39, + + 61, 46, 61, 49, 50, 61, 1, 61, 61, 61, + 61, 61, 11, 13, 20, 23, 28, 30, 61, 61, + 61, 51, 5, 61, 61, 61, 61, 61, 61, 48, + 8, 7, 61, 10, 61, 61, 61, 61, 61, 9, + 36, 40, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 5, 4, 4, 4, 4, 6, 4, + 4, 4, 7, 4, 7, 8, 4, 9, 10, 11, + 12, 10, 10, 10, 10, 10, 10, 4, 4, 4, + 4, 4, 4, 4, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 4, + 4, 4, 4, 4, 4, 4, 38, 39, 40, 41, + + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 4, 63, 4, 64, 4, 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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[65] = + { 0, + 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3 + } ; + +static yyconst flex_int16_t yy_base[251] = + { 0, + 0, 0, 120, 587, 107, 587, 0, 64, 66, 65, + 69, 74, 84, 71, 82, 80, 72, 82, 98, 85, + 101, 105, 124, 121, 126, 131, 125, 71, 141, 141, + 137, 152, 142, 151, 170, 104, 0, 92, 194, 0, + 84, 196, 0, 194, 199, 203, 212, 221, 246, 178, + 182, 204, 0, 205, 182, 222, 197, 226, 226, 233, + 227, 229, 234, 254, 247, 253, 0, 236, 245, 245, + 249, 268, 268, 250, 265, 0, 279, 0, 267, 278, + 283, 270, 289, 275, 283, 292, 279, 289, 284, 301, + 285, 24, 328, 0, 587, 587, 336, 226, 344, 0, + + 299, 312, 309, 323, 327, 324, 327, 329, 328, 345, + 331, 0, 333, 349, 0, 331, 350, 353, 354, 0, + 355, 341, 361, 351, 0, 358, 363, 0, 349, 356, + 353, 373, 0, 382, 366, 0, 392, 377, 0, 380, + 380, 401, 0, 587, 409, 418, 383, 390, 0, 396, + 0, 393, 401, 405, 414, 406, 0, 423, 0, 0, + 423, 0, 414, 421, 0, 0, 415, 422, 0, 419, + 419, 415, 421, 430, 0, 0, 0, 438, 438, 440, + 60, 434, 430, 0, 447, 467, 453, 442, 0, 465, + 0, 451, 456, 0, 454, 467, 479, 0, 0, 0, + + 462, 0, 469, 0, 0, 464, 0, 476, 488, 489, + 475, 473, 0, 0, 0, 0, 0, 0, 475, 477, + 484, 0, 0, 481, 484, 501, 484, 501, 510, 0, + 0, 0, 517, 0, 505, 511, 523, 510, 517, 0, + 0, 0, 587, 67, 568, 571, 574, 577, 580, 583 + } ; + +static yyconst flex_int16_t yy_def[251] = + { 0, + 243, 1, 243, 243, 243, 243, 244, 245, 246, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 247, 243, 244, 248, 245, 244, + 249, 246, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 250, 247, 244, 243, 243, 244, 244, 244, 49, + + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 243, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + 244, 244, 0, 243, 243, 243, 243, 243, 243, 243 + } ; + +static yyconst flex_int16_t yy_nxt[652] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 13, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 7, 7, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 7, 32, 33, 7, 34, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 7, 7, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 7, 32, 33, + 7, 34, 35, 7, 38, 38, 41, 41, 40, 37, + 205, 43, 44, 45, 45, 45, 45, 46, 46, 46, + 46, 47, 45, 45, 45, 45, 50, 144, 58, 96, + 48, 47, 45, 45, 45, 45, 95, 59, 51, 54, + + 48, 63, 52, 81, 55, 36, 56, 60, 36, 49, + 61, 50, 57, 58, 64, 48, 53, 65, 62, 243, + 67, 66, 59, 51, 54, 48, 63, 52, 81, 55, + 68, 56, 60, 73, 49, 61, 69, 57, 75, 64, + 70, 53, 65, 62, 71, 67, 66, 74, 77, 86, + 72, 79, 76, 84, 80, 68, 78, 82, 73, 83, + 85, 69, 90, 75, 88, 70, 87, 91, 89, 71, + 92, 92, 74, 77, 86, 72, 79, 76, 84, 80, + 243, 78, 82, 243, 83, 85, 243, 90, 243, 88, + 243, 87, 91, 89, 38, 38, 41, 41, 40, 101, + + 102, 43, 46, 46, 46, 46, 47, 45, 45, 45, + 45, 46, 46, 46, 46, 48, 103, 104, 105, 97, + 46, 46, 46, 46, 101, 102, 108, 98, 48, 99, + 99, 99, 99, 94, 99, 99, 99, 99, 243, 109, + 48, 103, 104, 105, 97, 106, 111, 107, 112, 110, + 113, 108, 114, 48, 100, 100, 100, 100, 100, 100, + 100, 100, 100, 100, 109, 115, 116, 117, 118, 119, + 106, 111, 107, 112, 110, 113, 120, 114, 121, 122, + 123, 126, 124, 100, 100, 100, 100, 100, 100, 127, + 115, 116, 117, 118, 119, 125, 128, 129, 130, 131, + + 132, 120, 133, 121, 122, 123, 126, 124, 134, 135, + 136, 137, 138, 140, 127, 143, 141, 243, 139, 243, + 125, 128, 129, 130, 131, 132, 142, 133, 92, 92, + 243, 147, 148, 134, 135, 136, 137, 138, 140, 149, + 143, 141, 145, 139, 146, 146, 146, 146, 150, 151, + 152, 142, 99, 99, 99, 99, 147, 148, 153, 154, + 155, 156, 157, 158, 149, 159, 243, 160, 161, 162, + 163, 164, 165, 150, 151, 152, 166, 167, 168, 169, + 170, 171, 172, 153, 154, 155, 156, 157, 158, 173, + 159, 94, 160, 161, 162, 163, 164, 165, 175, 174, + + 176, 166, 167, 168, 169, 170, 171, 172, 177, 178, + 179, 180, 181, 183, 173, 184, 182, 146, 146, 146, + 146, 185, 186, 175, 174, 176, 146, 146, 146, 146, + 187, 188, 189, 177, 178, 179, 180, 190, 183, 191, + 184, 182, 192, 193, 194, 195, 185, 186, 196, 197, + 198, 199, 200, 201, 202, 187, 188, 189, 203, 204, + 206, 207, 190, 208, 191, 212, 243, 192, 193, 194, + 195, 213, 243, 196, 197, 198, 199, 200, 201, 202, + 209, 214, 215, 203, 204, 206, 207, 216, 208, 217, + 212, 210, 218, 219, 220, 221, 213, 211, 222, 223, + + 224, 225, 226, 227, 228, 209, 214, 215, 229, 230, + 231, 232, 216, 233, 217, 234, 210, 218, 219, 220, + 221, 235, 211, 222, 223, 224, 225, 226, 227, 228, + 236, 237, 238, 229, 230, 231, 232, 239, 233, 240, + 234, 241, 242, 243, 243, 243, 235, 243, 243, 243, + 243, 243, 243, 243, 243, 236, 237, 238, 243, 243, + 243, 243, 239, 243, 240, 243, 241, 242, 39, 243, + 39, 42, 243, 42, 93, 243, 93, 38, 243, 38, + 41, 243, 41, 92, 243, 92, 3, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243 + } ; + +static yyconst flex_int16_t yy_chk[652] = + { 0, + 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, 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, 1, 1, + 1, 1, 1, 1, 8, 8, 9, 9, 8, 244, + 181, 9, 10, 10, 10, 10, 10, 11, 11, 11, + 11, 12, 12, 12, 12, 12, 14, 92, 17, 41, + 12, 13, 13, 13, 13, 13, 38, 18, 15, 16, + + 13, 20, 15, 28, 16, 36, 16, 18, 5, 12, + 19, 14, 16, 17, 20, 12, 15, 21, 19, 3, + 22, 21, 18, 15, 16, 13, 20, 15, 28, 16, + 22, 16, 18, 24, 12, 19, 22, 16, 25, 20, + 23, 15, 21, 19, 23, 22, 21, 24, 26, 31, + 23, 27, 25, 30, 27, 22, 26, 29, 24, 29, + 30, 22, 33, 25, 32, 23, 31, 34, 32, 23, + 35, 35, 24, 26, 31, 23, 27, 25, 30, 27, + 0, 26, 29, 0, 29, 30, 0, 33, 0, 32, + 0, 31, 34, 32, 39, 39, 42, 42, 39, 50, + + 51, 42, 44, 44, 44, 44, 45, 45, 45, 45, + 45, 46, 46, 46, 46, 45, 52, 54, 55, 46, + 47, 47, 47, 47, 50, 51, 57, 48, 47, 48, + 48, 48, 48, 35, 98, 98, 98, 98, 0, 58, + 45, 52, 54, 55, 46, 56, 59, 56, 60, 58, + 61, 57, 62, 47, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 58, 63, 64, 65, 66, 68, + 56, 59, 56, 60, 58, 61, 69, 62, 70, 71, + 72, 74, 73, 49, 49, 49, 49, 49, 49, 75, + 63, 64, 65, 66, 68, 73, 77, 79, 80, 81, + + 82, 69, 83, 70, 71, 72, 74, 73, 84, 85, + 86, 87, 88, 89, 75, 91, 90, 0, 88, 0, + 73, 77, 79, 80, 81, 82, 90, 83, 93, 93, + 0, 101, 102, 84, 85, 86, 87, 88, 89, 103, + 91, 90, 97, 88, 97, 97, 97, 97, 104, 105, + 106, 90, 99, 99, 99, 99, 101, 102, 107, 108, + 109, 110, 111, 113, 103, 114, 0, 116, 117, 118, + 119, 121, 122, 104, 105, 106, 123, 124, 126, 127, + 129, 130, 131, 107, 108, 109, 110, 111, 113, 132, + 114, 93, 116, 117, 118, 119, 121, 122, 134, 132, + + 135, 123, 124, 126, 127, 129, 130, 131, 137, 138, + 140, 141, 142, 147, 132, 148, 142, 145, 145, 145, + 145, 150, 152, 134, 132, 135, 146, 146, 146, 146, + 153, 154, 155, 137, 138, 140, 141, 156, 147, 158, + 148, 142, 161, 163, 164, 167, 150, 152, 168, 170, + 171, 172, 173, 174, 178, 153, 154, 155, 179, 180, + 182, 183, 156, 185, 158, 187, 0, 161, 163, 164, + 167, 188, 0, 168, 170, 171, 172, 173, 174, 178, + 186, 190, 192, 179, 180, 182, 183, 193, 185, 195, + 187, 186, 196, 197, 201, 203, 188, 186, 206, 208, + + 209, 210, 211, 212, 219, 186, 190, 192, 220, 221, + 224, 225, 193, 226, 195, 227, 186, 196, 197, 201, + 203, 228, 186, 206, 208, 209, 210, 211, 212, 219, + 229, 233, 235, 220, 221, 224, 225, 236, 226, 237, + 227, 238, 239, 0, 0, 0, 228, 0, 0, 0, + 0, 0, 0, 0, 0, 229, 233, 235, 0, 0, + 0, 0, 236, 0, 237, 0, 238, 239, 245, 0, + 245, 246, 0, 246, 247, 0, 247, 248, 0, 248, + 249, 0, 249, 250, 0, 250, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "colorbar/lex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 12 "colorbar/lex.L" + #include + #include + #include + + #include "parser.H" + + extern YYSTYPE* cblval; +/* rules */ +#line 646 "colorbar/lex.C" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 26 "colorbar/lex.L" + + +#line 749 "colorbar/lex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 244 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 243 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 28 "colorbar/lex.L" +{return ADJUST_;} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 29 "colorbar/lex.L" +{return BEGIN_;} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 30 "colorbar/lex.L" +{return BIAS_;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 31 "colorbar/lex.L" +{return BW_;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 32 "colorbar/lex.L" +{return CHANNEL_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 33 "colorbar/lex.L" +{return CMYK_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 34 "colorbar/lex.L" +{return COLORMAP_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 35 "colorbar/lex.L" +{return COLORBAR_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 36 "colorbar/lex.L" +{return COLORSPACE_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 37 "colorbar/lex.L" +{return CONTRAST_;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 38 "colorbar/lex.L" +{return CURSOR_;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 39 "colorbar/lex.L" +{return DEBUG_;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 40 "colorbar/lex.L" +{return DELETE_;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 41 "colorbar/lex.L" +{return EDIT_;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 42 "colorbar/lex.L" +{return END_;} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 43 "colorbar/lex.L" +{return GET_;} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 44 "colorbar/lex.L" +{return GRAY_;} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 45 "colorbar/lex.L" +{return FALSE_;} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 46 "colorbar/lex.L" +{return FILE_;} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 47 "colorbar/lex.L" +{return HEIGHT_;} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 48 "colorbar/lex.L" +{return HIDE_;} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 49 "colorbar/lex.L" +{return ID_;} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 50 "colorbar/lex.L" +{return INVERT_;} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 51 "colorbar/lex.L" +{return ITT_;} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 52 "colorbar/lex.L" +{return LEVEL_;} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 53 "colorbar/lex.L" +{return LIST_;} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 54 "colorbar/lex.L" +{return LOAD_;} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 55 "colorbar/lex.L" +{return MACOSX_;} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 56 "colorbar/lex.L" +{return MAP_;} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 57 "colorbar/lex.L" +{return MOTION_;} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 58 "colorbar/lex.L" +{return N_;} + YY_BREAK +case 32: +YY_RULE_SETUP +#line 59 "colorbar/lex.L" +{return NAME_;} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 60 "colorbar/lex.L" +{return NO_;} + YY_BREAK +case 34: +YY_RULE_SETUP +#line 61 "colorbar/lex.L" +{return OFF_;} + YY_BREAK +case 35: +YY_RULE_SETUP +#line 62 "colorbar/lex.L" +{return ON_;} + YY_BREAK +case 36: +YY_RULE_SETUP +#line 63 "colorbar/lex.L" +{return POSTSCRIPT_;} + YY_BREAK +case 37: +YY_RULE_SETUP +#line 64 "colorbar/lex.L" +{return PRINT_;} + YY_BREAK +case 38: +YY_RULE_SETUP +#line 65 "colorbar/lex.L" +{return QUERY_;} + YY_BREAK +case 39: +YY_RULE_SETUP +#line 66 "colorbar/lex.L" +{return RESET_;} + YY_BREAK +case 40: +YY_RULE_SETUP +#line 67 "colorbar/lex.L" +{return RESOLUTION_;} + YY_BREAK +case 41: +YY_RULE_SETUP +#line 68 "colorbar/lex.L" +{return RGB_;} + YY_BREAK +case 42: +YY_RULE_SETUP +#line 69 "colorbar/lex.L" +{return SAVE_;} + YY_BREAK +case 43: +YY_RULE_SETUP +#line 70 "colorbar/lex.L" +{return SHOW_;} + YY_BREAK +case 44: +YY_RULE_SETUP +#line 71 "colorbar/lex.L" +{return TAG_;} + YY_BREAK +case 45: +YY_RULE_SETUP +#line 72 "colorbar/lex.L" +{return TRUE_;} + YY_BREAK +case 46: +YY_RULE_SETUP +#line 73 "colorbar/lex.L" +{return VALUE_;} + YY_BREAK +case 47: +YY_RULE_SETUP +#line 74 "colorbar/lex.L" +{return VAR_;} + YY_BREAK +case 48: +YY_RULE_SETUP +#line 75 "colorbar/lex.L" +{return VERSION_;} + YY_BREAK +case 49: +YY_RULE_SETUP +#line 76 "colorbar/lex.L" +{return WIDTH_;} + YY_BREAK +case 50: +YY_RULE_SETUP +#line 77 "colorbar/lex.L" +{return WIN32_;} + YY_BREAK +case 51: +YY_RULE_SETUP +#line 78 "colorbar/lex.L" +{return WINDOW_;} + YY_BREAK +case 52: +YY_RULE_SETUP +#line 79 "colorbar/lex.L" +{return Y_;} + YY_BREAK +case 53: +YY_RULE_SETUP +#line 80 "colorbar/lex.L" +{return YES_;} + YY_BREAK +case 54: +YY_RULE_SETUP +#line 82 "colorbar/lex.L" +{ // Integer + cblval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 55: +#line 88 "colorbar/lex.L" +case 56: +YY_RULE_SETUP +#line 88 "colorbar/lex.L" +{ // Real Number + cblval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 57: +YY_RULE_SETUP +#line 93 "colorbar/lex.L" +{ // Pointer + cblval->ptr = (void*)strtoul(yytext,NULL,16); + return POINTER; + } + YY_BREAK +case 58: +#line 99 "colorbar/lex.L" +case 59: +YY_RULE_SETUP +#line 99 "colorbar/lex.L" +{ // Quoted String + int ll = (yyleng-2)<(CBBUFSIZE-1) ? (yyleng-2):(CBBUFSIZE-1); + strncpy(cblval->str,yytext+1,ll); // skip the " " + cblval->str[ll] = '\0'; // Remove the '"' + return STRING; + } + YY_BREAK +case 60: +YY_RULE_SETUP +#line 106 "colorbar/lex.L" +{ // Quoted String + int ll = (yyleng-2)<(CBBUFSIZE-1) ? (yyleng-2):(CBBUFSIZE-1); + strncpy(cblval->str,yytext+1,ll); // skip the '{' + cblval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + YY_BREAK +case 61: +YY_RULE_SETUP +#line 113 "colorbar/lex.L" +{ // General String-- at least 2 printable chars + int ll = yyleng <(CBBUFSIZE-1) ? yyleng:(CBBUFSIZE-1); + strncpy(cblval->str,yytext,ll); + cblval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 62: +YY_RULE_SETUP +#line 120 "colorbar/lex.L" +{ // White Spaces + } + YY_BREAK +case 63: +YY_RULE_SETUP +#line 123 "colorbar/lex.L" +{ // Else, return the char + return yytext[0]; + } + YY_BREAK +case 64: +YY_RULE_SETUP +#line 127 "colorbar/lex.L" +ECHO; + YY_BREAK +#line 1169 "colorbar/lex.C" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + cbfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + cbfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + cbrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) cbrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 244 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 244 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 243); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) cballoc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) cballoc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + cbfree((void *) b->yy_ch_buf ); + + cbfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)cballoc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)cbrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) cballoc(new_size ); + + else + (yy_start_stack) = (int *) cbrealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *cballoc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *cbrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void cbfree (void * ptr ) +{ + free( (char *) ptr ); /* see cbrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 127 "colorbar/lex.L" + + + diff --git a/tksao/colorbar/lex.L b/tksao/colorbar/lex.L new file mode 100644 index 0000000..636d81e --- /dev/null +++ b/tksao/colorbar/lex.L @@ -0,0 +1,127 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ + +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + + #include "parser.H" + + extern YYSTYPE* cblval; +%} + +D [0-9] +E [Ee][+-]?{D}+ + +/* rules */ + +%% + +adjust {return ADJUST_;} +begin {return BEGIN_;} +bias {return BIAS_;} +bw {return BW_;} +channel {return CHANNEL_;} +cmyk {return CMYK_;} +colormap {return COLORMAP_;} +colorbar {return COLORBAR_;} +colorspace {return COLORSPACE_;} +contrast {return CONTRAST_;} +cursor {return CURSOR_;} +debug {return DEBUG_;} +delete {return DELETE_;} +edit {return EDIT_;} +end {return END_;} +get {return GET_;} +gray {return GRAY_;} +false {return FALSE_;} +file {return FILE_;} +height {return HEIGHT_;} +hide {return HIDE_;} +id {return ID_;} +invert {return INVERT_;} +itt {return ITT_;} +level {return LEVEL_;} +list {return LIST_;} +load {return LOAD_;} +macosx {return MACOSX_;} +map {return MAP_;} +motion {return MOTION_;} +n {return N_;} +name {return NAME_;} +no {return NO_;} +off {return OFF_;} +on {return ON_;} +postscript {return POSTSCRIPT_;} +print {return PRINT_;} +query {return QUERY_;} +reset {return RESET_;} +resolution {return RESOLUTION_;} +rgb {return RGB_;} +save {return SAVE_;} +show {return SHOW_;} +tag {return TAG_;} +true {return TRUE_;} +value {return VALUE_;} +var {return VAR_;} +version {return VERSION_;} +width {return WIDTH_;} +win32 {return WIN32_;} +window {return WINDOW_;} +y {return Y_;} +yes {return YES_;} + +[+-]?{D}+ { // Integer + cblval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + cblval->real = atof(yytext); + return REAL; + } + +0[xX][0-9a-fA-F]+ { // Pointer + cblval->ptr = (void*)strtoul(yytext,NULL,16); + return POINTER; + } + +\"[^\"\n]*\" | +\'[^\'\n]*\' { // Quoted String + int ll = (yyleng-2)<(CBBUFSIZE-1) ? (yyleng-2):(CBBUFSIZE-1); + strncpy(cblval->str,yytext+1,ll); // skip the " " + cblval->str[ll] = '\0'; // Remove the '"' + return STRING; + } + +\{[^\}\n]*\} { // Quoted String + int ll = (yyleng-2)<(CBBUFSIZE-1) ? (yyleng-2):(CBBUFSIZE-1); + strncpy(cblval->str,yytext+1,ll); // skip the '{' + cblval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + +[!-~][!-~]+ { // General String-- at least 2 printable chars + int ll = yyleng <(CBBUFSIZE-1) ? yyleng:(CBBUFSIZE-1); + strncpy(cblval->str,yytext,ll); + cblval->str[ll] = '\0'; + return STRING; + } + +[ \t]+ { // White Spaces + } + +. { // Else, return the char + return yytext[0]; + } + +%% diff --git a/tksao/colorbar/lut.C b/tksao/colorbar/lut.C new file mode 100644 index 0000000..3b51110 --- /dev/null +++ b/tksao/colorbar/lut.C @@ -0,0 +1,174 @@ +// Copyright (C) 1999-200 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "lut.h" +#include "colorbar.h" + +// LUT Parser Stuf +#undef yyFlexLexer +#define yyFlexLexer rgbFlexLexer +#include + +void* rgblval; +rgbFlexLexer* rgblexx; +extern int rgbparse(LUTColorMap*, rgbFlexLexer*); + +int rgblex(void* vval, rgbFlexLexer* ll) +{ + rgblval = vval; + rgblexx = ll; + return ll ? ll->yylex() : 0; +} + +void rgberror(LUTColorMap* cm, rgbFlexLexer* ll, const char* m) {} + +// RGBColor +istream& operator>>(istream& str, RGBColor& cc) +{ + str >> cc.red_ >> cc.green_ >> cc.blue_; + return str; +} + +ostream& operator<<(ostream& str, RGBColor& cc) +{ + str.setf(ios::fixed, ios::floatfield); + str << setw(8) << setprecision(6) + << cc.red_ << " " << cc.green_ << " " << cc.blue_ << endl; + return str; +} + +// LUTColorMap + +LUTColorMap::LUTColorMap(Colorbar* p) : ColorMapInfo(p) +{ +} + +void LUTColorMap::newRGBColor(float r, float g, float b) +{ + colors.append(new RGBColor(r,g,b)); +} + +int LUTColorMap::load() +{ + ifstream str(fileName); + if (!str) + return 0; + + rgbFlexLexer* ll = new rgbFlexLexer(&str); + rgbparse(this, ll); + delete ll; + + if (colors.isEmpty()) + return 0; // bailout + else + return 1; // we found at least one RGBColor +} + +int LUTColorMap::load(const char* var) +{ + const char* ccmd = Tcl_GetVar(parent_->getInterp(), var, + TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG); + if (!ccmd) + return 0; + + // only make command string as long as needed + // or the rest will be processed as garbage + int len = strlen(ccmd)+2; + char* buf = new char[len]; + memcpy(buf, ccmd, len); + + // add terminator to make parser happy + buf[len-2] = '\n'; + buf[len-1] = '\0'; + + string x(buf); + istringstream istr(x); + + rgbFlexLexer* ll = new rgbFlexLexer(&istr); + rgbparse(this, ll); + delete ll; + delete [] buf; + + if (colors.isEmpty()) + return 0; // bailout + else + return 1; // we found at least one RGBColor +} + +void LUTColorMap::save(const char* fn) +{ + ofstream fstr(fn); + if (!fstr) + return; + fstr << *this; +} + +unsigned char LUTColorMap::getRedChar(int ii, int count) +{ + int size = colors.count(); + int index = (int)((ii*size/count) + .5); + if (index>=0 && indexred() * UCHAR_MAX); + else + return 0; +} + +unsigned char LUTColorMap::getGreenChar(int ii, int count) +{ + int size = colors.count(); + int index = (int)((ii*size/count) + .5); + if (index>=0 && indexgreen() * UCHAR_MAX); + else + return 0; +} + +unsigned char LUTColorMap::getBlueChar(int ii, int count) +{ + int size = colors.count(); + int index = (int)((ii*size/count) + .5); + if (index>=0 && indexblue() * UCHAR_MAX); + else + return 0; +} + +unsigned short LUTColorMap::getRedShrt(int ii, int count) +{ + int size = colors.count(); + int index = (int)((ii*size/count) + .5); + if (index >=0 && index < size) + return (unsigned short)(colors[index]->red() * USHRT_MAX); + else + return 0; +} + +unsigned short LUTColorMap::getGreenShrt(int ii, int count) +{ + int size = colors.count(); + int index = (int)((ii*size/count) + .5); + if (index>=0 && indexgreen() * USHRT_MAX); + else + return 0; +} + +unsigned short LUTColorMap::getBlueShrt(int ii, int count) +{ + int size = colors.count(); + int index = (int)((ii*size/count) + .5); + if (index>=0 && indexblue() * USHRT_MAX); + else + return 0; +} + +ostream& operator<<(ostream& str, LUTColorMap& cc) +{ + cc.colors.head(); + do + str << *cc.colors.current(); + while (cc.colors.next()); + return str; +} diff --git a/tksao/colorbar/lut.h b/tksao/colorbar/lut.h new file mode 100644 index 0000000..d523a5a --- /dev/null +++ b/tksao/colorbar/lut.h @@ -0,0 +1,76 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __lut_h__ +#define __lut_h__ + +#include "colormap.h" +#include "list.h" + +// RGBColor +class RGBColor { +private: + float red_; + float green_; + float blue_; + RGBColor* next_; + RGBColor* previous_; + +public: + RGBColor() {red_=green_=blue_=0;} + RGBColor(float r, float g, float b) {red_=r; green_=g; blue_=b;} + RGBColor(const RGBColor& a) { + red_=a.red_; green_=a.green_; blue_=a.blue_; + next_=a.next_; previous_=a.previous_; + } + RGBColor& operator=(const RGBColor& a) { + red_=a.red_; green_=a.green_; blue_=a.blue_; + next_=a.next_; previous_=a.previous_; return *this; + } + + RGBColor* next() + {return next_;} + RGBColor* previous() + {return previous_;} + void setNext(RGBColor* n) + {next_ = n;} + void setPrevious(RGBColor* p) + {previous_=p;} + + float red() {return red_;} + float green() {return green_;} + float blue() {return blue_;} + + friend istream& operator>>(istream&, RGBColor&); + friend ostream& operator<<(ostream&, RGBColor&); +}; + +// LUTColorMap +class LUTColorMap : public ColorMapInfo { +protected: + List colors; + +public: + LUTColorMap(Colorbar* p); + + ColorMapInfo* dup() {return new LUTColorMap(*this);} + int load(); + int load(const char* var); + void save(const char*); + + unsigned char getRedChar(int, int); + unsigned char getGreenChar(int, int); + unsigned char getBlueChar(int, int); + + unsigned short getRedShrt(int, int); + unsigned short getGreenShrt(int, int); + unsigned short getBlueShrt(int, int); + + void newRGBColor(float,float,float); + + friend ostream& operator<<(ostream&, LUTColorMap&); +}; + +#endif + diff --git a/tksao/colorbar/lutlex.C b/tksao/colorbar/lutlex.C new file mode 100644 index 0000000..6956e12 --- /dev/null +++ b/tksao/colorbar/lutlex.C @@ -0,0 +1,1699 @@ +#line 2 "colorbar/lutlex.C" + +#line 4 "colorbar/lutlex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer rgbFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *rgballoc (yy_size_t ); +void *rgbrealloc (void *,yy_size_t ); +void rgbfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 18 +#define YY_END_OF_BUFFER 19 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[57] = + { 0, + 0, 0, 2, 2, 19, 17, 14, 16, 17, 17, + 17, 10, 13, 13, 13, 13, 13, 13, 13, 2, + 1, 14, 15, 0, 10, 12, 11, 10, 13, 13, + 13, 13, 5, 13, 7, 13, 13, 2, 0, 0, + 0, 11, 13, 13, 6, 13, 9, 11, 0, 12, + 13, 13, 8, 3, 4, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 5, 1, 5, 6, 1, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, + 1, 1, 1, 1, 8, 9, 10, 11, 12, 13, + 14, 10, 10, 10, 10, 15, 10, 16, 17, 10, + 10, 18, 19, 20, 21, 10, 10, 10, 22, 10, + 1, 1, 1, 1, 1, 1, 23, 24, 10, 25, + + 26, 27, 28, 10, 10, 10, 10, 29, 10, 30, + 31, 10, 10, 32, 33, 34, 35, 10, 10, 10, + 36, 10, 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, 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, + 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, 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, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[37] = + { 0, + 1, 1, 2, 1, 1, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3 + } ; + +static yyconst flex_int16_t yy_base[60] = + { 0, + 0, 0, 139, 138, 140, 143, 137, 143, 135, 31, + 129, 33, 123, 35, 40, 36, 38, 37, 44, 0, + 143, 124, 143, 117, 65, 50, 66, 68, 117, 76, + 78, 80, 116, 83, 115, 58, 79, 0, 53, 83, + 113, 93, 95, 98, 113, 99, 112, 108, 101, 96, + 100, 101, 91, 60, 46, 143, 131, 46, 134 + } ; + +static yyconst flex_int16_t yy_def[60] = + { 0, + 56, 1, 57, 57, 56, 56, 56, 56, 56, 56, + 56, 58, 58, 58, 58, 58, 58, 58, 58, 59, + 56, 56, 56, 56, 56, 56, 56, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 59, 56, 56, + 56, 58, 58, 58, 58, 58, 58, 56, 56, 56, + 58, 58, 58, 58, 58, 0, 56, 56, 56 + } ; + +static yyconst flex_int16_t yy_nxt[180] = + { 0, + 6, 7, 8, 9, 10, 11, 12, 13, 13, 13, + 14, 13, 15, 13, 13, 16, 17, 13, 13, 18, + 13, 19, 13, 13, 14, 13, 15, 13, 13, 16, + 17, 13, 13, 18, 13, 19, 24, 25, 27, 28, + 56, 56, 56, 56, 30, 56, 31, 32, 29, 56, + 34, 56, 33, 35, 36, 37, 26, 41, 30, 48, + 31, 40, 32, 56, 34, 56, 33, 35, 36, 37, + 27, 25, 26, 27, 28, 40, 39, 39, 46, 30, + 41, 56, 42, 56, 56, 56, 43, 49, 56, 50, + 39, 39, 46, 30, 44, 45, 56, 47, 56, 42, + + 56, 43, 50, 56, 56, 56, 56, 50, 44, 45, + 53, 47, 55, 54, 48, 51, 52, 56, 56, 48, + 56, 56, 56, 26, 53, 22, 55, 54, 56, 51, + 52, 20, 20, 20, 38, 26, 38, 23, 22, 56, + 21, 21, 5, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56 + } ; + +static yyconst flex_int16_t yy_chk[180] = + { 0, + 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, 1, + 1, 1, 1, 1, 1, 1, 10, 10, 12, 12, + 14, 16, 18, 17, 12, 15, 14, 15, 58, 19, + 17, 55, 16, 17, 18, 19, 26, 39, 12, 39, + 14, 26, 15, 36, 17, 54, 16, 17, 18, 19, + 25, 25, 27, 28, 28, 26, 25, 27, 36, 28, + 30, 30, 30, 31, 37, 32, 31, 40, 34, 40, + 25, 27, 36, 28, 32, 34, 53, 37, 42, 42, + + 43, 31, 50, 44, 46, 51, 52, 49, 32, 34, + 46, 37, 52, 51, 48, 43, 44, 47, 45, 41, + 35, 33, 29, 24, 46, 22, 52, 51, 13, 43, + 44, 57, 57, 57, 59, 11, 59, 9, 7, 5, + 4, 3, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "colorbar/lutlex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 12 "colorbar/lutlex.L" + #include + #include + #include + #include + + #include "util.h" + #include "lutparser.H" + + extern YYSTYPE* rgblval; + extern rgbFlexLexer* rgblexx; + +/* rules */ +#line 478 "colorbar/lutlex.C" + +#define INITIAL 0 +#define DISCARD 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 31 "colorbar/lutlex.L" + + +#line 582 "colorbar/lutlex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 57 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 56 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +#line 33 "colorbar/lutlex.L" +{ // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(rgblval->str,""); // feed a blank string + return STRING; + } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 40 "colorbar/lutlex.L" +{ // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(LUTBUFSIZE-1) ? yyleng:(LUTBUFSIZE-1); + strncpy(rgblval->str,yytext,ll); + rgblval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 48 "colorbar/lutlex.L" +{return DEBUG_;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 49 "colorbar/lutlex.L" +{return FALSE_;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 50 "colorbar/lutlex.L" +{return NO_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 51 "colorbar/lutlex.L" +{return OFF_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 52 "colorbar/lutlex.L" +{return ON_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 53 "colorbar/lutlex.L" +{return TRUE_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 54 "colorbar/lutlex.L" +{return YES_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 56 "colorbar/lutlex.L" +{ // Integer + rgblval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 11: +#line 62 "colorbar/lutlex.L" +case 12: +YY_RULE_SETUP +#line 62 "colorbar/lutlex.L" +{ // Real Number + rgblval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 67 "colorbar/lutlex.L" +{ // General String + int ll = yyleng <(LUTBUFSIZE-1) ? yyleng:(LUTBUFSIZE-1); + strncpy(rgblval->str,yytext,ll); + rgblval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 74 "colorbar/lutlex.L" +{ // White Spaces + } + YY_BREAK +case 15: +/* rule 15 can match eol */ +YY_RULE_SETUP +#line 77 "colorbar/lutlex.L" +{ // windows line feed + return '\n'; + } + YY_BREAK +case 16: +/* rule 16 can match eol */ +YY_RULE_SETUP +#line 81 "colorbar/lutlex.L" +{ // linefeed + return '\n'; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(DISCARD): +#line 85 "colorbar/lutlex.L" +{ // eof + return EOF_; + } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 89 "colorbar/lutlex.L" +{ // Else, return the char + return toupper(yytext[0]); + } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 93 "colorbar/lutlex.L" +ECHO; + YY_BREAK +#line 787 "colorbar/lutlex.C" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + rgbfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + rgbfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + rgbrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) rgbrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 57 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 57 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 56); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) rgballoc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) rgballoc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + rgbfree((void *) b->yy_ch_buf ); + + rgbfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)rgballoc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)rgbrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) rgballoc(new_size ); + + else + (yy_start_stack) = (int *) rgbrealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *rgballoc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *rgbrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void rgbfree (void * ptr ) +{ + free( (char *) ptr ); /* see rgbrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 93 "colorbar/lutlex.L" + + + +void rgbDiscard(int doit) +{ + if (rgblexx) + rgblexx->begin(DISCARD, doit); +} + +void rgbFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} + diff --git a/tksao/colorbar/lutlex.L b/tksao/colorbar/lutlex.L new file mode 100644 index 0000000..8d056af --- /dev/null +++ b/tksao/colorbar/lutlex.L @@ -0,0 +1,106 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ + +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + #include + + #include "util.h" + #include "lutparser.H" + + extern YYSTYPE* rgblval; + extern rgbFlexLexer* rgblexx; +%} + +%x DISCARD + +D [0-9] +E [Ee][+-]?{D}+ + +/* rules */ + +%% + +[\n] { // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(rgblval->str,""); // feed a blank string + return STRING; + } + +[^\n]* { // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(LUTBUFSIZE-1) ? yyleng:(LUTBUFSIZE-1); + strncpy(rgblval->str,yytext,ll); + rgblval->str[ll] = '\0'; + return STRING; + } + +debug {return DEBUG_;} +false {return FALSE_;} +no {return NO_;} +off {return OFF_;} +on {return ON_;} +true {return TRUE_;} +yes {return YES_;} + +[+-]?{D}+ { // Integer + rgblval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + rgblval->real = atof(yytext); + return REAL; + } + +[0-9A-Za-z]+ { // General String + int ll = yyleng <(LUTBUFSIZE-1) ? yyleng:(LUTBUFSIZE-1); + strncpy(rgblval->str,yytext,ll); + rgblval->str[ll] = '\0'; + return STRING; + } + +[ \t]+ { // White Spaces + } + +\r\n { // windows line feed + return '\n'; + } + +\n { // linefeed + return '\n'; + } + +<> { // eof + return EOF_; + } + +. { // Else, return the char + return toupper(yytext[0]); + } + +%% + +void rgbDiscard(int doit) +{ + if (rgblexx) + rgblexx->begin(DISCARD, doit); +} + +void rgbFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} diff --git a/tksao/colorbar/lutparser.C b/tksao/colorbar/lutparser.C new file mode 100644 index 0000000..3b42cec --- /dev/null +++ b/tksao/colorbar/lutparser.C @@ -0,0 +1,1632 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse rgbparse +#define yylex rgblex +#define yyerror rgberror +#define yylval rgblval +#define yychar rgbchar +#define yydebug rgbdebug +#define yynerrs rgbnerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + REAL = 258, + INT = 259, + STRING = 260, + EOF_ = 261, + DEBUG_ = 262, + FALSE_ = 263, + NO_ = 264, + OFF_ = 265, + ON_ = 266, + TRUE_ = 267, + YES_ = 268 + }; +#endif +/* Tokens. */ +#define REAL 258 +#define INT 259 +#define STRING 260 +#define EOF_ 261 +#define DEBUG_ 262 +#define FALSE_ 263 +#define NO_ 264 +#define OFF_ 265 +#define ON_ 266 +#define TRUE_ 267 +#define YES_ 268 + + + + +/* Copy the first part of user declarations. */ +#line 10 "colorbar/lutparser.Y" + +#define YYDEBUG 1 + +#define DISCARD_(x) {yyclearin; rgbDiscard(x);} + +#include +#include + +#include "lut.h" + +#undef yyFlexLexer +#define yyFlexLexer rgbFlexLexer +#include + +extern int rgblex(void*, rgbFlexLexer*); +extern void rgberror(LUTColorMap*, rgbFlexLexer*, const char*); +extern void rgbDiscard(int); + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 29 "colorbar/lutparser.Y" +{ +#define LUTBUFSIZE 4096 + char str[LUTBUFSIZE]; + int integer; + float real; +} +/* Line 193 of yacc.c. */ +#line 156 "colorbar/lutparser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 169 "colorbar/lutparser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 12 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 20 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 17 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 14 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 22 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 268 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 15, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 14, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 7, 10, 13, 17, 18, 22, 24, + 26, 28, 30, 32, 34 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 18, 0, -1, 18, 19, 21, -1, 19, 21, -1, + 7, 23, -1, 22, 22, 22, -1, -1, 14, 20, + 5, -1, 15, -1, 16, -1, 6, -1, 3, -1, + 4, -1, 11, -1, 10, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 54, 54, 55, 58, 59, 60, 60, 63, 64, + 65, 68, 69, 72, 73 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "REAL", "INT", "STRING", "EOF_", + "DEBUG_", "FALSE_", "NO_", "OFF_", "ON_", "TRUE_", "YES_", "'#'", + "'\\n'", "';'", "$accept", "commands", "command", "@1", "terminator", + "numeric", "debug", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 35, 10, 59 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 17, 18, 18, 19, 19, 20, 19, 21, 21, + 21, 22, 22, 23, 23 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 3, 2, 2, 3, 0, 3, 1, 1, + 1, 1, 1, 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 11, 12, 0, 6, 0, 0, 0, 14, 13, + 4, 0, 1, 0, 10, 8, 9, 3, 0, 7, + 2, 5 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 5, 6, 11, 17, 7, 10 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -6 +static const yytype_int8 yypact[] = +{ + -2, -6, -6, 5, -6, 0, 3, 7, -6, -6, + -6, 8, -6, 3, -6, -6, -6, -6, 7, -6, + -6, -6 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -6, -6, 15, -6, -5, -1, -6 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_uint8 yytable[] = +{ + 12, 1, 2, 1, 2, 3, 18, 3, 20, 14, + 1, 2, 4, 19, 4, 8, 9, 21, 15, 16, + 13 +}; + +static const yytype_uint8 yycheck[] = +{ + 0, 3, 4, 3, 4, 7, 7, 7, 13, 6, + 3, 4, 14, 5, 14, 10, 11, 18, 15, 16, + 5 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 7, 14, 18, 19, 22, 10, 11, + 23, 20, 0, 19, 6, 15, 16, 21, 22, 5, + 21, 22 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (cm, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, cm, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, LUTColorMap* cm, rgbFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, cm, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + LUTColorMap* cm; + rgbFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (cm); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, LUTColorMap* cm, rgbFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, cm, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + LUTColorMap* cm; + rgbFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, cm, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, LUTColorMap* cm, rgbFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, cm, ll) + YYSTYPE *yyvsp; + int yyrule; + LUTColorMap* cm; + rgbFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , cm, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, cm, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, LUTColorMap* cm, rgbFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, cm, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + LUTColorMap* cm; + rgbFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (cm); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (LUTColorMap* cm, rgbFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (LUTColorMap* cm, rgbFlexLexer* ll) +#else +int +yyparse (cm, ll) + LUTColorMap* cm; + rgbFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 5: +#line 59 "colorbar/lutparser.Y" + {cm->newRGBColor((yyvsp[(1) - (3)].real),(yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real));;} + break; + + case 6: +#line 60 "colorbar/lutparser.Y" + {DISCARD_(1);} + break; + + case 10: +#line 65 "colorbar/lutparser.Y" + {YYACCEPT;;} + break; + + case 11: +#line 68 "colorbar/lutparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 12: +#line 69 "colorbar/lutparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].integer);;} + break; + + case 13: +#line 72 "colorbar/lutparser.Y" + {yydebug=1;;} + break; + + case 14: +#line 73 "colorbar/lutparser.Y" + {yydebug=0;;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1417 "colorbar/lutparser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (cm, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (cm, ll, yymsg); + } + else + { + yyerror (cm, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, cm, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, cm, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (cm, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, cm, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, cm, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 75 "colorbar/lutparser.Y" + + diff --git a/tksao/colorbar/lutparser.H b/tksao/colorbar/lutparser.H new file mode 100644 index 0000000..77d2675 --- /dev/null +++ b/tksao/colorbar/lutparser.H @@ -0,0 +1,89 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + REAL = 258, + INT = 259, + STRING = 260, + EOF_ = 261, + DEBUG_ = 262, + FALSE_ = 263, + NO_ = 264, + OFF_ = 265, + ON_ = 266, + TRUE_ = 267, + YES_ = 268 + }; +#endif +/* Tokens. */ +#define REAL 258 +#define INT 259 +#define STRING 260 +#define EOF_ 261 +#define DEBUG_ 262 +#define FALSE_ 263 +#define NO_ 264 +#define OFF_ 265 +#define ON_ 266 +#define TRUE_ 267 +#define YES_ 268 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 29 "colorbar/lutparser.Y" +{ +#define LUTBUFSIZE 4096 + char str[LUTBUFSIZE]; + int integer; + float real; +} +/* Line 1529 of yacc.c. */ +#line 82 "colorbar/lutparser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/colorbar/lutparser.Y b/tksao/colorbar/lutparser.Y new file mode 100644 index 0000000..3100809 --- /dev/null +++ b/tksao/colorbar/lutparser.Y @@ -0,0 +1,75 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {LUTColorMap* cm} +%lex-param {rgbFlexLexer* ll} +%parse-param {rgbFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#define DISCARD_(x) {yyclearin; rgbDiscard(x);} + +#include +#include + +#include "lut.h" + +#undef yyFlexLexer +#define yyFlexLexer rgbFlexLexer +#include + +extern int rgblex(void*, rgbFlexLexer*); +extern void rgberror(LUTColorMap*, rgbFlexLexer*, const char*); +extern void rgbDiscard(int); +%} + +%union { +#define LUTBUFSIZE 4096 + char str[LUTBUFSIZE]; + int integer; + float real; +} + +%type numeric + +%token REAL +%token INT +%token STRING + +%token EOF_ + +%token DEBUG_ +%token FALSE_ +%token NO_ +%token OFF_ +%token ON_ +%token TRUE_ +%token YES_ + +%% + +commands: commands command terminator + | command terminator + ; + +command : DEBUG_ debug + | numeric numeric numeric {cm->newRGBColor($1,$2,$3);} + | '#' {DISCARD_(1)} STRING + ; + +terminator: '\n' + | ';' + | EOF_ {YYACCEPT;} + ; + +numeric : REAL {$$=$1;} + | INT {$$=$1;} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + ; +%% diff --git a/tksao/colorbar/parser.C b/tksao/colorbar/parser.C new file mode 100644 index 0000000..deb2241 --- /dev/null +++ b/tksao/colorbar/parser.C @@ -0,0 +1,2215 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse cbparse +#define yylex cblex +#define yyerror cberror +#define yylval cblval +#define yychar cbchar +#define yydebug cbdebug +#define yynerrs cbnerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + STRING = 260, + POINTER = 261, + ADJUST_ = 262, + BEGIN_ = 263, + BIAS_ = 264, + BW_ = 265, + CHANNEL_ = 266, + CMYK_ = 267, + COLORMAP_ = 268, + COLORBAR_ = 269, + COLORSPACE_ = 270, + CONTRAST_ = 271, + CURSOR_ = 272, + DEBUG_ = 273, + DELETE_ = 274, + EDIT_ = 275, + END_ = 276, + GET_ = 277, + GRAY_ = 278, + FALSE_ = 279, + FILE_ = 280, + HEIGHT_ = 281, + HIDE_ = 282, + ID_ = 283, + INVERT_ = 284, + ITT_ = 285, + LEVEL_ = 286, + LIST_ = 287, + LOAD_ = 288, + MACOSX_ = 289, + MAP_ = 290, + MOTION_ = 291, + N_ = 292, + NAME_ = 293, + NO_ = 294, + OFF_ = 295, + ON_ = 296, + POSTSCRIPT_ = 297, + PRINT_ = 298, + QUERY_ = 299, + RESET_ = 300, + RESOLUTION_ = 301, + RGB_ = 302, + SAVE_ = 303, + SHOW_ = 304, + TAG_ = 305, + TRUE_ = 306, + VALUE_ = 307, + VAR_ = 308, + VERSION_ = 309, + WIDTH_ = 310, + WIN32_ = 311, + WINDOW_ = 312, + Y_ = 313, + YES_ = 314 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define STRING 260 +#define POINTER 261 +#define ADJUST_ 262 +#define BEGIN_ 263 +#define BIAS_ 264 +#define BW_ 265 +#define CHANNEL_ 266 +#define CMYK_ 267 +#define COLORMAP_ 268 +#define COLORBAR_ 269 +#define COLORSPACE_ 270 +#define CONTRAST_ 271 +#define CURSOR_ 272 +#define DEBUG_ 273 +#define DELETE_ 274 +#define EDIT_ 275 +#define END_ 276 +#define GET_ 277 +#define GRAY_ 278 +#define FALSE_ 279 +#define FILE_ 280 +#define HEIGHT_ 281 +#define HIDE_ 282 +#define ID_ 283 +#define INVERT_ 284 +#define ITT_ 285 +#define LEVEL_ 286 +#define LIST_ 287 +#define LOAD_ 288 +#define MACOSX_ 289 +#define MAP_ 290 +#define MOTION_ 291 +#define N_ 292 +#define NAME_ 293 +#define NO_ 294 +#define OFF_ 295 +#define ON_ 296 +#define POSTSCRIPT_ 297 +#define PRINT_ 298 +#define QUERY_ 299 +#define RESET_ 300 +#define RESOLUTION_ 301 +#define RGB_ 302 +#define SAVE_ 303 +#define SHOW_ 304 +#define TAG_ 305 +#define TRUE_ 306 +#define VALUE_ 307 +#define VAR_ 308 +#define VERSION_ 309 +#define WIDTH_ 310 +#define WIN32_ 311 +#define WINDOW_ 312 +#define Y_ 313 +#define YES_ 314 + + + + +/* Copy the first part of user declarations. */ +#line 10 "colorbar/parser.Y" + +#define YYDEBUG 1 + +#include + +#include "colorbarbase.h" + +#undef yyFlexLexer +#define yyFlexLexer cbFlexLexer +#include + +extern int cblex(void*, cbFlexLexer*); +extern void cberror(ColorbarBase*, cbFlexLexer*, const char*); + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 25 "colorbar/parser.Y" +{ +#define CBBUFSIZE 1024 + float real; + int integer; + char str[CBBUFSIZE]; + void* ptr; +} +/* Line 193 of yacc.c. */ +#line 245 "colorbar/parser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 258 "colorbar/parser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 93 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 139 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 60 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 23 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 96 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 154 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 314 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 6, 10, 13, 16, 19, 21, 24, + 27, 30, 33, 36, 39, 42, 45, 47, 51, 54, + 57, 59, 61, 64, 66, 68, 70, 72, 74, 76, + 78, 80, 82, 84, 86, 88, 90, 95, 104, 107, + 110, 111, 114, 116, 118, 120, 122, 125, 129, 131, + 133, 135, 137, 140, 143, 147, 150, 152, 153, 156, + 158, 160, 161, 163, 165, 167, 170, 173, 175, 178, + 181, 184, 187, 191, 193, 195, 197, 200, 203, 206, + 208, 210, 212, 214, 217, 220, 223, 226, 231, 233, + 234, 237, 242, 246, 250, 252, 255 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 61, 0, -1, 18, 63, -1, 7, 62, 62, -1, + 14, 65, -1, 13, 66, -1, 22, 68, -1, 27, + -1, 29, 64, -1, 30, 70, -1, 32, 71, -1, + 33, 72, -1, 34, 74, -1, 35, 75, -1, 42, + 76, -1, 44, 17, -1, 45, -1, 47, 11, 5, + -1, 50, 78, -1, 48, 81, -1, 49, -1, 54, + -1, 56, 82, -1, 4, -1, 3, -1, 41, -1, + 40, -1, 3, -1, 59, -1, 58, -1, 41, -1, + 51, -1, 39, -1, 37, -1, 40, -1, 24, -1, + 3, 62, 62, 3, -1, 47, 62, 62, 62, 62, + 62, 62, 3, -1, 31, 67, -1, 57, 5, -1, + -1, 3, 6, -1, 9, -1, 14, -1, 13, -1, + 16, -1, 25, 38, -1, 25, 38, 3, -1, 26, + -1, 28, -1, 29, -1, 38, -1, 38, 3, -1, + 47, 11, -1, 52, 3, 3, -1, 50, 69, -1, + 55, -1, -1, 3, 3, -1, 5, -1, 3, -1, + -1, 28, -1, 38, -1, 30, -1, 30, 28, -1, + 30, 38, -1, 5, -1, 5, 5, -1, 53, 73, + -1, 30, 5, -1, 5, 5, -1, 5, 5, 5, + -1, 43, -1, 5, -1, 3, -1, 15, 77, -1, + 31, 3, -1, 46, 3, -1, 10, -1, 23, -1, + 47, -1, 12, -1, 19, 79, -1, 20, 80, -1, + 33, 5, -1, 48, 5, -1, 3, 62, 62, 5, + -1, 5, -1, -1, 3, 3, -1, 8, 3, 3, + 5, -1, 36, 3, 3, -1, 21, 3, 3, -1, + 5, -1, 3, 5, -1, 43, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 98, 98, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, + 116, 117, 118, 121, 122, 125, 126, 129, 131, 132, + 133, 134, 136, 137, 138, 139, 142, 143, 147, 148, + 151, 152, 155, 156, 157, 158, 159, 160, 161, 162, + 163, 164, 165, 166, 167, 168, 169, 172, 173, 176, + 177, 180, 181, 182, 183, 184, 185, 188, 189, 190, + 191, 194, 195, 198, 205, 206, 209, 211, 212, 215, + 216, 217, 218, 221, 222, 223, 224, 225, 226, 229, + 230, 233, 234, 235, 238, 239, 242 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "INT", "REAL", "STRING", "POINTER", + "ADJUST_", "BEGIN_", "BIAS_", "BW_", "CHANNEL_", "CMYK_", "COLORMAP_", + "COLORBAR_", "COLORSPACE_", "CONTRAST_", "CURSOR_", "DEBUG_", "DELETE_", + "EDIT_", "END_", "GET_", "GRAY_", "FALSE_", "FILE_", "HEIGHT_", "HIDE_", + "ID_", "INVERT_", "ITT_", "LEVEL_", "LIST_", "LOAD_", "MACOSX_", "MAP_", + "MOTION_", "N_", "NAME_", "NO_", "OFF_", "ON_", "POSTSCRIPT_", "PRINT_", + "QUERY_", "RESET_", "RESOLUTION_", "RGB_", "SAVE_", "SHOW_", "TAG_", + "TRUE_", "VALUE_", "VAR_", "VERSION_", "WIDTH_", "WIN32_", "WINDOW_", + "Y_", "YES_", "$accept", "command", "numeric", "debug", "yesno", + "colorbar", "colormap", "colormaplevel", "get", "getTag", "itt", "list", + "load", "loadVar", "macosx", "map", "postscript", "pscolorspace", "tag", + "tagdelete", "tagedit", "save", "win32", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 60, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 62, 62, 63, 63, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 65, 65, 66, 66, + 67, 67, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 69, 69, 70, + 70, 71, 71, 71, 71, 71, 71, 72, 72, 72, + 72, 73, 73, 74, 75, 75, 76, 76, 76, 77, + 77, 77, 77, 78, 78, 78, 78, 78, 78, 79, + 79, 80, 80, 80, 81, 81, 82 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 2, 3, 2, 2, 2, 1, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 3, 2, 2, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 4, 8, 2, 2, + 0, 2, 1, 1, 1, 1, 2, 3, 1, 1, + 1, 1, 2, 2, 3, 2, 1, 0, 2, 1, + 1, 0, 1, 1, 1, 2, 2, 1, 2, 2, + 2, 2, 3, 1, 1, 1, 2, 2, 2, 1, + 1, 1, 1, 2, 2, 2, 2, 4, 1, 0, + 2, 4, 3, 3, 1, 2, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 0, 0, 0, 0, 0, 7, 0, 0, 61, + 0, 0, 0, 0, 0, 16, 0, 0, 20, 0, + 21, 0, 0, 24, 23, 0, 40, 0, 5, 0, + 0, 4, 26, 25, 2, 42, 44, 43, 45, 0, + 48, 49, 50, 51, 0, 57, 0, 56, 6, 27, + 35, 33, 32, 34, 30, 31, 29, 28, 8, 60, + 59, 9, 62, 64, 63, 10, 67, 0, 0, 11, + 73, 12, 75, 74, 13, 0, 0, 0, 14, 15, + 0, 0, 94, 19, 0, 88, 89, 0, 0, 0, + 18, 96, 22, 1, 3, 0, 38, 39, 0, 0, + 46, 52, 53, 0, 55, 0, 65, 66, 68, 70, + 0, 69, 79, 82, 80, 81, 76, 77, 78, 17, + 95, 0, 0, 83, 0, 0, 0, 84, 85, 86, + 41, 0, 0, 47, 58, 54, 71, 0, 90, 0, + 0, 0, 36, 0, 72, 87, 0, 93, 92, 0, + 91, 0, 0, 37 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 22, 25, 34, 58, 31, 28, 96, 48, 104, + 61, 65, 69, 111, 71, 74, 78, 116, 90, 123, + 127, 83, 92 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -41 +static const yytype_int8 yypact[] = +{ + 33, 15, -15, 5, 13, 84, -41, -2, 9, -21, + -3, -40, 20, -5, -11, -41, 17, 67, -41, 10, + -41, -19, 31, -41, -41, 15, 41, 56, -41, 15, + 15, -41, -41, -41, -41, -41, -41, -41, -41, 26, + -41, -41, -41, 68, 25, 73, 76, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -17, -41, -41, 79, 80, 81, -41, + -41, -41, -41, -41, -41, 22, 85, 87, -41, -41, + 86, 89, -41, -41, 15, -41, 92, 12, 94, 96, + -41, -41, -41, -41, -41, 97, -41, -41, 15, 15, + 99, -41, -41, 101, -41, 102, -41, -41, -41, -41, + 103, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, 15, 108, -41, 111, 112, 113, -41, -41, -41, + -41, 114, 15, -41, -41, -41, 115, 116, -41, 120, + 122, 124, -41, 15, -41, -41, 123, -41, -41, 15, + -41, 15, 126, -41 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -41, -41, -25, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_uint8 yytable[] = +{ + 94, 49, 66, 70, 98, 99, 79, 62, 29, 63, + 75, 106, 59, 84, 60, 85, 26, 64, 23, 24, + 124, 107, 50, 72, 91, 73, 76, 67, 80, 86, + 87, 93, 112, 125, 113, 51, 102, 52, 53, 54, + 1, 77, 27, 88, 95, 114, 2, 3, 126, 55, + 68, 4, 30, 32, 33, 5, 56, 57, 89, 121, + 6, 97, 7, 8, 100, 9, 10, 11, 12, 115, + 81, 101, 82, 131, 132, 13, 103, 14, 15, 105, + 16, 17, 18, 19, 108, 109, 110, 20, 117, 21, + 118, 119, 0, 35, 120, 122, 137, 36, 37, 128, + 38, 129, 133, 130, 134, 135, 0, 143, 136, 39, + 40, 138, 41, 42, 139, 140, 141, 142, 149, 0, + 144, 145, 43, 146, 151, 147, 152, 148, 150, 153, + 0, 44, 0, 0, 45, 0, 46, 0, 0, 47 +}; + +static const yytype_int16 yycheck[] = +{ + 25, 3, 5, 43, 29, 30, 17, 28, 3, 30, + 15, 28, 3, 3, 5, 5, 31, 38, 3, 4, + 8, 38, 24, 3, 43, 5, 31, 30, 11, 19, + 20, 0, 10, 21, 12, 37, 11, 39, 40, 41, + 7, 46, 57, 33, 3, 23, 13, 14, 36, 51, + 53, 18, 47, 40, 41, 22, 58, 59, 48, 84, + 27, 5, 29, 30, 38, 32, 33, 34, 35, 47, + 3, 3, 5, 98, 99, 42, 3, 44, 45, 3, + 47, 48, 49, 50, 5, 5, 5, 54, 3, 56, + 3, 5, -1, 9, 5, 3, 121, 13, 14, 5, + 16, 5, 3, 6, 3, 3, -1, 132, 5, 25, + 26, 3, 28, 29, 3, 3, 3, 3, 143, -1, + 5, 5, 38, 3, 149, 3, 151, 3, 5, 3, + -1, 47, -1, -1, 50, -1, 52, -1, -1, 55 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 7, 13, 14, 18, 22, 27, 29, 30, 32, + 33, 34, 35, 42, 44, 45, 47, 48, 49, 50, + 54, 56, 61, 3, 4, 62, 31, 57, 66, 3, + 47, 65, 40, 41, 63, 9, 13, 14, 16, 25, + 26, 28, 29, 38, 47, 50, 52, 55, 68, 3, + 24, 37, 39, 40, 41, 51, 58, 59, 64, 3, + 5, 70, 28, 30, 38, 71, 5, 30, 53, 72, + 43, 74, 3, 5, 75, 15, 31, 46, 76, 17, + 11, 3, 5, 81, 3, 5, 19, 20, 33, 48, + 78, 43, 82, 0, 62, 3, 67, 5, 62, 62, + 38, 3, 11, 3, 69, 3, 28, 38, 5, 5, + 5, 73, 10, 12, 23, 47, 77, 3, 3, 5, + 5, 62, 3, 79, 8, 21, 36, 80, 5, 5, + 6, 62, 62, 3, 3, 3, 5, 62, 3, 3, + 3, 3, 3, 62, 5, 5, 3, 3, 3, 62, + 5, 62, 62, 3 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (cb, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, cb, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, ColorbarBase* cb, cbFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, cb, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + ColorbarBase* cb; + cbFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (cb); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, ColorbarBase* cb, cbFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, cb, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + ColorbarBase* cb; + cbFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, cb, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, ColorbarBase* cb, cbFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, cb, ll) + YYSTYPE *yyvsp; + int yyrule; + ColorbarBase* cb; + cbFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , cb, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, cb, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, ColorbarBase* cb, cbFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, cb, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + ColorbarBase* cb; + cbFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (cb); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (ColorbarBase* cb, cbFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (ColorbarBase* cb, cbFlexLexer* ll) +#else +int +yyparse (cb, ll) + ColorbarBase* cb; + cbFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 3: +#line 99 "colorbar/parser.Y" + {cb->adjustCmd((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real));;} + break; + + case 7: +#line 103 "colorbar/parser.Y" + {cb->hideCmd();;} + break; + + case 8: +#line 104 "colorbar/parser.Y" + {cb->invertCmd((yyvsp[(2) - (2)].integer) );;} + break; + + case 15: +#line 111 "colorbar/parser.Y" + {cb->queryCursorCmd();;} + break; + + case 16: +#line 112 "colorbar/parser.Y" + {cb->resetCmd();;} + break; + + case 17: +#line 113 "colorbar/parser.Y" + {cb->setRGBChannelCmd((yyvsp[(3) - (3)].str));;} + break; + + case 20: +#line 116 "colorbar/parser.Y" + {cb->showCmd();;} + break; + + case 21: +#line 117 "colorbar/parser.Y" + {cb->msg("Colorbar 1.0");;} + break; + + case 23: +#line 121 "colorbar/parser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 24: +#line 122 "colorbar/parser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].integer);;} + break; + + case 25: +#line 125 "colorbar/parser.Y" + {yydebug=1;;} + break; + + case 26: +#line 126 "colorbar/parser.Y" + {yydebug=0;;} + break; + + case 27: +#line 129 "colorbar/parser.Y" + {(yyval.integer)=((yyvsp[(1) - (1)].integer) ? 1 : 0);;} + break; + + case 28: +#line 131 "colorbar/parser.Y" + {(yyval.integer)=1;;} + break; + + case 29: +#line 132 "colorbar/parser.Y" + {(yyval.integer)=1;;} + break; + + case 30: +#line 133 "colorbar/parser.Y" + {(yyval.integer)=1;;} + break; + + case 31: +#line 134 "colorbar/parser.Y" + {(yyval.integer)=1;;} + break; + + case 32: +#line 136 "colorbar/parser.Y" + {(yyval.integer)=0;;} + break; + + case 33: +#line 137 "colorbar/parser.Y" + {(yyval.integer)=0;;} + break; + + case 34: +#line 138 "colorbar/parser.Y" + {(yyval.integer)=0;;} + break; + + case 35: +#line 139 "colorbar/parser.Y" + {(yyval.integer)=0;;} + break; + + case 36: +#line 142 "colorbar/parser.Y" + {cb->setColorbarCmd((yyvsp[(1) - (4)].integer), (yyvsp[(2) - (4)].real), (yyvsp[(3) - (4)].real), (yyvsp[(4) - (4)].integer));;} + break; + + case 37: +#line 144 "colorbar/parser.Y" + {cb->setColorbarCmd((yyvsp[(2) - (8)].real), (yyvsp[(3) - (8)].real), (yyvsp[(4) - (8)].real), (yyvsp[(5) - (8)].real), (yyvsp[(6) - (8)].real), (yyvsp[(7) - (8)].real), (yyvsp[(8) - (8)].integer));;} + break; + + case 39: +#line 148 "colorbar/parser.Y" + {cb->setColormapWindowCmd((yyvsp[(2) - (2)].str));;} + break; + + case 40: +#line 151 "colorbar/parser.Y" + {cb->setColormapLevelCmd();;} + break; + + case 41: +#line 152 "colorbar/parser.Y" + {cb->setColormapLevelCmd((yyvsp[(1) - (2)].integer), (double*)(yyvsp[(2) - (2)].ptr));;} + break; + + case 42: +#line 155 "colorbar/parser.Y" + {cb->getBiasCmd();;} + break; + + case 43: +#line 156 "colorbar/parser.Y" + {cb->getColorbarCmd();;} + break; + + case 44: +#line 157 "colorbar/parser.Y" + {cb->getColormapCmd();;} + break; + + case 45: +#line 158 "colorbar/parser.Y" + {cb->getContrastCmd();;} + break; + + case 46: +#line 159 "colorbar/parser.Y" + {cb->getCurrentFileNameCmd();;} + break; + + case 47: +#line 160 "colorbar/parser.Y" + {cb->getColormapFileNameCmd((yyvsp[(3) - (3)].integer));;} + break; + + case 48: +#line 161 "colorbar/parser.Y" + {cb->getHeightCmd();;} + break; + + case 49: +#line 162 "colorbar/parser.Y" + {cb->getCurrentIDCmd();;} + break; + + case 50: +#line 163 "colorbar/parser.Y" + {cb->getInvertCmd();;} + break; + + case 51: +#line 164 "colorbar/parser.Y" + {cb->getCurrentNameCmd();;} + break; + + case 52: +#line 165 "colorbar/parser.Y" + {cb->getColormapNameCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 53: +#line 166 "colorbar/parser.Y" + {cb->getRGBChannelCmd();;} + break; + + case 54: +#line 167 "colorbar/parser.Y" + {cb->getValueCmd((yyvsp[(2) - (3)].integer),(yyvsp[(3) - (3)].integer));;} + break; + + case 56: +#line 169 "colorbar/parser.Y" + {cb->getWidthCmd();;} + break; + + case 57: +#line 172 "colorbar/parser.Y" + {cb->getTagCmd();;} + break; + + case 58: +#line 173 "colorbar/parser.Y" + {cb->getTagCmd((yyvsp[(1) - (2)].integer),(yyvsp[(2) - (2)].integer));;} + break; + + case 59: +#line 176 "colorbar/parser.Y" + {;} + break; + + case 60: +#line 177 "colorbar/parser.Y" + {;} + break; + + case 61: +#line 180 "colorbar/parser.Y" + {cb->listNameCmd();;} + break; + + case 62: +#line 181 "colorbar/parser.Y" + {cb->listIDCmd();;} + break; + + case 63: +#line 182 "colorbar/parser.Y" + {cb->listNameCmd();;} + break; + + case 64: +#line 183 "colorbar/parser.Y" + {;} + break; + + case 65: +#line 184 "colorbar/parser.Y" + {;} + break; + + case 66: +#line 185 "colorbar/parser.Y" + {;} + break; + + case 67: +#line 188 "colorbar/parser.Y" + {cb->loadCmd((yyvsp[(1) - (1)].str),NULL);;} + break; + + case 68: +#line 189 "colorbar/parser.Y" + {cb->loadCmd((yyvsp[(1) - (2)].str),(yyvsp[(2) - (2)].str));;} + break; + + case 70: +#line 191 "colorbar/parser.Y" + {;} + break; + + case 71: +#line 194 "colorbar/parser.Y" + {cb->loadCmd((yyvsp[(1) - (2)].str),NULL,(yyvsp[(2) - (2)].str));;} + break; + + case 72: +#line 195 "colorbar/parser.Y" + {cb->loadCmd((yyvsp[(1) - (3)].str),(yyvsp[(2) - (3)].str),(yyvsp[(3) - (3)].str));;} + break; + + case 73: +#line 198 "colorbar/parser.Y" + { +#ifdef MAC_OSX_TK + cb->macosxPrintCmd(); +#endif + ;} + break; + + case 74: +#line 205 "colorbar/parser.Y" + {cb->mapCmd((yyvsp[(1) - (1)].str));;} + break; + + case 75: +#line 206 "colorbar/parser.Y" + {cb->mapCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 76: +#line 210 "colorbar/parser.Y" + {cb->psColorSpaceCmd((Widget::PSColorSpace)(yyvsp[(2) - (2)].integer));;} + break; + + case 77: +#line 211 "colorbar/parser.Y" + {cb->psLevelCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 78: +#line 212 "colorbar/parser.Y" + {cb->psResolutionCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 79: +#line 215 "colorbar/parser.Y" + {(yyval.integer) = Widget::BW;;} + break; + + case 80: +#line 216 "colorbar/parser.Y" + {(yyval.integer) = Widget::GRAY;;} + break; + + case 81: +#line 217 "colorbar/parser.Y" + {(yyval.integer) = Widget::RGB;;} + break; + + case 82: +#line 218 "colorbar/parser.Y" + {(yyval.integer) = Widget::CMYK;;} + break; + + case 85: +#line 223 "colorbar/parser.Y" + {cb->tagLoadCmd((yyvsp[(2) - (2)].str));;} + break; + + case 86: +#line 224 "colorbar/parser.Y" + {cb->tagSaveCmd((yyvsp[(2) - (2)].str));;} + break; + + case 87: +#line 225 "colorbar/parser.Y" + {cb->tagCmd((yyvsp[(1) - (4)].integer),Vector((yyvsp[(2) - (4)].real),(yyvsp[(3) - (4)].real)),(yyvsp[(4) - (4)].str));;} + break; + + case 88: +#line 226 "colorbar/parser.Y" + {cb->tagCmd((yyvsp[(1) - (1)].str));;} + break; + + case 89: +#line 229 "colorbar/parser.Y" + {cb->tagDeleteCmd();;} + break; + + case 90: +#line 230 "colorbar/parser.Y" + {cb->tagDeleteCmd((yyvsp[(1) - (2)].integer),(yyvsp[(2) - (2)].integer));;} + break; + + case 91: +#line 233 "colorbar/parser.Y" + {cb->tagEditBeginCmd((yyvsp[(2) - (4)].integer),(yyvsp[(3) - (4)].integer),(yyvsp[(4) - (4)].str));;} + break; + + case 92: +#line 234 "colorbar/parser.Y" + {cb->tagEditMotionCmd((yyvsp[(2) - (3)].integer),(yyvsp[(3) - (3)].integer));;} + break; + + case 93: +#line 235 "colorbar/parser.Y" + {cb->tagEditEndCmd((yyvsp[(2) - (3)].integer),(yyvsp[(3) - (3)].integer));;} + break; + + case 94: +#line 238 "colorbar/parser.Y" + {cb->saveCmd((yyvsp[(1) - (1)].str));;} + break; + + case 95: +#line 239 "colorbar/parser.Y" + {cb->saveCmd((yyvsp[(1) - (2)].integer),(yyvsp[(2) - (2)].str));;} + break; + + case 96: +#line 242 "colorbar/parser.Y" + { +#ifdef _WIN32 + cb->win32PrintCmd(); +#endif + ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 2000 "colorbar/parser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (cb, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (cb, ll, yymsg); + } + else + { + yyerror (cb, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, cb, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, cb, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (cb, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, cb, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, cb, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 249 "colorbar/parser.Y" + + diff --git a/tksao/colorbar/parser.H b/tksao/colorbar/parser.H new file mode 100644 index 0000000..66acc3a --- /dev/null +++ b/tksao/colorbar/parser.H @@ -0,0 +1,182 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + STRING = 260, + POINTER = 261, + ADJUST_ = 262, + BEGIN_ = 263, + BIAS_ = 264, + BW_ = 265, + CHANNEL_ = 266, + CMYK_ = 267, + COLORMAP_ = 268, + COLORBAR_ = 269, + COLORSPACE_ = 270, + CONTRAST_ = 271, + CURSOR_ = 272, + DEBUG_ = 273, + DELETE_ = 274, + EDIT_ = 275, + END_ = 276, + GET_ = 277, + GRAY_ = 278, + FALSE_ = 279, + FILE_ = 280, + HEIGHT_ = 281, + HIDE_ = 282, + ID_ = 283, + INVERT_ = 284, + ITT_ = 285, + LEVEL_ = 286, + LIST_ = 287, + LOAD_ = 288, + MACOSX_ = 289, + MAP_ = 290, + MOTION_ = 291, + N_ = 292, + NAME_ = 293, + NO_ = 294, + OFF_ = 295, + ON_ = 296, + POSTSCRIPT_ = 297, + PRINT_ = 298, + QUERY_ = 299, + RESET_ = 300, + RESOLUTION_ = 301, + RGB_ = 302, + SAVE_ = 303, + SHOW_ = 304, + TAG_ = 305, + TRUE_ = 306, + VALUE_ = 307, + VAR_ = 308, + VERSION_ = 309, + WIDTH_ = 310, + WIN32_ = 311, + WINDOW_ = 312, + Y_ = 313, + YES_ = 314 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define STRING 260 +#define POINTER 261 +#define ADJUST_ 262 +#define BEGIN_ 263 +#define BIAS_ 264 +#define BW_ 265 +#define CHANNEL_ 266 +#define CMYK_ 267 +#define COLORMAP_ 268 +#define COLORBAR_ 269 +#define COLORSPACE_ 270 +#define CONTRAST_ 271 +#define CURSOR_ 272 +#define DEBUG_ 273 +#define DELETE_ 274 +#define EDIT_ 275 +#define END_ 276 +#define GET_ 277 +#define GRAY_ 278 +#define FALSE_ 279 +#define FILE_ 280 +#define HEIGHT_ 281 +#define HIDE_ 282 +#define ID_ 283 +#define INVERT_ 284 +#define ITT_ 285 +#define LEVEL_ 286 +#define LIST_ 287 +#define LOAD_ 288 +#define MACOSX_ 289 +#define MAP_ 290 +#define MOTION_ 291 +#define N_ 292 +#define NAME_ 293 +#define NO_ 294 +#define OFF_ 295 +#define ON_ 296 +#define POSTSCRIPT_ 297 +#define PRINT_ 298 +#define QUERY_ 299 +#define RESET_ 300 +#define RESOLUTION_ 301 +#define RGB_ 302 +#define SAVE_ 303 +#define SHOW_ 304 +#define TAG_ 305 +#define TRUE_ 306 +#define VALUE_ 307 +#define VAR_ 308 +#define VERSION_ 309 +#define WIDTH_ 310 +#define WIN32_ 311 +#define WINDOW_ 312 +#define Y_ 313 +#define YES_ 314 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 25 "colorbar/parser.Y" +{ +#define CBBUFSIZE 1024 + float real; + int integer; + char str[CBBUFSIZE]; + void* ptr; +} +/* Line 1529 of yacc.c. */ +#line 175 "colorbar/parser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/colorbar/parser.Y b/tksao/colorbar/parser.Y new file mode 100644 index 0000000..ad3b473 --- /dev/null +++ b/tksao/colorbar/parser.Y @@ -0,0 +1,249 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {ColorbarBase* cb} +%lex-param {cbFlexLexer* ll} +%parse-param {cbFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#include + +#include "colorbarbase.h" + +#undef yyFlexLexer +#define yyFlexLexer cbFlexLexer +#include + +extern int cblex(void*, cbFlexLexer*); +extern void cberror(ColorbarBase*, cbFlexLexer*, const char*); +%} + +%union { +#define CBBUFSIZE 1024 + float real; + int integer; + char str[CBBUFSIZE]; + void* ptr; +} + +%type numeric +%type yesno +%type pscolorspace + +%token INT +%token REAL +%token STRING +%token POINTER + +%token ADJUST_ +%token BEGIN_ +%token BIAS_ +%token BW_ +%token CHANNEL_ +%token CMYK_ +%token COLORMAP_ +%token COLORBAR_ +%token COLORSPACE_ +%token CONTRAST_ +%token CURSOR_ +%token DEBUG_ +%token DELETE_ +%token EDIT_ +%token END_ +%token GET_ +%token GRAY_ +%token FALSE_ +%token FILE_ +%token HEIGHT_ +%token HIDE_ +%token ID_ +%token INVERT_ +%token ITT_ +%token LEVEL_ +%token LIST_ +%token LOAD_ +%token MACOSX_ +%token MAP_ +%token MOTION_ +%token N_ +%token NAME_ +%token NO_ +%token OFF_ +%token ON_ +%token POSTSCRIPT_ +%token PRINT_ +%token QUERY_ +%token RESET_ +%token RESOLUTION_ +%token RGB_ +%token SAVE_ +%token SHOW_ +%token TAG_ +%token TRUE_ +%token VALUE_ +%token VAR_ +%token VERSION_ +%token WIDTH_ +%token WIN32_ +%token WINDOW_ +%token Y_ +%token YES_ + +%% + +command : DEBUG_ debug + | ADJUST_ numeric numeric {cb->adjustCmd($2,$3);} + | COLORBAR_ colorbar + | COLORMAP_ colormap + | GET_ get + | HIDE_ {cb->hideCmd();} + | INVERT_ yesno {cb->invertCmd($2 );} + | ITT_ itt + | LIST_ list + | LOAD_ load + | MACOSX_ macosx + | MAP_ map + | POSTSCRIPT_ postscript + | QUERY_ CURSOR_ {cb->queryCursorCmd();} + | RESET_ {cb->resetCmd();} + | RGB_ CHANNEL_ STRING {cb->setRGBChannelCmd($3);} + | TAG_ tag + | SAVE_ save + | SHOW_ {cb->showCmd();} + | VERSION_ {cb->msg("Colorbar 1.0");} + | WIN32_ win32 + ; + +numeric : REAL {$$=$1;} + | INT {$$=$1;} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + ; + +yesno : INT {$$=($1 ? 1 : 0);} + + | YES_ {$$=1;} + | Y_ {$$=1;} + | ON_ {$$=1;} + | TRUE_ {$$=1;} + + | NO_ {$$=0;} + | N_ {$$=0;} + | OFF_ {$$=0;} + | FALSE_ {$$=0;} + ; + +colorbar: INT numeric numeric INT {cb->setColorbarCmd($1, $2, $3, $4);} + | RGB_ numeric numeric numeric numeric numeric numeric INT + {cb->setColorbarCmd($2, $3, $4, $5, $6, $7, $8);} + ; + +colormap: LEVEL_ colormaplevel + | WINDOW_ STRING {cb->setColormapWindowCmd($2);} + ; + +colormaplevel : /* empty */ {cb->setColormapLevelCmd();} + | INT POINTER {cb->setColormapLevelCmd($1, (double*)$2);} + ; + +get : BIAS_ {cb->getBiasCmd();} + | COLORBAR_ {cb->getColorbarCmd();} + | COLORMAP_ {cb->getColormapCmd();} + | CONTRAST_ {cb->getContrastCmd();} + | FILE_ NAME_ {cb->getCurrentFileNameCmd();} + | FILE_ NAME_ INT {cb->getColormapFileNameCmd($3);} + | HEIGHT_ {cb->getHeightCmd();} + | ID_ {cb->getCurrentIDCmd();} + | INVERT_ {cb->getInvertCmd();} + | NAME_ {cb->getCurrentNameCmd();} + | NAME_ INT {cb->getColormapNameCmd($2);} + | RGB_ CHANNEL_ {cb->getRGBChannelCmd();} + | VALUE_ INT INT {cb->getValueCmd($2,$3);} + | TAG_ getTag + | WIDTH_ {cb->getWidthCmd();} + ; + +getTag : /* empty */ {cb->getTagCmd();} + | INT INT {cb->getTagCmd($1,$2);} + ; + +itt : STRING {} + | INT {} + ; + +list : /* empty */ {cb->listNameCmd();} + | ID_ {cb->listIDCmd();} + | NAME_ {cb->listNameCmd();} + | ITT_ {} + | ITT_ ID_ {} + | ITT_ NAME_ {} + ; + +load : STRING {cb->loadCmd($1,NULL);} + | STRING STRING {cb->loadCmd($1,$2);} + | VAR_ loadVar + | ITT_ STRING {} + ; + +loadVar : STRING STRING {cb->loadCmd($1,NULL,$2);} + | STRING STRING STRING {cb->loadCmd($1,$2,$3);} + ; + +macosx : PRINT_ { +#ifdef MAC_OSX_TK + cb->macosxPrintCmd(); +#endif + } + ; + +map : STRING {cb->mapCmd($1);} + | INT {cb->mapCmd($1);} + ; + +postscript : COLORSPACE_ pscolorspace + {cb->psColorSpaceCmd((Widget::PSColorSpace)$2);} + | LEVEL_ INT {cb->psLevelCmd($2);} + | RESOLUTION_ INT {cb->psResolutionCmd($2);} + ; + +pscolorspace : BW_ {$$ = Widget::BW;} + | GRAY_ {$$ = Widget::GRAY;} + | RGB_ {$$ = Widget::RGB;} + | CMYK_ {$$ = Widget::CMYK;} + ; + +tag : DELETE_ tagdelete + | EDIT_ tagedit + | LOAD_ STRING {cb->tagLoadCmd($2);} + | SAVE_ STRING {cb->tagSaveCmd($2);} + | INT numeric numeric STRING {cb->tagCmd($1,Vector($2,$3),$4);} + | STRING {cb->tagCmd($1);} + ; + +tagdelete: /* empty */ {cb->tagDeleteCmd();} + | INT INT {cb->tagDeleteCmd($1,$2);} + ; + +tagedit : BEGIN_ INT INT STRING {cb->tagEditBeginCmd($2,$3,$4);} + | MOTION_ INT INT {cb->tagEditMotionCmd($2,$3);} + | END_ INT INT {cb->tagEditEndCmd($2,$3);} + ; + +save : STRING {cb->saveCmd($1);} + | INT STRING {cb->saveCmd($1,$2);} + ; + +win32 : PRINT_ { +#ifdef _WIN32 + cb->win32PrintCmd(); +#endif + } + ; + +%% diff --git a/tksao/colorbar/sao.C b/tksao/colorbar/sao.C new file mode 100644 index 0000000..bf58a0a --- /dev/null +++ b/tksao/colorbar/sao.C @@ -0,0 +1,209 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "sao.h" +#include "colorbar.h" + +SAOColorMap* cm; + +// SAO Parser Stuf +#undef yyFlexLexer +#define yyFlexLexer liFlexLexer +#include + +void* lilval; +liFlexLexer* lilexx; +extern int liparse(SAOColorMap*, liFlexLexer*); + +int lilex(void* vval, liFlexLexer* ll) +{ + lilval = vval; + lilexx = ll; + return ll ? ll->yylex() : 0; +} + +void lierror(SAOColorMap* cm, liFlexLexer* ll, const char* m) {} + +// LIColor +ostream& operator<<(ostream& s, LIColor& c) +{ + s << "(" << c.x << "," << c.y << ")"; + return s; +} + +// SAOColorMap +SAOColorMap::SAOColorMap(Colorbar* p) : ColorMapInfo(p) +{ + current =&red; +} + +void SAOColorMap::newLIColor(float aa, float bb) +{ + current->append(new LIColor(aa,bb)); +} + +void SAOColorMap::setChannel(ChannelType which) +{ + switch (which) { + case RED: + current = &red; + break; + case GREEN: + current = &green; + break; + case BLUE: + current = &blue; + break; + } +} + +int SAOColorMap::load() +{ + ifstream str(fileName); + if (!str) + return 0; + + liFlexLexer* ll = new liFlexLexer(&str); + liparse(this, ll); + delete ll; + + if (red.isEmpty() || green.isEmpty() || blue.isEmpty()) + return 0; // something is missing, bailout + else + return 1; // we found at least one LIColor for each RGB +} + +int SAOColorMap::load(const char* var) +{ + const char* ccmd = Tcl_GetVar(parent_->getInterp(), var, + TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG); + if (!ccmd) + return 0; + + // only make command string as long as needed + // or the rest will be processed as garbage + int len = strlen(ccmd)+2; + char* buf = new char[len]; + memcpy(buf, ccmd, len); + + // add terminator to make parser happy + buf[len-2] = '\n'; + buf[len-1] = '\0'; + + string x(buf); + istringstream istr(x); + + liFlexLexer* ll = new liFlexLexer(&istr); + liparse(this, ll); + delete ll; + delete [] buf; + + if (red.isEmpty() || green.isEmpty() || blue.isEmpty()) + return 0; // something is missing, bailout + else + return 1; // we found at least one LIColor for each RGB +} + +void SAOColorMap::save(const char* fn) +{ + ofstream f(fn); + if (!f) + return; + f << *this; +} + +unsigned char SAOColorMap::getColorChar(int i, int count, List* cc) +{ + float x = (float)i/count; + + LIColor* head = cc->head(); + LIColor* tail = NULL; + + while (head && (head->getX() < x)) + if (head) { + tail = head; + head = head->next(); + } + + if (tail && head) { // interpolate between head and tail + float m = (head->getY() - tail->getY()) / (head->getX() - tail->getX()); + if (m) { + float y = m * (x - tail->getX()) + tail->getY(); //point slope form + return (unsigned char)(y * UCHAR_MAX); + } + else + return (unsigned char)(head->getY() * UCHAR_MAX); + + } + else if (!tail && head) // return first LIColor + return (unsigned char)(head->getY() * UCHAR_MAX); + + else if (tail && !head) // return last LIColor + return (unsigned char)(tail->getY() * UCHAR_MAX); + + else + return 0; // there is something very wrong-- bail out +} + +unsigned short SAOColorMap::getColorShrt(int i, int count, List* cc) +{ + float x = (float)i/count; + + LIColor* head = cc->head(); + LIColor* tail = NULL; + + while (head && (head->getX() < x)) + if (head) { + tail = head; + head = head->next(); + } + + if (tail && head) { // interpolate between head and tail + float m = (head->getY() - tail->getY()) / (head->getX() - tail->getX()); + if (m) { + float y = m * (x - tail->getX()) + tail->getY(); //point slope form + return (unsigned short)(y * USHRT_MAX); + } + else + return (unsigned short)(head->getY() * USHRT_MAX); + + } + else if (!tail && head) // return first LIColor + return (unsigned short)(head->getY() * USHRT_MAX); + + else if (tail && !head) // return last LIColor + return (unsigned short)(tail->getY() * USHRT_MAX); + + else + return 0; // there is something very wrong-- bail out +} + +ostream& operator<<(ostream& str, SAOColorMap& c) +{ + str << "# SAOimage color table" << endl; + str << "PSEUDOCOLOR" << endl; + + str << "RED:" << endl; + c.red.head(); + do + str << *c.red.current(); + while (c.red.next()); + str << endl; + + str << "GREEN:" << endl; + c.green.head(); + do + str << *c.green.current(); + while (c.green.next()); + str << endl; + + str << "BLUE:" << endl; + c.blue.head(); + do + str << *c.blue.current(); + while (c.blue.next()); + str << endl; + + return str; +} diff --git a/tksao/colorbar/sao.h b/tksao/colorbar/sao.h new file mode 100644 index 0000000..70c939c --- /dev/null +++ b/tksao/colorbar/sao.h @@ -0,0 +1,85 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __sao_h__ +#define __sao_h__ + +#include "colormap.h" +#include "list.h" + +class Colorbar; + +// LIColor +class LIColor { + private: + float x; + float y; + LIColor* next_; + LIColor* previous_; + + public: + LIColor() + {x=0; y=0; next_=NULL; previous_=NULL;} + LIColor(float ll, float ii) + {x=ll; y=ii, next_=NULL; previous_=NULL;} + + LIColor(const LIColor& a) + {x=a.x; y=a.y; next_=a.next_; previous_=a.previous_;} + LIColor& operator=(const LIColor& a) + {x=a.x; y=a.y; next_=a.next_; previous_=a.previous_; return *this;} + + LIColor* next() + {return next_;} + LIColor* previous() + {return previous_;} + void setNext(LIColor* n) + {next_ = n;} + void setPrevious(LIColor* p) + {previous_=p;} + + float getX() {return x;} + float getY() {return y;} + + friend ostream& operator<<(ostream&, LIColor&); +}; + +// SAOColorMap +class SAOColorMap : public ColorMapInfo { + public: + enum ChannelType {RED,GREEN,BLUE}; + +protected: + List red; + List green; + List blue; + List* current; + +protected: + unsigned char getColorChar(int, int, List*); + unsigned short getColorShrt(int, int, List*); + +public: + SAOColorMap(Colorbar* p); + + ColorMapInfo* dup() {return new SAOColorMap(*this);} + int load(); + int load(const char* var); + void save(const char*); + + unsigned char getRedChar(int i, int c) {return getColorChar(i,c,&red);} + unsigned char getGreenChar(int i, int c) {return getColorChar(i,c,&green);} + unsigned char getBlueChar(int i, int c) {return getColorChar(i,c,&blue);} + + unsigned short getRedShrt(int i, int c) {return getColorShrt(i,c,&red);} + unsigned short getGreenShrt(int i, int c) {return getColorShrt(i,c,&green);} + unsigned short getBlueShrt(int i, int c) {return getColorShrt(i,c,&blue);} + + void setChannel(ChannelType); + void newLIColor(float,float); + + friend ostream& operator<<(ostream&, SAOColorMap&); +}; + +#endif + diff --git a/tksao/colorbar/saolex.C b/tksao/colorbar/saolex.C new file mode 100644 index 0000000..4836f17 --- /dev/null +++ b/tksao/colorbar/saolex.C @@ -0,0 +1,1754 @@ +#line 2 "colorbar/saolex.C" + +#line 4 "colorbar/saolex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer liFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *lialloc (yy_size_t ); +void *lirealloc (void *,yy_size_t ); +void lifree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 23 +#define YY_END_OF_BUFFER 24 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[84] = + { 0, + 0, 0, 2, 2, 24, 22, 19, 21, 22, 22, + 22, 15, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 2, 1, 19, 20, 0, 15, 17, + 16, 15, 18, 18, 18, 18, 18, 18, 18, 8, + 18, 10, 18, 18, 18, 18, 2, 0, 0, 0, + 16, 18, 18, 18, 18, 18, 9, 18, 12, 18, + 14, 16, 0, 17, 3, 18, 18, 18, 18, 18, + 13, 4, 7, 5, 6, 18, 18, 18, 18, 18, + 18, 11, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 5, 1, 5, 6, 1, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, + 1, 1, 1, 1, 8, 9, 10, 11, 12, 13, + 14, 15, 15, 15, 15, 16, 17, 18, 19, 20, + 15, 21, 22, 23, 24, 15, 15, 15, 25, 15, + 1, 1, 1, 1, 1, 1, 26, 27, 28, 29, + + 30, 31, 32, 15, 15, 15, 15, 33, 34, 35, + 36, 37, 15, 38, 39, 40, 41, 15, 15, 15, + 42, 15, 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, 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, + 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, 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, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[43] = + { 0, + 1, 1, 2, 1, 1, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3 + } ; + +static yyconst flex_int16_t yy_base[87] = + { 0, + 0, 0, 217, 210, 212, 222, 209, 222, 206, 37, + 200, 39, 200, 41, 42, 44, 47, 43, 53, 54, + 52, 57, 69, 0, 222, 202, 222, 196, 80, 82, + 84, 91, 196, 95, 84, 100, 99, 101, 107, 195, + 98, 194, 110, 117, 114, 111, 0, 60, 119, 192, + 124, 130, 128, 135, 137, 133, 189, 138, 186, 147, + 184, 182, 158, 144, 143, 150, 155, 160, 152, 167, + 142, 141, 77, 74, 71, 169, 166, 174, 175, 178, + 177, 55, 222, 215, 53, 218 + } ; + +static yyconst flex_int16_t yy_def[87] = + { 0, + 83, 1, 84, 84, 83, 83, 83, 83, 83, 83, + 83, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 86, 83, 83, 83, 83, 83, 83, + 83, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 86, 83, 83, 83, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 83, 83, 83, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 0, 83, 83, 83 + } ; + +static yyconst flex_int16_t yy_nxt[265] = + { 0, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, + 15, 13, 16, 17, 13, 13, 13, 18, 19, 20, + 21, 13, 22, 13, 23, 13, 14, 13, 15, 13, + 16, 17, 13, 13, 18, 19, 20, 21, 13, 22, + 13, 23, 28, 29, 31, 32, 83, 83, 83, 83, + 34, 37, 83, 36, 38, 33, 35, 83, 83, 83, + 83, 40, 83, 44, 50, 41, 62, 39, 34, 37, + 42, 36, 38, 35, 83, 43, 83, 45, 40, 83, + 46, 44, 83, 41, 39, 31, 29, 42, 30, 83, + 30, 48, 43, 49, 45, 48, 31, 32, 46, 50, + + 83, 51, 34, 83, 83, 83, 83, 52, 53, 48, + 57, 49, 83, 48, 54, 83, 83, 55, 56, 83, + 34, 58, 83, 63, 52, 64, 53, 59, 57, 83, + 51, 54, 61, 83, 55, 83, 56, 60, 83, 58, + 83, 65, 83, 83, 69, 59, 83, 83, 83, 61, + 64, 66, 83, 68, 60, 83, 67, 83, 71, 65, + 83, 70, 69, 72, 64, 83, 73, 74, 66, 75, + 68, 83, 83, 67, 83, 78, 71, 76, 70, 83, + 83, 72, 83, 83, 73, 74, 75, 77, 62, 83, + 80, 83, 79, 78, 83, 76, 81, 82, 62, 83, + + 83, 83, 30, 26, 77, 83, 30, 80, 27, 79, + 26, 83, 25, 81, 82, 24, 24, 24, 47, 25, + 47, 5, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83 + } ; + +static yyconst flex_int16_t yy_chk[265] = + { 0, + 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, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 10, 10, 12, 12, 14, 15, 18, 16, + 12, 16, 17, 15, 17, 85, 14, 21, 19, 20, + 82, 18, 22, 21, 48, 19, 48, 17, 12, 16, + 19, 15, 17, 14, 23, 20, 75, 22, 18, 74, + 23, 21, 73, 19, 17, 29, 29, 19, 30, 35, + 31, 29, 20, 30, 22, 31, 32, 32, 23, 34, + + 34, 34, 32, 41, 37, 36, 38, 35, 36, 29, + 41, 30, 39, 31, 37, 43, 46, 38, 39, 45, + 32, 43, 44, 49, 35, 49, 36, 44, 41, 51, + 51, 37, 46, 53, 38, 52, 39, 45, 56, 43, + 54, 52, 55, 58, 56, 44, 72, 71, 65, 46, + 64, 53, 60, 55, 45, 66, 54, 69, 60, 52, + 67, 58, 56, 66, 63, 68, 67, 68, 53, 69, + 55, 77, 70, 54, 76, 77, 60, 70, 58, 78, + 79, 66, 81, 80, 67, 68, 69, 76, 62, 61, + 79, 59, 78, 77, 57, 70, 80, 81, 50, 42, + + 40, 33, 28, 26, 76, 13, 11, 79, 9, 78, + 7, 5, 4, 80, 81, 84, 84, 84, 86, 3, + 86, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "colorbar/saolex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 12 "colorbar/saolex.L" + #include + #include + #include + #include + + #include "util.h" + #include "saoparser.H" + + extern YYSTYPE* lilval; + extern liFlexLexer* lilexx; + +/* rules */ +#line 508 "colorbar/saolex.C" + +#define INITIAL 0 +#define DISCARD 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 31 "colorbar/saolex.L" + + +#line 612 "colorbar/saolex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 84 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 83 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +#line 33 "colorbar/saolex.L" +{ // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(lilval->str,""); // feed a blank string + return STRING; + } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 40 "colorbar/saolex.L" +{ // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(SAOBUFSIZE-1) ? yyleng:(SAOBUFSIZE-1); + strncpy(lilval->str,yytext,ll); + lilval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 48 "colorbar/saolex.L" +{return BLUE_;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 49 "colorbar/saolex.L" +{return DEBUG_;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 50 "colorbar/saolex.L" +{return GAMMA_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 51 "colorbar/saolex.L" +{return GREEN_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 52 "colorbar/saolex.L" +{return FALSE_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 53 "colorbar/saolex.L" +{return NO_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 54 "colorbar/saolex.L" +{return OFF_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 55 "colorbar/saolex.L" +{return ON_;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 56 "colorbar/saolex.L" +{return PSEUDOCOLOR_;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 57 "colorbar/saolex.L" +{return RED_;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 58 "colorbar/saolex.L" +{return TRUE_;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 59 "colorbar/saolex.L" +{return YES_;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 61 "colorbar/saolex.L" +{ // Integer + lilval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 16: +#line 67 "colorbar/saolex.L" +case 17: +YY_RULE_SETUP +#line 67 "colorbar/saolex.L" +{ // Real Number + lilval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 72 "colorbar/saolex.L" +{ // General String + int ll = yyleng <(SAOBUFSIZE-1) ? yyleng:(SAOBUFSIZE-1); + strncpy(lilval->str,yytext,ll); + lilval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 79 "colorbar/saolex.L" +{ // White Spaces + } + YY_BREAK +case 20: +/* rule 20 can match eol */ +YY_RULE_SETUP +#line 82 "colorbar/saolex.L" +{ // windows line feed + return '\n'; + } + YY_BREAK +case 21: +/* rule 21 can match eol */ +YY_RULE_SETUP +#line 86 "colorbar/saolex.L" +{ // linefeed + return '\n'; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(DISCARD): +#line 90 "colorbar/saolex.L" +{ // eof + return EOF_; + } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 94 "colorbar/saolex.L" +{ // Else, return the char + return toupper(yytext[0]); + } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 98 "colorbar/saolex.L" +ECHO; + YY_BREAK +#line 842 "colorbar/saolex.C" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + lifree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + lifree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + lirealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) lirealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 84 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 84 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 83); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) lialloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) lialloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + lifree((void *) b->yy_ch_buf ); + + lifree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)lialloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)lirealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) lialloc(new_size ); + + else + (yy_start_stack) = (int *) lirealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *lialloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *lirealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void lifree (void * ptr ) +{ + free( (char *) ptr ); /* see lirealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 98 "colorbar/saolex.L" + + + +void liDiscard(int doit) +{ + if (lilexx) + lilexx->begin(DISCARD, doit); +} + +void liFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} + diff --git a/tksao/colorbar/saolex.L b/tksao/colorbar/saolex.L new file mode 100644 index 0000000..c41e29b --- /dev/null +++ b/tksao/colorbar/saolex.L @@ -0,0 +1,111 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ + +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + #include + + #include "util.h" + #include "saoparser.H" + + extern YYSTYPE* lilval; + extern liFlexLexer* lilexx; +%} + +%x DISCARD + +D [0-9] +E [Ee][+-]?{D}+ + +/* rules */ + +%% + +[\n] { // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(lilval->str,""); // feed a blank string + return STRING; + } + +[^\n]* { // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(SAOBUFSIZE-1) ? yyleng:(SAOBUFSIZE-1); + strncpy(lilval->str,yytext,ll); + lilval->str[ll] = '\0'; + return STRING; + } + +blue {return BLUE_;} +debug {return DEBUG_;} +gamma {return GAMMA_;} +green {return GREEN_;} +false {return FALSE_;} +no {return NO_;} +off {return OFF_;} +on {return ON_;} +pseudocolor {return PSEUDOCOLOR_;} +red {return RED_;} +true {return TRUE_;} +yes {return YES_;} + +[+-]?{D}+ { // Integer + lilval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + lilval->real = atof(yytext); + return REAL; + } + +[0-9A-Za-z]+ { // General String + int ll = yyleng <(SAOBUFSIZE-1) ? yyleng:(SAOBUFSIZE-1); + strncpy(lilval->str,yytext,ll); + lilval->str[ll] = '\0'; + return STRING; + } + +[ \t]+ { // White Spaces + } + +\r\n { // windows line feed + return '\n'; + } + +\n { // linefeed + return '\n'; + } + +<> { // eof + return EOF_; + } + +. { // Else, return the char + return toupper(yytext[0]); + } + +%% + +void liDiscard(int doit) +{ + if (lilexx) + lilexx->begin(DISCARD, doit); +} + +void liFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} diff --git a/tksao/colorbar/saoparser.C b/tksao/colorbar/saoparser.C new file mode 100644 index 0000000..2a22d4a --- /dev/null +++ b/tksao/colorbar/saoparser.C @@ -0,0 +1,1674 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse liparse +#define yylex lilex +#define yyerror lierror +#define yylval lilval +#define yychar lichar +#define yydebug lidebug +#define yynerrs linerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + REAL = 258, + INT = 259, + STRING = 260, + EOF_ = 261, + BLUE_ = 262, + DEBUG_ = 263, + GAMMA_ = 264, + GREEN_ = 265, + FALSE_ = 266, + NO_ = 267, + OFF_ = 268, + ON_ = 269, + PSEUDOCOLOR_ = 270, + RED_ = 271, + TRUE_ = 272, + YES_ = 273 + }; +#endif +/* Tokens. */ +#define REAL 258 +#define INT 259 +#define STRING 260 +#define EOF_ 261 +#define BLUE_ 262 +#define DEBUG_ 263 +#define GAMMA_ 264 +#define GREEN_ 265 +#define FALSE_ 266 +#define NO_ 267 +#define OFF_ 268 +#define ON_ 269 +#define PSEUDOCOLOR_ 270 +#define RED_ 271 +#define TRUE_ 272 +#define YES_ 273 + + + + +/* Copy the first part of user declarations. */ +#line 10 "colorbar/saoparser.Y" + +#define YYDEBUG 1 + +#define DISCARD_(x) {yyclearin; liDiscard(x);} + +#include +#include + +#include "sao.h" + +#undef yyFlexLexer +#define yyFlexLexer liFlexLexer +#include + +extern int lilex(void*, liFlexLexer*); +extern void lierror(SAOColorMap*, liFlexLexer*, const char*); +extern void liDiscard(int); + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 29 "colorbar/saoparser.Y" +{ +#define SAOBUFSIZE 4096 + char str[SAOBUFSIZE]; + int integer; + float real; +} +/* Line 193 of yacc.c. */ +#line 166 "colorbar/saoparser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 179 "colorbar/saoparser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 23 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 36 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 26 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 11 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 24 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 40 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 273 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 24, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 19, 2, 2, 2, 2, + 21, 23, 2, 2, 22, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 20, 25, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 7, 10, 13, 15, 17, 18, 22, + 24, 28, 32, 36, 37, 40, 43, 45, 51, 53, + 55, 57, 59, 61, 63 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 27, 0, -1, 27, 28, 34, -1, 28, 34, -1, + 8, 36, -1, 30, -1, 15, -1, -1, 19, 29, + 5, -1, 32, -1, 16, 20, 31, -1, 10, 20, + 31, -1, 7, 20, 31, -1, -1, 9, 35, -1, + 32, 33, -1, 33, -1, 21, 35, 22, 35, 23, + -1, 24, -1, 25, -1, 6, -1, 3, -1, 4, + -1, 14, -1, 13, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 59, 59, 60, 63, 64, 65, 66, 66, 67, + 70, 71, 72, 75, 76, 79, 80, 83, 86, 87, + 88, 91, 92, 95, 96 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "REAL", "INT", "STRING", "EOF_", "BLUE_", + "DEBUG_", "GAMMA_", "GREEN_", "FALSE_", "NO_", "OFF_", "ON_", + "PSEUDOCOLOR_", "RED_", "TRUE_", "YES_", "'#'", "':'", "'('", "','", + "')'", "'\\n'", "';'", "$accept", "commands", "command", "@1", "color", + "gamma", "lis", "li", "terminator", "numeric", "debug", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 35, + 58, 40, 44, 41, 10, 59 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 26, 27, 27, 28, 28, 28, 29, 28, 28, + 30, 30, 30, 31, 31, 32, 32, 33, 34, 34, + 34, 35, 35, 36, 36 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 3, 2, 2, 1, 1, 0, 3, 1, + 3, 3, 3, 0, 2, 2, 1, 5, 1, 1, + 1, 1, 1, 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 0, 0, 0, 6, 0, 7, 0, 0, 0, + 5, 9, 16, 13, 24, 23, 4, 13, 13, 0, + 21, 22, 0, 1, 0, 20, 18, 19, 3, 15, + 0, 12, 11, 10, 8, 0, 2, 14, 0, 17 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 8, 9, 19, 10, 31, 11, 12, 28, 22, + 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -30 +static const yytype_int8 yypact[] = +{ + 10, -15, -11, 4, -30, 7, -30, 8, 0, -2, + -30, -12, -30, 19, -30, -30, -30, 19, 19, 25, + -30, -30, 11, -30, -2, -30, -30, -30, -30, -30, + 8, -30, -30, -30, -30, 8, -30, -30, 9, -30 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -30, -30, 26, -30, -30, -4, -30, 24, 12, -29, + -30 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_uint8 yytable[] = +{ + 23, 37, 14, 15, 25, 13, 38, 1, 2, 7, + 3, 20, 21, 32, 33, 4, 5, 1, 2, 6, + 3, 7, 26, 27, 17, 4, 5, 18, 30, 6, + 34, 7, 39, 35, 24, 29, 36 +}; + +static const yytype_uint8 yycheck[] = +{ + 0, 30, 13, 14, 6, 20, 35, 7, 8, 21, + 10, 3, 4, 17, 18, 15, 16, 7, 8, 19, + 10, 21, 24, 25, 20, 15, 16, 20, 9, 19, + 5, 21, 23, 22, 8, 11, 24 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 7, 8, 10, 15, 16, 19, 21, 27, 28, + 30, 32, 33, 20, 13, 14, 36, 20, 20, 29, + 3, 4, 35, 0, 28, 6, 24, 25, 34, 33, + 9, 31, 31, 31, 5, 22, 34, 35, 35, 23 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (cm, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, cm, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, SAOColorMap* cm, liFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, cm, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + SAOColorMap* cm; + liFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (cm); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, SAOColorMap* cm, liFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, cm, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + SAOColorMap* cm; + liFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, cm, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, SAOColorMap* cm, liFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, cm, ll) + YYSTYPE *yyvsp; + int yyrule; + SAOColorMap* cm; + liFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , cm, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, cm, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, SAOColorMap* cm, liFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, cm, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + SAOColorMap* cm; + liFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (cm); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (SAOColorMap* cm, liFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (SAOColorMap* cm, liFlexLexer* ll) +#else +int +yyparse (cm, ll) + SAOColorMap* cm; + liFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 7: +#line 66 "colorbar/saoparser.Y" + {DISCARD_(1);} + break; + + case 10: +#line 70 "colorbar/saoparser.Y" + {cm->setChannel(SAOColorMap::RED);;} + break; + + case 11: +#line 71 "colorbar/saoparser.Y" + {cm->setChannel(SAOColorMap::GREEN);;} + break; + + case 12: +#line 72 "colorbar/saoparser.Y" + {cm->setChannel(SAOColorMap::BLUE);;} + break; + + case 17: +#line 83 "colorbar/saoparser.Y" + {cm->newLIColor((yyvsp[(2) - (5)].real),(yyvsp[(4) - (5)].real));;} + break; + + case 20: +#line 88 "colorbar/saoparser.Y" + {YYACCEPT;;} + break; + + case 21: +#line 91 "colorbar/saoparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 22: +#line 92 "colorbar/saoparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].integer);;} + break; + + case 23: +#line 95 "colorbar/saoparser.Y" + {yydebug=1;;} + break; + + case 24: +#line 96 "colorbar/saoparser.Y" + {yydebug=0;;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1459 "colorbar/saoparser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (cm, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (cm, ll, yymsg); + } + else + { + yyerror (cm, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, cm, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, cm, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (cm, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, cm, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, cm, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 98 "colorbar/saoparser.Y" + + diff --git a/tksao/colorbar/saoparser.H b/tksao/colorbar/saoparser.H new file mode 100644 index 0000000..bd72351 --- /dev/null +++ b/tksao/colorbar/saoparser.H @@ -0,0 +1,99 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + REAL = 258, + INT = 259, + STRING = 260, + EOF_ = 261, + BLUE_ = 262, + DEBUG_ = 263, + GAMMA_ = 264, + GREEN_ = 265, + FALSE_ = 266, + NO_ = 267, + OFF_ = 268, + ON_ = 269, + PSEUDOCOLOR_ = 270, + RED_ = 271, + TRUE_ = 272, + YES_ = 273 + }; +#endif +/* Tokens. */ +#define REAL 258 +#define INT 259 +#define STRING 260 +#define EOF_ 261 +#define BLUE_ 262 +#define DEBUG_ 263 +#define GAMMA_ 264 +#define GREEN_ 265 +#define FALSE_ 266 +#define NO_ 267 +#define OFF_ 268 +#define ON_ 269 +#define PSEUDOCOLOR_ 270 +#define RED_ 271 +#define TRUE_ 272 +#define YES_ 273 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 29 "colorbar/saoparser.Y" +{ +#define SAOBUFSIZE 4096 + char str[SAOBUFSIZE]; + int integer; + float real; +} +/* Line 1529 of yacc.c. */ +#line 92 "colorbar/saoparser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/colorbar/saoparser.Y b/tksao/colorbar/saoparser.Y new file mode 100644 index 0000000..9c88127 --- /dev/null +++ b/tksao/colorbar/saoparser.Y @@ -0,0 +1,98 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {SAOColorMap* cm} +%lex-param {liFlexLexer* ll} +%parse-param {liFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#define DISCARD_(x) {yyclearin; liDiscard(x);} + +#include +#include + +#include "sao.h" + +#undef yyFlexLexer +#define yyFlexLexer liFlexLexer +#include + +extern int lilex(void*, liFlexLexer*); +extern void lierror(SAOColorMap*, liFlexLexer*, const char*); +extern void liDiscard(int); +%} + +%union { +#define SAOBUFSIZE 4096 + char str[SAOBUFSIZE]; + int integer; + float real; +} + +%type numeric + +%token REAL +%token INT +%token STRING + +%token EOF_ + +%token BLUE_ +%token DEBUG_ +%token GAMMA_ +%token GREEN_ +%token FALSE_ +%token NO_ +%token OFF_ +%token ON_ +%token PSEUDOCOLOR_ +%token RED_ +%token TRUE_ +%token YES_ + +%% + +commands: commands command terminator + | command terminator + ; + +command : DEBUG_ debug + | color + | PSEUDOCOLOR_ + | '#' {DISCARD_(1)} STRING + | lis + ; + +color : RED_ ':' gamma {cm->setChannel(SAOColorMap::RED);} + | GREEN_ ':' gamma {cm->setChannel(SAOColorMap::GREEN);} + | BLUE_ ':' gamma {cm->setChannel(SAOColorMap::BLUE);} + ; + +gamma : /* empty */ + | GAMMA_ numeric + ; + +lis : lis li + | li + ; + +li : '(' numeric ',' numeric ')' {cm->newLIColor($2,$4);} + ; + +terminator: '\n' + | ';' + | EOF_ {YYACCEPT;} + ; + +numeric : REAL {$$=$1;} + | INT {$$=$1;} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + ; +%% diff --git a/tksao/configure b/tksao/configure new file mode 100755 index 0000000..fbbadb1 --- /dev/null +++ b/tksao/configure @@ -0,0 +1,10781 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69 for tksao 1.0. +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='tksao' +PACKAGE_TARNAME='tksao' +PACKAGE_VERSION='1.0' +PACKAGE_STRING='tksao 1.0' +PACKAGE_BUGREPORT='' +PACKAGE_URL='' + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='LTLIBOBJS +LIBOBJS +WISH_PROG +TCLSH_PROG +VC_MANIFEST_EMBED_EXE +VC_MANIFEST_EMBED_DLL +RANLIB_STUB +MAKE_STUB_LIB +MAKE_STATIC_LIB +MAKE_SHARED_LIB +MAKE_LIB +TCL_DBGX +LDFLAGS_DEFAULT +CFLAGS_DEFAULT +LD_LIBRARY_PATH_VAR +SHLIB_CFLAGS +SHLIB_LD_LIBS +SHLIB_LD +STLIB_LD +CFLAGS_WARNING +CFLAGS_OPTIMIZE +CFLAGS_DEBUG +RC +CELIB_DIR +AR +SHARED_BUILD +TCL_THREADS +XMKMF +TK_XLIB_DIR_NATIVE +TK_TOP_DIR_NATIVE +TK_INCLUDES +TCL_INCLUDES +PKG_OBJECTS +PKG_SOURCES +MATH_LIBS +EGREP +GREP +RANLIB +SET_MAKE +INSTALL +CPP +TK_XINCLUDES +TK_LIBS +TK_STUB_LIB_SPEC +TK_STUB_LIB_FLAG +TK_STUB_LIB_FILE +TK_LIB_SPEC +TK_LIB_FLAG +TK_LIB_FILE +TK_SRC_DIR +TK_BIN_DIR +TK_VERSION +TCL_SHLIB_LD_LIBS +TCL_LD_FLAGS +TCL_EXTRA_CFLAGS +TCL_DEFS +TCL_LIBS +CLEANFILES +OBJEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +TCL_STUB_LIB_SPEC +TCL_STUB_LIB_FLAG +TCL_STUB_LIB_FILE +TCL_LIB_SPEC +TCL_LIB_FLAG +TCL_LIB_FILE +TCL_SRC_DIR +TCL_BIN_DIR +TCL_PATCH_LEVEL +TCL_VERSION +PKG_CFLAGS +PKG_LIBS +PKG_INCLUDES +PKG_HEADERS +PKG_TCL_SOURCES +PKG_STUB_OBJECTS +PKG_STUB_SOURCES +PKG_STUB_LIB_FILE +PKG_LIB_FILE +EXEEXT +CYGPATH +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +with_tcl +with_tk +with_tclinclude +with_tkinclude +with_x +enable_threads +enable_shared +enable_64bit +enable_64bit_vis +enable_rpath +enable_wince +with_celib +enable_symbols +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP +XMKMF' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures tksao 1.0 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/tksao] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +X features: + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of tksao 1.0:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-threads build with threads + --enable-shared build and link with shared libraries (default: on) + --enable-64bit enable 64bit support (default: off) + --enable-64bit-vis enable 64bit Sparc VIS support (default: off) + --disable-rpath disable rpath support (default: on) + --enable-wince enable Win/CE support (where applicable) + --enable-symbols build with debugging symbols (default: off) + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-tcl directory containing tcl configuration + (tclConfig.sh) + --with-tk directory containing tk configuration (tkConfig.sh) + --with-tclinclude directory containing the public Tcl header files + --with-tkinclude directory containing the public Tk header files + --with-x use the X Window System + --with-celib=DIR use Windows/CE support library from DIR + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + XMKMF Path to xmkmf, Makefile generator for X Window System + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to the package provider. +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +tksao configure 1.0 +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by tksao $as_me 1.0, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +#-------------------------------------------------------------------- +# Call TEA_INIT as the first TEA_ macro to set up initial vars. +# This will define a ${TEA_PLATFORM} variable == "unix" or "windows" +# as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE. +#-------------------------------------------------------------------- + + + # TEA extensions pass this us the version of TEA they think they + # are compatible with. + TEA_VERSION="3.9" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for correct TEA configuration" >&5 +$as_echo_n "checking for correct TEA configuration... " >&6; } + if test x"${PACKAGE_NAME}" = x ; then + as_fn_error $? " +The PACKAGE_NAME variable must be defined by your TEA configure.in" "$LINENO" 5 + fi + if test x"3.9" = x ; then + as_fn_error $? " +TEA version not specified." "$LINENO" 5 + elif test "3.9" != "${TEA_VERSION}" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: warning: requested TEA version \"3.9\", have \"${TEA_VERSION}\"" >&5 +$as_echo "warning: requested TEA version \"3.9\", have \"${TEA_VERSION}\"" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok (TEA ${TEA_VERSION})" >&5 +$as_echo "ok (TEA ${TEA_VERSION})" >&6; } + fi + + # If the user did not set CFLAGS, set it now to keep macros + # like AC_PROG_CC and AC_TRY_COMPILE from adding "-g -O2". + if test "${CFLAGS+set}" != "set" ; then + CFLAGS="" + fi + + case "`uname -s`" in + *win32*|*WIN32*|*MINGW32_*) + # Extract the first word of "cygpath", so it can be a program name with args. +set dummy cygpath; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CYGPATH+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CYGPATH"; then + ac_cv_prog_CYGPATH="$CYGPATH" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CYGPATH="cygpath -w" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_CYGPATH" && ac_cv_prog_CYGPATH="echo" +fi +fi +CYGPATH=$ac_cv_prog_CYGPATH +if test -n "$CYGPATH"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CYGPATH" >&5 +$as_echo "$CYGPATH" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + EXEEXT=".exe" + TEA_PLATFORM="windows" + ;; + *CYGWIN_*) + CYGPATH=echo + EXEEXT=".exe" + # TEA_PLATFORM is determined later in LOAD_TCLCONFIG + ;; + *) + CYGPATH=echo + # Maybe we are cross-compiling.... + case ${host_alias} in + *mingw32*) + EXEEXT=".exe" + TEA_PLATFORM="windows" + ;; + *) + EXEEXT="" + TEA_PLATFORM="unix" + ;; + esac + ;; + esac + + # Check if exec_prefix is set. If not use fall back to prefix. + # Note when adjusted, so that TEA_PREFIX can correct for this. + # This is needed for recursive configures, since autoconf propagates + # $prefix, but not $exec_prefix (doh!). + if test x$exec_prefix = xNONE ; then + exec_prefix_default=yes + exec_prefix=$prefix + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}" >&5 +$as_echo "$as_me: configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}" >&6;} + + + + + # This package name must be replaced statically for AC_SUBST to work + + # Substitute STUB_LIB_FILE in case package creates a stub library too. + + + # We AC_SUBST these here to ensure they are subst'ed, + # in case the user doesn't call TEA_ADD_... + + + + + + + + + +ac_aux_dir= +for ac_dir in tclconfig "$srcdir"/tclconfig; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in tclconfig \"$srcdir\"/tclconfig" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + + +#-------------------------------------------------------------------- +# Load the tclConfig.sh file +#-------------------------------------------------------------------- + + + + # + # Ok, lets find the tcl configuration + # First, look for one uninstalled. + # the alternative search directory is invoked by --with-tcl + # + + if test x"${no_tcl}" = x ; then + # we reset no_tcl in case something fails here + no_tcl=true + +# Check whether --with-tcl was given. +if test "${with_tcl+set}" = set; then : + withval=$with_tcl; with_tclconfig="${withval}" +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tcl configuration" >&5 +$as_echo_n "checking for Tcl configuration... " >&6; } + if ${ac_cv_c_tclconfig+:} false; then : + $as_echo_n "(cached) " >&6 +else + + + # First check to see if --with-tcl was specified. + if test x"${with_tclconfig}" != x ; then + case "${with_tclconfig}" in + */tclConfig.sh ) + if test -f "${with_tclconfig}"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself" >&5 +$as_echo "$as_me: WARNING: --with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself" >&2;} + with_tclconfig="`echo "${with_tclconfig}" | sed 's!/tclConfig\.sh$!!'`" + fi ;; + esac + if test -f "${with_tclconfig}/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd "${with_tclconfig}"; pwd)`" + else + as_fn_error $? "${with_tclconfig} directory doesn't contain tclConfig.sh" "$LINENO" 5 + fi + fi + + # then check for a private Tcl installation + if test x"${ac_cv_c_tclconfig}" = x ; then + for i in \ + ../tcl \ + `ls -dr ../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \ + `ls -dr ../tcl[8-9].[0-9] 2>/dev/null` \ + `ls -dr ../tcl[8-9].[0-9]* 2>/dev/null` \ + ../../tcl \ + `ls -dr ../../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \ + `ls -dr ../../tcl[8-9].[0-9] 2>/dev/null` \ + `ls -dr ../../tcl[8-9].[0-9]* 2>/dev/null` \ + ../../../tcl \ + `ls -dr ../../../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \ + `ls -dr ../../../tcl[8-9].[0-9] 2>/dev/null` \ + `ls -dr ../../../tcl[8-9].[0-9]* 2>/dev/null` ; do + if test "${TEA_PLATFORM}" = "windows" \ + -a -f "$i/win/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd $i/win; pwd)`" + break + fi + if test -f "$i/unix/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd $i/unix; pwd)`" + break + fi + done + fi + + # on Darwin, check in Framework installation locations + if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then + for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ + `ls -d /Library/Frameworks 2>/dev/null` \ + `ls -d /Network/Library/Frameworks 2>/dev/null` \ + `ls -d /System/Library/Frameworks 2>/dev/null` \ + ; do + if test -f "$i/Tcl.framework/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd $i/Tcl.framework; pwd)`" + break + fi + done + fi + + # TEA specific: on Windows, check in common installation locations + if test "${TEA_PLATFORM}" = "windows" \ + -a x"${ac_cv_c_tclconfig}" = x ; then + for i in `ls -d C:/Tcl/lib 2>/dev/null` \ + `ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \ + ; do + if test -f "$i/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd $i; pwd)`" + break + fi + done + fi + + # check in a few common install locations + if test x"${ac_cv_c_tclconfig}" = x ; then + for i in `ls -d ${libdir} 2>/dev/null` \ + `ls -d ${exec_prefix}/lib 2>/dev/null` \ + `ls -d ${prefix}/lib 2>/dev/null` \ + `ls -d /usr/local/lib 2>/dev/null` \ + `ls -d /usr/contrib/lib 2>/dev/null` \ + `ls -d /usr/lib 2>/dev/null` \ + `ls -d /usr/lib64 2>/dev/null` \ + ; do + if test -f "$i/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd $i; pwd)`" + break + fi + done + fi + + # check in a few other private locations + if test x"${ac_cv_c_tclconfig}" = x ; then + for i in \ + ${srcdir}/../tcl \ + `ls -dr ${srcdir}/../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \ + `ls -dr ${srcdir}/../tcl[8-9].[0-9] 2>/dev/null` \ + `ls -dr ${srcdir}/../tcl[8-9].[0-9]* 2>/dev/null` ; do + if test "${TEA_PLATFORM}" = "windows" \ + -a -f "$i/win/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd $i/win; pwd)`" + break + fi + if test -f "$i/unix/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd $i/unix; pwd)`" + break + fi + done + fi + +fi + + + if test x"${ac_cv_c_tclconfig}" = x ; then + TCL_BIN_DIR="# no Tcl configs found" + as_fn_error $? "Can't find Tcl configuration definitions. Use --with-tcl to specify a directory containing tclConfig.sh" "$LINENO" 5 + else + no_tcl= + TCL_BIN_DIR="${ac_cv_c_tclconfig}" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${TCL_BIN_DIR}/tclConfig.sh" >&5 +$as_echo "found ${TCL_BIN_DIR}/tclConfig.sh" >&6; } + fi + fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for existence of ${TCL_BIN_DIR}/tclConfig.sh" >&5 +$as_echo_n "checking for existence of ${TCL_BIN_DIR}/tclConfig.sh... " >&6; } + + if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: loading" >&5 +$as_echo "loading" >&6; } + . "${TCL_BIN_DIR}/tclConfig.sh" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not find ${TCL_BIN_DIR}/tclConfig.sh" >&5 +$as_echo "could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6; } + fi + + # eval is required to do the TCL_DBGX substitution + eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\"" + eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\"" + + # If the TCL_BIN_DIR is the build directory (not the install directory), + # then set the common variable name to the value of the build variables. + # For example, the variable TCL_LIB_SPEC will be set to the value + # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC + # instead of TCL_BUILD_LIB_SPEC since it will work with both an + # installed and uninstalled version of Tcl. + if test -f "${TCL_BIN_DIR}/Makefile" ; then + TCL_LIB_SPEC="${TCL_BUILD_LIB_SPEC}" + TCL_STUB_LIB_SPEC="${TCL_BUILD_STUB_LIB_SPEC}" + TCL_STUB_LIB_PATH="${TCL_BUILD_STUB_LIB_PATH}" + elif test "`uname -s`" = "Darwin"; then + # If Tcl was built as a framework, attempt to use the libraries + # from the framework at the given location so that linking works + # against Tcl.framework installed in an arbitrary location. + case ${TCL_DEFS} in + *TCL_FRAMEWORK*) + if test -f "${TCL_BIN_DIR}/${TCL_LIB_FILE}"; then + for i in "`cd "${TCL_BIN_DIR}"; pwd`" \ + "`cd "${TCL_BIN_DIR}"/../..; pwd`"; do + if test "`basename "$i"`" = "${TCL_LIB_FILE}.framework"; then + TCL_LIB_SPEC="-F`dirname "$i" | sed -e 's/ /\\\\ /g'` -framework ${TCL_LIB_FILE}" + break + fi + done + fi + if test -f "${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"; then + TCL_STUB_LIB_SPEC="-L`echo "${TCL_BIN_DIR}" | sed -e 's/ /\\\\ /g'` ${TCL_STUB_LIB_FLAG}" + TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}" + fi + ;; + esac + fi + + # eval is required to do the TCL_DBGX substitution + eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\"" + eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\"" + eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\"" + eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\"" + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking platform" >&5 +$as_echo_n "checking platform... " >&6; } + hold_cc=$CC; CC="$TCL_CC" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifdef _WIN32 + #error win32 + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + TEA_PLATFORM="unix" +else + TEA_PLATFORM="windows" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CC=$hold_cc + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TEA_PLATFORM" >&5 +$as_echo "$TEA_PLATFORM" >&6; } + + # The BUILD_$pkg is to define the correct extern storage class + # handling when making this package + +cat >>confdefs.h <<_ACEOF +#define BUILD_${PACKAGE_NAME} /**/ +_ACEOF + + # Do this here as we have fully defined TEA_PLATFORM now + if test "${TEA_PLATFORM}" = "windows" ; then + EXEEXT=".exe" + CLEANFILES="$CLEANFILES *.lib *.dll *.pdb *.exp" + fi + + # TEA specific: + + + + + + + + +#-------------------------------------------------------------------- +# Load the tkConfig.sh file if necessary (Tk extension) +#-------------------------------------------------------------------- + + + # + # Ok, lets find the tk configuration + # First, look for one uninstalled. + # the alternative search directory is invoked by --with-tk + # + + if test x"${no_tk}" = x ; then + # we reset no_tk in case something fails here + no_tk=true + +# Check whether --with-tk was given. +if test "${with_tk+set}" = set; then : + withval=$with_tk; with_tkconfig="${withval}" +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tk configuration" >&5 +$as_echo_n "checking for Tk configuration... " >&6; } + if ${ac_cv_c_tkconfig+:} false; then : + $as_echo_n "(cached) " >&6 +else + + + # First check to see if --with-tkconfig was specified. + if test x"${with_tkconfig}" != x ; then + case "${with_tkconfig}" in + */tkConfig.sh ) + if test -f "${with_tkconfig}"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --with-tk argument should refer to directory containing tkConfig.sh, not to tkConfig.sh itself" >&5 +$as_echo "$as_me: WARNING: --with-tk argument should refer to directory containing tkConfig.sh, not to tkConfig.sh itself" >&2;} + with_tkconfig="`echo "${with_tkconfig}" | sed 's!/tkConfig\.sh$!!'`" + fi ;; + esac + if test -f "${with_tkconfig}/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd "${with_tkconfig}"; pwd)`" + else + as_fn_error $? "${with_tkconfig} directory doesn't contain tkConfig.sh" "$LINENO" 5 + fi + fi + + # then check for a private Tk library + if test x"${ac_cv_c_tkconfig}" = x ; then + for i in \ + ../tk \ + `ls -dr ../tk[8-9].[0-9].[0-9]* 2>/dev/null` \ + `ls -dr ../tk[8-9].[0-9] 2>/dev/null` \ + `ls -dr ../tk[8-9].[0-9]* 2>/dev/null` \ + ../../tk \ + `ls -dr ../../tk[8-9].[0-9].[0-9]* 2>/dev/null` \ + `ls -dr ../../tk[8-9].[0-9] 2>/dev/null` \ + `ls -dr ../../tk[8-9].[0-9]* 2>/dev/null` \ + ../../../tk \ + `ls -dr ../../../tk[8-9].[0-9].[0-9]* 2>/dev/null` \ + `ls -dr ../../../tk[8-9].[0-9] 2>/dev/null` \ + `ls -dr ../../../tk[8-9].[0-9]* 2>/dev/null` ; do + if test "${TEA_PLATFORM}" = "windows" \ + -a -f "$i/win/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd $i/win; pwd)`" + break + fi + if test -f "$i/unix/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd $i/unix; pwd)`" + break + fi + done + fi + + # on Darwin, check in Framework installation locations + if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tkconfig}" = x ; then + for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ + `ls -d /Library/Frameworks 2>/dev/null` \ + `ls -d /Network/Library/Frameworks 2>/dev/null` \ + `ls -d /System/Library/Frameworks 2>/dev/null` \ + ; do + if test -f "$i/Tk.framework/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd $i/Tk.framework; pwd)`" + break + fi + done + fi + + # check in a few common install locations + if test x"${ac_cv_c_tkconfig}" = x ; then + for i in `ls -d ${libdir} 2>/dev/null` \ + `ls -d ${exec_prefix}/lib 2>/dev/null` \ + `ls -d ${prefix}/lib 2>/dev/null` \ + `ls -d /usr/local/lib 2>/dev/null` \ + `ls -d /usr/contrib/lib 2>/dev/null` \ + `ls -d /usr/lib 2>/dev/null` \ + `ls -d /usr/lib64 2>/dev/null` \ + ; do + if test -f "$i/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd $i; pwd)`" + break + fi + done + fi + + # TEA specific: on Windows, check in common installation locations + if test "${TEA_PLATFORM}" = "windows" \ + -a x"${ac_cv_c_tkconfig}" = x ; then + for i in `ls -d C:/Tcl/lib 2>/dev/null` \ + `ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \ + ; do + if test -f "$i/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd $i; pwd)`" + break + fi + done + fi + + # check in a few other private locations + if test x"${ac_cv_c_tkconfig}" = x ; then + for i in \ + ${srcdir}/../tk \ + `ls -dr ${srcdir}/../tk[8-9].[0-9].[0-9]* 2>/dev/null` \ + `ls -dr ${srcdir}/../tk[8-9].[0-9] 2>/dev/null` \ + `ls -dr ${srcdir}/../tk[8-9].[0-9]* 2>/dev/null` ; do + if test "${TEA_PLATFORM}" = "windows" \ + -a -f "$i/win/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd $i/win; pwd)`" + break + fi + if test -f "$i/unix/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd $i/unix; pwd)`" + break + fi + done + fi + +fi + + + if test x"${ac_cv_c_tkconfig}" = x ; then + TK_BIN_DIR="# no Tk configs found" + as_fn_error $? "Can't find Tk configuration definitions. Use --with-tk to specify a directory containing tkConfig.sh" "$LINENO" 5 + else + no_tk= + TK_BIN_DIR="${ac_cv_c_tkconfig}" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${TK_BIN_DIR}/tkConfig.sh" >&5 +$as_echo "found ${TK_BIN_DIR}/tkConfig.sh" >&6; } + fi + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for existence of ${TK_BIN_DIR}/tkConfig.sh" >&5 +$as_echo_n "checking for existence of ${TK_BIN_DIR}/tkConfig.sh... " >&6; } + + if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: loading" >&5 +$as_echo "loading" >&6; } + . "${TK_BIN_DIR}/tkConfig.sh" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not find ${TK_BIN_DIR}/tkConfig.sh" >&5 +$as_echo "could not find ${TK_BIN_DIR}/tkConfig.sh" >&6; } + fi + + # eval is required to do the TK_DBGX substitution + eval "TK_LIB_FILE=\"${TK_LIB_FILE}\"" + eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\"" + + # If the TK_BIN_DIR is the build directory (not the install directory), + # then set the common variable name to the value of the build variables. + # For example, the variable TK_LIB_SPEC will be set to the value + # of TK_BUILD_LIB_SPEC. An extension should make use of TK_LIB_SPEC + # instead of TK_BUILD_LIB_SPEC since it will work with both an + # installed and uninstalled version of Tcl. + if test -f "${TK_BIN_DIR}/Makefile" ; then + TK_LIB_SPEC="${TK_BUILD_LIB_SPEC}" + TK_STUB_LIB_SPEC="${TK_BUILD_STUB_LIB_SPEC}" + TK_STUB_LIB_PATH="${TK_BUILD_STUB_LIB_PATH}" + elif test "`uname -s`" = "Darwin"; then + # If Tk was built as a framework, attempt to use the libraries + # from the framework at the given location so that linking works + # against Tk.framework installed in an arbitrary location. + case ${TK_DEFS} in + *TK_FRAMEWORK*) + if test -f "${TK_BIN_DIR}/${TK_LIB_FILE}"; then + for i in "`cd "${TK_BIN_DIR}"; pwd`" \ + "`cd "${TK_BIN_DIR}"/../..; pwd`"; do + if test "`basename "$i"`" = "${TK_LIB_FILE}.framework"; then + TK_LIB_SPEC="-F`dirname "$i" | sed -e 's/ /\\\\ /g'` -framework ${TK_LIB_FILE}" + break + fi + done + fi + if test -f "${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"; then + TK_STUB_LIB_SPEC="-L` echo "${TK_BIN_DIR}" | sed -e 's/ /\\\\ /g'` ${TK_STUB_LIB_FLAG}" + TK_STUB_LIB_PATH="${TK_BIN_DIR}/${TK_STUB_LIB_FILE}" + fi + ;; + esac + fi + + # eval is required to do the TK_DBGX substitution + eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\"" + eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\"" + eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\"" + eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\"" + + # TEA specific: Ensure windowingsystem is defined + if test "${TEA_PLATFORM}" = "unix" ; then + case ${TK_DEFS} in + *MAC_OSX_TK*) + +$as_echo "#define MAC_OSX_TK 1" >>confdefs.h + + TEA_WINDOWINGSYSTEM="aqua" + ;; + *) + TEA_WINDOWINGSYSTEM="x11" + ;; + esac + elif test "${TEA_PLATFORM}" = "windows" ; then + TEA_WINDOWINGSYSTEM="win32" + fi + + + + + + + + + + + + + + # TEA specific: + + + + +#----------------------------------------------------------------------- +# Handle the --prefix=... option by defaulting to what Tcl gave. +# Must be called after TEA_LOAD_TCLCONFIG and before TEA_SETUP_COMPILER. +#----------------------------------------------------------------------- + + + if test "${prefix}" = "NONE"; then + prefix_default=yes + if test x"${TCL_PREFIX}" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: --prefix defaulting to TCL_PREFIX ${TCL_PREFIX}" >&5 +$as_echo "$as_me: --prefix defaulting to TCL_PREFIX ${TCL_PREFIX}" >&6;} + prefix=${TCL_PREFIX} + else + { $as_echo "$as_me:${as_lineno-$LINENO}: --prefix defaulting to /usr/local" >&5 +$as_echo "$as_me: --prefix defaulting to /usr/local" >&6;} + prefix=/usr/local + fi + fi + if test "${exec_prefix}" = "NONE" -a x"${prefix_default}" = x"yes" \ + -o x"${exec_prefix_default}" = x"yes" ; then + if test x"${TCL_EXEC_PREFIX}" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: --exec-prefix defaulting to TCL_EXEC_PREFIX ${TCL_EXEC_PREFIX}" >&5 +$as_echo "$as_me: --exec-prefix defaulting to TCL_EXEC_PREFIX ${TCL_EXEC_PREFIX}" >&6;} + exec_prefix=${TCL_EXEC_PREFIX} + else + { $as_echo "$as_me:${as_lineno-$LINENO}: --exec-prefix defaulting to ${prefix}" >&5 +$as_echo "$as_me: --exec-prefix defaulting to ${prefix}" >&6;} + exec_prefix=$prefix + fi + fi + + +#----------------------------------------------------------------------- +# Standard compiler checks. +# This sets up CC by using the CC env var, or looks for gcc otherwise. +# This also calls AC_PROG_CC and a few others to create the basic setup +# necessary to compile executables. +#----------------------------------------------------------------------- + + + # Don't put any macros that use the compiler (e.g. AC_TRY_COMPILE) + # in this macro, they need to go into TEA_SETUP_COMPILER instead. + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + INSTALL="\$(SHELL) \$(srcdir)/tclconfig/install-sh -c" + + + #-------------------------------------------------------------------- + # Checks to see if the make program sets the $MAKE variable. + #-------------------------------------------------------------------- + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + + + #-------------------------------------------------------------------- + # Find ranlib + #-------------------------------------------------------------------- + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + + + #-------------------------------------------------------------------- + # Determines the correct binary file extension (.o, .obj, .exe etc.) + #-------------------------------------------------------------------- + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + # Any macros that use the compiler (e.g. AC_TRY_COMPILE) have to go here. + + + #------------------------------------------------------------------------ + # If we're using GCC, see if the compiler understands -pipe. If so, use it. + # It makes compiling go faster. (This is only a performance feature.) + #------------------------------------------------------------------------ + + if test -z "$no_pipe" -a -n "$GCC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler understands -pipe" >&5 +$as_echo_n "checking if the compiler understands -pipe... " >&6; } +if ${tcl_cv_cc_pipe+:} false; then : + $as_echo_n "(cached) " >&6 +else + + hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -pipe" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_cc_pipe=yes +else + tcl_cv_cc_pipe=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$hold_cflags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_pipe" >&5 +$as_echo "$tcl_cv_cc_pipe" >&6; } + if test $tcl_cv_cc_pipe = yes; then + CFLAGS="$CFLAGS -pipe" + fi + fi + + #-------------------------------------------------------------------- + # Common compiler flag setup + #-------------------------------------------------------------------- + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 +$as_echo_n "checking whether byte ordering is bigendian... " >&6; } +if ${ac_cv_c_bigendian+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_bigendian=unknown + # See if we're dealing with a universal compiler. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __APPLE_CC__ + not a universal capable compiler + #endif + typedef int dummy; + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + # Check for potential -arch flags. It is not universal unless + # there are at least two -arch flags with different values. + ac_arch= + ac_prev= + for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do + if test -n "$ac_prev"; then + case $ac_word in + i?86 | x86_64 | ppc | ppc64) + if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then + ac_arch=$ac_word + else + ac_cv_c_bigendian=universal + break + fi + ;; + esac + ac_prev= + elif test "x$ac_word" = "x-arch"; then + ac_prev=arch + fi + done +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test $ac_cv_c_bigendian = unknown; then + # See if sys/param.h defines the BYTE_ORDER macro. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ + && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ + && LITTLE_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # It does; now see whether it defined to BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # It does; now see whether it defined to _BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef _BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # Compile a test program. + if test "$cross_compiling" = yes; then : + # Try to guess by grepping values from an object file. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +short int ascii_mm[] = + { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; + short int ascii_ii[] = + { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; + int use_ascii (int i) { + return ascii_mm[i] + ascii_ii[i]; + } + short int ebcdic_ii[] = + { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; + short int ebcdic_mm[] = + { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; + int use_ebcdic (int i) { + return ebcdic_mm[i] + ebcdic_ii[i]; + } + extern int foo; + +int +main () +{ +return use_ascii (foo) == use_ebcdic (foo); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then + ac_cv_c_bigendian=yes + fi + if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi + fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_c_bigendian=no +else + ac_cv_c_bigendian=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 +$as_echo "$ac_cv_c_bigendian" >&6; } + case $ac_cv_c_bigendian in #( + yes) + $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h +;; #( + no) + ;; #( + universal) + +$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h + + ;; #( + *) + as_fn_error $? "unknown endianness + presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; + esac + + if test "${TEA_PLATFORM}" = "unix" ; then + + #-------------------------------------------------------------------- + # On a few very rare systems, all of the libm.a stuff is + # already in libc.a. Set compiler flags accordingly. + # Also, Linux requires the "ieee" library for math to work + # right (and it must appear before "-lm"). + #-------------------------------------------------------------------- + + ac_fn_c_check_func "$LINENO" "sin" "ac_cv_func_sin" +if test "x$ac_cv_func_sin" = xyes; then : + MATH_LIBS="" +else + MATH_LIBS="-lm" +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lieee" >&5 +$as_echo_n "checking for main in -lieee... " >&6; } +if ${ac_cv_lib_ieee_main+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lieee $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_ieee_main=yes +else + ac_cv_lib_ieee_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ieee_main" >&5 +$as_echo "$ac_cv_lib_ieee_main" >&6; } +if test "x$ac_cv_lib_ieee_main" = xyes; then : + MATH_LIBS="-lieee $MATH_LIBS" +fi + + + #-------------------------------------------------------------------- + # Interactive UNIX requires -linet instead of -lsocket, plus it + # needs net/errno.h to define the socket-related error codes. + #-------------------------------------------------------------------- + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -linet" >&5 +$as_echo_n "checking for main in -linet... " >&6; } +if ${ac_cv_lib_inet_main+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-linet $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_inet_main=yes +else + ac_cv_lib_inet_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_inet_main" >&5 +$as_echo "$ac_cv_lib_inet_main" >&6; } +if test "x$ac_cv_lib_inet_main" = xyes; then : + LIBS="$LIBS -linet" +fi + + ac_fn_c_check_header_mongrel "$LINENO" "net/errno.h" "ac_cv_header_net_errno_h" "$ac_includes_default" +if test "x$ac_cv_header_net_errno_h" = xyes; then : + + +$as_echo "#define HAVE_NET_ERRNO_H 1" >>confdefs.h + +fi + + + + #-------------------------------------------------------------------- + # Check for the existence of the -lsocket and -lnsl libraries. + # The order here is important, so that they end up in the right + # order in the command line generated by make. Here are some + # special considerations: + # 1. Use "connect" and "accept" to check for -lsocket, and + # "gethostbyname" to check for -lnsl. + # 2. Use each function name only once: can't redo a check because + # autoconf caches the results of the last check and won't redo it. + # 3. Use -lnsl and -lsocket only if they supply procedures that + # aren't already present in the normal libraries. This is because + # IRIX 5.2 has libraries, but they aren't needed and they're + # bogus: they goof up name resolution if used. + # 4. On some SVR4 systems, can't use -lsocket without -lnsl too. + # To get around this problem, check for both libraries together + # if -lsocket doesn't work by itself. + #-------------------------------------------------------------------- + + tcl_checkBoth=0 + ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect" +if test "x$ac_cv_func_connect" = xyes; then : + tcl_checkSocket=0 +else + tcl_checkSocket=1 +fi + + if test "$tcl_checkSocket" = 1; then + ac_fn_c_check_func "$LINENO" "setsockopt" "ac_cv_func_setsockopt" +if test "x$ac_cv_func_setsockopt" = xyes; then : + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for setsockopt in -lsocket" >&5 +$as_echo_n "checking for setsockopt in -lsocket... " >&6; } +if ${ac_cv_lib_socket_setsockopt+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char setsockopt (); +int +main () +{ +return setsockopt (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_socket_setsockopt=yes +else + ac_cv_lib_socket_setsockopt=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_setsockopt" >&5 +$as_echo "$ac_cv_lib_socket_setsockopt" >&6; } +if test "x$ac_cv_lib_socket_setsockopt" = xyes; then : + LIBS="$LIBS -lsocket" +else + tcl_checkBoth=1 +fi + +fi + + fi + if test "$tcl_checkBoth" = 1; then + tk_oldLibs=$LIBS + LIBS="$LIBS -lsocket -lnsl" + ac_fn_c_check_func "$LINENO" "accept" "ac_cv_func_accept" +if test "x$ac_cv_func_accept" = xyes; then : + tcl_checkNsl=0 +else + LIBS=$tk_oldLibs +fi + + fi + ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" +if test "x$ac_cv_func_gethostbyname" = xyes; then : + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 +$as_echo_n "checking for gethostbyname in -lnsl... " >&6; } +if ${ac_cv_lib_nsl_gethostbyname+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnsl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gethostbyname (); +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_nsl_gethostbyname=yes +else + ac_cv_lib_nsl_gethostbyname=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 +$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } +if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : + LIBS="$LIBS -lnsl" +fi + +fi + + + # TEA specific: Don't perform the eval of the libraries here because + # DL_LIBS won't be set until we call TEA_CONFIG_CFLAGS + + TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}' + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dirent.h" >&5 +$as_echo_n "checking dirent.h... " >&6; } +if ${tcl_cv_dirent_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ + +#ifndef _POSIX_SOURCE +# ifdef __Lynx__ + /* + * Generate compilation error to make the test fail: Lynx headers + * are only valid if really in the POSIX environment. + */ + + missing_procedure(); +# endif +#endif +DIR *d; +struct dirent *entryPtr; +char *p; +d = opendir("foobar"); +entryPtr = readdir(d); +p = entryPtr->d_name; +closedir(d); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + tcl_cv_dirent_h=yes +else + tcl_cv_dirent_h=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_dirent_h" >&5 +$as_echo "$tcl_cv_dirent_h" >&6; } + + if test $tcl_cv_dirent_h = no; then + +$as_echo "#define NO_DIRENT_H 1" >>confdefs.h + + fi + + # TEA specific: + ac_fn_c_check_header_mongrel "$LINENO" "errno.h" "ac_cv_header_errno_h" "$ac_includes_default" +if test "x$ac_cv_header_errno_h" = xyes; then : + +else + +$as_echo "#define NO_ERRNO_H 1" >>confdefs.h + +fi + + + ac_fn_c_check_header_mongrel "$LINENO" "float.h" "ac_cv_header_float_h" "$ac_includes_default" +if test "x$ac_cv_header_float_h" = xyes; then : + +else + +$as_echo "#define NO_FLOAT_H 1" >>confdefs.h + +fi + + + ac_fn_c_check_header_mongrel "$LINENO" "values.h" "ac_cv_header_values_h" "$ac_includes_default" +if test "x$ac_cv_header_values_h" = xyes; then : + +else + +$as_echo "#define NO_VALUES_H 1" >>confdefs.h + +fi + + + ac_fn_c_check_header_mongrel "$LINENO" "limits.h" "ac_cv_header_limits_h" "$ac_includes_default" +if test "x$ac_cv_header_limits_h" = xyes; then : + +$as_echo "#define HAVE_LIMITS_H 1" >>confdefs.h + +else + +$as_echo "#define NO_LIMITS_H 1" >>confdefs.h + +fi + + + ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" +if test "x$ac_cv_header_stdlib_h" = xyes; then : + tcl_ok=1 +else + tcl_ok=0 +fi + + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "strtol" >/dev/null 2>&1; then : + +else + tcl_ok=0 +fi +rm -f conftest* + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "strtoul" >/dev/null 2>&1; then : + +else + tcl_ok=0 +fi +rm -f conftest* + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "strtod" >/dev/null 2>&1; then : + +else + tcl_ok=0 +fi +rm -f conftest* + + if test $tcl_ok = 0; then + +$as_echo "#define NO_STDLIB_H 1" >>confdefs.h + + fi + ac_fn_c_check_header_mongrel "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default" +if test "x$ac_cv_header_string_h" = xyes; then : + tcl_ok=1 +else + tcl_ok=0 +fi + + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "strstr" >/dev/null 2>&1; then : + +else + tcl_ok=0 +fi +rm -f conftest* + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "strerror" >/dev/null 2>&1; then : + +else + tcl_ok=0 +fi +rm -f conftest* + + + # See also memmove check below for a place where NO_STRING_H can be + # set and why. + + if test $tcl_ok = 0; then + +$as_echo "#define NO_STRING_H 1" >>confdefs.h + + fi + + ac_fn_c_check_header_mongrel "$LINENO" "sys/wait.h" "ac_cv_header_sys_wait_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_wait_h" = xyes; then : + +else + +$as_echo "#define NO_SYS_WAIT_H 1" >>confdefs.h + +fi + + + ac_fn_c_check_header_mongrel "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default" +if test "x$ac_cv_header_dlfcn_h" = xyes; then : + +else + +$as_echo "#define NO_DLFCN_H 1" >>confdefs.h + +fi + + + + # OS/390 lacks sys/param.h (and doesn't need it, by chance). + for ac_header in sys/param.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_param_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_PARAM_H 1 +_ACEOF + +fi + +done + + + # Let the user call this, because if it triggers, they will + # need a compat/strtod.c that is correct. Users can also + # use Tcl_GetDouble(FromObj) instead. + #TEA_BUGGY_STRTOD + fi + + +#----------------------------------------------------------------------- +# __CHANGE__ +# Specify the C source files to compile in TEA_ADD_SOURCES, +# public headers that need to be installed in TEA_ADD_HEADERS, +# stub library C source files to compile in TEA_ADD_STUB_SOURCES, +# and runtime Tcl library files in TEA_ADD_TCL_SOURCES. +# This defines PKG(_STUB)_SOURCES, PKG(_STUB)_OBJECTS, PKG_HEADERS +# and PKG_TCL_SOURCES. +#----------------------------------------------------------------------- + + + vars=" +saotk.C +colorbar/cbgrid.C +colorbar/colorbar.C +colorbar/colorbarbase.C +colorbar/colorbarrgb.C +colorbar/colorbarrgbtruecolor16.C +colorbar/colorbarrgbtruecolor24.C +colorbar/colorbarrgbtruecolor8.C +colorbar/colorbartruecolor16.C +colorbar/colorbartruecolor24.C +colorbar/colorbartruecolor8.C +colorbar/colormap.C +colorbar/colortag.C +colorbar/default.C +colorbar/lex.C +colorbar/lut.C +colorbar/lutlex.C +colorbar/lutparser.C +colorbar/parser.C +colorbar/sao.C +colorbar/saolex.C +colorbar/saoparser.C +fitsy++/alloc.C +fitsy++/allocgz.C +fitsy++/analysis.C +fitsy++/block.C +fitsy++/card.C +fitsy++/channel.C +fitsy++/column.C +fitsy++/compress.C +fitsy++/envi.C +fitsy++/envilex.C +fitsy++/enviparser.C +fitsy++/file.C +fitsy++/gzip.C +fitsy++/hcompress.C +fitsy++/hdecompress.c +fitsy++/hdu.C +fitsy++/head.C +fitsy++/hist.C +fitsy++/hpx.C +fitsy++/iis.C +fitsy++/lex.C +fitsy++/map.C +fitsy++/mapincr.C +fitsy++/mmap.C +fitsy++/mmapincr.C +fitsy++/nrrd.C +fitsy++/nrrdgzip.C +fitsy++/nrrdlex.C +fitsy++/nrrdparser.C +fitsy++/order.C +fitsy++/outchannel.C +fitsy++/outfile.C +fitsy++/outfits.C +fitsy++/outsocket.C +fitsy++/parser.C +fitsy++/photo.C +fitsy++/plio.C +fitsy++/pliocomp.c +fitsy++/rice.C +fitsy++/ricecomp.c +fitsy++/savefits.C +fitsy++/share.C +fitsy++/smap.C +fitsy++/smmap.C +fitsy++/socket.C +fitsy++/socketgz.C +fitsy++/sshare.C +fitsy++/strm.C +fitsy++/var.C +frame/annulus.C +frame/base.C +frame/basebox.C +frame/basecommand.C +frame/baseellipse.C +frame/baseline.C +frame/basemarker.C +frame/basepolygon.C +frame/box.C +frame/boxannulus.C +frame/bpanda.C +frame/callback.C +frame/ciaolex.C +frame/ciaoparser.C +frame/circle.C +frame/colorscale.C +frame/colorscalergb.C +frame/colorscaletrue16.C +frame/colorscaletrue24.C +frame/colorscaletrue32.C +frame/colorscaletrue8.C +frame/compass.C +frame/composite.C +frame/context.C +frame/contour.C +frame/contourlex.C +frame/contourparser.C +frame/coord.C +frame/cpanda.C +frame/ds9lex.C +frame/ds9parser.C +frame/ellipse.C +frame/ellipseannulus.C +frame/epanda.C +frame/fitsanalysis.C +frame/fitsbin.C +frame/fitsblock.C +frame/fitscompress.C +frame/fitsdata.C +frame/fitsenvi.C +frame/fitshealpix.C +frame/fitsimage.C +frame/fitsmap.C +frame/fitsmask.C +frame/fitsnrrd.C +frame/fr3dcommand.C +frame/fr3dmap.C +frame/frame.C +frame/frame3d.C +frame/frame3dbase.C +frame/frame3dtruecolor16.C +frame/frame3dtruecolor24.C +frame/frame3dtruecolor8.C +frame/framebase.C +frame/framergb.C +frame/framergbtruecolor16.C +frame/framergbtruecolor24.C +frame/framergbtruecolor8.C +frame/frametruecolor16.C +frame/frametruecolor24.C +frame/frametruecolor8.C +frame/frblt.C +frame/frcommand.C +frame/frload.C +frame/frmap.C +frame/frmarker.C +frame/frmarkerxml.C +frame/frsave.C +frame/frscale.C +frame/fvcontour.C +frame/grid.C +frame/grid25d.C +frame/grid2d.C +frame/grid3d.C +frame/inversescale.C +frame/lex.C +frame/line.C +frame/marker.C +frame/parser.C +frame/point.C +frame/polygon.C +frame/projection.C +frame/proslex.C +frame/prosparser.C +frame/raytrace.C +frame/ruler.C +frame/saolex.C +frame/saoparser.C +frame/segment.C +frame/tag.C +frame/text.C +frame/tnglex.C +frame/tngparser.C +frame/vect.C +frame/xylex.C +frame/xyparser.C +list/list.C +magnifier/lex.C +magnifier/magnifier.C +magnifier/magnifiertrue.C +magnifier/parser.C +panner/lex.C +panner/panner.C +panner/pannertrue.C +panner/parser.C +util/attribute.C +util/grf.C +util/grf3d.C +util/grid25dbase.C +util/grid2dbase.C +util/grid3dbase.C +util/gridbase.C +util/ps.C +util/smooth.C +util/util.C +vector/vector.C +vector/vector3d.C +wcssubs/cel.c +wcssubs/distort.c +wcssubs/dsspos.c +wcssubs/hget.c +wcssubs/hput.c +wcssubs/iget.c +wcssubs/lin.c +wcssubs/platepos.c +wcssubs/poly.c +wcssubs/proj.c +wcssubs/sph.c +wcssubs/tnxpos.c +wcssubs/wcs.c +wcssubs/wcscon.c +wcssubs/wcsinit.c +wcssubs/wcslib.c +wcssubs/wcstrig.c +wcssubs/worldpos.c +wcssubs/zpxpos.c +widget/truecolor16.C +widget/truecolor24.C +widget/truecolor8.C +widget/widget.C +" + for i in $vars; do + case $i in + \$*) + # allow $-var names + PKG_SOURCES="$PKG_SOURCES $i" + PKG_OBJECTS="$PKG_OBJECTS $i" + ;; + *) + # check for existence - allows for generic/win/unix VPATH + # To add more dirs here (like 'src'), you have to update VPATH + # in Makefile.in as well + if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \ + -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \ + -a ! -f "${srcdir}/macosx/$i" \ + ; then + as_fn_error $? "could not find source file '$i'" "$LINENO" 5 + fi + PKG_SOURCES="$PKG_SOURCES $i" + # this assumes it is in a VPATH dir +# i=`basename $i` + # handle user calling this before or after TEA_SETUP_COMPILER + if test x"${OBJEXT}" != x ; then + j="`echo $i | sed -e 's/\.[^.]*$//'`.${OBJEXT}" + else + j="`echo $i | sed -e 's/\.[^.]*$//'`.\${OBJEXT}" + fi + PKG_OBJECTS="$PKG_OBJECTS $j" + ;; + esac + done + + + + + + vars="" + for i in $vars; do + # check for existence, be strict because it is installed + if test ! -f "${srcdir}/$i" ; then + as_fn_error $? "could not find header file '${srcdir}/$i'" "$LINENO" 5 + fi + PKG_HEADERS="$PKG_HEADERS $i" + done + + + + vars="-I. -I./colorbar -I./fitsy++ -I./frame -I./list -I./magnifier -I./panner -I./util -I./vector -I./wcssubs -I./widget -I${prefix}/include" + for i in $vars; do + PKG_INCLUDES="$PKG_INCLUDES $i" + done + + + + vars="-lstdc++" + for i in $vars; do + if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then + # Convert foo.lib to -lfoo for GCC. No-op if not *.lib + i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'` + fi + PKG_LIBS="$PKG_LIBS $i" + done + + + + PKG_CFLAGS="$PKG_CFLAGS " + + + + vars="" + for i in $vars; do + # check for existence - allows for generic/win/unix VPATH + if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \ + -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \ + -a ! -f "${srcdir}/macosx/$i" \ + ; then + as_fn_error $? "could not find stub source file '$i'" "$LINENO" 5 + fi + PKG_STUB_SOURCES="$PKG_STUB_SOURCES $i" + # this assumes it is in a VPATH dir + i=`basename $i` + # handle user calling this before or after TEA_SETUP_COMPILER + if test x"${OBJEXT}" != x ; then + j="`echo $i | sed -e 's/\.[^.]*$//'`.${OBJEXT}" + else + j="`echo $i | sed -e 's/\.[^.]*$//'`.\${OBJEXT}" + fi + PKG_STUB_OBJECTS="$PKG_STUB_OBJECTS $j" + done + + + + + vars="" + for i in $vars; do + # check for existence, be strict because it is installed + if test ! -f "${srcdir}/$i" ; then + as_fn_error $? "could not find tcl source file '${srcdir}/$i'" "$LINENO" 5 + fi + PKG_TCL_SOURCES="$PKG_TCL_SOURCES $i" + done + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking system version" >&5 +$as_echo_n "checking system version... " >&6; } +if ${tcl_cv_sys_version+:} false; then : + $as_echo_n "(cached) " >&6 +else + + # TEA specific: + if test "${TEA_PLATFORM}" = "windows" ; then + tcl_cv_sys_version=windows + else + tcl_cv_sys_version=`uname -s`-`uname -r` + if test "$?" -ne 0 ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find uname command" >&5 +$as_echo "$as_me: WARNING: can't find uname command" >&2;} + tcl_cv_sys_version=unknown + else + if test "`uname -s`" = "AIX" ; then + tcl_cv_sys_version=AIX-`uname -v`.`uname -r` + fi + fi + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_sys_version" >&5 +$as_echo "$tcl_cv_sys_version" >&6; } + system=$tcl_cv_sys_version + +case $system in + windows*) + $as_echo "#define HAVE_MINGW32 1" >>confdefs.h + + ;; + *) + for ac_header in sys/shm.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/shm.h" "ac_cv_header_sys_shm_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_shm_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_SHM_H 1 +_ACEOF + +fi + +done + + ;; +esac + +#-------------------------------------------------------------------- +# __CHANGE__ +# +# You can add more files to clean if your extension creates any extra +# files by extending CLEANFILES. +# Add pkgIndex.tcl if it is generated in the Makefile instead of ./configure +# and change Makefile.in to move it from CONFIG_CLEAN_FILES to BINARIES var. +# +# A few miscellaneous platform-specific items: +# TEA_ADD_* any platform specific compiler/build info here. +#-------------------------------------------------------------------- + +#CLEANFILES="$CLEANFILES pkgIndex.tcl" +if test "${TEA_PLATFORM}" = "windows" ; then + # Ensure no empty if clauses + : + #TEA_ADD_SOURCES([win/winFile.c]) + #TEA_ADD_INCLUDES([-I\"$(${CYGPATH} ${srcdir}/win)\"]) + + vars="-I${prefix}/include/libxml2" + for i in $vars; do + PKG_INCLUDES="$PKG_INCLUDES $i" + done + + +else + # Ensure no empty else clauses + : + #TEA_ADD_SOURCES([unix/unixFile.c]) + #TEA_ADD_LIBS([-lsuperfly]) + + vars="-I/usr/include/libxml2" + for i in $vars; do + PKG_INCLUDES="$PKG_INCLUDES $i" + done + + +fi + +#-------------------------------------------------------------------- +# __CHANGE__ +# Choose which headers you need. Extension authors should try very +# hard to only rely on the Tcl public header files. Internal headers +# contain private data structures and are subject to change without +# notice. +# This MUST be called after TEA_LOAD_TCLCONFIG / TEA_LOAD_TKCONFIG +#-------------------------------------------------------------------- + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tcl public headers" >&5 +$as_echo_n "checking for Tcl public headers... " >&6; } + + +# Check whether --with-tclinclude was given. +if test "${with_tclinclude+set}" = set; then : + withval=$with_tclinclude; with_tclinclude=${withval} +fi + + + if ${ac_cv_c_tclh+:} false; then : + $as_echo_n "(cached) " >&6 +else + + # Use the value from --with-tclinclude, if it was given + + if test x"${with_tclinclude}" != x ; then + if test -f "${with_tclinclude}/tcl.h" ; then + ac_cv_c_tclh=${with_tclinclude} + else + as_fn_error $? "${with_tclinclude} directory does not contain tcl.h" "$LINENO" 5 + fi + else + list="" + if test "`uname -s`" = "Darwin"; then + # If Tcl was built as a framework, attempt to use + # the framework's Headers directory + case ${TCL_DEFS} in + *TCL_FRAMEWORK*) + list="`ls -d ${TCL_BIN_DIR}/Headers 2>/dev/null`" + ;; + esac + fi + + # Look in the source dir only if Tcl is not installed, + # and in that situation, look there before installed locations. + if test -f "${TCL_BIN_DIR}/Makefile" ; then + list="$list `ls -d ${TCL_SRC_DIR}/generic 2>/dev/null`" + fi + + # Check order: pkg --prefix location, Tcl's --prefix location, + # relative to directory of tclConfig.sh. + + eval "temp_includedir=${includedir}" + list="$list \ + `ls -d ${temp_includedir} 2>/dev/null` \ + `ls -d ${TCL_PREFIX}/include 2>/dev/null` \ + `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null`" + if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then + list="$list /usr/local/include /usr/include" + if test x"${TCL_INCLUDE_SPEC}" != x ; then + d=`echo "${TCL_INCLUDE_SPEC}" | sed -e 's/^-I//'` + list="$list `ls -d ${d} 2>/dev/null`" + fi + fi + for i in $list ; do + if test -f "$i/tcl.h" ; then + ac_cv_c_tclh=$i + break + fi + done + fi + +fi + + + # Print a message based on how we determined the include path + + if test x"${ac_cv_c_tclh}" = x ; then + as_fn_error $? "tcl.h not found. Please specify its location with --with-tclinclude" "$LINENO" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_cv_c_tclh}" >&5 +$as_echo "${ac_cv_c_tclh}" >&6; } + fi + + # Convert to a native path and substitute into the output files. + + INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclh}` + + TCL_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\" + + + +#TEA_PRIVATE_TCL_HEADERS + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tk public headers" >&5 +$as_echo_n "checking for Tk public headers... " >&6; } + + +# Check whether --with-tkinclude was given. +if test "${with_tkinclude+set}" = set; then : + withval=$with_tkinclude; with_tkinclude=${withval} +fi + + + if ${ac_cv_c_tkh+:} false; then : + $as_echo_n "(cached) " >&6 +else + + # Use the value from --with-tkinclude, if it was given + + if test x"${with_tkinclude}" != x ; then + if test -f "${with_tkinclude}/tk.h" ; then + ac_cv_c_tkh=${with_tkinclude} + else + as_fn_error $? "${with_tkinclude} directory does not contain tk.h" "$LINENO" 5 + fi + else + list="" + if test "`uname -s`" = "Darwin"; then + # If Tk was built as a framework, attempt to use + # the framework's Headers directory. + case ${TK_DEFS} in + *TK_FRAMEWORK*) + list="`ls -d ${TK_BIN_DIR}/Headers 2>/dev/null`" + ;; + esac + fi + + # Look in the source dir only if Tk is not installed, + # and in that situation, look there before installed locations. + if test -f "${TK_BIN_DIR}/Makefile" ; then + list="$list `ls -d ${TK_SRC_DIR}/generic 2>/dev/null`" + fi + + # Check order: pkg --prefix location, Tk's --prefix location, + # relative to directory of tkConfig.sh, Tcl's --prefix location, + # relative to directory of tclConfig.sh. + + eval "temp_includedir=${includedir}" + list="$list \ + `ls -d ${temp_includedir} 2>/dev/null` \ + `ls -d ${TK_PREFIX}/include 2>/dev/null` \ + `ls -d ${TK_BIN_DIR}/../include 2>/dev/null` \ + `ls -d ${TCL_PREFIX}/include 2>/dev/null` \ + `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null`" + if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then + list="$list /usr/local/include /usr/include" + if test x"${TK_INCLUDE_SPEC}" != x ; then + d=`echo "${TK_INCLUDE_SPEC}" | sed -e 's/^-I//'` + list="$list `ls -d ${d} 2>/dev/null`" + fi + fi + for i in $list ; do + if test -f "$i/tk.h" ; then + ac_cv_c_tkh=$i + break + fi + done + fi + +fi + + + # Print a message based on how we determined the include path + + if test x"${ac_cv_c_tkh}" = x ; then + as_fn_error $? "tk.h not found. Please specify its location with --with-tkinclude" "$LINENO" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_cv_c_tkh}" >&5 +$as_echo "${ac_cv_c_tkh}" >&6; } + fi + + # Convert to a native path and substitute into the output files. + + INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tkh}` + + TK_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\" + + + + if test "${TEA_WINDOWINGSYSTEM}" != "x11"; then + # On Windows and Aqua, we need the X compat headers + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for X11 header files" >&5 +$as_echo_n "checking for X11 header files... " >&6; } + if test ! -r "${INCLUDE_DIR_NATIVE}/X11/Xlib.h"; then + INCLUDE_DIR_NATIVE="`${CYGPATH} ${TK_SRC_DIR}/xlib`" + TK_XINCLUDES=-I\"${INCLUDE_DIR_NATIVE}\" + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${INCLUDE_DIR_NATIVE}" >&5 +$as_echo "${INCLUDE_DIR_NATIVE}" >&6; } + fi + + + # Allow for --with-tkinclude to take effect and define ${ac_cv_c_tkh} + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tk private include files" >&5 +$as_echo_n "checking for Tk private include files... " >&6; } + + TK_SRC_DIR_NATIVE=`${CYGPATH} ${TK_SRC_DIR}` + TK_TOP_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}\" + + # Check to see if tkPort.h isn't already with the public headers + # Don't look for tkInt.h because that resides with tk.h in the core + # sources, but the Port headers are in a different directory + if test "${TEA_PLATFORM}" = "windows" -a \ + -f "${ac_cv_c_tkh}/tkWinPort.h"; then + result="private headers found with public headers" + elif test "${TEA_PLATFORM}" = "unix" -a \ + -f "${ac_cv_c_tkh}/tkUnixPort.h"; then + result="private headers found with public headers" + else + TK_GENERIC_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/generic\" + TK_XLIB_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/xlib\" + if test "${TEA_PLATFORM}" = "windows"; then + TK_PLATFORM_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/win\" + else + TK_PLATFORM_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/unix\" + fi + # Overwrite the previous TK_INCLUDES as this should capture both + # public and private headers in the same set. + # We want to ensure these are substituted so as not to require + # any *_NATIVE vars be defined in the Makefile + TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE}" + # Detect and add ttk subdir + if test -d "${TK_SRC_DIR}/generic/ttk"; then + TK_INCLUDES="${TK_INCLUDES} -I\"${TK_SRC_DIR_NATIVE}/generic/ttk\"" + fi + if test "${TEA_WINDOWINGSYSTEM}" != "x11"; then + TK_INCLUDES="${TK_INCLUDES} -I\"${TK_XLIB_DIR_NATIVE}\"" + fi + if test "${TEA_WINDOWINGSYSTEM}" = "aqua"; then + TK_INCLUDES="${TK_INCLUDES} -I\"${TK_SRC_DIR_NATIVE}/macosx\"" + fi + if test "`uname -s`" = "Darwin"; then + # If Tk was built as a framework, attempt to use + # the framework's Headers and PrivateHeaders directories + case ${TK_DEFS} in + *TK_FRAMEWORK*) + if test -d "${TK_BIN_DIR}/Headers" -a \ + -d "${TK_BIN_DIR}/PrivateHeaders"; then + TK_INCLUDES="-I\"${TK_BIN_DIR}/Headers\" -I\"${TK_BIN_DIR}/PrivateHeaders\" ${TK_INCLUDES}" + else + TK_INCLUDES="${TK_INCLUDES} ${TK_INCLUDE_SPEC} `echo "${TK_INCLUDE_SPEC}" | sed -e 's/Headers/PrivateHeaders/'`" + fi + ;; + esac + result="Using ${TK_INCLUDES}" + else + if test ! -f "${TK_SRC_DIR}/generic/tkInt.h" ; then + as_fn_error $? "Cannot find private header tkInt.h in ${TK_SRC_DIR}" "$LINENO" 5 + fi + result="Using srcdir found in tkConfig.sh: ${TK_SRC_DIR}" + fi + fi + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${result}" >&5 +$as_echo "${result}" >&6; } + + + if test "${TEA_WINDOWINGSYSTEM}" = "x11" ; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for X" >&5 +$as_echo_n "checking for X... " >&6; } + + +# Check whether --with-x was given. +if test "${with_x+set}" = set; then : + withval=$with_x; +fi + +# $have_x is `yes', `no', `disabled', or empty when we do not yet know. +if test "x$with_x" = xno; then + # The user explicitly disabled X. + have_x=disabled +else + case $x_includes,$x_libraries in #( + *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #( + *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then : + $as_echo_n "(cached) " >&6 +else + # One or both of the vars are not set, and there is no cached value. +ac_x_includes=no ac_x_libraries=no +rm -f -r conftest.dir +if mkdir conftest.dir; then + cd conftest.dir + cat >Imakefile <<'_ACEOF' +incroot: + @echo incroot='${INCROOT}' +usrlibdir: + @echo usrlibdir='${USRLIBDIR}' +libdir: + @echo libdir='${LIBDIR}' +_ACEOF + if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then + # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. + for ac_var in incroot usrlibdir libdir; do + eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`" + done + # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. + for ac_extension in a so sl dylib la dll; do + if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" && + test -f "$ac_im_libdir/libX11.$ac_extension"; then + ac_im_usrlibdir=$ac_im_libdir; break + fi + done + # Screen out bogus values from the imake configuration. They are + # bogus both because they are the default anyway, and because + # using them would break gcc on systems where it needs fixed includes. + case $ac_im_incroot in + /usr/include) ac_x_includes= ;; + *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;; + esac + case $ac_im_usrlibdir in + /usr/lib | /usr/lib64 | /lib | /lib64) ;; + *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;; + esac + fi + cd .. + rm -f -r conftest.dir +fi + +# Standard set of common directories for X headers. +# Check X11 before X11Rn because it is often a symlink to the current release. +ac_x_header_dirs=' +/usr/X11/include +/usr/X11R7/include +/usr/X11R6/include +/usr/X11R5/include +/usr/X11R4/include + +/usr/include/X11 +/usr/include/X11R7 +/usr/include/X11R6 +/usr/include/X11R5 +/usr/include/X11R4 + +/usr/local/X11/include +/usr/local/X11R7/include +/usr/local/X11R6/include +/usr/local/X11R5/include +/usr/local/X11R4/include + +/usr/local/include/X11 +/usr/local/include/X11R7 +/usr/local/include/X11R6 +/usr/local/include/X11R5 +/usr/local/include/X11R4 + +/usr/X386/include +/usr/x386/include +/usr/XFree86/include/X11 + +/usr/include +/usr/local/include +/usr/unsupported/include +/usr/athena/include +/usr/local/x11r5/include +/usr/lpp/Xamples/include + +/usr/openwin/include +/usr/openwin/share/include' + +if test "$ac_x_includes" = no; then + # Guess where to find include files, by looking for Xlib.h. + # First, try using that file with no special directory specified. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # We can compile using X headers with no special include directory. +ac_x_includes= +else + for ac_dir in $ac_x_header_dirs; do + if test -r "$ac_dir/X11/Xlib.h"; then + ac_x_includes=$ac_dir + break + fi +done +fi +rm -f conftest.err conftest.i conftest.$ac_ext +fi # $ac_x_includes = no + +if test "$ac_x_libraries" = no; then + # Check for the libraries. + # See if we find them without any special options. + # Don't add to $LIBS permanently. + ac_save_LIBS=$LIBS + LIBS="-lX11 $LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +XrmInitialize () + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + LIBS=$ac_save_LIBS +# We can link X programs with no special library path. +ac_x_libraries= +else + LIBS=$ac_save_LIBS +for ac_dir in `$as_echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` +do + # Don't even attempt the hair of trying to link an X program! + for ac_extension in a so sl dylib la dll; do + if test -r "$ac_dir/libX11.$ac_extension"; then + ac_x_libraries=$ac_dir + break 2 + fi + done +done +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi # $ac_x_libraries = no + +case $ac_x_includes,$ac_x_libraries in #( + no,* | *,no | *\'*) + # Didn't find X, or a directory has "'" in its name. + ac_cv_have_x="have_x=no";; #( + *) + # Record where we found X for the cache. + ac_cv_have_x="have_x=yes\ + ac_x_includes='$ac_x_includes'\ + ac_x_libraries='$ac_x_libraries'" +esac +fi +;; #( + *) have_x=yes;; + esac + eval "$ac_cv_have_x" +fi # $with_x != no + +if test "$have_x" != yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_x" >&5 +$as_echo "$have_x" >&6; } + no_x=yes +else + # If each of the values was on the command line, it overrides each guess. + test "x$x_includes" = xNONE && x_includes=$ac_x_includes + test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries + # Update the cache value to reflect the command line values. + ac_cv_have_x="have_x=yes\ + ac_x_includes='$x_includes'\ + ac_x_libraries='$x_libraries'" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: libraries $x_libraries, headers $x_includes" >&5 +$as_echo "libraries $x_libraries, headers $x_includes" >&6; } +fi + + not_really_there="" + if test "$no_x" = ""; then + if test "$x_includes" = ""; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + not_really_there="yes" +fi +rm -f conftest.err conftest.i conftest.$ac_ext + else + if test ! -r $x_includes/X11/Xlib.h; then + not_really_there="yes" + fi + fi + fi + if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for X11 header files" >&5 +$as_echo_n "checking for X11 header files... " >&6; } + found_xincludes="no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + found_xincludes="yes" +else + found_xincludes="no" +fi +rm -f conftest.err conftest.i conftest.$ac_ext + if test "$found_xincludes" = "no"; then + dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/X11R6/include /usr/X11R5/include /usr/include/X11R5 /usr/include/X11R4 /usr/openwin/include /usr/X11/include /usr/sww/include" + for i in $dirs ; do + if test -r $i/X11/Xlib.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $i" >&5 +$as_echo "$i" >&6; } + XINCLUDES=" -I$i" + found_xincludes="yes" + break + fi + done + fi + else + if test "$x_includes" != ""; then + XINCLUDES="-I$x_includes" + found_xincludes="yes" + fi + fi + if test "$found_xincludes" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: couldn't find any!" >&5 +$as_echo "couldn't find any!" >&6; } + fi + + if test "$no_x" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for X11 libraries" >&5 +$as_echo_n "checking for X11 libraries... " >&6; } + XLIBSW=nope + dirs="/usr/unsupported/lib /usr/local/lib /usr/X386/lib /usr/X11R6/lib /usr/X11R5/lib /usr/lib/X11R5 /usr/lib/X11R4 /usr/openwin/lib /usr/X11/lib /usr/sww/X11/lib" + for i in $dirs ; do + if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl -o -r $i/libX11.dylib; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $i" >&5 +$as_echo "$i" >&6; } + XLIBSW="-L$i -lX11" + x_libraries="$i" + break + fi + done + else + if test "$x_libraries" = ""; then + XLIBSW=-lX11 + else + XLIBSW="-L$x_libraries -lX11" + fi + fi + if test "$XLIBSW" = nope ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XCreateWindow in -lXwindow" >&5 +$as_echo_n "checking for XCreateWindow in -lXwindow... " >&6; } +if ${ac_cv_lib_Xwindow_XCreateWindow+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lXwindow $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char XCreateWindow (); +int +main () +{ +return XCreateWindow (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_Xwindow_XCreateWindow=yes +else + ac_cv_lib_Xwindow_XCreateWindow=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xwindow_XCreateWindow" >&5 +$as_echo "$ac_cv_lib_Xwindow_XCreateWindow" >&6; } +if test "x$ac_cv_lib_Xwindow_XCreateWindow" = xyes; then : + XLIBSW=-lXwindow +fi + + fi + if test "$XLIBSW" = nope ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not find any! Using -lX11." >&5 +$as_echo "could not find any! Using -lX11." >&6; } + XLIBSW=-lX11 + fi + # TEA specific: + if test x"${XLIBSW}" != x ; then + PKG_LIBS="${PKG_LIBS} ${XLIBSW}" + fi + + fi + + +#-------------------------------------------------------------------- +# Check whether --enable-threads or --disable-threads was given. +# This auto-enables if Tcl was compiled threaded. +#-------------------------------------------------------------------- + + + # Check whether --enable-threads was given. +if test "${enable_threads+set}" = set; then : + enableval=$enable_threads; tcl_ok=$enableval +else + tcl_ok=yes +fi + + + if test "${enable_threads+set}" = set; then + enableval="$enable_threads" + tcl_ok=$enableval + else + tcl_ok=yes + fi + + if test "$tcl_ok" = "yes" -o "${TCL_THREADS}" = 1; then + TCL_THREADS=1 + + if test "${TEA_PLATFORM}" != "windows" ; then + # We are always OK on Windows, so check what this platform wants: + + # USE_THREAD_ALLOC tells us to try the special thread-based + # allocator that significantly reduces lock contention + +$as_echo "#define USE_THREAD_ALLOC 1" >>confdefs.h + + +$as_echo "#define _REENTRANT 1" >>confdefs.h + + if test "`uname -s`" = "SunOS" ; then + +$as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h + + fi + +$as_echo "#define _THREAD_SAFE 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_mutex_init in -lpthread" >&5 +$as_echo_n "checking for pthread_mutex_init in -lpthread... " >&6; } +if ${ac_cv_lib_pthread_pthread_mutex_init+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_mutex_init (); +int +main () +{ +return pthread_mutex_init (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_pthread_pthread_mutex_init=yes +else + ac_cv_lib_pthread_pthread_mutex_init=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_mutex_init" >&5 +$as_echo "$ac_cv_lib_pthread_pthread_mutex_init" >&6; } +if test "x$ac_cv_lib_pthread_pthread_mutex_init" = xyes; then : + tcl_ok=yes +else + tcl_ok=no +fi + + if test "$tcl_ok" = "no"; then + # Check a little harder for __pthread_mutex_init in the same + # library, as some systems hide it there until pthread.h is + # defined. We could alternatively do an AC_TRY_COMPILE with + # pthread.h, but that will work with libpthread really doesn't + # exist, like AIX 4.2. [Bug: 4359] + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __pthread_mutex_init in -lpthread" >&5 +$as_echo_n "checking for __pthread_mutex_init in -lpthread... " >&6; } +if ${ac_cv_lib_pthread___pthread_mutex_init+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char __pthread_mutex_init (); +int +main () +{ +return __pthread_mutex_init (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_pthread___pthread_mutex_init=yes +else + ac_cv_lib_pthread___pthread_mutex_init=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread___pthread_mutex_init" >&5 +$as_echo "$ac_cv_lib_pthread___pthread_mutex_init" >&6; } +if test "x$ac_cv_lib_pthread___pthread_mutex_init" = xyes; then : + tcl_ok=yes +else + tcl_ok=no +fi + + fi + + if test "$tcl_ok" = "yes"; then + # The space is needed + THREADS_LIBS=" -lpthread" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_mutex_init in -lpthreads" >&5 +$as_echo_n "checking for pthread_mutex_init in -lpthreads... " >&6; } +if ${ac_cv_lib_pthreads_pthread_mutex_init+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthreads $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_mutex_init (); +int +main () +{ +return pthread_mutex_init (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_pthreads_pthread_mutex_init=yes +else + ac_cv_lib_pthreads_pthread_mutex_init=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthreads_pthread_mutex_init" >&5 +$as_echo "$ac_cv_lib_pthreads_pthread_mutex_init" >&6; } +if test "x$ac_cv_lib_pthreads_pthread_mutex_init" = xyes; then : + tcl_ok=yes +else + tcl_ok=no +fi + + if test "$tcl_ok" = "yes"; then + # The space is needed + THREADS_LIBS=" -lpthreads" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_mutex_init in -lc" >&5 +$as_echo_n "checking for pthread_mutex_init in -lc... " >&6; } +if ${ac_cv_lib_c_pthread_mutex_init+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lc $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_mutex_init (); +int +main () +{ +return pthread_mutex_init (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_c_pthread_mutex_init=yes +else + ac_cv_lib_c_pthread_mutex_init=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_pthread_mutex_init" >&5 +$as_echo "$ac_cv_lib_c_pthread_mutex_init" >&6; } +if test "x$ac_cv_lib_c_pthread_mutex_init" = xyes; then : + tcl_ok=yes +else + tcl_ok=no +fi + + if test "$tcl_ok" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_mutex_init in -lc_r" >&5 +$as_echo_n "checking for pthread_mutex_init in -lc_r... " >&6; } +if ${ac_cv_lib_c_r_pthread_mutex_init+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lc_r $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_mutex_init (); +int +main () +{ +return pthread_mutex_init (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_c_r_pthread_mutex_init=yes +else + ac_cv_lib_c_r_pthread_mutex_init=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_pthread_mutex_init" >&5 +$as_echo "$ac_cv_lib_c_r_pthread_mutex_init" >&6; } +if test "x$ac_cv_lib_c_r_pthread_mutex_init" = xyes; then : + tcl_ok=yes +else + tcl_ok=no +fi + + if test "$tcl_ok" = "yes"; then + # The space is needed + THREADS_LIBS=" -pthread" + else + TCL_THREADS=0 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Do not know how to find pthread lib on your system - thread support disabled" >&5 +$as_echo "$as_me: WARNING: Do not know how to find pthread lib on your system - thread support disabled" >&2;} + fi + fi + fi + fi + fi + else + TCL_THREADS=0 + fi + # Do checking message here to not mess up interleaved configure output + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for building with threads" >&5 +$as_echo_n "checking for building with threads... " >&6; } + if test "${TCL_THREADS}" = 1; then + +$as_echo "#define TCL_THREADS 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (default)" >&5 +$as_echo "yes (default)" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + # TCL_THREADS sanity checking. See if our request for building with + # threads is the same as the way Tcl was built. If not, warn the user. + case ${TCL_DEFS} in + *THREADS=1*) + if test "${TCL_THREADS}" = "0"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: + Building ${PACKAGE_NAME} without threads enabled, but building against Tcl + that IS thread-enabled. It is recommended to use --enable-threads." >&5 +$as_echo "$as_me: WARNING: + Building ${PACKAGE_NAME} without threads enabled, but building against Tcl + that IS thread-enabled. It is recommended to use --enable-threads." >&2;} + fi + ;; + *) + if test "${TCL_THREADS}" = "1"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: + --enable-threads requested, but building against a Tcl that is NOT + thread-enabled. This is an OK configuration that will also run in + a thread-enabled core." >&5 +$as_echo "$as_me: WARNING: + --enable-threads requested, but building against a Tcl that is NOT + thread-enabled. This is an OK configuration that will also run in + a thread-enabled core." >&2;} + fi + ;; + esac + + + +#-------------------------------------------------------------------- +# The statement below defines a collection of symbols related to +# building as a shared library instead of a static library. +#-------------------------------------------------------------------- + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to build libraries" >&5 +$as_echo_n "checking how to build libraries... " >&6; } + # Check whether --enable-shared was given. +if test "${enable_shared+set}" = set; then : + enableval=$enable_shared; tcl_ok=$enableval +else + tcl_ok=yes +fi + + + if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + tcl_ok=$enableval + else + tcl_ok=yes + fi + + if test "$tcl_ok" = "yes" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: shared" >&5 +$as_echo "shared" >&6; } + SHARED_BUILD=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: static" >&5 +$as_echo "static" >&6; } + SHARED_BUILD=0 + +$as_echo "#define STATIC_BUILD 1" >>confdefs.h + + fi + + + +#-------------------------------------------------------------------- +# This macro figures out what flags to use with the compiler/linker +# when building shared/static debug/optimized objects. This information +# can be taken from the tclConfig.sh file, but this figures it all out. +#-------------------------------------------------------------------- + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + + + + + # Step 0.a: Enable 64 bit support? + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if 64bit support is requested" >&5 +$as_echo_n "checking if 64bit support is requested... " >&6; } + # Check whether --enable-64bit was given. +if test "${enable_64bit+set}" = set; then : + enableval=$enable_64bit; do64bit=$enableval +else + do64bit=no +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $do64bit" >&5 +$as_echo "$do64bit" >&6; } + + # Step 0.b: Enable Solaris 64 bit VIS support? + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if 64bit Sparc VIS support is requested" >&5 +$as_echo_n "checking if 64bit Sparc VIS support is requested... " >&6; } + # Check whether --enable-64bit-vis was given. +if test "${enable_64bit_vis+set}" = set; then : + enableval=$enable_64bit_vis; do64bitVIS=$enableval +else + do64bitVIS=no +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $do64bitVIS" >&5 +$as_echo "$do64bitVIS" >&6; } + # Force 64bit on with VIS + if test "$do64bitVIS" = "yes"; then : + do64bit=yes +fi + + # Step 0.c: Check if visibility support is available. Do this here so + # that platform specific alternatives can be used below if this fails. + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports visibility \"hidden\"" >&5 +$as_echo_n "checking if compiler supports visibility \"hidden\"... " >&6; } +if ${tcl_cv_cc_visibility_hidden+:} false; then : + $as_echo_n "(cached) " >&6 +else + + hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + extern __attribute__((__visibility__("hidden"))) void f(void); + void f(void) {} +int +main () +{ +f(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + tcl_cv_cc_visibility_hidden=yes +else + tcl_cv_cc_visibility_hidden=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS=$hold_cflags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_visibility_hidden" >&5 +$as_echo "$tcl_cv_cc_visibility_hidden" >&6; } + if test $tcl_cv_cc_visibility_hidden = yes; then : + + +$as_echo "#define MODULE_SCOPE extern __attribute__((__visibility__(\"hidden\")))" >>confdefs.h + + +$as_echo "#define HAVE_HIDDEN 1" >>confdefs.h + + +fi + + # Step 0.d: Disable -rpath support? + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if rpath support is requested" >&5 +$as_echo_n "checking if rpath support is requested... " >&6; } + # Check whether --enable-rpath was given. +if test "${enable_rpath+set}" = set; then : + enableval=$enable_rpath; doRpath=$enableval +else + doRpath=yes +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $doRpath" >&5 +$as_echo "$doRpath" >&6; } + + # TEA specific: Cross-compiling options for Windows/CE builds? + + if test "${TEA_PLATFORM}" = windows; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Windows/CE build is requested" >&5 +$as_echo_n "checking if Windows/CE build is requested... " >&6; } + # Check whether --enable-wince was given. +if test "${enable_wince+set}" = set; then : + enableval=$enable_wince; doWince=$enableval +else + doWince=no +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $doWince" >&5 +$as_echo "$doWince" >&6; } + +fi + + # Set the variable "system" to hold the name and version number + # for the system. + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking system version" >&5 +$as_echo_n "checking system version... " >&6; } +if ${tcl_cv_sys_version+:} false; then : + $as_echo_n "(cached) " >&6 +else + + # TEA specific: + if test "${TEA_PLATFORM}" = "windows" ; then + tcl_cv_sys_version=windows + else + tcl_cv_sys_version=`uname -s`-`uname -r` + if test "$?" -ne 0 ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find uname command" >&5 +$as_echo "$as_me: WARNING: can't find uname command" >&2;} + tcl_cv_sys_version=unknown + else + if test "`uname -s`" = "AIX" ; then + tcl_cv_sys_version=AIX-`uname -v`.`uname -r` + fi + fi + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_sys_version" >&5 +$as_echo "$tcl_cv_sys_version" >&6; } + system=$tcl_cv_sys_version + + + # Require ranlib early so we can override it in special cases below. + + + + # Set configuration options based on system name and version. + # This is similar to Tcl's unix/tcl.m4 except that we've added a + # "windows" case and removed some core-only vars. + + do64bit_ok=no + # default to '{$LIBS}' and set to "" on per-platform necessary basis + SHLIB_LD_LIBS='${LIBS}' + # When ld needs options to work in 64-bit mode, put them in + # LDFLAGS_ARCH so they eventually end up in LDFLAGS even if [load] + # is disabled by the user. [Bug 1016796] + LDFLAGS_ARCH="" + UNSHARED_LIB_SUFFIX="" + # TEA specific: use PACKAGE_VERSION instead of VERSION + TCL_TRIM_DOTS='`echo ${PACKAGE_VERSION} | tr -d .`' + ECHO_VERSION='`echo ${PACKAGE_VERSION}`' + TCL_LIB_VERSIONS_OK=ok + CFLAGS_DEBUG=-g + if test "$GCC" = yes; then : + + CFLAGS_OPTIMIZE=-O2 + CFLAGS_WARNING="-Wall" + +else + + CFLAGS_OPTIMIZE=-O + CFLAGS_WARNING="" + +fi + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="ar" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_AR" = x; then + AR="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +else + AR="$ac_cv_prog_AR" +fi + + STLIB_LD='${AR} cr' + LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH" + if test "x$SHLIB_VERSION" = x; then : + SHLIB_VERSION="1.0" +fi + case $system in + # TEA specific: + windows) + # This is a 2-stage check to make sure we have the 64-bit SDK + # We have to know where the SDK is installed. + # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs + # MACHINE is IX86 for LINK, but this is used by the manifest, + # which requires x86|amd64|ia64. + MACHINE="X86" + if test "$do64bit" != "no" ; then + if test "x${MSSDK}x" = "xx" ; then + MSSDK="C:/Progra~1/Microsoft Platform SDK" + fi + MSSDK=`echo "$MSSDK" | sed -e 's!\\\!/!g'` + PATH64="" + case "$do64bit" in + amd64|x64|yes) + MACHINE="AMD64" ; # default to AMD64 64-bit build + PATH64="${MSSDK}/Bin/Win64/x86/AMD64" + ;; + ia64) + MACHINE="IA64" + PATH64="${MSSDK}/Bin/Win64" + ;; + esac + if test "$GCC" != "yes" -a ! -d "${PATH64}" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find 64-bit $MACHINE SDK to enable 64bit mode" >&5 +$as_echo "$as_me: WARNING: Could not find 64-bit $MACHINE SDK to enable 64bit mode" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ensure latest Platform SDK is installed" >&5 +$as_echo "$as_me: WARNING: Ensure latest Platform SDK is installed" >&2;} + do64bit="no" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using 64-bit $MACHINE mode" >&5 +$as_echo " Using 64-bit $MACHINE mode" >&6; } + do64bit_ok="yes" + fi + fi + + if test "$doWince" != "no" ; then + if test "$do64bit" != "no" ; then + as_fn_error $? "Windows/CE and 64-bit builds incompatible" "$LINENO" 5 + fi + if test "$GCC" = "yes" ; then + as_fn_error $? "Windows/CE and GCC builds incompatible" "$LINENO" 5 + fi + + # First, look for one uninstalled. + # the alternative search directory is invoked by --with-celib + + if test x"${no_celib}" = x ; then + # we reset no_celib in case something fails here + no_celib=true + +# Check whether --with-celib was given. +if test "${with_celib+set}" = set; then : + withval=$with_celib; with_celibconfig=${withval} +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Windows/CE celib directory" >&5 +$as_echo_n "checking for Windows/CE celib directory... " >&6; } + if ${ac_cv_c_celibconfig+:} false; then : + $as_echo_n "(cached) " >&6 +else + + # First check to see if --with-celibconfig was specified. + if test x"${with_celibconfig}" != x ; then + if test -d "${with_celibconfig}/inc" ; then + ac_cv_c_celibconfig=`(cd ${with_celibconfig}; pwd)` + else + as_fn_error $? "${with_celibconfig} directory doesn't contain inc directory" "$LINENO" 5 + fi + fi + + # then check for a celib library + if test x"${ac_cv_c_celibconfig}" = x ; then + for i in \ + ../celib-palm-3.0 \ + ../celib \ + ../../celib-palm-3.0 \ + ../../celib \ + `ls -dr ../celib-*3.[0-9]* 2>/dev/null` \ + ${srcdir}/../celib-palm-3.0 \ + ${srcdir}/../celib \ + `ls -dr ${srcdir}/../celib-*3.[0-9]* 2>/dev/null` \ + ; do + if test -d "$i/inc" ; then + ac_cv_c_celibconfig=`(cd $i; pwd)` + break + fi + done + fi + +fi + + if test x"${ac_cv_c_celibconfig}" = x ; then + as_fn_error $? "Cannot find celib support library directory" "$LINENO" 5 + else + no_celib= + CELIB_DIR=${ac_cv_c_celibconfig} + CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found $CELIB_DIR" >&5 +$as_echo "found $CELIB_DIR" >&6; } + fi + fi + + # Set defaults for common evc4/PPC2003 setup + # Currently Tcl requires 300+, possibly 420+ for sockets + CEVERSION=420; # could be 211 300 301 400 420 ... + TARGETCPU=ARMV4; # could be ARMV4 ARM MIPS SH3 X86 ... + ARCH=ARM; # could be ARM MIPS X86EM ... + PLATFORM="Pocket PC 2003"; # or "Pocket PC 2002" + if test "$doWince" != "yes"; then + # If !yes then the user specified something + # Reset ARCH to allow user to skip specifying it + ARCH= + eval `echo $doWince | awk -F, '{ \ + if (length($1)) { printf "CEVERSION=\"%s\"\n", $1; \ + if ($1 < 400) { printf "PLATFORM=\"Pocket PC 2002\"\n" } }; \ + if (length($2)) { printf "TARGETCPU=\"%s\"\n", toupper($2) }; \ + if (length($3)) { printf "ARCH=\"%s\"\n", toupper($3) }; \ + if (length($4)) { printf "PLATFORM=\"%s\"\n", $4 }; \ + }'` + if test "x${ARCH}" = "x" ; then + ARCH=$TARGETCPU; + fi + fi + OSVERSION=WCE$CEVERSION; + if test "x${WCEROOT}" = "x" ; then + WCEROOT="C:/Program Files/Microsoft eMbedded C++ 4.0" + if test ! -d "${WCEROOT}" ; then + WCEROOT="C:/Program Files/Microsoft eMbedded Tools" + fi + fi + if test "x${SDKROOT}" = "x" ; then + SDKROOT="C:/Program Files/Windows CE Tools" + if test ! -d "${SDKROOT}" ; then + SDKROOT="C:/Windows CE Tools" + fi + fi + WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'` + SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'` + if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" \ + -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then + as_fn_error $? "could not find PocketPC SDK or target compiler to enable WinCE mode $CEVERSION,$TARGETCPU,$ARCH,$PLATFORM" "$LINENO" 5 + doWince="no" + else + # We could PATH_NOSPACE these, but that's not important, + # as long as we quote them when used. + CEINCLUDE="${SDKROOT}/${OSVERSION}/${PLATFORM}/include" + if test -d "${CEINCLUDE}/${TARGETCPU}" ; then + CEINCLUDE="${CEINCLUDE}/${TARGETCPU}" + fi + CELIBPATH="${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" + fi + fi + + if test "$GCC" != "yes" ; then + if test "${SHARED_BUILD}" = "0" ; then + runtime=-MT + else + runtime=-MD + fi + + if test "$do64bit" != "no" ; then + # All this magic is necessary for the Win64 SDK RC1 - hobbs + CC="\"${PATH64}/cl.exe\"" + CFLAGS="${CFLAGS} -I\"${MSSDK}/Include\" -I\"${MSSDK}/Include/crt\" -I\"${MSSDK}/Include/crt/sys\"" + RC="\"${MSSDK}/bin/rc.exe\"" + lflags="-nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\"" + LINKBIN="\"${PATH64}/link.exe\"" + CFLAGS_DEBUG="-nologo -Zi -Od -W3 ${runtime}d" + CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}" + # Avoid 'unresolved external symbol __security_cookie' + # errors, c.f. http://support.microsoft.com/?id=894573 + + vars="bufferoverflowU.lib" + for i in $vars; do + if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then + # Convert foo.lib to -lfoo for GCC. No-op if not *.lib + i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'` + fi + PKG_LIBS="$PKG_LIBS $i" + done + + + elif test "$doWince" != "no" ; then + CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin" + if test "${TARGETCPU}" = "X86"; then + CC="\"${CEBINROOT}/cl.exe\"" + else + CC="\"${CEBINROOT}/cl${ARCH}.exe\"" + fi + CFLAGS="$CFLAGS -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\"" + RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\"" + arch=`echo ${ARCH} | awk '{print tolower($0)}'` + defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _WINDOWS" + if test "${SHARED_BUILD}" = "1" ; then + # Static CE builds require static celib as well + defs="${defs} _DLL" + fi + for i in $defs ; do + +cat >>confdefs.h <<_ACEOF +#define $i 1 +_ACEOF + + done + +cat >>confdefs.h <<_ACEOF +#define _WIN32_WCE $CEVERSION +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define UNDER_CE $CEVERSION +_ACEOF + + CFLAGS_DEBUG="-nologo -Zi -Od" + CFLAGS_OPTIMIZE="-nologo -Ox" + lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'` + lflags="-MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo" + LINKBIN="\"${CEBINROOT}/link.exe\"" + + else + RC="rc" + lflags="-nologo" + LINKBIN="link" + CFLAGS_DEBUG="-nologo -Z7 -Od -W3 -WX ${runtime}d" + CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}" + fi + fi + + if test "$GCC" = "yes"; then + # mingw gcc mode + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args. +set dummy ${ac_tool_prefix}windres; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RC"; then + ac_cv_prog_RC="$RC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RC="${ac_tool_prefix}windres" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RC=$ac_cv_prog_RC +if test -n "$RC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RC" >&5 +$as_echo "$RC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RC"; then + ac_ct_RC=$RC + # Extract the first word of "windres", so it can be a program name with args. +set dummy windres; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RC"; then + ac_cv_prog_ac_ct_RC="$ac_ct_RC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RC="windres" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RC=$ac_cv_prog_ac_ct_RC +if test -n "$ac_ct_RC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RC" >&5 +$as_echo "$ac_ct_RC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RC" = x; then + RC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RC=$ac_ct_RC + fi +else + RC="$ac_cv_prog_RC" +fi + + CFLAGS_DEBUG="-g" + CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" + SHLIB_LD='${CC} -shared' + UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' + LDFLAGS_CONSOLE="-wl,--subsystem,console ${lflags}" + LDFLAGS_WINDOW="-wl,--subsystem,windows ${lflags}" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cross-compile version of gcc" >&5 +$as_echo_n "checking for cross-compile version of gcc... " >&6; } +if ${ac_cv_cross+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #ifdef __WIN32__ + #error cross-compiler + #endif + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_cross=yes +else + ac_cv_cross=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cross" >&5 +$as_echo "$ac_cv_cross" >&6; } + if test "$ac_cv_cross" = "yes"; then + case "$do64bit" in + amd64|x64|yes) + CC="x86_64-w64-mingw32-gcc" + LD="x86_64-w64-mingw32-ld" + AR="x86_64-w64-mingw32-ar" + RANLIB="x86_64-w64-mingw32-ranlib" + RC="x86_64-w64-mingw32-windres" + ;; + *) + CC="i686-w64-mingw32-gcc" + LD="i686-w64-mingw32-ld" + AR="i686-w64-mingw32-ar" + RANLIB="i686-w64-mingw32-ranlib" + RC="i686-w64-mingw32-windres" + ;; + esac + fi + + else + SHLIB_LD="${LINKBIN} -dll ${lflags}" + # link -lib only works when -lib is the first arg + STLIB_LD="${LINKBIN} -lib ${lflags}" + UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.lib' + PATHTYPE=-w + # For information on what debugtype is most useful, see: + # http://msdn.microsoft.com/library/en-us/dnvc60/html/gendepdebug.asp + # and also + # http://msdn2.microsoft.com/en-us/library/y0zzbyt4%28VS.80%29.aspx + # This essentially turns it all on. + LDFLAGS_DEBUG="-debug -debugtype:cv" + LDFLAGS_OPTIMIZE="-release" + if test "$doWince" != "no" ; then + LDFLAGS_CONSOLE="-link ${lflags}" + LDFLAGS_WINDOW=${LDFLAGS_CONSOLE} + else + LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}" + LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}" + fi + fi + + SHLIB_SUFFIX=".dll" + SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.dll' + + TCL_LIB_VERSIONS_OK=nodots + ;; + AIX-*) + if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes"; then : + + # AIX requires the _r compiler when gcc isn't being used + case "${CC}" in + *_r|*_r\ *) + # ok ... + ;; + *) + # Make sure only first arg gets _r + CC=`echo "$CC" | sed -e 's/^\([^ ]*\)/\1_r/'` + ;; + esac + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using $CC for compiling with threads" >&5 +$as_echo "Using $CC for compiling with threads" >&6; } + +fi + LIBS="$LIBS -lc" + SHLIB_CFLAGS="" + SHLIB_SUFFIX=".so" + + LD_LIBRARY_PATH_VAR="LIBPATH" + + # Check to enable 64-bit flags for compiler/linker + if test "$do64bit" = yes; then : + + if test "$GCC" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC on $system" >&5 +$as_echo "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;} + +else + + do64bit_ok=yes + CFLAGS="$CFLAGS -q64" + LDFLAGS_ARCH="-q64" + RANLIB="${RANLIB} -X64" + AR="${AR} -X64" + SHLIB_LD_FLAGS="-b64" + +fi + +fi + + if test "`uname -m`" = ia64; then : + + # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC + SHLIB_LD="/usr/ccs/bin/ld -G -z text" + if test "$GCC" = yes; then : + + CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' + +else + + CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}' + +fi + LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' + +else + + if test "$GCC" = yes; then : + + SHLIB_LD='${CC} -shared -Wl,-bexpall' + +else + + SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bexpall -H512 -T512 -bnoentry" + LDFLAGS="$LDFLAGS -brtl" + +fi + SHLIB_LD="${SHLIB_LD} ${SHLIB_LD_FLAGS}" + CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + +fi + ;; + BeOS*) + SHLIB_CFLAGS="-fPIC" + SHLIB_LD='${CC} -nostart' + SHLIB_SUFFIX=".so" + + #----------------------------------------------------------- + # Check for inet_ntoa in -lbind, for BeOS (which also needs + # -lsocket, even if the network functions are in -lnet which + # is always linked to, for compatibility. + #----------------------------------------------------------- + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_ntoa in -lbind" >&5 +$as_echo_n "checking for inet_ntoa in -lbind... " >&6; } +if ${ac_cv_lib_bind_inet_ntoa+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lbind $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char inet_ntoa (); +int +main () +{ +return inet_ntoa (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_bind_inet_ntoa=yes +else + ac_cv_lib_bind_inet_ntoa=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bind_inet_ntoa" >&5 +$as_echo "$ac_cv_lib_bind_inet_ntoa" >&6; } +if test "x$ac_cv_lib_bind_inet_ntoa" = xyes; then : + LIBS="$LIBS -lbind -lsocket" +fi + + ;; + BSD/OS-4.*) + SHLIB_CFLAGS="-export-dynamic -fPIC" + SHLIB_LD='${CC} -shared' + SHLIB_SUFFIX=".so" + LDFLAGS="$LDFLAGS -export-dynamic" + CC_SEARCH_FLAGS="" + LD_SEARCH_FLAGS="" + ;; + CYGWIN_*) + SHLIB_CFLAGS="" + SHLIB_LD='${CC} -shared' + SHLIB_SUFFIX=".dll" + EXEEXT=".exe" + CC_SEARCH_FLAGS="" + LD_SEARCH_FLAGS="" + ;; + Haiku*) + LDFLAGS="$LDFLAGS -Wl,--export-dynamic" + SHLIB_CFLAGS="-fPIC" + SHLIB_SUFFIX=".so" + SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS}' + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_ntoa in -lnetwork" >&5 +$as_echo_n "checking for inet_ntoa in -lnetwork... " >&6; } +if ${ac_cv_lib_network_inet_ntoa+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnetwork $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char inet_ntoa (); +int +main () +{ +return inet_ntoa (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_network_inet_ntoa=yes +else + ac_cv_lib_network_inet_ntoa=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_network_inet_ntoa" >&5 +$as_echo "$ac_cv_lib_network_inet_ntoa" >&6; } +if test "x$ac_cv_lib_network_inet_ntoa" = xyes; then : + LIBS="$LIBS -lnetwork" +fi + + ;; + HP-UX-*.11.*) + # Use updated header definitions where possible + +$as_echo "#define _XOPEN_SOURCE_EXTENDED 1" >>confdefs.h + + # TEA specific: Needed by Tcl, but not most extensions + #AC_DEFINE(_XOPEN_SOURCE, 1, [Do we want to use the XOPEN network library?]) + #LIBS="$LIBS -lxnet" # Use the XOPEN network library + + if test "`uname -m`" = ia64; then : + + SHLIB_SUFFIX=".so" + # Use newer C++ library for C++ extensions + #if test "$GCC" != "yes" ; then + # CPPFLAGS="-AA" + #fi + +else + + SHLIB_SUFFIX=".sl" + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 +$as_echo_n "checking for shl_load in -ldld... " >&6; } +if ${ac_cv_lib_dld_shl_load+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load (); +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dld_shl_load=yes +else + ac_cv_lib_dld_shl_load=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 +$as_echo "$ac_cv_lib_dld_shl_load" >&6; } +if test "x$ac_cv_lib_dld_shl_load" = xyes; then : + tcl_ok=yes +else + tcl_ok=no +fi + + if test "$tcl_ok" = yes; then : + + LDFLAGS="$LDFLAGS -Wl,-E" + CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.' + LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.' + LD_LIBRARY_PATH_VAR="SHLIB_PATH" + +fi + if test "$GCC" = yes; then : + + SHLIB_LD='${CC} -shared' + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + +else + + CFLAGS="$CFLAGS -z" + # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc + #CFLAGS="$CFLAGS +DAportable" + SHLIB_CFLAGS="+z" + SHLIB_LD="ld -b" + +fi + + # Check to enable 64-bit flags for compiler/linker + if test "$do64bit" = "yes"; then : + + if test "$GCC" = yes; then : + + case `${CC} -dumpmachine` in + hppa64*) + # 64-bit gcc in use. Fix flags for GNU ld. + do64bit_ok=yes + SHLIB_LD='${CC} -shared' + if test $doRpath = yes; then : + + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' +fi + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC on $system" >&5 +$as_echo "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;} + ;; + esac + +else + + do64bit_ok=yes + CFLAGS="$CFLAGS +DD64" + LDFLAGS_ARCH="+DD64" + +fi + +fi ;; + IRIX-6.*) + SHLIB_CFLAGS="" + SHLIB_LD="ld -n32 -shared -rdata_shared" + SHLIB_SUFFIX=".so" + if test $doRpath = yes; then : + + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}' +fi + if test "$GCC" = yes; then : + + CFLAGS="$CFLAGS -mabi=n32" + LDFLAGS="$LDFLAGS -mabi=n32" + +else + + case $system in + IRIX-6.3) + # Use to build 6.2 compatible binaries on 6.3. + CFLAGS="$CFLAGS -n32 -D_OLD_TERMIOS" + ;; + *) + CFLAGS="$CFLAGS -n32" + ;; + esac + LDFLAGS="$LDFLAGS -n32" + +fi + ;; + IRIX64-6.*) + SHLIB_CFLAGS="" + SHLIB_LD="ld -n32 -shared -rdata_shared" + SHLIB_SUFFIX=".so" + if test $doRpath = yes; then : + + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}' +fi + + # Check to enable 64-bit flags for compiler/linker + + if test "$do64bit" = yes; then : + + if test "$GCC" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported by gcc" >&5 +$as_echo "$as_me: WARNING: 64bit mode not supported by gcc" >&2;} + +else + + do64bit_ok=yes + SHLIB_LD="ld -64 -shared -rdata_shared" + CFLAGS="$CFLAGS -64" + LDFLAGS_ARCH="-64" + +fi + +fi + ;; + Linux*|GNU*|NetBSD-Debian) + SHLIB_CFLAGS="-fPIC" + SHLIB_SUFFIX=".so" + + # TEA specific: + CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" + + # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS + SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS_DEFAULT}' + LDFLAGS="$LDFLAGS -Wl,--export-dynamic" + if test $doRpath = yes; then : + + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' +fi + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + if test "`uname -m`" = "alpha"; then : + CFLAGS="$CFLAGS -mieee" +fi + if test $do64bit = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts -m64 flag" >&5 +$as_echo_n "checking if compiler accepts -m64 flag... " >&6; } +if ${tcl_cv_cc_m64+:} false; then : + $as_echo_n "(cached) " >&6 +else + + hold_cflags=$CFLAGS + CFLAGS="$CFLAGS -m64" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + tcl_cv_cc_m64=yes +else + tcl_cv_cc_m64=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS=$hold_cflags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_m64" >&5 +$as_echo "$tcl_cv_cc_m64" >&6; } + if test $tcl_cv_cc_m64 = yes; then : + + CFLAGS="$CFLAGS -m64" + do64bit_ok=yes + +fi + +fi + + # The combo of gcc + glibc has a bug related to inlining of + # functions like strtod(). The -fno-builtin flag should address + # this problem but it does not work. The -fno-inline flag is kind + # of overkill but it works. Disable inlining only when one of the + # files in compat/*.c is being linked in. + + if test x"${USE_COMPAT}" != x; then : + CFLAGS="$CFLAGS -fno-inline" +fi + ;; + Lynx*) + SHLIB_CFLAGS="-fPIC" + SHLIB_SUFFIX=".so" + CFLAGS_OPTIMIZE=-02 + SHLIB_LD='${CC} -shared' + LD_FLAGS="-Wl,--export-dynamic" + if test $doRpath = yes; then : + + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' +fi + ;; + OpenBSD-*) + arch=`arch -s` + case "$arch" in + vax) + SHLIB_SUFFIX="" + SHARED_LIB_SUFFIX="" + LDFLAGS="" + ;; + *) + SHLIB_CFLAGS="-fPIC" + SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}' + SHLIB_SUFFIX=".so" + if test $doRpath = yes; then : + + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' +fi + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}' + LDFLAGS="-Wl,-export-dynamic" + ;; + esac + case "$arch" in + vax) + CFLAGS_OPTIMIZE="-O1" + ;; + *) + CFLAGS_OPTIMIZE="-O2" + ;; + esac + if test "${TCL_THREADS}" = "1"; then : + + # On OpenBSD: Compile with -pthread + # Don't link with -lpthread + LIBS=`echo $LIBS | sed s/-lpthread//` + CFLAGS="$CFLAGS -pthread" + +fi + # OpenBSD doesn't do version numbers with dots. + UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' + TCL_LIB_VERSIONS_OK=nodots + ;; + NetBSD-*) + # NetBSD has ELF and can use 'cc -shared' to build shared libs + SHLIB_CFLAGS="-fPIC" + SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}' + SHLIB_SUFFIX=".so" + LDFLAGS="$LDFLAGS -export-dynamic" + if test $doRpath = yes; then : + + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' +fi + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + if test "${TCL_THREADS}" = "1"; then : + + # The -pthread needs to go in the CFLAGS, not LIBS + LIBS=`echo $LIBS | sed s/-pthread//` + CFLAGS="$CFLAGS -pthread" + LDFLAGS="$LDFLAGS -pthread" + +fi + ;; + FreeBSD-*) + # This configuration from FreeBSD Ports. + SHLIB_CFLAGS="-fPIC" + SHLIB_LD="${CC} -shared" + TCL_SHLIB_LD_EXTRAS="-Wl,-soname=\$@" + SHLIB_SUFFIX=".so" + LDFLAGS="" + if test $doRpath = yes; then : + + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' +fi + if test "${TCL_THREADS}" = "1"; then : + + # The -pthread needs to go in the LDFLAGS, not LIBS + LIBS=`echo $LIBS | sed s/-pthread//` + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LDFLAGS="$LDFLAGS $PTHREAD_LIBS" +fi + # Version numbers are dot-stripped by system policy. + TCL_TRIM_DOTS=`echo ${PACKAGE_VERSION} | tr -d .` + UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' + SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1' + TCL_LIB_VERSIONS_OK=nodots + ;; + Darwin-*) + CFLAGS_OPTIMIZE="-Os" + SHLIB_CFLAGS="-fno-common" + # To avoid discrepancies between what headers configure sees during + # preprocessing tests and compiling tests, move any -isysroot and + # -mmacosx-version-min flags from CFLAGS to CPPFLAGS: + CPPFLAGS="${CPPFLAGS} `echo " ${CFLAGS}" | \ + awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \ + if ($i~/^(isysroot|mmacosx-version-min)/) print "-"$i}'`" + CFLAGS="`echo " ${CFLAGS}" | \ + awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \ + if (!($i~/^(isysroot|mmacosx-version-min)/)) print "-"$i}'`" + if test $do64bit = yes; then : + + case `arch` in + ppc) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts -arch ppc64 flag" >&5 +$as_echo_n "checking if compiler accepts -arch ppc64 flag... " >&6; } +if ${tcl_cv_cc_arch_ppc64+:} false; then : + $as_echo_n "(cached) " >&6 +else + + hold_cflags=$CFLAGS + CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + tcl_cv_cc_arch_ppc64=yes +else + tcl_cv_cc_arch_ppc64=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS=$hold_cflags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_arch_ppc64" >&5 +$as_echo "$tcl_cv_cc_arch_ppc64" >&6; } + if test $tcl_cv_cc_arch_ppc64 = yes; then : + + CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5" + do64bit_ok=yes + +fi;; + i386) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts -arch x86_64 flag" >&5 +$as_echo_n "checking if compiler accepts -arch x86_64 flag... " >&6; } +if ${tcl_cv_cc_arch_x86_64+:} false; then : + $as_echo_n "(cached) " >&6 +else + + hold_cflags=$CFLAGS + CFLAGS="$CFLAGS -arch x86_64" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + tcl_cv_cc_arch_x86_64=yes +else + tcl_cv_cc_arch_x86_64=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS=$hold_cflags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_arch_x86_64" >&5 +$as_echo "$tcl_cv_cc_arch_x86_64" >&6; } + if test $tcl_cv_cc_arch_x86_64 = yes; then : + + CFLAGS="$CFLAGS -arch x86_64" + do64bit_ok=yes + +fi;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Don't know how enable 64-bit on architecture \`arch\`" >&5 +$as_echo "$as_me: WARNING: Don't know how enable 64-bit on architecture \`arch\`" >&2;};; + esac + +else + + # Check for combined 32-bit and 64-bit fat build + if echo "$CFLAGS " |grep -E -q -- '-arch (ppc64|x86_64) ' \ + && echo "$CFLAGS " |grep -E -q -- '-arch (ppc|i386) '; then : + + fat_32_64=yes +fi + +fi + # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS + SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS_DEFAULT}' + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ld accepts -single_module flag" >&5 +$as_echo_n "checking if ld accepts -single_module flag... " >&6; } +if ${tcl_cv_ld_single_module+:} false; then : + $as_echo_n "(cached) " >&6 +else + + hold_ldflags=$LDFLAGS + LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +int i; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + tcl_cv_ld_single_module=yes +else + tcl_cv_ld_single_module=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$hold_ldflags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_single_module" >&5 +$as_echo "$tcl_cv_ld_single_module" >&6; } + if test $tcl_cv_ld_single_module = yes; then : + + SHLIB_LD="${SHLIB_LD} -Wl,-single_module" + +fi + # TEA specific: link shlib with current and compatibility version flags + vers=`echo ${PACKAGE_VERSION} | sed -e 's/^\([0-9]\{1,5\}\)\(\(\.[0-9]\{1,3\}\)\{0,2\}\).*$/\1\2/p' -e d` + SHLIB_LD="${SHLIB_LD} -current_version ${vers:-0} -compatibility_version ${vers:-0}" + SHLIB_SUFFIX=".dylib" + # Don't use -prebind when building for Mac OS X 10.4 or later only: + if test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F '10\\.' '{print int($2)}'`" -lt 4 -a \ + "`echo "${CPPFLAGS}" | awk -F '-mmacosx-version-min=10\\.' '{print int($2)}'`" -lt 4; then : + + LDFLAGS="$LDFLAGS -prebind" +fi + LDFLAGS="$LDFLAGS -headerpad_max_install_names" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ld accepts -search_paths_first flag" >&5 +$as_echo_n "checking if ld accepts -search_paths_first flag... " >&6; } +if ${tcl_cv_ld_search_paths_first+:} false; then : + $as_echo_n "(cached) " >&6 +else + + hold_ldflags=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,-search_paths_first" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +int i; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + tcl_cv_ld_search_paths_first=yes +else + tcl_cv_ld_search_paths_first=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$hold_ldflags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_search_paths_first" >&5 +$as_echo "$tcl_cv_ld_search_paths_first" >&6; } + if test $tcl_cv_ld_search_paths_first = yes; then : + + LDFLAGS="$LDFLAGS -Wl,-search_paths_first" + +fi + if test "$tcl_cv_cc_visibility_hidden" != yes; then : + + +$as_echo "#define MODULE_SCOPE __private_extern__" >>confdefs.h + + tcl_cv_cc_visibility_hidden=yes + +fi + CC_SEARCH_FLAGS="" + LD_SEARCH_FLAGS="" + LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH" + # TEA specific: for combined 32 & 64 bit fat builds of Tk + # extensions, verify that 64-bit build is possible. + if test "$fat_32_64" = yes && test -n "${TK_BIN_DIR}"; then : + + if test "${TEA_WINDOWINGSYSTEM}" = x11; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit X11" >&5 +$as_echo_n "checking for 64-bit X11... " >&6; } +if ${tcl_cv_lib_x11_64+:} false; then : + $as_echo_n "(cached) " >&6 +else + + for v in CFLAGS CPPFLAGS LDFLAGS; do + eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"' + done + CPPFLAGS="$CPPFLAGS -I/usr/X11R6/include" + LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +XrmInitialize(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + tcl_cv_lib_x11_64=yes +else + tcl_cv_lib_x11_64=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + for v in CFLAGS CPPFLAGS LDFLAGS; do + eval $v'="$hold_'$v'"' + done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_lib_x11_64" >&5 +$as_echo "$tcl_cv_lib_x11_64" >&6; } + +fi + if test "${TEA_WINDOWINGSYSTEM}" = aqua; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit Tk" >&5 +$as_echo_n "checking for 64-bit Tk... " >&6; } +if ${tcl_cv_lib_tk_64+:} false; then : + $as_echo_n "(cached) " >&6 +else + + for v in CFLAGS CPPFLAGS LDFLAGS; do + eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"' + done + CPPFLAGS="$CPPFLAGS -DUSE_TCL_STUBS=1 -DUSE_TK_STUBS=1 ${TCL_INCLUDES} ${TK_INCLUDES}" + LDFLAGS="$LDFLAGS ${TCL_STUB_LIB_SPEC} ${TK_STUB_LIB_SPEC}" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +Tk_InitStubs(NULL, "", 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + tcl_cv_lib_tk_64=yes +else + tcl_cv_lib_tk_64=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + for v in CFLAGS CPPFLAGS LDFLAGS; do + eval $v'="$hold_'$v'"' + done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_lib_tk_64" >&5 +$as_echo "$tcl_cv_lib_tk_64" >&6; } + +fi + # remove 64-bit arch flags from CFLAGS et al. if configuration + # does not support 64-bit. + if test "$tcl_cv_lib_tk_64" = no -o "$tcl_cv_lib_x11_64" = no; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: Removing 64-bit architectures from compiler & linker flags" >&5 +$as_echo "$as_me: Removing 64-bit architectures from compiler & linker flags" >&6;} + for v in CFLAGS CPPFLAGS LDFLAGS; do + eval $v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"' + done +fi + +fi + ;; + OS/390-*) + CFLAGS_OPTIMIZE="" # Optimizer is buggy + +$as_echo "#define _OE_SOCKETS 1" >>confdefs.h + + ;; + OSF1-V*) + # Digital OSF/1 + SHLIB_CFLAGS="" + if test "$SHARED_BUILD" = 1; then : + + SHLIB_LD='ld -shared -expect_unresolved "*"' + +else + + SHLIB_LD='ld -non_shared -expect_unresolved "*"' + +fi + SHLIB_SUFFIX=".so" + if test $doRpath = yes; then : + + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}' +fi + if test "$GCC" = yes; then : + CFLAGS="$CFLAGS -mieee" +else + + CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee" +fi + # see pthread_intro(3) for pthread support on osf1, k.furukawa + if test "${TCL_THREADS}" = 1; then : + + CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE" + CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64" + LIBS=`echo $LIBS | sed s/-lpthreads//` + if test "$GCC" = yes; then : + + LIBS="$LIBS -lpthread -lmach -lexc" + +else + + CFLAGS="$CFLAGS -pthread" + LDFLAGS="$LDFLAGS -pthread" + +fi + +fi + ;; + QNX-6*) + # QNX RTP + # This may work for all QNX, but it was only reported for v6. + SHLIB_CFLAGS="-fPIC" + SHLIB_LD="ld -Bshareable -x" + SHLIB_LD_LIBS="" + SHLIB_SUFFIX=".so" + CC_SEARCH_FLAGS="" + LD_SEARCH_FLAGS="" + ;; + SCO_SV-3.2*) + if test "$GCC" = yes; then : + + SHLIB_CFLAGS="-fPIC -melf" + LDFLAGS="$LDFLAGS -melf -Wl,-Bexport" + +else + + SHLIB_CFLAGS="-Kpic -belf" + LDFLAGS="$LDFLAGS -belf -Wl,-Bexport" + +fi + SHLIB_LD="ld -G" + SHLIB_LD_LIBS="" + SHLIB_SUFFIX=".so" + CC_SEARCH_FLAGS="" + LD_SEARCH_FLAGS="" + ;; + SunOS-5.[0-6]) + # Careful to not let 5.10+ fall into this case + + # Note: If _REENTRANT isn't defined, then Solaris + # won't define thread-safe library routines. + + +$as_echo "#define _REENTRANT 1" >>confdefs.h + + +$as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h + + + SHLIB_CFLAGS="-KPIC" + SHLIB_SUFFIX=".so" + if test "$GCC" = yes; then : + + SHLIB_LD='${CC} -shared' + CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + +else + + SHLIB_LD="/usr/ccs/bin/ld -G -z text" + CC_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + +fi + ;; + SunOS-5*) + # Note: If _REENTRANT isn't defined, then Solaris + # won't define thread-safe library routines. + + +$as_echo "#define _REENTRANT 1" >>confdefs.h + + +$as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h + + + SHLIB_CFLAGS="-KPIC" + + # Check to enable 64-bit flags for compiler/linker + if test "$do64bit" = yes; then : + + arch=`isainfo` + if test "$arch" = "sparcv9 sparc"; then : + + if test "$GCC" = yes; then : + + if test "`${CC} -dumpversion | awk -F. '{print $1}'`" -lt 3; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC < 3.2 on $system" >&5 +$as_echo "$as_me: WARNING: 64bit mode not supported with GCC < 3.2 on $system" >&2;} + +else + + do64bit_ok=yes + CFLAGS="$CFLAGS -m64 -mcpu=v9" + LDFLAGS="$LDFLAGS -m64 -mcpu=v9" + SHLIB_CFLAGS="-fPIC" + +fi + +else + + do64bit_ok=yes + if test "$do64bitVIS" = yes; then : + + CFLAGS="$CFLAGS -xarch=v9a" + LDFLAGS_ARCH="-xarch=v9a" + +else + + CFLAGS="$CFLAGS -xarch=v9" + LDFLAGS_ARCH="-xarch=v9" + +fi + # Solaris 64 uses this as well + #LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH_64" + +fi + +else + if test "$arch" = "amd64 i386"; then : + + if test "$GCC" = yes; then : + + case $system in + SunOS-5.1[1-9]*|SunOS-5.[2-9][0-9]*) + do64bit_ok=yes + CFLAGS="$CFLAGS -m64" + LDFLAGS="$LDFLAGS -m64";; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC on $system" >&5 +$as_echo "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;};; + esac + +else + + do64bit_ok=yes + case $system in + SunOS-5.1[1-9]*|SunOS-5.[2-9][0-9]*) + CFLAGS="$CFLAGS -m64" + LDFLAGS="$LDFLAGS -m64";; + *) + CFLAGS="$CFLAGS -xarch=amd64" + LDFLAGS="$LDFLAGS -xarch=amd64";; + esac + +fi + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported for $arch" >&5 +$as_echo "$as_me: WARNING: 64bit mode not supported for $arch" >&2;} +fi +fi + +fi + + SHLIB_SUFFIX=".so" + if test "$GCC" = yes; then : + + SHLIB_LD='${CC} -shared' + CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + if test "$do64bit_ok" = yes; then : + + if test "$arch" = "sparcv9 sparc"; then : + + # We need to specify -static-libgcc or we need to + # add the path to the sparv9 libgcc. + # JH: static-libgcc is necessary for core Tcl, but may + # not be necessary for extensions. + SHLIB_LD="$SHLIB_LD -m64 -mcpu=v9 -static-libgcc" + # for finding sparcv9 libgcc, get the regular libgcc + # path, remove so name and append 'sparcv9' + #v9gcclibdir="`gcc -print-file-name=libgcc_s.so` | ..." + #CC_SEARCH_FLAGS="${CC_SEARCH_FLAGS},-R,$v9gcclibdir" + +else + if test "$arch" = "amd64 i386"; then : + + # JH: static-libgcc is necessary for core Tcl, but may + # not be necessary for extensions. + SHLIB_LD="$SHLIB_LD -m64 -static-libgcc" + +fi +fi + +fi + +else + + case $system in + SunOS-5.[1-9][0-9]*) + # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS + SHLIB_LD='${CC} -G -z text ${LDFLAGS_DEFAULT}';; + *) + SHLIB_LD='/usr/ccs/bin/ld -G -z text';; + esac + CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' + +fi + ;; + UNIX_SV* | UnixWare-5*) + SHLIB_CFLAGS="-KPIC" + SHLIB_LD='${CC} -G' + SHLIB_LD_LIBS="" + SHLIB_SUFFIX=".so" + # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers + # that don't grok the -Bexport option. Test that it does. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld accepts -Bexport flag" >&5 +$as_echo_n "checking for ld accepts -Bexport flag... " >&6; } +if ${tcl_cv_ld_Bexport+:} false; then : + $as_echo_n "(cached) " >&6 +else + + hold_ldflags=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,-Bexport" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +int i; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + tcl_cv_ld_Bexport=yes +else + tcl_cv_ld_Bexport=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$hold_ldflags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_Bexport" >&5 +$as_echo "$tcl_cv_ld_Bexport" >&6; } + if test $tcl_cv_ld_Bexport = yes; then : + + LDFLAGS="$LDFLAGS -Wl,-Bexport" + +fi + CC_SEARCH_FLAGS="" + LD_SEARCH_FLAGS="" + ;; + esac + + if test "$do64bit" = yes -a "$do64bit_ok" = no; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit support being disabled -- don't know magic for this platform" >&5 +$as_echo "$as_me: WARNING: 64bit support being disabled -- don't know magic for this platform" >&2;} + +fi + + + + # Add in the arch flags late to ensure it wasn't removed. + # Not necessary in TEA, but this is aligned with core + LDFLAGS="$LDFLAGS $LDFLAGS_ARCH" + + # If we're running gcc, then change the C flags for compiling shared + # libraries to the right flags for gcc, instead of those for the + # standard manufacturer compiler. + + if test "$GCC" = yes; then : + + case $system in + AIX-*) ;; + BSD/OS*) ;; + CYGWIN_*|MINGW32_*) ;; + IRIX*) ;; + NetBSD-*|FreeBSD-*|OpenBSD-*) ;; + Darwin-*) ;; + SCO_SV-3.2*) ;; + windows) ;; + *) SHLIB_CFLAGS="-fPIC" ;; + esac +fi + + if test "$tcl_cv_cc_visibility_hidden" != yes; then : + + +$as_echo "#define MODULE_SCOPE extern" >>confdefs.h + + +fi + + if test "$SHARED_LIB_SUFFIX" = ""; then : + + # TEA specific: use PACKAGE_VERSION instead of VERSION + SHARED_LIB_SUFFIX='${PACKAGE_VERSION}${SHLIB_SUFFIX}' +fi + if test "$UNSHARED_LIB_SUFFIX" = ""; then : + + # TEA specific: use PACKAGE_VERSION instead of VERSION + UNSHARED_LIB_SUFFIX='${PACKAGE_VERSION}.a' +fi + + if test "${GCC}" = "yes" -a ${SHLIB_SUFFIX} = ".dll"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SEH support in compiler" >&5 +$as_echo_n "checking for SEH support in compiler... " >&6; } +if ${tcl_cv_seh+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + tcl_cv_seh=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN + + int main(int argc, char** argv) { + int a, b = 0; + __try { + a = 666 / b; + } + __except (EXCEPTION_EXECUTE_HANDLER) { + return 0; + } + return 1; + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + tcl_cv_seh=yes +else + tcl_cv_seh=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_seh" >&5 +$as_echo "$tcl_cv_seh" >&6; } + if test "$tcl_cv_seh" = "no" ; then + +$as_echo "#define HAVE_NO_SEH 1" >>confdefs.h + + fi + + # + # Check to see if the excpt.h include file provided contains the + # definition for EXCEPTION_DISPOSITION; if not, which is the case + # with Cygwin's version as of 2002-04-10, define it to be int, + # sufficient for getting the current code to work. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EXCEPTION_DISPOSITION support in include files" >&5 +$as_echo_n "checking for EXCEPTION_DISPOSITION support in include files... " >&6; } +if ${tcl_cv_eh_disposition+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# define WIN32_LEAN_AND_MEAN +# include +# undef WIN32_LEAN_AND_MEAN + +int +main () +{ + + EXCEPTION_DISPOSITION x; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_eh_disposition=yes +else + tcl_cv_eh_disposition=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_eh_disposition" >&5 +$as_echo "$tcl_cv_eh_disposition" >&6; } + if test "$tcl_cv_eh_disposition" = "no" ; then + +$as_echo "#define EXCEPTION_DISPOSITION int" >>confdefs.h + + fi + + # Check to see if winnt.h defines CHAR, SHORT, and LONG + # even if VOID has already been #defined. The win32api + # used by mingw and cygwin is known to do this. + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for winnt.h that ignores VOID define" >&5 +$as_echo_n "checking for winnt.h that ignores VOID define... " >&6; } +if ${tcl_cv_winnt_ignore_void+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define VOID void +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN + +int +main () +{ + + CHAR c; + SHORT s; + LONG l; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_winnt_ignore_void=yes +else + tcl_cv_winnt_ignore_void=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_winnt_ignore_void" >&5 +$as_echo "$tcl_cv_winnt_ignore_void" >&6; } + if test "$tcl_cv_winnt_ignore_void" = "yes" ; then + +$as_echo "#define HAVE_WINNT_IGNORE_VOID 1" >>confdefs.h + + fi + fi + + # See if the compiler supports casting to a union type. + # This is used to stop gcc from printing a compiler + # warning when initializing a union member. + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cast to union support" >&5 +$as_echo_n "checking for cast to union support... " >&6; } +if ${tcl_cv_cast_to_union+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + union foo { int i; double d; }; + union foo f = (union foo) (int) 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_cast_to_union=yes +else + tcl_cv_cast_to_union=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cast_to_union" >&5 +$as_echo "$tcl_cv_cast_to_union" >&6; } + if test "$tcl_cv_cast_to_union" = "yes"; then + +$as_echo "#define HAVE_CAST_TO_UNION 1" >>confdefs.h + + fi + + + + + + + + + + + + + + # These must be called after we do the basic CFLAGS checks and + # verify any possible 64-bit or similar switches are necessary + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for required early compiler flags" >&5 +$as_echo_n "checking for required early compiler flags... " >&6; } + tcl_flags="" + + if ${tcl_cv_flag__isoc99_source+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +char *p = (char *)strtoll; char *q = (char *)strtoull; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_flag__isoc99_source=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _ISOC99_SOURCE 1 +#include +int +main () +{ +char *p = (char *)strtoll; char *q = (char *)strtoull; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_flag__isoc99_source=yes +else + tcl_cv_flag__isoc99_source=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + if test "x${tcl_cv_flag__isoc99_source}" = "xyes" ; then + +$as_echo "#define _ISOC99_SOURCE 1" >>confdefs.h + + tcl_flags="$tcl_flags _ISOC99_SOURCE" + fi + + + if ${tcl_cv_flag__largefile64_source+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +struct stat64 buf; int i = stat64("/", &buf); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_flag__largefile64_source=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _LARGEFILE64_SOURCE 1 +#include +int +main () +{ +struct stat64 buf; int i = stat64("/", &buf); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_flag__largefile64_source=yes +else + tcl_cv_flag__largefile64_source=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + if test "x${tcl_cv_flag__largefile64_source}" = "xyes" ; then + +$as_echo "#define _LARGEFILE64_SOURCE 1" >>confdefs.h + + tcl_flags="$tcl_flags _LARGEFILE64_SOURCE" + fi + + + if ${tcl_cv_flag__largefile_source64+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +char *p = (char *)open64; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_flag__largefile_source64=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _LARGEFILE_SOURCE64 1 +#include +int +main () +{ +char *p = (char *)open64; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_flag__largefile_source64=yes +else + tcl_cv_flag__largefile_source64=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + if test "x${tcl_cv_flag__largefile_source64}" = "xyes" ; then + +$as_echo "#define _LARGEFILE_SOURCE64 1" >>confdefs.h + + tcl_flags="$tcl_flags _LARGEFILE_SOURCE64" + fi + + if test "x${tcl_flags}" = "x" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 +$as_echo "none" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${tcl_flags}" >&5 +$as_echo "${tcl_flags}" >&6; } + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit integer type" >&5 +$as_echo_n "checking for 64-bit integer type... " >&6; } + if ${tcl_cv_type_64bit+:} false; then : + $as_echo_n "(cached) " >&6 +else + + tcl_cv_type_64bit=none + # See if the compiler knows natively about __int64 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +__int64 value = (__int64) 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_type_64bit=__int64 +else + tcl_type_64bit="long long" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + # See if we should use long anyway Note that we substitute in the + # type that is our current guess for a 64-bit type inside this check + # program, so it should be modified only carefully... + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +switch (0) { + case 1: case (sizeof(${tcl_type_64bit})==sizeof(long)): ; + } + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_type_64bit=${tcl_type_64bit} +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + if test "${tcl_cv_type_64bit}" = none ; then + +$as_echo "#define TCL_WIDE_INT_IS_LONG 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using long" >&5 +$as_echo "using long" >&6; } + elif test "${tcl_cv_type_64bit}" = "__int64" \ + -a "${TEA_PLATFORM}" = "windows" ; then + # TEA specific: We actually want to use the default tcl.h checks in + # this case to handle both TCL_WIDE_INT_TYPE and TCL_LL_MODIFIER* + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using Tcl header defaults" >&5 +$as_echo "using Tcl header defaults" >&6; } + else + +cat >>confdefs.h <<_ACEOF +#define TCL_WIDE_INT_TYPE ${tcl_cv_type_64bit} +_ACEOF + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${tcl_cv_type_64bit}" >&5 +$as_echo "${tcl_cv_type_64bit}" >&6; } + + # Now check for auxiliary declarations + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct dirent64" >&5 +$as_echo_n "checking for struct dirent64... " >&6; } +if ${tcl_cv_struct_dirent64+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +struct dirent64 p; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_struct_dirent64=yes +else + tcl_cv_struct_dirent64=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_struct_dirent64" >&5 +$as_echo "$tcl_cv_struct_dirent64" >&6; } + if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then + +$as_echo "#define HAVE_STRUCT_DIRENT64 1" >>confdefs.h + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct stat64" >&5 +$as_echo_n "checking for struct stat64... " >&6; } +if ${tcl_cv_struct_stat64+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +struct stat64 p; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_struct_stat64=yes +else + tcl_cv_struct_stat64=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_struct_stat64" >&5 +$as_echo "$tcl_cv_struct_stat64" >&6; } + if test "x${tcl_cv_struct_stat64}" = "xyes" ; then + +$as_echo "#define HAVE_STRUCT_STAT64 1" >>confdefs.h + + fi + + for ac_func in open64 lseek64 +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for off64_t" >&5 +$as_echo_n "checking for off64_t... " >&6; } + if ${tcl_cv_type_off64_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +off64_t offset; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_type_off64_t=yes +else + tcl_cv_type_off64_t=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + if test "x${tcl_cv_type_off64_t}" = "xyes" && \ + test "x${ac_cv_func_lseek64}" = "xyes" && \ + test "x${ac_cv_func_open64}" = "xyes" ; then + +$as_echo "#define HAVE_TYPE_OFF64_T 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + fi + + + +#-------------------------------------------------------------------- +# Set the default compiler switches based on the --enable-symbols option. +#-------------------------------------------------------------------- + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for build with symbols" >&5 +$as_echo_n "checking for build with symbols... " >&6; } + # Check whether --enable-symbols was given. +if test "${enable_symbols+set}" = set; then : + enableval=$enable_symbols; tcl_ok=$enableval +else + tcl_ok=no +fi + + DBGX="" + if test "$tcl_ok" = "no"; then + CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE} -DNDEBUG" + LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + else + CFLAGS_DEFAULT="${CFLAGS_DEBUG}" + LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}" + if test "$tcl_ok" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (standard debugging)" >&5 +$as_echo "yes (standard debugging)" >&6; } + fi + fi + # TEA specific: + if test "${TEA_PLATFORM}" != "windows" ; then + LDFLAGS_DEFAULT="${LDFLAGS}" + fi + + + + + if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then + +$as_echo "#define TCL_MEM_DEBUG 1" >>confdefs.h + + fi + + if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then + if test "$tcl_ok" = "all"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled symbols mem debugging" >&5 +$as_echo "enabled symbols mem debugging" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled $tcl_ok debugging" >&5 +$as_echo "enabled $tcl_ok debugging" >&6; } + fi + fi + + +#-------------------------------------------------------------------- +# Everyone should be linking against the Tcl stub library. If you +# can't for some reason, remove this definition. If you aren't using +# stubs, you also need to modify the SHLIB_LD_LIBS setting below to +# link against the non-stubbed Tcl library. Add Tk too if necessary. +#-------------------------------------------------------------------- + + +$as_echo "#define USE_TCL_STUBS 1" >>confdefs.h + +#AC_DEFINE(USE_TK_STUBS, 1, [Use Tk stubs]) + +#-------------------------------------------------------------------- +# This macro generates a line to use when building a library. It +# depends on values set by the TEA_ENABLE_SHARED, TEA_ENABLE_SYMBOLS, +# and TEA_LOAD_TCLCONFIG macros above. +#-------------------------------------------------------------------- + + + if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes"; then + MAKE_STATIC_LIB="\${STLIB_LD} -out:\$@ \$(PKG_OBJECTS)" + MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LD_LIBS} \${LDFLAGS_DEFAULT} -out:\$@ \$(PKG_OBJECTS)" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if defined(_MSC_VER) && _MSC_VER >= 1400 +print("manifest needed") +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "manifest needed" >/dev/null 2>&1; then : + + # Could do a CHECK_PROG for mt, but should always be with MSVC8+ + VC_MANIFEST_EMBED_DLL="if test -f \$@.manifest ; then mt.exe -nologo -manifest \$@.manifest -outputresource:\$@\;2 ; fi" + VC_MANIFEST_EMBED_EXE="if test -f \$@.manifest ; then mt.exe -nologo -manifest \$@.manifest -outputresource:\$@\;1 ; fi" + MAKE_SHARED_LIB="${MAKE_SHARED_LIB} ; ${VC_MANIFEST_EMBED_DLL}" + + CLEANFILES="$CLEANFILES *.manifest" + + +fi +rm -f conftest* + + MAKE_STUB_LIB="\${STLIB_LD} -out:\$@ \$(PKG_STUB_OBJECTS)" + else + MAKE_STATIC_LIB="\${STLIB_LD} \$@ \$(PKG_OBJECTS)" + MAKE_SHARED_LIB="\${SHLIB_LD} -o \$@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}" + MAKE_STUB_LIB="\${STLIB_LD} \$@ \$(PKG_STUB_OBJECTS)" + fi + + if test "${SHARED_BUILD}" = "1" ; then + MAKE_LIB="${MAKE_SHARED_LIB} " + else + MAKE_LIB="${MAKE_STATIC_LIB} " + fi + + #-------------------------------------------------------------------- + # Shared libraries and static libraries have different names. + # Use the double eval to make sure any variables in the suffix is + # substituted. (@@@ Might not be necessary anymore) + #-------------------------------------------------------------------- + + if test "${TEA_PLATFORM}" = "windows" ; then + if test "${SHARED_BUILD}" = "1" ; then + # We force the unresolved linking of symbols that are really in + # the private libraries of Tcl and Tk. + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}`\"" + if test x"${TK_BIN_DIR}" != x ; then + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TK_BIN_DIR}/${TK_STUB_LIB_FILE}`\"" + fi + eval eval "PKG_LIB_FILE=${PACKAGE_NAME}${SHARED_LIB_SUFFIX}" + else + eval eval "PKG_LIB_FILE=${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}" + fi + # Some packages build their own stubs libraries + eval eval "PKG_STUB_LIB_FILE=${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}" + if test "$GCC" = "yes"; then + PKG_STUB_LIB_FILE=lib${PKG_STUB_LIB_FILE} + fi + # These aren't needed on Windows (either MSVC or gcc) + RANLIB=: + RANLIB_STUB=: + else + RANLIB_STUB="${RANLIB}" + if test "${SHARED_BUILD}" = "1" ; then + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TCL_STUB_LIB_SPEC}" + if test x"${TK_BIN_DIR}" != x ; then + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TK_STUB_LIB_SPEC}" + fi + eval eval "PKG_LIB_FILE=lib${PACKAGE_NAME}${SHARED_LIB_SUFFIX}" + RANLIB=: + else + eval eval "PKG_LIB_FILE=lib${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}" + fi + # Some packages build their own stubs libraries + eval eval "PKG_STUB_LIB_FILE=lib${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}" + fi + + # These are escaped so that only CFLAGS is picked up at configure time. + # The other values will be substituted at make time. + CFLAGS="${CFLAGS} \${CFLAGS_DEFAULT} \${CFLAGS_WARNING}" + if test "${SHARED_BUILD}" = "1" ; then + CFLAGS="${CFLAGS} \${SHLIB_CFLAGS}" + fi + + + + + + + + + + +#-------------------------------------------------------------------- +# Determine the name of the tclsh and/or wish executables in the +# Tcl and Tk build directories or the location they were installed +# into. These paths are used to support running test cases only, +# the Makefile should not be making use of these paths to generate +# a pkgIndex.tcl file or anything else at extension build time. +#-------------------------------------------------------------------- + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tclsh" >&5 +$as_echo_n "checking for tclsh... " >&6; } + if test -f "${TCL_BIN_DIR}/Makefile" ; then + # tclConfig.sh is in Tcl build directory + if test "${TEA_PLATFORM}" = "windows"; then + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" + else + TCLSH_PROG="${TCL_BIN_DIR}/tclsh" + fi + else + # tclConfig.sh is in install location + if test "${TEA_PLATFORM}" = "windows"; then + TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" + else + TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}${TCL_DBGX}" + fi + list="`ls -d ${TCL_BIN_DIR}/../bin 2>/dev/null` \ + `ls -d ${TCL_BIN_DIR}/.. 2>/dev/null` \ + `ls -d ${TCL_PREFIX}/bin 2>/dev/null`" + for i in $list ; do + if test -f "$i/${TCLSH_PROG}" ; then + REAL_TCL_BIN_DIR="`cd "$i"; pwd`/" + break + fi + done + TCLSH_PROG="${REAL_TCL_BIN_DIR}${TCLSH_PROG}" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${TCLSH_PROG}" >&5 +$as_echo "${TCLSH_PROG}" >&6; } + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wish" >&5 +$as_echo_n "checking for wish... " >&6; } + if test -f "${TK_BIN_DIR}/Makefile" ; then + # tkConfig.sh is in Tk build directory + if test "${TEA_PLATFORM}" = "windows"; then + WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}" + else + WISH_PROG="${TK_BIN_DIR}/wish" + fi + else + # tkConfig.sh is in install location + if test "${TEA_PLATFORM}" = "windows"; then + WISH_PROG="wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}" + else + WISH_PROG="wish${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}${TK_DBGX}" + fi + list="`ls -d ${TK_BIN_DIR}/../bin 2>/dev/null` \ + `ls -d ${TK_BIN_DIR}/.. 2>/dev/null` \ + `ls -d ${TK_PREFIX}/bin 2>/dev/null`" + for i in $list ; do + if test -f "$i/${WISH_PROG}" ; then + REAL_TK_BIN_DIR="`cd "$i"; pwd`/" + break + fi + done + WISH_PROG="${REAL_TK_BIN_DIR}${WISH_PROG}" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${WISH_PROG}" >&5 +$as_echo "${WISH_PROG}" >&6; } + + + +#-------------------------------------------------------------------- +# Finally, substitute all of the various values into the Makefile. +# You may alternatively have a special pkgIndex.tcl.in or other files +# which require substituting th AC variables in. Include these here. +#-------------------------------------------------------------------- + +ac_config_files="$ac_config_files Makefile pkgIndex.tcl" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +ac_script=' +:mline +/\\$/{ + N + s,\\\n,, + b mline +} +t clear +:clear +s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g +t quote +s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g +t quote +b any +:quote +s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g +s/\[/\\&/g +s/\]/\\&/g +s/\$/$$/g +H +:any +${ + g + s/^\n// + s/\n/ /g + p +} +' +DEFS=`sed -n "$ac_script" confdefs.h` + + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +CFLAGS="${CFLAGS} ${CPPFLAGS}"; CPPFLAGS="" + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by tksao $as_me 1.0, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Report bugs to the package provider." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +tksao config.status 1.0 +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h | --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "pkgIndex.tcl") CONFIG_FILES="$CONFIG_FILES pkgIndex.tcl" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + + +eval set X " :F $CONFIG_FILES " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + + + + esac + +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff --git a/tksao/configure.in b/tksao/configure.in new file mode 100755 index 0000000..b3596b0 --- /dev/null +++ b/tksao/configure.in @@ -0,0 +1,411 @@ +#!/bin/bash -norc +dnl This file is an input file used by the GNU "autoconf" program to +dnl generate the file "configure", which is run during Tcl installation +dnl to configure the system for the local environment. + +#----------------------------------------------------------------------- +# Sample configure.in for Tcl Extensions. The only places you should +# need to modify this file are marked by the string __CHANGE__ +#----------------------------------------------------------------------- + +#----------------------------------------------------------------------- +# __CHANGE__ +# Set your package name and version numbers here. +# +# This initializes the environment with PACKAGE_NAME and PACKAGE_VERSION +# set as provided. These will also be added as -D defs in your Makefile +# so you can encode the package version directly into the source files. +# This will also define a special symbol for Windows (BUILD_ +# so that we create the export library with the dll. +#----------------------------------------------------------------------- + +AC_INIT([tksao], [1.0]) + +#-------------------------------------------------------------------- +# Call TEA_INIT as the first TEA_ macro to set up initial vars. +# This will define a ${TEA_PLATFORM} variable == "unix" or "windows" +# as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE. +#-------------------------------------------------------------------- + +TEA_INIT([3.9]) + +AC_CONFIG_AUX_DIR(tclconfig) + +#-------------------------------------------------------------------- +# Load the tclConfig.sh file +#-------------------------------------------------------------------- + +TEA_PATH_TCLCONFIG +TEA_LOAD_TCLCONFIG + +#-------------------------------------------------------------------- +# Load the tkConfig.sh file if necessary (Tk extension) +#-------------------------------------------------------------------- + +TEA_PATH_TKCONFIG +TEA_LOAD_TKCONFIG + +#----------------------------------------------------------------------- +# Handle the --prefix=... option by defaulting to what Tcl gave. +# Must be called after TEA_LOAD_TCLCONFIG and before TEA_SETUP_COMPILER. +#----------------------------------------------------------------------- + +TEA_PREFIX + +#----------------------------------------------------------------------- +# Standard compiler checks. +# This sets up CC by using the CC env var, or looks for gcc otherwise. +# This also calls AC_PROG_CC and a few others to create the basic setup +# necessary to compile executables. +#----------------------------------------------------------------------- + +TEA_SETUP_COMPILER + +#----------------------------------------------------------------------- +# __CHANGE__ +# Specify the C source files to compile in TEA_ADD_SOURCES, +# public headers that need to be installed in TEA_ADD_HEADERS, +# stub library C source files to compile in TEA_ADD_STUB_SOURCES, +# and runtime Tcl library files in TEA_ADD_TCL_SOURCES. +# This defines PKG(_STUB)_SOURCES, PKG(_STUB)_OBJECTS, PKG_HEADERS +# and PKG_TCL_SOURCES. +#----------------------------------------------------------------------- + +TEA_ADD_SOURCES([ +saotk.C +colorbar/cbgrid.C +colorbar/colorbar.C +colorbar/colorbarbase.C +colorbar/colorbarrgb.C +colorbar/colorbarrgbtruecolor16.C +colorbar/colorbarrgbtruecolor24.C +colorbar/colorbarrgbtruecolor8.C +colorbar/colorbartruecolor16.C +colorbar/colorbartruecolor24.C +colorbar/colorbartruecolor8.C +colorbar/colormap.C +colorbar/colortag.C +colorbar/default.C +colorbar/lex.C +colorbar/lut.C +colorbar/lutlex.C +colorbar/lutparser.C +colorbar/parser.C +colorbar/sao.C +colorbar/saolex.C +colorbar/saoparser.C +fitsy++/alloc.C +fitsy++/allocgz.C +fitsy++/analysis.C +fitsy++/block.C +fitsy++/card.C +fitsy++/channel.C +fitsy++/column.C +fitsy++/compress.C +fitsy++/envi.C +fitsy++/envilex.C +fitsy++/enviparser.C +fitsy++/file.C +fitsy++/gzip.C +fitsy++/hcompress.C +fitsy++/hdecompress.c +fitsy++/hdu.C +fitsy++/head.C +fitsy++/hist.C +fitsy++/hpx.C +fitsy++/iis.C +fitsy++/lex.C +fitsy++/map.C +fitsy++/mapincr.C +fitsy++/mmap.C +fitsy++/mmapincr.C +fitsy++/nrrd.C +fitsy++/nrrdgzip.C +fitsy++/nrrdlex.C +fitsy++/nrrdparser.C +fitsy++/order.C +fitsy++/outchannel.C +fitsy++/outfile.C +fitsy++/outfits.C +fitsy++/outsocket.C +fitsy++/parser.C +fitsy++/photo.C +fitsy++/plio.C +fitsy++/pliocomp.c +fitsy++/rice.C +fitsy++/ricecomp.c +fitsy++/savefits.C +fitsy++/share.C +fitsy++/smap.C +fitsy++/smmap.C +fitsy++/socket.C +fitsy++/socketgz.C +fitsy++/sshare.C +fitsy++/strm.C +fitsy++/var.C +frame/annulus.C +frame/base.C +frame/basebox.C +frame/basecommand.C +frame/baseellipse.C +frame/baseline.C +frame/basemarker.C +frame/basepolygon.C +frame/box.C +frame/boxannulus.C +frame/bpanda.C +frame/callback.C +frame/ciaolex.C +frame/ciaoparser.C +frame/circle.C +frame/colorscale.C +frame/colorscalergb.C +frame/colorscaletrue16.C +frame/colorscaletrue24.C +frame/colorscaletrue32.C +frame/colorscaletrue8.C +frame/compass.C +frame/composite.C +frame/context.C +frame/contour.C +frame/contourlex.C +frame/contourparser.C +frame/coord.C +frame/cpanda.C +frame/ds9lex.C +frame/ds9parser.C +frame/ellipse.C +frame/ellipseannulus.C +frame/epanda.C +frame/fitsanalysis.C +frame/fitsbin.C +frame/fitsblock.C +frame/fitscompress.C +frame/fitsdata.C +frame/fitsenvi.C +frame/fitshealpix.C +frame/fitsimage.C +frame/fitsmap.C +frame/fitsmask.C +frame/fitsnrrd.C +frame/fr3dcommand.C +frame/fr3dmap.C +frame/frame.C +frame/frame3d.C +frame/frame3dbase.C +frame/frame3dtruecolor16.C +frame/frame3dtruecolor24.C +frame/frame3dtruecolor8.C +frame/framebase.C +frame/framergb.C +frame/framergbtruecolor16.C +frame/framergbtruecolor24.C +frame/framergbtruecolor8.C +frame/frametruecolor16.C +frame/frametruecolor24.C +frame/frametruecolor8.C +frame/frblt.C +frame/frcommand.C +frame/frload.C +frame/frmap.C +frame/frmarker.C +frame/frmarkerxml.C +frame/frsave.C +frame/frscale.C +frame/fvcontour.C +frame/grid.C +frame/grid25d.C +frame/grid2d.C +frame/grid3d.C +frame/inversescale.C +frame/lex.C +frame/line.C +frame/marker.C +frame/parser.C +frame/point.C +frame/polygon.C +frame/projection.C +frame/proslex.C +frame/prosparser.C +frame/raytrace.C +frame/ruler.C +frame/saolex.C +frame/saoparser.C +frame/segment.C +frame/tag.C +frame/text.C +frame/tnglex.C +frame/tngparser.C +frame/vect.C +frame/xylex.C +frame/xyparser.C +list/list.C +magnifier/lex.C +magnifier/magnifier.C +magnifier/magnifiertrue.C +magnifier/parser.C +panner/lex.C +panner/panner.C +panner/pannertrue.C +panner/parser.C +util/attribute.C +util/grf.C +util/grf3d.C +util/grid25dbase.C +util/grid2dbase.C +util/grid3dbase.C +util/gridbase.C +util/ps.C +util/smooth.C +util/util.C +vector/vector.C +vector/vector3d.C +wcssubs/cel.c +wcssubs/distort.c +wcssubs/dsspos.c +wcssubs/hget.c +wcssubs/hput.c +wcssubs/iget.c +wcssubs/lin.c +wcssubs/platepos.c +wcssubs/poly.c +wcssubs/proj.c +wcssubs/sph.c +wcssubs/tnxpos.c +wcssubs/wcs.c +wcssubs/wcscon.c +wcssubs/wcsinit.c +wcssubs/wcslib.c +wcssubs/wcstrig.c +wcssubs/worldpos.c +wcssubs/zpxpos.c +widget/truecolor16.C +widget/truecolor24.C +widget/truecolor8.C +widget/widget.C +]) + +TEA_ADD_HEADERS([]) +TEA_ADD_INCLUDES([-I. -I./colorbar -I./fitsy++ -I./frame -I./list -I./magnifier -I./panner -I./util -I./vector -I./wcssubs -I./widget -I${prefix}/include]) +TEA_ADD_LIBS([-lstdc++]) +TEA_ADD_CFLAGS([]) +TEA_ADD_STUB_SOURCES([]) +TEA_ADD_TCL_SOURCES([]) + +TEA_CONFIG_SYSTEM +case $system in + windows*) + AC_DEFINE(HAVE_MINGW32) + ;; + *) + AC_CHECK_HEADERS(sys/shm.h) + ;; +esac + +#-------------------------------------------------------------------- +# __CHANGE__ +# +# You can add more files to clean if your extension creates any extra +# files by extending CLEANFILES. +# Add pkgIndex.tcl if it is generated in the Makefile instead of ./configure +# and change Makefile.in to move it from CONFIG_CLEAN_FILES to BINARIES var. +# +# A few miscellaneous platform-specific items: +# TEA_ADD_* any platform specific compiler/build info here. +#-------------------------------------------------------------------- + +#CLEANFILES="$CLEANFILES pkgIndex.tcl" +if test "${TEA_PLATFORM}" = "windows" ; then + # Ensure no empty if clauses + : + #TEA_ADD_SOURCES([win/winFile.c]) + #TEA_ADD_INCLUDES([-I\"$(${CYGPATH} ${srcdir}/win)\"]) + TEA_ADD_INCLUDES([-I${prefix}/include/libxml2]) +else + # Ensure no empty else clauses + : + #TEA_ADD_SOURCES([unix/unixFile.c]) + #TEA_ADD_LIBS([-lsuperfly]) + TEA_ADD_INCLUDES([-I/usr/include/libxml2]) +fi + +#-------------------------------------------------------------------- +# __CHANGE__ +# Choose which headers you need. Extension authors should try very +# hard to only rely on the Tcl public header files. Internal headers +# contain private data structures and are subject to change without +# notice. +# This MUST be called after TEA_LOAD_TCLCONFIG / TEA_LOAD_TKCONFIG +#-------------------------------------------------------------------- + +TEA_PUBLIC_TCL_HEADERS +#TEA_PRIVATE_TCL_HEADERS + +TEA_PUBLIC_TK_HEADERS +TEA_PRIVATE_TK_HEADERS +TEA_PATH_X + +#-------------------------------------------------------------------- +# Check whether --enable-threads or --disable-threads was given. +# This auto-enables if Tcl was compiled threaded. +#-------------------------------------------------------------------- + +TEA_ENABLE_THREADS + +#-------------------------------------------------------------------- +# The statement below defines a collection of symbols related to +# building as a shared library instead of a static library. +#-------------------------------------------------------------------- + +TEA_ENABLE_SHARED + +#-------------------------------------------------------------------- +# This macro figures out what flags to use with the compiler/linker +# when building shared/static debug/optimized objects. This information +# can be taken from the tclConfig.sh file, but this figures it all out. +#-------------------------------------------------------------------- + +TEA_CONFIG_CFLAGS + +#-------------------------------------------------------------------- +# Set the default compiler switches based on the --enable-symbols option. +#-------------------------------------------------------------------- + +TEA_ENABLE_SYMBOLS + +#-------------------------------------------------------------------- +# Everyone should be linking against the Tcl stub library. If you +# can't for some reason, remove this definition. If you aren't using +# stubs, you also need to modify the SHLIB_LD_LIBS setting below to +# link against the non-stubbed Tcl library. Add Tk too if necessary. +#-------------------------------------------------------------------- + +AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stubs]) +#AC_DEFINE(USE_TK_STUBS, 1, [Use Tk stubs]) + +#-------------------------------------------------------------------- +# This macro generates a line to use when building a library. It +# depends on values set by the TEA_ENABLE_SHARED, TEA_ENABLE_SYMBOLS, +# and TEA_LOAD_TCLCONFIG macros above. +#-------------------------------------------------------------------- + +TEA_MAKE_LIB + +#-------------------------------------------------------------------- +# Determine the name of the tclsh and/or wish executables in the +# Tcl and Tk build directories or the location they were installed +# into. These paths are used to support running test cases only, +# the Makefile should not be making use of these paths to generate +# a pkgIndex.tcl file or anything else at extension build time. +#-------------------------------------------------------------------- + +TEA_PROG_TCLSH +TEA_PROG_WISH + +#-------------------------------------------------------------------- +# Finally, substitute all of the various values into the Makefile. +# You may alternatively have a special pkgIndex.tcl.in or other files +# which require substituting th AC variables in. Include these here. +#-------------------------------------------------------------------- + +AC_OUTPUT([Makefile pkgIndex.tcl]) diff --git a/tksao/fitsy++/alloc.C b/tksao/fitsy++/alloc.C new file mode 100644 index 0000000..f7dde77 --- /dev/null +++ b/tksao/fitsy++/alloc.C @@ -0,0 +1,25 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include "alloc.h" + +FitsAlloc::FitsAlloc(const char* fn) +{ + parse(fn); + if (!valid_) + return; + + // we need the 'b' for windows... + if (!strncmp(pName_, "stdin", 5) || + !strncmp(pName_, "STDIN", 5) || + !strncmp(pName_, "-", 1)) + stream_ = fdopen(dup(fileno(stdin)), "rb"); + else + stream_ = fopen(pName_, "rb"); + + valid_ = stream_ ? 1 : 0; +} + + diff --git a/tksao/fitsy++/alloc.h b/tksao/fitsy++/alloc.h new file mode 100644 index 0000000..8069448 --- /dev/null +++ b/tksao/fitsy++/alloc.h @@ -0,0 +1,51 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsalloc_h__ +#define __fitsalloc_h__ + +#include "strm.h" + +class FitsAlloc : public virtual FitsStream { +public: + FitsAlloc(const char*); + virtual ~FitsAlloc() {} +}; + +class FitsFitsAlloc : public FitsAlloc, public FitsFitsStream { +public: + FitsFitsAlloc(const char* fn, ScanMode mode, FlushMode flush) + : FitsAlloc(fn), FitsFitsStream(mode, flush) {} +}; + +class FitsFitsNextAlloc : public FitsFitsNextStream { +public: + FitsFitsNextAlloc(FitsFile* prev) : FitsFitsNextStream(prev) {} +}; + +class FitsArrAlloc : public FitsAlloc, FitsArrStream { +public: + FitsArrAlloc(const char* fn, FlushMode flush) + : FitsAlloc(fn), FitsArrStream(flush) {} +}; + +class FitsNRRDAlloc : public FitsAlloc, FitsNRRDStream { +public: + FitsNRRDAlloc(const char* fn, FlushMode flush) + : FitsAlloc(fn), FitsNRRDStream(flush) {} +}; + +class FitsMosaicAlloc : public FitsAlloc, FitsMosaicStream { +public: + FitsMosaicAlloc(const char* fn, FlushMode flush) : + FitsAlloc(fn), FitsMosaicStream(flush) {} +}; + +class FitsMosaicNextAlloc : public FitsMosaicNextStream { +public: + FitsMosaicNextAlloc(FitsFile* prev, FlushMode flush) + : FitsMosaicNextStream(prev, flush) {} +}; + +#endif diff --git a/tksao/fitsy++/allocgz.C b/tksao/fitsy++/allocgz.C new file mode 100644 index 0000000..905b168 --- /dev/null +++ b/tksao/fitsy++/allocgz.C @@ -0,0 +1,25 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include "allocgz.h" + +FitsAllocGZ::FitsAllocGZ(const char* fn) +{ + parse(fn); + if (!valid_) + return; + + // we need the 'b' for windows... + if (!strncmp(pName_, "stdin", 5) || + !strncmp(pName_, "STDIN", 5) || + !strncmp(pName_, "-", 1)) + stream_ = gzdopen(dup(STDIN_FILENO), "rb"); + else + stream_ = gzopen(pName_, "rb"); + + valid_ = stream_ ? 1 : 0; +} + + diff --git a/tksao/fitsy++/allocgz.h b/tksao/fitsy++/allocgz.h new file mode 100644 index 0000000..c2b6e6e --- /dev/null +++ b/tksao/fitsy++/allocgz.h @@ -0,0 +1,46 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsallocgz_h__ +#define __fitsallocgz_h__ + +#include "strm.h" +#include "zlib.h" + +class FitsAllocGZ : public virtual FitsStream { +public: + FitsAllocGZ(const char*); + virtual ~FitsAllocGZ() {} +}; + +class FitsFitsAllocGZ : public FitsAllocGZ, public FitsFitsStream { +public: + FitsFitsAllocGZ(const char* fn, ScanMode mode, FlushMode flush) + : FitsAllocGZ(fn), FitsFitsStream(mode, flush) {} +}; + +class FitsFitsNextAllocGZ : public FitsFitsNextStream { +public: + FitsFitsNextAllocGZ(FitsFile* prev) : FitsFitsNextStream(prev) {} +}; + +class FitsArrAllocGZ : public FitsAllocGZ, FitsArrStream { +public: + FitsArrAllocGZ(const char* fn, FlushMode flush) + : FitsAllocGZ(fn), FitsArrStream(flush) {} +}; + +class FitsMosaicAllocGZ : public FitsAllocGZ, FitsMosaicStream { +public: + FitsMosaicAllocGZ(const char* fn, FlushMode flush) + : FitsAllocGZ(fn), FitsMosaicStream(flush) {} +}; + +class FitsMosaicNextAllocGZ : public FitsMosaicNextStream { +public: + FitsMosaicNextAllocGZ(FitsFile* prev, FlushMode flush) + : FitsMosaicNextStream(prev, flush) {} +}; + +#endif diff --git a/tksao/fitsy++/analysis.C b/tksao/fitsy++/analysis.C new file mode 100644 index 0000000..b06aa12 --- /dev/null +++ b/tksao/fitsy++/analysis.C @@ -0,0 +1,56 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "analysis.h" + +FitsAnalysis::FitsAnalysis(FitsFile* src) +{ + primary_ = src->primary(); + managePrimary_ = 0; + + head_ = new FitsHead(*(src->head())); + manageHead_ = 1; + + ext_ = src->ext(); + inherit_ = src->inherit(); + + // change bitpix to double + head_->setInteger("BITPIX", -64, ""); + + // unset BZERO/BSCALE if present + if (head_->find("BZERO")) + head_->setReal("BZERO",0,2,NULL); + + if (head_->find("BSCALE")) + head_->setReal("BSCALE",1,2,NULL); + + head_->updateHDU(); + + int width = head_->naxis(0); + int height = head_->naxis(1); + + // alloc memory + size_t size = (size_t)width*height; + data_ = new double[size]; + if (!data_) + return; + + dataSize_ = size; + dataSkip_ = 0; + + // clear memory + memset(data_, 0, size*sizeof(double)); + + // made it this far, must be valid + byteswap_ = 0; + endian_ = lsb() ? LITTLE : BIG; + valid_ = 1; +} + +FitsAnalysis::~FitsAnalysis() +{ + if (data_) + delete [] (char*)data_; +} + diff --git a/tksao/fitsy++/analysis.h b/tksao/fitsy++/analysis.h new file mode 100644 index 0000000..0c0d269 --- /dev/null +++ b/tksao/fitsy++/analysis.h @@ -0,0 +1,16 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsanalysis_h__ +#define __fitsanalysis_h__ + +#include "file.h" + +class FitsAnalysis : public FitsFile { +public: + FitsAnalysis(FitsFile*); + ~FitsAnalysis(); +}; + +#endif diff --git a/tksao/fitsy++/block.C b/tksao/fitsy++/block.C new file mode 100644 index 0000000..1712b2f --- /dev/null +++ b/tksao/fitsy++/block.C @@ -0,0 +1,269 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include +using namespace std; + +#include "block.h" + +FitsBlock::FitsBlock(FitsFile* fits, Vector& block) +{ + FitsHead* srcHead = fits->head(); + + width_ = srcHead->naxis(0)/block[0]; + height_ = srcHead->naxis(1)/block[1]; + if (width_<1) + width_ = 1; + if (height_<1) + height_ = 1; + size_ = (size_t)width_*height_; + + primary_ = fits->primary(); + ext_ = fits->ext(); + inherit_ = fits->inherit(); + + bitpix_ = srcHead->hdu()->bitpix(); + switch (bitpix_) { + case -64: + if (!(data_ = new double[size_])) + return; + dataSize_ = size_*sizeof(double); + break; + default: + bitpix_ = -32; + if (!(data_ = new float[size_])) + return; + dataSize_ = size_*sizeof(float); + break; + } + dataSkip_ = 0; + memset(data_, 0, dataSize_); + + initHeader(fits, block); + + // made it this far, must be valid + byteswap_ = 0; + endian_ = lsb() ? LITTLE : BIG; + valid_ = 1; +} + +FitsBlock::~FitsBlock() +{ + if (data_) + delete [] (char*)data_; +} + +void FitsBlock::initHeader(FitsFile* fits, Vector& block) +{ + head_ = new FitsHead(*(fits->head())); + + // change bitpix + switch (bitpix_) { + case -64: + head_->setInteger("BITPIX", -64, ""); + break; + default: + head_->setInteger("BITPIX", -32, ""); + break; + } + + // change width/height + head_->setInteger("NAXIS1", width_, ""); + head_->setInteger("NAXIS2", height_, ""); + + // IRAF + initLTMV(block); + initCCDSUM(block); + initKeySEC("BIASSEC",block); + initKeySEC("DATASEC",block); + initKeySEC("TRIMSEC",block); + + // WCS + initWCS(block); + + // clear cards + if (head_->find("BZERO")) + head_->carddel("BZERO"); + if (head_->find("BSCALE")) + head_->carddel("BSCALE"); + if (head_->find("DATASUM")) + head_->carddel("DATASUM"); + if (head_->find("CHECKSUM")) + head_->carddel("CHECKSUM"); + if (head_->find("DATAMIN")) + head_->carddel("DATAMIN"); + if (head_->find("DATAMAX")) + head_->carddel("DATAMAX"); + if (head_->find("DATAMEAN")) + head_->carddel("DATAMEAN"); + if (head_->find("GOODMIN")) + head_->carddel("GOODMIN"); + if (head_->find("GOODMAX")) + head_->carddel("GOODMAX"); + if (head_->find("IRAF-MIN")) + head_->carddel("IRAF-MIN"); + if (head_->find("IRAF-MAX")) + head_->carddel("IRAF-MAX"); + + head_->updateHDU(); +} + +void FitsBlock::initCCDSUM(Vector& block) +{ + if (head_->find("CCDSUM")) { + char* val = head_->getString("CCDSUM"); + float xx,yy; + istringstream istr(val); + istr >> xx >> yy; + + xx *= block[0]; + yy *= block[1]; + + ostringstream ostr; + ostr << xx << ' ' << yy << ends; + head_->setString("CCDSUM", ostr.str().c_str(), ""); + } +} + +void FitsBlock::initKeySEC(const char* key, Vector& block) +{ + if (head_->find(key)) { + char* sec = head_->getString(key); + Vector ll,ur; + parseSection(sec,&ll,&ur); + Matrix mm = Translate(-1,-1) * + Scale(1/block[0],1/block[1]) * + Translate(1,1); + + Vector nll = ll*mm; + Vector nur = ur*mm; + ostringstream ostr; + ostr << '[' << int(nll[0]) << ':' << int(nur[0]) + << ',' << int(nll[1]) << ':' << int(nur[1]) << ']' << ends; + head_->setString(key, ostr.str().c_str(), ""); + } +} + +void FitsBlock::initLTMV(Vector& block) +{ + // always do LTMV + double ltv1 = head_->getReal("LTV1", 0); + double ltv2 = head_->getReal("LTV2", 0); + double ltm11 = head_->getReal("LTM1_1", 1); + double ltm12 = head_->getReal("LTM1_2", 0); + double ltm21 = head_->getReal("LTM2_1", 0); + double ltm22 = head_->getReal("LTM2_2", 1); + + Matrix mm(ltm11,ltm12,ltm21,ltm22,ltv1,ltv2); + Matrix im = mm * + Translate(-.5,-.5) * + Scale(1./block[0],1./block[1]) * + Translate(.5,.5); + + if (head_->find("LTV1")) + head_->setReal("LTV1", im.matrix(2,0), 8, ""); + else + head_->appendReal("LTV1", im.matrix(2,0), 8, ""); + + if (head_->find("LTV2")) + head_->setReal("LTV2", im.matrix(2,1), 8, ""); + else + head_->appendReal("LTV2", im.matrix(2,1), 8, ""); + + if (head_->find("LTM1_1")) + head_->setReal("LTM1_1", ltm11/block[0], 8, ""); + else + head_->appendReal("LTM1_1", ltm11/block[0], 8, ""); + + if (head_->find("LTM1_2")) + head_->setReal("LTM1_2", ltm12, 8, ""); + else + head_->appendReal("LTM1_2", ltm12, 8, ""); + + if (head_->find("LTM2_1")) + head_->setReal("LTM2_1", ltm21, 8, ""); + else + head_->appendReal("LTM2_1", ltm21, 8, ""); + + if (head_->find("LTM2_2")) + head_->setReal("LTM2_2", ltm22/block[1], 8, ""); + else + head_->appendReal("LTM2_2", ltm22/block[1], 8, ""); +} + +void FitsBlock::initWCS(Vector& block) +{ + // check for WCS + if (!head_->find("CRPIX1") && !head_->find("CRPIX2")) + return; + + double crpix1 = head_->getReal("CRPIX1", 0); + double crpix2 = head_->getReal("CRPIX2", 0); + Matrix pp = Matrix(1,0,0,1,crpix1,crpix2) * + Translate(-.5,-.5) * + Scale(1/block[0],1/block[1]) * + Translate(.5,.5); + + if (head_->find("CRPIX1")) + head_->setReal("CRPIX1", pp.matrix(2,0), 8, ""); + else + head_->appendReal("CRPIX1", pp.matrix(2,0), 8, ""); + + if (head_->find("CRPIX2")) + head_->setReal("CRPIX2", pp.matrix(2,1), 8, ""); + else + head_->appendReal("CRPIX2", pp.matrix(2,1), 8, ""); + + // CD + if (head_->find("CD1_1") || head_->find("CD1_2") || + head_->find("CD2_1") || head_->find("CD2_2")) { + double cd11 = head_->getReal("CD1_1", 1); + double cd12 = head_->getReal("CD1_2", 0); + double cd21 = head_->getReal("CD2_1", 0); + double cd22 = head_->getReal("CD2_2", 1); + Matrix mm = Matrix(cd11,cd12,cd21,cd22,0,0) * + Scale(block[0],block[1]); + + if (head_->find("CD1_1")) + head_->setReal("CD1_1", mm.matrix(0,0), 8, ""); + else + head_->appendReal("CD1_1", mm.matrix(0,0), 8, ""); + + if (head_->find("CD1_2")) + head_->setReal("CD1_2", mm.matrix(0,1), 8, ""); + else + head_->appendReal("CD1_2", mm.matrix(0,1), 8, ""); + + if (head_->find("CD2_1")) + head_->setReal("CD2_1", mm.matrix(1,0), 8, ""); + else + head_->appendReal("CD2_1", mm.matrix(1,0), 8, ""); + + if (head_->find("CD2_2")) + head_->setReal("CD2_2", mm.matrix(1,1), 8, ""); + else + head_->appendReal("CD2_2", mm.matrix(1,1), 8, ""); + + } + // CDELT + else if (head_->find("CDELT1") || head_->find("CDELT2")) { + double cdelt1 = head_->getReal("CDELT1", 1); + double cdelt2 = head_->getReal("CDELT2", 0); + Matrix mm = Matrix(cdelt1,0,0,cdelt2,0,0) * + Scale(block[0],block[1]); + + if (head_->find("CDELT1")) + head_->setReal("CDELT1", mm.matrix(0,0), 8, ""); + else + head_->appendReal("CDELT1", mm.matrix(0,0), 8, ""); + + if (head_->find("CDELT2")) + head_->setReal("CDELT2", mm.matrix(1,1), 8, ""); + else + head_->appendReal("CDELT2", mm.matrix(1,1), 8, ""); + } +} + diff --git a/tksao/fitsy++/block.h b/tksao/fitsy++/block.h new file mode 100644 index 0000000..276c19a --- /dev/null +++ b/tksao/fitsy++/block.h @@ -0,0 +1,30 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsblock_h__ +#define __fitsblock_h__ + +#include "vector.h" +#include "file.h" + +class FitsBlock : public FitsFile { + protected: + int width_; + int height_; + size_t size_; + int bitpix_; + + void initHeader(FitsFile*, Vector&); + + void initCCDSUM(Vector&); + void initKeySEC(const char*, Vector&); + void initLTMV(Vector&); + void initWCS(Vector&); + + public: + FitsBlock(FitsFile*, Vector&); + ~FitsBlock(); +}; + +#endif diff --git a/tksao/fitsy++/card.C b/tksao/fitsy++/card.C new file mode 100644 index 0000000..2e6bb6e --- /dev/null +++ b/tksao/fitsy++/card.C @@ -0,0 +1,288 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "card.h" + +FitsCard::FitsCard() +{ + card_ = new char[FTY_CARDLEN]; + managed = 1; +} + +FitsCard::FitsCard(char* c) +{ + card_ = c; + managed = 0; +} + +FitsCard::FitsCard(const FitsCard& a) +{ + card_ = new char[FTY_CARDLEN]; + managed = 1; + memcpy(card_, a.card_, FTY_CARDLEN); +} + +FitsCard::~FitsCard() +{ + if (managed) + delete [] card_; +} + +FitsCard& FitsCard::operator=(const FitsCard& a) +{ + memcpy(card_, a.card_, FTY_CARDLEN); + return *this; +} + +FitsCard& FitsCard::clear() +{ + memset(card_, ' ', FTY_CARDLEN); + return *this; +} + +FitsCard& FitsCard::setKey(const char* name) +{ + if (name) { + memset(card_, ' ', 8); + ostringstream str; + str << name; + memcpy(card_,str.str().c_str(),str.str().length()); + } + + return *this; +} + +FitsCard& FitsCard::setLogical(const char* name, int value, + const char* comment) +{ + setKey(name); + memset(card_+8, ' ', FTY_CARDLEN-8); + + ostringstream str; + str << "= " << (value ? 'T' : 'F'); + if (comment) + str << " / " << comment; + memcpy(card_+8,str.str().c_str(),str.str().length()); + + return *this; +} + +FitsCard& FitsCard::setInteger(const char* name, int value, + const char* comment) +{ + setKey(name); + memset(card_+8, ' ', FTY_CARDLEN-8); + + ostringstream str; + str << "= " << setw(20) << value; + if (comment) + str << " / " << comment; + memcpy(card_+8,str.str().c_str(),str.str().length()); + + return *this; +} + +FitsCard& FitsCard::setReal(const char* name, double value, + int prec, const char* comment) +{ + setKey(name); + memset(card_+8, ' ', FTY_CARDLEN-8); + + ostringstream str; + str << "= " << setw(20) << setprecision(prec) << value; + if (comment) + str << " / " << comment; + memcpy(card_+8,str.str().c_str(),str.str().length()); + + return *this; +} + +FitsCard& FitsCard::setComplex(const char* name, double real, double img, + int prec, const char* comment) +{ + setKey(name); + memset(card_+8, ' ', FTY_CARDLEN-8); + + ostringstream str; + str << "= " << setw(20) << setprecision(prec) << real << img; + if (comment) + str << " / " << comment; + memcpy(card_+8,str.str().c_str(),str.str().length()); + + return *this; +} + +FitsCard& FitsCard::setString(const char* name, const char* value, + const char* comment) +{ + setKey(name); + memset(card_+8, ' ', FTY_CARDLEN-8); + + ostringstream str; + str << "= '" << value << '\''; + if (comment) + str << " / " << comment; + memcpy(card_+8,str.str().c_str(),str.str().length()); + + return *this; +} + +FitsCard& FitsCard::setComment(const char* name, const char* value) +{ + setKey(name); + memset(card_+8, ' ', FTY_CARDLEN-8); + + ostringstream str; + str << "= " << value; + memcpy(card_+8,str.str().c_str(),str.str().length()); + + return *this; +} + +int FitsCard::getLogical() +{ + for (int i=10; i<80; i++) + if (card_[i] != ' ') + return (card_[i] == 'T' || card_[i] == 't'); + + return 0; +} + +int FitsCard::getInteger() +{ + string x(card_+10,FTY_CARDLEN-10); + istringstream str(x); + int r; + str >> r; + return r; +} + +double FitsCard::getReal() +{ + // support 'D' as well as 'E' format + char buf[FTY_CARDLEN-10+1]; + memcpy(buf, card_+10, FTY_CARDLEN-10); + buf[FTY_CARDLEN-10] = '\0'; + + char* ptr = buf; + while (*ptr && *ptr != '/') { + if (*ptr == 'D' || *ptr == 'E') { + *ptr = 'E'; + break; + } + ptr++; + } + + string x(buf,FTY_CARDLEN-10); + istringstream str(x); + double r; + str >> r; + return r; +} + +void FitsCard::getComplex(double* r, double* i) +{ + // support 'D' as well as 'E' format + char buf[FTY_CARDLEN-10+1]; + memcpy(buf, card_+10, FTY_CARDLEN-10); + buf[FTY_CARDLEN-10] = '\0'; + + char* ptr = buf; + while (*ptr && *ptr != '/') { + if (*ptr == 'D' || *ptr == 'E') { + *ptr = 'E'; + } + ptr++; + } + + string x(buf,FTY_CARDLEN-10); + istringstream str(x); + str >> *r >> *i; +} + +char* FitsCard::getString() +{ + char value[FTY_CARDLEN]; + value[0] = '\0'; + value[FTY_CARDLEN-1] = '\0'; + + int i,j; + + // find first ' + for (i=10; i + +#include +#include +#include +using namespace std; + +class FitsCard { +private: + char* card_; + int managed; + +public: + FitsCard(); + FitsCard(char*); + FitsCard(const FitsCard&); + ~FitsCard(); + FitsCard& operator=(const FitsCard&); + + char* card() {return card_;} + + FitsCard& clear(); + + FitsCard& setKey(const char *name); + + FitsCard& setLogical(const char* name, int value, const char* comment); + FitsCard& setLogical(int value, const char *comment) + {return setLogical(NULL, value, comment);} + + FitsCard& setInteger(const char* name, int value, const char *comment); + FitsCard& setInteger(int value, const char *comment) + {return setInteger(NULL, value, comment);} + + FitsCard& setReal(const char* name, double value, int prec, const char *comment); + FitsCard& setReal(double value, int prec, const char *comment) + {return setReal(NULL, value, prec, comment);} + + FitsCard& setComplex(const char* name, double real, double img, + int prec, const char *comment); + FitsCard& setComplex(double real, double img, int prec, const char *comment) + {return setComplex(NULL, real, img, prec, comment);} + + FitsCard& setString(const char* name, const char *value, const char *comm); + FitsCard& setString(const char *value, const char *comment) + {return setString(NULL, value, comment);} + + FitsCard& setComment(const char* name, const char* value); + FitsCard& setComment(const char *value) + {return setComment(NULL, value);} + + int getLogical(); + int getInteger(); + double getReal(); + void getComplex(double*, double*); + char* getString(); + char* getComment(); + char* getAsString(); +}; + +#endif diff --git a/tksao/fitsy++/channel.C b/tksao/fitsy++/channel.C new file mode 100644 index 0000000..8d0b8da --- /dev/null +++ b/tksao/fitsy++/channel.C @@ -0,0 +1,21 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "channel.h" + +FitsChannel::FitsChannel(Tcl_Interp* interp, const char* ch, const char* ext) +{ + parse(ext); + if (!valid_) + return; + + int tclMode; + stream_ = Tcl_GetChannel(interp, (char*)ch, &tclMode); + + valid_ = stream_ ? 1 : 0; +} + + diff --git a/tksao/fitsy++/channel.h b/tksao/fitsy++/channel.h new file mode 100644 index 0000000..a5baaf3 --- /dev/null +++ b/tksao/fitsy++/channel.h @@ -0,0 +1,55 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitschannel_h__ +#define __fitschannel_h__ + +#include "strm.h" + +class FitsChannel : public virtual FitsStream { +public: + FitsChannel(Tcl_Interp*, const char*, const char*); +}; + +class FitsFitsChannel : public FitsChannel, public FitsFitsStream{ +public: + FitsFitsChannel(Tcl_Interp* interp, const char* ch, + const char* ext, ScanMode mode, FlushMode flush) + : FitsChannel(interp, ch, ext), FitsFitsStream(mode, flush) {} +}; + +class FitsFitsNextChannel : public FitsFitsNextStream { +public: + FitsFitsNextChannel(FitsFile* prev) + : FitsFitsNextStream(prev) {} +}; + +class FitsArrChannel : public FitsChannel, FitsArrStream { +public: + FitsArrChannel(Tcl_Interp* interp, const char* ch, const char* ext, + FlushMode flush) + : FitsChannel(interp, ch, ext), FitsArrStream(flush) {} +}; + +class FitsNRRDChannel : public FitsChannel, FitsNRRDStream { +public: + FitsNRRDChannel(Tcl_Interp* interp, const char* ch, const char* ext, + FlushMode flush) + : FitsChannel(interp, ch, ext), FitsNRRDStream(flush) {} +}; + +class FitsMosaicChannel : public FitsChannel, FitsMosaicStream { +public: + FitsMosaicChannel(Tcl_Interp* interp, const char* ch, FlushMode flush) + : FitsChannel(interp, ch, ""), FitsMosaicStream(flush) {} +}; + +class FitsMosaicNextChannel : public FitsMosaicNextStream { +public: + FitsMosaicNextChannel(FitsFile* prev, FlushMode flush) + : FitsMosaicNextStream(prev, flush) {} +}; + +#endif + diff --git a/tksao/fitsy++/column.C b/tksao/fitsy++/column.C new file mode 100644 index 0000000..0c788c0 --- /dev/null +++ b/tksao/fitsy++/column.C @@ -0,0 +1,649 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include +#include +#include + +#include +#include +#include +using namespace std; + +#include "column.h" +#include "file.h" +#include "head.h" + +FitsColumn::FitsColumn(FitsHead* head, int i, int off) +{ + index_ = i; + width_ = 0; + offset_ = off; + type_ = ' '; + + tform_ = head->getString(keycat("TFORM",i)); + ttype_ = head->getString(keycat("TTYPE",i)); + tunit_ = head->getString(keycat("TUNIT",i)); + tscal_ = head->getReal(keycat("TSCAL",i), 1); + tzero_ = head->getReal(keycat("TZERO",i), 0); + hastnull_ = head->find(keycat("TNULL",i)) ? 1:0; + tnull_ = head->getInteger(keycat("TNULL",i), 0); + + char* td = head->find(keycat("TDMAX",i)); + char* tl = head->find(keycat("TLMAX",i)); + char* ta = head->find(keycat("TALEN",i)); + char* ax = head->find(keycat("AXLEN",i)); + + // this provides backward compatibility + if (td) { + hastlmin_ = head->find(keycat("TDMIN",i)) ? 1:0; + hastlmax_ = 1; + tlmin_ = head->getReal(keycat("TDMIN",i), 0); + tlmax_ = head->getReal(keycat("TDMAX",i), 0); + } + else if (tl) { + hastlmin_ = head->find(keycat("TLMIN",i)) ? 1:0; + hastlmax_ = 1; + tlmin_ = head->getReal(keycat("TLMIN",i), 0); + tlmax_ = head->getReal(keycat("TLMAX",i), 0); + } + else if (ta) { + hastlmin_ = 0; + hastlmax_ = 1; + tlmin_ = 1; + tlmax_ = head->getReal(keycat("TALEN",i), 0); + } + else if (ax) { + hastlmin_ = 0; + hastlmax_ = 1; + tlmin_ = 1; + tlmax_ = head->getReal(keycat("AXLEN",i), 0); + } + else { + hastlmin_ = 0; + hastlmax_ = 0; + tlmin_ = 0; + tlmax_ = 0; + } + + // now, make sure they are valid + if (tlmin_>tlmax_) { + hastlmin_ = 0; + hastlmax_ = 0; + tlmin_ = 0; + tlmax_ = 0; + } + + // use tlmin/tlmax if available + if (hastlmin_ || hastlmax_) { + min_ = tlmin_; + max_ = tlmax_; + } + else { + min_ = -DBL_MAX; + max_ = DBL_MAX; + } +} + +FitsColumn::~FitsColumn() +{ + if (tform_) + delete [] tform_; + if (tunit_) + delete [] tunit_; + if (ttype_) + delete [] ttype_; +} + +char* FitsColumn::keycat(const char* name, int i) +{ + ostringstream str; + str << name << i << ends; + memcpy(keybuf,str.str().c_str(),str.str().length()); + return keybuf; +} + +// FitsAsciiColumn + +FitsAsciiColumn::FitsAsciiColumn(FitsHead* head, int i, int offset) + : FitsColumn(head, i, offset) +{ + int tbcol = head->getInteger(keycat("TBCOL",i),0); + if (tbcol) + offset_ = tbcol-1; +} + +char* FitsAsciiColumn::str(const char* ptr, int i) +{ + strncpy(buf_, ptr+offset_, width_); + buf_[width_] = '\0'; + return buf_; +} + +FitsAsciiColumnStr::FitsAsciiColumnStr(FitsHead* head, int i, int offset) + : FitsAsciiColumn(head, i, offset) +{ + if (tform_) { + string x(tform_); + istringstream str(x); + str >> type_ >> width_; + } +} + +FitsAsciiColumnA::FitsAsciiColumnA(FitsHead* head, int i, int offset) + : FitsAsciiColumn(head, i, offset) +{ + prec_ = 0; + + if (tform_) { + char s; + string x(tform_); + istringstream str(x); + str >> type_ >> width_ >> s >> prec_; + } +} + +double FitsAsciiColumnA::value(const char* ptr, int i) +{ + string x(ptr+offset_); + istringstream str(x); + double r; + str >> r; + + return r; +} + +template FitsAsciiColumnT::FitsAsciiColumnT(FitsHead* head, + int i, int off) + : FitsAsciiColumnA(head, i, off) {} + +template <> Vector FitsAsciiColumnT::dimension() +{ + return (hastlmin_ || hastlmax_) ? Vector(tlmin_,tlmax_) + : Vector(INT_MIN,INT_MAX); +} + +template <> Vector FitsAsciiColumnT::dimension() +{ + return (hastlmin_ || hastlmax_) ? Vector(tlmin_,tlmax_) + : Vector(-FLT_MAX,FLT_MAX); +} + +template <> Vector FitsAsciiColumnT::dimension() +{ + return (hastlmin_ || hastlmax_) ? Vector(tlmin_,tlmax_) + : Vector(-DBL_MAX,DBL_MAX); +} + +// FitsBinColumn + +FitsBinColumn::FitsBinColumn(FitsHead* head, int i, int offset) + : FitsColumn(head, i, offset) +{ + tdisp_ = head->getString(keycat("TDISP",i)); + + repeat_ = 1; + if (tform_) { + string x(tform_); + istringstream str(x); + if (isalpha(tform_[0])) + str >> type_; + else + str >> repeat_ >> type_; + } +} + +FitsBinColumn::~FitsBinColumn() +{ + if (tdisp_) + delete [] tdisp_; +} + +// FitsBinColumnStr + +FitsBinColumnStr::FitsBinColumnStr(FitsHead* head, int i, int offset) + : FitsBinColumn(head, i, offset) +{ + width_ = repeat_; +} + +char* FitsBinColumnStr::str(const char* ptr, int i) +{ + strncpy(buf_, ptr+offset_, width_); + buf_[width_] = '\0'; + return buf_; +} + +// FitsBinColumnLogical + +FitsBinColumnLogical::FitsBinColumnLogical(FitsHead* head, int i, int offset) + : FitsBinColumn(head, i, offset) +{ + width_ = repeat_; +} + +char* FitsBinColumnLogical::str(const char* ptr, int i) +{ + strncpy(buf_, ptr+offset_+i, 1); + buf_[width_] = '\0'; + return buf_; +} + +// FitsBinColumnArray + +FitsBinColumnArray::FitsBinColumnArray(FitsHead* head, int i, int offset) + : FitsBinColumn(head, i, offset) +{ + ptype_ = ' '; + psize_ = 1; + pmax_ = 1; + abuf_ = NULL; + + byteswap_ = lsb(); + + if (tform_) { + int rr; + char tt; + string x(tform_); + istringstream str(x); + if (isalpha(tform_[0])) + str >> tt; + else + str >> rr >> tt; + + char s; + str >> ptype_ >> s >> pmax_ >> s; + + switch (ptype_) { + case 'L': + psize_ = 1; + break; + case 'X': + psize_ = 1; + break; + case 'B': + psize_ = 1; + break; + case 'I': + psize_ = 2; + break; + case 'J': + psize_ = 4; + break; + case 'K': + psize_ = 8; + break; + case 'A': + psize_ = 1; + break; + case 'E': + psize_ = 4; + break; + case 'D': + psize_ = 8; + break; + case 'C': + psize_ = 8; + break; + case 'M': + psize_ = 16; + break; + + default: + internalError("Fitsy++ column unknown table column type."); + return; + } + + // sanity check + pmax_ *= psize_; + + if (pmax_ > 0) + abuf_ = new char[pmax_]; + } +} + +FitsBinColumnArray::~FitsBinColumnArray() +{ + if (abuf_) + delete [] abuf_; +} + +void* FitsBinColumnArray::get(const char* heap, const char* ptr, int* cnt) +{ + *cnt = swap(ptr,0); + if (*cnt > pmax_) { + // just in case + internalError("Fitsy++ column variable array size greater than specified"); + *cnt = pmax_; + } + size_t pp = swap(ptr,1); + + if (abuf_) { + memset(abuf_,pmax_,0); + memcpy(abuf_,heap+pp,(*cnt)*psize_); + } + + return abuf_; +} + +FitsBinColumnArrayP::FitsBinColumnArrayP(FitsHead* head, int i, int offset) + : FitsBinColumnArray(head, i, offset) +{ + width_ = 8; +} + +int FitsBinColumnArrayP::swap(const char* ptr, int i) +{ + const char* p = ptr+offset_+i*4; + union { + char c[4]; + int i; + } u; + + if (byteswap_) { + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + } + else + memcpy(u.c,p,4); + + return u.i; +} + +FitsBinColumnArrayQ::FitsBinColumnArrayQ(FitsHead* head, int i, int offset) + : FitsBinColumnArray(head, i, offset) +{ + width_ = 16; +} + +int FitsBinColumnArrayQ::swap(const char* ptr, int i) +{ + const char* p = ptr+offset_+i*8; + union { + char c[8]; + long l; + } u; + + if (byteswap_) { + u.c[7] = *p++; + u.c[6] = *p++; + u.c[5] = *p++; + u.c[4] = *p++; + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + } + else + memcpy(u.c,p,8); + + return u.l; +} + +// FitsbinColumnBit + +FitsBinColumnBit::FitsBinColumnBit(FitsHead* head, int i, int off) + : FitsBinColumn(head, i, off) +{ + width_ = (repeat_+7)/8; +} + +// FitsBinColumnB + +FitsBinColumnB::FitsBinColumnB(FitsHead* head, int i, int offset) + : FitsBinColumn(head, i, offset) +{ + byteswap_ = lsb(); +} + +// FitsBinColumnT + +template FitsBinColumnT::FitsBinColumnT(FitsHead* head, + int i, int off) + : FitsBinColumnB(head, i, off) +{ + width_ = repeat_ * sizeof(T); +} + +template <> double FitsBinColumnT::value(const char* ptr, int i) +{ + return (unsigned char)(*(ptr+offset_+i)); +} + +template <> double FitsBinColumnT::value(const char* ptr, int i) +{ + const char* p = ptr+offset_+i*2; + union { + char c[2]; + short s; + } u; + + if (byteswap_) { + u.c[1] = *p++; + u.c[0] = *p; + } + else { + u.c[0] = *p++; + u.c[1] = *p; + } + + return u.s; +} + +template <> double FitsBinColumnT::value(const char* ptr, int i) +{ + const char* p = ptr+offset_+i*2; + union { + char c[2]; + unsigned short s; + } u; + + if (byteswap_) { + u.c[1] = *p++; + u.c[0] = *p; + } + else { + u.c[0] = *p++; + u.c[1] = *p; + } + + return u.s; +} + +template <> double FitsBinColumnT::value(const char* ptr, int i) +{ + const char* p = ptr+offset_+i*4; + union { + char c[4]; + int i; + } u; + + if (byteswap_) { + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + } + else + memcpy(u.c,p,4); + + return u.i; +} + +template <> double FitsBinColumnT::value(const char* ptr, int i) +{ + const char* p = ptr+offset_+i*4; + union { + char c[4]; + unsigned int i; + } u; + + if (byteswap_) { + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + } + else + memcpy(u.c,p,4); + + return u.i; +} + +template <> double FitsBinColumnT::value(const char* ptr, int i) +{ + const char* p = ptr+offset_+i*8; + union { + char c[8]; + long long i; + } u; + + if (byteswap_) { + u.c[7] = *p++; + u.c[6] = *p++; + u.c[5] = *p++; + u.c[4] = *p++; + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + } + else + memcpy(u.c,p,8); + + return u.i; +} + +template <> double FitsBinColumnT::value(const char* ptr, int i) +{ + const char* p = ptr+offset_+i*4; + union { + char c[4]; + float f; + } u; + + if (byteswap_) { + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + } + else + memcpy(u.c,p,4); + + return u.f; +} + +template <> double FitsBinColumnT::value(const char* ptr, int i) +{ + const char* p = ptr+offset_+i*8; + union { + char c[8]; + double d; + } u; + + if (byteswap_) { + u.c[7] = *p++; + u.c[6] = *p++; + u.c[5] = *p++; + u.c[4] = *p++; + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + } + else + memcpy(u.c,p,8); + + return u.d; +} + +template char* FitsBinColumnT::str(const char* ptr, int i) +{ + ostringstream ost; + ost << value(ptr,i) << ends; + return (char*)dupstr(ost.str().c_str()); +} + +template <> Vector FitsBinColumnT::dimension() +{ + return (hastlmin_ || hastlmax_) ? Vector(tlmin_-.5,tlmax_+.5) + : Vector(0,UCHAR_MAX); +} + +template <> Vector FitsBinColumnT::dimension() +{ + return (hastlmin_ || hastlmax_) ? Vector(tlmin_-.5,tlmax_+.5) + : Vector(SHRT_MIN,SHRT_MAX); +} + +template <> Vector FitsBinColumnT::dimension() +{ + return (hastlmin_ || hastlmax_) ? Vector(tlmin_-.5,tlmax_+.5) + : Vector(0,USHRT_MAX); +} + +template <> Vector FitsBinColumnT::dimension() +{ + return (hastlmin_ || hastlmax_) ? Vector(tlmin_-.5,tlmax_+.5) + : Vector(INT_MIN,INT_MAX); +} + +template <> Vector FitsBinColumnT::dimension() +{ + return (hastlmin_ || hastlmax_) ? Vector(tlmin_-.5,tlmax_+.5) + : Vector(0,UINT_MAX); +} + +// some older versions of gcc do not have LLONG +#ifndef LLONG_MIN +# ifdef LONG_LONG_MIN +# define LLONG_MIN LONG_LONG_MIN +# else +# define LLONG_MIN LONG_MIN +# endif +#endif + +#ifndef LLONG_MAX +# ifdef LONG_LONG_MAX +# define LLONG_MAX LONG_LONG_MAX +# else +# define LLONG_MAX LONG_MAX +# endif +#endif + +template <> Vector FitsBinColumnT::dimension() +{ + return (hastlmin_ || hastlmax_) ? Vector(tlmin_-.5,tlmax_+.5) + : Vector(LLONG_MIN,LLONG_MAX); +} + +template <> Vector FitsBinColumnT::dimension() +{ + return (hastlmin_ || hastlmax_) ? Vector(tlmin_,tlmax_) + : Vector(-FLT_MAX,FLT_MAX); +} + +template <> Vector FitsBinColumnT::dimension() +{ + return (hastlmin_ || hastlmax_) ? Vector(tlmin_,tlmax_) + : Vector(-DBL_MAX,DBL_MAX); +} + +template class FitsAsciiColumnT; +template class FitsAsciiColumnT; +template class FitsAsciiColumnT; + +template class FitsBinColumnT; +template class FitsBinColumnT; +template class FitsBinColumnT; +template class FitsBinColumnT; +template class FitsBinColumnT; +template class FitsBinColumnT; +template class FitsBinColumnT; +template class FitsBinColumnT; diff --git a/tksao/fitsy++/column.h b/tksao/fitsy++/column.h new file mode 100644 index 0000000..bf9a984 --- /dev/null +++ b/tksao/fitsy++/column.h @@ -0,0 +1,198 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitscolumn_h__ +#define __fitscolumn_h__ + +#include "vector.h" + +class FitsHead; + +class FitsColumn { +protected: + int index_; // col number 1 to n + int width_; // overall width of field in chars + int offset_; // offset in chars from start of row + char type_; // type + + char* tform_; + char* ttype_; + char* tunit_; + float tscal_; + float tzero_; + + int tnull_; + int hastnull_; + + float tlmin_; + float tlmax_; + int hastlmin_; + int hastlmax_; + + double min_; + double max_; + int validmm_; + + char buf_[128]; + + char keybuf[9]; + char* keycat(const char*, int); + +public: + FitsColumn(FitsHead*, int, int); + virtual ~FitsColumn(); + + int width() {return width_;} + int offset() {return offset_;} + int index() {return index_;} + + const char* tform() {return tform_;} + const char* ttype() {return ttype_;} + const char* tunit() {return tunit_;} + float tscal() {return tscal_;} + float tzero() {return tzero_;} + int tnull() {return tnull_;} + float tlmin() {return tlmin_;} + float tlmax() {return tlmax_;} + + int hasscaling() {return tscal_ != 1 || tzero_ != 0;} + int hastnull() {return hastnull_;} + + virtual double value(const char* ptr, int i =0) {return 0;} + virtual char* str(const char* ptr, int i =0) {return NULL;} + virtual Vector dimension() {return Vector();} + virtual int repeat() {return 1;} + + void setMin(double m) {min_=m;} + void setMax(double m) {max_=m;} + + double getMin() {return min_;} + double getMax() {return max_;} + + int hasMinMax() {return min_ != -DBL_MAX ? 1 : 0;} + int hasTLMinTLMax() {return hastlmin_ && hastlmax_;} +}; + +// FitsAsciiColumn + +class FitsAsciiColumn : public FitsColumn { +public: + FitsAsciiColumn(FitsHead*, int, int); + + char* str(const char* ptr, int i =0); +}; + +class FitsAsciiColumnStr : public FitsAsciiColumn { +public: + FitsAsciiColumnStr(FitsHead*, int, int); +}; + +class FitsAsciiColumnA : public FitsAsciiColumn { +private: + int prec_; + +public: + FitsAsciiColumnA(FitsHead*, int, int); + + double value(const char*, int i =0); +}; + +template +class FitsAsciiColumnT : public FitsAsciiColumnA { +public: + FitsAsciiColumnT(FitsHead*, int, int); + + Vector dimension(); +}; + +// FitsBinColumn + +class FitsBinColumn : public FitsColumn { +protected: + char* tdisp_; + int repeat_; // repeat count + +public: + FitsBinColumn(FitsHead*, int, int); + ~FitsBinColumn(); + + int repeat() {return repeat_;} +}; + +class FitsBinColumnStr : public FitsBinColumn { +public: + FitsBinColumnStr(FitsHead*, int, int); + + char* str(const char* ptr, int i =0); +}; + +class FitsBinColumnLogical : public FitsBinColumn { +public: + FitsBinColumnLogical(FitsHead*, int, int); + + double value(const char* ptr, int i =0) + {return (*(ptr+offset_+i) == 'T') ? 1 : 0;} + char* str(const char* ptr, int i =0); +}; + +class FitsBinColumnArray : public FitsBinColumn { + protected: + int byteswap_; + char ptype_; + int psize_; + int pmax_; + char* abuf_; + + virtual int swap(const char* ptr, int i =0) =0; + +public: + FitsBinColumnArray(FitsHead*, int, int); + virtual ~FitsBinColumnArray(); + + virtual void* get(const char* heap, const char* ptr, int* cnt); +}; + +class FitsBinColumnArrayP : public FitsBinColumnArray { + protected: + int swap(const char* ptr, int i =0); + +public: + FitsBinColumnArrayP(FitsHead*, int, int); +}; + +class FitsBinColumnArrayQ : public FitsBinColumnArray { + protected: + int swap(const char* ptr, int i =0); + +public: + FitsBinColumnArrayQ(FitsHead*, int, int); +}; + +class FitsBinColumnBit : public FitsBinColumn { +public: + FitsBinColumnBit(FitsHead*, int, int); +}; + +class FitsBinColumnB : public FitsBinColumn { +protected: + int byteswap_; + +public: + FitsBinColumnB(FitsHead*, int, int); +}; + +template +class FitsBinColumnT : public FitsBinColumnB { +private: + T swap(T*); + +public: + FitsBinColumnT(FitsHead*, int, int); + + double value(const char*, int i =0); + char* str(const char* ptr, int i =0); + Vector dimension(); +}; + +#endif diff --git a/tksao/fitsy++/compress.C b/tksao/fitsy++/compress.C new file mode 100644 index 0000000..09c602d --- /dev/null +++ b/tksao/fitsy++/compress.C @@ -0,0 +1,875 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "compress.h" +#include "head.h" +#include "zlib.h" +#include "util.h" + +FitsCompress::FitsCompress(FitsFile* fits) +{ + bitpix_ = fits->getInteger("ZBITPIX",0); + type_ = fits->getString("ZCMPTYPE"); + // int naxes = fits->getInteger("ZNAXIS",0); + width_ = fits->getInteger("ZNAXIS1",0); + height_ = fits->getInteger("ZNAXIS2",0); + depth_ = fits->getInteger("ZNAXIS3",1); + ww_ = fits->getInteger("ZTILE1",width_); + hh_ = fits->getInteger("ZTILE2",1); + dd_ = fits->getInteger("ZTILE3",1); + bscale_ = fits->getReal("ZSCALE",1); + bzero_ = fits->getReal("ZZERO",0); + blank_ = fits->getInteger("ZBLANK",0); + zmaskcmp_ = fits->getString("ZMASKCMP"); + + quantize_ = NODITHER; + char keyword[] = "ZQUANTIZ"; + if (fits->find(keyword)) { + char* which = fits->getString(keyword); + if (!strncmp(which,"NONE",4)) + quantize_ = NODITHER; + else if (!strncmp(which,"SUBTRACTIVE_DITHER_1",20)) + quantize_ = SUBDITHER1; + else if (!strncmp(which,"SUBTRACTIVE_DITHER_2",20)) + quantize_ = SUBDITHER2; + delete [] which; + } + quantOffset_ = fits->getInteger("ZDITHER0",1); + + tilesize_ = (size_t)ww_*hh_*dd_; + size_ = (size_t)width_*height_*depth_; + + FitsHead* srcHead = fits->head(); + FitsTableHDU* srcHDU = (FitsTableHDU*)(srcHead->hdu()); + uncompress_ = srcHDU->find("UNCOMPRESSED_DATA"); + gzcompress_ = srcHDU->find("GZIP_COMPRESSED_DATA"); + compress_ = srcHDU->find("COMPRESSED_DATA"); + zscale_ = srcHDU->find("ZSCALE"); + zzero_ = srcHDU->find("ZZERO"); + zblank_ = srcHDU->find("ZBLANK"); + null_ = srcHDU->find("NULL_PIXEL_MASK"); + + hasScaling_ = (zscale_ && zzero_) || (fits->find("ZSCALE") && fits->find("ZZERO")) ? 1 : 0; + hasBlank_ = zblank_ || fits->find("ZBLANK") ? 1 : 0; + + // Random seq + double aa =16807; + double mm =2147483647; + double seed =1; + numRandom_ =10000; + random_ = new float[numRandom_]; + + for (int ii=0; iihead(); + // FitsTableHDU* srcHDU = (FitsTableHDU*)(srcHead->hdu()); + + if (srcHead->find("ZTENSION")) { + char* str = srcHead->getString("ZTENSION"); + head_ = new FitsHead(width_, height_, depth_, bitpix_, str); + delete [] str; + } + else + head_ = new FitsHead(width_, height_, depth_, bitpix_); + + if (!head_->isValid()) + return 0; + + char* ptr = srcHead->cards(); + for (int ii=0; iincard(); ii++, ptr+=80) { + char key[9]; + key[8] = '\0'; + memcpy(key,ptr,8); + if (!strncmp(key,"ZIMAGE",6) || + !strncmp(key,"ZCMPTYPE",8) || + !strncmp(key,"ZBITPIX",7) || + !strncmp(key,"ZNAXIS",6) || + !strncmp(key,"ZTILE",5) || + !strncmp(key,"ZNAME",5) || + !strncmp(key,"ZVAL",4) || + !strncmp(key,"ZMASKCMP",8) || + + !strncmp(key,"ZSIMPLE",7) || + !strncmp(key,"ZTENSION",8) || + !strncmp(key,"ZEXTEND",7) || + + !strncmp(key,"SIMPLE",6) || + !strncmp(key,"BITPIX",6) || + !strncmp(key,"NAXIS",5) || + !strncmp(key,"END",3) || + !strncmp(key,"XTENSION",8) || + !strncmp(key,"PCOUNT",6) || + !strncmp(key,"GCOUNT",6) || + !strncmp(key,"EXTEND",6) || + + !strncmp(key,"CHECKSUM",8) || + !strncmp(key,"DATASUM",7) || + + !strncmp(key,"TFIELDS",7) || + !strncmp(key,"TBCOL",5) || + !strncmp(key,"TFORM",5) || + !strncmp(key,"TSCAL",5) || + !strncmp(key,"TZERO",5) || + !strncmp(key,"TNULL",5) || + !strncmp(key,"TTYPE",5) || + !strncmp(key,"TUNIT",5) || + !strncmp(key,"TDISP",5) || + !strncmp(key,"THEAP",5) || + !strncmp(key,"TDIM",4)) + continue; + + // eat this one + if (!strncmp(key,"EXTNAME",7)) { + FitsCard cc(ptr); + char* str = cc.getString(); + if (str) { + if (!strncmp(str,"COMPRESSED_IMAGE",8)) { + delete [] str; + continue; + } + delete [] str; + } + } + + // substitute these + + if (!strncmp(key,"ZBLOCK",6)) { + FitsCard cc(ptr); + head_->appendInteger("BLOCK",cc.getInteger(),NULL); + continue; + } + if (!strncmp(key,"ZPCOUNT",7)) { + FitsCard cc(ptr); + head_->appendInteger("PCOUNT",cc.getInteger(),NULL); + continue; + } + if (!strncmp(key,"ZGCOUNT",7)) { + FitsCard cc(ptr); + head_->appendInteger("GCOUNT",cc.getInteger(),NULL); + continue; + } + if (!strncmp(key,"ZHECKSUM",8)) { + FitsCard cc(ptr); + char* str = cc.getString(); + if (str) { + head_->appendString("CHECKSUM",str,NULL); + delete [] str; + continue; + } + } + if (!strncmp(key,"ZDATASUM",8)) { + FitsCard cc(ptr); + char* str = cc.getString(); + if (str) { + head_->appendString("DATASUM",str,NULL); + delete [] str; + continue; + } + } + + // pass these unaltered + head_->cardins(ptr,NULL); + } + + // we added cards + head_->updateHDU(); + + // other + primary_ = fits->primary(); + managePrimary_ = 0; + + inherit_ = head_->inherit(); + + return 1; +} + +void FitsCompress::initRandom(int row) +{ + row++; + int rrow = row + quantOffset_-1; + randSeed_ = (int)((rrow-1) % numRandom_); + randNext_ = (int)(random_[randSeed_]*500); +} + +double FitsCompress::unquantize(double val, double zs, double zz) +{ + double rr = (val-random_[randNext_]+.5)*zs + zz; + + randNext_++; + if (randNext_ == numRandom_) { + randSeed_++; + if (randSeed_ == numRandom_) + randSeed_ = 0; + randNext_ = (int)(random_[randSeed_]*500); + } + + return rr; +} + +#define ZERO_VALUE -2147483646 /* value used to represent zero-valued pixels */ +double FitsCompress::unquantizeZero(double val, double zs, double zz) +{ + double rr = (val == ZERO_VALUE) ? 0 : (val-random_[randNext_]+.5)*zs + zz; + + randNext_++; + if (randNext_ == numRandom_) { + randSeed_++; + if (randSeed_ == numRandom_) + randSeed_ = 0; + randNext_ = (int)(random_[randSeed_]*500); + } + + return rr; +} + +template FitsCompressm::FitsCompressm(FitsFile* fits) + : FitsCompress(fits) {} + +template void FitsCompressm::uncompress(FitsFile* fits) +{ + if (!initHeader(fits)) + return; + + if (!inflate(fits)) + return; + + swapBytes(); + + // all done + valid_ = 1; +} + +template int FitsCompressm::inflate(FitsFile* fits) +{ + FitsHead* srcHead = fits->head(); + FitsTableHDU* srcHDU = (FitsTableHDU*)(srcHead->hdu()); + + if (null_) { + internalError("Fitsy++ does not support NULL_PIXEL_MASK at this time."); + return 0; + } + + T* dest = new T[size_]; + if (!dest) { + internalError("Fitsy++ compress unable to allocate memory"); + return 0; + } + + // init image + memset(dest, 0, size_*sizeof(T)); + + // src + char* sdata = (char*)fits->data(); + char* sptr = sdata; + int heap = srcHDU->realbytes(); + int rowlen = srcHDU->width(); + int rows = srcHDU->rows(); + + // dest + int iistart =0; + int iistop =ww_; + if (iistop > width_) + iistop = width_; + + int jjstart =0; + int jjstop =hh_; + if (jjstop > height_) + jjstop = height_; + + int kkstart =0; + int kkstop =dd_; + if (kkstop > depth_) + kkstop = depth_; + + for (int rr=0; rrpage(sptr, rowlen); + + int ok=0; + if (gzcompress_ && !ok) { + if (gzcompressed(dest, sptr, sdata+heap, + kkstart, kkstop, jjstart, jjstop, iistart, iistop)) { + if (DebugCompress) + cerr << 'z'; + ok=1; + } + } + + if (compress_ && !ok) { + initRandom(rr); + if (compressed(dest, sptr, sdata+heap, + kkstart, kkstop, jjstart, jjstop, iistart, iistop)) { + if (DebugCompress) + cerr << 'c'; + ok=1; + } + } + + if (uncompress_ && !ok) { + if (uncompressed(dest, sptr, sdata+heap, + kkstart, kkstop, jjstart, jjstop, iistart, iistop)) { + if (DebugCompress) + cerr << 'u'; + ok=1; + } + } + + if (!ok) + return 0; + + // tiles may not be an even multiple of the image size + iistart += ww_; + iistop += ww_; + if (iistop > width_) + iistop = width_; + + if (iistart >= width_) { + iistart = 0; + iistop = ww_; + if (iistop > width_) + iistop = width_; + + jjstart += hh_; + jjstop += hh_; + if (jjstop > height_) + jjstop = height_; + + if (jjstart >= height_) { + jjstart = 0; + jjstop = hh_; + if (jjstop > height_) + jjstop = height_; + + kkstart += dd_; + kkstop += dd_; + + // we only do up to 3 dimensions + if (kkstart >= depth_) + break; + } + } + } + + // we can't use incr paging due to the location of the heap + // fits->resetpage(); + + data_ = dest; + + dataSize_ = size_; + dataSkip_ = 0; + + return 1; +} + +// uncompressed + +template int FitsCompressm::uncompressed(T* dest, char* sptr, + char* heap, + int kkstart, int kkstop, + int jjstart, int jjstop, + int iistart, int iistop) +{ + int ocnt=0; + T* obuf = (T*)(((FitsBinColumnArray*)uncompress_)->get(heap, sptr, &ocnt)); + + // obuf can be NULL + if (!obuf || !ocnt) + return 0; + + int ll=0; + for (int kk=kkstart; kk int FitsCompressm::gzcompressed(T* dest, char* sptr, + char* heap, + int kkstart, int kkstop, + int jjstart, int jjstop, + int iistart, int iistop) +{ + int icnt=0; + unsigned char* ibuf = (unsigned char*)((FitsBinColumnArray*)gzcompress_)->get(heap, sptr, &icnt); + + // ibuf can be NULL + if (!ibuf || !icnt) + return 0; + + int ocnt = tilesize_; + char obuf[ocnt*sizeof(T)]; + + z_stream zstrm; + zstrm.next_in = NULL; + zstrm.avail_in = 0; + zstrm.zalloc = NULL; + zstrm.zfree = NULL; + zstrm.opaque = NULL; + + // look for both zlib and gzcompressed headers + if (inflateInit2(&zstrm, MAX_WBITS+32) != Z_OK) { + internalError("Fitsy++ gzcompressed inflateInit error"); + return 0; + } + + zstrm.avail_in = icnt; + zstrm.next_in = ibuf; + zstrm.avail_out = ocnt*sizeof(T); + zstrm.next_out = (Bytef*)obuf; + + if (DebugCompress) + cerr << " inflate START: avail_in " << zstrm.avail_in + << " avail_out " << zstrm.avail_out + << " total_in " << zstrm.total_in + << " total_out " << zstrm.total_out << endl; + + int result = ::inflate(&zstrm, Z_FINISH); + + switch (result) { + case Z_OK: + if (DebugCompress) + cerr << " inflate OK: avail_in " << zstrm.avail_in + << " avail_out " << zstrm.avail_out + << " total_in " << zstrm.total_in + << " total_out " << zstrm.total_out << endl; + break; + case Z_STREAM_END: + if (DebugCompress) + cerr << " inflate STREAM_END: avail_in " << zstrm.avail_in + << " avail_out " << zstrm.avail_out + << " total_in " << zstrm.total_in + << " total_out " << zstrm.total_out << endl; + break; + case Z_BUF_ERROR: + if (DebugCompress) + cerr << " inflate BUF_ERROR: avail_in " << zstrm.avail_in + << " avail_out " << zstrm.avail_out << endl; + return 0; + default: + internalError("Fitsy++ gzcompressed inflate error"); + return 0; + } + + inflateEnd(&zstrm); + + int ll=0; + for (int kk=kkstart; kk void FitsCompressm::swapBytes() +{ + if (byteswap_) { + T* dest = (T*)data_; + for (size_t ii=0; ii unsigned char FitsCompressm::swap(unsigned char* ptr) +{ + return *ptr; +} + +template <> short FitsCompressm::swap(short* ptr) +{ + const char* p = (const char*)ptr; + union { + char c[2]; + short s; + } u; + + u.c[1] = *p++; + u.c[0] = *p; + + return u.s; +} + +template <> unsigned short FitsCompressm::swap(unsigned short* ptr) +{ + const char* p = (const char*)ptr; + union { + char c[2]; + unsigned short s; + } u; + + u.c[1] = *p++; + u.c[0] = *p; + + return u.s; +} + +template <> int FitsCompressm::swap(int* ptr) +{ + const char* p = (const char*)ptr; + union { + char c[4]; + int i; + } u; + + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + return u.i; +} + +template <> long long FitsCompressm::swap(long long* ptr) +{ + const char* p = (const char*)ptr; + union { + char c[8]; + long long i; + } u; + + u.c[7] = *p++; + u.c[6] = *p++; + u.c[5] = *p++; + u.c[4] = *p++; + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + return u.i; +} + +template <> float FitsCompressm::swap(float* ptr) +{ + const char* p = (const char*)ptr; + union { + char c[4]; + float f; + } u; + + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + return u.f; +} + +template <> double FitsCompressm::swap(double* ptr) +{ + const char* p = (const char*)ptr; + union { + char c[8]; + double d; + } u; + + u.c[7] = *p++; + u.c[6] = *p++; + u.c[5] = *p++; + u.c[4] = *p++; + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + return u.d; +} + +// getValue char + +template T FitsCompressm::getValue(char* ptr, double zs, + double zz, int blank) +{ + return hasScaling_ ? T((*ptr)*zs + zz) : *ptr; +} + +template <> float FitsCompressm::getValue(char* ptr, double zs, + double zz, int blank) +{ + if (!hasBlank_ && !hasScaling_ && + quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2) + return *ptr; + + if (hasBlank_ && *ptr == blank) + return NAN; + + switch (quantize_) { + case NODITHER: + return hasScaling_ ? (*ptr)*zs + zz : *ptr; + case SUBDITHER1: + case SUBDITHER2: + return unquantize(*ptr,zs,zz); + } + + // so compiler will not complain + return hasScaling_ ? (*ptr)*zs + zz : *ptr; +} + +template <> double FitsCompressm::getValue(char* ptr, double zs, + double zz, int blank) +{ + if (!hasBlank_ && !hasScaling_ && + quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2) + return *ptr; + + if (hasBlank_ && *ptr == blank) + return NAN; + + switch (quantize_) { + case NODITHER: + return hasScaling_ ? (*ptr)*zs + zz : *ptr; + case SUBDITHER1: + case SUBDITHER2: + return unquantize(*ptr,zs,zz); + } + + // so compiler will not complain + return hasScaling_ ? (*ptr)*zs + zz : *ptr; +} + +// getValue short + +template T FitsCompressm::getValue(short* ptr, double zs, + double zz, int blank) +{ + return hasScaling_ ? T((*ptr)*zs + zz) : *ptr; +} + +template <> float FitsCompressm::getValue(short* ptr, double zs, + double zz, int blank) +{ + if (!hasBlank_ && !hasScaling_ && + quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2) + return *ptr; + + if (hasBlank_ && *ptr == blank) + return NAN; + + switch (quantize_) { + case NODITHER: + return hasScaling_ ? (*ptr)*zs + zz : *ptr; + case SUBDITHER1: + case SUBDITHER2: + return unquantize(*ptr,zs,zz); + } + + // so compiler will not complain + return hasScaling_ ? (*ptr)*zs + zz : *ptr; +} + +template <> double FitsCompressm::getValue(short* ptr, double zs, + double zz, int blank) +{ + if (!hasBlank_ && !hasScaling_ && + quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2) + return *ptr; + + if (hasBlank_ && *ptr == blank) + return NAN; + + switch (quantize_) { + case NODITHER: + return hasScaling_ ? (*ptr)*zs + zz : *ptr; + case SUBDITHER1: + case SUBDITHER2: + return unquantize(*ptr,zs,zz); + } + + // so compiler will not complain + return hasScaling_ ? (*ptr)*zs + zz : *ptr; +} + +// getValue int + +template T FitsCompressm::getValue(int* ptr, double zs, + double zz, int blank) +{ + return hasScaling_ ? T((*ptr)*zs + zz) : *ptr; +} + +template <> float FitsCompressm::getValue(int* ptr, double zs, + double zz, int blank) +{ + if (!hasBlank_ && !hasScaling_ && + quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2) + return *ptr; + + if (hasBlank_ && *ptr == blank) + return NAN; + + switch (quantize_) { + case NODITHER: + return hasScaling_ ? (*ptr)*zs + zz : *ptr; + case SUBDITHER1: + return unquantize(*ptr,zs,zz); + case SUBDITHER2: + return unquantizeZero(*ptr,zs,zz); + } + + // so compiler will not complain + return hasScaling_ ? (*ptr)*zs + zz : *ptr; +} + +template <> double FitsCompressm::getValue(int* ptr, double zs, + double zz, int blank) +{ + if (!hasBlank_ && !hasScaling_ && + quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2) + return *ptr; + + if (hasBlank_ && *ptr == blank) + return NAN; + + switch (quantize_) { + case NODITHER: + return hasScaling_ ? (*ptr)*zs + zz : *ptr; + case SUBDITHER1: + return unquantize(*ptr,zs,zz); + case SUBDITHER2: + return unquantizeZero(*ptr,zs,zz); + } + + // so compiler will not complain + return hasScaling_ ? (*ptr)*zs + zz : *ptr; +} + +// getValue long long + +template T FitsCompressm::getValue(long long* ptr, double zs, + double zz, int blank) +{ + return hasScaling_ ? T((*ptr)*zs + zz) : *ptr; +} + +template <> float FitsCompressm::getValue(long long* ptr, double zs, + double zz, int blank) +{ + if (!hasBlank_ && !hasScaling_ && + quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2) + return *ptr; + + if (hasBlank_ && *ptr == blank) + return NAN; + + switch (quantize_) { + case NODITHER: + return hasScaling_ ? (*ptr)*zs + zz : *ptr; + case SUBDITHER1: + return unquantize(*ptr,zs,zz); + case SUBDITHER2: + return unquantizeZero(*ptr,zs,zz); + } + + // so compiler will not complain + return hasScaling_ ? (*ptr)*zs + zz : *ptr; +} + +template <> double FitsCompressm::getValue(long long* ptr, double zs, + double zz, int blank) +{ + if (!hasBlank_ && !hasScaling_ && + quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2) + return *ptr; + + if (hasBlank_ && *ptr == blank) + return NAN; + + switch (quantize_) { + case NODITHER: + return hasScaling_ ? (*ptr)*zs + zz : *ptr; + case SUBDITHER1: + return unquantize(*ptr,zs,zz); + case SUBDITHER2: + return unquantizeZero(*ptr,zs,zz); + } + + // so compiler will not complain + return hasScaling_ ? (*ptr)*zs + zz : *ptr; +} + +// getValue float + +template T FitsCompressm::getValue(float* ptr, double zs, + double zz, int blank) +{ + return hasScaling_ ? T((*ptr)*zs + zz) : *ptr; +} + +// getValue double + +template T FitsCompressm::getValue(double* ptr, double zs, + double zz, int blank) +{ + return hasScaling_ ? T((*ptr)*zs + zz) : *ptr; +} + +template class FitsCompressm; +template class FitsCompressm; +template class FitsCompressm; +template class FitsCompressm; +template class FitsCompressm; +template class FitsCompressm; +template class FitsCompressm; + +FitsPostNext::FitsPostNext(FitsFile* p) +{ + FitsCompress* prev = (FitsCompress*)p; + + primary_ = prev->primary(); + managePrimary_ = 0; + + head_ = prev->head(); + manageHead_ = 0; + + FitsImageHDU* hdu = (FitsImageHDU*)head_->hdu(); + data_ = (char*)prev->data() + hdu->imgbytes(); + dataSize_ = 0; + dataSkip_ = 0; + + ext_ = prev->ext(); + inherit_ = head_->inherit(); + byteswap_ = prev->byteswap(); + endian_ = prev->endian(); + valid_ = 1; + + return; +} diff --git a/tksao/fitsy++/compress.h b/tksao/fitsy++/compress.h new file mode 100644 index 0000000..938de7b --- /dev/null +++ b/tksao/fitsy++/compress.h @@ -0,0 +1,94 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitscompress_h__ +#define __fitscompress_h__ + +#include "file.h" + +class FitsCompress : public FitsFile { + public: + enum QuantMethod {NODITHER,SUBDITHER1,SUBDITHER2}; + + protected: + int bitpix_; + char* type_; + int width_; + int height_; + int depth_; + int ww_; + int hh_; + int dd_; + double bscale_; + double bzero_; + unsigned int blank_; + char* zmaskcmp_; + + size_t tilesize_; + size_t size_; + + FitsColumn* gzcompress_; + FitsColumn* compress_; + FitsColumn* uncompress_; + FitsColumn* zscale_; + FitsColumn* zzero_; + FitsColumn* zblank_; + FitsColumn* null_; + + int hasScaling_; + int hasBlank_; + + QuantMethod quantize_; + int quantOffset_; + + int numRandom_; + float* random_; + int randSeed_; + int randNext_; + + protected: + int initHeader(FitsFile*); + void initRandom(int); + + double unquantize(double, double, double); + double unquantizeZero(double, double, double); + + public: + FitsCompress(FitsFile*); + virtual ~FitsCompress(); +}; + +template +class FitsCompressm : public FitsCompress { + private: + int inflate(FitsFile*); + void swapBytes(); + + protected: + T swap(T* ptr); + + protected: + void uncompress(FitsFile* fits); + int gzcompressed(T*, char*, char*, int, int, int, int, int, int); + virtual int compressed(T*, char*, char*, int, int, int, int, int, int) =0; + int uncompressed(T*, char*, char*, int, int, int, int, int, int); + + T getValue(char*, double, double, int); + T getValue(short*, double, double, int); + T getValue(int*, double, double, int); + T getValue(long long*, double, double, int); + T getValue(float*, double, double, int); + T getValue(double*, double, double, int); + + public: + FitsCompressm(FitsFile*); +}; + +class FitsPostNext : public FitsFile { +public: + FitsPostNext(FitsFile* prev); +}; + +#endif + diff --git a/tksao/fitsy++/envi.C b/tksao/fitsy++/envi.C new file mode 100644 index 0000000..08b0cc0 --- /dev/null +++ b/tksao/fitsy++/envi.C @@ -0,0 +1,141 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "envi.h" +#include "head.h" + +FitsENVI::FitsENVI(FitsFile* fits) +{ + byteswap_ = fits->byteswap(); + endian_ = fits->endian(); + + pBitpix_ = fits->pBitpix(); + pWidth_ = fits->pWidth(); + pHeight_ = fits->pHeight(); + pDepth_ = fits->pDepth(); + + pEncoding_ = FitsFile::BSQ; + + pCRPIX3_ = fits->pCRPIX3(); + pCRVAL3_ = fits->pCRVAL3(); + pCDELT3_ = fits->pCDELT3(); + + size_ = (size_t)pWidth_*pHeight_*pDepth_; +} + +FitsENVI::~FitsENVI() +{ + if (data_) + delete [] (char*)data_; +} + +int FitsENVI::initHeader(FitsFile* fits) +{ + // simple check + if (!pWidth_ || !pHeight_ || !pBitpix_) + return 0; + + // create header + head_ = new FitsHead(pWidth_, pHeight_, pDepth_, pBitpix_); + if (!head_->isValid()) + return 0; + + // WCS? + if (pCRPIX3_>0 || pCRVAL3_>0 || pCDELT3_!=1) { + head_->appendString("CTYPE1","LINEAR", NULL); + head_->appendReal("CRPIX1",1, 9, NULL); + head_->appendReal("CRVAL1",1, 9, NULL); + head_->appendReal("CDELT1",1, 9, NULL); + + head_->appendString("CTYPE2","LINEAR", NULL); + head_->appendReal("CRPIX2",1, 9, NULL); + head_->appendReal("CRVAL2",1, 9, NULL); + head_->appendReal("CDELT2",1, 9, NULL); + + head_->appendString("CTYPE3","WAVELENGTH", NULL); + head_->appendReal("CRPIX3",pCRPIX3_, 9, NULL); + head_->appendReal("CRVAL3",pCRVAL3_, 9, NULL); + head_->appendReal("CDELT3",pCDELT3_, 9, NULL); + } + + // other + primary_ = fits->primary(); + managePrimary_ = 0; + + inherit_ = head_->inherit(); + + return 1; +} + +template FitsENVIBIPm::FitsENVIBIPm(FitsFile* fits) + : FitsENVI(fits) +{ + if (!initHeader(fits)) + return; + + T* dest = new T[size_]; + if (!dest) { + internalError("Fitsy++ envi unable to allocate memory"); + return; + } + memset(dest, 0, size_*sizeof(T)); + + T* ptr = (T*)fits->data(); + for (int jj=0; jj; +template class FitsENVIBIPm; +template class FitsENVIBIPm; +template class FitsENVIBIPm; +template class FitsENVIBIPm; +template class FitsENVIBIPm; +template class FitsENVIBIPm; + +template FitsENVIBILm::FitsENVIBILm(FitsFile* fits) + : FitsENVI(fits) +{ + if (!initHeader(fits)) + return; + + T* dest = new T[size_]; + if (!dest) { + internalError("Fitsy++ envi unable to allocate memory"); + return; + } + memset(dest, 0, size_*sizeof(T)); + + T* ptr = (T*)fits->data(); + for (int jj=0; jj; +template class FitsENVIBILm; +template class FitsENVIBILm; +template class FitsENVIBILm; +template class FitsENVIBILm; +template class FitsENVIBILm; +template class FitsENVIBILm; diff --git a/tksao/fitsy++/envi.h b/tksao/fitsy++/envi.h new file mode 100644 index 0000000..9887542 --- /dev/null +++ b/tksao/fitsy++/envi.h @@ -0,0 +1,35 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsenvi_h__ +#define __fitsenvi_h__ + +#include "file.h" + +class FitsENVI : public FitsFile { + protected: + size_t size_; + + protected: + int initHeader(FitsFile*); + + public: + FitsENVI(FitsFile*); + virtual ~FitsENVI(); +}; + +template +class FitsENVIBILm : public FitsENVI { + public: + FitsENVIBILm(FitsFile*); +}; + +template +class FitsENVIBIPm : public FitsENVI { + public: + FitsENVIBIPm(FitsFile*); +}; + +#endif + diff --git a/tksao/fitsy++/envilex.C b/tksao/fitsy++/envilex.C new file mode 100644 index 0000000..a35f6da --- /dev/null +++ b/tksao/fitsy++/envilex.C @@ -0,0 +1,2223 @@ +#line 2 "fitsy++/envilex.C" + +#line 4 "fitsy++/envilex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer enviFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *envialloc (yy_size_t ); +void *envirealloc (void *,yy_size_t ); +void envifree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 72 +#define YY_END_OF_BUFFER 73 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[282] = + { 0, + 0, 0, 2, 2, 0, 0, 73, 71, 68, 70, + 71, 71, 71, 64, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 3, 2, 1, 63, 61, 62, + 63, 60, 59, 63, 56, 59, 4, 68, 69, 0, + 64, 66, 65, 64, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 6, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 2, 61, 0, 56, 59, + + 56, 58, 57, 59, 0, 0, 0, 65, 67, 67, + 11, 12, 13, 14, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 32, 67, 67, 7, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 0, 0, 0, 59, 57, 65, 0, 66, + 67, 9, 15, 17, 67, 67, 67, 16, 67, 22, + 67, 23, 24, 67, 67, 26, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 40, 67, 67, 67, 67, + 67, 67, 67, 48, 67, 67, 51, 67, 67, 67, + + 57, 0, 58, 67, 10, 5, 67, 67, 67, 21, + 67, 67, 67, 67, 30, 31, 33, 34, 67, 37, + 38, 67, 42, 67, 67, 45, 67, 67, 67, 67, + 52, 53, 67, 67, 67, 67, 20, 25, 27, 67, + 29, 35, 39, 67, 67, 67, 67, 47, 67, 50, + 54, 67, 8, 18, 67, 67, 36, 67, 67, 44, + 46, 49, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 28, 41, 67, 55, 19, 43, + 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 5, 6, 7, 8, 1, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 1, 1, 1, + 1, 1, 1, 1, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 1, 1, 1, 1, 1, 1, 36, 37, 38, 39, + + 40, 41, 42, 43, 44, 45, 20, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 1, 62, 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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[63] = + { 0, + 1, 1, 2, 1, 1, 1, 3, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 1, 1 + } ; + +static yyconst flex_int16_t yy_base[287] = + { 0, + 0, 0, 806, 805, 62, 124, 807, 810, 800, 810, + 788, 64, 781, 66, 78, 179, 781, 68, 69, 127, + 71, 75, 128, 76, 77, 80, 150, 148, 132, 231, + 144, 91, 83, 102, 810, 0, 810, 810, 786, 810, + 88, 810, 92, 778, 141, 778, 810, 783, 810, 775, + 187, 134, 190, 197, 775, 212, 153, 202, 201, 227, + 200, 204, 226, 246, 228, 145, 210, 232, 236, 254, + 255, 258, 274, 270, 282, 286, 278, 280, 772, 297, + 289, 288, 296, 300, 311, 294, 303, 306, 316, 95, + 327, 325, 322, 323, 330, 0, 776, 768, 349, 767, + + 351, 353, 359, 375, 365, 383, 765, 220, 369, 387, + 765, 764, 763, 761, 371, 393, 379, 394, 386, 389, + 398, 400, 397, 409, 402, 407, 404, 408, 427, 405, + 428, 414, 760, 431, 429, 437, 446, 456, 443, 439, + 458, 467, 451, 470, 453, 463, 465, 474, 475, 479, + 477, 484, 505, 512, 757, 334, 514, 756, 751, 750, + 494, 501, 750, 746, 518, 517, 519, 739, 520, 725, + 523, 687, 684, 527, 528, 636, 530, 532, 531, 535, + 537, 540, 562, 548, 544, 629, 565, 569, 577, 573, + 584, 580, 550, 570, 587, 593, 558, 598, 596, 600, + + 544, 542, 541, 606, 541, 534, 604, 605, 588, 503, + 603, 621, 610, 619, 491, 486, 454, 440, 624, 410, + 626, 630, 370, 631, 644, 363, 649, 654, 652, 657, + 356, 658, 659, 662, 651, 663, 347, 345, 341, 669, + 338, 666, 268, 667, 674, 679, 685, 262, 683, 256, + 238, 693, 216, 206, 689, 712, 174, 690, 715, 172, + 156, 152, 719, 696, 589, 707, 716, 709, 721, 722, + 734, 738, 736, 744, 133, 110, 741, 103, 97, 94, + 810, 792, 796, 94, 800, 802 + } ; + +static yyconst flex_int16_t yy_def[287] = + { 0, + 281, 1, 282, 282, 283, 283, 281, 281, 281, 281, + 281, 281, 281, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 281, 285, 281, 281, 281, 281, + 281, 281, 286, 281, 286, 286, 281, 281, 281, 281, + 281, 281, 281, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 285, 281, 281, 281, 286, + + 286, 281, 281, 286, 281, 281, 281, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 281, 281, 281, 286, 286, 281, 281, 281, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + + 281, 281, 281, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 0, 281, 281, 281, 281, 281 + } ; + +static yyconst flex_int16_t yy_nxt[873] = + { 0, + 8, 9, 10, 11, 12, 8, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 17, 17, + 24, 25, 26, 27, 28, 17, 29, 30, 31, 32, + 33, 34, 17, 17, 17, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 17, 24, 25, 26, 27, 28, + 17, 29, 30, 31, 32, 33, 34, 17, 17, 17, + 35, 8, 38, 39, 40, 38, 41, 42, 43, 44, + 45, 50, 51, 53, 54, 281, 281, 63, 281, 56, + 70, 64, 281, 281, 281, 281, 75, 281, 71, 77, + 281, 65, 94, 74, 76, 98, 99, 55, 281, 98, + + 101, 281, 281, 63, 281, 56, 70, 64, 57, 281, + 281, 95, 75, 93, 71, 77, 65, 281, 94, 74, + 76, 147, 38, 47, 38, 39, 40, 38, 41, 42, + 43, 44, 45, 57, 281, 281, 66, 95, 93, 281, + 281, 84, 52, 72, 67, 85, 147, 106, 103, 101, + 73, 281, 281, 68, 104, 281, 121, 281, 69, 281, + 281, 91, 66, 281, 78, 81, 109, 84, 82, 72, + 67, 85, 79, 106, 83, 73, 80, 92, 68, 281, + 104, 281, 121, 69, 38, 47, 281, 91, 58, 59, + 78, 81, 109, 82, 53, 51, 60, 79, 52, 83, + + 105, 80, 92, 105, 53, 54, 61, 281, 281, 281, + 56, 281, 62, 281, 58, 59, 107, 281, 107, 281, + 108, 111, 60, 281, 110, 114, 105, 281, 108, 105, + 122, 61, 115, 281, 281, 281, 56, 62, 281, 281, + 86, 123, 87, 281, 88, 281, 111, 112, 89, 110, + 114, 113, 124, 281, 116, 122, 117, 115, 120, 90, + 118, 281, 281, 281, 126, 281, 86, 123, 87, 281, + 88, 125, 112, 119, 89, 281, 113, 281, 124, 116, + 127, 281, 117, 120, 90, 281, 118, 281, 128, 281, + 126, 130, 131, 281, 136, 281, 281, 125, 119, 135, + + 132, 281, 129, 281, 281, 127, 133, 281, 134, 137, + 281, 139, 144, 281, 128, 143, 130, 131, 281, 140, + 136, 138, 141, 281, 135, 142, 132, 129, 145, 281, + 281, 133, 281, 134, 281, 137, 139, 281, 144, 150, + 143, 281, 157, 151, 140, 281, 138, 141, 281, 149, + 146, 142, 281, 145, 281, 148, 103, 99, 103, 101, + 152, 102, 153, 281, 104, 150, 154, 102, 151, 107, + 281, 107, 153, 158, 149, 146, 281, 281, 281, 155, + 148, 156, 281, 157, 163, 152, 281, 159, 153, 159, + 104, 160, 154, 281, 281, 161, 281, 167, 153, 162, + + 281, 281, 164, 166, 281, 281, 168, 281, 165, 281, + 163, 281, 281, 170, 281, 281, 281, 281, 171, 174, + 161, 281, 178, 167, 173, 162, 169, 175, 164, 166, + 172, 176, 168, 165, 281, 281, 281, 180, 281, 170, + 177, 179, 182, 171, 281, 174, 281, 281, 178, 173, + 281, 169, 175, 281, 181, 172, 176, 187, 281, 184, + 281, 281, 180, 281, 183, 281, 177, 179, 182, 185, + 281, 186, 281, 188, 281, 190, 194, 281, 195, 181, + 193, 281, 281, 187, 281, 184, 281, 189, 197, 183, + 191, 281, 192, 281, 196, 185, 186, 200, 281, 188, + + 190, 281, 194, 204, 195, 193, 199, 198, 281, 155, + 281, 155, 189, 201, 197, 191, 202, 192, 202, 196, + 203, 281, 157, 200, 281, 281, 281, 281, 205, 204, + 281, 199, 198, 206, 281, 281, 210, 281, 281, 281, + 211, 281, 281, 209, 281, 208, 207, 281, 281, 203, + 203, 281, 201, 205, 212, 281, 213, 281, 215, 206, + 214, 216, 210, 217, 221, 281, 211, 218, 209, 281, + 208, 207, 281, 228, 220, 219, 281, 281, 222, 212, + 281, 213, 223, 215, 281, 214, 216, 281, 217, 221, + 224, 281, 218, 225, 281, 281, 281, 226, 228, 220, + + 281, 219, 227, 281, 222, 281, 230, 281, 223, 232, + 281, 281, 281, 281, 237, 229, 224, 281, 225, 270, + 233, 234, 236, 226, 235, 231, 281, 227, 281, 238, + 240, 281, 230, 281, 239, 232, 281, 281, 281, 237, + 229, 244, 245, 281, 270, 233, 241, 234, 236, 235, + 231, 281, 242, 243, 238, 240, 281, 246, 281, 281, + 239, 281, 247, 249, 281, 281, 281, 244, 245, 281, + 281, 241, 252, 281, 281, 253, 281, 242, 243, 254, + 248, 281, 256, 246, 250, 251, 281, 255, 247, 249, + 281, 281, 281, 257, 281, 258, 281, 281, 252, 262, + + 281, 253, 259, 281, 254, 248, 260, 266, 256, 250, + 251, 261, 255, 269, 281, 263, 281, 264, 257, 281, + 258, 265, 281, 281, 267, 262, 281, 259, 281, 281, + 271, 260, 281, 266, 268, 275, 261, 273, 272, 269, + 263, 281, 264, 281, 274, 281, 281, 265, 281, 277, + 267, 281, 278, 281, 280, 271, 276, 281, 160, 160, + 268, 275, 273, 272, 158, 201, 279, 281, 281, 274, + 281, 281, 281, 158, 281, 277, 102, 97, 278, 281, + 280, 276, 281, 52, 48, 281, 102, 97, 281, 52, + 49, 279, 36, 36, 36, 36, 46, 46, 46, 46, + + 96, 48, 96, 96, 100, 100, 281, 37, 37, 7, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281 + } ; + +static yyconst flex_int16_t yy_chk[873] = + { 0, + 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, 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, 1, 1, + 1, 1, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 12, 12, 14, 14, 18, 19, 18, 21, 14, + 21, 18, 22, 24, 25, 15, 25, 26, 22, 26, + 33, 19, 33, 24, 25, 41, 41, 284, 32, 43, + + 43, 280, 90, 18, 279, 14, 21, 18, 15, 34, + 278, 34, 25, 32, 22, 26, 19, 276, 33, 24, + 25, 90, 5, 5, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 15, 20, 23, 20, 34, 32, 29, + 275, 29, 52, 23, 20, 29, 90, 52, 45, 45, + 23, 31, 66, 20, 45, 28, 66, 27, 20, 262, + 57, 31, 20, 261, 27, 28, 57, 29, 28, 23, + 20, 29, 27, 52, 28, 23, 27, 31, 20, 260, + 45, 257, 66, 20, 6, 6, 16, 31, 16, 16, + 27, 28, 57, 28, 51, 51, 16, 27, 53, 28, + + 51, 27, 31, 53, 54, 54, 16, 61, 59, 58, + 54, 62, 16, 254, 16, 16, 56, 67, 56, 56, + 56, 59, 16, 253, 58, 61, 51, 108, 108, 53, + 67, 16, 62, 63, 60, 65, 54, 16, 30, 68, + 30, 68, 30, 69, 30, 251, 59, 60, 30, 58, + 61, 60, 69, 64, 63, 67, 64, 62, 65, 30, + 64, 70, 71, 250, 71, 72, 30, 68, 30, 248, + 30, 70, 60, 64, 30, 243, 60, 74, 69, 63, + 72, 73, 64, 65, 30, 77, 64, 78, 73, 75, + 71, 74, 74, 76, 78, 82, 81, 70, 64, 77, + + 75, 86, 73, 83, 80, 72, 75, 84, 76, 80, + 87, 82, 87, 88, 73, 86, 74, 74, 85, 83, + 78, 81, 84, 89, 77, 85, 75, 73, 88, 93, + 94, 75, 92, 76, 91, 80, 82, 95, 87, 93, + 86, 156, 156, 94, 83, 241, 81, 84, 239, 92, + 89, 85, 238, 88, 237, 91, 99, 99, 101, 101, + 95, 102, 99, 231, 101, 93, 102, 103, 94, 105, + 226, 105, 103, 105, 92, 89, 109, 223, 115, 104, + 91, 104, 104, 104, 115, 95, 117, 106, 99, 106, + 101, 106, 102, 119, 110, 109, 120, 119, 103, 110, + + 116, 118, 116, 118, 123, 121, 120, 122, 117, 125, + 115, 127, 130, 122, 126, 128, 124, 220, 123, 126, + 109, 132, 130, 119, 125, 110, 121, 127, 116, 118, + 124, 128, 120, 117, 129, 131, 135, 132, 134, 122, + 129, 131, 135, 123, 136, 126, 140, 218, 130, 125, + 139, 121, 127, 137, 134, 124, 128, 140, 143, 137, + 145, 217, 132, 138, 136, 141, 129, 131, 135, 138, + 146, 139, 147, 141, 142, 143, 146, 144, 147, 134, + 145, 148, 149, 140, 151, 137, 150, 142, 149, 136, + 144, 152, 144, 216, 148, 138, 139, 152, 215, 141, + + 143, 161, 146, 161, 147, 145, 151, 150, 162, 153, + 210, 153, 142, 153, 149, 144, 154, 144, 154, 148, + 154, 157, 157, 152, 166, 165, 167, 169, 162, 161, + 171, 151, 150, 165, 174, 175, 171, 177, 179, 178, + 174, 206, 180, 169, 181, 167, 166, 182, 205, 203, + 202, 185, 201, 162, 175, 184, 177, 193, 179, 165, + 178, 180, 171, 181, 185, 197, 174, 182, 169, 183, + 167, 166, 187, 193, 184, 183, 188, 194, 187, 175, + 190, 177, 188, 179, 189, 178, 180, 192, 181, 185, + 189, 191, 182, 190, 195, 209, 265, 191, 193, 184, + + 196, 183, 192, 199, 187, 198, 196, 200, 188, 199, + 211, 207, 208, 204, 209, 195, 189, 213, 190, 265, + 200, 204, 208, 191, 207, 198, 214, 192, 212, 211, + 213, 219, 196, 221, 212, 199, 186, 222, 224, 209, + 195, 222, 224, 176, 265, 200, 214, 204, 208, 207, + 198, 225, 219, 221, 211, 213, 227, 225, 235, 229, + 212, 228, 227, 229, 230, 232, 233, 222, 224, 234, + 236, 214, 233, 242, 244, 234, 240, 219, 221, 235, + 228, 245, 240, 225, 230, 232, 246, 236, 227, 229, + 249, 173, 247, 242, 172, 244, 255, 258, 233, 249, + + 252, 234, 245, 264, 235, 228, 246, 258, 240, 230, + 232, 247, 236, 264, 266, 252, 268, 255, 242, 256, + 244, 256, 259, 267, 259, 249, 263, 245, 269, 270, + 266, 246, 170, 258, 263, 270, 247, 268, 267, 264, + 252, 271, 255, 273, 269, 272, 168, 256, 277, 272, + 259, 274, 273, 164, 277, 266, 271, 163, 160, 159, + 263, 270, 268, 267, 158, 155, 274, 133, 114, 269, + 113, 112, 111, 107, 100, 272, 98, 97, 273, 79, + 277, 271, 55, 50, 48, 46, 44, 39, 17, 13, + 11, 274, 282, 282, 282, 282, 283, 283, 283, 283, + + 285, 9, 285, 285, 286, 286, 7, 4, 3, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "fitsy++/envilex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 11 "fitsy++/envilex.L" + #include + #include + #include + + #include "util.h" + #include "enviparser.H" + + extern YYSTYPE* envilval; + extern enviFlexLexer* envilexx; + + +/* rules */ +#line 710 "fitsy++/envilex.C" + +#define INITIAL 0 +#define DISCARD 1 +#define BRACKET 2 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 30 "fitsy++/envilex.L" + + +#line 815 "fitsy++/envilex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 282 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 281 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +#line 32 "fitsy++/envilex.L" +{ // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(envilval->str,""); // feed a blank string + return STRING; + } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 39 "fitsy++/envilex.L" +{ // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(ENVIPARSERSIZE-1) ? yyleng:(ENVIPARSERSIZE-1); + strncpy(envilval->str,yytext,ll); + envilval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 47 "fitsy++/envilex.L" +{ + BEGIN BRACKET; + return '{'; + } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 52 "fitsy++/envilex.L" +{ + BEGIN INITIAL; + return '}'; + } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 57 "fitsy++/envilex.L" +{return DEBUG_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 58 "fitsy++/envilex.L" +{return ON_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 59 "fitsy++/envilex.L" +{return OFF_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 61 "fitsy++/envilex.L" +{return AVERAGE_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 62 "fitsy++/envilex.L" +{return BAND_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 63 "fitsy++/envilex.L" +{return BANDS_;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 64 "fitsy++/envilex.L" +{return BBL_;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 65 "fitsy++/envilex.L" +{return BIL_;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 66 "fitsy++/envilex.L" +{return BIP_;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 67 "fitsy++/envilex.L" +{return BSQ_;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 68 "fitsy++/envilex.L" +{return BYTE_;} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 69 "fitsy++/envilex.L" +{return ENVI_;} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 70 "fitsy++/envilex.L" +{return DATA_;} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 71 "fitsy++/envilex.L" +{return DEFAULT_;} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 72 "fitsy++/envilex.L" +{return DESCRIPTION_;} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 73 "fitsy++/envilex.L" +{return FACTOR_;} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 74 "fitsy++/envilex.L" +{return FRAME_;} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 75 "fitsy++/envilex.L" +{return FILE_;} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 76 "fitsy++/envilex.L" +{return FWHM_;} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 77 "fitsy++/envilex.L" +{return GAIN_;} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 78 "fitsy++/envilex.L" +{return HEADER_;} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 79 "fitsy++/envilex.L" +{return INFO_;} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 80 "fitsy++/envilex.L" +{return IGNORE_;} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 81 "fitsy++/envilex.L" +{return INTERLEAVE_;} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 82 "fitsy++/envilex.L" +{return LIMITS_;} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 83 "fitsy++/envilex.L" +{return LINES_;} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 84 "fitsy++/envilex.L" +{return MAJOR_;} + YY_BREAK +case 32: +YY_RULE_SETUP +#line 85 "fitsy++/envilex.L" +{return MAP_;} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 86 "fitsy++/envilex.L" +{return MINOR_;} + YY_BREAK +case 34: +YY_RULE_SETUP +#line 87 "fitsy++/envilex.L" +{return NAMES_;} + YY_BREAK +case 35: +YY_RULE_SETUP +#line 88 "fitsy++/envilex.L" +{return OFFSET_;} + YY_BREAK +case 36: +YY_RULE_SETUP +#line 89 "fitsy++/envilex.L" +{return OFFSETS_;} + YY_BREAK +case 37: +YY_RULE_SETUP +#line 90 "fitsy++/envilex.L" +{return ORDER_;} + YY_BREAK +case 38: +YY_RULE_SETUP +#line 91 "fitsy++/envilex.L" +{return PIXEL_;} + YY_BREAK +case 39: +YY_RULE_SETUP +#line 92 "fitsy++/envilex.L" +{return PIXELS_;} + YY_BREAK +case 40: +YY_RULE_SETUP +#line 93 "fitsy++/envilex.L" +{return PLOT_;} + YY_BREAK +case 41: +YY_RULE_SETUP +#line 94 "fitsy++/envilex.L" +{return PROJECTION_;} + YY_BREAK +case 42: +YY_RULE_SETUP +#line 95 "fitsy++/envilex.L" +{return RANGE_;} + YY_BREAK +case 43: +YY_RULE_SETUP +#line 96 "fitsy++/envilex.L" +{return REFLECTANCE_;} + YY_BREAK +case 44: +YY_RULE_SETUP +#line 97 "fitsy++/envilex.L" +{return SAMPLES_;} + YY_BREAK +case 45: +YY_RULE_SETUP +#line 98 "fitsy++/envilex.L" +{return SCALE_;} + YY_BREAK +case 46: +YY_RULE_SETUP +#line 99 "fitsy++/envilex.L" +{return SCANNER_;} + YY_BREAK +case 47: +YY_RULE_SETUP +#line 100 "fitsy++/envilex.L" +{return SENSOR_;} + YY_BREAK +case 48: +YY_RULE_SETUP +#line 101 "fitsy++/envilex.L" +{return SIZE_;} + YY_BREAK +case 49: +YY_RULE_SETUP +#line 102 "fitsy++/envilex.L" +{return STRETCH_;} + YY_BREAK +case 50: +YY_RULE_SETUP +#line 103 "fitsy++/envilex.L" +{return TITLES_;} + YY_BREAK +case 51: +YY_RULE_SETUP +#line 104 "fitsy++/envilex.L" +{return TYPE_;} + YY_BREAK +case 52: +YY_RULE_SETUP +#line 105 "fitsy++/envilex.L" +{return UNITS_;} + YY_BREAK +case 53: +YY_RULE_SETUP +#line 106 "fitsy++/envilex.L" +{return VALUE_;} + YY_BREAK +case 54: +YY_RULE_SETUP +#line 107 "fitsy++/envilex.L" +{return VALUES_;} + YY_BREAK +case 55: +YY_RULE_SETUP +#line 108 "fitsy++/envilex.L" +{return WAVELENGTH_;} + YY_BREAK +case 56: +YY_RULE_SETUP +#line 111 "fitsy++/envilex.L" +{ // Integer + envilval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 57: +#line 117 "fitsy++/envilex.L" +case 58: +YY_RULE_SETUP +#line 117 "fitsy++/envilex.L" +{ // Real Number + envilval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 59: +YY_RULE_SETUP +#line 123 "fitsy++/envilex.L" +{ // General String + int ll = yyleng <(ENVIPARSERSIZE-1) ? yyleng:(ENVIPARSERSIZE-1); + strncpy(envilval->str,yytext,ll); + envilval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 60: +YY_RULE_SETUP +#line 130 "fitsy++/envilex.L" +{ + return ','; + } + YY_BREAK +case 61: +YY_RULE_SETUP +#line 134 "fitsy++/envilex.L" +{ // White Spaces + } + YY_BREAK +case 62: +/* rule 62 can match eol */ +YY_RULE_SETUP +#line 137 "fitsy++/envilex.L" +{ // linefeed + } + YY_BREAK +case 63: +YY_RULE_SETUP +#line 140 "fitsy++/envilex.L" +{ // other chars, eat it + } + YY_BREAK +case 64: +YY_RULE_SETUP +#line 143 "fitsy++/envilex.L" +{ // Integer + envilval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 65: +#line 149 "fitsy++/envilex.L" +case 66: +YY_RULE_SETUP +#line 149 "fitsy++/envilex.L" +{ // Real Number + envilval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 67: +YY_RULE_SETUP +#line 155 "fitsy++/envilex.L" +{ // General String + int ll = yyleng <(ENVIPARSERSIZE-1) ? yyleng:(ENVIPARSERSIZE-1); + strncpy(envilval->str,yytext,ll); + envilval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 68: +YY_RULE_SETUP +#line 162 "fitsy++/envilex.L" +{ // White Spaces + } + YY_BREAK +case 69: +/* rule 69 can match eol */ +YY_RULE_SETUP +#line 165 "fitsy++/envilex.L" +{ // windows line feed + return '\n'; + } + YY_BREAK +case 70: +/* rule 70 can match eol */ +YY_RULE_SETUP +#line 169 "fitsy++/envilex.L" +{ // linefeed + return '\n'; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(DISCARD): +case YY_STATE_EOF(BRACKET): +#line 173 "fitsy++/envilex.L" +{ // eof + return EOF_; + } + YY_BREAK +case 71: +YY_RULE_SETUP +#line 177 "fitsy++/envilex.L" +{ // Else, return the char + return yytext[0]; + } + YY_BREAK +case 72: +YY_RULE_SETUP +#line 181 "fitsy++/envilex.L" +ECHO; + YY_BREAK +#line 1311 "fitsy++/envilex.C" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + envifree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + envifree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + envirealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) envirealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 282 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 282 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 281); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) envialloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) envialloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + envifree((void *) b->yy_ch_buf ); + + envifree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)envialloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)envirealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) envialloc(new_size ); + + else + (yy_start_stack) = (int *) envirealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *envialloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *envirealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void envifree (void * ptr ) +{ + free( (char *) ptr ); /* see envirealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 181 "fitsy++/envilex.L" + + + +void enviDiscard(int doit) +{ + if (envilexx) + envilexx->begin(DISCARD, doit); +} + +void enviFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} + diff --git a/tksao/fitsy++/envilex.L b/tksao/fitsy++/envilex.L new file mode 100644 index 0000000..061ab46 --- /dev/null +++ b/tksao/fitsy++/envilex.L @@ -0,0 +1,194 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + + #include "util.h" + #include "enviparser.H" + + extern YYSTYPE* envilval; + extern enviFlexLexer* envilexx; +%} + +%x DISCARD +%x BRACKET + +D [0-9] +E [Ee][+-]?{D}+ + +/* rules */ + +%% + +[\n] { // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(envilval->str,""); // feed a blank string + return STRING; + } + +[^\n]* { // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(ENVIPARSERSIZE-1) ? yyleng:(ENVIPARSERSIZE-1); + strncpy(envilval->str,yytext,ll); + envilval->str[ll] = '\0'; + return STRING; + } + +\{ { + BEGIN BRACKET; + return '{'; + } + +\} { + BEGIN INITIAL; + return '}'; + } + +debug {return DEBUG_;} +on {return ON_;} +off {return OFF_;} + +average {return AVERAGE_;} +band {return BAND_;} +bands {return BANDS_;} +bbl {return BBL_;} +bil {return BIL_;} +bip {return BIP_;} +bsq {return BSQ_;} +byte {return BYTE_;} +envi {return ENVI_;} +data {return DATA_;} +default {return DEFAULT_;} +description {return DESCRIPTION_;} +factor {return FACTOR_;} +frame {return FRAME_;} +file {return FILE_;} +fwhm {return FWHM_;} +gain {return GAIN_;} +header {return HEADER_;} +info {return INFO_;} +ignore {return IGNORE_;} +interleave {return INTERLEAVE_;} +limits {return LIMITS_;} +lines {return LINES_;} +major {return MAJOR_;} +map {return MAP_;} +minor {return MINOR_;} +names {return NAMES_;} +offset {return OFFSET_;} +offsets {return OFFSETS_;} +order {return ORDER_;} +pixel {return PIXEL_;} +pixels {return PIXELS_;} +plot {return PLOT_;} +projection {return PROJECTION_;} +range {return RANGE_;} +reflectance {return REFLECTANCE_;} +samples {return SAMPLES_;} +scale {return SCALE_;} +scanner {return SCANNER_;} +sensor {return SENSOR_;} +size {return SIZE_;} +stretch {return STRETCH_;} +titles {return TITLES_;} +type {return TYPE_;} +units {return UNITS_;} +value {return VALUE_;} +values {return VALUES_;} +wavelength {return WAVELENGTH_;} + + +[+-]?{D}+ { // Integer + envilval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + envilval->real = atof(yytext); + return REAL; + } + + +[0-9A-Za-z\-]+ { // General String + int ll = yyleng <(ENVIPARSERSIZE-1) ? yyleng:(ENVIPARSERSIZE-1); + strncpy(envilval->str,yytext,ll); + envilval->str[ll] = '\0'; + return STRING; + } + +, { + return ','; + } + +[ \t]+ { // White Spaces + } + +\n { // linefeed + } + +. { // other chars, eat it + } + +[+-]?{D}+ { // Integer + envilval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + envilval->real = atof(yytext); + return REAL; + } + + +[0-9A-Za-z]+ { // General String + int ll = yyleng <(ENVIPARSERSIZE-1) ? yyleng:(ENVIPARSERSIZE-1); + strncpy(envilval->str,yytext,ll); + envilval->str[ll] = '\0'; + return STRING; + } + +[ \t]+ { // White Spaces + } + +\r\n { // windows line feed + return '\n'; + } + +\n { // linefeed + return '\n'; + } + +<> { // eof + return EOF_; + } + +. { // Else, return the char + return yytext[0]; + } + +%% + +void enviDiscard(int doit) +{ + if (envilexx) + envilexx->begin(DISCARD, doit); +} + +void enviFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} diff --git a/tksao/fitsy++/enviparser.C b/tksao/fitsy++/enviparser.C new file mode 100644 index 0000000..1817b47 --- /dev/null +++ b/tksao/fitsy++/enviparser.C @@ -0,0 +1,2017 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse enviparse +#define yylex envilex +#define yyerror envierror +#define yylval envilval +#define yychar envichar +#define yydebug envidebug +#define yynerrs envinerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + EOF_ = 258, + INT = 259, + REAL = 260, + STRING = 261, + DEBUG_ = 262, + ON_ = 263, + OFF_ = 264, + AVERAGE_ = 265, + BAND_ = 266, + BANDS_ = 267, + BBL_ = 268, + BIL_ = 269, + BIP_ = 270, + BSQ_ = 271, + BYTE_ = 272, + DATA_ = 273, + DEFAULT_ = 274, + DESCRIPTION_ = 275, + ENVI_ = 276, + FACTOR_ = 277, + FRAME_ = 278, + FILE_ = 279, + FWHM_ = 280, + GAIN_ = 281, + HEADER_ = 282, + INFO_ = 283, + IGNORE_ = 284, + INTERLEAVE_ = 285, + LIMITS_ = 286, + LINES_ = 287, + MAJOR_ = 288, + MAP_ = 289, + MINOR_ = 290, + NAMES_ = 291, + OFFSET_ = 292, + OFFSETS_ = 293, + ORDER_ = 294, + PIXEL_ = 295, + PIXELS_ = 296, + PLOT_ = 297, + PROJECTION_ = 298, + RANGE_ = 299, + REFLECTANCE_ = 300, + SAMPLES_ = 301, + SCALE_ = 302, + SCANNER_ = 303, + SENSOR_ = 304, + SIZE_ = 305, + START_ = 306, + STRETCH_ = 307, + TITLES_ = 308, + TYPE_ = 309, + UNITS_ = 310, + VALUE_ = 311, + VALUES_ = 312, + WAVELENGTH_ = 313 + }; +#endif +/* Tokens. */ +#define EOF_ 258 +#define INT 259 +#define REAL 260 +#define STRING 261 +#define DEBUG_ 262 +#define ON_ 263 +#define OFF_ 264 +#define AVERAGE_ 265 +#define BAND_ 266 +#define BANDS_ 267 +#define BBL_ 268 +#define BIL_ 269 +#define BIP_ 270 +#define BSQ_ 271 +#define BYTE_ 272 +#define DATA_ 273 +#define DEFAULT_ 274 +#define DESCRIPTION_ 275 +#define ENVI_ 276 +#define FACTOR_ 277 +#define FRAME_ 278 +#define FILE_ 279 +#define FWHM_ 280 +#define GAIN_ 281 +#define HEADER_ 282 +#define INFO_ 283 +#define IGNORE_ 284 +#define INTERLEAVE_ 285 +#define LIMITS_ 286 +#define LINES_ 287 +#define MAJOR_ 288 +#define MAP_ 289 +#define MINOR_ 290 +#define NAMES_ 291 +#define OFFSET_ 292 +#define OFFSETS_ 293 +#define ORDER_ 294 +#define PIXEL_ 295 +#define PIXELS_ 296 +#define PLOT_ 297 +#define PROJECTION_ 298 +#define RANGE_ 299 +#define REFLECTANCE_ 300 +#define SAMPLES_ 301 +#define SCALE_ 302 +#define SCANNER_ 303 +#define SENSOR_ 304 +#define SIZE_ 305 +#define START_ 306 +#define STRETCH_ 307 +#define TITLES_ 308 +#define TYPE_ 309 +#define UNITS_ 310 +#define VALUE_ 311 +#define VALUES_ 312 +#define WAVELENGTH_ 313 + + + + +/* Copy the first part of user declarations. */ +#line 10 "fitsy++/enviparser.Y" + +#define YYDEBUG 1 + +#define DISCARD_(x) {yyclearin; enviDiscard(x);} + +#include "file.h" + +#undef yyFlexLexer +#define yyFlexLexer enviFlexLexer +#include + +extern int envilex(void*, enviFlexLexer*); +extern void envierror(FitsFile*, enviFlexLexer*, const char*); +extern void enviDiscard(int); + +static int numWave; +static float wave[MAXWAVES]; + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 30 "fitsy++/enviparser.Y" +{ +#define ENVIPARSERSIZE 1024 + float real; + int integer; + char str[ENVIPARSERSIZE]; +} +/* Line 193 of yacc.c. */ +#line 247 "fitsy++/enviparser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 260 "fitsy++/enviparser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 202 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 70 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 28 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 77 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 200 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 313 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 66, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 63, 64, 2, 2, 69, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 65, + 2, 59, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 60, 61, + 62, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 67, 2, 68, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 4, 7, 11, 14, 15, 18, 20, + 22, 26, 30, 34, 38, 43, 49, 55, 56, 62, + 67, 71, 72, 78, 83, 88, 93, 98, 103, 108, + 113, 119, 125, 131, 137, 138, 145, 150, 155, 156, + 161, 165, 169, 175, 181, 190, 191, 195, 197, 199, + 201, 203, 205, 207, 209, 211, 213, 215, 217, 220, + 224, 227, 229, 233, 237, 239, 243, 247, 249, 268, + 269, 274, 277, 280, 284, 288, 291, 293 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 71, 0, -1, -1, 72, 73, -1, 73, 74, 81, + -1, 74, 81, -1, -1, 7, 83, -1, 79, -1, + 21, -1, 20, 59, 87, -1, 46, 59, 4, -1, + 32, 59, 4, -1, 12, 59, 4, -1, 27, 37, + 59, 4, -1, 33, 23, 38, 59, 91, -1, 35, + 23, 38, 59, 91, -1, -1, 24, 54, 59, 75, + 6, -1, 18, 54, 59, 84, -1, 30, 59, 85, + -1, -1, 49, 54, 59, 76, 6, -1, 17, 39, + 59, 86, -1, 60, 51, 59, 91, -1, 61, 51, + 59, 91, -1, 34, 28, 59, 93, -1, 43, 28, + 59, 87, -1, 19, 12, 59, 91, -1, 58, 55, + 59, 6, -1, 45, 47, 22, 59, 82, -1, 62, + 42, 44, 59, 89, -1, 62, 42, 10, 59, 89, + -1, 62, 42, 53, 59, 87, -1, -1, 18, 29, + 57, 59, 77, 6, -1, 40, 50, 59, 89, -1, + 11, 36, 59, 87, -1, -1, 58, 59, 78, 95, + -1, 25, 59, 87, -1, 13, 59, 87, -1, 18, + 26, 57, 59, 89, -1, 18, 37, 57, 59, 89, + -1, 48, 31, 63, 41, 64, 59, 4, 4, -1, + -1, 65, 80, 6, -1, 66, -1, 3, -1, 5, + -1, 4, -1, 8, -1, 9, -1, 4, -1, 16, + -1, 15, -1, 14, -1, 4, -1, 67, 68, -1, + 67, 88, 68, -1, 88, 6, -1, 6, -1, 67, + 90, 68, -1, 90, 69, 82, -1, 82, -1, 67, + 92, 68, -1, 92, 69, 4, -1, 4, -1, 67, + 6, 69, 4, 69, 4, 69, 82, 69, 82, 69, + 82, 69, 82, 69, 4, 94, 68, -1, -1, 69, + 6, 69, 6, -1, 69, 6, -1, 67, 68, -1, + 67, 96, 68, -1, 96, 69, 97, -1, 96, 69, + -1, 97, -1, 82, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 102, 102, 102, 104, 105, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 119, 120, + 121, 122, 122, 123, 124, 125, 126, 127, 128, 129, + 130, 131, 132, 133, 134, 134, 135, 136, 137, 137, + 138, 139, 140, 141, 142, 145, 145, 148, 149, 152, + 153, 156, 157, 160, 190, 191, 192, 195, 208, 209, + 212, 213, 216, 219, 220, 223, 226, 227, 230, 233, + 234, 235, 238, 244, 259, 260, 261, 264 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "EOF_", "INT", "REAL", "STRING", + "DEBUG_", "ON_", "OFF_", "AVERAGE_", "BAND_", "BANDS_", "BBL_", "BIL_", + "BIP_", "BSQ_", "BYTE_", "DATA_", "DEFAULT_", "DESCRIPTION_", "ENVI_", + "FACTOR_", "FRAME_", "FILE_", "FWHM_", "GAIN_", "HEADER_", "INFO_", + "IGNORE_", "INTERLEAVE_", "LIMITS_", "LINES_", "MAJOR_", "MAP_", + "MINOR_", "NAMES_", "OFFSET_", "OFFSETS_", "ORDER_", "PIXEL_", "PIXELS_", + "PLOT_", "PROJECTION_", "RANGE_", "REFLECTANCE_", "SAMPLES_", "SCALE_", + "SCANNER_", "SENSOR_", "SIZE_", "START_", "STRETCH_", "TITLES_", "TYPE_", + "UNITS_", "VALUE_", "VALUES_", "WAVELENGTH_", "'='", "'X'", "'Y'", "'Z'", + "'('", "')'", "';'", "'\\n'", "'{'", "'}'", "','", "$accept", "start", + "@1", "commands", "command", "@2", "@3", "@4", "@5", "comment", "@6", + "terminator", "numeric", "debug", "bitpix", "encoding", "endian", + "liststr", "strings", "listnum", "numerics", "listint", "ints", + "listmap", "listmapopt", "listwave", "aWaves", "aWave", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 61, + 88, 89, 90, 40, 41, 59, 10, 123, 125, 44 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 70, 72, 71, 73, 73, 74, 74, 74, 74, + 74, 74, 74, 74, 74, 74, 74, 75, 74, 74, + 74, 76, 74, 74, 74, 74, 74, 74, 74, 74, + 74, 74, 74, 74, 77, 74, 74, 74, 78, 74, + 74, 74, 74, 74, 74, 80, 79, 81, 81, 82, + 82, 83, 83, 84, 85, 85, 85, 86, 87, 87, + 88, 88, 89, 90, 90, 91, 92, 92, 93, 94, + 94, 94, 95, 95, 96, 96, 96, 97 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 2, 3, 2, 0, 2, 1, 1, + 3, 3, 3, 3, 4, 5, 5, 0, 5, 4, + 3, 0, 5, 4, 4, 4, 4, 4, 4, 4, + 5, 5, 5, 5, 0, 6, 4, 4, 0, 4, + 3, 3, 5, 5, 8, 0, 3, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 1, 3, 3, 1, 3, 3, 1, 18, 0, + 4, 2, 2, 3, 3, 2, 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 2, 0, 6, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 45, 6, 0, 8, 51, 52, 7, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 38, 0, 0, 0, 0, 0, 48, + 47, 5, 0, 13, 0, 41, 0, 0, 0, 0, + 0, 0, 10, 17, 40, 0, 56, 55, 54, 20, + 12, 0, 0, 0, 0, 0, 0, 11, 0, 21, + 0, 0, 0, 0, 0, 0, 0, 46, 4, 37, + 61, 58, 0, 57, 23, 0, 34, 0, 53, 19, + 0, 28, 0, 14, 0, 0, 26, 0, 0, 36, + 27, 0, 0, 0, 29, 0, 39, 24, 25, 0, + 0, 0, 60, 59, 42, 0, 43, 67, 0, 18, + 15, 0, 16, 50, 49, 64, 0, 30, 0, 22, + 72, 77, 0, 76, 32, 31, 33, 35, 65, 0, + 0, 62, 0, 0, 73, 75, 66, 0, 63, 0, + 74, 0, 44, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 69, 0, 0, 71, 68, 0, 70 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 1, 2, 32, 33, 122, 133, 145, 101, 34, + 67, 71, 161, 37, 119, 89, 114, 75, 112, 129, + 156, 121, 148, 126, 195, 136, 162, 163 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -126 +static const yytype_int16 yypact[] = +{ + -126, 24, 68, -126, -1, 1, -6, -3, 6, -14, + 50, 40, -126, 12, 45, 46, 51, 53, 82, 81, + 92, 69, 90, 73, 63, 93, 67, -9, 72, 74, + 85, -126, 9, -2, -126, -126, -126, -126, 75, 127, + 65, 76, 79, 80, 83, 84, 86, 65, 87, 65, + 88, 62, 134, 101, 89, 103, 91, 94, 120, 140, + 95, 96, 97, -126, 98, 100, 7, 143, -2, -126, + -126, -126, 65, -126, 4, -126, 147, 102, 104, 105, + 148, 99, -126, -126, -126, 150, -126, -126, -126, -126, + -126, 106, 107, 108, 109, 65, 110, -126, 119, -126, + 156, 111, 99, 99, 112, 113, 114, -126, -126, -126, + -126, -126, 5, -126, -126, 109, -126, 109, -126, -126, + 164, -126, 169, -126, 99, 171, -126, 99, 14, -126, + -126, 14, 115, 174, -126, 0, -126, -126, -126, 109, + 109, 65, -126, -126, -126, 175, -126, -126, -37, -126, + -126, 116, -126, -126, -126, -126, 22, -126, 123, -126, + -126, -126, 28, -126, -126, -126, -126, -126, -126, 166, + 179, -126, 14, 180, -126, 14, -126, 117, -126, 183, + -126, 184, -126, 121, 14, 122, 14, 124, 14, 125, + 14, 126, 185, 128, 186, 130, 131, -126, 190, -126 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -126, -126, -126, -126, 167, -126, -126, -126, -126, -126, + -126, 133, -125, -126, -126, -126, -126, -47, -126, -33, + -126, -89, -126, -126, -126, -126, -126, 27 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -4 +static const yytype_int16 yytable[] = +{ + 82, 69, 84, 155, 153, 154, 157, 35, 36, -3, + 110, 142, 42, 137, 138, 43, 4, 104, 153, 154, + 5, 6, 7, 44, 3, 109, 8, 9, 10, 11, + 12, 168, 169, 13, 14, 150, 15, 38, 152, 16, + 45, 17, 18, 19, 20, 41, 62, 178, 130, 21, + 63, 105, 22, 39, 23, 24, 40, 25, 26, 185, + 106, 187, 46, 189, 70, 191, 48, 27, 160, 28, + 29, 30, 111, 143, 31, 4, 86, 87, 88, 5, + 6, 7, 144, 50, 146, 8, 9, 10, 11, 12, + 171, 172, 13, 14, 166, 15, 174, 175, 16, 47, + 17, 18, 19, 20, 49, 53, 164, 165, 21, 54, + 51, 22, 52, 23, 24, 55, 25, 26, 57, 56, + 58, 61, 59, 64, 60, 65, 27, 66, 28, 29, + 30, 73, 74, 31, 72, 76, 77, 78, 90, 91, + 79, 93, 96, 80, 97, 81, 83, 85, 92, 107, + 94, 113, 118, 95, 123, 99, 100, 102, 98, 103, + 132, 115, 134, 116, 117, 124, 120, 127, 147, 131, + 176, 139, 140, 141, 125, 149, 128, 151, 135, 158, + 159, 167, 173, 177, 179, 170, 181, 182, 183, 193, + 184, 186, 196, 188, 190, 192, 199, 194, 197, 68, + 198, 108, 180 +}; + +static const yytype_uint8 yycheck[] = +{ + 47, 3, 49, 128, 4, 5, 131, 8, 9, 0, + 6, 6, 26, 102, 103, 29, 7, 10, 4, 5, + 11, 12, 13, 37, 0, 72, 17, 18, 19, 20, + 21, 68, 69, 24, 25, 124, 27, 36, 127, 30, + 54, 32, 33, 34, 35, 39, 55, 172, 95, 40, + 59, 44, 43, 59, 45, 46, 59, 48, 49, 184, + 53, 186, 12, 188, 66, 190, 54, 58, 68, 60, + 61, 62, 68, 68, 65, 7, 14, 15, 16, 11, + 12, 13, 115, 37, 117, 17, 18, 19, 20, 21, + 68, 69, 24, 25, 141, 27, 68, 69, 30, 59, + 32, 33, 34, 35, 59, 23, 139, 140, 40, 28, + 59, 43, 59, 45, 46, 23, 48, 49, 28, 50, + 47, 54, 59, 51, 31, 51, 58, 42, 60, 61, + 62, 4, 67, 65, 59, 59, 57, 57, 4, 38, + 57, 38, 22, 59, 4, 59, 59, 59, 59, 6, + 59, 4, 4, 59, 4, 59, 59, 59, 63, 59, + 41, 59, 6, 59, 59, 59, 67, 59, 4, 59, + 4, 59, 59, 59, 67, 6, 67, 6, 67, 64, + 6, 6, 59, 4, 4, 69, 69, 4, 4, 4, + 69, 69, 6, 69, 69, 69, 6, 69, 68, 32, + 69, 68, 175 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 71, 72, 0, 7, 11, 12, 13, 17, 18, + 19, 20, 21, 24, 25, 27, 30, 32, 33, 34, + 35, 40, 43, 45, 46, 48, 49, 58, 60, 61, + 62, 65, 73, 74, 79, 8, 9, 83, 36, 59, + 59, 39, 26, 29, 37, 54, 12, 59, 54, 59, + 37, 59, 59, 23, 28, 23, 50, 28, 47, 59, + 31, 54, 55, 59, 51, 51, 42, 80, 74, 3, + 66, 81, 59, 4, 67, 87, 59, 57, 57, 57, + 59, 59, 87, 59, 87, 59, 14, 15, 16, 85, + 4, 38, 59, 38, 59, 59, 22, 4, 63, 59, + 59, 78, 59, 59, 10, 44, 53, 6, 81, 87, + 6, 68, 88, 4, 86, 59, 59, 59, 4, 84, + 67, 91, 75, 4, 59, 67, 93, 59, 67, 89, + 87, 59, 41, 76, 6, 67, 95, 91, 91, 59, + 59, 59, 6, 68, 89, 77, 89, 4, 92, 6, + 91, 6, 91, 4, 5, 82, 90, 82, 64, 6, + 68, 82, 96, 97, 89, 89, 87, 6, 68, 69, + 69, 68, 69, 59, 68, 69, 4, 4, 82, 4, + 97, 69, 4, 4, 69, 82, 69, 82, 69, 82, + 69, 82, 69, 4, 69, 94, 6, 68, 69, 6 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (envi, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, envi, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, FitsFile* envi, enviFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, envi, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + FitsFile* envi; + enviFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (envi); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, FitsFile* envi, enviFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, envi, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + FitsFile* envi; + enviFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, envi, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, FitsFile* envi, enviFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, envi, ll) + YYSTYPE *yyvsp; + int yyrule; + FitsFile* envi; + enviFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , envi, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, envi, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, FitsFile* envi, enviFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, envi, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + FitsFile* envi; + enviFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (envi); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (FitsFile* envi, enviFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (FitsFile* envi, enviFlexLexer* ll) +#else +int +yyparse (envi, ll) + FitsFile* envi; + enviFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 102 "fitsy++/enviparser.Y" + {envi->setpArch(FitsFile::BIG);} + break; + + case 11: +#line 113 "fitsy++/enviparser.Y" + {envi->setpWidth((yyvsp[(3) - (3)].integer));;} + break; + + case 12: +#line 114 "fitsy++/enviparser.Y" + {envi->setpHeight((yyvsp[(3) - (3)].integer));;} + break; + + case 13: +#line 115 "fitsy++/enviparser.Y" + {envi->setpDepth((yyvsp[(3) - (3)].integer));;} + break; + + case 14: +#line 116 "fitsy++/enviparser.Y" + {envi->setpSkip((yyvsp[(4) - (4)].integer));;} + break; + + case 17: +#line 119 "fitsy++/enviparser.Y" + {DISCARD_(1);} + break; + + case 21: +#line 122 "fitsy++/enviparser.Y" + {DISCARD_(1);} + break; + + case 34: +#line 134 "fitsy++/enviparser.Y" + {DISCARD_(1);} + break; + + case 38: +#line 137 "fitsy++/enviparser.Y" + {numWave=0;;} + break; + + case 45: +#line 145 "fitsy++/enviparser.Y" + {DISCARD_(1);} + break; + + case 48: +#line 149 "fitsy++/enviparser.Y" + {YYACCEPT;;} + break; + + case 49: +#line 152 "fitsy++/enviparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 50: +#line 153 "fitsy++/enviparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].integer);;} + break; + + case 51: +#line 156 "fitsy++/enviparser.Y" + {yydebug=1;;} + break; + + case 52: +#line 157 "fitsy++/enviparser.Y" + {yydebug=0;;} + break; + + case 53: +#line 161 "fitsy++/enviparser.Y" + { + switch((yyvsp[(1) - (1)].integer)) { + case 1: + {envi->setpBitpix(8);} + break; + case 2: + {envi->setpBitpix(16);} + break; + case 12: + {envi->setpBitpix(-16);} + break; + case 3: + {envi->setpBitpix(32);} + break; + case 14: + {envi->setpBitpix(64);} + break; + case 4: + {envi->setpBitpix(-32);} + break; + case 5: + {envi->setpBitpix(-64);} + break; + default: + break; + } + ;} + break; + + case 54: +#line 190 "fitsy++/enviparser.Y" + {envi->setpEncoding(FitsFile::BSQ);;} + break; + + case 55: +#line 191 "fitsy++/enviparser.Y" + {envi->setpEncoding(FitsFile::BIP);;} + break; + + case 56: +#line 192 "fitsy++/enviparser.Y" + {envi->setpEncoding(FitsFile::BIL);;} + break; + + case 57: +#line 196 "fitsy++/enviparser.Y" + { + switch((yyvsp[(1) - (1)].integer)) { + case 0: + {envi->setpArch(FitsFile::LITTLE);} + break; + case 1: + {envi->setpArch(FitsFile::BIG);} + break; + } + ;} + break; + + case 72: +#line 239 "fitsy++/enviparser.Y" + { + envi->setpCRPIX3(1); + envi->setpCRVAL3(1); + envi->setpCDELT3(1); + ;} + break; + + case 73: +#line 245 "fitsy++/enviparser.Y" + { + if (numWave>=2) { + envi->setpCRPIX3(1); + envi->setpCRVAL3(wave[0]); + envi->setpCDELT3((wave[numWave-1]-wave[0])/(numWave-1)); + } + else { + envi->setpCRPIX3(1); + envi->setpCRVAL3(1); + envi->setpCDELT3(1); + } + ;} + break; + + case 77: +#line 265 "fitsy++/enviparser.Y" + { + if (numWave < MAXWAVES) + wave[numWave++] = (yyvsp[(1) - (1)].real); + ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1802 "fitsy++/enviparser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (envi, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (envi, ll, yymsg); + } + else + { + yyerror (envi, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, envi, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, envi, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (envi, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, envi, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, envi, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 271 "fitsy++/enviparser.Y" + + diff --git a/tksao/fitsy++/enviparser.H b/tksao/fitsy++/enviparser.H new file mode 100644 index 0000000..7bbd68d --- /dev/null +++ b/tksao/fitsy++/enviparser.H @@ -0,0 +1,179 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + EOF_ = 258, + INT = 259, + REAL = 260, + STRING = 261, + DEBUG_ = 262, + ON_ = 263, + OFF_ = 264, + AVERAGE_ = 265, + BAND_ = 266, + BANDS_ = 267, + BBL_ = 268, + BIL_ = 269, + BIP_ = 270, + BSQ_ = 271, + BYTE_ = 272, + DATA_ = 273, + DEFAULT_ = 274, + DESCRIPTION_ = 275, + ENVI_ = 276, + FACTOR_ = 277, + FRAME_ = 278, + FILE_ = 279, + FWHM_ = 280, + GAIN_ = 281, + HEADER_ = 282, + INFO_ = 283, + IGNORE_ = 284, + INTERLEAVE_ = 285, + LIMITS_ = 286, + LINES_ = 287, + MAJOR_ = 288, + MAP_ = 289, + MINOR_ = 290, + NAMES_ = 291, + OFFSET_ = 292, + OFFSETS_ = 293, + ORDER_ = 294, + PIXEL_ = 295, + PIXELS_ = 296, + PLOT_ = 297, + PROJECTION_ = 298, + RANGE_ = 299, + REFLECTANCE_ = 300, + SAMPLES_ = 301, + SCALE_ = 302, + SCANNER_ = 303, + SENSOR_ = 304, + SIZE_ = 305, + START_ = 306, + STRETCH_ = 307, + TITLES_ = 308, + TYPE_ = 309, + UNITS_ = 310, + VALUE_ = 311, + VALUES_ = 312, + WAVELENGTH_ = 313 + }; +#endif +/* Tokens. */ +#define EOF_ 258 +#define INT 259 +#define REAL 260 +#define STRING 261 +#define DEBUG_ 262 +#define ON_ 263 +#define OFF_ 264 +#define AVERAGE_ 265 +#define BAND_ 266 +#define BANDS_ 267 +#define BBL_ 268 +#define BIL_ 269 +#define BIP_ 270 +#define BSQ_ 271 +#define BYTE_ 272 +#define DATA_ 273 +#define DEFAULT_ 274 +#define DESCRIPTION_ 275 +#define ENVI_ 276 +#define FACTOR_ 277 +#define FRAME_ 278 +#define FILE_ 279 +#define FWHM_ 280 +#define GAIN_ 281 +#define HEADER_ 282 +#define INFO_ 283 +#define IGNORE_ 284 +#define INTERLEAVE_ 285 +#define LIMITS_ 286 +#define LINES_ 287 +#define MAJOR_ 288 +#define MAP_ 289 +#define MINOR_ 290 +#define NAMES_ 291 +#define OFFSET_ 292 +#define OFFSETS_ 293 +#define ORDER_ 294 +#define PIXEL_ 295 +#define PIXELS_ 296 +#define PLOT_ 297 +#define PROJECTION_ 298 +#define RANGE_ 299 +#define REFLECTANCE_ 300 +#define SAMPLES_ 301 +#define SCALE_ 302 +#define SCANNER_ 303 +#define SENSOR_ 304 +#define SIZE_ 305 +#define START_ 306 +#define STRETCH_ 307 +#define TITLES_ 308 +#define TYPE_ 309 +#define UNITS_ 310 +#define VALUE_ 311 +#define VALUES_ 312 +#define WAVELENGTH_ 313 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 30 "fitsy++/enviparser.Y" +{ +#define ENVIPARSERSIZE 1024 + float real; + int integer; + char str[ENVIPARSERSIZE]; +} +/* Line 1529 of yacc.c. */ +#line 172 "fitsy++/enviparser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/fitsy++/enviparser.Y b/tksao/fitsy++/enviparser.Y new file mode 100644 index 0000000..8b768ee --- /dev/null +++ b/tksao/fitsy++/enviparser.Y @@ -0,0 +1,271 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {FitsFile* envi} +%lex-param {enviFlexLexer* ll} +%parse-param {enviFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#define DISCARD_(x) {yyclearin; enviDiscard(x);} + +#include "file.h" + +#undef yyFlexLexer +#define yyFlexLexer enviFlexLexer +#include + +extern int envilex(void*, enviFlexLexer*); +extern void envierror(FitsFile*, enviFlexLexer*, const char*); +extern void enviDiscard(int); + +static int numWave; +static float wave[MAXWAVES]; + +%} + +%union { +#define ENVIPARSERSIZE 1024 + float real; + int integer; + char str[ENVIPARSERSIZE]; +} + +%type numeric + + // Basic +%token EOF_ +%token INT +%token REAL +%token STRING + +%token DEBUG_ +%token ON_ +%token OFF_ + +%token AVERAGE_ +%token BAND_ +%token BANDS_ +%token BBL_ +%token BIL_ +%token BIP_ +%token BSQ_ +%token BYTE_ +%token DATA_ +%token DEFAULT_ +%token DESCRIPTION_ +%token ENVI_ +%token FACTOR_ +%token FRAME_ +%token FILE_ +%token FWHM_ +%token GAIN_ +%token HEADER_ +%token INFO_ +%token IGNORE_ +%token INTERLEAVE_ +%token LIMITS_ +%token LINES_ +%token MAJOR_ +%token MAP_ +%token MINOR_ +%token NAMES_ +%token OFFSET_ +%token OFFSETS_ +%token ORDER_ +%token PIXEL_ +%token PIXELS_ +%token PLOT_ +%token PROJECTION_ +%token RANGE_ +%token REFLECTANCE_ +%token SAMPLES_ +%token SCALE_ +%token SCANNER_ +%token SENSOR_ +%token SIZE_ +%token START_ +%token STRETCH_ +%token TITLES_ +%token TYPE_ +%token UNITS_ +%token VALUE_ +%token VALUES_ +%token WAVELENGTH_ + +%% + + //start : {yydebug=1;} commands + start : {envi->setpArch(FitsFile::BIG)} commands + +commands: commands command terminator + | command terminator + ; + +command : /* empty */ + | DEBUG_ debug + | comment + | ENVI_ + | DESCRIPTION_ '=' liststr + | SAMPLES_ '=' INT {envi->setpWidth($3);} + | LINES_ '=' INT {envi->setpHeight($3);} + | BANDS_ '=' INT {envi->setpDepth($3);} + | HEADER_ OFFSET_ '=' INT {envi->setpSkip($4);} + | MAJOR_ FRAME_ OFFSETS_ '=' listint + | MINOR_ FRAME_ OFFSETS_ '=' listint + | FILE_ TYPE_ '=' {DISCARD_(1)} STRING + | DATA_ TYPE_ '=' bitpix + | INTERLEAVE_ '=' encoding + | SENSOR_ TYPE_ '=' {DISCARD_(1)} STRING + | BYTE_ ORDER_ '=' endian + | 'X' START_ '=' listint + | 'Y' START_ '=' listint + | MAP_ INFO_ '=' listmap + | PROJECTION_ INFO_ '=' liststr + | DEFAULT_ BANDS_ '=' listint + | WAVELENGTH_ UNITS_ '=' STRING + | REFLECTANCE_ SCALE_ FACTOR_ '=' numeric + | 'Z' PLOT_ RANGE_ '=' listnum + | 'Z' PLOT_ AVERAGE_ '=' listnum + | 'Z' PLOT_ TITLES_ '=' liststr + | DATA_ IGNORE_ VALUES_ '=' {DISCARD_(1)} STRING + | PIXEL_ SIZE_ '=' listnum + | BAND_ NAMES_ '=' liststr + | WAVELENGTH_ '=' {numWave=0;} listwave + | FWHM_ '=' liststr + | BBL_ '=' liststr + | DATA_ GAIN_ VALUES_ '=' listnum + | DATA_ OFFSET_ VALUES_ '=' listnum + | SCANNER_ LIMITS_ '(' PIXELS_ ')' '=' INT INT + ; + +comment : ';' {DISCARD_(1)} STRING + ; + +terminator: '\n' + | EOF_ {YYACCEPT;} + ; + +numeric : REAL {$$=$1;} + | INT {$$=$1;} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + ; + +bitpix : INT + { + switch($1) { + case 1: + {envi->setpBitpix(8);} + break; + case 2: + {envi->setpBitpix(16);} + break; + case 12: + {envi->setpBitpix(-16);} + break; + case 3: + {envi->setpBitpix(32);} + break; + case 14: + {envi->setpBitpix(64);} + break; + case 4: + {envi->setpBitpix(-32);} + break; + case 5: + {envi->setpBitpix(-64);} + break; + default: + break; + } + } + ; + +encoding : BSQ_ {envi->setpEncoding(FitsFile::BSQ);} + | BIP_ {envi->setpEncoding(FitsFile::BIP);} + | BIL_ {envi->setpEncoding(FitsFile::BIL);} + ; + +endian : INT + { + switch($1) { + case 0: + {envi->setpArch(FitsFile::LITTLE);} + break; + case 1: + {envi->setpArch(FitsFile::BIG);} + break; + } + } + ; + +liststr : '{' '}' + | '{' strings '}' + ; + +strings : strings STRING + | STRING + ; + +listnum : '{' numerics '}' + ; + +numerics: numerics ',' numeric + | numeric + ; + +listint : '{' ints '}' + ; + +ints : ints ',' INT + | INT + ; + +listmap : '{' STRING ',' INT ',' INT ',' numeric ',' numeric ',' numeric ',' numeric ',' INT listmapopt '}' + ; + +listmapopt : /* empty */ + | ',' STRING ',' STRING + | ',' STRING + ; + +listwave: '{' '}' + { + envi->setpCRPIX3(1); + envi->setpCRVAL3(1); + envi->setpCDELT3(1); + } + | '{' aWaves '}' + { + if (numWave>=2) { + envi->setpCRPIX3(1); + envi->setpCRVAL3(wave[0]); + envi->setpCDELT3((wave[numWave-1]-wave[0])/(numWave-1)); + } + else { + envi->setpCRPIX3(1); + envi->setpCRVAL3(1); + envi->setpCDELT3(1); + } + } + ; + +aWaves : aWaves ',' aWave + | aWaves ',' + | aWave + ; + +aWave : numeric + { + if (numWave < MAXWAVES) + wave[numWave++] = $1; + } + ; + +%% diff --git a/tksao/fitsy++/file.C b/tksao/fitsy++/file.C new file mode 100644 index 0000000..3c28fd1 --- /dev/null +++ b/tksao/fitsy++/file.C @@ -0,0 +1,517 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include +using namespace std; + +#include "file.h" + +// extention parser +#undef yyFlexLexer +#define yyFlexLexer ffFlexLexer +#include + +void* fflval; +ffFlexLexer* fflexx; +extern int ffparse(FitsFile*, ffFlexLexer*); + +int fflex(void* vval, ffFlexLexer* ll) +{ + fflval = vval; + fflexx = ll; + return ll ? ll->yylex() : 0; +} + +void fferror(FitsFile* ff, ffFlexLexer* ll, const char* m) +{ + ff->error(m); + const char* cmd = ll ? ll->YYText() : (const char*)NULL; + if (cmd && cmd[0] != '\n') + ff->error(cmd); +} + +// nrrd parser +#undef yyFlexLexer +#define yyFlexLexer nrrdFlexLexer +#include + +void* nrrdlval; +nrrdFlexLexer* nrrdlexx; +extern int nrrdparse(FitsFile*, nrrdFlexLexer*); + +int nrrdlex(void* vval, nrrdFlexLexer* ll) +{ + nrrdlval = vval; + nrrdlexx = ll; + return ll ? ll->yylex() : 0; +} + +void nrrderror(FitsFile* nrrd, nrrdFlexLexer* ll, const char* m) +{ + nrrd->error(m); + const char* cmd = ll ? ll->YYText() : (const char*)NULL; + if (cmd && cmd[0] != '\n') + nrrd->error(cmd); +} + +// envi parser +#undef yyFlexLexer +#define yyFlexLexer enviFlexLexer +#include + +void* envilval; +enviFlexLexer* envilexx; +extern int enviparse(FitsFile*, enviFlexLexer*); + +int envilex(void* vval, enviFlexLexer* ll) +{ + envilval = vval; + envilexx = ll; + return ll ? ll->yylex() : 0; +} + +void envierror(FitsFile* envi, enviFlexLexer* ll, const char* m) +{ + envi->error(m); + const char* cmd = ll ? ll->YYText() : (const char*)NULL; + if (cmd && cmd[0] != '\n') + envi->error(cmd); +} + +FitsFile::FitsFile() +{ + primary_ = NULL; + managePrimary_ = 0; + + head_ = NULL; + manageHead_ = 1; + + data_ = NULL; + dataSize_ = 0; + dataSkip_ = 0; + + ext_ = 0; + inherit_ = 0; + byteswap_ = lsb(); + endian_ = BIG; + valid_ = 0; + + pName_ = NULL; + pExt_ = NULL; + pIndex_ = -1; + + pFilter_ = NULL; + pBinX_ = NULL; + pBinY_ = NULL; + pBinZ_ = NULL; + + pBitpix_ =0; + pWidth_ =0; + pHeight_ =0; + pDepth_ =1; + pSkip_ =0; + pArch_ =NATIVE; + + pEncoding_ =RAW; + + pHPXOrder_ =-1; + pHPXSystem_ =-1; + pHPXLayout_ =-1; + pHPXColumn_ =-1; + pHPXQuad_ =-1; + + pCRPIX3_ =1; + pCRVAL3_ =1; + pCDELT3_ =1; + + pcoord_ =0; + pxvalid_ =0; + pxmin_ =0; + pxmax_ =0; + pyvalid_ =0; + pymin_ =0; + pymax_ =0; + pzvalid_ =0; + pzmin_ =0; + pzmax_ =0; + pbvalid_ =0; + pblock_ =1; +} + +FitsFile::~FitsFile() +{ + if (manageHead_ && head_) + delete head_; + + if (managePrimary_ && primary_) + delete primary_; + + if (pName_) + delete [] pName_; + + if (pExt_) + delete [] pExt_; + + if (pFilter_) + delete [] pFilter_; + + if (pBinX_) + delete [] pBinX_; + + if (pBinY_) + delete [] pBinY_; + + if (pBinZ_) + delete [] pBinZ_; +} + +void FitsFile::parse(const char* fn) +{ + if (fn) { + string x(fn); + istringstream str(x); + + valid_ = 1; + ffFlexLexer* ll = new ffFlexLexer(&str); + ffparse(this, ll); + delete ll; + } + + if (!pBinX_ && !pBinY_) { + char *env; + if ((env = getenv("DS9_BINKEY"))) { + string x(env); + istringstream str(x); + + valid_ = 1; + ffFlexLexer* ll = new ffFlexLexer(&str); + ffparse(this, ll); + delete ll; + } + } + + if (!pWidth_ && !pHeight_ && !pBitpix_) { + char *env; + if ((env = getenv("DS9_ARRAY"))) { + string x(env); + istringstream str(x); + + valid_ = 1; + ffFlexLexer* ll = new ffFlexLexer(&str); + ffparse(this, ll); + delete ll; + } + } +} + +void FitsFile::error(const char* m) +{ + valid_ = 0; + // cerr << m << endl; +} + +int FitsFile::findEnd(const char* blk) +{ + for (int j=0; jhdu()); + FitsColumn* col = hdu->find(name); + if (col) { + if (!col->hasMinMax()) { + double zmin = DBL_MAX; + double zmax = -DBL_MAX; + int rowlen = hdu->width(); + int numrow = hdu->rows(); + + char* ptr = (char*)data(); + for (int i=0; ivalue(ptr); + if (z < zmin) + zmin = z; + if (z > zmax) + zmax = z; + } + // for memory models that support internal paging + resetpage(); + + col->setMin(zmin); + col->setMax(zmax); + return Vector(zmin,zmax); + } + else + return Vector(col->getMin(), col->getMax()); + } + } + return Vector(); +} + +void FitsFile::setColMinMax(const char* name, const Vector& lim) +{ + if (isBinTable()) { + FitsTableHDU* hdu = (FitsTableHDU*)(head()->hdu()); + FitsColumn* col = hdu->find(name); + if (col) { + Vector ll=lim; + col->setMin(ll[0]); + col->setMax(ll[1]); + } + } +} + +Vector FitsFile::getColDim(const char* name) +{ + if (isBinTable()) { + FitsTableHDU* hdu = (FitsTableHDU*)(head()->hdu()); + FitsColumn* col = hdu->find(name); + if (col) { + if (col->hasTLMinTLMax()) { + Vector lim = col->dimension(); + col->setMin(lim[0]); + col->setMax(lim[1]); + return lim; + } + else + return getColMinMax(name); + } + } + + return Vector(); +} + +int FitsFile::validParams() +{ + if (!pWidth_ || !pHeight_ || !pBitpix_) + return 0; + + // check for valid bitpix + switch (pBitpix_) { + case 8: + case 16: + case -16: + case 32: + case 64: + case -32: + case -64: + break; + default: + return 0; + } + + return 1; +} + +void FitsFile::setByteSwap() +{ + switch (pArch_) { + case BIG: + endian_ = pArch_; + byteswap_ = lsb(); + break; + case LITTLE: + endian_ = pArch_; + byteswap_ = !lsb(); + break; + case NATIVE: + endian_ = lsb() ? LITTLE : BIG; + byteswap_ = 0; + break; + } +} + +void FitsFile::parseNRRD(istream& str) +{ + valid_ = 1; + nrrdFlexLexer* ll = new nrrdFlexLexer(&str); + nrrdparse(this, ll); + delete ll; +} + +void FitsFile::parseENVI(istream& str) +{ + valid_ = 1; + enviFlexLexer* ll = new enviFlexLexer(&str); + enviparse(this, ll); + delete ll; +} + +int FitsFile::find(const char* name) +{ + if (head_) { + if (head_->find(name)) + return 1; + else + if (primary_ && inherit_) + if (primary_->find(name)) + return 1; + } + + return 0; +} + +int FitsFile::getLogical(const char* name, int def) +{ + if (head_) { + int r = head_->getLogical(name,def); + if (r != def) + return r; + else + if (primary_ && inherit_) + return primary_->getLogical(name,def); + } + + return def; +} + +int FitsFile::getInteger(const char* name, int def) +{ + if (head_) { + int r = head_->getInteger(name,def); + if (r != def) + return r; + else + if (primary_ && inherit_) + return primary_->getInteger(name,def); + } + + return def; +} + +double FitsFile::getReal(const char* name, double def) +{ + if (head_) { + double r = head_->getReal(name,def); + if (r != def) + return r; + else + if (primary_ && inherit_) + return primary_->getReal(name,def); + } + + return def; +} + +void FitsFile::getComplex(const char* name, double* real, double* img, + double rdef, double idef) +{ + if (head_) { + head_->getComplex(name, real, img, rdef, idef); + if (*real != rdef || *img != idef) + return; + else + if (primary_ && inherit_) { + primary_->getComplex(name, real, img, rdef, idef); + return; + } + } + + *real = rdef; + *img = idef; +} + +char* FitsFile::getString(const char* name) +{ + if (head_) { + char* r = head_->getString(name); + if (r) + return r; + else + if (primary_ && inherit_) + return primary_->getString(name); + } + + return NULL; +} + +char* FitsFile::getComment(const char* name) +{ + if (head_) { + char* r = head_->getComment(name); + if (r) + return r; + else + if (primary_ && inherit_) + return primary_->getComment(name); + } + + return NULL; +} + +char* FitsFile::getKeyword(const char* name) +{ + if (head_) { + char* r = head_->getKeyword(name); + if (r) + return r; + else + if (primary_ && inherit_) + return primary_->getKeyword(name); + } + + return NULL; +} + + + diff --git a/tksao/fitsy++/file.h b/tksao/fitsy++/file.h new file mode 100644 index 0000000..2c49896 --- /dev/null +++ b/tksao/fitsy++/file.h @@ -0,0 +1,230 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsfile_h__ +#define __fitsfile_h__ + +#include "head.h" + +#define B4KB 4096 +#define B1MB 1048576 +#define MAXWAVES 2048 + +extern int DebugGZ; +extern int DebugCompress; + +class OutFitsStream; + +class FitsFile { +public: + enum FlushMode {NOFLUSH,FLUSH}; + enum ScanMode {RELAX, EXACT}; + enum ArchType {NATIVE,BIG,LITTLE}; + enum EncodingType {RAW,ASCII,HEX,GZIP,BZ2,BIP,BIL,BSQ}; + +protected: + FitsHead* primary_; // pointer to primary header + int managePrimary_; // flag, true if we manage primary header + + FitsHead* head_; // pointer to header + int manageHead_; // flag, true if we manage header + + void* data_; // pointer to raw data + size_t dataSize_; // size of data memory segment + size_t dataSkip_; // skip into data memory segment + + int ext_; // extension number + int inherit_; // do we have inheritence? + int byteswap_; // flag, true if byteswap is needed + ArchType endian_; // endian of data + int valid_; // flag, true if file is valid + + char* pName_; // parsed file name + char* pExt_; // parsed ext name + int pIndex_; // parsed ext number + + char* pFilter_; // unparsed filter spec + char* pBinX_; // parsed bin table x col name + char* pBinY_; // parsed bin table y col name + char* pBinZ_; // parsed bin table z col name + + int pBitpix_; // parsed bitpix + int pWidth_; // parsed width + int pHeight_; // parsed height + int pDepth_; // parsed depth + size_t pSkip_; // parsed skip size + ArchType pArch_; // parsed arch type + EncodingType pEncoding_; // parsed encoding + + int pHPXOrder_; // parsed HPX params + int pHPXSystem_; + int pHPXLayout_; + int pHPXColumn_; + int pHPXQuad_; + + double pCRPIX3_; // WCS_3 axis params + double pCRVAL3_; + double pCDELT3_; + + int pcoord_; + int pxvalid_; + int pxmin_; + int pxmax_; + int pyvalid_; + int pymin_; + int pymax_; + int pzvalid_; + int pzmin_; + int pzmax_; + int pbvalid_; + int pblock_; + +protected: + void parse(const char*); + void parseNRRD(istream&); + void parseENVI(istream&); + int validParams(); + int findEnd(const char*); + void setByteSwap(); + +public: + FitsFile(); + virtual ~FitsFile(); + + int manageHead() {return manageHead_;} + + virtual void done() {} + virtual char* page(char* ptr, size_t r) {return ptr;} + virtual void resetpage() {} + void error(const char*); + void* data() {return data_;} + size_t dataSize() {return dataSize_;} + size_t dataSkip() {return dataSkip_;} + FitsHead* head() {return head_;} + FitsHead* primary() {return primary_;} + int ext() {return ext_;} + const char* extname() {return head_ ? head_->extname() : NULL;} + int inherit() {return inherit_;} + void setValid(int vv) {valid_=vv;} + int isValid() {return valid_;} + int isImage() {return head_ ? head_->isImage() : 0;} + int isTable() {return head_ ? head_->isTable() : 0;} + int isAsciiTable() {return head_ ? head_->isAsciiTable() : 0;} + int isBinTable() {return head_ ? head_->isBinTable() : 0;} + int byteswap() {return byteswap_;} + ArchType endian() {return endian_;} + + void setpName(const char*); + void setpExt(const char*); + void setpIndex(int i) {pIndex_ = i;} + void setpFilter(const char*); + void setpBinX(const char*); + void setpBinY(const char*); + void setpBinZ(const char*); + void setpBinXY(const char* x, const char* y) + {setpBinX(x); setpBinY(y);} + void setpBinXYZ(const char* x, const char* y, const char* z) + {setpBinX(x); setpBinY(y); setpBinZ(z);} + + const char* pName() {return pName_;} + const char* pExt() {return pExt_;} + int pIndex() {return pIndex_;} + + const char* pFilter() {return pFilter_;} + const char* pBinX() {return pBinX_;} + const char* pBinY() {return pBinY_;} + const char* pBinZ() {return pBinZ_;} + + int pBitpix() {return pBitpix_;} + int pWidth() {return pWidth_;} + int pHeight() {return pHeight_;} + int pDepth() {return pDepth_;} + size_t pSkip() {return pSkip_;} + ArchType pArch() {return pArch_;} + + void setpWidth(int i) {pWidth_ = i;} + void setpHeight(int i) {pHeight_ = i;} + void setpDepth(int i) {pDepth_ = i;} + void setpBitpix(int b) {pBitpix_ = b;} + void setpSkip(size_t s) {pSkip_ = s;} + void setpArch(ArchType a) {pArch_ = a;} + + EncodingType pEncoding() {return pEncoding_;} + void setpEncoding(EncodingType e) {pEncoding_ = e;} + + int pHPXOrder() {return pHPXOrder_;} + int pHPXSystem() {return pHPXSystem_;} + int pHPXLayout() {return pHPXLayout_;} + int pHPXColumn() {return pHPXColumn_;} + int pHPXQuad() {return pHPXQuad_;} + + void setpHPXOrder(int oo) {pHPXOrder_ = oo;} + void setpHPXSystem(int ss) {pHPXSystem_ = ss;} + void setpHPXLayout(int ll) {pHPXLayout_ = ll;} + void setpHPXColumn(int cc) {pHPXColumn_ = cc-1;} + void setpHPXQuad(int qq) {pHPXQuad_ = qq-1;} + + double pCRPIX3() {return pCRPIX3_;} + double pCRVAL3() {return pCRVAL3_;} + double pCDELT3() {return pCDELT3_;} + + void setpCRPIX3(double dd) {pCRPIX3_ = dd;} + void setpCRVAL3(double dd) {pCRVAL3_ = dd;} + void setpCDELT3(double dd) {pCDELT3_ = dd;} + + int pcoord() {return pcoord_;} + int pxvalid() {return pxvalid_;} + int pxmin() {return pxmin_;} + int pxmax() {return pxmax_;} + int pyvalid() {return pyvalid_;} + int pymin() {return pymin_;} + int pymax() {return pymax_;} + int pzvalid() {return pzvalid_;} + int pzmin() {return pzmin_;} + int pzmax() {return pzmax_;} + int pbvalid() {return pbvalid_;} + int pblock() {return pblock_;} + + void setpcoord(int vv) {pcoord_ = vv;} + void setpxvalid(int vv) {pxvalid_ = vv;} + void setpxmin(int vv) {pxmin_ = vv;} + void setpxmax(int vv) {pxmax_ = vv;} + void setpyvalid(int vv) {pyvalid_ = vv;} + void setpymin(int vv) {pymin_ = vv;} + void setpymax(int vv) {pymax_ = vv;} + void setpzvalid(int vv) {pzvalid_ = vv;} + void setpzmin(int vv) {pzmin_ = vv;} + void setpzmax(int vv) {pzmax_ = vv;} + void setpbvalid(int vv) {pbvalid_ = vv;} + void setpblock(int vv) {pblock_ = vv;} + + Vector getColMinMax(const char*); + Vector getColDim(const char*); + + void setColMinMax(const char*, const Vector&); + + int find(const char* name); + + int getLogical(const char* name, int def); + int getInteger(const char* name, int def); + double getReal(const char* name, double def); + void getComplex(const char* name, double* real, double* img, + double rdef, double idef); + char* getString(const char* name); + char* getComment(const char* name); + char* getKeyword(const char* name); + + int saveFitsPrimHeader(OutFitsStream&); + int saveFitsHeader(OutFitsStream&, int); + int saveFitsXtHeader(OutFitsStream&, int); + int saveFits(OutFitsStream&); + int saveFitsPad(OutFitsStream&, size_t, char); + int saveFitsTable(OutFitsStream&); + int saveFitsIISHeader(OutFitsStream&); + int saveFitsIIS(OutFitsStream&, Vector&); + + int saveArray(OutFitsStream&, ArchType); +}; + +#endif diff --git a/tksao/fitsy++/gzip.C b/tksao/fitsy++/gzip.C new file mode 100644 index 0000000..6f83af6 --- /dev/null +++ b/tksao/fitsy++/gzip.C @@ -0,0 +1,339 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include +using namespace std; + +#include "gzip.h" +#include "zlib.h" +#include "util.h" + +template FitsGzipm::FitsGzipm(FitsFile* fits) + : FitsCompressm(fits) +{ + FitsCompressm::uncompress(fits); +} + +template int FitsGzipm::compressed(T* dest, char* sptr, + char* heap, + int kkstart, int kkstop, + int jjstart, int jjstop, + int iistart, int iistop) +{ + double zs = FitsCompressm::bscale_; + if (FitsCompressm::zscale_) + zs = FitsCompressm::zscale_->value(sptr,0); + + double zz = FitsCompressm::bzero_; + if (FitsCompressm::zzero_) + zz = FitsCompressm::zzero_->value(sptr,0); + + int blank = FitsCompressm::blank_; + if (FitsCompressm::zblank_) + blank = (int)FitsCompressm::zblank_->value(sptr,0); + + int icnt=0; + unsigned char* ibuf = (unsigned char*)((FitsBinColumnArray*)FitsCompressm::compress_)->get(heap, sptr, &icnt); + + // ibuf can be NULL + if (!ibuf || !icnt) + return 0; + + int ocnt = FitsCompressm::tilesize_; + char* obuf = new char[ocnt*sizeof(long long)]; + if (!obuf) { + internalError("Fitsy++ gzip unable to alloc."); + return 0; + } + + z_stream zstrm; + zstrm.next_in = NULL; + zstrm.avail_in = 0; + zstrm.zalloc = NULL; + zstrm.zfree = NULL; + zstrm.opaque = NULL; + + // look for both zlib and gzip headers + if (inflateInit2(&zstrm, MAX_WBITS+32) != Z_OK) { + internalError("Fitsy++ gzip inflateInit error"); + if (obuf) + delete [] obuf; + return 0; + } + + zstrm.avail_in = icnt; + zstrm.next_in = ibuf; + zstrm.avail_out = ocnt*sizeof(int); + zstrm.next_out = (Bytef*)obuf; + + if (DebugCompress) + cerr << " inflate START: avail_in " << zstrm.avail_in + << " avail_out " << zstrm.avail_out + << " total_in " << zstrm.total_in + << " total_out " << zstrm.total_out << endl; + + int result = ::inflate(&zstrm, Z_FINISH); + + switch (result) { + case Z_OK: + if (DebugCompress) + cerr << " inflate OK: avail_in " << zstrm.avail_in + << " avail_out " << zstrm.avail_out + << " total_in " << zstrm.total_in + << " total_out " << zstrm.total_out << endl; + break; + case Z_STREAM_END: + if (DebugCompress) + cerr << " inflate STREAM_END: avail_in " << zstrm.avail_in + << " avail_out " << zstrm.avail_out + << " total_in " << zstrm.total_in + << " total_out " << zstrm.total_out << endl; + break; + case Z_BUF_ERROR: + if (DebugCompress) + cerr << " inflate BUF_ERROR: avail_in " << zstrm.avail_in + << " avail_out " << zstrm.avail_out << endl; + if (obuf) + delete [] obuf; + return 0; + default: + internalError("Fitsy++ gzip inflate error"); + if (obuf) + delete [] obuf; + return 0; + } + + int bytepix = zstrm.total_out/FitsCompressm::tilesize_; + + inflateEnd(&zstrm); + + // GZIP_2- unshuffle if needed + if (!strncmp(FitsCompressm::type_,"GZIP_2",6)) { + switch (bytepix) { + case 1: + break; + case 2: + { + int ll = ocnt*sizeof(short); + char* nbuf = new char[ll]; + if (!nbuf) { + internalError("Fitsy++ gzip unable to alloc."); + if (obuf) + delete [] obuf; + return 0; + } + char* optr = obuf+ll-1; + char* nptr = nbuf+ll-1; + + for (int ii=0; ii::width_*FitsCompressm::height_ + jj*FitsCompressm::width_ + ii; + // very carefull about type conversions + T val = FitsCompressm::getValue(obuf+ll,zs,zz,blank); + dest[id] = val; + } + break; + case 2: + for (int kk=kkstart; kk::byteswap_) { + const char* p = (const char*)((short*)obuf+ll); + union { + char c[2]; + short s; + } u; + + u.c[1] = *p++; + u.c[0] = *p; + + *((short*)obuf+ll) = u.s; + } + // very carefull about type conversions + size_t id = kk*FitsCompressm::width_*FitsCompressm::height_ + jj*FitsCompressm::width_ + ii; + T val = FitsCompressm::getValue((short*)obuf+ll,zs,zz,blank); + dest[id] = val; + } + break; + case 4: + for (int kk=kkstart; kk::byteswap_) { + const char* p = (const char*)((int*)obuf+ll); + union { + char c[4]; + int i; + } u; + + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + *((int*)obuf+ll) = u.i; + } + // very carefull about type conversions + size_t id = kk*FitsCompressm::width_*FitsCompressm::height_ + jj*FitsCompressm::width_ + ii; + T val =0; + switch (FitsCompressm::quantize_) { + case FitsCompress::NODITHER: + val = FitsCompressm::getValue((float*)obuf+ll,zs,zz,blank); + break; + case FitsCompress::SUBDITHER1: + case FitsCompress::SUBDITHER2: + val = FitsCompressm::getValue((int*)obuf+ll,zs,zz,blank); + break; + } + dest[id] = val; + } + break; + case 8: + for (int kk=kkstart; kk::byteswap_) { + const char* p = (const char*)((long long*)obuf+ll); + union { + char c[8]; + long long i; + } u; + + u.c[7] = *p++; + u.c[6] = *p++; + u.c[5] = *p++; + u.c[4] = *p++; + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + *((long long*)obuf+ll) = u.i; + } + // very carefull about type conversions + size_t id = kk*FitsCompressm::width_*FitsCompressm::height_ + jj*FitsCompressm::width_ + ii; + T val =0; + switch (FitsCompressm::quantize_) { + case FitsCompress::NODITHER: + val = FitsCompressm::getValue((double*)obuf+ll,zs,zz,blank); + break; + case FitsCompress::SUBDITHER1: + case FitsCompress::SUBDITHER2: + val = FitsCompressm::getValue((long long*)obuf+ll,zs,zz,blank); + break; + } + dest[id] = val; + } + break; + + default: + internalError("Fitsy++ gzip illegal bytepix"); + if (obuf) + delete [] obuf; + return 0; + } + + if (obuf) + delete [] obuf; + return 1; +} + +template class FitsGzipm; +template class FitsGzipm; +template class FitsGzipm; +template class FitsGzipm; +template class FitsGzipm; +template class FitsGzipm; +template class FitsGzipm; + diff --git a/tksao/fitsy++/gzip.h b/tksao/fitsy++/gzip.h new file mode 100644 index 0000000..6769155 --- /dev/null +++ b/tksao/fitsy++/gzip.h @@ -0,0 +1,19 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsgzip_h__ +#define __fitsgzip_h__ + +#include "compress.h" + +template +class FitsGzipm : public FitsCompressm { + private: + int compressed(T*, char*, char*, int, int, int, int, int, int); + + public: + FitsGzipm(FitsFile*); +}; + +#endif diff --git a/tksao/fitsy++/hcompress.C b/tksao/fitsy++/hcompress.C new file mode 100644 index 0000000..dab851c --- /dev/null +++ b/tksao/fitsy++/hcompress.C @@ -0,0 +1,120 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include +using namespace std; + +// Note: currently, hcompress will not work with float or double data with +// BLANK defined, due to the fact that the decompress code takes a int() and +// not an unsigned int() + +#include "hcompress.h" +#include "util.h" + +extern "C" { + int fits_hdecompress(unsigned char *input, int smooth, int *a, int *ny, int *nx, int *scale, int *status); + int fits_hdecompress64(unsigned char *input, int smooth, long long *a, int *ny, int *nx, int *scale, int *status); +} + +template FitsHcompressm::FitsHcompressm(FitsFile* fits) + : FitsCompressm(fits) +{ + // hcompress parameters + smooth_ = 0; + char name[] = "ZNAME "; + char val[] = "ZVAL "; + for (int ii=0; ii<9; ii++) { + name[5] = '0'+ii; + val[4] = '0'+ii; + if (fits->find(name)) { + char* which = fits->getString(name); + if (!strncmp(which,"SMOOTH",4)) + smooth_ = fits->getInteger(val,4); + delete [] which; + } + } + + FitsCompressm::uncompress(fits); +} + +template int FitsHcompressm::compressed(T* dest, char* sptr, + char* heap, + int kkstart, int kkstop, + int jjstart, int jjstop, + int iistart, int iistop) +{ + double zs = FitsCompressm::bscale_; + if (FitsCompressm::zscale_) + zs = FitsCompressm::zscale_->value(sptr,0); + + double zz = FitsCompressm::bzero_; + if (FitsCompressm::zzero_) + zz = FitsCompressm::zzero_->value(sptr,0); + + int blank = FitsCompressm::blank_; + if (FitsCompressm::zblank_) + blank = (int)FitsCompressm::zblank_->value(sptr,0); + + int icnt=0; + unsigned char* ibuf = (unsigned char*)((FitsBinColumnArray*)FitsCompressm::compress_)->get(heap, sptr, &icnt); + + // ibuf can be NULL + if (!ibuf || !icnt) + return 0; + + int ocnt = FitsCompressm::tilesize_; + int nx,ny,scale; + int status=0; + int ll=0; + + switch (FitsCompressm::bitpix_) { + case 8: + case 16: + { + int* obuf = new int[ocnt]; + if (fits_hdecompress(ibuf, smooth_, obuf, &nx, &ny, &scale, &status)) { + internalError("Fitsy++ hcompress bad inflate result"); + return 0; + } + for (int kk=kkstart; kk::width_*FitsCompressm::height_ + jj*FitsCompressm::width_ + ii] = FitsCompressm::getValue(obuf+ll,zs,zz,blank); + + if (obuf) + delete [] obuf; + } + break; + case 32: + case -32: + case -64: + { + long long* obuf = new long long[ocnt]; + if (fits_hdecompress64(ibuf, smooth_, obuf, &nx, &ny, &scale, &status)) { + internalError("Fitsy++ hcompress bad inflate result"); + return 0; + } + for (int kk=kkstart; kk::width_*FitsCompressm::height_ + jj*FitsCompressm::width_ + ii] = FitsCompressm::getValue((int*)obuf+ll,zs,zz,blank); + + if (obuf) + delete [] obuf; + } + break; + } + + return 1; +} + +template class FitsHcompressm; +template class FitsHcompressm; +template class FitsHcompressm; +template class FitsHcompressm; +template class FitsHcompressm; +template class FitsHcompressm; +template class FitsHcompressm; diff --git a/tksao/fitsy++/hcompress.h b/tksao/fitsy++/hcompress.h new file mode 100644 index 0000000..1cb318a --- /dev/null +++ b/tksao/fitsy++/hcompress.h @@ -0,0 +1,22 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitshcompress_h__ +#define __fitshcompress_h__ + +#include "compress.h" + +template +class FitsHcompressm : public FitsCompressm { + protected: + int smooth_; + + private: + int compressed(T*, char*, char*, int, int, int, int, int, int); + + public: + FitsHcompressm(FitsFile*); +}; + +#endif diff --git a/tksao/fitsy++/hdecompress.c b/tksao/fitsy++/hdecompress.c new file mode 100644 index 0000000..06d1c7a --- /dev/null +++ b/tksao/fitsy++/hdecompress.c @@ -0,0 +1,2619 @@ +/* ######################################################################### +These routines to apply the H-compress decompression algorithm to a 2-D Fits +image were written by R. White at the STScI and were obtained from the STScI at +http://www.stsci.edu/software/hcompress.html + +This source file is a concatination of the following sources files in the +original distribution + hinv.c + hsmooth.c + undigitize.c + decode.c + dodecode.c + qtree_decode.c + qread.c + bit_input.c + + +The following modifications have been made to the original code: + + - commented out redundant "include" statements + - added the nextchar global variable + - changed all the 'extern' declarations to 'static', since all the routines are in + the same source file + - changed the first parameter in decode (and in lower level routines from a file stream + to a char array + - modified the myread routine, and lower level byte reading routines, to copy + the input bytes to a char array, instead of reading them from a file stream + - changed the function declarations to the more modern ANSI C style + - changed calls to printf and perror to call the CFITSIO ffpmsg routine + - replace "exit" statements with "return" statements + + ############################################################################ */ + +#include +#include +#include +#include +/*#include "fitsio2.h"*/ +#define LONGLONG long long +#define DATA_DECOMPRESSION_ERR 0 + +static void ffpmsg(const char* str) {} + +/* WDP added test to see if min and max are already defined */ +#ifndef min +#define min(a,b) (((a)<(b))?(a):(b)) +#endif +#ifndef max +#define max(a,b) (((a)>(b))?(a):(b)) +#endif + +static long nextchar; + +static int decode(unsigned char *infile, int *a, int *nx, int *ny, int *scale); +static int decode64(unsigned char *infile, LONGLONG *a, int *nx, int *ny, int *scale); +static int hinv(int a[], int nx, int ny, int smooth ,int scale); +static int hinv64(LONGLONG a[], int nx, int ny, int smooth ,int scale); +static void undigitize(int a[], int nx, int ny, int scale); +static void undigitize64(LONGLONG a[], int nx, int ny, int scale); +static void unshuffle(int a[], int n, int n2, int tmp[]); +static void unshuffle64(LONGLONG a[], int n, int n2, LONGLONG tmp[]); +static void hsmooth(int a[], int nxtop, int nytop, int ny, int scale); +static void hsmooth64(LONGLONG a[], int nxtop, int nytop, int ny, int scale); +static void qread(unsigned char *infile,char *a, int n); +static int readint(unsigned char *infile); +static LONGLONG readlonglong(unsigned char *infile); +static int dodecode(unsigned char *infile, int a[], int nx, int ny, unsigned char nbitplanes[3]); +static int dodecode64(unsigned char *infile, LONGLONG a[], int nx, int ny, unsigned char nbitplanes[3]); +static int qtree_decode(unsigned char *infile, int a[], int n, int nqx, int nqy, int nbitplanes); +static int qtree_decode64(unsigned char *infile, LONGLONG a[], int n, int nqx, int nqy, int nbitplanes); +static void start_inputing_bits(); +static int input_bit(unsigned char *infile); +static int input_nbits(unsigned char *infile, int n); +/* make input_nybble a separate routine, for added effiency */ +/* #define input_nybble(infile) input_nbits(infile,4) */ +static int input_nybble(unsigned char *infile); +static int input_nnybble(unsigned char *infile, int n, unsigned char *array); + +static void qtree_expand(unsigned char *infile, unsigned char a[], int nx, int ny, unsigned char b[]); +static void qtree_bitins(unsigned char a[], int nx, int ny, int b[], int n, int bit); +static void qtree_bitins64(unsigned char a[], int nx, int ny, LONGLONG b[], int n, int bit); +static void qtree_copy(unsigned char a[], int nx, int ny, unsigned char b[], int n); +static void read_bdirect(unsigned char *infile, int a[], int n, int nqx, int nqy, unsigned char scratch[], int bit); +static void read_bdirect64(unsigned char *infile, LONGLONG a[], int n, int nqx, int nqy, unsigned char scratch[], int bit); +static int input_huffman(unsigned char *infile); + +/* ---------------------------------------------------------------------- */ +int fits_hdecompress(unsigned char *input, int smooth, int *a, int *ny, int *nx, + int *scale, int *status) +{ + /* + decompress the input byte stream using the H-compress algorithm + + input - input array of compressed bytes + a - pre-allocated array to hold the output uncompressed image + nx - returned X axis size + ny - returned Y axis size + + NOTE: the nx and ny dimensions as defined within this code are reversed from + the usual FITS notation. ny is the fastest varying dimension, which is + usually considered the X axis in the FITS image display + + */ +int stat; + + if (*status > 0) return(*status); + + /* decode the input array */ + + stat = decode(input, a, nx, ny, scale); + *status = stat; + if (stat) return(*status); + + /* + * Un-Digitize + */ + undigitize(a, *nx, *ny, *scale); + + /* + * Inverse H-transform + */ + stat = hinv(a, *nx, *ny, smooth, *scale); + *status = stat; + + return(*status); +} +/* ---------------------------------------------------------------------- */ +int fits_hdecompress64(unsigned char *input, int smooth, LONGLONG *a, int *ny, int *nx, + int *scale, int *status) +{ + /* + decompress the input byte stream using the H-compress algorithm + + input - input array of compressed bytes + a - pre-allocated array to hold the output uncompressed image + nx - returned X axis size + ny - returned Y axis size + + NOTE: the nx and ny dimensions as defined within this code are reversed from + the usual FITS notation. ny is the fastest varying dimension, which is + usually considered the X axis in the FITS image display + + */ + int stat, *iarray, ii, nval; + + if (*status > 0) return(*status); + + /* decode the input array */ + + stat = decode64(input, a, nx, ny, scale); + *status = stat; + if (stat) return(*status); + + /* + * Un-Digitize + */ + undigitize64(a, *nx, *ny, *scale); + + /* + * Inverse H-transform + */ + stat = hinv64(a, *nx, *ny, smooth, *scale); + + *status = stat; + + /* pack the I*8 values back into an I*4 array */ + iarray = (int *) a; + nval = (*nx) * (*ny); + + for (ii = 0; ii < nval; ii++) + iarray[ii] = (int) a[ii]; + + return(*status); +} + +/* ############################################################################ */ +/* ############################################################################ */ + +/* Copyright (c) 1993 Association of Universities for Research + * in Astronomy. All rights reserved. Produced under National + * Aeronautics and Space Administration Contract No. NAS5-26555. + */ +/* hinv.c Inverse H-transform of NX x NY integer image + * + * Programmer: R. White Date: 23 July 1993 + */ + +/* ############################################################################ */ +static int +hinv(int a[], int nx, int ny, int smooth ,int scale) +/* +int smooth; 0 for no smoothing, else smooth during inversion +int scale; used if smoothing is specified +*/ +{ +int nmax, log2n, i, j, k; +int nxtop,nytop,nxf,nyf,c; +int oddx,oddy; +int shift, bit0, bit1, bit2, mask0, mask1, mask2, + prnd0, prnd1, prnd2, nrnd0, nrnd1, nrnd2, lowbit0, lowbit1; +int h0, hx, hy, hc; +int s10, s00; +int *tmp; + + /* + * log2n is log2 of max(nx,ny) rounded up to next power of 2 + */ + nmax = (nx>ny) ? nx : ny; + log2n = (int) (log((float) nmax)/log(2.0)+0.5); + if ( nmax > (1<> 1; + prnd1 = bit1 >> 1; + prnd2 = bit2 >> 1; + nrnd0 = prnd0 - 1; + nrnd1 = prnd1 - 1; + nrnd2 = prnd2 - 1; + /* + * round h0 to multiple of bit2 + */ + a[0] = (a[0] + ((a[0] >= 0) ? prnd2 : nrnd2)) & mask2; + /* + * do log2n expansions + * + * We're indexing a as a 2-D array with dimensions (nx,ny). + */ + nxtop = 1; + nytop = 1; + nxf = nx; + nyf = ny; + c = 1<=0; k--) { + /* + * this somewhat cryptic code generates the sequence + * ntop[k-1] = (ntop[k]+1)/2, where ntop[log2n] = n + */ + c = c>>1; + nxtop = nxtop<<1; + nytop = nytop<<1; + if (nxf <= c) { nxtop -= 1; } else { nxf -= c; } + if (nyf <= c) { nytop -= 1; } else { nyf -= c; } + /* + * double shift and fix nrnd0 (because prnd0=0) on last pass + */ + if (k == 0) { + nrnd0 = 0; + shift = 2; + } + /* + * unshuffle in each dimension to interleave coefficients + */ + for (i = 0; i= 0) ? prnd1 : nrnd1)) & mask1; + hy = (hy + ((hy >= 0) ? prnd1 : nrnd1)) & mask1; + hc = (hc + ((hc >= 0) ? prnd0 : nrnd0)) & mask0; + /* + * propagate bit0 of hc to hx,hy + */ + lowbit0 = hc & bit0; + hx = (hx >= 0) ? (hx - lowbit0) : (hx + lowbit0); + hy = (hy >= 0) ? (hy - lowbit0) : (hy + lowbit0); + /* + * Propagate bits 0 and 1 of hc,hx,hy to h0. + * This could be simplified if we assume h0>0, but then + * the inversion would not be lossless for images with + * negative pixels. + */ + lowbit1 = (hc ^ hx ^ hy) & bit1; + h0 = (h0 >= 0) + ? (h0 + lowbit0 - lowbit1) + : (h0 + ((lowbit0 == 0) ? lowbit1 : (lowbit0-lowbit1))); + /* + * Divide sums by 2 (4 last time) + */ + a[s10+1] = (h0 + hx + hy + hc) >> shift; + a[s10 ] = (h0 + hx - hy - hc) >> shift; + a[s00+1] = (h0 - hx + hy - hc) >> shift; + a[s00 ] = (h0 - hx - hy + hc) >> shift; + s00 += 2; + s10 += 2; + } + if (oddy) { + /* + * do last element in row if row length is odd + * s00+1, s10+1 are off edge + */ + h0 = a[s00 ]; + hx = a[s10 ]; + hx = ((hx >= 0) ? (hx+prnd1) : (hx+nrnd1)) & mask1; + lowbit1 = hx & bit1; + h0 = (h0 >= 0) ? (h0 - lowbit1) : (h0 + lowbit1); + a[s10 ] = (h0 + hx) >> shift; + a[s00 ] = (h0 - hx) >> shift; + } + } + if (oddx) { + /* + * do last row if column length is odd + * s10, s10+1 are off edge + */ + s00 = ny*i; + for (j = 0; j= 0) ? (hy+prnd1) : (hy+nrnd1)) & mask1; + lowbit1 = hy & bit1; + h0 = (h0 >= 0) ? (h0 - lowbit1) : (h0 + lowbit1); + a[s00+1] = (h0 + hy) >> shift; + a[s00 ] = (h0 - hy) >> shift; + s00 += 2; + } + if (oddy) { + /* + * do corner element if both row and column lengths are odd + * s00+1, s10, s10+1 are off edge + */ + h0 = a[s00 ]; + a[s00 ] = h0 >> shift; + } + } + /* + * divide all the masks and rounding values by 2 + */ + bit2 = bit1; + bit1 = bit0; + bit0 = bit0 >> 1; + mask1 = mask0; + mask0 = mask0 >> 1; + prnd1 = prnd0; + prnd0 = prnd0 >> 1; + nrnd1 = nrnd0; + nrnd0 = prnd0 - 1; + } + free(tmp); + return(0); +} +/* ############################################################################ */ +static int +hinv64(LONGLONG a[], int nx, int ny, int smooth ,int scale) +/* +int smooth; 0 for no smoothing, else smooth during inversion +int scale; used if smoothing is specified +*/ +{ +int nmax, log2n, i, j, k; +int nxtop,nytop,nxf,nyf,c; +int oddx,oddy; +int shift; +LONGLONG mask0, mask1, mask2, prnd0, prnd1, prnd2, bit0, bit1, bit2; +LONGLONG nrnd0, nrnd1, nrnd2, lowbit0, lowbit1; +LONGLONG h0, hx, hy, hc; +int s10, s00; +LONGLONG *tmp; + + /* + * log2n is log2 of max(nx,ny) rounded up to next power of 2 + */ + nmax = (nx>ny) ? nx : ny; + log2n = (int) (log((float) nmax)/log(2.0)+0.5); + if ( nmax > (1<> 1; + prnd1 = bit1 >> 1; + prnd2 = bit2 >> 1; + nrnd0 = prnd0 - 1; + nrnd1 = prnd1 - 1; + nrnd2 = prnd2 - 1; + /* + * round h0 to multiple of bit2 + */ + a[0] = (a[0] + ((a[0] >= 0) ? prnd2 : nrnd2)) & mask2; + /* + * do log2n expansions + * + * We're indexing a as a 2-D array with dimensions (nx,ny). + */ + nxtop = 1; + nytop = 1; + nxf = nx; + nyf = ny; + c = 1<=0; k--) { + /* + * this somewhat cryptic code generates the sequence + * ntop[k-1] = (ntop[k]+1)/2, where ntop[log2n] = n + */ + c = c>>1; + nxtop = nxtop<<1; + nytop = nytop<<1; + if (nxf <= c) { nxtop -= 1; } else { nxf -= c; } + if (nyf <= c) { nytop -= 1; } else { nyf -= c; } + /* + * double shift and fix nrnd0 (because prnd0=0) on last pass + */ + if (k == 0) { + nrnd0 = 0; + shift = 2; + } + /* + * unshuffle in each dimension to interleave coefficients + */ + for (i = 0; i= 0) ? prnd1 : nrnd1)) & mask1; + hy = (hy + ((hy >= 0) ? prnd1 : nrnd1)) & mask1; + hc = (hc + ((hc >= 0) ? prnd0 : nrnd0)) & mask0; + /* + * propagate bit0 of hc to hx,hy + */ + lowbit0 = hc & bit0; + hx = (hx >= 0) ? (hx - lowbit0) : (hx + lowbit0); + hy = (hy >= 0) ? (hy - lowbit0) : (hy + lowbit0); + /* + * Propagate bits 0 and 1 of hc,hx,hy to h0. + * This could be simplified if we assume h0>0, but then + * the inversion would not be lossless for images with + * negative pixels. + */ + lowbit1 = (hc ^ hx ^ hy) & bit1; + h0 = (h0 >= 0) + ? (h0 + lowbit0 - lowbit1) + : (h0 + ((lowbit0 == 0) ? lowbit1 : (lowbit0-lowbit1))); + /* + * Divide sums by 2 (4 last time) + */ + a[s10+1] = (h0 + hx + hy + hc) >> shift; + a[s10 ] = (h0 + hx - hy - hc) >> shift; + a[s00+1] = (h0 - hx + hy - hc) >> shift; + a[s00 ] = (h0 - hx - hy + hc) >> shift; + s00 += 2; + s10 += 2; + } + if (oddy) { + /* + * do last element in row if row length is odd + * s00+1, s10+1 are off edge + */ + h0 = a[s00 ]; + hx = a[s10 ]; + hx = ((hx >= 0) ? (hx+prnd1) : (hx+nrnd1)) & mask1; + lowbit1 = hx & bit1; + h0 = (h0 >= 0) ? (h0 - lowbit1) : (h0 + lowbit1); + a[s10 ] = (h0 + hx) >> shift; + a[s00 ] = (h0 - hx) >> shift; + } + } + if (oddx) { + /* + * do last row if column length is odd + * s10, s10+1 are off edge + */ + s00 = ny*i; + for (j = 0; j= 0) ? (hy+prnd1) : (hy+nrnd1)) & mask1; + lowbit1 = hy & bit1; + h0 = (h0 >= 0) ? (h0 - lowbit1) : (h0 + lowbit1); + a[s00+1] = (h0 + hy) >> shift; + a[s00 ] = (h0 - hy) >> shift; + s00 += 2; + } + if (oddy) { + /* + * do corner element if both row and column lengths are odd + * s00+1, s10, s10+1 are off edge + */ + h0 = a[s00 ]; + a[s00 ] = h0 >> shift; + } + } + /* + * divide all the masks and rounding values by 2 + */ + bit2 = bit1; + bit1 = bit0; + bit0 = bit0 >> 1; + mask1 = mask0; + mask0 = mask0 >> 1; + prnd1 = prnd0; + prnd0 = prnd0 >> 1; + nrnd1 = nrnd0; + nrnd0 = prnd0 - 1; + } + free(tmp); + return(0); +} + +/* ############################################################################ */ +static void +unshuffle(int a[], int n, int n2, int tmp[]) +/* +int a[]; array to shuffle +int n; number of elements to shuffle +int n2; second dimension +int tmp[]; scratch storage +*/ +{ +int i; +int nhalf; +int *p1, *p2, *pt; + + /* + * copy 2nd half of array to tmp + */ + nhalf = (n+1)>>1; + pt = tmp; + p1 = &a[n2*nhalf]; /* pointer to a[i] */ + for (i=nhalf; i= 0; i--) { + *p1 = *p2; + p2 -= n2; + p1 -= (n2+n2); + } + /* + * now distribute 2nd half of array (in tmp) to odd elements + */ + pt = tmp; + p1 = &a[n2]; /* pointer to a[i] */ + for (i=1; i>1; + pt = tmp; + p1 = &a[n2*nhalf]; /* pointer to a[i] */ + for (i=nhalf; i= 0; i--) { + *p1 = *p2; + p2 -= n2; + p1 -= (n2+n2); + } + /* + * now distribute 2nd half of array (in tmp) to odd elements + */ + pt = tmp; + p1 = &a[n2]; /* pointer to a[i] */ + for (i=1; i> 1); + if (smax <= 0) return; + ny2 = ny << 1; + /* + * We're indexing a as a 2-D array with dimensions (nxtop,ny) of which + * only (nxtop,nytop) are used. The coefficients on the edge of the + * array are not adjusted (which is why the loops below start at 2 + * instead of 0 and end at nxtop-2 instead of nxtop.) + */ + /* + * Adjust x difference hx + */ + for (i = 2; i=0, dmin<=0. + */ + if (dmin < dmax) { + diff = max( min(diff, dmax), dmin); + /* + * Compute change in slope limited to range +/- smax. + * Careful with rounding negative numbers when using + * shift for divide by 8. + */ + s = diff-(a[s10]<<3); + s = (s>=0) ? (s>>3) : ((s+7)>>3) ; + s = max( min(s, smax), -smax); + a[s10] = a[s10]+s; + } + s00 += 2; + s10 += 2; + } + } + /* + * Adjust y difference hy + */ + for (i = 0; i=0) ? (s>>3) : ((s+7)>>3) ; + s = max( min(s, smax), -smax); + a[s00+1] = a[s00+1]+s; + } + s00 += 2; + s10 += 2; + } + } + /* + * Adjust curvature difference hc + */ + for (i = 2; i=0, dmin<=0. + */ + if (dmin < dmax) { + diff = max( min(diff, dmax), dmin); + /* + * Compute change in slope limited to range +/- smax. + * Careful with rounding negative numbers when using + * shift for divide by 64. + */ + s = diff-(a[s10+1]<<6); + s = (s>=0) ? (s>>6) : ((s+63)>>6) ; + s = max( min(s, smax), -smax); + a[s10+1] = a[s10+1]+s; + } + s00 += 2; + s10 += 2; + } + } +} +/* ############################################################################ */ +static void +hsmooth64(LONGLONG a[], int nxtop, int nytop, int ny, int scale) +/* +LONGLONG a[]; array of H-transform coefficients +int nxtop,nytop; size of coefficient block to use +int ny; actual 1st dimension of array +int scale; truncation scale factor that was used +*/ +{ +int i, j; +int ny2, s10, s00; +LONGLONG hm, h0, hp, hmm, hpm, hmp, hpp, hx2, hy2, diff, dmax, dmin, s, smax, m1, m2; + + /* + * Maximum change in coefficients is determined by scale factor. + * Since we rounded during division (see digitize.c), the biggest + * permitted change is scale/2. + */ + smax = (scale >> 1); + if (smax <= 0) return; + ny2 = ny << 1; + /* + * We're indexing a as a 2-D array with dimensions (nxtop,ny) of which + * only (nxtop,nytop) are used. The coefficients on the edge of the + * array are not adjusted (which is why the loops below start at 2 + * instead of 0 and end at nxtop-2 instead of nxtop.) + */ + /* + * Adjust x difference hx + */ + for (i = 2; i=0, dmin<=0. + */ + if (dmin < dmax) { + diff = max( min(diff, dmax), dmin); + /* + * Compute change in slope limited to range +/- smax. + * Careful with rounding negative numbers when using + * shift for divide by 8. + */ + s = diff-(a[s10]<<3); + s = (s>=0) ? (s>>3) : ((s+7)>>3) ; + s = max( min(s, smax), -smax); + a[s10] = a[s10]+s; + } + s00 += 2; + s10 += 2; + } + } + /* + * Adjust y difference hy + */ + for (i = 0; i=0) ? (s>>3) : ((s+7)>>3) ; + s = max( min(s, smax), -smax); + a[s00+1] = a[s00+1]+s; + } + s00 += 2; + s10 += 2; + } + } + /* + * Adjust curvature difference hc + */ + for (i = 2; i=0, dmin<=0. + */ + if (dmin < dmax) { + diff = max( min(diff, dmax), dmin); + /* + * Compute change in slope limited to range +/- smax. + * Careful with rounding negative numbers when using + * shift for divide by 64. + */ + s = diff-(a[s10+1]<<6); + s = (s>=0) ? (s>>6) : ((s+63)>>6) ; + s = max( min(s, smax), -smax); + a[s10+1] = a[s10+1]+s; + } + s00 += 2; + s10 += 2; + } + } +} + + +/* ############################################################################ */ +/* ############################################################################ */ +/* Copyright (c) 1993 Association of Universities for Research + * in Astronomy. All rights reserved. Produced under National + * Aeronautics and Space Administration Contract No. NAS5-26555. + */ +/* undigitize.c undigitize H-transform + * + * Programmer: R. White Date: 9 May 1991 + */ + +/* ############################################################################ */ +static void +undigitize(int a[], int nx, int ny, int scale) +{ +int *p; + + /* + * multiply by scale + */ + if (scale <= 1) return; + for (p=a; p <= &a[nx*ny-1]; p++) *p = (*p)*scale; +} +/* ############################################################################ */ +static void +undigitize64(LONGLONG a[], int nx, int ny, int scale) +{ +LONGLONG *p, scale64; + + /* + * multiply by scale + */ + if (scale <= 1) return; + scale64 = (LONGLONG) scale; /* use a 64-bit int for efficiency in the big loop */ + + for (p=a; p <= &a[nx*ny-1]; p++) *p = (*p)*scale64; +} + +/* ############################################################################ */ +/* ############################################################################ */ +/* Copyright (c) 1993 Association of Universities for Research + * in Astronomy. All rights reserved. Produced under National + * Aeronautics and Space Administration Contract No. NAS5-26555. + */ +/* decode.c read codes from infile and construct array + * + * Programmer: R. White Date: 2 February 1994 + */ + + +static char code_magic[2] = { (char)0xDD, (char)0x99 }; + +/* ############################################################################ */ +static int decode(unsigned char *infile, int *a, int *nx, int *ny, int *scale) +/* +char *infile; input file +int *a; address of output array [nx][ny] +int *nx,*ny; size of output array +int *scale; scale factor for digitization +*/ +{ +LONGLONG sumall; +int nel, stat; +unsigned char nbitplanes[3]; +char tmagic[2]; + + /* initialize the byte read position to the beginning of the array */; + nextchar = 0; + + /* + * File starts either with special 2-byte magic code or with + * FITS keyword "SIMPLE =" + */ + qread(infile, tmagic, sizeof(tmagic)); + /* + * check for correct magic code value + */ + if (memcmp(tmagic,code_magic,sizeof(code_magic)) != 0) { + ffpmsg("bad file format"); + return(DATA_DECOMPRESSION_ERR); + } + *nx =readint(infile); /* x size of image */ + *ny =readint(infile); /* y size of image */ + *scale=readint(infile); /* scale factor for digitization */ + + nel = (*nx) * (*ny); + + /* sum of all pixels */ + sumall=readlonglong(infile); + /* # bits in quadrants */ + + qread(infile, (char *) nbitplanes, sizeof(nbitplanes)); + + stat = dodecode(infile, a, *nx, *ny, nbitplanes); + /* + * put sum of all pixels back into pixel 0 + */ + a[0] = (int) sumall; + return(stat); +} +/* ############################################################################ */ +static int decode64(unsigned char *infile, LONGLONG *a, int *nx, int *ny, int *scale) +/* +char *infile; input file +LONGLONG *a; address of output array [nx][ny] +int *nx,*ny; size of output array +int *scale; scale factor for digitization +*/ +{ +int nel, stat; +LONGLONG sumall; +unsigned char nbitplanes[3]; +char tmagic[2]; + + /* initialize the byte read position to the beginning of the array */; + nextchar = 0; + + /* + * File starts either with special 2-byte magic code or with + * FITS keyword "SIMPLE =" + */ + qread(infile, tmagic, sizeof(tmagic)); + /* + * check for correct magic code value + */ + if (memcmp(tmagic,code_magic,sizeof(code_magic)) != 0) { + ffpmsg("bad file format"); + return(DATA_DECOMPRESSION_ERR); + } + *nx =readint(infile); /* x size of image */ + *ny =readint(infile); /* y size of image */ + *scale=readint(infile); /* scale factor for digitization */ + + nel = (*nx) * (*ny); + + /* sum of all pixels */ + sumall=readlonglong(infile); + /* # bits in quadrants */ + + qread(infile, (char *) nbitplanes, sizeof(nbitplanes)); + + stat = dodecode64(infile, a, *nx, *ny, nbitplanes); + /* + * put sum of all pixels back into pixel 0 + */ + a[0] = sumall; + + return(stat); +} + + +/* ############################################################################ */ +/* ############################################################################ */ +/* Copyright (c) 1993 Association of Universities for Research + * in Astronomy. All rights reserved. Produced under National + * Aeronautics and Space Administration Contract No. NAS5-26555. + */ +/* dodecode.c Decode stream of characters on infile and return array + * + * This version encodes the different quadrants separately + * + * Programmer: R. White Date: 9 May 1991 + */ + +/* ############################################################################ */ +static int +dodecode(unsigned char *infile, int a[], int nx, int ny, unsigned char nbitplanes[3]) + +/* int a[]; + int nx,ny; Array dimensions are [nx][ny] + unsigned char nbitplanes[3]; Number of bit planes in quadrants +*/ +{ +int i, nel, nx2, ny2, stat; + + nel = nx*ny; + nx2 = (nx+1)/2; + ny2 = (ny+1)/2; + + /* + * initialize a to zero + */ + for (i=0; inqy) ? nqx : nqy; + log2n = (int) (log((float) nqmax)/log(2.0)+0.5); + if (nqmax > (1<= 0; bit--) { + /* + * Was bitplane was quadtree-coded or written directly? + */ + b = input_nybble(infile); + + if(b == 0) { + /* + * bit map was written directly + */ + read_bdirect(infile,a,n,nqx,nqy,scratch,bit); + } else if (b != 0xf) { + ffpmsg("qtree_decode: bad format code"); + return(DATA_DECOMPRESSION_ERR); + } else { + /* + * bitmap was quadtree-coded, do log2n expansions + * + * read first code + */ + scratch[0] = input_huffman(infile); + /* + * now do log2n expansions, reading codes from file as necessary + */ + nx = 1; + ny = 1; + nfx = nqx; + nfy = nqy; + c = 1<>1; + nx = nx<<1; + ny = ny<<1; + if (nfx <= c) { nx -= 1; } else { nfx -= c; } + if (nfy <= c) { ny -= 1; } else { nfy -= c; } + qtree_expand(infile,scratch,nx,ny,scratch); + } + /* + * now copy last set of 4-bit codes to bitplane bit of array a + */ + qtree_bitins(scratch,nqx,nqy,a,n,bit); + } + } + free(scratch); + return(0); +} +/* ############################################################################ */ +static int +qtree_decode64(unsigned char *infile, LONGLONG a[], int n, int nqx, int nqy, int nbitplanes) + +/* +char *infile; +LONGLONG a[]; a is 2-D array with dimensions (n,n) +int n; length of full row in a +int nqx; partial length of row to decode +int nqy; partial length of column (<=n) +int nbitplanes; number of bitplanes to decode +*/ +{ +int log2n, k, bit, b, nqmax; +int nx,ny,nfx,nfy,c; +int nqx2, nqy2; +unsigned char *scratch; + + /* + * log2n is log2 of max(nqx,nqy) rounded up to next power of 2 + */ + nqmax = (nqx>nqy) ? nqx : nqy; + log2n = (int) (log((float) nqmax)/log(2.0)+0.5); + if (nqmax > (1<= 0; bit--) { + /* + * Was bitplane was quadtree-coded or written directly? + */ + b = input_nybble(infile); + + if(b == 0) { + /* + * bit map was written directly + */ + read_bdirect64(infile,a,n,nqx,nqy,scratch,bit); + } else if (b != 0xf) { + ffpmsg("qtree_decode64: bad format code"); + return(DATA_DECOMPRESSION_ERR); + } else { + /* + * bitmap was quadtree-coded, do log2n expansions + * + * read first code + */ + scratch[0] = input_huffman(infile); + /* + * now do log2n expansions, reading codes from file as necessary + */ + nx = 1; + ny = 1; + nfx = nqx; + nfy = nqy; + c = 1<>1; + nx = nx<<1; + ny = ny<<1; + if (nfx <= c) { nx -= 1; } else { nfx -= c; } + if (nfy <= c) { ny -= 1; } else { nfy -= c; } + qtree_expand(infile,scratch,nx,ny,scratch); + } + /* + * now copy last set of 4-bit codes to bitplane bit of array a + */ + qtree_bitins64(scratch,nqx,nqy,a,n,bit); + } + } + free(scratch); + return(0); +} + + +/* ############################################################################ */ +/* + * do one quadtree expansion step on array a[(nqx+1)/2,(nqy+1)/2] + * results put into b[nqx,nqy] (which may be the same as a) + */ +static void +qtree_expand(unsigned char *infile, unsigned char a[], int nx, int ny, unsigned char b[]) +{ +int i; + + /* + * first copy a to b, expanding each 4-bit value + */ + qtree_copy(a,nx,ny,b,ny); + /* + * now read new 4-bit values into b for each non-zero element + */ + for (i = nx*ny-1; i >= 0; i--) { + if (b[i]) b[i] = input_huffman(infile); + } +} + +/* ############################################################################ */ +/* + * copy 4-bit values from a[(nx+1)/2,(ny+1)/2] to b[nx,ny], expanding + * each value to 2x2 pixels + * a,b may be same array + */ +static void +qtree_copy(unsigned char a[], int nx, int ny, unsigned char b[], int n) +/* int n; declared y dimension of b */ +{ +int i, j, k, nx2, ny2; +int s00, s10; + + /* + * first copy 4-bit values to b + * start at end in case a,b are same array + */ + nx2 = (nx+1)/2; + ny2 = (ny+1)/2; + k = ny2*(nx2-1)+ny2-1; /* k is index of a[i,j] */ + for (i = nx2-1; i >= 0; i--) { + s00 = 2*(n*i+ny2-1); /* s00 is index of b[2*i,2*j] */ + for (j = ny2-1; j >= 0; j--) { + b[s00] = a[k]; + k -= 1; + s00 -= 2; + } + } + /* + * now expand each 2x2 block + */ + for (i = 0; i>1) & 1; + b[s00+1] = (b[s00]>>2) & 1; + b[s00 ] = (b[s00]>>3) & 1; +*/ + + s00 += 2; + s10 += 2; + } + + if (j < ny) { + /* + * row size is odd, do last element in row + * s00+1, s10+1 are off edge + */ + /* not worth converting this to use 16 case statements */ + b[s10 ] = (b[s00]>>1) & 1; + b[s00 ] = (b[s00]>>3) & 1; + } + } + if (i < nx) { + /* + * column size is odd, do last row + * s10, s10+1 are off edge + */ + s00 = n*i; + for (j = 0; j>2) & 1; + b[s00 ] = (b[s00]>>3) & 1; + s00 += 2; + } + if (j < ny) { + /* + * both row and column size are odd, do corner element + * s00+1, s10, s10+1 are off edge + */ + /* not worth converting this to use 16 case statements */ + b[s00 ] = (b[s00]>>3) & 1; + } + } +} + +/* ############################################################################ */ +/* + * Copy 4-bit values from a[(nx+1)/2,(ny+1)/2] to b[nx,ny], expanding + * each value to 2x2 pixels and inserting into bitplane BIT of B. + * A,B may NOT be same array (it wouldn't make sense to be inserting + * bits into the same array anyway.) + */ +static void +qtree_bitins(unsigned char a[], int nx, int ny, int b[], int n, int bit) +/* + int n; declared y dimension of b +*/ +{ +int i, j, k; +int s00; +int plane_val; + + plane_val = 1 << bit; + + /* + * expand each 2x2 block + */ + k = 0; /* k is index of a[i/2,j/2] */ + for (i = 0; i>1) & 1) << bit; + b[s00+1] |= ((a[k]>>2) & 1) << bit; + b[s00 ] |= ((a[k]>>3) & 1) << bit; +*/ + s00 += 2; +/* s10 += 2; */ + k += 1; + } + if (j < ny) { + /* + * row size is odd, do last element in row + * s00+1, s10+1 are off edge + */ + + switch (a[k]) { + case(0): + break; + case(1): + break; + case(2): + b[s00+n ] |= plane_val; + break; + case(3): + b[s00+n ] |= plane_val; + break; + case(4): + break; + case(5): + break; + case(6): + b[s00+n ] |= plane_val; + break; + case(7): + b[s00+n ] |= plane_val; + break; + case(8): + b[s00 ] |= plane_val; + break; + case(9): + b[s00 ] |= plane_val; + break; + case(10): + b[s00+n ] |= plane_val; + b[s00 ] |= plane_val; + break; + case(11): + b[s00+n ] |= plane_val; + b[s00 ] |= plane_val; + break; + case(12): + b[s00 ] |= plane_val; + break; + case(13): + b[s00 ] |= plane_val; + break; + case(14): + b[s00+n ] |= plane_val; + b[s00 ] |= plane_val; + break; + case(15): + b[s00+n ] |= plane_val; + b[s00 ] |= plane_val; + break; + } + +/* + b[s10 ] |= ((a[k]>>1) & 1) << bit; + b[s00 ] |= ((a[k]>>3) & 1) << bit; +*/ + k += 1; + } + } + if (i < nx) { + /* + * column size is odd, do last row + * s10, s10+1 are off edge + */ + s00 = n*i; + for (j = 0; j>2) & 1) << bit; + b[s00 ] |= ((a[k]>>3) & 1) << bit; +*/ + + s00 += 2; + k += 1; + } + if (j < ny) { + /* + * both row and column size are odd, do corner element + * s00+1, s10, s10+1 are off edge + */ + + switch (a[k]) { + case(0): + break; + case(1): + break; + case(2): + break; + case(3): + break; + case(4): + break; + case(5): + break; + case(6): + break; + case(7): + break; + case(8): + b[s00 ] |= plane_val; + break; + case(9): + b[s00 ] |= plane_val; + break; + case(10): + b[s00 ] |= plane_val; + break; + case(11): + b[s00 ] |= plane_val; + break; + case(12): + b[s00 ] |= plane_val; + break; + case(13): + b[s00 ] |= plane_val; + break; + case(14): + b[s00 ] |= plane_val; + break; + case(15): + b[s00 ] |= plane_val; + break; + } + +/* + b[s00 ] |= ((a[k]>>3) & 1) << bit; +*/ + k += 1; + } + } +} +/* ############################################################################ */ +/* + * Copy 4-bit values from a[(nx+1)/2,(ny+1)/2] to b[nx,ny], expanding + * each value to 2x2 pixels and inserting into bitplane BIT of B. + * A,B may NOT be same array (it wouldn't make sense to be inserting + * bits into the same array anyway.) + */ +static void +qtree_bitins64(unsigned char a[], int nx, int ny, LONGLONG b[], int n, int bit) +/* + int n; declared y dimension of b +*/ +{ +int i, j, k; +int s00; +int plane_val; + + plane_val = 1 << bit; + + /* + * expand each 2x2 block + */ + k = 0; /* k is index of a[i/2,j/2] */ + for (i = 0; i>1) & 1) << bit; + b[s00+1] |= ((((LONGLONG)a[k])>>2) & 1) << bit; + b[s00 ] |= ((((LONGLONG)a[k])>>3) & 1) << bit; +*/ + s00 += 2; +/* s10 += 2; */ + k += 1; + } + if (j < ny) { + /* + * row size is odd, do last element in row + * s00+1, s10+1 are off edge + */ + + switch (a[k]) { + case(0): + break; + case(1): + break; + case(2): + b[s00+n ] |= plane_val; + break; + case(3): + b[s00+n ] |= plane_val; + break; + case(4): + break; + case(5): + break; + case(6): + b[s00+n ] |= plane_val; + break; + case(7): + b[s00+n ] |= plane_val; + break; + case(8): + b[s00 ] |= plane_val; + break; + case(9): + b[s00 ] |= plane_val; + break; + case(10): + b[s00+n ] |= plane_val; + b[s00 ] |= plane_val; + break; + case(11): + b[s00+n ] |= plane_val; + b[s00 ] |= plane_val; + break; + case(12): + b[s00 ] |= plane_val; + break; + case(13): + b[s00 ] |= plane_val; + break; + case(14): + b[s00+n ] |= plane_val; + b[s00 ] |= plane_val; + break; + case(15): + b[s00+n ] |= plane_val; + b[s00 ] |= plane_val; + break; + } +/* + b[s10 ] |= ((((LONGLONG)a[k])>>1) & 1) << bit; + b[s00 ] |= ((((LONGLONG)a[k])>>3) & 1) << bit; +*/ + k += 1; + } + } + if (i < nx) { + /* + * column size is odd, do last row + * s10, s10+1 are off edge + */ + s00 = n*i; + for (j = 0; j>2) & 1) << bit; + b[s00 ] |= ((((LONGLONG)a[k])>>3) & 1) << bit; +*/ + s00 += 2; + k += 1; + } + if (j < ny) { + /* + * both row and column size are odd, do corner element + * s00+1, s10, s10+1 are off edge + */ + + switch (a[k]) { + case(0): + break; + case(1): + break; + case(2): + break; + case(3): + break; + case(4): + break; + case(5): + break; + case(6): + break; + case(7): + break; + case(8): + b[s00 ] |= plane_val; + break; + case(9): + b[s00 ] |= plane_val; + break; + case(10): + b[s00 ] |= plane_val; + break; + case(11): + b[s00 ] |= plane_val; + break; + case(12): + b[s00 ] |= plane_val; + break; + case(13): + b[s00 ] |= plane_val; + break; + case(14): + b[s00 ] |= plane_val; + break; + case(15): + b[s00 ] |= plane_val; + break; + } +/* + b[s00 ] |= ((((LONGLONG)a[k])>>3) & 1) << bit; +*/ + k += 1; + } + } +} + +/* ############################################################################ */ +static void +read_bdirect(unsigned char *infile, int a[], int n, int nqx, int nqy, unsigned char scratch[], int bit) +{ + + + /* + * read bit image packed 4 pixels/nybble + */ +/* + int i; + for (i = 0; i < ((nqx+1)/2) * ((nqy+1)/2); i++) { + scratch[i] = input_nybble(infile); + } +*/ + input_nnybble(infile, ((nqx+1)/2) * ((nqy+1)/2), scratch); + + /* + * insert in bitplane BIT of image A + */ + qtree_bitins(scratch,nqx,nqy,a,n,bit); +} +/* ############################################################################ */ +static void +read_bdirect64(unsigned char *infile, LONGLONG a[], int n, int nqx, int nqy, unsigned char scratch[], int bit) +{ + + /* + * read bit image packed 4 pixels/nybble + */ +/* + int i; + for (i = 0; i < ((nqx+1)/2) * ((nqy+1)/2); i++) { + scratch[i] = input_nybble(infile); + } +*/ + input_nnybble(infile, ((nqx+1)/2) * ((nqy+1)/2), scratch); + + /* + * insert in bitplane BIT of image A + */ + qtree_bitins64(scratch,nqx,nqy,a,n,bit); +} + +/* ############################################################################ */ +/* + * Huffman decoding for fixed codes + * + * Coded values range from 0-15 + * + * Huffman code values (hex): + * + * 3e, 00, 01, 08, 02, 09, 1a, 1b, + * 03, 1c, 0a, 1d, 0b, 1e, 3f, 0c + * + * and number of bits in each code: + * + * 6, 3, 3, 4, 3, 4, 5, 5, + * 3, 5, 4, 5, 4, 5, 6, 4 + */ +static int input_huffman(unsigned char *infile) +{ +int c; + + /* + * get first 3 bits to start + */ + c = input_nbits(infile,3); + if (c < 4) { + /* + * this is all we need + * return 1,2,4,8 for c=0,1,2,3 + */ + return(1<>bits_to_go) & 1); +} + +/* ############################################################################ */ +/* INPUT N BITS (N must be <= 8) */ + +static int input_nbits(unsigned char *infile, int n) +{ + /* AND mask for retreiving the right-most n bits */ + static int mask[9] = {0, 1, 3, 7, 15, 31, 63, 127, 255}; + + if (bits_to_go < n) { + /* + * need another byte's worth of bits + */ + + buffer2 = (buffer2<<8) | (int) infile[nextchar]; + nextchar++; + bits_to_go += 8; + } + /* + * now pick off the first n bits + */ + bits_to_go -= n; + + /* there was a slight gain in speed by replacing the following line */ +/* return( (buffer2>>bits_to_go) & ((1<>bits_to_go) & (*(mask+n)) ); +} +/* ############################################################################ */ +/* INPUT 4 BITS */ + +static int input_nybble(unsigned char *infile) +{ + if (bits_to_go < 4) { + /* + * need another byte's worth of bits + */ + + buffer2 = (buffer2<<8) | (int) infile[nextchar]; + nextchar++; + bits_to_go += 8; + } + /* + * now pick off the first 4 bits + */ + bits_to_go -= 4; + + return( (buffer2>>bits_to_go) & 15 ); +} +/* ############################################################################ */ +/* INPUT array of 4 BITS */ + +static int input_nnybble(unsigned char *infile, int n, unsigned char array[]) +{ + /* copy n 4-bit nybbles from infile to the lower 4 bits of array */ + +int ii, kk, shift1, shift2; + +/* forcing byte alignment doesn;t help, and even makes it go slightly slower +if (bits_to_go != 8) input_nbits(infile, bits_to_go); +*/ + if (n == 1) { + array[0] = input_nybble(infile); + return(0); + } + + if (bits_to_go == 8) { + /* + already have 2 full nybbles in buffer2, so + backspace the infile array to reuse last char + */ + nextchar--; + bits_to_go = 0; + } + + /* bits_to_go now has a value in the range 0 - 7. After adding */ + /* another byte, bits_to_go effectively will be in range 8 - 15 */ + + shift1 = bits_to_go + 4; /* shift1 will be in range 4 - 11 */ + shift2 = bits_to_go; /* shift2 will be in range 0 - 7 */ + kk = 0; + + /* special case */ + if (bits_to_go == 0) + { + for (ii = 0; ii < n/2; ii++) { + /* + * refill the buffer with next byte + */ + buffer2 = (buffer2<<8) | (int) infile[nextchar]; + nextchar++; + array[kk] = (int) ((buffer2>>4) & 15); + array[kk + 1] = (int) ((buffer2) & 15); /* no shift required */ + kk += 2; + } + } + else + { + for (ii = 0; ii < n/2; ii++) { + /* + * refill the buffer with next byte + */ + buffer2 = (buffer2<<8) | (int) infile[nextchar]; + nextchar++; + array[kk] = (int) ((buffer2>>shift1) & 15); + array[kk + 1] = (int) ((buffer2>>shift2) & 15); + kk += 2; + } + } + + + if (ii * 2 != n) { /* have to read last odd byte */ + array[n-1] = input_nybble(infile); + } + + return( (buffer2>>bits_to_go) & 15 ); +} diff --git a/tksao/fitsy++/hdu.C b/tksao/fitsy++/hdu.C new file mode 100644 index 0000000..27f1a59 --- /dev/null +++ b/tksao/fitsy++/hdu.C @@ -0,0 +1,323 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include + +#include +#include +#include +using namespace std; + +#include "hdu.h" +#include "head.h" + +FitsHDU::FitsHDU(FitsHead* head) +{ + extname_ = head->getString("EXTNAME"); + // trim any spaces at end + if (extname_) { + for (int ii=strlen(extname_)-1; ii>=0; ii--) { + if (extname_[ii] == ' ') + extname_[ii] = '\0'; + else + break; + } + } + + extver_ = head->getInteger("EXTVER", 0); + + bitpix_ = head->getInteger("BITPIX", 0); + naxes_ = head->getInteger("NAXIS", 0); + if (naxes_>FTY_MAXAXES) + naxes_ = FTY_MAXAXES; + + // init naxis_ + for(int i=0; igetInteger(keycat("NAXIS",(i+1)), 0); + + // special case: 1D image + if (naxis_[0]>0 && naxis_[1]==0) + naxis_[1] = 1; + + realbytes_ = 0; + heapbytes_ = head->getInteger("PCOUNT",0); + allbytes_ = 0; + padbytes_ = 0; + databytes_ = 0; + datablocks_ = 0; +} + +FitsHDU::~FitsHDU() +{ + if (extname_) + delete [] extname_; +} + +char* FitsHDU::keycat(const char* name, int i) +{ + ostringstream str; + str << name << i << ends; + memcpy(keybuf,str.str().c_str(),str.str().length()); + return keybuf; +} + +void FitsHDU::updateCards(FitsHead* head) +{ + head->setInteger("BITPIX", bitpix_, NULL); + head->setInteger("NAXIS", naxes_, NULL); + + for (int i=1; i<=naxes_; i++) + head->setInteger(keycat("NAXIS", i), naxis_[i-1], NULL); +} + +// FitsImageHDU + +FitsImageHDU::FitsImageHDU(FitsHead* head) : FitsHDU(head) +{ + size_t imgpixels = (size_t)naxis_[0]*naxis_[1]; + imgbytes_ = imgpixels * (abs(bitpix_)/8); + + size_t realpixels; + if (naxes_>0) { + realpixels = 1; + for (int i=0; igetReal("BZERO", 0.0); + bscale_ = head->getReal("BSCALE", 1.0); + hasblank_ = head->find("BLANK") ? 1:0; + blank_ = head->getInteger("BLANK", 0); +} + +void FitsImageHDU::updateCards(FitsHead* head) +{ + FitsHDU::updateCards(head); + if (blank_) + if (bitpix_ > 0) + head->setInteger("BLANK", blank_, NULL); + + if (bzero_) + head->setReal("BZERO", bzero_ , 7, NULL); + if (bscale_ != 1) + head->setReal("BSCALE", bscale_, 7, NULL); +} + +// FitsTableHDU + +FitsTableHDU::FitsTableHDU(FitsHead* head) : FitsHDU(head) +{ + tfields_ = head->getInteger("TFIELDS", 0); + cols_ = NULL; + + // number of rows * width of row in bytes + realbytes_ = (size_t)naxis_[0]*naxis_[1]; + allbytes_ = realbytes_ + heapbytes_; + datablocks_ = (allbytes_ + (FTY_BLOCK-1))/FTY_BLOCK; + databytes_ = datablocks_ * FTY_BLOCK; + padbytes_ = databytes_ - allbytes_; +} + +FitsTableHDU::~FitsTableHDU() +{ + if (cols_) { + for (int i=0; ittype() << ' '; + str << ends; + return dupstr(str.str().c_str()); +} + +FitsColumn* FitsTableHDU::find(const char* name) +{ + char* n = toUpper(name); + // trim any spaces + char* nn = n; + while (*nn) + nn++; + nn--; + while (*nn == ' ') + *nn-- = '\0'; + + for (int i=0; ittype()); + // trim any spaces + char* tt=t; + while (*tt) + tt++; + tt--; + while (*tt == ' ') + *tt-- = '\0'; + + if (!strncmp(n,t,strlen(n)) && strlen(n)==strlen(t)) { + delete [] n; + delete [] t; + return cols_[i]; + } + + delete [] t; + } + } + + delete [] n; + return NULL; +} + +FitsColumn* FitsTableHDU::find(int i) +{ + if (i>=0 && idimension() : Vector(); +} + +FitsAsciiTableHDU::FitsAsciiTableHDU(FitsHead* head) : FitsTableHDU(head) +{ + cols_ = new FitsColumn*[tfields_]; + + size_t offset = 0; + for (int i=0; igetString(keycat("TFORM",i+1)); + char type = 'F'; + if (tform) { + string x(tform); + istringstream str(x); + str >> type; + } + + switch (type) { + case 'A': + cols_[i] = new FitsAsciiColumnStr(head, i+1, offset); + break; + case 'I': + cols_[i] = new FitsAsciiColumnT(head, i+1, offset); + break; + case 'F': + cols_[i] = new FitsAsciiColumnT(head, i+1, offset); + break; + case 'E': + cols_[i] = new FitsAsciiColumnT(head, i+1, offset); + break; + case 'D': + cols_[i] = new FitsAsciiColumnT(head, i+1, offset); + break; + } + + delete [] tform; + if (cols_[i]) + offset += cols_[i]->width(); + } +} + +FitsBinTableHDU::FitsBinTableHDU(FitsHead* head) : FitsTableHDU(head) +{ + cols_ = new FitsColumn*[tfields_]; + + int offset =0; + for (int i=0; igetString(keycat("TFORM",i+1)); + int repeat; + char type = 'J'; + if (tform) { + string x(tform); + istringstream str(x); + if (isalpha(tform[0])) + str >> type; + else + str >> repeat >> type; + } + + switch (type) { + case 'L': + cols_[i] = new FitsBinColumnLogical(head, i+1, offset); + break; + case 'X': + cols_[i] = new FitsBinColumnBit(head, i+1, offset); + break; + case 'B': + cols_[i] = new FitsBinColumnT(head, i+1, offset); + break; + case 'I': + cols_[i] = new FitsBinColumnT(head, i+1, offset); + break; + case 'U': + cols_[i] = new FitsBinColumnT(head, i+1, offset); + break; + case 'J': + cols_[i] = new FitsBinColumnT(head, i+1, offset); + break; + case 'V': + cols_[i] = new FitsBinColumnT(head, i+1, offset); + break; + case 'K': + cols_[i] = new FitsBinColumnT(head, i+1, offset); + break; + case 'A': + cols_[i] = new FitsBinColumnStr(head, i+1, offset); + break; + case 'E': + cols_[i] = new FitsBinColumnT(head, i+1, offset); + break; + case 'D': + cols_[i] = new FitsBinColumnT(head, i+1, offset); + break; + case 'C': + cols_[i] = NULL; + internalError("Fitsy++ hdu single precision complex column type not supported"); + break; + case 'M': + cols_[i] = NULL; + internalError("Fitsy++ hdu double precision complex column type not supported"); + break; + case 'P': + cols_[i] = new FitsBinColumnArrayP(head, i+1, offset); + break; + case 'Q': + cols_[i] = new FitsBinColumnArrayQ(head, i+1, offset); + break; + + default: + cols_[i] = NULL; + internalError("Fitsy++ hdu unknown table column type"); + break; + } + + delete [] tform; + if (cols_[i]) + offset += cols_[i]->width(); + } +} + diff --git a/tksao/fitsy++/hdu.h b/tksao/fitsy++/hdu.h new file mode 100644 index 0000000..bb1cfc2 --- /dev/null +++ b/tksao/fitsy++/hdu.h @@ -0,0 +1,109 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitshdu_h__ +#define __fitshdu_h__ + +#include + +#include "column.h" + +#define FTY_MAXAXES 10 + +class FitsHead; + +class FitsHDU { + protected: + char* extname_; // EXTNAME keyword + int extver_; // EXTVER keyword + + int bitpix_; // BITPIX keyword + int naxes_; // NAXIS keyword + int naxis_[FTY_MAXAXES]; // NAXIS[i] keywords + + size_t realbytes_; // Number of real bytes + size_t heapbytes_; // Number of heap bytes + size_t allbytes_; // Number of real bytes + heap bytes + size_t padbytes_; // Number of pad bytes + size_t databytes_; // Number of total bytes (padded) + size_t datablocks_; // Number of total blocks + + char keybuf[9]; + char* keycat(const char*, int); + +public: + FitsHDU(FitsHead*); + virtual ~FitsHDU(); + + virtual void updateCards(FitsHead*); + + const char* extname() {return extname_;} + int extver() {return extver_;} + int bitpix() {return bitpix_;} + int naxes() {return naxes_;} + int naxis(int ii) {return naxis_[ii];} + + size_t realbytes() {return realbytes_;} + size_t heapbytes() {return heapbytes_;} + size_t allbytes() {return allbytes_;} + size_t padbytes() {return padbytes_;} + size_t databytes() {return databytes_;} + size_t datablocks() {return datablocks_;} +}; + +class FitsImageHDU : public FitsHDU { +private: + size_t imgbytes_; // number of image bytes + + double bscale_; + double bzero_; + int hasblank_; + int blank_; + +public: + FitsImageHDU(FitsHead*); + + void updateCards(FitsHead*); + + size_t imgbytes() {return imgbytes_;} + void setScaling(double t,double z) {bscale_=t; bzero_=z;} + double bscale() {return bscale_;} + double bzero() {return bzero_;} + int hasscaling() {return bscale_ != 1 || bzero_ != 0;} + int hasblank() {return hasblank_;} + int blank() {return blank_;} +}; + +class FitsTableHDU : public FitsHDU { +protected: + int tfields_; + FitsColumn** cols_; + +public: + FitsTableHDU(FitsHead*); + virtual ~FitsTableHDU(); + + int tfields() {return tfields_;} + int rows() {return naxis_[1];} + int cols() {return tfields_;} + int width() {return naxis_[0];} + char* list(); + FitsColumn* find(const char*); + FitsColumn* find(int); + Vector dimension(const char*); +}; + +class FitsBinTableHDU : public FitsTableHDU { +public: + FitsBinTableHDU(FitsHead*); +}; + +class FitsAsciiTableHDU : public FitsTableHDU { +public: + FitsAsciiTableHDU(FitsHead*); +}; + +#endif + + diff --git a/tksao/fitsy++/head.C b/tksao/fitsy++/head.C new file mode 100644 index 0000000..f3807fb --- /dev/null +++ b/tksao/fitsy++/head.C @@ -0,0 +1,643 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include +#include + +#ifndef __WIN32 +#include +#include +#endif + +#include "file.h" +#include "head.h" + +FitsHead::FitsHead(char* raw, size_t bytes, Memory mem) +{ + cards_ = raw; + mapdata_ = raw; + mapsize_ = bytes; + memory_ = mem; + ncard_ = 0; + acard_ = 0; + ccard_ = 0; + + index_ = NULL; + + valid_ = 0; + inherit_ = 0; + + hdu_ = NULL; + + char* c; + int i; + for (c = cards_, i=0; c < cards_+bytes; c+=FTY_CARDLEN, i++) { + // only compare 4 chars + if (!strncmp(c, "END ", 4)) { + ncard_ = i + 1; + acard_ = ((ncard_+FTY_CARDS-1)/FTY_CARDS) * FTY_CARDS; + valid_ = 1; + + buildIndex(); + updateHDU(); + return; + } + } +} + +FitsHead::FitsHead(char* raw, size_t bytes, char* mm, + size_t sz, Memory mem) +{ + cards_ = raw; + mapdata_ = mm; + mapsize_ = sz; + memory_ = mem; + ncard_ = 0; + acard_ = 0; + ccard_ = 0; + + index_ = NULL; + + valid_ = 0; + inherit_ = 0; + + hdu_ = NULL; + + char* c; + int i; + for (c = cards_, i=0; c < cards_+bytes; c+=FTY_CARDLEN, i++) { + // only compare 4 chars + if (!strncmp(c, "END ", 4)) { + ncard_ = i + 1; + acard_ = ((ncard_+FTY_CARDS-1)/FTY_CARDS) * FTY_CARDS; + valid_ = 1; + + buildIndex(); + updateHDU(); + return; + } + } +} + +// Create Image FitsHead + +FitsHead::FitsHead(int width, int height, int depth, int bitpix, char* xtension) +{ + cards_ = new char[FTY_BLOCK]; + memset(cards_, ' ', FTY_BLOCK); + memcpy(cards_, "END", 3); + + mapdata_ = NULL; + mapsize_ = 0; + memory_ = ALLOC; + + ncard_ = 1; + acard_ = FTY_CARDS; + ccard_ = 0; + + index_ = NULL; + + if (!xtension) + appendLogical("SIMPLE", 1, "Fits Standard"); + else + appendString("XTENSION", xtension, "Fits Standard"); + + appendInteger("BITPIX", bitpix, "Bits per pixel"); + appendInteger("NAXIS", depth>1 ? 3 : 2, "Number of axes"); + appendInteger("NAXIS1", width, "Axis Length"); + appendInteger("NAXIS2", height, "Axis Length"); + if (depth>1) + appendInteger("NAXIS3", depth, "Axis Length"); + + valid_ = 1; + inherit_ = 0; + + hdu_ = NULL; + + buildIndex(); + updateHDU(); +} + +FitsHead::FitsHead(int width, int height, int depth, int bitpix, + char* mm, size_t sz, Memory mem) +{ + cards_ = new char[FTY_BLOCK]; + memset(cards_, ' ', FTY_BLOCK); + memcpy(cards_, "END", 3); + + mapdata_ = mm; + mapsize_ = sz; + memory_ = mem; + + ncard_ = 1; + acard_ = FTY_CARDS; + ccard_ = 0; + + index_ = NULL; + + appendLogical("SIMPLE", 1, "Fits Standard"); + appendInteger("BITPIX", bitpix, "Bits per pixel"); + appendInteger("NAXIS", depth==1 ? 2 : 3, "Number of axes"); + appendInteger("NAXIS1", width, "Axis Length"); + appendInteger("NAXIS2", height, "Axis Length"); + if (depth>1) + appendInteger("NAXIS3", depth, "Axis Length"); + + valid_ = 1; + inherit_ = 0; + + hdu_ = NULL; + + buildIndex(); + updateHDU(); +} + +FitsHead::FitsHead(const FitsHead& a) +{ + cards_ = new char[a.acard_*FTY_CARDLEN]; + memmove(cards_, a.cards_, a.acard_*FTY_CARDLEN); + mapdata_ = NULL; + mapsize_ = 0; + memory_ = ALLOC; + + index_ = NULL; + acard_ = a.acard_; + ncard_ = a.ncard_; + ccard_ = a.ccard_; + + valid_ = 1; + inherit_ = 0; + + hdu_ = NULL; + + buildIndex(); + updateHDU(); +} + +FitsHead::~FitsHead() +{ + if (index_) + delete [] index_; + + if (hdu_) + delete hdu_; + + switch (memory_) { + case ALLOC: + if (cards_) + delete [] cards_; + break; + case MMAP: +#ifndef __WIN32 + if (mapdata_>0) + munmap((caddr_t)mapdata_, mapsize_); +#endif + break; + case SHARE: +#ifndef __WIN32 + if (mapdata_>0) + shmdt(mapdata_); +#endif + case EXTERNAL: + break; + } +} + +int FitsHead::isImage() +{ + // just look for SIMPLE, if present it may be of value 'F' + char* xtension = getString("XTENSION"); + char* simple = find("SIMPLE"); + int r = + (simple || (xtension && !strncmp(xtension, "IMAGE", 5))) && + naxes() > 0 && + naxis(0) > 0 && + naxis(1) > 0; + + delete [] xtension; + return r; +} + +int FitsHead::isTable() +{ + char* xtension = getString("XTENSION"); + int r = (xtension && (!strncmp(xtension, "TABLE", 5) || + !strncmp(xtension, "BINTABLE", 8))); + + delete [] xtension; + return r; +} + +int FitsHead::isAsciiTable() +{ + char* xtension = getString("XTENSION"); + int r = (xtension && (!strncmp(xtension, "TABLE", 5))); + + delete [] xtension; + return r; +} + +int FitsHead::isBinTable() +{ + char* xtension = getString("XTENSION"); + int r = (xtension && (!strncmp(xtension, "BINTABLE", 8))); + + delete [] xtension; + return r; +} + +int FitsHead::isHeap() +{ + return getInteger("PCOUNT",0) ? 1 : 0; +} + +void FitsHead::updateHDU() +{ + if (hdu_) + delete hdu_; + hdu_ = NULL; + + // just find simple, it might be present but of value 'F' + char* simple = find("SIMPLE"); + char* xtension = getString("XTENSION"); + + if (xtension) + inherit_ = getLogical("INHERIT",0); + + if (simple || (xtension && !strncmp(xtension, "IMAGE", 5))) + hdu_ = new FitsImageHDU(this); + + if (xtension && !strncmp(xtension, "TABLE", 5)) + hdu_ = new FitsAsciiTableHDU(this); + + if (xtension && !strncmp(xtension, "BINTABLE", 8)) + hdu_ = new FitsBinTableHDU(this); + + delete [] xtension; +} + +int FitsHead::getLogical(const char* name, int def) +{ + char* card = find(name); + if (card) { + FitsCard c(card); + return c.getLogical(); + } + else + return def; +} + +int FitsHead::getInteger(const char* name, int def) +{ + char* card = find(name); + if (card) { + FitsCard c(card); + return c.getInteger(); + } + else + return def; +} + +double FitsHead::getReal(const char* name, double def) +{ + char* card = find(name); + if (card) { + FitsCard c(card); + return c.getReal(); + } + else + return def; +} + +void FitsHead::getComplex(const char* name, double* real, double* img, + double rdef, double idef) +{ + char* card = find(name); + if (card) { + FitsCard c(card); + c.getComplex(real, img); + } + else { + *real = rdef; + *img = idef; + } +} + +char* FitsHead::getString(const char* name) +{ + char* card = find(name); + if (card) { + FitsCard c(card); + return c.getString(); + } + else + return NULL; +} + +char* FitsHead::getComment(const char* name) +{ + char* card = find(name); + if (card) { + FitsCard c(card); + return c.getComment(); + } + else + return NULL; +} + +char* FitsHead::getKeyword(const char* name) +{ + char* card = find(name); + if (card) { + FitsCard c(card); + return c.getAsString(); + } + else + return NULL; +} + +char* FitsHead::setKey(const char* name, const char* value) +{ + char* card = find(name); + if (card) + FitsCard(card).setKey(value); + + buildIndex(); + return card; +} + +char* FitsHead::setLogical(const char* name, int value, const char* comm) +{ + char* card = find(name); + if (card) + FitsCard(card).setLogical(value, comm); + + return card; +} + +char* FitsHead::setInteger(const char* name, int value, const char* comm) +{ + char* card = find(name); + if (card) + FitsCard(card).setInteger(value, comm); + + return card; +} + +char* FitsHead::setReal(const char* name, double value, int prec, + const char* comm) +{ + char* card = find(name); + if (card) + FitsCard(card).setReal(value, prec, comm); + + return card; +} + +char* FitsHead::setComplex(const char* name, double real, double img, int prec, + const char* comm) +{ + char* card = find(name); + if (card) + FitsCard(card).setComplex(real, img, prec, comm); + + return card; +} + +char* FitsHead::setString(const char* name, const char* value, const char* comm) +{ + char* card = find(name); + if (card) + FitsCard(card).setString(value, comm); + + return card; +} + +char* FitsHead::setComment(const char* name, const char* value) +{ + char* card = find(name); + if (card) + FitsCard(card).setComment(value); + + return card; +} + +char* FitsHead::cardins(char* card, char* here) +{ + // do we need to allocate another block? + if (ncard_+1 > acard_) { + switch (memory_) { + case ALLOC: + { + char* old = cards_; + int oldsz = acard_*FTY_CARDLEN; + int sz = oldsz+FTY_BLOCK; + + acard_ = sz/FTY_CARDLEN; + cards_ = new char[sz]; + memset(cards_, ' ', sz); + memcpy(cards_, old, oldsz); + + // don't forget to redirect here if needed + if (here) { + size_t diff = here-old; + here = cards_+diff; + } + delete [] old; + } + break; + case MMAP: + case SHARE: + case EXTERNAL: + internalError("Fitsy++ head can't add card: readonly memory"); + return NULL; + } + } + + char* where = here ? here : cards_+((ncard_-1)*FTY_CARDLEN); + memmove(where+FTY_CARDLEN, where, (cards_+(ncard_*FTY_CARDLEN))-where); + memmove(where, card, FTY_CARDLEN); + ncard_++; + + buildIndex(); + + return where; +} + +char* FitsHead::carddel(const char* name) +{ + char* card = find(name); + if (card) { + char* next = card+FTY_CARDLEN; + char* last = cards_+((ncard_-1)*FTY_CARDLEN); + memmove(card, next, last-card); + memset(last,' ', FTY_CARDLEN); + } + + buildIndex(); + return card; +} + +char* FitsHead::cardclear(const char* name) +{ + char* card = find(name); + if (card) + FitsCard(card).clear(); + + buildIndex(); + return card; +} + +char* FitsHead::insertLogical(const char* name, int value, const char* comm, + const char* here) +{ + FitsCard key; + key.setLogical(name, value, comm); + return cardins(key.card(), (char*)here); +} + +char* FitsHead::insertInteger(const char* name, int value, const char* comm, + const char* here) +{ + FitsCard key; + key.setInteger(name, value, comm); + return cardins(key.card(), (char*)here); +} + +char* FitsHead::insertReal(const char* name, double value, int prec, + const char* comm, const char* here) +{ + FitsCard key; + key.setReal(name, value, prec, comm); + return cardins(key.card(), (char*)here); +} + +char* FitsHead::insertComplex(const char* name, double real, double img, + int prec, const char* comm, const char* here) +{ + FitsCard key; + key.setComplex(name, real, img, prec, comm); + return cardins(key.card(), (char*)here); +} + +char* FitsHead::insertString(const char* name, const char* value, + const char* comm, const char* here) +{ + FitsCard key; + key.setString(name, value, comm); + return cardins(key.card(), (char*)here); +} + +char* FitsHead::insertComment(const char* name, const char* value, + const char* here) +{ + FitsCard key; + key.setComment(name, value); + return cardins(key.card(), (char*)here); +} + +char* FitsHead::first() +{ + ccard_ = 0; + return (ccard_8 ? 8 : len); + for (int i=0; i8 ? 8 : len); + for (int i=0; i 1) { + int i = strncmp(k, base[cut], 8); + if (!i) + return base[cut]; + + if (i < 0) { + hi = cut; + cut = (lo+hi)/2; + } + else { + lo = cut; + cut = (lo+hi)/2; + } + } + + if (!strncmp(k, base[cut], 8)) + return base[cut]; + + return NULL; +} + +static int compare(const void* a, const void* b) +{ + char** aa = (char**)a; + char** bb = (char**)b; + return strncmp(*aa, *bb, 8); +} + +void FitsHead::buildIndex() +{ + if (index_) + delete [] index_; + + index_ = new char*[ncard_]; + for (int i=0; iextname() : NULL;} + int extver() {return hdu_ ? hdu_->extver() : 0;} + int bitpix() {return hdu_ ? hdu_->bitpix() : 0;} + int naxes() {return hdu_ ? hdu_->naxes() : 0;} + int naxis(int ii) {return hdu_ ? hdu_->naxis(ii) : 0;} + + size_t realbytes() {return hdu_ ? hdu_->realbytes() : 0;} + size_t heapbytes() {return hdu_ ? hdu_->heapbytes() : 0;} + size_t allbytes() {return hdu_ ? hdu_->allbytes() : 0;} + size_t padbytes() {return hdu_ ? hdu_->padbytes() : 0;} + size_t databytes() {return hdu_ ? hdu_->databytes() : 0;} + size_t datablocks() {return hdu_ ? hdu_->datablocks() : 0;} + + void buildIndex(); + void updateHDU(); + void updateCards() {if (hdu_) hdu_->updateCards(this);} + + char* find(const char* name); + char* findSeq(const char* name); + char* findIndex(const char* name); + + char* cardins(char* card, char* here); + char* carddel(const char* card); + char* cardclear(const char* card); + + char* setKey(const char* name, const char* value); + char* setLogical(const char* name, int value, const char* comm); + char* setInteger(const char* name, int value, const char* comm); + char* setReal(const char* name, double value, int prec, const char* comm); + char* setComplex(const char* name, double real, double img, int prec, + const char* comm); + char* setString(const char* name, const char* value, const char* comm); + char* setComment(const char* name, const char* value); + + char* insertLogical(const char* name, int value, const char* comm, + const char* here); + char* insertInteger(const char* name, int value, const char* comm, + const char* here); + char* insertReal(const char* name, double value, + int prec, const char* comm, const char* here); + char* insertComplex(const char* name, double real, double img, + int prec, const char* comm, const char* here); + char* insertString(const char* name, const char* value, const char* comm, + const char* here); + char* insertComment(const char* name, const char* value, const char* here); + + char* appendLogical(const char* name, int value, const char* comm) + {return insertLogical(name, value, comm, NULL);} + char* appendInteger(const char* name, int value, const char* comm) + {return insertInteger(name, value, comm, NULL);} + char* appendReal(const char* name, double value, int prec, const char* comm) + {return insertReal(name, value, prec, comm, NULL);} + char* appendComplex(const char* name, double real, double img, + int prec, const char* comm) + {return insertComplex(name, real, img, prec, comm, NULL);} + char* appendString(const char* name, const char* value, const char* comm) + {return insertString(name, value, comm, NULL);} + + int getLogical(const char* name, int def); + int getInteger(const char* name, int def); + double getReal(const char* name, double def); + void getComplex(const char* name, double* real, double* img, + double rdef, double idef); + char* getString(const char* name); + char* getComment(const char* name); + + char* getKeyword(const char* name); + + char* first(); + char* next(); +}; + +#endif diff --git a/tksao/fitsy++/hist.C b/tksao/fitsy++/hist.C new file mode 100644 index 0000000..fa181fc --- /dev/null +++ b/tksao/fitsy++/hist.C @@ -0,0 +1,662 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include + +#include +#include +#include +using namespace std; + +#include "hist.h" +#include "util.h" + +#include "fitsy.h" +#include "filter.h" + +#ifdef __CYGWIN__ +// limit size, cygwin pipe to 64K / (4 args x 4 bytes) +#define FILTERSIZE 2048 +#else +#define FILTERSIZE 65536 +#endif +#define MULTWCS 27 + +char *gerrorstring(void); + +static const char* reservedKeywords[] = { + "SIMPLE","XTENSION","ZSIMPLE","ZTENSION","ZIMAGE","ZTABLE", + "BITPIX","ZBITPIX", + "NAXIS","ZNAXIS", + "NAXIS.","ZNAXIS.", + "END", + "PCOUNT","ZPCOUNT", + "GCOUNT","ZGCOUNT", + "CHECKSUM","ZHECKSUM", + "DATASUM","ZDATASUM", + /* "OBJECT",*/ + "INHERIT", + "BSCALE", + "BZERO","TZERO.", + "BUNIT","TUNIT.", + "BLANK", + "DATAMAX","TDMAX.","TLMAX.", + "DATAMIN","TDMIN.","TLMIN.", + "BLOCKED","ZBLOCKED", + "EXTENDED","ZEXTEND", + + "EXTNAME","ZNAME.", + "EXTVER", + "EXTLEVEL", + + "TFIELDS", + "TFORM.","ZFORM.", + "TBCOL.", + + "ZCMPTYPE","ZCTYP.","ZTILELEN","ZTILE.","ZVAL.", + "ZMASKCMP","ZQUANTIZ","ZDITHER0","ZTHEAP", + "TSCAL.","TNULL.","TTYPE.","TDISP.", "TDIM.","THEAP", + "FZTILELN","FZALGOR","FZALG.", + "PTYPE.","PSCAL.","PZERO.", + + "WCSAXES.","WCSAX.?", + "CTYPE.?",".CTYP.",".CTY.?","TCTYP.","TCTY.?", + "CUNIT.?",".CUNI.",".CUN.?","TCUNI.","TCUN.?", + "CRVAL.?",".CRVL.",".CRV.?","TCRVL.","TCRV.?", + "CDELT.?",".CDLT.",".CDE.?","TCDLT.","TCDE.?", + "CRPIX.?",".CRPX.",".CRP.?","TCRPX.","TCRP.?", + "CROTA.",".CROT.","TCROT.", + "PC._.?","..PC.?","TPC._.?","TP._.?", + "CD._.?","..CD.?","TCD._.?","TC._.?", + "PV._.?",".PV._.?",".V._.?","TPV._.?","TV._.?", + ".V._X?", + "PS._.?",".PS._.?",".S._.?","TPS._.?","TS._.?", + "WCSNAME?","WCSN.?","WCS.?","TWCS.?", + "CNAME.?",".CNA.?","TCNA.?", + "CRDER.?",".CRD.?","TCRD.?", + "CSYER.?",".CSY.?","TCSY.?", + "WCST.?", + "WCSX.?", + /* "LONPOLE?", */ "LONP.?", + /* "LATPOLE?", */ "LATP.?", + /* "EQUINOX?", */ "EQUI.?", + /* "EPOCH", */ + /* "RADESYS", */ "REDE.?", + "RESTFRQ?","RFRQ.?", + "RESTWAV?","RWAV.?", + "SPECSYS?","SPEC.?", + "SSYSOBS?","SOBS.?", + "SSYSSRC?","SSRC.?", + "OBSGEO-X","OBSGX.", + "OBSGEO-Y","OBSGY.", + "OBSGEO-Z","OBSGZ.", + "VELOSYS?","VSYS.?", + "ZSOURCE?","ZSOU.?", + "VELANGL?","VANG.?", + + /* "DATE",*/ + /* "DATE-OBS", */ "DOBS.", + /* "MJD-OBS", */ "MJDOB.", + "BEPOCH", + "JEPOCH", + /* "DATE-AVE", */ "DAVG.", + /* "MJD-AVG", */ "MJDA.", + /* "DATE-BEG", */ + /* "MJD-BEG", */ + /* "TSTART", "TSTOP", */ + /* "DATE-END", */ + /* "MJD-END", */ + "XPOSURE", + "TELAPSE", + /* "TIMESYS",*/ + /* "MJDREF",*/ + /* "JDREF",*/ + /* "DATEREF",*/ + "TREFPOS","TRPOS.", + "TREFDIR","TRDIR.", + "PLEPHEM", + /* "TIMEUNIT",*/ + /* "TIMEOFFS",*/ + /* "TIMSYER",*/ + /* "TIMRDER",*/ + /* "TIMEDEL",*/ + /* "TIMEPIXR",*/ + "CZPHS",".CZPH.",".CZP.?","TCZPH.","TCZP.?", + "CPERI",".CPER.",".CPR.?","TCPER.","TCPR.?" +}; + +FitsHist::FitsHist(FitsFile* fits, int w, int h, int d, + Matrix& m, Function func, Vector block) + : width_(w), height_(h), depth_(d) +{ + size_ = (size_t)width_*height_*depth_; + + xcol_ = NULL; + ycol_ = NULL; + zcol_ = NULL; + + fitsy_ = NULL; + filter_ = NULL; + + valid_ = 0; + + if (!initHeader(fits)) + return; + + // we need to translate by another .5 for the offset from Data to Image + Matrix mm = m * Translate(.5,.5); + + initLTMV(mm); + initWCS(fits, mm, block); + + initFilter(fits); + bin(fits, m, func, block); + + if (byteswap_) + swap(); + + deleteFilter(); + valid_ = 1; +} + +FitsHist::~FitsHist() +{ + if (data_) + delete [] (float*)data_; +} + +int FitsHist::initHeader(FitsFile* fits) +{ + FitsHead* srcHead = fits->head(); + FitsTableHDU* srcHDU = (FitsTableHDU*)(srcHead->hdu()); + + // make sure we have a table with columns, X, Y + if (!fits->isBinTable()) + return 0; + + // make sure we have rows and cols + if (!srcHDU->width() || !srcHDU->rows()) + return 0; + + // get X column + if (fits->pBinX()) + xcol_ = srcHDU->find(fits->pBinX()); + + if (!xcol_) + return 0; + + // get Y column + if (fits->pBinY()) + ycol_ = srcHDU->find(fits->pBinY()); + + if (!ycol_) + return 0; + + // get Z column (if specified) + if (fits->pBinZ() && depth_ > 1) + zcol_ = srcHDU->find(fits->pBinZ()); + else + zcol_ = NULL; + + // create header + head_ = new FitsHead(width_, height_, depth_, -32); + if (!head_->isValid()) + return 0; + + // now screen other KEYWORDS for addition + char* cc = srcHead->first(); + while (cc) { + if (screenKeyword(cc)) + head_->cardins(cc, (char*)NULL); + cc = srcHead->next(); + } + + // MJD-OBJ deprecated + double rr = srcHead->getReal("MJD_OBS",0); + if (rr) + head_->appendReal("MJD-OBS", rr, 10, NULL); + + // we added cards + head_->updateHDU(); + + return 1; +} + +static int mstrcmp(const char* s1, const char* s2) +{ + const char* p1 = s1; + const char* p2 = s2; + while (*p1 != '\0') { + if (*p1 == '?') + return 0; + + if (*p2=='\0') + return 1; + if (*p1 != '.') { + if (*p2>*p1) + return -1; + if (*p2<*p1) + return 1; + } + else { + if (*p2<'0' || *p2>'9') + return 1; + p2++; + if (*p2<'0' || *p2>'9') + p2--; + } + + p1++; + p2++; + } + + if (*p2 != '\0') + return -1; + + return 0; +} + +int FitsHist::screenKeyword(const char* cc) +{ + int cnt= sizeof(reservedKeywords)/sizeof(const char*); + + char key[9]; + memset(key,0,9); + strncpy(key,cc,8); + for (int ii=8; ii>=0; ii--) + if (key[ii]==' ') + key[ii] = '\0'; + + const char** ptr = reservedKeywords; + for (int ii=0; iihead(); + + const char* filtstr = fits->pFilter(); + if (filtstr && *filtstr) { + + ostringstream str; + str << "bincols=(" << fits->pBinX() << ',' << fits->pBinY() << ')'; + + if (byteswap_) + str << ",convert=true"; + str << ends; + + if (!(fitsy_ = ft_headinit(srcHead->cards(), srcHead->headbytes()))) + internalError("Fitsy++ hist bad filter head"); + else { + if (!(filter_ = FilterOpen((FITSHead)fitsy_, (char*)filtstr, + (char*)str.str().c_str()))){ + internalError("Fitsy++ hist unable to build filter"); + } + } + } +} + +void FitsHist::deleteFilter() +{ + if (filter_) { + FilterClose((Filter)filter_); + filter_ = NULL; + } + + if (fitsy_) { + ft_headfree((FITSHead)fitsy_,0); + fitsy_ = NULL; + } +} + +void FitsHist::bin(FitsFile* fits, Matrix& m, Function func, Vector block) +{ + FitsHead* srcHead = fits->head(); + FitsTableHDU* srcHDU = (FitsTableHDU*)(srcHead->hdu()); + + // create image space + float* dest = new float[size_]; + memset(dest, 0, size_*sizeof(float)); + + // bin it up + char* ptr = (char*)fits->data(); + int rowlen = srcHDU->width(); + int rows = srcHDU->rows(); + + // third dimension + double zmin; + double zlength; + if (zcol_) { + zmin = zcol_->getMin(); + zlength = zcol_->getMax() - zcol_->getMin(); + } + + // filter + int goodincr = 0; + int goodindex = FILTERSIZE; + int* good = NULL; + if (filter_) + good = new int[FILTERSIZE]; + + // matrix + register double m00 = m.matrix(0,0); + register double m10 = m.matrix(1,0); + register double m20 = m.matrix(2,0); + register double m01 = m.matrix(0,1); + register double m11 = m.matrix(1,1); + register double m21 = m.matrix(2,1); + + for (int ii=0; ii=FILTERSIZE)) { + // for memory models that support internal paging + // need at lease FILTERSIZE rows + ptr = fits->page(ptr, rowlen*FILTERSIZE); + + int diff = srcHDU->rows() - (goodincr * FILTERSIZE); + if (FilterEvents((Filter)filter_, ptr, srcHDU->width(), + (diffpage(ptr, rowlen); + } + + if (!good || (good && good[goodindex])) { + register double x = xcol_->value(ptr); + register double y = ycol_->value(ptr); + + register double X = x*m00 + y*m10 + m20; + register double Y = x*m01 + y*m11 + m21; + + if (X >= 0 && X < width_ && Y >= 0 && Y < height_) { + if (!zcol_) + dest[((int)Y)*width_ + (int)X]++; + else { + int zz = (int)((zcol_->value(ptr)-zmin)/zlength*depth_); + if (zz>=0 && zzresetpage(); + + // Average + if (func==AVERAGE) + for (size_t kk=0; kkappendReal("LTM1_1", m[0][0], 10, NULL); + head_->appendReal("LTM1_2", m[0][1], 10, NULL); + head_->appendReal("LTM2_1", m[1][0], 10, NULL); + head_->appendReal("LTM2_2", m[1][1], 10, NULL); + head_->appendReal("LTV1" , m[2][0], 10, NULL); + head_->appendReal("LTV2" , m[2][1], 10, NULL); +} + +void FitsHist::mapWCSString(FitsHead* head, char* w, + const char* out, const char* prim) +{ + ostringstream istr; + istr << prim << xcol_->index() << w << ends; + + if (head->find(istr.str().c_str())) { + char* cc = head->getString(istr.str().c_str()); + head_->appendString(out, cc, NULL); + delete [] cc; + } +} + +void FitsHist::mapWCSString(FitsHead* head, char* w, + const char* out, const char* prim, const char* alt) +{ + ostringstream istr1, istr2; + if (!w[0]) { + istr1 << prim << xcol_->index() << w << ends; + istr2 << prim << ycol_->index() << w << ends; + } + else { + istr1 << alt << xcol_->index() << w << ends; + istr2 << alt << ycol_->index() << w << ends; + } + ostringstream ostr1, ostr2; + ostr1 << out << "1" << w << ends; + ostr2 << out << "2" << w << ends; + + if (head->find(istr1.str().c_str()) || + head->find(istr2.str().c_str())) { + char* cc1 = head->getString(istr1.str().c_str()); + char* cc2 = head->getString(istr2.str().c_str()); + + head_->appendString(ostr1.str().c_str(), cc1, NULL); + head_->appendString(ostr2.str().c_str(), cc2, NULL); + delete [] cc1; + delete [] cc2; + } +} + +void FitsHist::mapWCSReal(FitsHead* head, const char* out, const char* in) +{ + ostringstream istr; + istr << in << xcol_->index() << ends; + + if (head->find(istr.str().c_str())) { + float cc = head->getReal(istr.str().c_str(), 0); + head_->appendReal(out, cc, 10, NULL); + } +} + +void FitsHist::mapWCSReal(FitsHead* head, char* w, + const char* out, const char* in) +{ + ostringstream istr; + istr << in << xcol_->index() << w << ends; + + if (head->find(istr.str().c_str())) { + float cc = head->getReal(istr.str().c_str(), 0); + head_->appendReal(out, cc, 10, NULL); + } +} + +void FitsHist::mapWCSReal(FitsHead* head, char* w, + const char* out, const char* prim, const char* alt, + Matrix mm) +{ + ostringstream istr1, istr2; + if (!w[0]) { + istr1 << prim << xcol_->index() << w << ends; + istr2 << prim << ycol_->index() << w << ends; + } + else { + istr1 << alt << xcol_->index() << w << ends; + istr2 << alt << ycol_->index() << w << ends; + } + ostringstream ostr1, ostr2; + ostr1 << out << "1" << w << ends; + ostr2 << out << "2" << w << ends; + + if (head->find(istr1.str().c_str()) || + head->find(istr2.str().c_str())) { + float cc1 = head->getReal(istr1.str().c_str(),0); + float cc2 = head->getReal(istr2.str().c_str(),0); + Vector cc = Vector(cc1,cc2) * mm; + + head_->appendReal(ostr1.str().c_str(), cc[0], 10, NULL); + head_->appendReal(ostr2.str().c_str(), cc[1], 10, NULL); + } +} + +void FitsHist::mapWCSMatrix(FitsHead* head, char* w, + const char* out, const char* in, + Vector vv) +{ + ostringstream istr1, istr2, istr3, istr4; + istr1 << in << xcol_->index() << "_" << xcol_->index() << w << ends; + istr2 << in << xcol_->index() << "_" << ycol_->index() << w << ends; + istr3 << in << ycol_->index() << "_" << xcol_->index() << w << ends; + istr4 << in << ycol_->index() << "_" << ycol_->index() << w << ends; + + ostringstream ostr1, ostr2, ostr3, ostr4; + ostr1 << out << "1_1" << w << ends; + ostr2 << out << "1_2" << w << ends; + ostr3 << out << "2_1" << w << ends; + ostr4 << out << "2_2" << w << ends; + + if (head->find(istr1.str().c_str()) || + head->find(istr2.str().c_str()) || + head->find(istr3.str().c_str()) || + head->find(istr4.str().c_str())) { + float cc11 = head->getReal(istr1.str().c_str(), 0); + float cc12 = head->getReal(istr2.str().c_str(), 0); + float cc21 = head->getReal(istr3.str().c_str(), 0); + float cc22 = head->getReal(istr4.str().c_str(), 0); + Matrix cc = Matrix(cc11*vv[0], cc12*vv[0], + cc21*vv[1], cc22*vv[1], + 0, 0); + head_->appendReal(ostr1.str().c_str(), cc[0][0], 10, NULL); + head_->appendReal(ostr2.str().c_str(), cc[0][1], 10, NULL); + head_->appendReal(ostr3.str().c_str(), cc[1][0], 10, NULL); + head_->appendReal(ostr4.str().c_str(), cc[1][1], 10, NULL); + } +} + +void FitsHist::mapWCSVector(FitsHead* head, char* w, + const char* out, const char* in) +{ + for (int ii=0; ii<=9; ii++) { + ostringstream istr1, istr2; + istr1 << in << xcol_->index() << "_" << ii << w << ends; + istr2 << in << ycol_->index() << "_" << ii << w << ends; + + ostringstream ostr1, ostr2; + ostr1 << out << "1_" << ii << ends; + ostr2 << out << "2_" << ii << ends; + + if (head->find(istr1.str().c_str()) || + head->find(istr2.str().c_str())) { + float cc1 = head->getReal(istr1.str().c_str(), 0); + float cc2 = head->getReal(istr2.str().c_str(), 0); + head_->appendReal(ostr1.str().c_str(), cc1, 10, NULL); + head_->appendReal(ostr2.str().c_str(), cc2, 10, NULL); + } + } +} + +void FitsHist::initWCS(FitsFile* fits, Matrix& mm, Vector block) +{ + FitsHead* srcHead = fits->head(); + char w[2]; + w[1] = '\0'; + + for (int i=0; ifind("EQUINOX")) + mapWCSReal(srcHead, w, "EQUINOX", "EQUI"); + if (!head_->find("MJD-OBS")) + mapWCSReal(srcHead, "MJD-OBS", "MJDOB"); + if (!head_->find("RADESYS")) + mapWCSString(srcHead, w, "RADESYS", "RADE"); + } +} + +FitsHistNext::FitsHistNext(FitsFile* prev) +{ + primary_ = prev->primary(); + managePrimary_ = 0; + + head_ = prev->head(); + manageHead_ = 0; + + FitsImageHDU* hdu = (FitsImageHDU*)head_->hdu(); + data_ = (char*)prev->data() + hdu->imgbytes(); + dataSize_ = 0; + dataSkip_ = 0; + + ext_ = prev->ext(); + inherit_ = prev->inherit(); + byteswap_ = prev->byteswap(); + endian_ = prev->endian(); + valid_ = 1; + + return; +} diff --git a/tksao/fitsy++/hist.h b/tksao/fitsy++/hist.h new file mode 100644 index 0000000..abfc498 --- /dev/null +++ b/tksao/fitsy++/hist.h @@ -0,0 +1,59 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitshist_h__ +#define __fitshist_h__ + +#include "vector.h" +#include "file.h" + +class FitsHist : public FitsFile { + public: + enum Function {SUM, AVERAGE}; + + private: + int width_; + int height_; + int depth_; + size_t size_; + + FitsColumn* xcol_; + FitsColumn* ycol_; + FitsColumn* zcol_; + + void* fitsy_; + void* filter_; + + int initHeader(FitsFile*); + int screenKeyword(const char*); + void initLTMV(Matrix&); + void initWCS(FitsFile*, Matrix&, Vector); + void mapWCSMatrix(FitsHead*, char* w, const char* out, const char* in, + Vector); + void mapWCSReal(FitsHead* head, const char* out, const char* in); + void mapWCSReal(FitsHead* head, char* w, const char* out, const char* in); + void mapWCSReal(FitsHead*, char* w, + const char* out, const char* prim, const char* alt, + Matrix); + void mapWCSString(FitsHead*, char* w, const char* out, const char* prim); + void mapWCSString(FitsHead*, char* w, + const char* out, const char* prim, const char* alt); + void mapWCSVector(FitsHead*, char* w, const char* out, const char* in); + void initFilter(FitsFile*); + void deleteFilter(); + void bin(FitsFile*, Matrix&, Function, Vector); + void swap(); + + public: + FitsHist(FitsFile* src, int width, int height, int depth, + Matrix& m, Function func, Vector block); + ~FitsHist(); +}; + +class FitsHistNext : public FitsFile { +public: + FitsHistNext(FitsFile* prev); +}; + +#endif diff --git a/tksao/fitsy++/hpx.C b/tksao/fitsy++/hpx.C new file mode 100644 index 0000000..0078858 --- /dev/null +++ b/tksao/fitsy++/hpx.C @@ -0,0 +1,579 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +// This source has been modified from the original authored by +// Dr. Mark Calabretta as distributed with WCSLIBS under GNU GPL version 3 +// WCSLIB 4.7 - an implementation of the FITS WCS standard. +// Copyright (C) 1995-2011, Mark Calabretta + +#include +#include + +#include +#include +#include +using namespace std; + +#include "hpx.h" +#include "util.h" + +#include "fitsy.h" + +FitsHPX::FitsHPX(FitsFile* fits, Order oo, CoordSys ss, Layout ll, + int cc, int qq) + : order_(oo), coord_(ss), layout_(ll), quad_(qq) +{ + FitsHead* head = fits->head(); + FitsTableHDU* hdu = (FitsTableHDU*)(head->hdu()); + col_ = (FitsBinColumn*)hdu->find(cc); + if (!col_) + return; + + int nrow = hdu->rows(); + int nelem = col_->repeat(); + + nside_ = head->getInteger("NSIDE",0); + long firstpix = head->getInteger("FIRSTPIX",-1); + long lastpix = head->getInteger("LASTPIX",-1); + + if (!nside_) { + // Deduce NSIDE + if (lastpix >= 0) { + // If LASTPIX is present without NSIDE we can only assume it's npix. + nside_ = (int)(sqrt((double)((lastpix+1) / 12)) + 0.5); + } + else if (nrow) + nside_ = (int)(sqrt((double)((nrow * nelem) / 12)) + 0.5); + } + + long npix = 12*nside_*nside_; + + if (firstpix < 0) + firstpix = 0; + if (lastpix < 0) + lastpix = npix - 1; + + build(fits); + + if (byteswap_) + swap(); + + valid_ = 1; +} + +FitsHPX::~FitsHPX() +{ + if (data_) + delete [] (float*)data_; +} + +void FitsHPX::build(FitsFile* fits) +{ + // Number of facets on a side of each layout + const int NFACET[] = {5, 4, 4}; + + // Arrays that define the facet location and rotation for each recognised + // layout. Bear in mind that these appear to be upside-down, i.e. the top + // line contains facet numbers for the bottom row of the output image. + // Facets numbered -1 are blank. + + // Equatorial (diagonal) facet layout. + const int FACETS[][5][5] = {{{ 6, 9, -1, -1, -1}, + { 1, 5, 8, -1, -1}, + {-1, 0, 4, 11, -1}, + {-1, -1, 3, 7, 10}, + {-1, -1, -1, 2, 6}}, + // North polar (X) facet layout. + {{ 8, 4, 4, 11, -1}, + { 5, 0, 3, 7, -1}, + { 5, 1, 2, 7, -1}, + { 9, 6, 6, 10, -1}, + {-1, -1, -1, -1, -1}}, + // South polar (X) facet layout. + {{ 1, 6, 6, 2, -1}, + { 5, 9, 10, 7, -1}, + { 5, 8, 11, 7, -1}, + { 0, 4, 4, 3, -1}, + {-1, -1, -1, -1, -1}}}; + + // All facets of the equatorial layout are rotated by +45 degrees with + // respect to the normal orientation, i.e. that with the equator running + // horizontally. The rotation recorded for the polar facets is the number + // of additional positive (anti-clockwise) 90 degree turns with respect to + // the equatorial layout. + + // Equatorial (diagonal), no facet rotation. + const int FROTAT[][5][5] = {{{ 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0}}, + // North polar (X) facet rotation. + {{ 3, 3, 0, 0, 0}, + { 3, 3, 0, 0, 0}, + { 2, 2, 1, 1, 0}, + { 2, 2, 1, 1, 0}, + { 0, 0, 0, 0, 0}}, + // South polar (X) facet rotation. + {{ 1, 1, 2, 2, 0}, + { 1, 1, 2, 2, 0}, + { 0, 0, 3, 3, 0}, + { 0, 0, 3, 3, 0}, + { 0, 0, 0, 0, 0}}}; + + // Facet halving codes. 0: the facet is whole (or wholly blank), + // 1: blanked bottom-right, 2: top-right, 3: top-left, 4: bottom-left. + // Positive values mean that the diagonal is included, otherwise not. + + // Equatorial (diagonal), no facet halving. + const int FHALVE[][5][5] = {{{ 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0}}, + // North polar (X) facet halving. + {{ 0, 1, -4, 0, 0}, + {-3, 0, 0, 2, 0}, + { 4, 0, 0, -1, 0}, + { 0, -2, 3, 0, 0}, + { 0, 0, 0, 0, 0}}, + // South polar (X) facet halving. + {{ 0, 1, -4, 0, 0}, + {-3, 0, 0, 2, 0}, + { 4, 0, 0, -1, 0}, + { 0, -2, 3, 0, 0}, + { 0, 0, 0, 0, 0}}}; + + FitsHead* head = fits->head(); + FitsTableHDU* hdu = (FitsTableHDU*)(head->hdu()); + int rowlen = hdu->width(); + char* data = (char*)fits->data(); + + int nside = nside_; + int layout = layout_; + int nfacet = NFACET[layout]; + + pWidth_ = nfacet*nside; + pHeight_ = pWidth_; + + // create image space + size_t pSize = (size_t)pWidth_*pHeight_; + float* dest = new float[pSize]; + for (longlong ii=0; ii= 0) { + if (facet <= 3) { + facet += quad_; + if (facet > 3) facet -= 4; + } + else if (facet <= 7) { + facet += quad_; + if (facet > 7) facet -= 4; + } + else { + facet += quad_; + if (facet > 11) facet -= 4; + } + } + + // Write out the data + if (facet < 0) + ; + else { + switch (order_) { + case NESTED: + NESTidx(nside, facet, rotn, jj, healidx); + break; + case RING: + RINGidx(nside, facet, rotn, jj, healidx); + break; + } + + // Gather data into the output vector. + long* healp = healidx; + for (float* rowp = row; rowp < row+nside; rowp++) + *rowp = col_->value(data+*(healp++)*rowlen,0); + + // Apply blanking to halved facets. + if (halve) { + int i1; + int i2; + if (abs(halve) == 1) { + // Blank bottom-right. + i1 = jj; + i2 = nside; + if (halve > 0) + i1++; + } else if (abs(halve) == 2) { + // Blank top-right. + i1 = nside - jj; + i2 = nside; + if (halve < 0) + i1--; + } else if (abs(halve) == 3) { + // Blank top-left. + i1 = 0; + i2 = jj; + if (halve < 0) + i2++; + } else { + // Blank bottom-left. + i1 = 0; + i2 = nside - jj; + if (halve > 0) + i2--; + } + + for (float* rowp = row+i1; rowp < row+i2; rowp++) + *rowp = NAN; + } + + // Write out this facet's contribution to this row of the map. + memcpy(dest+fpixel-1, row, nside*sizeof(float)); + } + + fpixel += nelem; + } + } + } + + data_ = dest; + + dataSize_ = pSize; + dataSkip_ = 0; +} + +// (imap,jmap) are 0-relative pixel coordinates in the output map with origin +// at the bottom-left corner of the specified facet which is rotated by +// (45 + rotn * 90) degrees from its natural orientation; imap increases to +// the right and jmap upwards. + +void FitsHPX::NESTidx(int nside, int facet, int rotn, int jmap, long *healidx) +{ + // Nested index (0-relative) of the first pixel in this facet. + int hh = facet*nside*nside; + + int nside1 = nside - 1; + long* hp = healidx; + for (int imap = 0; imap < nside; imap++, hp++) { + // (ii,jj) are 0-relative pixel coordinates with origin in the southern + // corner of the facet; i increases to the north-east and j to the + // north-west. + int ii =0; + int jj =0; + if (rotn == 0) { + ii = nside1 - imap; + jj = jmap; + } + else if (rotn == 1) { + ii = nside1 - jmap; + jj = nside1 - imap; + } + else if (rotn == 2) { + ii = imap; + jj = nside1 - jmap; + } + else if (rotn == 3) { + ii = jmap; + jj = imap; + } + + *hp = 0; + int bit = 1; + while (ii || jj) { + if (ii & 1) *hp |= bit; + bit <<= 1; + if (jj & 1) *hp |= bit; + bit <<= 1; + ii >>= 1; + jj >>= 1; + } + + *hp += hh; + } +} + +// (imap,jmap) pixel coordinates are as described above for NESTidx(). This +// function computes the double-pixelisation index then converts it to the +// regular ring index. + +void FitsHPX::RINGidx(int nside, int facet, int rotn, int jmap, long *healidx) +{ + const int I0[] = { 1, 3, -3, -1, 0, 2, 4, -2, 1, 3, -3, -1}; + const int J0[] = { 1, 1, 1, 1, 0, 0, 0, 0, -1, -1, -1, -1}; + + int n2side = 2 * nside; + int n8side = 8 * nside; + + // Double-pixelisation index of the last pixel in the north polar cap. */ + int npole = (n2side - 1) * (n2side - 1) - 1; + + // Double-pixelisation pixel coordinates of the centre of the facet. */ + int i0 = nside * I0[facet]; + int j0 = nside * J0[facet]; + + int nside1 = nside - 1; + long* hp = healidx; + for (int imap = 0; imap < nside; imap++, hp++) { + // (ii,jj) are 0-relative, double-pixelisation pixel coordinates. The + // origin is at the intersection of the equator and prime meridian, + // i increases to the east (N.B.) and j to the north. + int ii =0; + int jj =0; + if (rotn == 0) { + ii = i0 + nside1 - (jmap + imap); + jj = j0 + jmap - imap; + } + else if (rotn == 1) { + ii = i0 + imap - jmap; + jj = j0 + nside1 - (imap + jmap); + } + else if (rotn == 2) { + ii = i0 + (imap + jmap) - nside1; + jj = j0 + imap - jmap; + } + else if (rotn == 3) { + ii = i0 + jmap - imap; + jj = j0 + jmap + imap - nside1; + } + + // Convert i for counting pixels + if (ii < 0) + ii += n8side; + ii++; + + if (jj > nside) { + // North polar regime. + if (jj == n2side) + *hp = 0; + else { + // Number of pixels in a polar facet with this value of jj. + int npj = 2 * (n2side - jj); + + // Index of the last pixel in the row above this. + *hp = (npj - 1) * (npj - 1) - 1; + + // Number of pixels in this row in the polar facets before this. + *hp += npj * (ii/n2side); + + // Pixel number in this polar facet. + *hp += ii%n2side - (jj - nside) - 1; + } + } + else if (jj >= -nside) { + // Equatorial regime. + *hp = npole + n8side * (nside - jj) + ii; + } + else { + // South polar regime. + *hp = 24 * nside * nside + 1; + + if (jj > -n2side) { + // Number of pixels in a polar facet with this value of jj. + int npj = 2 * (jj + n2side); + + // Total number of pixels in this row or below it. + *hp -= (npj + 1) * (npj + 1); + + // Number of pixels in this row in the polar facets before this. + *hp += npj * (ii/n2side); + + // Pixel number in this polar facet. + *hp += ii%n2side + (nside + jj) - 1; + } + } + + // Convert double-pixelisation index to regular. + *hp -= 1; + *hp /= 2; + } +} + +void FitsHPX::initHeader(FitsFile* fits) +{ + FitsHead* src = fits->head(); + + // create header + head_ = new FitsHead(pWidth_, pHeight_, 1, -32); + + // OBJECT + char* object = src->getString("OBJECT"); + if (object) { + head_->appendString("OBJECT", object, NULL); + delete [] object; + } + + // CRPIX1/2 + float crpix1; + switch (layout_) { + case EQUATOR: + crpix1 = (5 * nside_ + 1) / 2.; + break; + case NORTH: + case SOUTH: + crpix1 = (4 * nside_ + 1) / 2.; + break; + } + float crpix2 = crpix1; + head_->appendReal("CRPIX1", crpix1, 8, "Coordinate reference pixel"); + head_->appendReal("CRPIX2", crpix2, 8, "Coordinate reference pixel"); + + // PCx_y + float cos45 = sqrt(2.0) / 2.0; + if (layout_ == EQUATOR) { + head_->appendReal("PC1_1", cos45, 8, "Transformation matrix element"); + head_->appendReal("PC1_2", cos45, 8, "Transformation matrix element"); + head_->appendReal("PC2_1", -cos45, 8, "Transformation matrix element"); + head_->appendReal("PC2_2", cos45, 8, "Transformation matrix element"); + } + + // CDELT1/2 + float cdelt1 = -90.0 / nside_ / sqrt(2.); + float cdelt2 = -cdelt1; + head_->appendReal("CDELT1", cdelt1, 8, "[deg] Coordinate increment"); + head_->appendReal("CDELT2", cdelt2, 8, "[deg] Coordinate increment"); + + // CTYPE1/2 + const char* pcode; + switch (layout_) { + case EQUATOR: + pcode = "HPX"; + break; + case NORTH: + case SOUTH: + pcode = "XPH"; + break; + } + const char* ctype1; + const char* ctype2; + const char* descr1; + const char* descr2; + switch (coord_) { + case EQU: + ctype1 = "RA--"; + ctype2 = "DEC-"; + descr1 = "Right ascension"; + descr2 = "Declination"; + break; + case GAL: + ctype1 = "GLON"; + ctype2 = "GLAT"; + descr1 = "Galactic longitude"; + descr2 = "Galactic latitude"; + break; + case ECL: + ctype1 = "ELON"; + ctype2 = "ELAT"; + descr1 = "Ecliptic longitude"; + descr2 = "Ecliptic latitude"; + break; + case UNKNOWN: + ctype1 = "XLON"; + ctype2 = "XLAT"; + descr1 = "Longitude"; + descr2 = " Latitude"; + } + { + ostringstream cval; + cval << ctype1 << '-' << pcode << ends; + ostringstream comm; + comm << descr1 << " in an " << pcode << " projection" << ends; + head_->appendString("CTYPE1", cval.str().c_str(), comm.str().c_str()); + } + { + ostringstream cval; + cval << ctype2 << '-' << pcode << ends; + ostringstream comm; + comm << descr2 << " in an " << pcode << " projection" << ends; + head_->appendString("CTYPE2", cval.str().c_str(), comm.str().c_str()); + } + + // CRVAL1/CRVAL2 + float crval1 = 0. + 90.*quad_; + float crval2; + switch (layout_) { + case EQUATOR: + crval2 = 0.; + break; + case NORTH: + crval1 += 180.; + crval2 = 90.; + break; + case SOUTH: + crval1 += 180.; + crval2 = -90.; + break; + } + if (360. < crval1) + crval1 -= 360.; + + { + ostringstream comm; + comm << "[deg] " << descr1 << " at the reference point" << ends; + head_->appendReal("CRVAL1", crval1, 8, comm.str().c_str()); + } + { + ostringstream comm; + comm << "[deg] " << descr2 << " at the reference point" << ends; + head_->appendReal("CRVAL2", crval2, 8, comm.str().c_str()); + } + + // PV2_1/2 + switch (layout_) { + case EQUATOR: + head_->appendInteger("PV2_1", 4, "HPX H parameter (longitude)"); + head_->appendInteger("PV2_2", 3, "HPX K parameter (latitude)"); + break; + case NORTH: + case SOUTH: + head_->appendReal("LONPOLE", 180., 8, "[deg] Native longitude of the celestial pole"); + break; + } + + // we added cards + head_->updateHDU(); +} + +void FitsHPX::swap() +{ + if (!data_) + return; + + // we now need to byteswap back to native form + float* dest = (float*)data_; + for (int ii=0; iiisValid()) + return; + + // alloc memory + size_t size = (size_t)width*height; + data_ = new char[size]; + if (!data_) + return; + + dataSize_ = size; + dataSkip_ = 0; + + // clear memory + memset(data_, '\0', size); + + // made it this far, must be valid + valid_ = 1; +} + +FitsIIS::~FitsIIS() +{ + if (data_) + delete [] (char*)data_; +} + +void FitsIIS::erase() +{ + // clear memory + FitsImageHDU* hdu = (FitsImageHDU*)head_->hdu(); + memset(data_, '\0', hdu->realbytes()); +} + +char* FitsIIS::get(int xx, int yy, int dx, int dy) +{ + // fill-in in reverse order + int ll = dx*dy; + char* dest = new char[ll]; + int ww = head_->naxis(0); + int hh = head_->naxis(1); + + char* dptr = dest; + char* sptr = (char*)data_ + ((hh-1)-yy)*ww + xx; + while (ll) { + memcpy(dptr, sptr, ww); + sptr -= ww; + dptr += ww; + ll -= ww; + } + + return dest; +} + +void FitsIIS::set(const char* src, int xx, int yy, int dx, int dy) +{ + // fill-in in reverse order + int ll = dx*dy; + int ww = head_->naxis(0); + int hh = head_->naxis(1); + + char* sptr = (char*)src; + char* dptr = (char*)data_ + ((hh-1)-yy)*ww + xx; + while (ll) { + memcpy(dptr, sptr, ww); + sptr += ww; + dptr -= ww; + ll -= ww; + } +} + diff --git a/tksao/fitsy++/iis.h b/tksao/fitsy++/iis.h new file mode 100644 index 0000000..a82152d --- /dev/null +++ b/tksao/fitsy++/iis.h @@ -0,0 +1,20 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsiis_h__ +#define __fitsiis_h__ + +#include "file.h" + +class FitsIIS : public FitsFile { +public: + FitsIIS(int, int); + ~FitsIIS(); + + void erase(); + char* get(int xx, int yy, int dx, int dy); + void set(const char* src, int xx, int yy, int dx, int dy); +}; + +#endif diff --git a/tksao/fitsy++/lex.C b/tksao/fitsy++/lex.C new file mode 100644 index 0000000..ad898a4 --- /dev/null +++ b/tksao/fitsy++/lex.C @@ -0,0 +1,1959 @@ +#line 2 "fitsy++/lex.C" + +#line 4 "fitsy++/lex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer ffFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *ffalloc (yy_size_t ); +void *ffrealloc (void *,yy_size_t ); +void fffree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 45 +#define YY_END_OF_BUFFER 46 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[178] = + { 0, + 0, 0, 0, 0, 42, 42, 0, 0, 46, 1, + 3, 1, 1, 2, 4, 41, 40, 45, 41, 39, + 37, 37, 36, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 38, 42, 44, 44, 43, 1, 3, 1, 40, 36, + 37, 36, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 42, 43, 37, 37, 7, + 9, 37, 13, 14, 37, 37, 37, 37, 20, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + + 37, 37, 37, 5, 37, 37, 37, 37, 37, 15, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 27, + 28, 29, 37, 37, 37, 33, 34, 35, 6, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 25, 26, 30, 37, 37, 37, 11, 10, 12, 37, + 17, 37, 37, 21, 22, 24, 31, 37, 37, 37, + 37, 37, 37, 32, 37, 16, 37, 19, 37, 8, + 37, 37, 18, 37, 37, 23, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 5, 6, 7, 8, 1, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 1, 1, 1, + 1, 1, 1, 1, 10, 11, 12, 13, 14, 8, + 15, 16, 17, 8, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 8, 29, 30, 31, 32, + 33, 1, 34, 1, 8, 1, 35, 36, 37, 38, + + 39, 8, 40, 41, 42, 8, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 8, 54, 55, + 56, 57, 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, 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, + 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, 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, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[58] = + { 0, + 1, 2, 3, 1, 1, 1, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 2, 2, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4 + } ; + +static yyconst flex_int16_t yy_base[184] = + { 0, + 0, 3, 37, 0, 339, 336, 5, 6, 119, 0, + 14, 0, 15, 381, 381, 381, 18, 381, 108, 381, + 105, 0, 101, 70, 79, 75, 81, 87, 90, 87, + 92, 90, 78, 77, 89, 117, 86, 100, 102, 103, + 381, 0, 381, 26, 23, 0, 19, 22, 23, 22, + 0, 21, 130, 129, 99, 125, 127, 134, 121, 132, + 121, 122, 127, 131, 133, 146, 151, 141, 146, 137, + 140, 150, 168, 172, 175, 0, 20, 178, 185, 182, + 185, 175, 0, 173, 183, 184, 192, 194, 0, 183, + 179, 180, 181, 195, 198, 197, 190, 188, 189, 197, + + 215, 219, 222, 0, 213, 224, 224, 233, 231, 0, + 226, 240, 224, 240, 225, 235, 241, 240, 232, 0, + 0, 0, 242, 245, 239, 0, 0, 0, 0, 249, + 244, 234, 236, 241, 264, 267, 265, 267, 281, 283, + 0, 0, 0, 277, 269, 282, 0, 0, 0, 283, + 0, 276, 285, 0, 289, 0, 0, 283, 295, 294, + 290, 296, 288, 0, 290, 0, 302, 0, 300, 0, + 296, 299, 0, 308, 314, 0, 381, 360, 364, 368, + 372, 24, 376 + } ; + +static yyconst flex_int16_t yy_def[184] = + { 0, + 178, 178, 177, 3, 179, 179, 180, 180, 177, 181, + 177, 181, 181, 177, 177, 177, 177, 177, 177, 177, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 177, 183, 177, 177, 177, 181, 177, 181, 177, 177, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 183, 177, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 0, 177, 177, 177, + 177, 177, 177 + } ; + +static yyconst flex_int16_t yy_nxt[439] = + { 0, + 177, 11, 12, 13, 11, 12, 13, 18, 18, 44, + 44, 44, 44, 45, 45, 47, 47, 47, 48, 49, + 47, 49, 47, 47, 49, 48, 49, 51, 77, 52, + 50, 77, 14, 15, 77, 14, 15, 16, 17, 18, + 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 22, 22, 30, 31, 22, 32, 33, 22, + 34, 35, 36, 22, 37, 22, 38, 39, 40, 41, + 16, 24, 25, 26, 27, 28, 29, 22, 22, 30, + 31, 22, 32, 33, 22, 34, 35, 36, 22, 37, + 22, 38, 39, 40, 53, 54, 55, 56, 57, 60, + + 61, 62, 66, 64, 67, 68, 72, 58, 63, 52, + 59, 65, 73, 52, 74, 75, 50, 83, 177, 53, + 54, 55, 56, 57, 60, 61, 62, 66, 64, 67, + 68, 72, 58, 63, 69, 59, 65, 73, 70, 74, + 75, 78, 83, 80, 84, 85, 86, 71, 87, 81, + 88, 89, 90, 91, 79, 82, 92, 93, 94, 69, + 95, 96, 97, 70, 98, 99, 78, 100, 80, 84, + 85, 86, 71, 87, 81, 88, 89, 90, 91, 79, + 82, 92, 93, 94, 101, 95, 96, 97, 102, 98, + 99, 103, 100, 104, 105, 106, 107, 109, 110, 111, + + 112, 113, 108, 114, 115, 116, 117, 118, 119, 101, + 120, 121, 122, 102, 123, 124, 103, 125, 104, 105, + 106, 107, 109, 110, 111, 112, 113, 108, 114, 115, + 116, 117, 118, 119, 126, 120, 121, 122, 127, 123, + 124, 128, 125, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, 144, 126, + 145, 146, 147, 127, 148, 149, 128, 150, 129, 130, + 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, + 141, 142, 143, 144, 151, 145, 146, 147, 152, 148, + 149, 153, 150, 154, 155, 156, 157, 158, 159, 160, + + 161, 162, 163, 164, 165, 166, 167, 168, 169, 151, + 170, 171, 172, 152, 173, 174, 153, 175, 154, 155, + 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, + 166, 167, 168, 169, 176, 170, 171, 172, 18, 173, + 174, 18, 175, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 176, + 10, 10, 10, 10, 42, 42, 42, 42, 43, 43, + 43, 43, 46, 177, 46, 46, 76, 76, 177, 76, + 9, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177 + } ; + +static yyconst flex_int16_t yy_chk[439] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 8, 7, + 8, 7, 8, 7, 8, 11, 13, 11, 13, 17, + 47, 17, 47, 48, 49, 48, 49, 182, 77, 52, + 50, 45, 1, 1, 44, 2, 2, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 24, 25, 26, 27, 28, 29, + + 30, 31, 33, 32, 34, 35, 37, 28, 31, 23, + 28, 32, 38, 21, 39, 40, 19, 55, 9, 24, + 25, 26, 27, 28, 29, 30, 31, 33, 32, 34, + 35, 37, 28, 31, 36, 28, 32, 38, 36, 39, + 40, 53, 55, 54, 56, 57, 58, 36, 59, 54, + 60, 61, 62, 63, 53, 54, 64, 65, 66, 36, + 67, 68, 69, 36, 70, 71, 53, 72, 54, 56, + 57, 58, 36, 59, 54, 60, 61, 62, 63, 53, + 54, 64, 65, 66, 73, 67, 68, 69, 74, 70, + 71, 75, 72, 78, 79, 80, 81, 82, 84, 85, + + 86, 87, 81, 88, 90, 91, 92, 93, 94, 73, + 95, 96, 97, 74, 98, 99, 75, 100, 78, 79, + 80, 81, 82, 84, 85, 86, 87, 81, 88, 90, + 91, 92, 93, 94, 101, 95, 96, 97, 102, 98, + 99, 103, 100, 105, 106, 107, 108, 109, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 123, 124, 101, + 125, 130, 131, 102, 132, 133, 103, 134, 105, 106, + 107, 108, 109, 111, 112, 113, 114, 115, 116, 117, + 118, 119, 123, 124, 135, 125, 130, 131, 136, 132, + 133, 137, 134, 138, 139, 140, 144, 145, 146, 150, + + 152, 153, 155, 158, 159, 160, 161, 162, 163, 135, + 165, 167, 169, 136, 171, 172, 137, 174, 138, 139, + 140, 144, 145, 146, 150, 152, 153, 155, 158, 159, + 160, 161, 162, 163, 175, 165, 167, 169, 6, 171, + 172, 5, 174, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 175, + 178, 178, 178, 178, 179, 179, 179, 179, 180, 180, + 180, 180, 181, 0, 181, 181, 183, 183, 0, 183, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "fitsy++/lex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 11 "fitsy++/lex.L" + #include + #include + #include + + #include "util.h" + #include "parser.H" + + extern YYSTYPE* fflval; + extern ffFlexLexer* fflexx; + + extern char ff_filter[]; + #define RET(x) {strcat(ff_filter,yytext);return x;} + #define CLEARFILTER {ff_filter[0]='\0';} + + + +/* rules */ +#line 584 "fitsy++/lex.C" + +#define INITIAL 0 +#define EXT 1 +#define FILTER 2 +#define ARRAY 3 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 32 "fitsy++/lex.L" + + +#line 690 "fitsy++/lex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 178 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 177 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +#line 34 "fitsy++/lex.L" +{ // File + strcpy(fflval->str,yytext); + return STRING; + } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 39 "fitsy++/lex.L" +{ // first bracket + BEGIN EXT; + CLEARFILTER + return yytext[0]; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 45 "fitsy++/lex.L" +{ // White Spaces + } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 48 "fitsy++/lex.L" +{ // Else, return the char + return yytext[0]; + } + YY_BREAK + +case 5: +YY_RULE_SETUP +#line 54 "fitsy++/lex.L" +{RET(ARCH_)} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 55 "fitsy++/lex.L" +{RET(ARRAY_)} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 56 "fitsy++/lex.L" +{RET(BIG_)} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 57 "fitsy++/lex.L" +{RET(BIGENDIAN_)} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 58 "fitsy++/lex.L" +{RET(BIN_)} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 59 "fitsy++/lex.L" +{RET(BINKEY_)} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 60 "fitsy++/lex.L" +{RET(BINCOL_)} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 61 "fitsy++/lex.L" +{RET(BITPIX_)} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 62 "fitsy++/lex.L" +{RET(COL_)} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 63 "fitsy++/lex.L" +{RET(DIM_)} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 64 "fitsy++/lex.L" +{RET(DIMS_)} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 65 "fitsy++/lex.L" +{RET(ECLIPTIC_)} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 66 "fitsy++/lex.L" +{RET(ENDIAN_)} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 67 "fitsy++/lex.L" +{RET(EQUATORIAL_)} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 68 "fitsy++/lex.L" +{RET(GALACTIC_)} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 69 "fitsy++/lex.L" +{RET(KEY_)} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 70 "fitsy++/lex.L" +{RET(LAYOUT_)} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 71 "fitsy++/lex.L" +{RET(LITTLE_)} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 72 "fitsy++/lex.L" +{RET(LITTLEENDIAN_)} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 73 "fitsy++/lex.L" +{RET(NESTED_)} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 74 "fitsy++/lex.L" +{RET(NORTH_)} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 75 "fitsy++/lex.L" +{RET(ORDER_)} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 76 "fitsy++/lex.L" +{RET(QUAD_)} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 77 "fitsy++/lex.L" +{RET(RING_)} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 78 "fitsy++/lex.L" +{RET(SKIP_)} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 79 "fitsy++/lex.L" +{RET(SOUTH_)} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 80 "fitsy++/lex.L" +{RET(SYSTEM_)} + YY_BREAK +case 32: +YY_RULE_SETUP +#line 81 "fitsy++/lex.L" +{RET(UNKNOWN_)} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 82 "fitsy++/lex.L" +{RET(XDIM_)} + YY_BREAK +case 34: +YY_RULE_SETUP +#line 83 "fitsy++/lex.L" +{RET(YDIM_)} + YY_BREAK +case 35: +YY_RULE_SETUP +#line 84 "fitsy++/lex.L" +{RET(ZDIM_)} + YY_BREAK +case 36: +YY_RULE_SETUP +#line 86 "fitsy++/lex.L" +{ // Integer + fflval->integer = atoi(yytext); + RET(INT) + } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 91 "fitsy++/lex.L" +{ // Extn/Col Name + strcpy(fflval->str,yytext); + RET(STRING) + } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 96 "fitsy++/lex.L" +{ // bracket + CLEARFILTER + return yytext[0]; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 101 "fitsy++/lex.L" +{ // comma + CLEARFILTER + return yytext[0]; + } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 106 "fitsy++/lex.L" +{ // White Spaces + strcat(ff_filter,yytext); + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 110 "fitsy++/lex.L" +{ // Else, return the char + strcat(ff_filter,yytext); + return yytext[0]; + } + YY_BREAK + +case 42: +YY_RULE_SETUP +#line 117 "fitsy++/lex.L" +{ // rest of Filter + strcpy(fflval->str,yytext); + fflval->str[yyleng-1] = '\0'; // Remove the ']' + strcat(ff_filter,fflval->str); + return STRING; + } + YY_BREAK + +case 43: +YY_RULE_SETUP +#line 126 "fitsy++/lex.L" +{ // Integer + fflval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 131 "fitsy++/lex.L" +{ // Else, return the char + return yytext[0]; + } + YY_BREAK + +case 45: +YY_RULE_SETUP +#line 137 "fitsy++/lex.L" +ECHO; + YY_BREAK +#line 1036 "fitsy++/lex.C" +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXT): +case YY_STATE_EOF(FILTER): +case YY_STATE_EOF(ARRAY): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + fffree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + fffree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + ffrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ffrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 178 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 178 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 177); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) ffalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) ffalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + fffree((void *) b->yy_ch_buf ); + + fffree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)ffalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)ffrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) ffalloc(new_size ); + + else + (yy_start_stack) = (int *) ffrealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *ffalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *ffrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void fffree (void * ptr ) +{ + free( (char *) ptr ); /* see ffrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 137 "fitsy++/lex.L" + + + +void ffFilter(int doit) +{ + if (fflexx) + fflexx->begin(FILTER, doit); +} + +void ffArray(int doit) +{ + if (fflexx) + fflexx->begin(ARRAY, doit); +} + +void ffFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} + diff --git a/tksao/fitsy++/lex.L b/tksao/fitsy++/lex.L new file mode 100644 index 0000000..a25e7be --- /dev/null +++ b/tksao/fitsy++/lex.L @@ -0,0 +1,156 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + + #include "util.h" + #include "parser.H" + + extern YYSTYPE* fflval; + extern ffFlexLexer* fflexx; + + extern char ff_filter[]; + #define RET(x) {strcat(ff_filter,yytext);return x;} + #define CLEARFILTER {ff_filter[0]='\0';} +%} + +%x EXT +%x FILTER +%x ARRAY + +/* rules */ + +%% + +[^[\]\t]+ { // File + strcpy(fflval->str,yytext); + return STRING; + } + +\[ { // first bracket + BEGIN EXT; + CLEARFILTER + return yytext[0]; + } + +[ \t]+ { // White Spaces + } + +. { // Else, return the char + return yytext[0]; + } + +{ + +arch {RET(ARCH_)} +array {RET(ARRAY_)} +big {RET(BIG_)} +bigendian {RET(BIGENDIAN_)} +bin {RET(BIN_)} +binkey {RET(BINKEY_)} +bincol {RET(BINCOL_)} +bitpix {RET(BITPIX_)} +col {RET(COL_)} +dim {RET(DIM_)} +dims {RET(DIMS_)} +ecliptic {RET(ECLIPTIC_)} +endian {RET(ENDIAN_)} +equatorial {RET(EQUATORIAL_)} +galactic {RET(GALACTIC_)} +key {RET(KEY_)} +layout {RET(LAYOUT_)} +little {RET(LITTLE_)} +littleendian {RET(LITTLEENDIAN_)} +nested {RET(NESTED_)} +north {RET(NORTH_)} +order {RET(ORDER_)} +quad {RET(QUAD_)} +ring {RET(RING_)} +skip {RET(SKIP_)} +south {RET(SOUTH_)} +system {RET(SYSTEM_)} +unknown {RET(UNKNOWN_)} +xdim {RET(XDIM_)} +ydim {RET(YDIM_)} +zdim {RET(ZDIM_)} + +[-+]?[0-9]+ { // Integer + fflval->integer = atoi(yytext); + RET(INT) + } + +[0-9A-Za-z_.-]+ { // Extn/Col Name + strcpy(fflval->str,yytext); + RET(STRING) + } + +\[ { // bracket + CLEARFILTER + return yytext[0]; + } + +, { // comma + CLEARFILTER + return yytext[0]; + } + +[ \t]+ { // White Spaces + strcat(ff_filter,yytext); + } + +. { // Else, return the char + strcat(ff_filter,yytext); + return yytext[0]; + } + +} + +.* { // rest of Filter + strcpy(fflval->str,yytext); + fflval->str[yyleng-1] = '\0'; // Remove the ']' + strcat(ff_filter,fflval->str); + return STRING; + } + +{ + +[-+]?[0-9]+ { // Integer + fflval->integer = atoi(yytext); + return INT; + } + +. { // Else, return the char + return yytext[0]; + } + +} + +%% + +void ffFilter(int doit) +{ + if (fflexx) + fflexx->begin(FILTER, doit); +} + +void ffArray(int doit) +{ + if (fflexx) + fflexx->begin(ARRAY, doit); +} + +void ffFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} diff --git a/tksao/fitsy++/map.C b/tksao/fitsy++/map.C new file mode 100644 index 0000000..71593bf --- /dev/null +++ b/tksao/fitsy++/map.C @@ -0,0 +1,417 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "map.h" +#include "head.h" + +FitsMap::FitsMap() +{ + mapdata_ = NULL; + mapsize_ = 0; +} + +char* FitsMap::enddata() +{ + // return the address of the first data byte pass the end of data + return head_ ? (char*)data_+head_->databytes() : NULL; +} + +size_t FitsMap::endsize() +{ + // return the size - (header+data) + return head_ ? + (mapsize_ - (size_t)((char*)data_+head_->databytes()-mapdata_)) : 0; +} + +void FitsMap::found(char* here) +{ + data_ = here + head_->headbytes(); + + dataSize_ = mapsize_; + dataSkip_ = here - mapdata_ + head_->headbytes(); + + inherit_ = head_->inherit(); + valid_ = 1; +} + +void FitsMap::error() +{ + if (manageHead_ && head_) + delete head_; + head_ = NULL; + + if (managePrimary_ && primary_) + delete primary_; + primary_ = NULL; + + data_ = NULL; + + dataSize_ = 0; + dataSkip_ = 0; + + valid_ = 0; +} + +FitsFitsMap::FitsFitsMap(ScanMode mode) +{ + if (!valid_) + return; + + if (mode == EXACT || pExt_ || pIndex_>-1) + processExact(); + else + processRelax(); +} + +void FitsFitsMap::processExact() +{ + // find head and data for specified unit + char* here = mapdata_; + size_t size = mapsize_; + + // simple check for fits file + if (strncmp(mapdata_,"SIMPLE ",8) && strncmp(mapdata_,"XTENSION",8)) { + error(); + return; + } + + if (!(pExt_ || (pIndex_>0))) { + + // we are only looking for a primary image + head_ = new FitsHead(here, size, FitsHead::EXTERNAL); + if (head_->isValid()) { + found(here); + return; + } + } + else { + + // we are looking for an extension + // keep the primary header + primary_ = new FitsHead(here, size, FitsHead::EXTERNAL); + managePrimary_ = 1; + if (!primary_->isValid()) { + error(); + return; + } + here += primary_->headbytes() + primary_->databytes(); + size -= primary_->headbytes() + primary_->databytes(); + + if (pExt_) { + while (size > 0) { + head_ = new FitsHead(here, size, FitsHead::EXTERNAL); + if (!head_->isValid()) { + error(); + return; + } + ext_++; + + if (head_->extname()) { + char* a = toUpper(head_->extname()); + char* b = toUpper(pExt_); + if (!strncmp(a,b,strlen(b))) { + delete [] a; + delete [] b; + found(here); + return; + } + delete [] a; + delete [] b; + } + + here += head_->headbytes() + head_->databytes(); + size -= head_->headbytes() + head_->databytes(); + delete head_; + head_ = NULL; + } + } + else { + for (int i=1; i0; i++) { + head_ = new FitsHead(here, size, FitsHead::EXTERNAL); + if (!head_->isValid()) { + error(); + return; + } + ext_++; + + here += head_->headbytes() + head_->databytes(); + size -= head_->headbytes() + head_->databytes(); + delete head_; + head_ = NULL; + } + + head_ = new FitsHead(here, size, FitsHead::EXTERNAL); + if (head_->isValid()) { + ext_++; + found(here); + return; + } + } + } + + // Must have an error + error(); +} + +void FitsFitsMap::processRelax() +{ + char* here = mapdata_; + size_t size = mapsize_; + + // simple check for fits file + if (strncmp(mapdata_,"SIMPLE ",8) && strncmp(mapdata_,"XTENSION",8)) { + error(); + return; + } + + // check to see if there is an image in the primary + head_ = new FitsHead(here, size, FitsHead::EXTERNAL); + if (head_->isValid() && + head_->naxes() > 0 && + head_->naxis(0) > 0 && + head_->naxis(1) > 0) { + found(here); + return; + } + + // ok, no image, save primary and lets check extensions + here += head_->headbytes() + head_->databytes(); + size -= head_->headbytes() + head_->databytes(); + primary_ = head_; + managePrimary_ = 1; + head_ = NULL; + + while (size > 0) { + head_ = new FitsHead(here, size, FitsHead::EXTERNAL); + if (!head_->isValid()) { + error(); + return; + } + ext_++; + + // check for image + if (head_->isImage()) { + found(here); + return; + } + + // else, check for compressed image + if (head_->isBinTable() && head_->find("ZIMAGE")) { + found(here); + return; + } + + // else, check for bin table named STDEVT, EVENTS, RAYEVENT + if (head_->isBinTable() && head_->extname()) { + char* a = toUpper(head_->extname()); + if (!strncmp("STDEVT", a, 6) || + !strncmp("EVENTS", a, 6) || + !strncmp("RAYEVENT", a, 8)) { + delete [] a; + found(here); + return; + } + } + + // else, check for bin table with keyword PIXTYPE = 'HEALPIX ' + if (head_->isBinTable() && head_->find("PIXTYPE") && + (!strncmp(head_->getString("PIXTYPE"),"HEALPIX",4))) { + found(here); + return; + } + + // else, check for bin table with keyword NSIDE (also HEALPIX) + if (head_->isBinTable() && head_->find("NSIDE")) { + found(here); + return; + } + + here += head_->headbytes() + head_->databytes(); + size -= head_->headbytes() + head_->databytes(); + delete head_; + head_ = NULL; + } + + // did not find anything, bail out + error(); +} + +FitsFitsNextMap::FitsFitsNextMap(FitsFile* p) +{ + FitsMap* prev = (FitsMap*)p; + + primary_ = prev->primary(); + managePrimary_ = 0; + + head_ = prev->head(); + manageHead_ = 0; + + FitsImageHDU* hdu = (FitsImageHDU*)head_->hdu(); + data_ = (char*)prev->data() + hdu->imgbytes(); + dataSize_ = 0; + dataSkip_ = 0; + + ext_ = prev->ext(); + inherit_ = prev->inherit(); + byteswap_ = prev->byteswap(); + endian_ = prev->endian(); + valid_ = 1; + + pcoord_ = prev->pcoord(); + pxvalid_ = prev->pxvalid(); + pxmin_ = prev->pxmin(); + pxmax_ = prev->pxmax(); + pyvalid_ = prev->pyvalid(); + pymin_ = prev->pymin(); + pymax_ = prev->pymax(); + pzvalid_ = prev->pzvalid(); + pzmin_ = prev->pzmin(); + pzmax_ = prev->pzmax(); + pbvalid_ = prev->pbvalid(); + pblock_ = prev->pblock(); + + mapdata_ = prev->mapdata(); + mapsize_ = prev->mapsize(); + + return; +} + +FitsArrMap::FitsArrMap() +{ + if (!valid_) + return; + + // reset + valid_ = 0; + + // check to see if we have a nonzero width, height, and bitpix + if (!validParams()) + return; + + // check to see if dimensions equal mapped space + if (((size_t)pWidth_*pHeight_*pDepth_*abs(pBitpix_)/8)+pSkip_ > mapsize_) + return; + + // skip to start of data + data_ = mapdata_ + pSkip_; + + dataSize_ = mapsize_; + dataSkip_ = pSkip_; + + // new header + head_ = new FitsHead(pWidth_, pHeight_, pDepth_, pBitpix_); + if (!head_->isValid()) + return; + + // do we byteswap? + setByteSwap(); + + // made it this far, must be valid + valid_ = 1; +} + +FitsNRRDMap::FitsNRRDMap() +{ + if (!valid_) + return; + + // reset + valid_ = 0; + + // header + { + char buf[1024]; + char* dptr = buf; + char* sptr = mapdata_; + int cnt =0; + do { + *dptr++ = *sptr++; + if (cnt>0 && (*sptr == '\n' && *(sptr-1) == '\n')) { + pSkip_ = cnt+2; + break; + } + cnt++; + } while (cnt<1024); + *dptr = '\0'; + + string x(buf); + istringstream str(x); + parseNRRD(str); + if (!valid_) + return; + + // reset + valid_ =0; + } + + // check to see if we have a nonzero width, height, and bitpix + if (!validParams()) + return; + + // skip to start of data + data_ = mapdata_ + pSkip_; + + dataSize_ = mapsize_; + dataSkip_ = pSkip_; + + // new header + head_ = new FitsHead(pWidth_, pHeight_, pDepth_, pBitpix_); + if (!head_->isValid()) + return; + + // do we byteswap? + setByteSwap(); + + // so far, so good + valid_ = 1; +} + +FitsMosaicMap::FitsMosaicMap() +{ + if (!valid_) + return; + + char* here = mapdata_; + size_t size = mapsize_; + + // keep the primary header + primary_ = new FitsHead(here, size, FitsHead::EXTERNAL); + managePrimary_ = 1; + if (!primary_->isValid()) { + error(); + return; + } + + here += primary_->headbytes() + primary_->databytes(); + size -= primary_->headbytes() + primary_->databytes(); + + // first extension + head_ = new FitsHead(here, size, FitsHead::EXTERNAL); + if (!head_->isValid()) { + error(); + return; + } + ext_++; + found(here); +} + +FitsMosaicNextMap::FitsMosaicNextMap(FitsFile* p) +{ + FitsMap* prev = (FitsMap*)p; + + primary_ = prev->primary(); + managePrimary_ = 0; + ext_ = prev->ext(); + + mapdata_ = prev->enddata(); + mapsize_ = prev->endsize(); + + head_ = new FitsHead(mapdata_, mapsize_, FitsHead::EXTERNAL); + if (!head_->isValid()) { + error(); + return; + } + ext_++; + found(mapdata_); +} diff --git a/tksao/fitsy++/map.h b/tksao/fitsy++/map.h new file mode 100644 index 0000000..94cec81 --- /dev/null +++ b/tksao/fitsy++/map.h @@ -0,0 +1,69 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsmap_h__ +#define __fitsmap_h__ + +#include "file.h" + +class FitsMap : public FitsFile { +protected: + char* mapdata_; + size_t mapsize_; + +public: + FitsMap(); + virtual ~FitsMap() {} + + char* mapdata() {return mapdata_;} + size_t mapsize() {return mapsize_;} + void found(char*); + void error(); + char* enddata(); + size_t endsize(); +}; + +class FitsFitsMap : public virtual FitsMap { +protected: + void processExact(); + void processRelax(); + +public: + FitsFitsMap(ScanMode); +}; + +class FitsFitsNextMap : public FitsMap { +public: + FitsFitsNextMap(FitsFile* prev); +}; + +class FitsArrMap : public virtual FitsMap { +public: + FitsArrMap(); +}; + +class FitsNRRDMap : public virtual FitsMap { +public: + FitsNRRDMap(); +}; + +class FitsMosaicMap : public virtual FitsMap { +public: + FitsMosaicMap(); +}; + +class FitsMosaicNextMap : public FitsMap { +public: + FitsMosaicNextMap(FitsFile* prev); +}; + +#endif + + + + + + + + diff --git a/tksao/fitsy++/mapincr.C b/tksao/fitsy++/mapincr.C new file mode 100644 index 0000000..4ca1af7 --- /dev/null +++ b/tksao/fitsy++/mapincr.C @@ -0,0 +1,599 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "mapincr.h" + +#ifndef __WIN32 + +#include +#include +#include +#include +#include +#include + +#include "head.h" + +//#define PAGELIMIT 1073741824 +#define PAGELIMIT 536870912 + +FitsMapIncr::FitsMapIncr() +{ + mapdata_ = NULL; + mapsize_ = 0; + page_ = 0; + + filesize_ = 0; + seek_ = 0; + + dseek_ = 0; + nseek_ = 0; +} + +FitsMapIncr::~FitsMapIncr() +{ + if (mapdata_>0) + munmap((caddr_t)mapdata_, mapsize_); +} + +FitsHead* FitsMapIncr::headRead() +{ + // NOTE: the hdu cleans up after the hdu, + // here we only clean up after the data segment + + // mmap will return valid if seek_ is at end of file, so check first + if (filesize_-seek_<=0) + return NULL; + + // read first BLOCK + // seek_ needs to be an increment of getpagesize + int pagesize = getpagesize(); + off_t mmseek = (seek_/pagesize)*pagesize; + size_t offset = seek_ - mmseek; + + int fd = open(pName_, O_RDONLY); + size_t mmsize = offset+FTY_BLOCK; + char* mmdata = (char*)mmap(NULL, mmsize, PROT_READ, MAP_SHARED, fd, mmseek); + close(fd); + + // are we valid? + if ((long)mmdata == -1) + return NULL; + + // simple test + if (strncmp(mmdata+offset,"SIMPLE ",8) && + strncmp(mmdata+offset,"XTENSION",8)) { + munmap((caddr_t)mmdata, mmsize); + return NULL; + } + + // can we find 'END'? + while (mmsize-offset-FTY_BLOCK < filesize_-seek_) { + if (findEnd(mmdata+mmsize-FTY_BLOCK)) + break; + + // add another BLOCK + munmap((caddr_t)mmdata, mmsize); + fd = open(pName_, O_RDONLY); + mmdata = (char*)mmap(NULL, mmsize+FTY_BLOCK, PROT_READ, MAP_SHARED, + fd, mmseek); + close(fd); + + // are we valid? + if ((long)mmdata == -1) + return NULL; + + mmsize += FTY_BLOCK; + } + + // do we have a header? + FitsHead* hd = new FitsHead(mmdata+offset, mmsize-offset, + mmdata, mmsize, FitsHead::MMAP); + if (!hd || !hd->isValid()) { + delete hd; + return NULL; + } + + seek_ += mmsize-offset; + + // success! + return hd; +} + +void FitsMapIncr::dataSkip(size_t bytes) +{ + seek_ += bytes; +} + +void FitsMapIncr::dataSkipBlock(size_t blk) +{ + seek_ += blk*FTY_BLOCK; +} + +void FitsMapIncr::found() +{ + // at this point we mmap the data segment + + // must find a page boundary + int pagesize = getpagesize(); + off_t mmseek = (seek_/pagesize)*pagesize; + size_t offset = seek_ - mmseek; + + int fd = open(pName_, O_RDONLY); + + // determine internal page mode + if (!head_->isTable() || !head_->isAsciiTable() || head_->isHeap()) { + // no internal paging + mapsize_ = head_->databytes()+offset; + page_ = 0; + } + else { + // if mapsize_ will exceed our inernal page limit, turn on internal paging + if (head_->databytes()+offset > PAGELIMIT) { + mapsize_ = PAGELIMIT; + page_ = 1; + + dseek_ = seek_; + nseek_ = seek_-offset; + } + else { + // small enough, no internal paging + mapsize_ = head_->databytes()+offset; + page_ = 0; + } + } + mapdata_ = (char*)mmap(NULL, mapsize_, PROT_READ, MAP_SHARED, fd, mmseek); + close(fd); + + // are we valid? (we'd better be!) + if ((long)mapdata_ == -1) { + mapsize_ = 0; + mapdata_ = NULL; + error(); + return; + } + + // seek to next hdu, even if we are internal paging + seek_ += head_->databytes(); + // data starts after any page boundary + data_ = mapdata_+offset; + + dataSize_ = mapsize_; + dataSkip_ = 0; + + inherit_ = head_->inherit(); + valid_ = 1; +} + +char* FitsMapIncr::page(char* ptr, size_t row) +{ + if (!page_) + // no paging, just return + return ptr; + else { + // be sure that at least 'row' bytes are still available + if (ptr <= mapdata_+mapsize_-row) + // no problem yet + return ptr; + else { + // how far did we get + nseek_ += ptr-mapdata_; + // unmap the old segment + munmap((caddr_t)mapdata_, mapsize_); + + // next mmap segment + int pagesize = getpagesize(); + off_t mmseek = (nseek_/pagesize)*pagesize; + size_t offset = nseek_ - mmseek; + + int fd = open(pName_, O_RDONLY); + + // calc next internal page size + if (head_->databytes()+offset-(nseek_-dseek_) > PAGELIMIT) + mapsize_ = PAGELIMIT; + else + mapsize_ = head_->databytes()+offset-(nseek_-dseek_); + + mapdata_ =(char*)mmap(NULL, mapsize_, PROT_READ, MAP_SHARED, fd, mmseek); + close(fd); + + // are we valid? (we'd better be!) + if ((long)mapdata_ == -1) { + //*** what to do here? + internalError("Fitsy++ mapincr page() error"); + mapsize_ = 0; + mapdata_ = NULL; + } + + nseek_ -= offset; + return mapdata_+offset; + } + } +} + +void FitsMapIncr::resetpage() +{ + if (page_) { + // ok, get a new page + munmap((caddr_t)mapdata_, mapsize_); + + // remap original page + int pagesize = getpagesize(); + off_t mmseek = (dseek_/pagesize)*pagesize; + size_t offset = dseek_ - mmseek; + + int fd = open(pName_, O_RDONLY); + + if (head_->databytes()+offset > PAGELIMIT) + mapsize_ = PAGELIMIT; + else + mapsize_ = head_->databytes()+offset; + + mapdata_ =(char*)mmap(NULL, mapsize_, PROT_READ, MAP_SHARED, fd, mmseek); + close(fd); + + // are we valid? (we'd better be!) + if ((long)mapdata_ == -1) { + //*** what to do here? + internalError("Fitsy++ mapincr resetpage() error"); + mapsize_ = 0; + mapdata_ = NULL; + } + + // reset, we may have moved in memory + // found the data, save it + nseek_ = dseek_-offset; + data_ = mapdata_+offset; + + dataSize_ = mapsize_; + dataSkip_ = offset; + } +} + +void FitsMapIncr::error() +{ + if (manageHead_ && head_) + delete head_; + head_ = NULL; + + if (managePrimary_ && primary_) + delete primary_; + primary_ = NULL; + + data_ = NULL; + + dataSize_ = 0; + dataSkip_ = 0; + + valid_ = 0; +} + +FitsFitsMapIncr::FitsFitsMapIncr(ScanMode mode) +{ + if (!valid_) + return; + + if (mode == EXACT || pExt_ || pIndex_>-1) + processExact(); + else + processRelax(); +} + +void FitsFitsMapIncr::processExact() +{ + // simple check for fits file + if (!(pExt_ || (pIndex_>0))) { + + // we are only looking for a primary image + head_ = headRead(); + if (head_ && head_->isValid()) { + found(); + return; + } + } + else { + + // we are looking for an extension + // keep the primary header + primary_ = headRead(); + managePrimary_ = 1; + if (!(primary_ && primary_->isValid())) { + error(); + return; + } + dataSkipBlock(primary_->datablocks()); + + if (pExt_) { + while (seek_ < filesize_) { + head_ = headRead(); + if (!(head_ && head_->isValid())) { + error(); + return; + } + ext_++; + + if (head_->extname()) { + char* a = toUpper(head_->extname()); + char* b = toUpper(pExt_); + if (!strncmp(a,b,strlen(b))) { + delete [] a; + delete [] b; + found(); + return; + } + delete [] a; + delete [] b; + } + dataSkipBlock(head_->datablocks()); + delete head_; + head_ = NULL; + } + } + else { + for (int i=1; iisValid())) { + error(); + return; + } + ext_++; + + dataSkipBlock(head_->datablocks()); + delete head_; + head_ = NULL; + } + + head_ = headRead(); + if (head_ && head_->isValid()) { + ext_++; + found(); + return; + } + } + } + + // Must have an error + error(); +} + +void FitsFitsMapIncr::processRelax() +{ + // check to see if there is an image in the primary + head_ = headRead(); + if (!(head_ && head_->isValid())) { + error(); + return; + } + + if (head_ && + head_->isValid() && + head_->naxes() > 0 && + head_->naxis(0) > 0 && + head_->naxis(1) > 0) { + found(); + return; + } + + // ok, no image, save primary and lets check extensions + primary_ = head_; + managePrimary_ = 1; + dataSkipBlock(head_->datablocks()); + head_ = NULL; + + while (seek_ < filesize_) { + head_ = headRead(); + if (!(head_ && head_->isValid())) { + error(); + return; + } + ext_++; + + // check for image + if (head_->isImage()) { + found(); + return; + } + + // else, check for compressed image + if (head_->isBinTable() && head_->find("ZIMAGE")) { + found(); + return; + } + + // else, check for bin table named STDEVT, EVENTS, RAYEVENT + if (head_->isBinTable() && head_->extname()) { + char* a = toUpper(head_->extname()); + if (!strncmp("STDEVT", a, 6) || + !strncmp("EVENTS", a, 6) || + !strncmp("RAYEVENT", a, 8)) { + delete [] a; + found(); + return; + } + else + delete [] a; + } + + // else, check for bin table with keyword PIXTYPE = 'HEALPIX ' + if (head_->isBinTable() && head_->find("PIXTYPE") && + (!strncmp(head_->getString("PIXTYPE"),"HEALPIX",4))) { + found(); + return; + } + + // else, check for bin table with keyword NSIDE (also HEALPIX) + if (head_->isBinTable() && head_->find("NSIDE")) { + found(); + return; + } + + dataSkipBlock(head_->datablocks()); + delete head_; + head_ = NULL; + } + + // did not find anything, bail out + error(); +} + +FitsFitsNextMapIncr::FitsFitsNextMapIncr(FitsFile* p) +{ + FitsMapIncr* prev = (FitsMapIncr*)p; + + primary_ = prev->primary(); + managePrimary_ = 0; + + head_ = prev->head(); + manageHead_ = 0; + + FitsImageHDU* hdu = (FitsImageHDU*)head_->hdu(); + data_ = (char*)prev->data() + hdu->imgbytes(); + dataSize_ = 0; + dataSkip_ = 0; + + ext_ = prev->ext(); + inherit_ = prev->inherit(); + byteswap_ = prev->byteswap(); + endian_ = prev->endian(); + valid_ = 1; + + pcoord_ = prev->pcoord(); + pxvalid_ = prev->pxvalid(); + pxmin_ = prev->pxmin(); + pxmax_ = prev->pxmax(); + pyvalid_ = prev->pyvalid(); + pymin_ = prev->pymin(); + pymax_ = prev->pymax(); + pzvalid_ = prev->pzvalid(); + pzmin_ = prev->pzmin(); + pzmax_ = prev->pzmax(); + pbvalid_ = prev->pbvalid(); + pblock_ = prev->pblock(); + + filesize_ = prev->filesize(); + seek_ = prev->seek(); + + return; +} + +FitsArrMapIncr::FitsArrMapIncr() +{ + if (!valid_) + return; + + // reset + valid_ = 0; + + // check to see if we have a nonzero width, height, and bitpix + if (!validParams()) + return; + + // check to see if dimensions equal mapped space + size_t mmsize = ((size_t)pWidth_*pHeight_*pDepth_*abs(pBitpix_)/8) + pSkip_; + + if (mmsize > filesize_) + return; + + // skip to start of data + int fd = open(pName_, O_RDONLY); + char* mmdata = (char*)mmap(NULL, mmsize, PROT_READ, MAP_SHARED, fd, 0); + close(fd); + + // are we valid? + if ((long)mmdata == -1) + return; + + // new header + head_ = new FitsHead(pWidth_, pHeight_, pDepth_, pBitpix_, + mmdata, mmsize, FitsHead::ALLOC); + if (!head_->isValid()) + return; + + seek_ = mmsize; + data_ = mmdata + pSkip_; + + dataSize_ = mapsize_; + dataSkip_ = pSkip_; + + // do we byteswap? + setByteSwap(); + + // made it this far, must be valid + valid_ = 1; +} + +FitsMosaicMapIncr::FitsMosaicMapIncr() +{ + if (!valid_) + return; + + // keep the primary header + primary_ = headRead(); + managePrimary_ = 1; + if (!(primary_ && primary_->isValid())) { + error(); + return; + } + dataSkipBlock(primary_->datablocks()); + + // first extension + head_ = headRead(); + if (!(head_ && head_->isValid())) { + error(); + return; + } + ext_++; + found(); +} + +FitsMosaicNextMapIncr::FitsMosaicNextMapIncr(FitsFile* p) +{ + FitsMapIncr* prev = (FitsMapIncr*)p; + + pName_ = dupstr(prev->pName()); + filesize_ = prev->filesize(); + seek_ = prev->seek(); + + primary_ = prev->primary(); + managePrimary_ = 0; + ext_ = prev->ext(); + + head_ = headRead(); + if (!(head_ && head_->isValid())) { + error(); + return; + } + ext_++; + found(); +} + +#else + +FitsMapIncr::FitsMapIncr() +{ + mapdata_ = NULL; + mapsize_ = 0; +} + +FitsMapIncr::~FitsMapIncr() {} + +FitsHead* FitsMapIncr::headRead() {} +void FitsMapIncr::dataSkip(size_t bytes) {} +void FitsMapIncr::dataSkipBlock(size_t blk) {} +void FitsMapIncr::found() {} +char* FitsMapIncr::page(char* ptr, size_t row) +{ + return NULL; +} +void FitsMapIncr::resetpage() {} +void FitsMapIncr::error() {} +FitsFitsMapIncr::FitsFitsMapIncr(ScanMode mode) {} +void FitsFitsMapIncr::processExact() {} +void FitsFitsMapIncr::processRelax() {} + +FitsFitsNextMapIncr::FitsFitsNextMapIncr(FitsFile* p) {} +FitsArrMapIncr::FitsArrMapIncr() {} +FitsMosaicMapIncr::FitsMosaicMapIncr() {} +FitsMosaicNextMapIncr::FitsMosaicNextMapIncr(FitsFile* p) {} +#endif diff --git a/tksao/fitsy++/mapincr.h b/tksao/fitsy++/mapincr.h new file mode 100644 index 0000000..60eec22 --- /dev/null +++ b/tksao/fitsy++/mapincr.h @@ -0,0 +1,67 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsmapincr_h__ +#define __fitsmapincr_h__ + +#include "file.h" + +class FitsMapIncr : public FitsFile { +protected: + char* mapdata_; // mmap segment ptr + size_t mapsize_; // mmap segment size + int page_; // flag to indicate paging mode + + size_t filesize_; // size of the total segment + size_t seek_; // offset into segment + size_t dseek_; // offset to data segment + size_t nseek_; // offset into next page data segment + + FitsHead* headRead(); + void dataSkip(size_t); + void dataSkipBlock(size_t); + void found(); + void error(); + +public: + FitsMapIncr(); + virtual ~FitsMapIncr(); + + char* page(char*, size_t); + void resetpage(); + size_t filesize() {return filesize_;} + size_t seek() {return seek_;} +}; + +class FitsFitsMapIncr : public virtual FitsMapIncr { +protected: + void processExact(); + void processRelax(); + +public: + FitsFitsMapIncr(ScanMode); +}; + +class FitsFitsNextMapIncr : public FitsMapIncr { +public: + FitsFitsNextMapIncr(FitsFile* prev); +}; + +class FitsArrMapIncr : public virtual FitsMapIncr { +public: + FitsArrMapIncr(); +}; + +class FitsMosaicMapIncr : public virtual FitsMapIncr { +public: + FitsMosaicMapIncr(); +}; + +class FitsMosaicNextMapIncr : public FitsMapIncr { +public: + FitsMosaicNextMapIncr(FitsFile* prev); +}; + +#endif + diff --git a/tksao/fitsy++/mmap.C b/tksao/fitsy++/mmap.C new file mode 100644 index 0000000..5e8230b --- /dev/null +++ b/tksao/fitsy++/mmap.C @@ -0,0 +1,68 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "mmap.h" + +#ifndef __WIN32 +#include + +#include +#include +#include +#include + +FitsMMap::FitsMMap(const char* fn) +{ + // parse the fn and options + parse(fn); + if (!valid_) + return; + + // reset + valid_ = 0; + + if (!pName_) + return; + + // Map the file. + int file = open(pName_, O_RDONLY); + if (file == -1) + return; + + struct stat info; + if (fstat(file, &info) < 0) + return; + + // check to see if we have something, we may have a small array + if (info.st_size <= 0) + return; + + // map it + mapsize_ = info.st_size; + mapdata_ = (char*)mmap(NULL, mapsize_, PROT_READ, MAP_SHARED, file, 0); + + // close the file + close(file); + + // are we valid? + if ((long)mapdata_ == -1) + return; + + // so far, so good + valid_ = 1; +} + +FitsMMap::~FitsMMap() +{ + if (mapdata_>0) + munmap((caddr_t)mapdata_, mapsize_); +} + +#else + +FitsMMap::FitsMMap(const char* fn) {} +FitsMMap::~FitsMMap() {} + +#endif + diff --git a/tksao/fitsy++/mmap.h b/tksao/fitsy++/mmap.h new file mode 100644 index 0000000..fe76d47 --- /dev/null +++ b/tksao/fitsy++/mmap.h @@ -0,0 +1,47 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsmmap_h__ +#define __fitsmmap_h__ + +#include "map.h" + +class FitsMMap : public virtual FitsMap { +public: + FitsMMap(const char*); + virtual ~FitsMMap(); +}; + +class FitsFitsMMap : public FitsMMap, public FitsFitsMap { +public: + FitsFitsMMap(const char* fn, ScanMode mode) + : FitsMMap(fn), FitsFitsMap(mode) {} +}; + +class FitsFitsNextMMap : public FitsFitsNextMap { +public: + FitsFitsNextMMap(FitsFile* prev) : FitsFitsNextMap(prev) {} +}; + +class FitsArrMMap : public FitsMMap, public FitsArrMap { +public: + FitsArrMMap(const char* fn) : FitsMMap(fn), FitsArrMap() {} +}; + +class FitsNRRDMMap : public FitsMMap, public FitsNRRDMap { +public: + FitsNRRDMMap(const char* fn) : FitsMMap(fn), FitsNRRDMap() {} +}; + +class FitsMosaicMMap : public FitsMMap, public FitsMosaicMap { +public: + FitsMosaicMMap(const char* fn) : FitsMMap(fn), FitsMosaicMap() {} +}; + +class FitsMosaicNextMMap : public FitsMosaicNextMap { +public: + FitsMosaicNextMMap(FitsFile* prev) : FitsMosaicNextMap(prev) {} +}; + +#endif diff --git a/tksao/fitsy++/mmapincr.C b/tksao/fitsy++/mmapincr.C new file mode 100644 index 0000000..4b0d0df --- /dev/null +++ b/tksao/fitsy++/mmapincr.C @@ -0,0 +1,53 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "mmapincr.h" + +#ifndef __WIN32 + +#include +#include +#include +#include +#include + +FitsMMapIncr::FitsMMapIncr(const char* fn) +{ + // parse the fn and options + parse(fn); + if (!valid_) + return; + + // reset + valid_ =0; + + if (!pName_) + return; + + // Map the file. + int fd = open(pName_, O_RDONLY); + if (fd == -1) + return; + + struct stat info; + if (fstat(fd, &info) < 0) + return; + + close(fd); + + // check to see if we have something, we may have a small array + if (info.st_size <= 0) + return; + + filesize_ = info.st_size; + + // so far, so good + valid_ = 1; +} + +#else + +FitsMMapIncr::FitsMMapIncr(const char* fn) {} + +#endif diff --git a/tksao/fitsy++/mmapincr.h b/tksao/fitsy++/mmapincr.h new file mode 100644 index 0000000..3307093 --- /dev/null +++ b/tksao/fitsy++/mmapincr.h @@ -0,0 +1,41 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsmmapincr_h__ +#define __fitsmmapincr_h__ + +#include "mapincr.h" + +class FitsMMapIncr : public virtual FitsMapIncr { +public: + FitsMMapIncr(const char*); +}; + +class FitsFitsMMapIncr : public FitsMMapIncr, public FitsFitsMapIncr { +public: + FitsFitsMMapIncr(const char* fn, ScanMode mode) + : FitsMMapIncr(fn), FitsFitsMapIncr(mode) {} +}; + +class FitsFitsNextMMapIncr : public FitsFitsNextMapIncr { +public: + FitsFitsNextMMapIncr(FitsFile* prev) : FitsFitsNextMapIncr(prev) {} +}; + +class FitsArrMMapIncr : public FitsMMapIncr, public FitsArrMapIncr { +public: + FitsArrMMapIncr(const char* fn) : FitsMMapIncr(fn), FitsArrMapIncr() {} +}; + +class FitsMosaicMMapIncr : public FitsMMapIncr, public FitsMosaicMapIncr { +public: + FitsMosaicMMapIncr(const char* fn) : FitsMMapIncr(fn), FitsMosaicMapIncr() {} +}; + +class FitsMosaicNextMMapIncr : public FitsMosaicNextMapIncr { +public: + FitsMosaicNextMMapIncr(FitsFile* prev) : FitsMosaicNextMapIncr(prev) {} +}; + +#endif diff --git a/tksao/fitsy++/nrrd.C b/tksao/fitsy++/nrrd.C new file mode 100644 index 0000000..0981c72 --- /dev/null +++ b/tksao/fitsy++/nrrd.C @@ -0,0 +1,80 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "nrrd.h" +#include "head.h" + +FitsNRRD::FitsNRRD(FitsFile* fits) +{ + byteswap_ = fits->byteswap(); + endian_ = fits->endian(); + + pBitpix_ = fits->pBitpix(); + pWidth_ = fits->pWidth(); + pHeight_ = fits->pHeight(); + pDepth_ = fits->pDepth(); + + size_ = (size_t)pWidth_*pHeight_*pDepth_; +} + +FitsNRRD::~FitsNRRD() +{ + if (data_) + delete [] (char*)data_; +} + +int FitsNRRD::initHeader(FitsFile* fits) +{ + // simple check + if (!pWidth_ || !pHeight_ || !pBitpix_) + return 0; + + // create header + head_ = new FitsHead(pWidth_, pHeight_, pDepth_, pBitpix_); + if (!head_->isValid()) + return 0; + + // other + primary_ = fits->primary(); + managePrimary_ = 0; + + inherit_ = head_->inherit(); + + return 1; +} + +template FitsNRRDm::FitsNRRDm(FitsFile* fits) + : FitsNRRD(fits) +{ +} + +template void FitsNRRDm::uncompress(FitsFile* fits) +{ + if (!initHeader(fits)) + return; + + T* dest = new T[size_]; + if (!dest) { + internalError("Fitsy++ nrrd unable to allocate memory"); + return; + } + memset(dest, 0, size_*sizeof(T)); + compressed(dest, (char*)fits->data(), fits->dataSize()-fits->dataSkip()); + + data_ = dest; + + dataSize_ = size_; + dataSkip_ = 0; + + // all done + valid_ = 1; +} + +template class FitsNRRDm; +template class FitsNRRDm; +template class FitsNRRDm; +template class FitsNRRDm; +template class FitsNRRDm; +template class FitsNRRDm; +template class FitsNRRDm; diff --git a/tksao/fitsy++/nrrd.h b/tksao/fitsy++/nrrd.h new file mode 100644 index 0000000..138aea3 --- /dev/null +++ b/tksao/fitsy++/nrrd.h @@ -0,0 +1,36 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsnrrd_h__ +#define __fitsnrrd_h__ + +#include "file.h" + +class FitsNRRD : public FitsFile { + protected: + size_t size_; + + protected: + int initHeader(FitsFile*); + + public: + FitsNRRD(FitsFile*); + virtual ~FitsNRRD(); +}; + +template +class FitsNRRDm : public FitsNRRD { + private: + void swapBytes(FitsFile::ArchType); + + protected: + void uncompress(FitsFile* fits); + virtual int compressed(T*, char*, size_t) =0; + + public: + FitsNRRDm(FitsFile*); +}; + +#endif + diff --git a/tksao/fitsy++/nrrdgzip.C b/tksao/fitsy++/nrrdgzip.C new file mode 100644 index 0000000..0af4b7d --- /dev/null +++ b/tksao/fitsy++/nrrdgzip.C @@ -0,0 +1,84 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include +using namespace std; + +#include "nrrdgzip.h" +#include "zlib.h" +#include "util.h" + +template FitsNRRDGzipm::FitsNRRDGzipm(FitsFile* fits) + : FitsNRRDm(fits) +{ + FitsNRRDm::uncompress(fits); +} + +template int FitsNRRDGzipm::compressed(T* dest, char* src, + size_t sz) + +{ + z_stream zstrm; + zstrm.zalloc = NULL; + zstrm.zfree = NULL; + zstrm.opaque = NULL; + zstrm.avail_in = sz; + zstrm.next_in = (Bytef*)src; + zstrm.avail_out = this->size_*sizeof(T); + zstrm.next_out = (Bytef*)dest; + + // look for both zlib and gzip headers + if (inflateInit2(&zstrm, MAX_WBITS+32) != Z_OK) { + internalError("Fitsy++ gzip inflateInit error"); + return 0; + } + + if (DebugCompress) + cerr << " inflate START: avail_in " << zstrm.avail_in + << " avail_out " << zstrm.avail_out + << " total_in " << zstrm.total_in + << " total_out " << zstrm.total_out << endl; + + int result = ::inflate(&zstrm, Z_FINISH); + + switch (result) { + case Z_OK: + if (DebugCompress) + cerr << " inflate OK: avail_in " << zstrm.avail_in + << " avail_out " << zstrm.avail_out + << " total_in " << zstrm.total_in + << " total_out " << zstrm.total_out << endl; + break; + case Z_STREAM_END: + if (DebugCompress) + cerr << " inflate STREAM_END: avail_in " << zstrm.avail_in + << " avail_out " << zstrm.avail_out + << " total_in " << zstrm.total_in + << " total_out " << zstrm.total_out << endl; + break; + case Z_BUF_ERROR: + if (DebugCompress) + cerr << " inflate BUF_ERROR: avail_in " << zstrm.avail_in + << " avail_out " << zstrm.avail_out << endl; + return 0; + default: + internalError("Fitsy++ gzip inflate error"); + return 0; + } + + inflateEnd(&zstrm); + + return 1; +} + +template class FitsNRRDGzipm; +template class FitsNRRDGzipm; +template class FitsNRRDGzipm; +template class FitsNRRDGzipm; +template class FitsNRRDGzipm; +template class FitsNRRDGzipm; +template class FitsNRRDGzipm; + diff --git a/tksao/fitsy++/nrrdgzip.h b/tksao/fitsy++/nrrdgzip.h new file mode 100644 index 0000000..ce9e53d --- /dev/null +++ b/tksao/fitsy++/nrrdgzip.h @@ -0,0 +1,19 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsnrrdgzip_h__ +#define __fitsnrrdgzip_h__ + +#include "nrrd.h" + +template +class FitsNRRDGzipm : public FitsNRRDm { + private: + int compressed(T*, char*, size_t); + + public: + FitsNRRDGzipm(FitsFile*); +}; + +#endif diff --git a/tksao/fitsy++/nrrdlex.C b/tksao/fitsy++/nrrdlex.C new file mode 100644 index 0000000..c2b19f7 --- /dev/null +++ b/tksao/fitsy++/nrrdlex.C @@ -0,0 +1,2462 @@ +#line 2 "fitsy++/nrrdlex.C" + +#line 4 "fitsy++/nrrdlex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer nrrdFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *nrrdalloc (yy_size_t ); +void *nrrdrealloc (void *,yy_size_t ); +void nrrdfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 105 +#define YY_END_OF_BUFFER 106 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[359] = + { 0, + 0, 0, 2, 2, 106, 104, 100, 103, 104, 104, + 104, 95, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 104, 104, 2, 1, 100, 101, 0, 95, 97, + 96, 95, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 58, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 4, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 102, 0, 98, 2, 0, 0, 0, 96, 99, 99, + + 63, 99, 99, 60, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 57, 29, 99, 99, 99, 99, 99, 69, 67, 99, + 99, 99, 99, 5, 66, 99, 53, 99, 99, 99, + 99, 99, 99, 99, 99, 54, 99, 99, 99, 99, + 99, 99, 99, 96, 0, 97, 99, 82, 99, 74, + 99, 89, 99, 22, 99, 11, 99, 99, 99, 99, + 99, 99, 99, 12, 99, 59, 99, 99, 99, 23, + 99, 99, 72, 99, 40, 85, 83, 90, 91, 99, + 99, 99, 99, 99, 99, 99, 50, 71, 99, 55, + + 99, 19, 99, 37, 99, 99, 99, 99, 99, 56, + 99, 49, 99, 61, 99, 99, 3, 99, 99, 99, + 99, 99, 99, 47, 30, 35, 42, 0, 93, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 28, + 99, 79, 13, 99, 99, 25, 99, 26, 99, 14, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 48, 99, 62, 0, 0, 0, 24, + 92, 99, 64, 99, 99, 76, 70, 68, 16, 77, + 20, 99, 99, 38, 0, 99, 99, 99, 99, 32, + 99, 99, 99, 99, 99, 87, 65, 99, 99, 99, + + 94, 99, 31, 36, 43, 99, 99, 99, 99, 99, + 99, 0, 27, 33, 45, 99, 99, 86, 84, 99, + 75, 99, 99, 99, 99, 52, 73, 41, 6, 7, + 8, 9, 10, 99, 80, 99, 39, 0, 0, 99, + 21, 51, 99, 18, 99, 99, 99, 81, 34, 46, + 99, 88, 15, 17, 99, 44, 78, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 5, 1, 5, 6, 1, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 14, 1, 1, 1, + 1, 1, 1, 1, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 25, 32, 33, 34, 35, 25, 36, 37, 38, 39, + 1, 40, 1, 1, 41, 1, 42, 43, 44, 45, + + 46, 47, 48, 49, 50, 25, 51, 52, 53, 54, + 55, 56, 25, 57, 58, 59, 60, 25, 61, 62, + 63, 64, 65, 1, 66, 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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[67] = + { 0, + 1, 1, 2, 1, 3, 4, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 1, + 1, 6, 6, 6, 6, 7, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[367] = + { 0, + 0, 0, 1080, 1073, 1060, 1098, 1055, 1098, 1051, 1047, + 60, 70, 80, 81, 91, 106, 89, 82, 85, 83, + 96, 1046, 104, 135, 147, 149, 141, 158, 204, 176, + 218, 69, 985, 0, 1098, 1047, 1098, 270, 166, 81, + 137, 280, 1042, 322, 174, 152, 169, 201, 101, 199, + 205, 210, 215, 160, 223, 290, 310, 295, 292, 244, + 291, 305, 314, 296, 306, 340, 346, 318, 347, 352, + 345, 350, 351, 360, 1040, 358, 197, 356, 355, 382, + 362, 377, 353, 383, 386, 385, 390, 389, 405, 411, + 1098, 979, 1098, 0, 1039, 1038, 457, 467, 434, 429, + + 1036, 408, 195, 1035, 430, 477, 479, 482, 483, 484, + 485, 486, 487, 489, 491, 488, 497, 490, 493, 492, + 1034, 441, 496, 505, 510, 506, 522, 513, 516, 544, + 546, 518, 551, 1032, 547, 554, 1026, 548, 549, 553, + 552, 555, 571, 561, 578, 1023, 563, 572, 567, 574, + 587, 581, 591, 640, 649, 658, 668, 585, 593, 579, + 87, 1022, 669, 1021, 670, 1013, 671, 672, 673, 674, + 675, 676, 678, 1012, 677, 1011, 86, 239, 259, 98, + 679, 680, 681, 682, 698, 1010, 1009, 1008, 1005, 257, + 702, 707, 704, 724, 699, 723, 729, 1004, 732, 955, + + 734, 949, 735, 438, 736, 738, 739, 741, 740, 889, + 749, 747, 753, 841, 758, 755, 840, 768, 760, 769, + 794, 782, 801, 837, 265, 267, 269, 391, 771, 775, + 777, 804, 805, 297, 780, 807, 810, 812, 811, 700, + 823, 697, 694, 816, 819, 693, 418, 381, 610, 691, + 814, 832, 815, 828, 846, 847, 848, 852, 845, 853, + 857, 872, 850, 690, 876, 639, 576, 833, 850, 1098, + 637, 882, 635, 883, 618, 634, 633, 630, 626, 881, + 624, 895, 874, 521, 859, 621, 354, 907, 905, 623, + 909, 913, 885, 908, 915, 495, 453, 893, 920, 922, + + 436, 925, 1098, 1098, 1098, 923, 934, 975, 939, 930, + 932, 899, 1098, 921, 929, 966, 947, 431, 425, 954, + 422, 972, 951, 970, 983, 417, 348, 315, 311, 303, + 301, 299, 261, 985, 255, 989, 1098, 964, 967, 996, + 237, 231, 997, 181, 998, 1000, 1002, 172, 1098, 1098, + 991, 163, 161, 109, 1001, 94, 88, 1098, 1061, 1065, + 1067, 1074, 1081, 1084, 1089, 1092 + } ; + +static yyconst flex_int16_t yy_def[367] = + { 0, + 358, 1, 359, 359, 358, 358, 358, 358, 358, 360, + 358, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 358, 362, 363, 358, 358, 358, 358, 360, 364, + 364, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 358, 362, 358, 363, 365, 366, 358, 361, 361, 361, + + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 358, 358, 358, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 358, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 358, 358, 358, 358, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 358, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + + 361, 361, 358, 358, 358, 361, 361, 361, 361, 361, + 361, 358, 358, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 358, 358, 358, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 358, 358, + 361, 361, 361, 361, 361, 361, 361, 0, 358, 358, + 358, 358, 358, 358, 358, 358 + } ; + +static yyconst flex_int16_t yy_nxt[1165] = + { 0, + 6, 7, 8, 9, 10, 11, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 22, 28, 29, 30, 31, 22, 22, 22, 22, 32, + 6, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 23, 24, 25, 26, 27, 22, 28, 29, 30, 31, + 22, 22, 22, 22, 33, 6, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 41, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 358, 358, 358, 358, 44, + 358, 358, 358, 358, 358, 214, 358, 91, 225, 358, + + 96, 358, 62, 358, 47, 59, 358, 48, 60, 358, + 51, 358, 45, 52, 358, 44, 46, 58, 49, 50, + 53, 54, 91, 61, 63, 55, 96, 64, 62, 56, + 47, 59, 48, 60, 103, 57, 51, 45, 228, 52, + 358, 46, 58, 49, 50, 53, 358, 54, 61, 63, + 65, 55, 358, 64, 358, 56, 95, 358, 66, 103, + 57, 73, 68, 358, 67, 358, 358, 74, 358, 75, + 69, 41, 76, 77, 358, 100, 65, 358, 70, 358, + 71, 358, 95, 72, 66, 95, 358, 73, 68, 67, + 101, 99, 74, 110, 75, 83, 69, 76, 84, 77, + + 358, 100, 358, 70, 358, 71, 358, 104, 72, 358, + 358, 95, 85, 86, 160, 358, 101, 99, 110, 78, + 358, 83, 105, 358, 84, 108, 79, 80, 358, 81, + 102, 106, 137, 107, 82, 87, 358, 85, 86, 111, + 160, 88, 358, 109, 358, 78, 89, 226, 105, 358, + 90, 108, 79, 80, 81, 102, 106, 137, 107, 82, + 358, 87, 358, 234, 358, 111, 358, 88, 109, 227, + 358, 89, 358, 119, 358, 90, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 41, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 358, 358, 358, 119, 44, + + 358, 358, 358, 275, 358, 267, 358, 268, 358, 269, + 358, 358, 116, 117, 120, 358, 358, 112, 118, 358, + 358, 113, 124, 358, 123, 44, 97, 358, 98, 98, + 98, 98, 98, 98, 98, 98, 98, 114, 116, 117, + 120, 121, 112, 118, 115, 358, 113, 122, 124, 123, + 358, 358, 358, 358, 128, 358, 358, 358, 358, 358, + 358, 358, 114, 358, 315, 358, 121, 358, 125, 115, + 130, 134, 122, 126, 127, 129, 132, 133, 135, 128, + 131, 136, 358, 138, 139, 142, 358, 358, 358, 144, + 358, 358, 143, 125, 358, 358, 130, 134, 126, 127, + + 129, 132, 133, 140, 135, 131, 145, 136, 138, 139, + 358, 142, 148, 358, 144, 147, 358, 149, 143, 146, + 141, 285, 358, 358, 270, 159, 284, 358, 150, 140, + 358, 151, 145, 153, 358, 358, 358, 152, 148, 358, + 147, 358, 149, 358, 146, 141, 358, 247, 177, 270, + 178, 159, 248, 179, 150, 180, 151, 157, 358, 153, + 161, 158, 152, 154, 154, 154, 154, 154, 154, 154, + 154, 154, 358, 98, 98, 98, 98, 98, 98, 98, + 98, 98, 358, 157, 358, 161, 158, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 166, + + 358, 358, 358, 162, 170, 168, 169, 171, 175, 174, + 358, 358, 163, 164, 181, 358, 165, 172, 358, 167, + 173, 358, 176, 358, 182, 166, 358, 358, 162, 183, + 170, 168, 169, 171, 175, 174, 190, 163, 164, 184, + 181, 165, 172, 185, 167, 186, 173, 176, 187, 358, + 182, 358, 358, 358, 358, 183, 358, 358, 358, 358, + 358, 312, 190, 188, 184, 189, 358, 191, 358, 185, + 186, 197, 358, 187, 192, 193, 358, 358, 194, 358, + 195, 196, 202, 358, 358, 198, 358, 203, 199, 188, + 358, 189, 358, 191, 200, 201, 358, 197, 358, 192, + + 204, 193, 205, 194, 208, 195, 196, 206, 202, 303, + 198, 213, 211, 203, 199, 358, 207, 286, 212, 200, + 209, 201, 287, 358, 308, 204, 358, 205, 358, 358, + 208, 358, 206, 314, 303, 358, 213, 211, 358, 358, + 358, 207, 358, 212, 358, 209, 154, 154, 154, 154, + 154, 154, 154, 154, 154, 156, 156, 156, 156, 156, + 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, + 156, 156, 156, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 215, 216, + 219, 210, 217, 223, 222, 358, 358, 220, 358, 358, + + 218, 221, 358, 358, 358, 358, 230, 358, 232, 358, + 224, 229, 358, 231, 215, 216, 219, 210, 217, 223, + 222, 235, 236, 220, 233, 218, 221, 238, 358, 358, + 237, 230, 240, 232, 358, 224, 229, 358, 231, 358, + 358, 358, 241, 358, 358, 358, 358, 235, 236, 233, + 239, 243, 358, 238, 358, 244, 237, 240, 358, 245, + 358, 242, 252, 358, 254, 358, 246, 251, 241, 249, + 250, 253, 255, 358, 358, 239, 358, 243, 257, 256, + 358, 244, 358, 259, 245, 358, 242, 358, 252, 258, + 254, 246, 251, 262, 249, 250, 253, 263, 255, 358, + + 260, 261, 272, 257, 256, 265, 358, 271, 259, 358, + 358, 276, 358, 264, 258, 358, 358, 358, 262, 358, + 358, 358, 263, 273, 358, 260, 261, 272, 358, 266, + 280, 265, 271, 358, 274, 288, 276, 358, 278, 264, + 279, 281, 358, 277, 282, 358, 358, 283, 290, 273, + 358, 358, 358, 358, 266, 358, 280, 358, 358, 274, + 289, 288, 358, 278, 291, 279, 304, 281, 277, 282, + 293, 294, 283, 290, 292, 295, 298, 358, 297, 358, + 299, 358, 301, 305, 296, 289, 358, 358, 358, 291, + 358, 304, 313, 311, 358, 300, 293, 294, 358, 292, + + 358, 295, 298, 297, 302, 306, 299, 301, 305, 296, + 358, 307, 358, 358, 358, 309, 310, 313, 358, 311, + 358, 300, 323, 320, 317, 358, 358, 358, 358, 302, + 358, 306, 337, 316, 358, 358, 307, 358, 321, 358, + 309, 318, 310, 322, 358, 319, 326, 323, 320, 324, + 317, 325, 358, 327, 358, 328, 358, 337, 316, 358, + 358, 338, 335, 321, 336, 341, 318, 334, 322, 339, + 319, 358, 326, 342, 324, 358, 325, 358, 327, 344, + 358, 328, 329, 330, 331, 332, 333, 335, 358, 336, + 358, 341, 334, 343, 358, 340, 358, 349, 345, 342, + + 350, 358, 358, 358, 344, 358, 358, 358, 347, 358, + 358, 346, 356, 358, 358, 358, 358, 358, 358, 343, + 340, 348, 349, 345, 351, 350, 358, 358, 358, 352, + 353, 358, 354, 357, 347, 355, 346, 358, 356, 358, + 358, 358, 155, 97, 93, 358, 348, 358, 36, 351, + 93, 358, 38, 37, 352, 353, 36, 354, 357, 358, + 355, 34, 34, 34, 34, 34, 34, 34, 39, 39, + 43, 43, 43, 43, 92, 35, 92, 92, 92, 92, + 92, 94, 35, 94, 94, 94, 94, 94, 40, 358, + 40, 154, 358, 154, 156, 358, 156, 5, 358, 358, + + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358 + } ; + +static yyconst flex_int16_t yy_chk[1165] = + { 0, + 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, 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, 1, 1, + 1, 1, 1, 1, 1, 1, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 13, 14, 18, 20, 12, + 19, 177, 161, 357, 17, 161, 15, 32, 177, 356, + + 40, 21, 20, 180, 14, 18, 49, 14, 18, 23, + 15, 16, 13, 15, 354, 12, 13, 17, 14, 14, + 15, 16, 32, 19, 21, 16, 40, 23, 20, 16, + 14, 18, 14, 18, 49, 16, 15, 13, 180, 15, + 24, 13, 17, 14, 14, 15, 27, 16, 19, 21, + 24, 16, 25, 23, 26, 16, 41, 46, 24, 49, + 16, 27, 25, 28, 24, 54, 353, 27, 352, 27, + 25, 39, 27, 28, 47, 46, 24, 348, 26, 45, + 26, 30, 41, 26, 24, 39, 344, 27, 25, 24, + 47, 45, 27, 54, 27, 30, 25, 27, 30, 28, + + 103, 46, 77, 26, 50, 26, 48, 50, 26, 29, + 51, 39, 30, 30, 103, 52, 47, 45, 54, 29, + 53, 30, 50, 31, 30, 52, 29, 29, 55, 29, + 48, 51, 77, 51, 29, 31, 342, 30, 30, 55, + 103, 31, 341, 53, 178, 29, 31, 178, 50, 60, + 31, 52, 29, 29, 29, 48, 51, 77, 51, 29, + 335, 31, 190, 190, 179, 55, 333, 31, 53, 179, + 225, 31, 226, 60, 227, 31, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 56, 61, 59, 60, 42, + + 58, 64, 234, 234, 332, 225, 331, 226, 330, 227, + 62, 65, 58, 58, 61, 57, 329, 56, 59, 63, + 328, 56, 65, 68, 64, 42, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 57, 58, 58, + 61, 62, 56, 59, 57, 66, 56, 63, 65, 64, + 71, 67, 69, 327, 68, 72, 73, 70, 83, 287, + 79, 78, 57, 76, 287, 74, 62, 81, 66, 57, + 70, 73, 63, 66, 67, 69, 71, 72, 74, 68, + 70, 76, 82, 78, 79, 81, 248, 80, 84, 83, + 86, 85, 82, 66, 88, 87, 70, 73, 66, 67, + + 69, 71, 72, 80, 74, 70, 84, 76, 78, 79, + 89, 81, 87, 102, 83, 86, 90, 88, 82, 85, + 80, 248, 326, 247, 228, 102, 247, 321, 89, 80, + 319, 89, 84, 90, 100, 105, 318, 89, 87, 99, + 86, 301, 88, 204, 85, 80, 122, 204, 122, 228, + 122, 102, 204, 122, 89, 122, 89, 99, 297, 90, + 105, 100, 89, 97, 97, 97, 97, 97, 97, 97, + 97, 97, 98, 98, 98, 98, 98, 98, 98, 98, + 98, 98, 106, 99, 107, 105, 100, 108, 109, 110, + 111, 112, 113, 116, 114, 118, 115, 120, 119, 110, + + 296, 123, 117, 106, 114, 112, 113, 115, 119, 118, + 124, 126, 107, 108, 123, 125, 109, 116, 128, 111, + 117, 129, 120, 132, 124, 110, 284, 127, 106, 125, + 114, 112, 113, 115, 119, 118, 132, 107, 108, 126, + 123, 109, 116, 127, 111, 128, 117, 120, 129, 130, + 124, 131, 135, 138, 139, 125, 133, 141, 140, 136, + 142, 284, 132, 130, 126, 131, 144, 133, 147, 127, + 128, 141, 149, 129, 135, 136, 143, 148, 138, 150, + 139, 140, 147, 145, 160, 142, 152, 148, 143, 130, + 158, 131, 151, 133, 144, 145, 153, 141, 159, 135, + + 149, 136, 150, 138, 152, 139, 140, 150, 147, 267, + 142, 160, 158, 148, 143, 249, 151, 249, 159, 144, + 153, 145, 249, 275, 275, 149, 286, 150, 290, 281, + 152, 279, 150, 286, 267, 278, 160, 158, 277, 276, + 273, 151, 271, 159, 266, 153, 154, 154, 154, 154, + 154, 154, 154, 154, 154, 155, 155, 155, 155, 155, + 155, 155, 155, 155, 156, 156, 156, 156, 156, 156, + 156, 156, 156, 157, 163, 165, 167, 168, 169, 170, + 171, 172, 175, 173, 181, 182, 183, 184, 163, 165, + 169, 157, 167, 173, 172, 264, 250, 170, 246, 243, + + 168, 171, 242, 185, 195, 240, 182, 191, 184, 193, + 175, 181, 192, 183, 163, 165, 169, 157, 167, 173, + 172, 191, 192, 170, 185, 168, 171, 193, 196, 194, + 192, 182, 195, 184, 197, 175, 181, 199, 183, 201, + 203, 205, 196, 206, 207, 209, 208, 191, 192, 185, + 194, 199, 212, 193, 211, 199, 192, 195, 213, 201, + 216, 197, 208, 215, 211, 219, 203, 207, 196, 205, + 206, 209, 211, 218, 220, 194, 229, 199, 213, 212, + 230, 199, 231, 216, 201, 235, 197, 222, 208, 215, + 211, 203, 207, 219, 205, 206, 209, 220, 211, 221, + + 218, 218, 231, 213, 212, 222, 223, 230, 216, 232, + 233, 235, 236, 221, 215, 237, 239, 238, 219, 251, + 253, 244, 220, 232, 245, 218, 218, 231, 241, 223, + 239, 222, 230, 254, 233, 251, 235, 252, 237, 221, + 238, 241, 224, 236, 244, 217, 214, 245, 253, 232, + 259, 255, 256, 257, 223, 263, 239, 258, 260, 233, + 252, 251, 261, 237, 254, 238, 268, 241, 236, 244, + 256, 257, 245, 253, 255, 258, 260, 262, 259, 283, + 261, 265, 263, 269, 258, 252, 280, 272, 274, 254, + 293, 268, 285, 283, 210, 262, 256, 257, 298, 255, + + 282, 258, 260, 259, 265, 272, 261, 263, 269, 258, + 289, 274, 288, 294, 291, 280, 282, 285, 292, 283, + 295, 262, 298, 293, 289, 299, 314, 300, 306, 265, + 302, 272, 312, 288, 315, 310, 274, 311, 294, 307, + 280, 291, 282, 295, 309, 292, 302, 298, 293, 299, + 289, 300, 317, 306, 202, 307, 323, 312, 288, 320, + 200, 314, 310, 294, 311, 317, 291, 309, 295, 315, + 292, 316, 302, 320, 299, 324, 300, 322, 306, 323, + 308, 307, 308, 308, 308, 308, 308, 310, 325, 311, + 334, 317, 309, 322, 336, 316, 351, 338, 324, 320, + + 339, 340, 343, 345, 323, 346, 355, 347, 334, 198, + 189, 325, 351, 188, 187, 186, 176, 174, 166, 322, + 316, 336, 338, 324, 340, 339, 164, 162, 146, 343, + 345, 137, 346, 355, 334, 347, 325, 134, 351, 121, + 104, 101, 96, 95, 92, 75, 336, 43, 36, 340, + 33, 22, 10, 9, 343, 345, 7, 346, 355, 5, + 347, 359, 359, 359, 359, 359, 359, 359, 360, 360, + 361, 361, 361, 361, 362, 4, 362, 362, 362, 362, + 362, 363, 3, 363, 363, 363, 363, 363, 364, 0, + 364, 365, 0, 365, 366, 0, 366, 358, 358, 358, + + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "fitsy++/nrrdlex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 11 "fitsy++/nrrdlex.L" + #include + #include + #include + + #include "util.h" + #include "nrrdparser.H" + + extern YYSTYPE* nrrdlval; + extern nrrdFlexLexer* nrrdlexx; + +/* rules */ +#line 799 "fitsy++/nrrdlex.C" + +#define INITIAL 0 +#define DISCARD 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 29 "fitsy++/nrrdlex.L" + + +#line 903 "fitsy++/nrrdlex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 359 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 358 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +#line 31 "fitsy++/nrrdlex.L" +{ // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(nrrdlval->str,""); // feed a blank string + return STRING; + } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 38 "fitsy++/nrrdlex.L" +{ // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(NRRDPARSERSIZE-1) ? yyleng:(NRRDPARSERSIZE-1); + strncpy(nrrdlval->str,yytext,ll); + nrrdlval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 46 "fitsy++/nrrdlex.L" +{return DEBUG_;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 47 "fitsy++/nrrdlex.L" +{return ON_;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 48 "fitsy++/nrrdlex.L" +{return OFF_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 50 "fitsy++/nrrdlex.L" +{return NRRD0001_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 51 "fitsy++/nrrdlex.L" +{return NRRD0002_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 52 "fitsy++/nrrdlex.L" +{return NRRD0003_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 53 "fitsy++/nrrdlex.L" +{return NRRD0004_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 54 "fitsy++/nrrdlex.L" +{return NRRD0005_;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 56 "fitsy++/nrrdlex.L" +{return DATA_;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 57 "fitsy++/nrrdlex.L" +{return FILE_;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 59 "fitsy++/nrrdlex.L" +{return SPACE_;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 60 "fitsy++/nrrdlex.L" +{return UNITS_;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 61 "fitsy++/nrrdlex.L" +{return DIMENSIONS_;} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 62 "fitsy++/nrrdlex.L" +{return ORIGIN_;} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 63 "fitsy++/nrrdlex.L" +{return DIRECTIONS_;} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 65 "fitsy++/nrrdlex.L" +{return DIMENSION_;} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 67 "fitsy++/nrrdlex.L" +{return TYPE_;} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 68 "fitsy++/nrrdlex.L" +{return SIGNED_;} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 69 "fitsy++/nrrdlex.L" +{return UNSIGNED_;} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 70 "fitsy++/nrrdlex.L" +{return CHAR_;} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 71 "fitsy++/nrrdlex.L" +{return INT8_;} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 72 "fitsy++/nrrdlex.L" +{return INT8_T_;} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 73 "fitsy++/nrrdlex.L" +{return UCHAR_;} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 74 "fitsy++/nrrdlex.L" +{return UINT8_;} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 75 "fitsy++/nrrdlex.L" +{return UINT8_T_;} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 76 "fitsy++/nrrdlex.L" +{return SHORT_;} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 77 "fitsy++/nrrdlex.L" +{return INT_;} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 78 "fitsy++/nrrdlex.L" +{return INT16_;} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 79 "fitsy++/nrrdlex.L" +{return INT16_T_;} + YY_BREAK +case 32: +YY_RULE_SETUP +#line 80 "fitsy++/nrrdlex.L" +{return USHORT_;} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 81 "fitsy++/nrrdlex.L" +{return UINT16_;} + YY_BREAK +case 34: +YY_RULE_SETUP +#line 82 "fitsy++/nrrdlex.L" +{return UINT16_T_;} + YY_BREAK +case 35: +YY_RULE_SETUP +#line 83 "fitsy++/nrrdlex.L" +{return INT32_;} + YY_BREAK +case 36: +YY_RULE_SETUP +#line 84 "fitsy++/nrrdlex.L" +{return INT32_T_;} + YY_BREAK +case 37: +YY_RULE_SETUP +#line 85 "fitsy++/nrrdlex.L" +{return UINT_;} + YY_BREAK +case 38: +YY_RULE_SETUP +#line 86 "fitsy++/nrrdlex.L" +{return UINT32_;} + YY_BREAK +case 39: +YY_RULE_SETUP +#line 87 "fitsy++/nrrdlex.L" +{return UINT32_T_;} + YY_BREAK +case 40: +YY_RULE_SETUP +#line 88 "fitsy++/nrrdlex.L" +{return LONG_;} + YY_BREAK +case 41: +YY_RULE_SETUP +#line 89 "fitsy++/nrrdlex.L" +{return LONGLONG_;} + YY_BREAK +case 42: +YY_RULE_SETUP +#line 90 "fitsy++/nrrdlex.L" +{return INT64_;} + YY_BREAK +case 43: +YY_RULE_SETUP +#line 91 "fitsy++/nrrdlex.L" +{return INT64_T_;} + YY_BREAK +case 44: +YY_RULE_SETUP +#line 92 "fitsy++/nrrdlex.L" +{return ULONGLONG_;} + YY_BREAK +case 45: +YY_RULE_SETUP +#line 93 "fitsy++/nrrdlex.L" +{return UINT64_;} + YY_BREAK +case 46: +YY_RULE_SETUP +#line 94 "fitsy++/nrrdlex.L" +{return UINT64_T_;} + YY_BREAK +case 47: +YY_RULE_SETUP +#line 95 "fitsy++/nrrdlex.L" +{return FLOAT_;} + YY_BREAK +case 48: +YY_RULE_SETUP +#line 96 "fitsy++/nrrdlex.L" +{return DOUBLE_;} + YY_BREAK +case 49: +YY_RULE_SETUP +#line 98 "fitsy++/nrrdlex.L" +{return BLOCK_;} + YY_BREAK +case 50: +YY_RULE_SETUP +#line 99 "fitsy++/nrrdlex.L" +{return SIZE_;} + YY_BREAK +case 51: +YY_RULE_SETUP +#line 100 "fitsy++/nrrdlex.L" +{return BLOCKSIZE_;} + YY_BREAK +case 52: +YY_RULE_SETUP +#line 102 "fitsy++/nrrdlex.L" +{return ENCODING_;} + YY_BREAK +case 53: +YY_RULE_SETUP +#line 103 "fitsy++/nrrdlex.L" +{return RAW_;} + YY_BREAK +case 54: +YY_RULE_SETUP +#line 104 "fitsy++/nrrdlex.L" +{return TXT_;} + YY_BREAK +case 55: +YY_RULE_SETUP +#line 105 "fitsy++/nrrdlex.L" +{return TEXT_;} + YY_BREAK +case 56: +YY_RULE_SETUP +#line 106 "fitsy++/nrrdlex.L" +{return ASCII_;} + YY_BREAK +case 57: +YY_RULE_SETUP +#line 107 "fitsy++/nrrdlex.L" +{return HEX_;} + YY_BREAK +case 58: +YY_RULE_SETUP +#line 108 "fitsy++/nrrdlex.L" +{return GZ_;} + YY_BREAK +case 59: +YY_RULE_SETUP +#line 109 "fitsy++/nrrdlex.L" +{return GZIP_;} + YY_BREAK +case 60: +YY_RULE_SETUP +#line 110 "fitsy++/nrrdlex.L" +{return BZ2_;} + YY_BREAK +case 61: +YY_RULE_SETUP +#line 111 "fitsy++/nrrdlex.L" +{return BZIP2_;} + YY_BREAK +case 62: +YY_RULE_SETUP +#line 113 "fitsy++/nrrdlex.L" +{return ENDIAN_;} + YY_BREAK +case 63: +YY_RULE_SETUP +#line 114 "fitsy++/nrrdlex.L" +{return BIG_;} + YY_BREAK +case 64: +YY_RULE_SETUP +#line 115 "fitsy++/nrrdlex.L" +{return LITTLE_;} + YY_BREAK +case 65: +YY_RULE_SETUP +#line 117 "fitsy++/nrrdlex.L" +{return CONTENT_;} + YY_BREAK +case 66: +YY_RULE_SETUP +#line 119 "fitsy++/nrrdlex.L" +{return OLD_;} + YY_BREAK +case 67: +YY_RULE_SETUP +#line 120 "fitsy++/nrrdlex.L" +{return MIN_;} + YY_BREAK +case 68: +YY_RULE_SETUP +#line 121 "fitsy++/nrrdlex.L" +{return OLDMIN_;} + YY_BREAK +case 69: +YY_RULE_SETUP +#line 122 "fitsy++/nrrdlex.L" +{return MAX_;} + YY_BREAK +case 70: +YY_RULE_SETUP +#line 123 "fitsy++/nrrdlex.L" +{return OLDMAX_;} + YY_BREAK +case 71: +YY_RULE_SETUP +#line 125 "fitsy++/nrrdlex.L" +{return SKIP_;} + YY_BREAK +case 72: +YY_RULE_SETUP +#line 126 "fitsy++/nrrdlex.L" +{return LINE_;} + YY_BREAK +case 73: +YY_RULE_SETUP +#line 127 "fitsy++/nrrdlex.L" +{return LINESKIP_;} + YY_BREAK +case 74: +YY_RULE_SETUP +#line 128 "fitsy++/nrrdlex.L" +{return BYTE_;} + YY_BREAK +case 75: +YY_RULE_SETUP +#line 129 "fitsy++/nrrdlex.L" +{return BYTESKIP_;} + YY_BREAK +case 76: +YY_RULE_SETUP +#line 131 "fitsy++/nrrdlex.L" +{return NUMBER_;} + YY_BREAK +case 77: +YY_RULE_SETUP +#line 133 "fitsy++/nrrdlex.L" +{return SAMPLE_;} + YY_BREAK +case 78: +YY_RULE_SETUP +#line 134 "fitsy++/nrrdlex.L" +{return SAMPLEUNITS_;} + YY_BREAK +case 79: +YY_RULE_SETUP +#line 136 "fitsy++/nrrdlex.L" +{return SIZES_;} + YY_BREAK +case 80: +YY_RULE_SETUP +#line 137 "fitsy++/nrrdlex.L" +{return SPACINGS_;} + YY_BREAK +case 81: +YY_RULE_SETUP +#line 138 "fitsy++/nrrdlex.L" +{return THICKNESSES_;} + YY_BREAK +case 82: +YY_RULE_SETUP +#line 139 "fitsy++/nrrdlex.L" +{return AXIS_;} + YY_BREAK +case 83: +YY_RULE_SETUP +#line 140 "fitsy++/nrrdlex.L" +{return MINS_;} + YY_BREAK +case 84: +YY_RULE_SETUP +#line 141 "fitsy++/nrrdlex.L" +{return AXISMINS_;} + YY_BREAK +case 85: +YY_RULE_SETUP +#line 142 "fitsy++/nrrdlex.L" +{return MAXS_;} + YY_BREAK +case 86: +YY_RULE_SETUP +#line 143 "fitsy++/nrrdlex.L" +{return AXISMAXS_;} + YY_BREAK +case 87: +YY_RULE_SETUP +#line 144 "fitsy++/nrrdlex.L" +{return CENTERS_;} + YY_BREAK +case 88: +YY_RULE_SETUP +#line 145 "fitsy++/nrrdlex.L" +{return CENTERINGS_;} + YY_BREAK +case 89: +YY_RULE_SETUP +#line 146 "fitsy++/nrrdlex.L" +{return CELL_;} + YY_BREAK +case 90: +YY_RULE_SETUP +#line 147 "fitsy++/nrrdlex.L" +{return NODE_;} + YY_BREAK +case 91: +YY_RULE_SETUP +#line 148 "fitsy++/nrrdlex.L" +{return NONE_;} + YY_BREAK +case 92: +YY_RULE_SETUP +#line 149 "fitsy++/nrrdlex.L" +{return LABELS_;} + YY_BREAK +case 93: +YY_RULE_SETUP +#line 150 "fitsy++/nrrdlex.L" +{return KINDS_;} + YY_BREAK +case 94: +YY_RULE_SETUP +#line 151 "fitsy++/nrrdlex.L" +{return DOMAINS_;} + YY_BREAK +case 95: +YY_RULE_SETUP +#line 153 "fitsy++/nrrdlex.L" +{ // Integer + nrrdlval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 96: +#line 159 "fitsy++/nrrdlex.L" +case 97: +YY_RULE_SETUP +#line 159 "fitsy++/nrrdlex.L" +{ // Real Number + nrrdlval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 98: +YY_RULE_SETUP +#line 165 "fitsy++/nrrdlex.L" +{ // Quoted String + int ll = (yyleng-2)<(NRRDPARSERSIZE-1) ? (yyleng-2):(NRRDPARSERSIZE-1); + strncpy(nrrdlval->str,yytext+1,ll); // skip the '{' + nrrdlval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + YY_BREAK +case 99: +YY_RULE_SETUP +#line 172 "fitsy++/nrrdlex.L" +{ // General String + int ll = yyleng <(NRRDPARSERSIZE-1) ? yyleng:(NRRDPARSERSIZE-1); + strncpy(nrrdlval->str,yytext,ll); + nrrdlval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 100: +YY_RULE_SETUP +#line 179 "fitsy++/nrrdlex.L" +{ // White Spaces + } + YY_BREAK +case 101: +/* rule 101 can match eol */ +YY_RULE_SETUP +#line 182 "fitsy++/nrrdlex.L" +{ // windows line feed + return '\n'; + } + YY_BREAK +case 102: +YY_RULE_SETUP +#line 186 "fitsy++/nrrdlex.L" +{ // fake line feed + return '\n'; + } + YY_BREAK +case 103: +/* rule 103 can match eol */ +YY_RULE_SETUP +#line 190 "fitsy++/nrrdlex.L" +{ // linefeed + return '\n'; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(DISCARD): +#line 194 "fitsy++/nrrdlex.L" +{ // eof + return EOF_; + } + YY_BREAK +case 104: +YY_RULE_SETUP +#line 198 "fitsy++/nrrdlex.L" +{ // Else, return the char + return yytext[0]; + } + YY_BREAK +case 105: +YY_RULE_SETUP +#line 202 "fitsy++/nrrdlex.L" +ECHO; + YY_BREAK +#line 1550 "fitsy++/nrrdlex.C" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + nrrdfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + nrrdfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + nrrdrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) nrrdrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 359 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 359 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 358); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) nrrdalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) nrrdalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + nrrdfree((void *) b->yy_ch_buf ); + + nrrdfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)nrrdalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)nrrdrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) nrrdalloc(new_size ); + + else + (yy_start_stack) = (int *) nrrdrealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *nrrdalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *nrrdrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void nrrdfree (void * ptr ) +{ + free( (char *) ptr ); /* see nrrdrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 202 "fitsy++/nrrdlex.L" + + + +void nrrdDiscard(int doit) +{ + if (nrrdlexx) + nrrdlexx->begin(DISCARD, doit); +} + +void nrrdFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} + diff --git a/tksao/fitsy++/nrrdlex.L b/tksao/fitsy++/nrrdlex.L new file mode 100644 index 0000000..8acfa2d --- /dev/null +++ b/tksao/fitsy++/nrrdlex.L @@ -0,0 +1,215 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + + #include "util.h" + #include "nrrdparser.H" + + extern YYSTYPE* nrrdlval; + extern nrrdFlexLexer* nrrdlexx; +%} + +%x DISCARD + +D [0-9] +E [Ee][+-]?{D}+ + +/* rules */ + +%% + +[\n] { // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(nrrdlval->str,""); // feed a blank string + return STRING; + } + +[^\n]* { // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(NRRDPARSERSIZE-1) ? yyleng:(NRRDPARSERSIZE-1); + strncpy(nrrdlval->str,yytext,ll); + nrrdlval->str[ll] = '\0'; + return STRING; + } + +debug {return DEBUG_;} +on {return ON_;} +off {return OFF_;} + +NRRD0001 {return NRRD0001_;} +NRRD0002 {return NRRD0002_;} +NRRD0003 {return NRRD0003_;} +NRRD0004 {return NRRD0004_;} +NRRD0005 {return NRRD0005_;} + +data {return DATA_;} +file {return FILE_;} + +space {return SPACE_;} +units {return UNITS_;} +dimentions {return DIMENSIONS_;} +origin {return ORIGIN_;} +directions {return DIRECTIONS_;} + +dimension {return DIMENSION_;} + +type {return TYPE_;} +signed {return SIGNED_;} +unsigned {return UNSIGNED_;} +char {return CHAR_;} +int8 {return INT8_;} +int8_t {return INT8_T_;} +uchar {return UCHAR_;} +uint8 {return UINT8_;} +uint8_t {return UINT8_T_;} +short {return SHORT_;} +int {return INT_;} +int16 {return INT16_;} +int16_t {return INT16_T_;} +ushort {return USHORT_;} +unint16 {return UINT16_;} +unint16_t {return UINT16_T_;} +int32 {return INT32_;} +int32_t {return INT32_T_;} +uint {return UINT_;} +uint32 {return UINT32_;} +uint32_t {return UINT32_T_;} +long {return LONG_;} +longlong {return LONGLONG_;} +int64 {return INT64_;} +int64_t {return INT64_T_;} +unlonglong {return ULONGLONG_;} +unint64 {return UINT64_;} +unint64_t {return UINT64_T_;} +float {return FLOAT_;} +double {return DOUBLE_;} + +block {return BLOCK_;} +size {return SIZE_;} +blocksize {return BLOCKSIZE_;} + +encoding {return ENCODING_;} +raw {return RAW_;} +txt {return TXT_;} +text {return TEXT_;} +ascii {return ASCII_;} +hex {return HEX_;} +gz {return GZ_;} +gzip {return GZIP_;} +bz2 {return BZ2_;} +bzip2 {return BZIP2_;} + +endian {return ENDIAN_;} +big {return BIG_;} +little {return LITTLE_;} + +content {return CONTENT_;} + +old {return OLD_;} +min {return MIN_;} +oldmin {return OLDMIN_;} +max {return MAX_;} +oldmax {return OLDMAX_;} + +skip {return SKIP_;} +line {return LINE_;} +lineskip {return LINESKIP_;} +byte {return BYTE_;} +byteskip {return BYTESKIP_;} + +number {return NUMBER_;} + +sample {return SAMPLE_;} +sampleunits {return SAMPLEUNITS_;} + +sizes {return SIZES_;} +spacings {return SPACINGS_;} +thickness {return THICKNESSES_;} +axis {return AXIS_;} +mins {return MINS_;} +axismins {return AXISMINS_;} +maxs {return MAXS_;} +axismaxs {return AXISMAXS_;} +centers {return CENTERS_;} +centerings {return CENTERINGS_;} +cell {return CELL_;} +node {return NODE_;} +none {return NONE_;} +labels {return LABELS_;} +kinds {return KINDS_;} +domains {return DOMAINS_;} + +[+-]?{D}+ { // Integer + nrrdlval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + nrrdlval->real = atof(yytext); + return REAL; + } + + +\{[^\}\n]*\} { // Quoted String + int ll = (yyleng-2)<(NRRDPARSERSIZE-1) ? (yyleng-2):(NRRDPARSERSIZE-1); + strncpy(nrrdlval->str,yytext+1,ll); // skip the '{' + nrrdlval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + +[0-9A-Za-z]+ { // General String + int ll = yyleng <(NRRDPARSERSIZE-1) ? yyleng:(NRRDPARSERSIZE-1); + strncpy(nrrdlval->str,yytext,ll); + nrrdlval->str[ll] = '\0'; + return STRING; + } + +[ \t]+ { // White Spaces + } + +\r\n { // windows line feed + return '\n'; + } + +\\n { // fake line feed + return '\n'; + } + +\n { // linefeed + return '\n'; + } + +<> { // eof + return EOF_; + } + +. { // Else, return the char + return yytext[0]; + } + +%% + +void nrrdDiscard(int doit) +{ + if (nrrdlexx) + nrrdlexx->begin(DISCARD, doit); +} + +void nrrdFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} diff --git a/tksao/fitsy++/nrrdparser.C b/tksao/fitsy++/nrrdparser.C new file mode 100644 index 0000000..bcc7cde --- /dev/null +++ b/tksao/fitsy++/nrrdparser.C @@ -0,0 +1,2196 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse nrrdparse +#define yylex nrrdlex +#define yyerror nrrderror +#define yylval nrrdlval +#define yychar nrrdchar +#define yydebug nrrddebug +#define yynerrs nrrdnerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + EOF_ = 258, + INT = 259, + REAL = 260, + STRING = 261, + DEBUG_ = 262, + ON_ = 263, + OFF_ = 264, + NRRD0001_ = 265, + NRRD0002_ = 266, + NRRD0003_ = 267, + NRRD0004_ = 268, + NRRD0005_ = 269, + DATA_ = 270, + FILE_ = 271, + SPACE_ = 272, + UNITS_ = 273, + DIMENSIONS_ = 274, + ORIGIN_ = 275, + DIRECTIONS_ = 276, + DIMENSION_ = 277, + TYPE_ = 278, + SIGNED_ = 279, + UNSIGNED_ = 280, + CHAR_ = 281, + INT8_ = 282, + INT8_T_ = 283, + UCHAR_ = 284, + UINT8_ = 285, + UINT8_T_ = 286, + SHORT_ = 287, + INT_ = 288, + INT16_ = 289, + INT16_T_ = 290, + USHORT_ = 291, + UINT16_ = 292, + UINT16_T_ = 293, + INT32_ = 294, + INT32_T_ = 295, + UINT_ = 296, + UINT32_ = 297, + UINT32_T_ = 298, + LONG_ = 299, + LONGLONG_ = 300, + INT64_ = 301, + INT64_T_ = 302, + ULONGLONG_ = 303, + UINT64_ = 304, + UINT64_T_ = 305, + FLOAT_ = 306, + DOUBLE_ = 307, + BLOCK_ = 308, + SIZE_ = 309, + BLOCKSIZE_ = 310, + ENCODING_ = 311, + RAW_ = 312, + TXT_ = 313, + TEXT_ = 314, + ASCII_ = 315, + HEX_ = 316, + GZ_ = 317, + GZIP_ = 318, + BZ2_ = 319, + BZIP2_ = 320, + ENDIAN_ = 321, + BIG_ = 322, + LITTLE_ = 323, + CONTENT_ = 324, + OLD_ = 325, + MIN_ = 326, + OLDMIN_ = 327, + MAX_ = 328, + OLDMAX_ = 329, + SKIP_ = 330, + LINE_ = 331, + LINESKIP_ = 332, + BYTE_ = 333, + BYTESKIP_ = 334, + NUMBER_ = 335, + SAMPLE_ = 336, + SAMPLEUNITS_ = 337, + SIZES_ = 338, + SPACINGS_ = 339, + THICKNESSES_ = 340, + AXIS_ = 341, + MINS_ = 342, + AXISMINS_ = 343, + MAXS_ = 344, + AXISMAXS_ = 345, + CENTERS_ = 346, + CENTERINGS_ = 347, + CELL_ = 348, + NODE_ = 349, + NONE_ = 350, + LABELS_ = 351, + KINDS_ = 352, + DOMAINS_ = 353 + }; +#endif +/* Tokens. */ +#define EOF_ 258 +#define INT 259 +#define REAL 260 +#define STRING 261 +#define DEBUG_ 262 +#define ON_ 263 +#define OFF_ 264 +#define NRRD0001_ 265 +#define NRRD0002_ 266 +#define NRRD0003_ 267 +#define NRRD0004_ 268 +#define NRRD0005_ 269 +#define DATA_ 270 +#define FILE_ 271 +#define SPACE_ 272 +#define UNITS_ 273 +#define DIMENSIONS_ 274 +#define ORIGIN_ 275 +#define DIRECTIONS_ 276 +#define DIMENSION_ 277 +#define TYPE_ 278 +#define SIGNED_ 279 +#define UNSIGNED_ 280 +#define CHAR_ 281 +#define INT8_ 282 +#define INT8_T_ 283 +#define UCHAR_ 284 +#define UINT8_ 285 +#define UINT8_T_ 286 +#define SHORT_ 287 +#define INT_ 288 +#define INT16_ 289 +#define INT16_T_ 290 +#define USHORT_ 291 +#define UINT16_ 292 +#define UINT16_T_ 293 +#define INT32_ 294 +#define INT32_T_ 295 +#define UINT_ 296 +#define UINT32_ 297 +#define UINT32_T_ 298 +#define LONG_ 299 +#define LONGLONG_ 300 +#define INT64_ 301 +#define INT64_T_ 302 +#define ULONGLONG_ 303 +#define UINT64_ 304 +#define UINT64_T_ 305 +#define FLOAT_ 306 +#define DOUBLE_ 307 +#define BLOCK_ 308 +#define SIZE_ 309 +#define BLOCKSIZE_ 310 +#define ENCODING_ 311 +#define RAW_ 312 +#define TXT_ 313 +#define TEXT_ 314 +#define ASCII_ 315 +#define HEX_ 316 +#define GZ_ 317 +#define GZIP_ 318 +#define BZ2_ 319 +#define BZIP2_ 320 +#define ENDIAN_ 321 +#define BIG_ 322 +#define LITTLE_ 323 +#define CONTENT_ 324 +#define OLD_ 325 +#define MIN_ 326 +#define OLDMIN_ 327 +#define MAX_ 328 +#define OLDMAX_ 329 +#define SKIP_ 330 +#define LINE_ 331 +#define LINESKIP_ 332 +#define BYTE_ 333 +#define BYTESKIP_ 334 +#define NUMBER_ 335 +#define SAMPLE_ 336 +#define SAMPLEUNITS_ 337 +#define SIZES_ 338 +#define SPACINGS_ 339 +#define THICKNESSES_ 340 +#define AXIS_ 341 +#define MINS_ 342 +#define AXISMINS_ 343 +#define MAXS_ 344 +#define AXISMAXS_ 345 +#define CENTERS_ 346 +#define CENTERINGS_ 347 +#define CELL_ 348 +#define NODE_ 349 +#define NONE_ 350 +#define LABELS_ 351 +#define KINDS_ 352 +#define DOMAINS_ 353 + + + + +/* Copy the first part of user declarations. */ +#line 10 "fitsy++/nrrdparser.Y" + +#define YYDEBUG 1 + +#define DISCARD_(x) {yyclearin; nrrdDiscard(x);} + +#include "file.h" + +#undef yyFlexLexer +#define yyFlexLexer nrrdFlexLexer +#include + +extern int nrrdlex(void*, nrrdFlexLexer*); +extern void nrrderror(FitsFile*, nrrdFlexLexer*, const char*); +extern void nrrdDiscard(int); + +int dim; + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 29 "fitsy++/nrrdparser.Y" +{ +#define NRRDPARSERSIZE 256 + float real; + int integer; + char str[NRRDPARSERSIZE]; +} +/* Line 193 of yacc.c. */ +#line 326 "fitsy++/nrrdparser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 339 "fitsy++/nrrdparser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 245 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 102 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 44 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 152 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 240 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 353 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 101, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 100, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 99, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 98 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 4, 7, 11, 14, 15, 18, 20, + 22, 27, 30, 34, 38, 40, 44, 48, 49, 54, + 58, 62, 64, 66, 68, 70, 74, 78, 82, 86, + 91, 95, 100, 104, 108, 112, 116, 120, 124, 126, + 128, 130, 132, 134, 135, 139, 141, 143, 145, 147, + 149, 151, 152, 156, 160, 161, 166, 167, 172, 173, + 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, + 198, 200, 202, 205, 207, 209, 211, 214, 216, 218, + 220, 223, 226, 230, 232, 234, 236, 239, 243, 245, + 247, 249, 252, 254, 256, 258, 261, 263, 265, 267, + 270, 274, 278, 283, 285, 287, 289, 293, 298, 300, + 302, 307, 311, 313, 315, 317, 319, 321, 323, 325, + 327, 329, 331, 333, 338, 342, 347, 351, 356, 360, + 365, 369, 372, 374, 376, 379, 381, 384, 386, 389, + 391, 394, 396, 399, 401, 403, 405, 407, 410, 412, + 415, 417, 420 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int16 yyrhs[] = +{ + 103, 0, -1, -1, 104, 105, -1, 105, 106, 111, + -1, 106, 111, -1, -1, 7, 113, -1, 108, -1, + 109, -1, 15, 16, 99, 6, -1, 17, 114, -1, + 22, 99, 4, -1, 23, 99, 119, -1, 128, -1, + 56, 99, 129, -1, 66, 99, 130, -1, -1, 69, + 99, 107, 6, -1, 71, 99, 112, -1, 73, 99, + 112, -1, 131, -1, 132, -1, 133, -1, 134, -1, + 80, 99, 6, -1, 83, 99, 135, -1, 84, 99, + 137, -1, 85, 99, 138, -1, 86, 87, 99, 139, + -1, 88, 99, 139, -1, 86, 89, 99, 140, -1, + 90, 99, 140, -1, 91, 99, 141, -1, 92, 99, + 141, -1, 96, 99, 143, -1, 18, 99, 144, -1, + 97, 99, 145, -1, 10, -1, 11, -1, 12, -1, + 13, -1, 14, -1, -1, 100, 110, 6, -1, 101, + -1, 3, -1, 5, -1, 4, -1, 8, -1, 9, + -1, -1, 99, 115, 6, -1, 22, 99, 4, -1, + -1, 18, 99, 116, 6, -1, -1, 20, 99, 117, + 6, -1, -1, 21, 99, 118, 6, -1, 120, -1, + 121, -1, 122, -1, 123, -1, 124, -1, 125, -1, + 126, -1, 127, -1, 51, -1, 52, -1, 53, -1, + 26, -1, 24, 26, -1, 27, -1, 28, -1, 29, + -1, 25, 26, -1, 30, -1, 31, -1, 32, -1, + 32, 33, -1, 24, 32, -1, 24, 32, 33, -1, + 34, -1, 35, -1, 36, -1, 25, 32, -1, 25, + 32, 33, -1, 37, -1, 38, -1, 33, -1, 24, + 33, -1, 39, -1, 40, -1, 41, -1, 25, 33, + -1, 42, -1, 43, -1, 45, -1, 44, 44, -1, + 44, 44, 33, -1, 24, 44, 44, -1, 24, 44, + 44, 33, -1, 46, -1, 47, -1, 48, -1, 25, + 44, 44, -1, 25, 44, 44, 33, -1, 49, -1, + 50, -1, 53, 54, 99, 4, -1, 55, 99, 4, + -1, 57, -1, 58, -1, 59, -1, 60, -1, 61, + -1, 62, -1, 63, -1, 64, -1, 65, -1, 67, + -1, 68, -1, 70, 71, 99, 112, -1, 72, 99, + 112, -1, 70, 73, 99, 112, -1, 74, 99, 112, + -1, 76, 75, 99, 4, -1, 77, 99, 4, -1, + 78, 75, 99, 4, -1, 79, 99, 4, -1, 135, + 136, -1, 136, -1, 4, -1, 137, 112, -1, 112, + -1, 138, 112, -1, 112, -1, 139, 112, -1, 112, + -1, 140, 112, -1, 112, -1, 141, 142, -1, 142, + -1, 93, -1, 94, -1, 95, -1, 143, 6, -1, + 6, -1, 144, 6, -1, 6, -1, 145, 6, -1, + 6, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 168, 168, 168, 171, 172, 175, 176, 177, 178, + 179, 180, 181, 182, 183, 184, 185, 186, 186, 187, + 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, 203, 204, 205, 208, 209, + 210, 211, 212, 215, 215, 218, 219, 222, 223, 226, + 227, 230, 230, 231, 232, 232, 233, 233, 234, 234, + 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, + 247, 250, 251, 252, 253, 256, 257, 258, 259, 262, + 263, 264, 265, 266, 267, 270, 271, 272, 273, 274, + 277, 278, 279, 280, 283, 284, 285, 286, 289, 290, + 291, 292, 293, 294, 295, 298, 299, 300, 301, 302, + 305, 306, 309, 310, 311, 312, 313, 314, 315, 316, + 317, 320, 321, 324, 325, 328, 329, 332, 333, 336, + 337, 340, 341, 344, 361, 362, 365, 366, 369, 370, + 373, 374, 377, 378, 381, 382, 383, 386, 387, 390, + 391, 394, 395 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "EOF_", "INT", "REAL", "STRING", + "DEBUG_", "ON_", "OFF_", "NRRD0001_", "NRRD0002_", "NRRD0003_", + "NRRD0004_", "NRRD0005_", "DATA_", "FILE_", "SPACE_", "UNITS_", + "DIMENSIONS_", "ORIGIN_", "DIRECTIONS_", "DIMENSION_", "TYPE_", + "SIGNED_", "UNSIGNED_", "CHAR_", "INT8_", "INT8_T_", "UCHAR_", "UINT8_", + "UINT8_T_", "SHORT_", "INT_", "INT16_", "INT16_T_", "USHORT_", "UINT16_", + "UINT16_T_", "INT32_", "INT32_T_", "UINT_", "UINT32_", "UINT32_T_", + "LONG_", "LONGLONG_", "INT64_", "INT64_T_", "ULONGLONG_", "UINT64_", + "UINT64_T_", "FLOAT_", "DOUBLE_", "BLOCK_", "SIZE_", "BLOCKSIZE_", + "ENCODING_", "RAW_", "TXT_", "TEXT_", "ASCII_", "HEX_", "GZ_", "GZIP_", + "BZ2_", "BZIP2_", "ENDIAN_", "BIG_", "LITTLE_", "CONTENT_", "OLD_", + "MIN_", "OLDMIN_", "MAX_", "OLDMAX_", "SKIP_", "LINE_", "LINESKIP_", + "BYTE_", "BYTESKIP_", "NUMBER_", "SAMPLE_", "SAMPLEUNITS_", "SIZES_", + "SPACINGS_", "THICKNESSES_", "AXIS_", "MINS_", "AXISMINS_", "MAXS_", + "AXISMAXS_", "CENTERS_", "CENTERINGS_", "CELL_", "NODE_", "NONE_", + "LABELS_", "KINDS_", "DOMAINS_", "':'", "'#'", "'\\n'", "$accept", + "start", "@1", "commands", "command", "@2", "magic", "comment", "@3", + "terminator", "numeric", "debug", "space", "@4", "@5", "@6", "@7", + "type", "char", "uchar", "short", "ushort", "int", "uint", "long", + "ulong", "block", "encoding", "endian", "oldmin", "oldmax", "lineskip", + "byteskip", "sizes", "size", "spacings", "thicknesses", "axismins", + "axismaxs", "centers", "center", "labels", "units", "kinds", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348, 349, 350, 351, 352, 353, 58, + 35, 10 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 102, 104, 103, 105, 105, 106, 106, 106, 106, + 106, 106, 106, 106, 106, 106, 106, 107, 106, 106, + 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, + 106, 106, 106, 106, 106, 106, 106, 106, 108, 108, + 108, 108, 108, 110, 109, 111, 111, 112, 112, 113, + 113, 115, 114, 114, 116, 114, 117, 114, 118, 114, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 120, 120, 120, 120, 121, 121, 121, 121, 122, + 122, 122, 122, 122, 122, 123, 123, 123, 123, 123, + 124, 124, 124, 124, 125, 125, 125, 125, 126, 126, + 126, 126, 126, 126, 126, 127, 127, 127, 127, 127, + 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, + 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, + 134, 135, 135, 136, 137, 137, 138, 138, 139, 139, + 140, 140, 141, 141, 142, 142, 142, 143, 143, 144, + 144, 145, 145 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 2, 3, 2, 0, 2, 1, 1, + 4, 2, 3, 3, 1, 3, 3, 0, 4, 3, + 3, 1, 1, 1, 1, 3, 3, 3, 3, 4, + 3, 4, 3, 3, 3, 3, 3, 3, 1, 1, + 1, 1, 1, 0, 3, 1, 1, 1, 1, 1, + 1, 0, 3, 3, 0, 4, 0, 4, 0, 4, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, + 2, 2, 3, 1, 1, 1, 2, 3, 1, 1, + 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, + 3, 3, 4, 1, 1, 1, 3, 4, 1, 1, + 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 4, 3, 4, 3, 4, 3, 4, + 3, 2, 1, 1, 2, 1, 2, 1, 2, 1, + 2, 1, 2, 1, 1, 1, 1, 2, 1, 2, + 1, 2, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 2, 0, 6, 1, 0, 38, 39, 40, 41, 42, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 43, 6, 0, 8, 9, 14, 21, 22, 23, 24, + 49, 50, 7, 0, 0, 0, 0, 0, 51, 11, + 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 46, 45, 5, 0, 54, 56, 58, 0, + 0, 150, 36, 12, 0, 0, 71, 73, 74, 75, + 77, 78, 79, 90, 83, 84, 85, 88, 89, 92, + 93, 94, 96, 97, 0, 98, 103, 104, 105, 108, + 109, 68, 69, 70, 13, 60, 61, 62, 63, 64, + 65, 66, 67, 0, 111, 112, 113, 114, 115, 116, + 117, 118, 119, 120, 15, 121, 122, 16, 0, 0, + 0, 48, 47, 19, 124, 20, 126, 0, 128, 0, + 130, 25, 133, 26, 132, 135, 27, 137, 28, 0, + 0, 139, 30, 141, 32, 144, 145, 146, 33, 143, + 34, 148, 35, 152, 37, 44, 4, 10, 0, 0, + 0, 53, 52, 149, 72, 81, 91, 0, 76, 86, + 95, 0, 80, 99, 110, 18, 123, 125, 127, 129, + 131, 134, 136, 29, 31, 138, 140, 142, 147, 151, + 55, 57, 59, 82, 101, 87, 106, 100, 102, 107 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 1, 2, 41, 42, 158, 43, 44, 90, 94, + 181, 52, 59, 100, 198, 199, 200, 134, 135, 136, + 137, 138, 139, 140, 141, 142, 45, 154, 157, 46, + 47, 48, 49, 173, 174, 176, 178, 182, 184, 188, + 189, 192, 102, 194 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -138 +static const yytype_int16 yypact[] = +{ + -138, 4, 145, -138, 79, -138, -138, -138, -138, -138, + 52, -13, -36, -28, -16, 31, -4, -3, -2, -1, + -25, 0, 2, 6, 8, 34, 12, 53, 16, 30, + 35, 37, 41, -37, 42, 43, 46, 49, 50, 51, + -138, 47, 3, -138, -138, -138, -138, -138, -138, -138, + -138, -138, -138, 62, 65, 66, 67, 70, -138, -138, + 116, 142, -8, 71, 147, 17, 24, -138, 72, 73, + 89, 89, 89, 89, 74, 170, 76, 172, 171, 174, + 89, 89, 80, 81, 89, 89, -81, -81, 175, 176, + 177, 3, -138, -138, -138, 178, -138, -138, -138, 181, + 180, -138, 182, -138, 23, 40, -138, -138, -138, -138, + -138, -138, 154, -138, -138, -138, -138, -138, -138, -138, + -138, -138, -138, -138, 146, -138, -138, -138, -138, -138, + -138, -138, -138, -138, -138, -138, -138, -138, -138, -138, + -138, -138, -138, 185, -138, -138, -138, -138, -138, -138, + -138, -138, -138, -138, -138, -138, -138, -138, 186, 89, + 89, -138, -138, -138, -138, -138, -138, 187, -138, 189, + -138, -138, -138, 174, -138, -138, 89, -138, 89, 89, + 89, -138, 89, -138, 89, -138, -138, -138, -81, -138, + -81, -138, 188, -138, 190, -138, -138, -138, 191, 193, + 196, -138, -138, -138, -138, 162, -138, 159, -138, 173, + -138, 160, -138, 179, -138, -138, -138, -138, -138, -138, + -138, -138, -138, 89, 89, -138, -138, -138, -138, -138, + -138, -138, -138, -138, 194, -138, 199, -138, -138, -138 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -138, -138, -138, -138, 164, -138, -138, -138, -138, 117, + -70, -138, -138, -138, -138, -138, -138, -138, -138, -138, + -138, -138, -138, -138, -138, -138, -138, -138, -138, -138, + -138, -138, -138, -138, 36, -138, -138, 28, 33, 123, + -137, -138, -138, -138 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -4 +static const yytype_int16 yytable[] = +{ + 163, 164, 165, 166, 3, 54, 92, 55, 56, 57, + 175, 177, 185, 186, 187, 183, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, + 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, + 128, 129, 130, 131, 132, 133, 68, -3, 69, 204, + 82, 227, 83, 227, 4, 205, 206, 5, 6, 7, + 8, 9, 10, 60, 11, 12, 208, 207, 53, 13, + 14, 61, 209, 210, 145, 146, 147, 148, 149, 150, + 151, 152, 153, 62, 211, 63, 58, 50, 51, 216, + 217, 155, 156, 161, 162, 64, 65, 66, 67, 70, + 15, 71, 16, 17, 93, 72, 221, 73, 222, 74, + 183, 75, 225, 18, 226, 77, 19, 20, 21, 22, + 23, 24, 101, 25, 26, 27, 28, 29, 76, 78, + 30, 31, 32, 33, 79, 34, 80, 35, 36, 37, + 81, 84, 85, 38, 39, 86, 103, 40, 87, 88, + 89, 144, 4, 225, 226, 5, 6, 7, 8, 9, + 10, 95, 11, 12, 96, 97, 98, 13, 14, 99, + 143, 159, 160, 167, 168, 169, 170, 171, 172, 179, + 180, 191, 193, 195, 197, 201, 202, 212, 203, 214, + 213, 218, 215, 219, 228, 233, 229, 230, 15, 231, + 16, 17, 232, 234, 236, 91, 235, 223, 196, 220, + 190, 18, 237, 224, 19, 20, 21, 22, 23, 24, + 0, 25, 26, 27, 28, 29, 0, 238, 30, 31, + 32, 33, 239, 34, 0, 35, 36, 37, 0, 0, + 0, 38, 39, 0, 0, 40 +}; + +static const yytype_int16 yycheck[] = +{ + 70, 71, 72, 73, 0, 18, 3, 20, 21, 22, + 80, 81, 93, 94, 95, 85, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 71, 0, 73, 26, + 87, 188, 89, 190, 7, 32, 33, 10, 11, 12, + 13, 14, 15, 99, 17, 18, 26, 44, 16, 22, + 23, 99, 32, 33, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 99, 44, 54, 99, 8, 9, 159, + 160, 67, 68, 4, 5, 99, 99, 99, 99, 99, + 53, 99, 55, 56, 101, 99, 176, 99, 178, 75, + 180, 99, 182, 66, 184, 99, 69, 70, 71, 72, + 73, 74, 6, 76, 77, 78, 79, 80, 75, 99, + 83, 84, 85, 86, 99, 88, 99, 90, 91, 92, + 99, 99, 99, 96, 97, 99, 4, 100, 99, 99, + 99, 4, 7, 223, 224, 10, 11, 12, 13, 14, + 15, 99, 17, 18, 99, 99, 99, 22, 23, 99, + 99, 99, 99, 99, 4, 99, 4, 6, 4, 99, + 99, 6, 6, 6, 6, 4, 6, 33, 6, 4, + 44, 4, 6, 4, 6, 33, 6, 6, 53, 6, + 55, 56, 6, 44, 44, 41, 33, 179, 91, 173, + 87, 66, 33, 180, 69, 70, 71, 72, 73, 74, + -1, 76, 77, 78, 79, 80, -1, 33, 83, 84, + 85, 86, 33, 88, -1, 90, 91, 92, -1, -1, + -1, 96, 97, -1, -1, 100 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 103, 104, 0, 7, 10, 11, 12, 13, 14, + 15, 17, 18, 22, 23, 53, 55, 56, 66, 69, + 70, 71, 72, 73, 74, 76, 77, 78, 79, 80, + 83, 84, 85, 86, 88, 90, 91, 92, 96, 97, + 100, 105, 106, 108, 109, 128, 131, 132, 133, 134, + 8, 9, 113, 16, 18, 20, 21, 22, 99, 114, + 99, 99, 99, 54, 99, 99, 99, 99, 71, 73, + 99, 99, 99, 99, 75, 99, 75, 99, 99, 99, + 99, 99, 87, 89, 99, 99, 99, 99, 99, 99, + 110, 106, 3, 101, 111, 99, 99, 99, 99, 99, + 115, 6, 144, 4, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 119, 120, 121, 122, 123, 124, + 125, 126, 127, 99, 4, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 129, 67, 68, 130, 107, 99, + 99, 4, 5, 112, 112, 112, 112, 99, 4, 99, + 4, 6, 4, 135, 136, 112, 137, 112, 138, 99, + 99, 112, 139, 112, 140, 93, 94, 95, 141, 142, + 141, 6, 143, 6, 145, 6, 111, 6, 116, 117, + 118, 4, 6, 6, 26, 32, 33, 44, 26, 32, + 33, 44, 33, 44, 4, 6, 112, 112, 4, 4, + 136, 112, 112, 139, 140, 112, 112, 142, 6, 6, + 6, 6, 6, 33, 44, 33, 44, 33, 33, 33 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (nrrd, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, nrrd, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, FitsFile* nrrd, nrrdFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, nrrd, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + FitsFile* nrrd; + nrrdFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (nrrd); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, FitsFile* nrrd, nrrdFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, nrrd, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + FitsFile* nrrd; + nrrdFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, nrrd, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, FitsFile* nrrd, nrrdFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, nrrd, ll) + YYSTYPE *yyvsp; + int yyrule; + FitsFile* nrrd; + nrrdFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , nrrd, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, nrrd, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, FitsFile* nrrd, nrrdFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, nrrd, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + FitsFile* nrrd; + nrrdFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (nrrd); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (FitsFile* nrrd, nrrdFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (FitsFile* nrrd, nrrdFlexLexer* ll) +#else +int +yyparse (nrrd, ll) + FitsFile* nrrd; + nrrdFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 168 "fitsy++/nrrdparser.Y" + {dim=0; nrrd->setpArch(FitsFile::BIG);;} + break; + + case 17: +#line 186 "fitsy++/nrrdparser.Y" + {DISCARD_(1);} + break; + + case 43: +#line 215 "fitsy++/nrrdparser.Y" + {DISCARD_(1);} + break; + + case 46: +#line 219 "fitsy++/nrrdparser.Y" + {YYACCEPT;;} + break; + + case 47: +#line 222 "fitsy++/nrrdparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 48: +#line 223 "fitsy++/nrrdparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].integer);;} + break; + + case 49: +#line 226 "fitsy++/nrrdparser.Y" + {yydebug=1;;} + break; + + case 50: +#line 227 "fitsy++/nrrdparser.Y" + {yydebug=0;;} + break; + + case 51: +#line 230 "fitsy++/nrrdparser.Y" + {DISCARD_(1);} + break; + + case 54: +#line 232 "fitsy++/nrrdparser.Y" + {DISCARD_(1);} + break; + + case 56: +#line 233 "fitsy++/nrrdparser.Y" + {DISCARD_(1);} + break; + + case 58: +#line 234 "fitsy++/nrrdparser.Y" + {DISCARD_(1);} + break; + + case 60: +#line 237 "fitsy++/nrrdparser.Y" + {nrrd->setpBitpix(8);;} + break; + + case 61: +#line 238 "fitsy++/nrrdparser.Y" + {nrrd->setpBitpix(8);;} + break; + + case 62: +#line 239 "fitsy++/nrrdparser.Y" + {nrrd->setpBitpix(16);;} + break; + + case 63: +#line 240 "fitsy++/nrrdparser.Y" + {nrrd->setpBitpix(16);;} + break; + + case 64: +#line 241 "fitsy++/nrrdparser.Y" + {nrrd->setpBitpix(32);;} + break; + + case 65: +#line 242 "fitsy++/nrrdparser.Y" + {nrrd->setpBitpix(32);;} + break; + + case 66: +#line 243 "fitsy++/nrrdparser.Y" + {nrrd->setpBitpix(64);;} + break; + + case 67: +#line 244 "fitsy++/nrrdparser.Y" + {nrrd->setpBitpix(64);;} + break; + + case 68: +#line 245 "fitsy++/nrrdparser.Y" + {nrrd->setpBitpix(-32);;} + break; + + case 69: +#line 246 "fitsy++/nrrdparser.Y" + {nrrd->setpBitpix(-64);;} + break; + + case 112: +#line 309 "fitsy++/nrrdparser.Y" + {nrrd->setpEncoding(FitsFile::RAW);;} + break; + + case 113: +#line 310 "fitsy++/nrrdparser.Y" + {nrrd->setpEncoding(FitsFile::ASCII);;} + break; + + case 114: +#line 311 "fitsy++/nrrdparser.Y" + {nrrd->setpEncoding(FitsFile::ASCII);;} + break; + + case 115: +#line 312 "fitsy++/nrrdparser.Y" + {nrrd->setpEncoding(FitsFile::ASCII);;} + break; + + case 116: +#line 313 "fitsy++/nrrdparser.Y" + {nrrd->setpEncoding(FitsFile::HEX);;} + break; + + case 117: +#line 314 "fitsy++/nrrdparser.Y" + {nrrd->setpEncoding(FitsFile::GZIP);;} + break; + + case 118: +#line 315 "fitsy++/nrrdparser.Y" + {nrrd->setpEncoding(FitsFile::GZIP);;} + break; + + case 119: +#line 316 "fitsy++/nrrdparser.Y" + {nrrd->setpEncoding(FitsFile::BZ2);;} + break; + + case 120: +#line 317 "fitsy++/nrrdparser.Y" + {nrrd->setpEncoding(FitsFile::BZ2);;} + break; + + case 121: +#line 320 "fitsy++/nrrdparser.Y" + {nrrd->setpArch(FitsFile::BIG);;} + break; + + case 122: +#line 321 "fitsy++/nrrdparser.Y" + {nrrd->setpArch(FitsFile::LITTLE);;} + break; + + case 133: +#line 345 "fitsy++/nrrdparser.Y" + { + switch (dim) { + case 0: + nrrd->setpWidth((yyvsp[(1) - (1)].integer)); + break; + case 1: + nrrd->setpHeight((yyvsp[(1) - (1)].integer)); + break; + case 2: + nrrd->setpDepth((yyvsp[(1) - (1)].integer)); + break; + } + dim++; + ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1981 "fitsy++/nrrdparser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (nrrd, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (nrrd, ll, yymsg); + } + else + { + yyerror (nrrd, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, nrrd, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, nrrd, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (nrrd, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, nrrd, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, nrrd, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 398 "fitsy++/nrrdparser.Y" + + diff --git a/tksao/fitsy++/nrrdparser.H b/tksao/fitsy++/nrrdparser.H new file mode 100644 index 0000000..7495805 --- /dev/null +++ b/tksao/fitsy++/nrrdparser.H @@ -0,0 +1,259 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + EOF_ = 258, + INT = 259, + REAL = 260, + STRING = 261, + DEBUG_ = 262, + ON_ = 263, + OFF_ = 264, + NRRD0001_ = 265, + NRRD0002_ = 266, + NRRD0003_ = 267, + NRRD0004_ = 268, + NRRD0005_ = 269, + DATA_ = 270, + FILE_ = 271, + SPACE_ = 272, + UNITS_ = 273, + DIMENSIONS_ = 274, + ORIGIN_ = 275, + DIRECTIONS_ = 276, + DIMENSION_ = 277, + TYPE_ = 278, + SIGNED_ = 279, + UNSIGNED_ = 280, + CHAR_ = 281, + INT8_ = 282, + INT8_T_ = 283, + UCHAR_ = 284, + UINT8_ = 285, + UINT8_T_ = 286, + SHORT_ = 287, + INT_ = 288, + INT16_ = 289, + INT16_T_ = 290, + USHORT_ = 291, + UINT16_ = 292, + UINT16_T_ = 293, + INT32_ = 294, + INT32_T_ = 295, + UINT_ = 296, + UINT32_ = 297, + UINT32_T_ = 298, + LONG_ = 299, + LONGLONG_ = 300, + INT64_ = 301, + INT64_T_ = 302, + ULONGLONG_ = 303, + UINT64_ = 304, + UINT64_T_ = 305, + FLOAT_ = 306, + DOUBLE_ = 307, + BLOCK_ = 308, + SIZE_ = 309, + BLOCKSIZE_ = 310, + ENCODING_ = 311, + RAW_ = 312, + TXT_ = 313, + TEXT_ = 314, + ASCII_ = 315, + HEX_ = 316, + GZ_ = 317, + GZIP_ = 318, + BZ2_ = 319, + BZIP2_ = 320, + ENDIAN_ = 321, + BIG_ = 322, + LITTLE_ = 323, + CONTENT_ = 324, + OLD_ = 325, + MIN_ = 326, + OLDMIN_ = 327, + MAX_ = 328, + OLDMAX_ = 329, + SKIP_ = 330, + LINE_ = 331, + LINESKIP_ = 332, + BYTE_ = 333, + BYTESKIP_ = 334, + NUMBER_ = 335, + SAMPLE_ = 336, + SAMPLEUNITS_ = 337, + SIZES_ = 338, + SPACINGS_ = 339, + THICKNESSES_ = 340, + AXIS_ = 341, + MINS_ = 342, + AXISMINS_ = 343, + MAXS_ = 344, + AXISMAXS_ = 345, + CENTERS_ = 346, + CENTERINGS_ = 347, + CELL_ = 348, + NODE_ = 349, + NONE_ = 350, + LABELS_ = 351, + KINDS_ = 352, + DOMAINS_ = 353 + }; +#endif +/* Tokens. */ +#define EOF_ 258 +#define INT 259 +#define REAL 260 +#define STRING 261 +#define DEBUG_ 262 +#define ON_ 263 +#define OFF_ 264 +#define NRRD0001_ 265 +#define NRRD0002_ 266 +#define NRRD0003_ 267 +#define NRRD0004_ 268 +#define NRRD0005_ 269 +#define DATA_ 270 +#define FILE_ 271 +#define SPACE_ 272 +#define UNITS_ 273 +#define DIMENSIONS_ 274 +#define ORIGIN_ 275 +#define DIRECTIONS_ 276 +#define DIMENSION_ 277 +#define TYPE_ 278 +#define SIGNED_ 279 +#define UNSIGNED_ 280 +#define CHAR_ 281 +#define INT8_ 282 +#define INT8_T_ 283 +#define UCHAR_ 284 +#define UINT8_ 285 +#define UINT8_T_ 286 +#define SHORT_ 287 +#define INT_ 288 +#define INT16_ 289 +#define INT16_T_ 290 +#define USHORT_ 291 +#define UINT16_ 292 +#define UINT16_T_ 293 +#define INT32_ 294 +#define INT32_T_ 295 +#define UINT_ 296 +#define UINT32_ 297 +#define UINT32_T_ 298 +#define LONG_ 299 +#define LONGLONG_ 300 +#define INT64_ 301 +#define INT64_T_ 302 +#define ULONGLONG_ 303 +#define UINT64_ 304 +#define UINT64_T_ 305 +#define FLOAT_ 306 +#define DOUBLE_ 307 +#define BLOCK_ 308 +#define SIZE_ 309 +#define BLOCKSIZE_ 310 +#define ENCODING_ 311 +#define RAW_ 312 +#define TXT_ 313 +#define TEXT_ 314 +#define ASCII_ 315 +#define HEX_ 316 +#define GZ_ 317 +#define GZIP_ 318 +#define BZ2_ 319 +#define BZIP2_ 320 +#define ENDIAN_ 321 +#define BIG_ 322 +#define LITTLE_ 323 +#define CONTENT_ 324 +#define OLD_ 325 +#define MIN_ 326 +#define OLDMIN_ 327 +#define MAX_ 328 +#define OLDMAX_ 329 +#define SKIP_ 330 +#define LINE_ 331 +#define LINESKIP_ 332 +#define BYTE_ 333 +#define BYTESKIP_ 334 +#define NUMBER_ 335 +#define SAMPLE_ 336 +#define SAMPLEUNITS_ 337 +#define SIZES_ 338 +#define SPACINGS_ 339 +#define THICKNESSES_ 340 +#define AXIS_ 341 +#define MINS_ 342 +#define AXISMINS_ 343 +#define MAXS_ 344 +#define AXISMAXS_ 345 +#define CENTERS_ 346 +#define CENTERINGS_ 347 +#define CELL_ 348 +#define NODE_ 349 +#define NONE_ 350 +#define LABELS_ 351 +#define KINDS_ 352 +#define DOMAINS_ 353 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 29 "fitsy++/nrrdparser.Y" +{ +#define NRRDPARSERSIZE 256 + float real; + int integer; + char str[NRRDPARSERSIZE]; +} +/* Line 1529 of yacc.c. */ +#line 252 "fitsy++/nrrdparser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/fitsy++/nrrdparser.Y b/tksao/fitsy++/nrrdparser.Y new file mode 100644 index 0000000..ff8a82a --- /dev/null +++ b/tksao/fitsy++/nrrdparser.Y @@ -0,0 +1,398 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {FitsFile* nrrd} +%lex-param {nrrdFlexLexer* ll} +%parse-param {nrrdFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#define DISCARD_(x) {yyclearin; nrrdDiscard(x);} + +#include "file.h" + +#undef yyFlexLexer +#define yyFlexLexer nrrdFlexLexer +#include + +extern int nrrdlex(void*, nrrdFlexLexer*); +extern void nrrderror(FitsFile*, nrrdFlexLexer*, const char*); +extern void nrrdDiscard(int); + +int dim; + +%} + +%union { +#define NRRDPARSERSIZE 256 + float real; + int integer; + char str[NRRDPARSERSIZE]; +} + +%type numeric + + // Basic +%token EOF_ +%token INT +%token REAL +%token STRING + +%token DEBUG_ +%token ON_ +%token OFF_ + + // Magic +%token NRRD0001_ +%token NRRD0002_ +%token NRRD0003_ +%token NRRD0004_ +%token NRRD0005_ + + // 3. Headers +%token DATA_ +%token FILE_ + + // 4. Space +%token SPACE_ +%token UNITS_ +%token DIMENSIONS_ +%token ORIGIN_ +%token DIRECTIONS_ + + // 5.1 Dimension +%token DIMENSION_ + + // 5.2 Type +%token TYPE_ +%token SIGNED_ +%token UNSIGNED_ +%token CHAR_ +%token INT8_ +%token INT8_T_ +%token UCHAR_ +%token UINT8_ +%token UINT8_T_ +%token SHORT_ +%token INT_ +%token INT16_ +%token INT16_T_ +%token USHORT_ +%token UINT16_ +%token UINT16_T_ +%token INT32_ +%token INT32_T_ +%token UINT_ +%token UINT32_ +%token UINT32_T_ +%token LONG_ +%token LONGLONG_ +%token INT64_ +%token INT64_T_ +%token ULONGLONG_ +%token UINT64_ +%token UINT64_T_ +%token FLOAT_ +%token DOUBLE_ + + // 5.3 Block +%token BLOCK_ +%token SIZE_ +%token BLOCKSIZE_ + + // 5.4 ENCODING +%token ENCODING_ +%token RAW_ +%token TXT_ +%token TEXT_ +%token ASCII_ +%token HEX_ +%token GZ_ +%token GZIP_ +%token BZ2_ +%token BZIP2_ + + // 5.5 Endian +%token ENDIAN_ +%token BIG_ +%token LITTLE_ + + // 5.6 Content +%token CONTENT_ + + // 5.7 MinMax +%token OLD_ +%token MIN_ +%token OLDMIN_ +%token MAX_ +%token OLDMAX_ + + // 5.8 Skip +%token SKIP_ +%token LINE_ +%token LINESKIP_ +%token BYTE_ +%token BYTESKIP_ + + // 5.9 Number +%token NUMBER_ + + // 5.10 Sample +%token SAMPLE_ +%token SAMPLEUNITS_ + + // 6 Per Axis + +%token SIZES_ +%token SPACINGS_ +%token THICKNESSES_ +%token AXIS_ +%token MINS_ +%token AXISMINS_ +%token MAXS_ +%token AXISMAXS_ +%token CENTERS_ +%token CENTERINGS_ +%token CELL_ +%token NODE_ +%token NONE_ +%token LABELS_ +%token KINDS_ +%token DOMAINS_ + +%% + +start : {dim=0; nrrd->setpArch(FitsFile::BIG);} commands + ; + +commands: commands command terminator + | command terminator + ; + +command : /* empty */ + | DEBUG_ debug + | magic + | comment + | DATA_ FILE_ ':' STRING + | SPACE_ space + | DIMENSION_ ':' INT + | TYPE_ ':' type + | block + | ENCODING_ ':' encoding + | ENDIAN_ ':' endian + | CONTENT_ ':' {DISCARD_(1)} STRING + | MIN_ ':' numeric + | MAX_ ':' numeric + | oldmin + | oldmax + | lineskip + | byteskip + | NUMBER_ ':' STRING + | SIZES_ ':' sizes + | SPACINGS_ ':' spacings + | THICKNESSES_ ':' thicknesses + | AXIS_ MINS_ ':' axismins + | AXISMINS_ ':' axismins + | AXIS_ MAXS_ ':' axismaxs + | AXISMAXS_ ':' axismaxs + | CENTERS_ ':' centers + | CENTERINGS_ ':' centers + | LABELS_ ':' labels + | UNITS_ ':' units + | KINDS_ ':' kinds + ; + +magic : NRRD0001_ + | NRRD0002_ + | NRRD0003_ + | NRRD0004_ + | NRRD0005_ + ; + +comment : '#' {DISCARD_(1)} STRING + ; + +terminator: '\n' + | EOF_ {YYACCEPT;} + ; + +numeric : REAL {$$=$1;} + | INT {$$=$1;} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + ; + +space : ':' {DISCARD_(1)} STRING + | DIMENSION_ ':' INT + | UNITS_ ':' {DISCARD_(1)} STRING + | ORIGIN_ ':' {DISCARD_(1)} STRING + | DIRECTIONS_ ':' {DISCARD_(1)} STRING + ; + +type : char {nrrd->setpBitpix(8);} + | uchar {nrrd->setpBitpix(8);} + | short {nrrd->setpBitpix(16);} + | ushort {nrrd->setpBitpix(16);} + | int {nrrd->setpBitpix(32);} + | uint {nrrd->setpBitpix(32);} + | long {nrrd->setpBitpix(64);} + | ulong {nrrd->setpBitpix(64);} + | FLOAT_ {nrrd->setpBitpix(-32);} + | DOUBLE_ {nrrd->setpBitpix(-64);} + | BLOCK_ + ; + +char : CHAR_ + | SIGNED_ CHAR_ + | INT8_ + | INT8_T_ + ; + +uchar : UCHAR_ + | UNSIGNED_ CHAR_ + | UINT8_ + | UINT8_T_ + ; + +short : SHORT_ + | SHORT_ INT_ + | SIGNED_ SHORT_ + | SIGNED_ SHORT_ INT_ + | INT16_ + | INT16_T_ + ; + +ushort : USHORT_ + | UNSIGNED_ SHORT_ + | UNSIGNED_ SHORT_ INT_ + | UINT16_ + | UINT16_T_ + ; + +int : INT_ + | SIGNED_ INT_ + | INT32_ + | INT32_T_ + ; + +uint : UINT_ + | UNSIGNED_ INT_ + | UINT32_ + | UINT32_T_ + ; + +long : LONGLONG_ + | LONG_ LONG_ + | LONG_ LONG_ INT_ + | SIGNED_ LONG_ LONG_ + | SIGNED_ LONG_ LONG_ INT_ + | INT64_ + | INT64_T_ + ; + +ulong : ULONGLONG_ + | UNSIGNED_ LONG_ LONG_ + | UNSIGNED_ LONG_ LONG_ INT_ + | UINT64_ + | UINT64_T_ + ; + +block : BLOCK_ SIZE_ ':' INT + | BLOCKSIZE_ ':' INT + ; + +encoding : RAW_ {nrrd->setpEncoding(FitsFile::RAW);} + | TXT_ {nrrd->setpEncoding(FitsFile::ASCII);} + | TEXT_ {nrrd->setpEncoding(FitsFile::ASCII);} + | ASCII_ {nrrd->setpEncoding(FitsFile::ASCII);} + | HEX_ {nrrd->setpEncoding(FitsFile::HEX);} + | GZ_ {nrrd->setpEncoding(FitsFile::GZIP);} + | GZIP_ {nrrd->setpEncoding(FitsFile::GZIP);} + | BZ2_ {nrrd->setpEncoding(FitsFile::BZ2);} + | BZIP2_ {nrrd->setpEncoding(FitsFile::BZ2);} + ; + +endian : BIG_ {nrrd->setpArch(FitsFile::BIG);} + | LITTLE_ {nrrd->setpArch(FitsFile::LITTLE);} + ; + +oldmin : OLD_ MIN_ ':' numeric + | OLDMIN_ ':' numeric + ; + +oldmax : OLD_ MAX_ ':' numeric + | OLDMAX_ ':' numeric + ; + +lineskip : LINE_ SKIP_ ':' INT + | LINESKIP_ ':' INT + ; + +byteskip : BYTE_ SKIP_ ':' INT + | BYTESKIP_ ':' INT + ; + +sizes : sizes size + | size + ; + +size : INT + { + switch (dim) { + case 0: + nrrd->setpWidth($1); + break; + case 1: + nrrd->setpHeight($1); + break; + case 2: + nrrd->setpDepth($1); + break; + } + dim++; + } + ; + +spacings : spacings numeric + | numeric + ; + +thicknesses : thicknesses numeric + | numeric + ; + +axismins : axismins numeric + | numeric + ; + +axismaxs : axismaxs numeric + | numeric + ; + +centers : centers center + | center + ; + +center : CELL_ + | NODE_ + | NONE_ + ; + +labels : labels STRING + | STRING + ; + +units : units STRING + | STRING + ; + +kinds : kinds STRING + | STRING + ; + +%% diff --git a/tksao/fitsy++/order.C b/tksao/fitsy++/order.C new file mode 100644 index 0000000..f9eed55 --- /dev/null +++ b/tksao/fitsy++/order.C @@ -0,0 +1,267 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include +using namespace std; + +#include "order.h" + +FitsOrder::FitsOrder(FitsFile* fits, FitsHead* hdr, char* data, size_t sz) +{ + head_ = hdr; + data_ = data; + dataSize_ = sz; + + primary_ = fits->primary(); + ext_ = fits->ext(); + inherit_ = fits->inherit(); + byteswap_ = fits->byteswap(); + endian_ = fits->endian(); + + // just to make sure + head_->updateHDU(); + + valid_ = 1; +} + +FitsOrder::~FitsOrder() +{ + if (data_) + delete [] (char*)data_; +} + + +FitsOrderNext::FitsOrderNext(FitsFile* prev) +{ + primary_ = prev->primary(); + managePrimary_ = 0; + + head_ = prev->head(); + manageHead_ = 0; + + FitsImageHDU* hdu = (FitsImageHDU*)head_->hdu(); + data_ = (char*)prev->data() + hdu->imgbytes(); + dataSize_ = 0; + dataSkip_ = 0; + + ext_ = prev->ext(); + inherit_ = prev->inherit(); + byteswap_ = prev->byteswap(); + endian_ = prev->endian(); + valid_ = 1; + + return; +} + +/* +FitsOrder::FitsOrder(FitsFile* fits, int order) +{ + FitsHead* src = fits->head(); + + width_ = src->naxis(0); + height_ = src->naxis(1); + depth_ = src->naxis(2); + if (width_<1) + width_ = 1; + if (height_<1) + height_ = 1; + if (depth_<1) + depth_=1; + size_ = (size_t)width_*height_*depth_; + + primary_ = fits->primary(); + ext_ = fits->ext(); + inherit_ = fits->inherit(); + byteswap_ = fits->byteswap(); + endian_ = fits->endian(); + + bitpix_ = src->hdu()->bitpix(); + switch (bitpix_) { + case 8: + if (!(data_ = new char[size_])) + return; + dataSize_ = size_*sizeof(char); + pixelSize_ = 1; + break; + case 16: + if (!(data_ = new short[size_])) + return; + dataSize_ = size_*sizeof(short); + pixelSize_ = 2; + break; + case -16: + if (!(data_ = new unsigned short[size_])) + return; + dataSize_ = size_*sizeof(unsigned short); + pixelSize_ = 2; + break; + case 32: + if (!(data_ = new int[size_])) + return; + dataSize_ = size_*sizeof(int); + pixelSize_ = 4; + break; + case -32: + if (!(data_ = new float[size_])) + return; + dataSize_ = size_*sizeof(float); + pixelSize_ = 4; + break; + case 64: + if (!(data_ = new long long[size_])) + return; + dataSize_ = size_*sizeof(long long); + pixelSize_ = 8; + break; + case -64: + if (!(data_ = new double[size_])) + return; + dataSize_ = size_*sizeof(double); + pixelSize_ = 8; + break; + } + dataSkip_ = 0; + memset(data_, 0, dataSize_); + + initHeader(fits, order); + reorder(fits, order); + + // made it this far, must be valid + valid_ = 1; +} + +FitsOrder::~FitsOrder() +{ + if (data_) + delete [] (char*)data_; +} + +void FitsOrder::initHeader(FitsFile* fits, int order) +{ + head_ = new FitsHead(*(fits->head())); + + // NAXIS + int a1 = head_->getInteger("NAXIS1",1); + int a2 = head_->getInteger("NAXIS2",1); + int a3 = head_->getInteger("NAXIS3",1); + int n1,n2,n3; + + switch (order) { + case 123: + n1=a1; + n2=a2; + n3=a3; + break; + case 132: + n1=a1; + n2=a3; + n3=a2; + break; + case 213: + n1=a2; + n2=a1; + n3=a3; + break; + case 231: + n1=a2; + n2=a3; + n3=a1; + break; + case 312: + n1=a3; + n2=a1; + n3=a2; + break; + case 321: + n1=a3; + n2=a2; + n3=a1; + break; + } + + head_->setInteger("NAXES", 3, ""); + head_->setInteger("NAXIS1", n1, ""); + head_->setInteger("NAXIS2", n2, ""); + head_->setInteger("NAXIS3", n3, ""); + + head_->updateHDU(); +} + +void FitsOrder::reorder(FitsFile* fits, int order) +{ + char* src = (char*)fits->data(); + char* dest = (char*)data_; + char* dptr = dest; + int s1 = pixelSize_; + int s2 = width_*pixelSize_; + int s3 = height_*width_*pixelSize_; + + switch (order) { + case 123: + // should not be used, but just in case + memcpy(dest, src, dataSize_); + break; + case 132: + for (int jj=0; jj + +#include "outchannel.h" + +OutFitsChannel::OutFitsChannel(Tcl_Interp* interp, const char* ch) +{ + int tclMode; + if ((ch_ = Tcl_GetChannel(interp, (char*)ch, &tclMode))) + valid_ = 1; +} + +int OutFitsChannel::write(char* where, size_t size) +{ + // size_t size is unsigned + long long ss =size; + size_t rr = 0; + int r = 0; + + do { + r = Tcl_Write(ch_, where+rr, (ss>B1MB) ? B1MB : ss); + ss -= r; + rr += r; + } while (r>0 && rr +#include "outfile.h" + +OutFitsFile::OutFitsFile(const char* fn) +{ + if ((fd_ = fopen(fn, "wb"))) + valid_ = 1; +} + +OutFitsFile::~OutFitsFile() +{ + if (fd_) + fclose(fd_); +} + +int OutFitsFile::write(char* where, size_t size) +{ + // size_t size is unsigned + long long ss =size; + size_t rr = 0; + int r = 0; + + do { + r = fwrite(where+rr, 1, (ss>B1MB) ? B1MB : ss, fd_); + ss -= r; + rr += r; + } while (r>0 && rrB1MB) ? B1MB : ss); + ss -= r; + rr += r; + } while (r>0 && rrB4KB) ? B4KB : ss; + + switch (bitpix) { + case 8: + memcpy(buf, where+rr, r); + break; + case 16: + case -16: + for (int ii=0; ii0 && rr +#include + +#include "file.h" + +OutFitsSocket::OutFitsSocket(int s) +{ + id_ = s; + valid_ = 1; +} + +int OutFitsSocket::write(char* where, size_t size) +{ + // size_t size is unsigned + long long ss = size; + size_t rr =0; + int r; + do { + r = (ss>B4KB) ? B4KB : ss; + send(id_, where+rr, r, 0); + if (r == -1) { + internalError("Fitsy++ outsocket write error"); + return -1; + } + ss -= r; + rr += r; + } while (r>0 && rrnext_in = NULL; + stream_->avail_in = 0; + stream_->next_out = NULL; + stream_->avail_out = 0; + + stream_->zalloc = NULL; + stream_->zfree = NULL; + stream_->opaque = NULL; + + if (deflateInit2(stream_, Z_DEFAULT_COMPRESSION, Z_DEFLATED, + -MAX_WBITS, 8, Z_DEFAULT_STRATEGY) != Z_OK) { + internalError("Fitsy++ outsocket deflateInit error"); + return; + } + + // dump simple header + unsigned char header[10] = + {0x1f,0x8b,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x03}; + send(id_, header, 10, 0); + + stream_->next_out = buf_; + stream_->avail_out = B4KB; + + valid_ = 1; +} + +OutFitsSocketGZ::~OutFitsSocketGZ() +{ + // flush any pending output + while (deflategz(Z_FINISH) == Z_OK); + + // output crc/length + putlong(crc_); + putlong(stream_->total_in); + + if (deflateEnd(stream_) != Z_OK) + internalError("Fitsy++ outsocket deflateEnd error"); + + if (stream_) + delete stream_; + + if (buf_) + delete [] buf_; +} + +int OutFitsSocketGZ::write(char* where, size_t size) +{ + stream_->next_in = (unsigned char*)where; + stream_->avail_in = size; + + if (DebugGZ) + cerr << "write " << size << endl; + + while (stream_->avail_in > 0 && deflategz(Z_NO_FLUSH) == Z_OK); + + // update crc + crc_ = crc32(crc_, (const Bytef *)where, size); + + return size - stream_->avail_in; +} + +int OutFitsSocketGZ::deflategz(int flush) +{ + int result = deflate(stream_, flush); + + switch (result) { + case Z_OK: + if (DebugGZ) + cerr << "deflate OK: avail_in " << stream_->avail_in + << " avail_out " << stream_->avail_out << endl; + break; + case Z_STREAM_END: + if (DebugGZ) + cerr << "deflate STRM_END: avail_in " << stream_->avail_in + << " avail_out " << stream_->avail_out << endl; + break; + default: + if (DebugGZ) + cerr << "deflate Error " << result << endl; + return result; + } + + if (stream_->avail_out == 0 || result != Z_OK) { + int s = B4KB - stream_->avail_out; + unsigned char* d = buf_; + + while (s>0) { + int r = send(id_, d, s, 0); + + if (r == -1) { + internalError("Fitsy++ outsocket deflate send error"); + return Z_ERRNO; + } + + if (DebugGZ) + cerr << "deflate send " << r << " out of " << s << endl; + + s -= r; + d += r; + } + + stream_->next_out = buf_; + stream_->avail_out = B4KB; + } + + return result; +} + +void OutFitsSocketGZ::putlong(unsigned long l) +{ + // dump in LSB order + for (int n = 0; n < 4; n++) { + unsigned char foo = (int)(l & 0xff); + send(id_, &foo, 1, 0); + l >>= 8; + } +} + +#else + +OutFitsSocket::OutFitsSocket(int s) +{ + id_ = s; + valid_ = 0; +} + +int OutFitsSocket::write(char* where, size_t size) +{ + return 0; +} + +OutFitsSocketGZ::OutFitsSocketGZ(int s) +{ + id_ = s; + valid_ = 0; +} + +OutFitsSocketGZ::~OutFitsSocketGZ() {} + +int OutFitsSocketGZ::write(char* where, size_t size) +{ + return 0; +} + +int OutFitsSocketGZ::deflategz(int flush) +{ + return 0; +} + +void OutFitsSocketGZ::putlong(unsigned long l) {} + +#endif diff --git a/tksao/fitsy++/outsocket.h b/tksao/fitsy++/outsocket.h new file mode 100644 index 0000000..b7f9b8f --- /dev/null +++ b/tksao/fitsy++/outsocket.h @@ -0,0 +1,38 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __outfitssocket_h__ +#define __outfitssocket_h__ + +#include "outfits.h" +#include "zlib.h" + +class OutFitsSocket : public virtual OutFitsStream { + private: + int id_; + + public: + OutFitsSocket(int s); + + int write(char*, size_t); +}; + +class OutFitsSocketGZ : public virtual OutFitsStream { + private: + int id_; + z_stream* stream_; + unsigned char* buf_; + unsigned long crc_; + + int deflategz(int); + void putlong(unsigned long); + + public: + OutFitsSocketGZ(int); + ~OutFitsSocketGZ(); + + int write(char*, size_t); +}; + +#endif diff --git a/tksao/fitsy++/parser.C b/tksao/fitsy++/parser.C new file mode 100644 index 0000000..0324dfa --- /dev/null +++ b/tksao/fitsy++/parser.C @@ -0,0 +1,2194 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse ffparse +#define yylex fflex +#define yyerror fferror +#define yylval fflval +#define yychar ffchar +#define yydebug ffdebug +#define yynerrs ffnerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + STRING = 259, + ARCH_ = 260, + ARRAY_ = 261, + BIG_ = 262, + BIGENDIAN_ = 263, + BIN_ = 264, + BINKEY_ = 265, + BINCOL_ = 266, + BITPIX_ = 267, + COL_ = 268, + DIM_ = 269, + DIMS_ = 270, + ECLIPTIC_ = 271, + ENDIAN_ = 272, + EQUATORIAL_ = 273, + GALACTIC_ = 274, + KEY_ = 275, + LAYOUT_ = 276, + LITTLE_ = 277, + LITTLEENDIAN_ = 278, + NESTED_ = 279, + NORTH_ = 280, + ORDER_ = 281, + QUAD_ = 282, + RING_ = 283, + SKIP_ = 284, + SOUTH_ = 285, + SYSTEM_ = 286, + UNKNOWN_ = 287, + XDIM_ = 288, + YDIM_ = 289, + ZDIM_ = 290 + }; +#endif +/* Tokens. */ +#define INT 258 +#define STRING 259 +#define ARCH_ 260 +#define ARRAY_ 261 +#define BIG_ 262 +#define BIGENDIAN_ 263 +#define BIN_ 264 +#define BINKEY_ 265 +#define BINCOL_ 266 +#define BITPIX_ 267 +#define COL_ 268 +#define DIM_ 269 +#define DIMS_ 270 +#define ECLIPTIC_ 271 +#define ENDIAN_ 272 +#define EQUATORIAL_ 273 +#define GALACTIC_ 274 +#define KEY_ 275 +#define LAYOUT_ 276 +#define LITTLE_ 277 +#define LITTLEENDIAN_ 278 +#define NESTED_ 279 +#define NORTH_ 280 +#define ORDER_ 281 +#define QUAD_ 282 +#define RING_ 283 +#define SKIP_ 284 +#define SOUTH_ 285 +#define SYSTEM_ 286 +#define UNKNOWN_ 287 +#define XDIM_ 288 +#define YDIM_ 289 +#define ZDIM_ 290 + + + + +/* Copy the first part of user declarations. */ +#line 10 "fitsy++/parser.Y" + +#define YYDEBUG 1 + +#define GOTOFILT(x) {yyclearin; ffFilter(x);} +#define GOTOARR(x) {yyclearin; ffArray(x);} + +#include "file.h" +#include "hpx.h" + +#undef yyFlexLexer +#define yyFlexLexer ffFlexLexer +#include + +extern int fflex(void*, ffFlexLexer*); +extern void fferror(FitsFile*, ffFlexLexer*, const char*); + +char ff_filter[512]; +extern void ffFilter(int); +extern void ffArray(int); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 32 "fitsy++/parser.Y" +{ + float real; + int integer; + char str[256]; + void* ptr; +} +/* Line 193 of yacc.c. */ +#line 203 "fitsy++/parser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 216 "fitsy++/parser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 6 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 250 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 56 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 34 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 121 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 203 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 290 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 38, 39, 45, 2, 40, 2, 55, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 43, 2, + 2, 46, 2, 2, 44, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 42, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 36, 2, 37, 2, 2, 2, 2, 47, 2, + 54, 2, 53, 2, 2, 50, 2, 2, 51, 2, + 2, 2, 41, 2, 52, 48, 2, 49, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 5, 8, 12, 15, 21, 25, 30, + 35, 38, 42, 46, 52, 56, 61, 66, 69, 73, + 77, 83, 86, 90, 94, 95, 104, 105, 109, 110, + 112, 116, 120, 123, 126, 131, 135, 141, 147, 155, + 159, 161, 165, 169, 175, 176, 178, 180, 184, 188, + 190, 194, 198, 200, 206, 210, 214, 216, 218, 222, + 226, 229, 231, 233, 235, 237, 243, 247, 255, 261, + 265, 267, 271, 275, 277, 281, 285, 289, 293, 297, + 301, 305, 309, 313, 315, 317, 319, 321, 323, 328, + 330, 332, 334, 336, 338, 340, 342, 344, 346, 350, + 356, 357, 360, 361, 363, 365, 369, 373, 375, 379, + 383, 387, 391, 395, 397, 399, 401, 403, 405, 407, + 409, 411 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 57, 0, -1, 60, -1, 60, 61, -1, 60, 61, + 63, -1, 60, 63, -1, 60, 36, 62, 64, 37, + -1, 60, 61, 71, -1, 60, 61, 71, 63, -1, + 60, 61, 63, 71, -1, 60, 71, -1, 60, 71, + 63, -1, 60, 63, 71, -1, 60, 36, 62, 72, + 37, -1, 60, 61, 84, -1, 60, 61, 84, 63, + -1, 60, 61, 63, 84, -1, 60, 84, -1, 60, + 84, 63, -1, 60, 63, 84, -1, 60, 36, 62, + 84, 37, -1, 60, 75, -1, 60, 75, 63, -1, + 60, 63, 75, -1, -1, 60, 36, 6, 58, 38, + 79, 39, 37, -1, -1, 1, 59, 4, -1, -1, + 4, -1, 36, 4, 37, -1, 36, 3, 37, -1, + 4, 40, -1, 3, 40, -1, 36, 64, 65, 37, + -1, 66, 40, 67, -1, 66, 40, 67, 40, 70, + -1, 66, 40, 67, 40, 69, -1, 66, 40, 67, + 40, 70, 40, 69, -1, 66, 40, 70, -1, 68, + -1, 68, 40, 70, -1, 68, 40, 69, -1, 68, + 40, 70, 40, 69, -1, -1, 41, -1, 42, -1, + 3, 43, 3, -1, 3, 44, 3, -1, 45, -1, + 3, 43, 3, -1, 3, 44, 3, -1, 45, -1, + 3, 44, 3, 44, 3, -1, 3, 43, 3, -1, + 3, 44, 3, -1, 45, -1, 3, -1, 36, 72, + 37, -1, 73, 46, 74, -1, 73, 74, -1, 9, + -1, 10, -1, 11, -1, 20, -1, 38, 4, 40, + 4, 39, -1, 4, 40, 4, -1, 38, 4, 40, + 4, 40, 4, 39, -1, 4, 40, 4, 40, 4, + -1, 38, 4, 39, -1, 4, -1, 36, 76, 37, + -1, 76, 40, 77, -1, 77, -1, 33, 46, 3, + -1, 34, 46, 3, -1, 35, 46, 3, -1, 14, + 46, 3, -1, 15, 46, 3, -1, 12, 46, 3, + -1, 29, 46, 3, -1, 5, 46, 78, -1, 17, + 46, 78, -1, 78, -1, 7, -1, 8, -1, 22, + -1, 23, -1, 80, 81, 82, 83, -1, 47, -1, + 48, -1, 49, -1, 50, -1, 51, -1, 52, -1, + 53, -1, 54, -1, 3, -1, 3, 55, 3, -1, + 3, 55, 3, 55, 3, -1, -1, 43, 3, -1, + -1, 51, -1, 47, -1, 36, 85, 37, -1, 85, + 40, 86, -1, 86, -1, 31, 46, 87, -1, 26, + 46, 88, -1, 21, 46, 89, -1, 13, 46, 3, + -1, 27, 46, 3, -1, 18, -1, 19, -1, 16, + -1, 32, -1, 28, -1, 24, -1, 18, -1, 25, + -1, 30, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 81, 81, 82, 83, 84, 85, 87, 88, 89, + 90, 91, 92, 93, 95, 96, 97, 98, 99, 100, + 101, 103, 104, 105, 106, 106, 108, 108, 112, 113, + 123, 124, 127, 128, 131, 133, 134, 135, 136, 137, + 138, 139, 140, 141, 144, 145, 146, 149, 156, 158, + 166, 168, 170, 173, 180, 182, 184, 187, 190, 192, + 193, 196, 197, 198, 199, 202, 203, 204, 205, 206, + 207, 210, 213, 214, 217, 218, 219, 220, 221, 222, + 223, 224, 225, 226, 229, 230, 231, 232, 235, 238, + 239, 240, 241, 242, 243, 244, 245, 248, 249, 250, + 254, 255, 258, 259, 260, 263, 266, 267, 270, 271, + 272, 273, 274, 277, 278, 279, 280, 283, 284, 287, + 288, 289 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "INT", "STRING", "ARCH_", "ARRAY_", + "BIG_", "BIGENDIAN_", "BIN_", "BINKEY_", "BINCOL_", "BITPIX_", "COL_", + "DIM_", "DIMS_", "ECLIPTIC_", "ENDIAN_", "EQUATORIAL_", "GALACTIC_", + "KEY_", "LAYOUT_", "LITTLE_", "LITTLEENDIAN_", "NESTED_", "NORTH_", + "ORDER_", "QUAD_", "RING_", "SKIP_", "SOUTH_", "SYSTEM_", "UNKNOWN_", + "XDIM_", "YDIM_", "ZDIM_", "'['", "']'", "'('", "')'", "','", "'p'", + "'P'", "':'", "'@'", "'*'", "'='", "'b'", "'s'", "'u'", "'i'", "'l'", + "'r'", "'f'", "'d'", "'.'", "$accept", "command", "@1", "@2", "filename", + "ext", "extb", "sect", "sectb", "physical", "rangex", "rangey", + "rangexy", "rangez", "block", "bin", "binb", "binword", "binkey", "arrs", + "arrsb", "arr", "endian", "array", "atype", "adims", "askip", "aendian", + "hpxs", "hpxsb", "hpx", "hpxSystem", "hpxOrder", "hpxLayout", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 91, 93, 40, 41, + 44, 112, 80, 58, 64, 42, 61, 98, 115, 117, + 105, 108, 114, 102, 100, 46 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 56, 57, 57, 57, 57, 57, 57, 57, 57, + 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, + 57, 57, 57, 57, 58, 57, 59, 57, 60, 60, + 61, 61, 62, 62, 63, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 65, 65, 65, 66, 66, 66, + 67, 67, 67, 68, 69, 69, 69, 70, 71, 72, + 72, 73, 73, 73, 73, 74, 74, 74, 74, 74, + 74, 75, 76, 76, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 78, 78, 78, 78, 79, 80, + 80, 80, 80, 80, 80, 80, 80, 81, 81, 81, + 82, 82, 83, 83, 83, 84, 85, 85, 86, 86, + 86, 86, 86, 87, 87, 87, 87, 88, 88, 89, + 89, 89 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 2, 3, 2, 5, 3, 4, 4, + 2, 3, 3, 5, 3, 4, 4, 2, 3, 3, + 5, 2, 3, 3, 0, 8, 0, 3, 0, 1, + 3, 3, 2, 2, 4, 3, 5, 5, 7, 3, + 1, 3, 3, 5, 0, 1, 1, 3, 3, 1, + 3, 3, 1, 5, 3, 3, 1, 1, 3, 3, + 2, 1, 1, 1, 1, 5, 3, 7, 5, 3, + 1, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 1, 1, 1, 1, 1, 4, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 3, 5, + 0, 2, 0, 1, 1, 3, 3, 1, 3, 3, + 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, + 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 26, 29, 0, 2, 0, 1, 0, 3, 5, + 10, 21, 17, 27, 0, 0, 0, 24, 84, 85, + 61, 62, 63, 0, 0, 0, 0, 0, 64, 0, + 86, 87, 0, 0, 0, 0, 0, 0, 0, 49, + 0, 44, 0, 40, 0, 0, 0, 73, 83, 0, + 107, 0, 4, 7, 14, 0, 12, 23, 19, 0, + 11, 22, 18, 31, 33, 0, 0, 30, 32, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, + 46, 0, 0, 0, 58, 70, 0, 0, 60, 71, + 0, 105, 0, 0, 9, 16, 8, 15, 47, 48, + 81, 0, 79, 111, 77, 78, 82, 119, 120, 121, + 110, 118, 117, 109, 112, 80, 115, 113, 114, 116, + 108, 74, 75, 76, 6, 13, 20, 34, 57, 52, + 35, 39, 57, 56, 42, 41, 0, 0, 59, 72, + 106, 0, 89, 90, 91, 92, 93, 94, 95, 96, + 0, 0, 0, 0, 0, 0, 0, 0, 66, 69, + 0, 53, 0, 97, 100, 50, 51, 37, 36, 54, + 55, 0, 43, 0, 0, 25, 0, 0, 102, 0, + 68, 65, 0, 98, 101, 104, 103, 88, 38, 0, + 0, 67, 99 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 3, 70, 5, 4, 8, 40, 9, 41, 91, + 42, 140, 43, 144, 141, 10, 44, 45, 98, 11, + 46, 47, 48, 160, 161, 174, 188, 197, 12, 49, + 50, 130, 123, 120 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -114 +static const yytype_int16 yypact[] = +{ + 60, -114, -114, 10, -9, 44, -114, 8, 27, 29, + 45, 45, 45, -114, 105, 49, 37, -114, -114, -114, + -114, -114, -114, 55, 68, 82, 92, 94, -114, 119, + -114, -114, 123, 132, 136, 137, 147, 148, 149, -114, + 59, 75, 52, 156, 160, 36, 110, -114, -114, 139, + -114, 46, 162, 45, 45, 98, -114, -114, -114, -1, + -114, -114, -114, -114, -114, 196, 197, -114, -114, 77, + 163, 199, 200, 201, 202, 77, 72, 102, 203, 204, + 152, 205, 206, 207, 79, 67, 174, 175, 176, -114, + -114, 177, 30, 33, -114, 178, 211, 20, -114, -114, + 129, -114, 67, 146, -114, -114, -114, -114, -114, 172, + -114, 138, -114, -114, -114, -114, -114, -114, -114, -114, + -114, -114, -114, -114, -114, -114, -114, -114, -114, -114, + -114, -114, -114, -114, -114, -114, -114, -114, 117, -114, + 179, -114, 131, -114, -114, 180, 213, 114, -114, -114, + -114, 218, -114, -114, -114, -114, -114, -114, -114, -114, + 183, 220, 221, 222, 33, 223, 224, 42, 188, -114, + 225, -114, 193, 181, 189, -114, -114, -114, 191, -114, + -114, 131, -114, 229, 141, -114, 231, 232, 88, 42, + -114, -114, 233, 184, -114, -114, -114, -114, -114, 208, + 235, -114, -114 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -114, -114, -114, -114, -114, -114, -114, -7, 209, -114, + -114, -114, -114, -113, -93, 0, 210, -114, 143, 234, + -114, 142, -43, -114, -114, -114, -114, -114, -2, -114, + 144, -114, -114, -114 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -29 +static const yytype_int16 yytable[] = +{ + 145, 52, 84, 60, 61, 62, 54, 58, 53, 56, + 6, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 95, 27, 110, 7, 28, 29, + 30, 31, 116, 138, 32, 33, 142, 34, 88, 35, + 95, 36, 37, 38, 39, 181, 106, 107, 13, 84, + 105, 177, 104, 39, 182, 20, 21, 22, 96, 24, + -28, 1, 84, 51, 2, 55, 28, 29, 20, 21, + 22, 178, 32, 33, 96, 139, 198, 35, 143, 28, + 24, 59, 97, 69, 18, 19, 67, 143, 29, 68, + 117, 39, 92, 32, 33, 85, -28, 118, 35, 30, + 31, 71, 119, 16, 39, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 72, 27, 89, 90, 28, 29, + 30, 31, 65, 66, 32, 33, 121, 34, 73, 35, + 122, 36, 37, 38, 16, 195, 18, 19, 74, 196, + 75, 23, 63, 25, 26, 64, 27, 99, 65, 66, + 100, 30, 31, 169, 170, 20, 21, 22, 34, 24, + 162, 163, 36, 37, 38, 76, 28, 29, 126, 77, + 127, 128, 32, 33, 165, 166, 101, 35, 78, 102, + 191, 192, 79, 80, 129, 152, 153, 154, 155, 156, + 157, 158, 159, 81, 82, 83, 93, 94, 103, 108, + 109, 111, 112, 113, 114, 115, 124, 125, 131, 132, + 133, 134, 135, 136, 137, 147, 151, 168, 146, 164, + 167, 171, 172, 173, 175, 176, 179, 180, 183, 184, + 185, 189, 187, 190, 193, 194, 186, 199, 202, 200, + 148, 0, 149, 57, 0, 0, 150, 201, 0, 86, + 87 +}; + +static const yytype_int16 yycheck[] = +{ + 93, 8, 3, 10, 11, 12, 8, 9, 8, 9, + 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 4, 17, 69, 36, 20, 21, + 22, 23, 75, 3, 26, 27, 3, 29, 40, 31, + 4, 33, 34, 35, 45, 3, 53, 54, 4, 3, + 52, 164, 52, 45, 167, 9, 10, 11, 38, 13, + 0, 1, 3, 36, 4, 36, 20, 21, 9, 10, + 11, 164, 26, 27, 38, 45, 189, 31, 45, 20, + 13, 36, 46, 46, 7, 8, 37, 45, 21, 40, + 18, 45, 40, 26, 27, 36, 36, 25, 31, 22, + 23, 46, 30, 5, 45, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 46, 17, 41, 42, 20, 21, + 22, 23, 43, 44, 26, 27, 24, 29, 46, 31, + 28, 33, 34, 35, 5, 47, 7, 8, 46, 51, + 46, 12, 37, 14, 15, 40, 17, 37, 43, 44, + 40, 22, 23, 39, 40, 9, 10, 11, 29, 13, + 43, 44, 33, 34, 35, 46, 20, 21, 16, 46, + 18, 19, 26, 27, 43, 44, 37, 31, 46, 40, + 39, 40, 46, 46, 32, 47, 48, 49, 50, 51, + 52, 53, 54, 46, 46, 46, 40, 37, 36, 3, + 3, 38, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 37, 37, 37, 37, 4, 44, 4, 40, 40, + 40, 3, 39, 3, 3, 3, 3, 3, 40, 4, + 37, 40, 43, 4, 3, 3, 55, 4, 3, 55, + 97, -1, 100, 9, -1, -1, 102, 39, -1, 40, + 40 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 1, 4, 57, 60, 59, 0, 36, 61, 63, + 71, 75, 84, 4, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 17, 20, 21, + 22, 23, 26, 27, 29, 31, 33, 34, 35, 45, + 62, 64, 66, 68, 72, 73, 76, 77, 78, 85, + 86, 36, 63, 71, 84, 36, 71, 75, 84, 36, + 63, 63, 63, 37, 40, 43, 44, 37, 40, 46, + 58, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 3, 36, 64, 72, 84, 41, + 42, 65, 40, 40, 37, 4, 38, 46, 74, 37, + 40, 37, 40, 36, 71, 84, 63, 63, 3, 3, + 78, 38, 3, 3, 3, 3, 78, 18, 25, 30, + 89, 24, 28, 88, 3, 3, 16, 18, 19, 32, + 87, 3, 3, 3, 37, 37, 37, 37, 3, 45, + 67, 70, 3, 45, 69, 70, 40, 4, 74, 77, + 86, 44, 47, 48, 49, 50, 51, 52, 53, 54, + 79, 80, 43, 44, 40, 43, 44, 40, 4, 39, + 40, 3, 39, 3, 81, 3, 3, 69, 70, 3, + 3, 3, 69, 40, 4, 37, 55, 43, 82, 40, + 4, 39, 40, 3, 3, 47, 51, 83, 69, 4, + 55, 39, 3 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (ff, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, ff, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, FitsFile* ff, ffFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, ff, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + FitsFile* ff; + ffFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (ff); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, FitsFile* ff, ffFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, ff, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + FitsFile* ff; + ffFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, ff, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, FitsFile* ff, ffFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, ff, ll) + YYSTYPE *yyvsp; + int yyrule; + FitsFile* ff; + ffFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , ff, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, ff, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, FitsFile* ff, ffFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, ff, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + FitsFile* ff; + ffFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (ff); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (FitsFile* ff, ffFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (FitsFile* ff, ffFlexLexer* ll) +#else +int +yyparse (ff, ll) + FitsFile* ff; + ffFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 24: +#line 106 "fitsy++/parser.Y" + {GOTOARR(0);} + break; + + case 26: +#line 108 "fitsy++/parser.Y" + {GOTOFILT(0);} + break; + + case 27: +#line 109 "fitsy++/parser.Y" + {ff->setValid(1);ff->setpFilter(ff_filter);;} + break; + + case 29: +#line 113 "fitsy++/parser.Y" + {ff->setpName((yyvsp[(1) - (1)].str));;} + break; + + case 30: +#line 123 "fitsy++/parser.Y" + {ff->setpExt((yyvsp[(2) - (3)].str));;} + break; + + case 31: +#line 124 "fitsy++/parser.Y" + {ff->setpIndex((yyvsp[(2) - (3)].integer));;} + break; + + case 32: +#line 127 "fitsy++/parser.Y" + {ff->setpExt((yyvsp[(1) - (2)].str));;} + break; + + case 33: +#line 128 "fitsy++/parser.Y" + {ff->setpIndex((yyvsp[(1) - (2)].integer));;} + break; + + case 44: +#line 144 "fitsy++/parser.Y" + {ff->setpcoord(0);;} + break; + + case 45: +#line 145 "fitsy++/parser.Y" + {ff->setpcoord(1);;} + break; + + case 46: +#line 146 "fitsy++/parser.Y" + {ff->setpcoord(1);;} + break; + + case 47: +#line 150 "fitsy++/parser.Y" + { + // this is not a mistake + // need to fool parser into processing "xy0:xy1,block" + ff->setpxmin((yyvsp[(1) - (3)].integer)); ff->setpxmax((yyvsp[(3) - (3)].integer)); ff->setpxvalid(1); + ff->setpymin((yyvsp[(1) - (3)].integer)); ff->setpymax((yyvsp[(3) - (3)].integer)); ff->setpyvalid(1); + ;} + break; + + case 48: +#line 157 "fitsy++/parser.Y" + {ff->setpxmin((yyvsp[(3) - (3)].integer)-(yyvsp[(1) - (3)].integer)/2); ff->setpxmax((yyvsp[(3) - (3)].integer)+(yyvsp[(1) - (3)].integer)/2); ff->setpxvalid(1);;} + break; + + case 49: +#line 159 "fitsy++/parser.Y" + { + // this is not a mistake + // need to fool parser into processing "*,block" + ff->setpxvalid(0); ff->setpyvalid(0); + ;} + break; + + case 50: +#line 167 "fitsy++/parser.Y" + {ff->setpymin((yyvsp[(1) - (3)].integer)); ff->setpymax((yyvsp[(3) - (3)].integer)); ff->setpyvalid(1);;} + break; + + case 51: +#line 169 "fitsy++/parser.Y" + {ff->setpymin((yyvsp[(3) - (3)].integer)-(yyvsp[(1) - (3)].integer)/2); ff->setpymax((yyvsp[(3) - (3)].integer)+(yyvsp[(1) - (3)].integer)/2); ff->setpyvalid(1);;} + break; + + case 52: +#line 170 "fitsy++/parser.Y" + {ff->setpyvalid(0);;} + break; + + case 53: +#line 174 "fitsy++/parser.Y" + { + ff->setpxmin((yyvsp[(3) - (5)].integer)-(yyvsp[(1) - (5)].integer)/2); ff->setpxmax((yyvsp[(3) - (5)].integer)+(yyvsp[(1) - (5)].integer)/2); ff->setpxvalid(1); + ff->setpymin((yyvsp[(5) - (5)].integer)-(yyvsp[(1) - (5)].integer)/2); ff->setpymax((yyvsp[(5) - (5)].integer)+(yyvsp[(1) - (5)].integer)/2); ff->setpyvalid(1); + ;} + break; + + case 54: +#line 181 "fitsy++/parser.Y" + {ff->setpzmin((yyvsp[(1) - (3)].integer)); ff->setpzmax((yyvsp[(3) - (3)].integer)); ff->setpzvalid(1);;} + break; + + case 55: +#line 183 "fitsy++/parser.Y" + {ff->setpzmin((yyvsp[(3) - (3)].integer)-(yyvsp[(1) - (3)].integer)/2); ff->setpzmax((yyvsp[(3) - (3)].integer)+(yyvsp[(1) - (3)].integer)/2); ff->setpzvalid(1);;} + break; + + case 56: +#line 184 "fitsy++/parser.Y" + {ff->setpzvalid(0);;} + break; + + case 57: +#line 187 "fitsy++/parser.Y" + {ff->setpblock((yyvsp[(1) - (1)].integer)); ff->setpbvalid(1);;} + break; + + case 65: +#line 202 "fitsy++/parser.Y" + {ff->setpBinXY((yyvsp[(2) - (5)].str),(yyvsp[(4) - (5)].str));;} + break; + + case 66: +#line 203 "fitsy++/parser.Y" + {ff->setpBinXY((yyvsp[(1) - (3)].str),(yyvsp[(3) - (3)].str));;} + break; + + case 67: +#line 204 "fitsy++/parser.Y" + {ff->setpBinXYZ((yyvsp[(2) - (7)].str),(yyvsp[(4) - (7)].str),(yyvsp[(6) - (7)].str));;} + break; + + case 68: +#line 205 "fitsy++/parser.Y" + {ff->setpBinXYZ((yyvsp[(1) - (5)].str),(yyvsp[(3) - (5)].str),(yyvsp[(5) - (5)].str));;} + break; + + case 69: +#line 206 "fitsy++/parser.Y" + {ff->setpBinZ((yyvsp[(2) - (3)].str));;} + break; + + case 70: +#line 207 "fitsy++/parser.Y" + {ff->setpBinZ((yyvsp[(1) - (1)].str));;} + break; + + case 74: +#line 217 "fitsy++/parser.Y" + {ff->setpWidth((yyvsp[(3) - (3)].integer));;} + break; + + case 75: +#line 218 "fitsy++/parser.Y" + {ff->setpHeight((yyvsp[(3) - (3)].integer));;} + break; + + case 76: +#line 219 "fitsy++/parser.Y" + {ff->setpDepth((yyvsp[(3) - (3)].integer));;} + break; + + case 77: +#line 220 "fitsy++/parser.Y" + {ff->setpWidth((yyvsp[(3) - (3)].integer));ff->setpHeight((yyvsp[(3) - (3)].integer));;} + break; + + case 78: +#line 221 "fitsy++/parser.Y" + {ff->setpWidth((yyvsp[(3) - (3)].integer));ff->setpHeight((yyvsp[(3) - (3)].integer));;} + break; + + case 79: +#line 222 "fitsy++/parser.Y" + {ff->setpBitpix((yyvsp[(3) - (3)].integer));;} + break; + + case 80: +#line 223 "fitsy++/parser.Y" + {ff->setpSkip((yyvsp[(3) - (3)].integer));;} + break; + + case 81: +#line 224 "fitsy++/parser.Y" + {ff->setpArch((FitsFile::ArchType)(yyvsp[(3) - (3)].integer));;} + break; + + case 82: +#line 225 "fitsy++/parser.Y" + {ff->setpArch((FitsFile::ArchType)(yyvsp[(3) - (3)].integer));;} + break; + + case 83: +#line 226 "fitsy++/parser.Y" + {ff->setpArch((FitsFile::ArchType)(yyvsp[(1) - (1)].integer));;} + break; + + case 84: +#line 229 "fitsy++/parser.Y" + {(yyval.integer) = FitsFile::BIG;;} + break; + + case 85: +#line 230 "fitsy++/parser.Y" + {(yyval.integer) = FitsFile::BIG;;} + break; + + case 86: +#line 231 "fitsy++/parser.Y" + {(yyval.integer) = FitsFile::LITTLE;;} + break; + + case 87: +#line 232 "fitsy++/parser.Y" + {(yyval.integer) = FitsFile::LITTLE;;} + break; + + case 89: +#line 238 "fitsy++/parser.Y" + {ff->setpBitpix(8);;} + break; + + case 90: +#line 239 "fitsy++/parser.Y" + {ff->setpBitpix(16);;} + break; + + case 91: +#line 240 "fitsy++/parser.Y" + {ff->setpBitpix(-16);;} + break; + + case 92: +#line 241 "fitsy++/parser.Y" + {ff->setpBitpix(32);;} + break; + + case 93: +#line 242 "fitsy++/parser.Y" + {ff->setpBitpix(64);;} + break; + + case 94: +#line 243 "fitsy++/parser.Y" + {ff->setpBitpix(-32);;} + break; + + case 95: +#line 244 "fitsy++/parser.Y" + {ff->setpBitpix(-32);;} + break; + + case 96: +#line 245 "fitsy++/parser.Y" + {ff->setpBitpix(-64);;} + break; + + case 97: +#line 248 "fitsy++/parser.Y" + {ff->setpWidth((yyvsp[(1) - (1)].integer));ff->setpHeight((yyvsp[(1) - (1)].integer));;} + break; + + case 98: +#line 249 "fitsy++/parser.Y" + {ff->setpWidth((yyvsp[(1) - (3)].integer));ff->setpHeight((yyvsp[(3) - (3)].integer));;} + break; + + case 99: +#line 251 "fitsy++/parser.Y" + {ff->setpWidth((yyvsp[(1) - (5)].integer));ff->setpHeight((yyvsp[(3) - (5)].integer));ff->setpDepth((yyvsp[(5) - (5)].integer));;} + break; + + case 101: +#line 255 "fitsy++/parser.Y" + {ff->setpSkip((yyvsp[(2) - (2)].integer));;} + break; + + case 103: +#line 259 "fitsy++/parser.Y" + {ff->setpArch(FitsFile::LITTLE);;} + break; + + case 104: +#line 260 "fitsy++/parser.Y" + {ff->setpArch(FitsFile::BIG);;} + break; + + case 111: +#line 273 "fitsy++/parser.Y" + {ff->setpHPXColumn((yyvsp[(3) - (3)].integer));;} + break; + + case 112: +#line 274 "fitsy++/parser.Y" + {ff->setpHPXQuad((yyvsp[(3) - (3)].integer));;} + break; + + case 113: +#line 277 "fitsy++/parser.Y" + {ff->setpHPXSystem(FitsHPX::EQU);;} + break; + + case 114: +#line 278 "fitsy++/parser.Y" + {ff->setpHPXSystem(FitsHPX::GAL);;} + break; + + case 115: +#line 279 "fitsy++/parser.Y" + {ff->setpHPXSystem(FitsHPX::ECL);;} + break; + + case 116: +#line 280 "fitsy++/parser.Y" + {ff->setpHPXSystem(FitsHPX::UNKNOWN);;} + break; + + case 117: +#line 283 "fitsy++/parser.Y" + {ff->setpHPXOrder(FitsHPX::RING);;} + break; + + case 118: +#line 284 "fitsy++/parser.Y" + {ff->setpHPXOrder(FitsHPX::NESTED);;} + break; + + case 119: +#line 287 "fitsy++/parser.Y" + {ff->setpHPXLayout(FitsHPX::EQUATOR);;} + break; + + case 120: +#line 288 "fitsy++/parser.Y" + {ff->setpHPXLayout(FitsHPX::NORTH);;} + break; + + case 121: +#line 289 "fitsy++/parser.Y" + {ff->setpHPXLayout(FitsHPX::SOUTH);;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1979 "fitsy++/parser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (ff, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (ff, ll, yymsg); + } + else + { + yyerror (ff, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, ff, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, ff, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (ff, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, ff, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, ff, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 292 "fitsy++/parser.Y" + + diff --git a/tksao/fitsy++/parser.H b/tksao/fitsy++/parser.H new file mode 100644 index 0000000..6149ddc --- /dev/null +++ b/tksao/fitsy++/parser.H @@ -0,0 +1,133 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + STRING = 259, + ARCH_ = 260, + ARRAY_ = 261, + BIG_ = 262, + BIGENDIAN_ = 263, + BIN_ = 264, + BINKEY_ = 265, + BINCOL_ = 266, + BITPIX_ = 267, + COL_ = 268, + DIM_ = 269, + DIMS_ = 270, + ECLIPTIC_ = 271, + ENDIAN_ = 272, + EQUATORIAL_ = 273, + GALACTIC_ = 274, + KEY_ = 275, + LAYOUT_ = 276, + LITTLE_ = 277, + LITTLEENDIAN_ = 278, + NESTED_ = 279, + NORTH_ = 280, + ORDER_ = 281, + QUAD_ = 282, + RING_ = 283, + SKIP_ = 284, + SOUTH_ = 285, + SYSTEM_ = 286, + UNKNOWN_ = 287, + XDIM_ = 288, + YDIM_ = 289, + ZDIM_ = 290 + }; +#endif +/* Tokens. */ +#define INT 258 +#define STRING 259 +#define ARCH_ 260 +#define ARRAY_ 261 +#define BIG_ 262 +#define BIGENDIAN_ 263 +#define BIN_ 264 +#define BINKEY_ 265 +#define BINCOL_ 266 +#define BITPIX_ 267 +#define COL_ 268 +#define DIM_ 269 +#define DIMS_ 270 +#define ECLIPTIC_ 271 +#define ENDIAN_ 272 +#define EQUATORIAL_ 273 +#define GALACTIC_ 274 +#define KEY_ 275 +#define LAYOUT_ 276 +#define LITTLE_ 277 +#define LITTLEENDIAN_ 278 +#define NESTED_ 279 +#define NORTH_ 280 +#define ORDER_ 281 +#define QUAD_ 282 +#define RING_ 283 +#define SKIP_ 284 +#define SOUTH_ 285 +#define SYSTEM_ 286 +#define UNKNOWN_ 287 +#define XDIM_ 288 +#define YDIM_ 289 +#define ZDIM_ 290 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 32 "fitsy++/parser.Y" +{ + float real; + int integer; + char str[256]; + void* ptr; +} +/* Line 1529 of yacc.c. */ +#line 126 "fitsy++/parser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/fitsy++/parser.Y b/tksao/fitsy++/parser.Y new file mode 100644 index 0000000..ac5f629 --- /dev/null +++ b/tksao/fitsy++/parser.Y @@ -0,0 +1,292 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {FitsFile* ff} +%lex-param {ffFlexLexer* ll} +%parse-param {ffFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#define GOTOFILT(x) {yyclearin; ffFilter(x);} +#define GOTOARR(x) {yyclearin; ffArray(x);} + +#include "file.h" +#include "hpx.h" + +#undef yyFlexLexer +#define yyFlexLexer ffFlexLexer +#include + +extern int fflex(void*, ffFlexLexer*); +extern void fferror(FitsFile*, ffFlexLexer*, const char*); + +char ff_filter[512]; +extern void ffFilter(int); +extern void ffArray(int); + +%} + +%union { + float real; + int integer; + char str[256]; + void* ptr; +} + +%type endian + +%token INT +%token STRING + +%token ARCH_ +%token ARRAY_ +%token BIG_ +%token BIGENDIAN_ +%token BIN_ +%token BINKEY_ +%token BINCOL_ +%token BITPIX_ +%token COL_ +%token DIM_ +%token DIMS_ +%token ECLIPTIC_ +%token ENDIAN_ +%token EQUATORIAL_ +%token GALACTIC_ +%token KEY_ +%token LAYOUT_ +%token LITTLE_ +%token LITTLEENDIAN_ +%token NESTED_ +%token NORTH_ +%token ORDER_ +%token QUAD_ +%token RING_ +%token SKIP_ +%token SOUTH_ +%token SYSTEM_ +%token UNKNOWN_ +%token XDIM_ +%token YDIM_ +%token ZDIM_ + +%% + + //start: {yydebug=1;} command + +// assume any error is the start of a filter +command : filename + | filename ext + | filename ext sect + | filename sect + | filename '[' extb sectb ']' + + | filename ext bin + | filename ext bin sect + | filename ext sect bin + | filename bin + | filename bin sect + | filename sect bin + | filename '[' extb binb ']' + + | filename ext hpxs + | filename ext hpxs sect + | filename ext sect hpxs + | filename hpxs + | filename hpxs sect + | filename sect hpxs + | filename '[' extb hpxs ']' + + | filename arrs + | filename arrs sect + | filename sect arrs + | filename '[' ARRAY_ {GOTOARR(0)} '(' array ')' ']' + + | error {GOTOFILT(0)} STRING + {ff->setValid(1);ff->setpFilter(ff_filter);} + ; + +filename : /* empty */ + | STRING {ff->setpName($1);} + ; + +// we must do it this way so that a bare filter will be accepted +//ext : '[' extb ']' +// ; +//extb : STRING {ff->setpExt($1);} +// | INT {ff->setpIndex($1);} +// ; + +ext : '[' STRING ']' {ff->setpExt($2);} + | '[' INT ']' {ff->setpIndex($2);} + ; + +extb : STRING ',' {ff->setpExt($1);} + | INT ',' {ff->setpIndex($1);} + ; + +sect : '[' sectb physical ']' + +sectb : rangex ',' rangey + | rangex ',' rangey ',' block + | rangex ',' rangey ',' rangez + | rangex ',' rangey ',' block ',' rangez + | rangex ',' block + | rangexy + | rangexy ',' block + | rangexy ',' rangez + | rangexy ',' block ',' rangez + ; + +physical : /* empty */ {ff->setpcoord(0);} + | 'p' {ff->setpcoord(1);} + | 'P' {ff->setpcoord(1);} + ; + +rangex : INT ':' INT + { + // this is not a mistake + // need to fool parser into processing "xy0:xy1,block" + ff->setpxmin($1); ff->setpxmax($3); ff->setpxvalid(1); + ff->setpymin($1); ff->setpymax($3); ff->setpyvalid(1); + } + | INT '@' INT + {ff->setpxmin($3-$1/2); ff->setpxmax($3+$1/2); ff->setpxvalid(1);} + | '*' + { + // this is not a mistake + // need to fool parser into processing "*,block" + ff->setpxvalid(0); ff->setpyvalid(0); + } + ; + +rangey : INT ':' INT + {ff->setpymin($1); ff->setpymax($3); ff->setpyvalid(1);} + | INT '@' INT + {ff->setpymin($3-$1/2); ff->setpymax($3+$1/2); ff->setpyvalid(1);} + | '*' {ff->setpyvalid(0);} + ; + +rangexy : INT '@' INT '@' INT + { + ff->setpxmin($3-$1/2); ff->setpxmax($3+$1/2); ff->setpxvalid(1); + ff->setpymin($5-$1/2); ff->setpymax($5+$1/2); ff->setpyvalid(1); + } + ; + +rangez : INT ':' INT + {ff->setpzmin($1); ff->setpzmax($3); ff->setpzvalid(1);} + | INT '@' INT + {ff->setpzmin($3-$1/2); ff->setpzmax($3+$1/2); ff->setpzvalid(1);} + | '*' {ff->setpzvalid(0);} + ; + +block : INT {ff->setpblock($1); ff->setpbvalid(1);} + ; + +bin : '[' binb ']' + +binb : binword '=' binkey + | binword binkey + ; + +binword : BIN_ + | BINKEY_ + | BINCOL_ + | KEY_ + ; + +binkey : '(' STRING ',' STRING ')' {ff->setpBinXY($2,$4);} + | STRING ',' STRING {ff->setpBinXY($1,$3);} + | '(' STRING ',' STRING ',' STRING ')' {ff->setpBinXYZ($2,$4,$6);} + | STRING ',' STRING ',' STRING {ff->setpBinXYZ($1,$3,$5);} + | '(' STRING ')' {ff->setpBinZ($2);} + | STRING {ff->setpBinZ($1);} + ; + +arrs : '[' arrsb ']' + ; + +arrsb : arrsb ',' arr + | arr + ; + +arr : XDIM_ '=' INT {ff->setpWidth($3);} + | YDIM_ '=' INT {ff->setpHeight($3);} + | ZDIM_ '=' INT {ff->setpDepth($3);} + | DIM_ '=' INT {ff->setpWidth($3);ff->setpHeight($3);} + | DIMS_ '=' INT {ff->setpWidth($3);ff->setpHeight($3);} + | BITPIX_ '=' INT {ff->setpBitpix($3);} + | SKIP_ '=' INT {ff->setpSkip($3);} + | ARCH_ '=' endian {ff->setpArch((FitsFile::ArchType)$3);} + | ENDIAN_ '=' endian {ff->setpArch((FitsFile::ArchType)$3);} + | endian {ff->setpArch((FitsFile::ArchType)$1);} + ; + +endian : BIG_ {$$ = FitsFile::BIG;} + | BIGENDIAN_ {$$ = FitsFile::BIG;} + | LITTLE_ {$$ = FitsFile::LITTLE;} + | LITTLEENDIAN_ {$$ = FitsFile::LITTLE;} + ; + +array : atype adims askip aendian + ; + +atype : 'b' {ff->setpBitpix(8);} + | 's' {ff->setpBitpix(16);} + | 'u' {ff->setpBitpix(-16);} + | 'i' {ff->setpBitpix(32);} + | 'l' {ff->setpBitpix(64);} + | 'r' {ff->setpBitpix(-32);} + | 'f' {ff->setpBitpix(-32);} + | 'd' {ff->setpBitpix(-64);} + ; + +adims : INT {ff->setpWidth($1);ff->setpHeight($1);} + | INT '.' INT {ff->setpWidth($1);ff->setpHeight($3);} + | INT '.' INT '.' INT + {ff->setpWidth($1);ff->setpHeight($3);ff->setpDepth($5);} + ; + +askip : /* empty */ + | ':' INT {ff->setpSkip($2);} + ; + +aendian : /* empty */ + | 'l' {ff->setpArch(FitsFile::LITTLE);} + | 'b' {ff->setpArch(FitsFile::BIG);} + ; + +hpxs : '[' hpxsb ']' + ; + +hpxsb : hpxsb ',' hpx + | hpx + ; + +hpx : SYSTEM_ '=' hpxSystem + | ORDER_ '=' hpxOrder + | LAYOUT_ '=' hpxLayout + | COL_ '=' INT {ff->setpHPXColumn($3);} + | QUAD_ '=' INT {ff->setpHPXQuad($3);} + ; + +hpxSystem : EQUATORIAL_ {ff->setpHPXSystem(FitsHPX::EQU);} + | GALACTIC_ {ff->setpHPXSystem(FitsHPX::GAL);} + | ECLIPTIC_ {ff->setpHPXSystem(FitsHPX::ECL);} + | UNKNOWN_ {ff->setpHPXSystem(FitsHPX::UNKNOWN);} + ; + +hpxOrder : RING_ {ff->setpHPXOrder(FitsHPX::RING);} + | NESTED_ {ff->setpHPXOrder(FitsHPX::NESTED);} + ; + +hpxLayout : EQUATORIAL_ {ff->setpHPXLayout(FitsHPX::EQUATOR);} + | NORTH_ {ff->setpHPXLayout(FitsHPX::NORTH);} + | SOUTH_ {ff->setpHPXLayout(FitsHPX::SOUTH);} + ; + +%% diff --git a/tksao/fitsy++/photo.C b/tksao/fitsy++/photo.C new file mode 100644 index 0000000..88592e4 --- /dev/null +++ b/tksao/fitsy++/photo.C @@ -0,0 +1,153 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include +using namespace std; + +#include + +#include "photo.h" + +FitsPhoto::FitsPhoto(Tcl_Interp* interp, const char* ph) +{ + // reset + valid_ = 0; + + if (*ph == '\0') { + Tcl_AppendResult(interp, "bad image name ", NULL); + return; + } + Tk_PhotoHandle photo = Tk_FindPhoto(interp, ph); + if (!photo) { + Tcl_AppendResult(interp, "bad image handle ", NULL); + return; + } + Tk_PhotoImageBlock block; + if (!Tk_PhotoGetImage(photo,&block)) { + Tcl_AppendResult(interp, "bad image block ", NULL); + return; + } + int width =0; + int height =0; + Tk_PhotoGetSize(photo, &width, &height); + + // new header + head_ = new FitsHead(width, height, 1, 8); + if (!head_->isValid()) + return; + + size_t size = (size_t)width*height; + unsigned char* dest = new unsigned char[size]; + data_ = dest; + + dataSize_ = size; + dataSkip_ = 0; + + unsigned char* src = block.pixelPtr; + for (int jj=height-1; jj>=0; jj--) + for (int ii=0; iiisValid()) + return; + + size_t size = (size_t)width*height*depth; + unsigned char* dest = new unsigned char[size]; + data_ = dest; + + dataSize_ = size; + dataSkip_ = 0; + + unsigned char* src = block.pixelPtr; + for (int kk=0; kk=0; jj--) { + for (int ii=0; iiprimary(); + managePrimary_ = 0; + + head_ = prev->head(); + manageHead_ = 0; + FitsImageHDU* hdu = (FitsImageHDU*)head_->hdu(); + + data_ = (char*)prev->data() + hdu->imgbytes(); + dataSize_ = 0; + dataSkip_ = 0; + + ext_ = prev->ext(); + inherit_ = head_->inherit(); + byteswap_ = prev->byteswap(); + endian_ = prev->endian(); + valid_ = 1; + + return; +} diff --git a/tksao/fitsy++/photo.h b/tksao/fitsy++/photo.h new file mode 100644 index 0000000..a225e6b --- /dev/null +++ b/tksao/fitsy++/photo.h @@ -0,0 +1,31 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsphoto_h__ +#define __fitsphoto_h__ + +#include + +#include "vector.h" +#include "file.h" + +class FitsPhoto : public FitsFile { + public: + FitsPhoto(Tcl_Interp* interp, const char*); + ~FitsPhoto(); +}; + +class FitsPhotoCube : public FitsFile { + public: + FitsPhotoCube(Tcl_Interp* interp, const char*); + ~FitsPhotoCube(); +}; + +class FitsPhotoCubeNext : public FitsFile { + public: + FitsPhotoCubeNext(FitsFile*); +}; + +#endif + diff --git a/tksao/fitsy++/plio.C b/tksao/fitsy++/plio.C new file mode 100644 index 0000000..93ee601 --- /dev/null +++ b/tksao/fitsy++/plio.C @@ -0,0 +1,90 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include +using namespace std; + +#include "plio.h" + +extern "C" { + int pl_l2pi(short *ll_src, int xs, int *px_dst, int npix); +} + +template FitsPliom::FitsPliom(FitsFile* fits) + : FitsCompressm(fits) +{ + FitsCompressm::uncompress(fits); +} + +template int FitsPliom::compressed(T* dest, char* sptr, + char* heap, + int kkstart, int kkstop, + int jjstart, int jjstop, + int iistart, int iistop) +{ + double zs = FitsCompressm::bscale_; + if (FitsCompressm::zscale_) + zs = FitsCompressm::zscale_->value(sptr,0); + + double zz = FitsCompressm::bzero_; + if (FitsCompressm::zzero_) + zz = FitsCompressm::zzero_->value(sptr,0); + + int blank = FitsCompressm::blank_; + if (FitsCompressm::zblank_) + blank = (int)FitsCompressm::zblank_->value(sptr,0); + + int icnt=0; + short* ibuf = (short*)((FitsBinColumnArray*)FitsCompressm::compress_)->get(heap, sptr, &icnt); + + // ibuf can be NULL + if (!ibuf || !icnt) + return 0; + + // swap if needed + if (FitsCompressm::byteswap_) + for (int ii=0; ii::tilesize_; + int* obuf = new int[ocnt]; + + int cc = pl_l2pi(ibuf, 1, obuf, ocnt); + if (cc != ocnt) { + internalError("Fitsy++ plio error"); + return 0; + } + + int ll=0; + for (int kk=kkstart; kk::width_*FitsCompressm::height_ + jj*FitsCompressm::width_ + ii] = FitsCompressm::getValue(obuf+ll,zs,zz,blank); + + if (obuf) + delete [] obuf; + + return 1; +} + +template class FitsPliom; +template class FitsPliom; +template class FitsPliom; +template class FitsPliom; +template class FitsPliom; +template class FitsPliom; +template class FitsPliom; + diff --git a/tksao/fitsy++/plio.h b/tksao/fitsy++/plio.h new file mode 100644 index 0000000..8602cbd --- /dev/null +++ b/tksao/fitsy++/plio.h @@ -0,0 +1,19 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsplio_h__ +#define __fitsplio_h__ + +#include "compress.h" + +template +class FitsPliom : public FitsCompressm { + private: + int compressed(T*, char*, char*, int, int, int, int, int, int); + + public: + FitsPliom(FitsFile*); +}; + +#endif diff --git a/tksao/fitsy++/pliocomp.c b/tksao/fitsy++/pliocomp.c new file mode 100644 index 0000000..7550ed6 --- /dev/null +++ b/tksao/fitsy++/pliocomp.c @@ -0,0 +1,331 @@ +/* stdlib is needed for the abs function */ +#include +/* + The following prototype code was provided by Doug Tody, NRAO, for + performing conversion between pixel arrays and line lists. The + compression technique is used in IRAF. +*/ +int pl_p2li (int *pxsrc, int xs, short *lldst, int npix); +int pl_l2pi (short *ll_src, int xs, int *px_dst, int npix); + + +/* + * PL_P2L -- Convert a pixel array to a line list. The length of the list is + * returned as the function value. + * + * Translated from the SPP version using xc -f, f2c. 8Sep99 DCT. + */ + +#ifndef min +#define min(a,b) (((a)<(b))?(a):(b)) +#endif +#ifndef max +#define max(a,b) (((a)>(b))?(a):(b)) +#endif + +int pl_p2li (int *pxsrc, int xs, short *lldst, int npix) +/* int *pxsrc; input pixel array */ +/* int xs; starting index in pxsrc (?) */ +/* short *lldst; encoded line list */ +/* int npix; number of pixels to convert */ +{ + /* System generated locals */ + int ret_val, i__1, i__2, i__3; + + /* Local variables */ + static int zero, v, x1, hi, ip, dv, xe, np, op, iz, nv, pv, nz; + + /* Parameter adjustments */ + --lldst; + --pxsrc; + + /* Function Body */ + if (! (npix <= 0)) { + goto L110; + } + ret_val = 0; + goto L100; +L110: + lldst[3] = -100; + lldst[2] = 7; + lldst[1] = 0; + lldst[6] = 0; + lldst[7] = 0; + xe = xs + npix - 1; + op = 8; + zero = 0; +/* Computing MAX */ + i__1 = zero, i__2 = pxsrc[xs]; + pv = max(i__1,i__2); + x1 = xs; + iz = xs; + hi = 1; + i__1 = xe; + for (ip = xs; ip <= i__1; ++ip) { + if (! (ip < xe)) { + goto L130; + } +/* Computing MAX */ + i__2 = zero, i__3 = pxsrc[ip + 1]; + nv = max(i__2,i__3); + if (! (nv == pv)) { + goto L140; + } + goto L120; +L140: + if (! (pv == 0)) { + goto L150; + } + pv = nv; + x1 = ip + 1; + goto L120; +L150: + goto L131; +L130: + if (! (pv == 0)) { + goto L160; + } + x1 = xe + 1; +L160: +L131: + np = ip - x1 + 1; + nz = x1 - iz; + if (! (pv > 0)) { + goto L170; + } + dv = pv - hi; + if (! (dv != 0)) { + goto L180; + } + hi = pv; + if (! (abs(dv) > 4095)) { + goto L190; + } + lldst[op] = (short) ((pv & 4095) + 4096); + ++op; + lldst[op] = (short) (pv / 4096); + ++op; + goto L191; +L190: + if (! (dv < 0)) { + goto L200; + } + lldst[op] = (short) (-dv + 12288); + goto L201; +L200: + lldst[op] = (short) (dv + 8192); +L201: + ++op; + if (! (np == 1 && nz == 0)) { + goto L210; + } + v = lldst[op - 1]; + lldst[op - 1] = (short) (v | 16384); + goto L91; +L210: +L191: +L180: +L170: + if (! (nz > 0)) { + goto L220; + } +L230: + if (! (nz > 0)) { + goto L232; + } + lldst[op] = (short) min(4095,nz); + ++op; +/* L231: */ + nz += -4095; + goto L230; +L232: + if (! (np == 1 && pv > 0)) { + goto L240; + } + lldst[op - 1] = (short) (lldst[op - 1] + 20481); + goto L91; +L240: +L220: +L250: + if (! (np > 0)) { + goto L252; + } + lldst[op] = (short) (min(4095,np) + 16384); + ++op; +/* L251: */ + np += -4095; + goto L250; +L252: +L91: + x1 = ip + 1; + iz = x1; + pv = nv; +L120: + ; + } +/* L121: */ + lldst[4] = (short) ((op - 1) % 32768); + lldst[5] = (short) ((op - 1) / 32768); + ret_val = op - 1; + goto L100; +L100: + return ret_val; +} /* plp2li_ */ + +/* + * PL_L2PI -- Translate a PLIO line list into an integer pixel array. + * The number of pixels output (always npix) is returned as the function + * value. + * + * Translated from the SPP version using xc -f, f2c. 8Sep99 DCT. + */ + +int pl_l2pi (short *ll_src, int xs, int *px_dst, int npix) +/* short *ll_src; encoded line list */ +/* int xs; starting index in ll_src */ +/* int *px_dst; output pixel array */ +/* int npix; number of pixels to convert */ +{ + /* System generated locals */ + int ret_val, i__1, i__2; + + /* Local variables */ + static int data, sw0001, otop, i__, lllen, i1, i2, x1, x2, ip, xe, np, + op, pv, opcode, llfirt; + static int skipwd; + + /* Parameter adjustments */ + --px_dst; + --ll_src; + + /* Function Body */ + if (! (ll_src[3] > 0)) { + goto L110; + } + lllen = ll_src[3]; + llfirt = 4; + goto L111; +L110: + lllen = (ll_src[5] << 15) + ll_src[4]; + llfirt = ll_src[2] + 1; +L111: + if (! (npix <= 0 || lllen <= 0)) { + goto L120; + } + ret_val = 0; + goto L100; +L120: + xe = xs + npix - 1; + skipwd = 0; + op = 1; + x1 = 1; + pv = 1; + i__1 = lllen; + for (ip = llfirt; ip <= i__1; ++ip) { + if (! skipwd) { + goto L140; + } + skipwd = 0; + goto L130; +L140: + opcode = ll_src[ip] / 4096; + data = ll_src[ip] & 4095; + sw0001 = opcode; + goto L150; +L160: + x2 = x1 + data - 1; + i1 = max(x1,xs); + i2 = min(x2,xe); + np = i2 - i1 + 1; + if (! (np > 0)) { + goto L170; + } + otop = op + np - 1; + if (! (opcode == 4)) { + goto L180; + } + i__2 = otop; + for (i__ = op; i__ <= i__2; ++i__) { + px_dst[i__] = pv; +/* L190: */ + } +/* L191: */ + goto L181; +L180: + i__2 = otop; + for (i__ = op; i__ <= i__2; ++i__) { + px_dst[i__] = 0; +/* L200: */ + } +/* L201: */ + if (! (opcode == 5 && i2 == x2)) { + goto L210; + } + px_dst[otop] = pv; +L210: +L181: + op = otop + 1; +L170: + x1 = x2 + 1; + goto L151; +L220: + pv = (ll_src[ip + 1] << 12) + data; + skipwd = 1; + goto L151; +L230: + pv += data; + goto L151; +L240: + pv -= data; + goto L151; +L250: + pv += data; + goto L91; +L260: + pv -= data; +L91: + if (! (x1 >= xs && x1 <= xe)) { + goto L270; + } + px_dst[op] = pv; + ++op; +L270: + ++x1; + goto L151; +L150: + ++sw0001; + if (sw0001 < 1 || sw0001 > 8) { + goto L151; + } + switch ((int)sw0001) { + case 1: goto L160; + case 2: goto L220; + case 3: goto L230; + case 4: goto L240; + case 5: goto L160; + case 6: goto L160; + case 7: goto L250; + case 8: goto L260; + } +L151: + if (! (x1 > xe)) { + goto L280; + } + goto L131; +L280: +L130: + ; + } +L131: + i__1 = npix; + for (i__ = op; i__ <= i__1; ++i__) { + px_dst[i__] = 0; +/* L290: */ + } +/* L291: */ + ret_val = npix; + goto L100; +L100: + return ret_val; +} /* pll2pi_ */ + diff --git a/tksao/fitsy++/rice.C b/tksao/fitsy++/rice.C new file mode 100644 index 0000000..e8d2167 --- /dev/null +++ b/tksao/fitsy++/rice.C @@ -0,0 +1,157 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include +using namespace std; + +#include "rice.h" + +extern "C" { + int fits_rdecomp (unsigned char *c, + int clen, + unsigned int array[], + int nx, + int nblock); + int fits_rdecomp_short (unsigned char *c, + int clen, + unsigned short array[], + int nx, + int nblock); + int fits_rdecomp_byte (unsigned char *c, + int clen, + unsigned char array[], + int nx, + int nblock); +} + +template FitsRicem::FitsRicem(FitsFile* fits) + : FitsCompressm(fits) +{ + // rice parameters + block_ = 32; + bytepix_ = 4; + noisebit_ = 4; + char name[] = "ZNAME "; + char val[] = "ZVAL "; + for (int ii=0; ii<9; ii++) { + name[5] = '0'+ii; + val[4] = '0'+ii; + if (fits->find(name)) { + char* which = fits->getString(name); + if (!strncmp(which,"BLOCK",4)) + block_ = fits->getInteger(val,32); + else if (!strncmp(which,"BYTEPIX",4)) + bytepix_ = fits->getInteger(val,4); + else if (!strncmp(which,"NOISEBIT",4)) + noisebit_ = fits->getInteger(val,4); + delete [] which; + } + } + + FitsCompressm::uncompress(fits); +} + +template int FitsRicem::compressed(T* dest, char* sptr, + char* heap, + int kkstart, int kkstop, + int jjstart, int jjstop, + int iistart, int iistop) +{ + double zs = FitsCompressm::bscale_; + if (FitsCompressm::zscale_) + zs = FitsCompressm::zscale_->value(sptr,0); + + double zz = FitsCompressm::bzero_; + if (FitsCompressm::zzero_) + zz = FitsCompressm::zzero_->value(sptr,0); + + int blank = FitsCompressm::blank_; + if (FitsCompressm::zblank_) + blank = (int)FitsCompressm::zblank_->value(sptr,0); + + int icnt=0; + unsigned char* ibuf = (unsigned char*)((FitsBinColumnArray*)FitsCompressm::compress_)->get(heap, sptr, &icnt); + + // ibuf can be NULL + if (!ibuf || !icnt) + return 0; + + int ocnt = FitsCompressm::tilesize_; + int ll=0; + + switch (bytepix_) { + case 1: + { + char* obuf = new char[ocnt]; + if (fits_rdecomp_byte(ibuf, icnt, (unsigned char*)obuf, ocnt, block_)) { + internalError("Fitsy++ rice bad inflate result"); + return 0; + } + for (int kk=kkstart; kk::width_*FitsCompressm::height_ + jj*FitsCompressm::width_ + ii; + T val = FitsCompressm::getValue(obuf+ll,zs,zz,blank); + dest[id] = val; + } + + if (obuf) + delete [] obuf; + } + break; + case 2: + { + short* obuf = new short[ocnt]; + if (fits_rdecomp_short(ibuf, icnt, (unsigned short*)obuf, ocnt, block_)) { + internalError("Fitsy++ rice bad inflate result"); + return 0; + } + for (int kk=kkstart; kk::width_*FitsCompressm::height_ + jj*FitsCompressm::width_ + ii; + T val = FitsCompressm::getValue(obuf+ll,zs,zz,blank); + dest[id] = val; + } + + if (obuf) + delete [] obuf; + } + break; + case 4: + { + int* obuf = new int[ocnt]; + if (fits_rdecomp(ibuf, icnt, (unsigned int*)obuf, ocnt, block_)) { + internalError("Fitsy++ rice bad inflate result"); + return 0; + } + for (int kk=kkstart; kk::width_*FitsCompressm::height_ + jj*FitsCompressm::width_ + ii; + T val = FitsCompressm::getValue(obuf+ll,zs,zz,blank); + dest[id] = val; + } + + if (obuf) + delete [] obuf; + } + break; + } + + return 1; +} + +template class FitsRicem; +template class FitsRicem; +template class FitsRicem; +template class FitsRicem; +template class FitsRicem; +template class FitsRicem; +template class FitsRicem; diff --git a/tksao/fitsy++/rice.h b/tksao/fitsy++/rice.h new file mode 100644 index 0000000..14a17b8 --- /dev/null +++ b/tksao/fitsy++/rice.h @@ -0,0 +1,24 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsrice_h__ +#define __fitsrice_h__ + +#include "compress.h" + +template +class FitsRicem : public FitsCompressm { + protected: + int block_; + int bytepix_; + int noisebit_; + + private: + int compressed(T*, char*, char*, int, int, int, int, int, int); + + public: + FitsRicem(FitsFile*); +}; + +#endif diff --git a/tksao/fitsy++/ricecomp.c b/tksao/fitsy++/ricecomp.c new file mode 100644 index 0000000..a464d9d --- /dev/null +++ b/tksao/fitsy++/ricecomp.c @@ -0,0 +1,1386 @@ +/* + The following code was written by Richard White at STScI and made + available for use in CFITSIO in July 1999. These routines were + originally contained in 2 source files: rcomp.c and rdecomp.c, + and the 'include' file now called ricecomp.h was originally called buffer.h. +*/ + +/*----------------------------------------------------------*/ +/* */ +/* START OF SOURCE FILE ORIGINALLY CALLED rcomp.c */ +/* */ +/*----------------------------------------------------------*/ +/* @(#) rcomp.c 1.5 99/03/01 12:40:27 */ +/* rcomp.c Compress image line using + * (1) Difference of adjacent pixels + * (2) Rice algorithm coding + * + * Returns number of bytes written to code buffer or + * -1 on failure + */ + +#include +#include +#include + +static void ffpmsg(const char* str) {} + +typedef unsigned char Buffer_t; + +typedef struct { + int bitbuffer; /* bit buffer */ + int bits_to_go; /* bits to go in buffer */ + Buffer_t *start; /* start of buffer */ + Buffer_t *current; /* current position in buffer */ + Buffer_t *end; /* end of buffer */ +} Buffer; + +#define putcbuf(c,mf) ((*(mf->current)++ = c), 0) + +/*#include "fitsio2.h"*/ +#define FFLOCK +#define FFUNLOCK + +static void start_outputing_bits(Buffer *buffer); +static int done_outputing_bits(Buffer *buffer); +static int output_nbits(Buffer *buffer, int bits, int n); + +/* this routine used to be called 'rcomp' (WDP) */ +/*---------------------------------------------------------------------------*/ + +int fits_rcomp(int a[], /* input array */ + int nx, /* number of input pixels */ + unsigned char *c, /* output buffer */ + int clen, /* max length of output */ + int nblock) /* coding block size */ +{ +Buffer bufmem, *buffer = &bufmem; +/* int bsize; */ +int i, j, thisblock; +int lastpix, nextpix, pdiff; +int v, fs, fsmask, top, fsmax, fsbits, bbits; +int lbitbuffer, lbits_to_go; +unsigned int psum; +double pixelsum, dpsum; +unsigned int *diff; + + /* + * Original size of each pixel (bsize, bytes) and coding block + * size (nblock, pixels) + * Could make bsize a parameter to allow more efficient + * compression of short & byte images. + */ +/* bsize = 4; */ + +/* nblock = 32; now an input parameter*/ + /* + * From bsize derive: + * FSBITS = # bits required to store FS + * FSMAX = maximum value for FS + * BBITS = bits/pixel for direct coding + */ + +/* + switch (bsize) { + case 1: + fsbits = 3; + fsmax = 6; + break; + case 2: + fsbits = 4; + fsmax = 14; + break; + case 4: + fsbits = 5; + fsmax = 25; + break; + default: + ffpmsg("rdecomp: bsize must be 1, 2, or 4 bytes"); + return(-1); + } +*/ + + /* move out of switch block, to tweak performance */ + fsbits = 5; + fsmax = 25; + bbits = 1<start = c; + buffer->current = c; + buffer->end = c+clen; + buffer->bits_to_go = 8; + /* + * array for differences mapped to non-negative values + */ + diff = (unsigned int *) malloc(nblock*sizeof(unsigned int)); + if (diff == (unsigned int *) NULL) { + ffpmsg("fits_rcomp: insufficient memory"); + return(-1); + } + /* + * Code in blocks of nblock pixels + */ + start_outputing_bits(buffer); + + /* write out first int value to the first 4 bytes of the buffer */ + if (output_nbits(buffer, a[0], 32) == EOF) { + ffpmsg("rice_encode: end of buffer"); + free(diff); + return(-1); + } + + lastpix = a[0]; /* the first difference will always be zero */ + + thisblock = nblock; + for (i=0; i> 1; + for (fs = 0; psum>0; fs++) psum >>= 1; + + /* + * write the codes + * fsbits ID bits used to indicate split level + */ + if (fs >= fsmax) { + /* Special high entropy case when FS >= fsmax + * Just write pixel difference values directly, no Rice coding at all. + */ + if (output_nbits(buffer, fsmax+1, fsbits) == EOF) { + ffpmsg("rice_encode: end of buffer"); + free(diff); + return(-1); + } + for (j=0; jbitbuffer; + lbits_to_go = buffer->bits_to_go; + for (j=0; j> fs; + /* + * top is coded by top zeros + 1 + */ + if (lbits_to_go >= top+1) { + lbitbuffer <<= top+1; + lbitbuffer |= 1; + lbits_to_go -= top+1; + } else { + lbitbuffer <<= lbits_to_go; + putcbuf(lbitbuffer & 0xff,buffer); + + for (top -= lbits_to_go; top>=8; top -= 8) { + putcbuf(0, buffer); + } + lbitbuffer = 1; + lbits_to_go = 7-top; + } + /* + * bottom FS bits are written without coding + * code is output_nbits, moved into this routine to reduce overheads + * This code potentially breaks if FS>24, so I am limiting + * FS to 24 by choice of FSMAX above. + */ + if (fs > 0) { + lbitbuffer <<= fs; + lbitbuffer |= v & fsmask; + lbits_to_go -= fs; + while (lbits_to_go <= 0) { + putcbuf((lbitbuffer>>(-lbits_to_go)) & 0xff,buffer); + lbits_to_go += 8; + } + } + } + + /* check if overflowed output buffer */ + if (buffer->current > buffer->end) { + ffpmsg("rice_encode: end of buffer"); + free(diff); + return(-1); + } + buffer->bitbuffer = lbitbuffer; + buffer->bits_to_go = lbits_to_go; + } + } + done_outputing_bits(buffer); + free(diff); + /* + * return number of bytes used + */ + return(buffer->current - buffer->start); +} +/*---------------------------------------------------------------------------*/ + +int fits_rcomp_short( + short a[], /* input array */ + int nx, /* number of input pixels */ + unsigned char *c, /* output buffer */ + int clen, /* max length of output */ + int nblock) /* coding block size */ +{ +Buffer bufmem, *buffer = &bufmem; +/* int bsize; */ +int i, j, thisblock; + +/* +NOTE: in principle, the following 2 variable could be declared as 'short' +but in fact the code runs faster (on 32-bit Linux at least) as 'int' +*/ +int lastpix, nextpix; +/* int pdiff; */ +short pdiff; +int v, fs, fsmask, top, fsmax, fsbits, bbits; +int lbitbuffer, lbits_to_go; +/* unsigned int psum; */ +unsigned short psum; +double pixelsum, dpsum; +unsigned int *diff; + + /* + * Original size of each pixel (bsize, bytes) and coding block + * size (nblock, pixels) + * Could make bsize a parameter to allow more efficient + * compression of short & byte images. + */ +/* bsize = 2; */ + +/* nblock = 32; now an input parameter */ + /* + * From bsize derive: + * FSBITS = # bits required to store FS + * FSMAX = maximum value for FS + * BBITS = bits/pixel for direct coding + */ + +/* + switch (bsize) { + case 1: + fsbits = 3; + fsmax = 6; + break; + case 2: + fsbits = 4; + fsmax = 14; + break; + case 4: + fsbits = 5; + fsmax = 25; + break; + default: + ffpmsg("rdecomp: bsize must be 1, 2, or 4 bytes"); + return(-1); + } +*/ + + /* move these out of switch block to further tweak performance */ + fsbits = 4; + fsmax = 14; + + bbits = 1<start = c; + buffer->current = c; + buffer->end = c+clen; + buffer->bits_to_go = 8; + /* + * array for differences mapped to non-negative values + */ + diff = (unsigned int *) malloc(nblock*sizeof(unsigned int)); + if (diff == (unsigned int *) NULL) { + ffpmsg("fits_rcomp: insufficient memory"); + return(-1); + } + /* + * Code in blocks of nblock pixels + */ + start_outputing_bits(buffer); + + /* write out first short value to the first 2 bytes of the buffer */ + if (output_nbits(buffer, a[0], 16) == EOF) { + ffpmsg("rice_encode: end of buffer"); + free(diff); + return(-1); + } + + lastpix = a[0]; /* the first difference will always be zero */ + + thisblock = nblock; + for (i=0; i> 1; */ + psum = ((unsigned short) dpsum ) >> 1; + for (fs = 0; psum>0; fs++) psum >>= 1; + + /* + * write the codes + * fsbits ID bits used to indicate split level + */ + if (fs >= fsmax) { + /* Special high entropy case when FS >= fsmax + * Just write pixel difference values directly, no Rice coding at all. + */ + if (output_nbits(buffer, fsmax+1, fsbits) == EOF) { + ffpmsg("rice_encode: end of buffer"); + free(diff); + return(-1); + } + for (j=0; jbitbuffer; + lbits_to_go = buffer->bits_to_go; + for (j=0; j> fs; + /* + * top is coded by top zeros + 1 + */ + if (lbits_to_go >= top+1) { + lbitbuffer <<= top+1; + lbitbuffer |= 1; + lbits_to_go -= top+1; + } else { + lbitbuffer <<= lbits_to_go; + putcbuf(lbitbuffer & 0xff,buffer); + for (top -= lbits_to_go; top>=8; top -= 8) { + putcbuf(0, buffer); + } + lbitbuffer = 1; + lbits_to_go = 7-top; + } + /* + * bottom FS bits are written without coding + * code is output_nbits, moved into this routine to reduce overheads + * This code potentially breaks if FS>24, so I am limiting + * FS to 24 by choice of FSMAX above. + */ + if (fs > 0) { + lbitbuffer <<= fs; + lbitbuffer |= v & fsmask; + lbits_to_go -= fs; + while (lbits_to_go <= 0) { + putcbuf((lbitbuffer>>(-lbits_to_go)) & 0xff,buffer); + lbits_to_go += 8; + } + } + } + /* check if overflowed output buffer */ + if (buffer->current > buffer->end) { + ffpmsg("rice_encode: end of buffer"); + free(diff); + return(-1); + } + buffer->bitbuffer = lbitbuffer; + buffer->bits_to_go = lbits_to_go; + } + } + done_outputing_bits(buffer); + free(diff); + /* + * return number of bytes used + */ + return(buffer->current - buffer->start); +} +/*---------------------------------------------------------------------------*/ + +int fits_rcomp_byte( + signed char a[], /* input array */ + int nx, /* number of input pixels */ + unsigned char *c, /* output buffer */ + int clen, /* max length of output */ + int nblock) /* coding block size */ +{ +Buffer bufmem, *buffer = &bufmem; +/* int bsize; */ +int i, j, thisblock; + +/* +NOTE: in principle, the following 2 variable could be declared as 'short' +but in fact the code runs faster (on 32-bit Linux at least) as 'int' +*/ +int lastpix, nextpix; +/* int pdiff; */ +signed char pdiff; +int v, fs, fsmask, top, fsmax, fsbits, bbits; +int lbitbuffer, lbits_to_go; +/* unsigned int psum; */ +unsigned char psum; +double pixelsum, dpsum; +unsigned int *diff; + + /* + * Original size of each pixel (bsize, bytes) and coding block + * size (nblock, pixels) + * Could make bsize a parameter to allow more efficient + * compression of short & byte images. + */ +/* bsize = 1; */ + +/* nblock = 32; now an input parameter */ + /* + * From bsize derive: + * FSBITS = # bits required to store FS + * FSMAX = maximum value for FS + * BBITS = bits/pixel for direct coding + */ + +/* + switch (bsize) { + case 1: + fsbits = 3; + fsmax = 6; + break; + case 2: + fsbits = 4; + fsmax = 14; + break; + case 4: + fsbits = 5; + fsmax = 25; + break; + default: + ffpmsg("rdecomp: bsize must be 1, 2, or 4 bytes"); + return(-1); + } +*/ + + /* move these out of switch block to further tweak performance */ + fsbits = 3; + fsmax = 6; + bbits = 1<start = c; + buffer->current = c; + buffer->end = c+clen; + buffer->bits_to_go = 8; + /* + * array for differences mapped to non-negative values + */ + diff = (unsigned int *) malloc(nblock*sizeof(unsigned int)); + if (diff == (unsigned int *) NULL) { + ffpmsg("fits_rcomp: insufficient memory"); + return(-1); + } + /* + * Code in blocks of nblock pixels + */ + start_outputing_bits(buffer); + + /* write out first byte value to the first byte of the buffer */ + if (output_nbits(buffer, a[0], 8) == EOF) { + ffpmsg("rice_encode: end of buffer"); + free(diff); + return(-1); + } + + lastpix = a[0]; /* the first difference will always be zero */ + + thisblock = nblock; + for (i=0; i> 1; */ + psum = ((unsigned char) dpsum ) >> 1; + for (fs = 0; psum>0; fs++) psum >>= 1; + + /* + * write the codes + * fsbits ID bits used to indicate split level + */ + if (fs >= fsmax) { + /* Special high entropy case when FS >= fsmax + * Just write pixel difference values directly, no Rice coding at all. + */ + if (output_nbits(buffer, fsmax+1, fsbits) == EOF) { + ffpmsg("rice_encode: end of buffer"); + free(diff); + return(-1); + } + for (j=0; jbitbuffer; + lbits_to_go = buffer->bits_to_go; + for (j=0; j> fs; + /* + * top is coded by top zeros + 1 + */ + if (lbits_to_go >= top+1) { + lbitbuffer <<= top+1; + lbitbuffer |= 1; + lbits_to_go -= top+1; + } else { + lbitbuffer <<= lbits_to_go; + putcbuf(lbitbuffer & 0xff,buffer); + for (top -= lbits_to_go; top>=8; top -= 8) { + putcbuf(0, buffer); + } + lbitbuffer = 1; + lbits_to_go = 7-top; + } + /* + * bottom FS bits are written without coding + * code is output_nbits, moved into this routine to reduce overheads + * This code potentially breaks if FS>24, so I am limiting + * FS to 24 by choice of FSMAX above. + */ + if (fs > 0) { + lbitbuffer <<= fs; + lbitbuffer |= v & fsmask; + lbits_to_go -= fs; + while (lbits_to_go <= 0) { + putcbuf((lbitbuffer>>(-lbits_to_go)) & 0xff,buffer); + lbits_to_go += 8; + } + } + } + /* check if overflowed output buffer */ + if (buffer->current > buffer->end) { + ffpmsg("rice_encode: end of buffer"); + free(diff); + return(-1); + } + buffer->bitbuffer = lbitbuffer; + buffer->bits_to_go = lbits_to_go; + } + } + done_outputing_bits(buffer); + free(diff); + /* + * return number of bytes used + */ + return(buffer->current - buffer->start); +} +/*---------------------------------------------------------------------------*/ +/* bit_output.c + * + * Bit output routines + * Procedures return zero on success, EOF on end-of-buffer + * + * Programmer: R. White Date: 20 July 1998 + */ + +/* Initialize for bit output */ + +static void start_outputing_bits(Buffer *buffer) +{ + /* + * Buffer is empty to start with + */ + buffer->bitbuffer = 0; + buffer->bits_to_go = 8; +} + +/*---------------------------------------------------------------------------*/ +/* Output N bits (N must be <= 32) */ + +static int output_nbits(Buffer *buffer, int bits, int n) +{ +/* local copies */ +int lbitbuffer; +int lbits_to_go; + /* AND mask for the right-most n bits */ + static unsigned int mask[33] = + {0, + 0x1, 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, + 0x1ff, 0x3ff, 0x7ff, 0xfff, 0x1fff, 0x3fff, 0x7fff, 0xffff, + 0x1ffff, 0x3ffff, 0x7ffff, 0xfffff, 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff, + 0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff}; + + /* + * insert bits at end of bitbuffer + */ + lbitbuffer = buffer->bitbuffer; + lbits_to_go = buffer->bits_to_go; + if (lbits_to_go+n > 32) { + /* + * special case for large n: put out the top lbits_to_go bits first + * note that 0 < lbits_to_go <= 8 + */ + lbitbuffer <<= lbits_to_go; +/* lbitbuffer |= (bits>>(n-lbits_to_go)) & ((1<>(n-lbits_to_go)) & *(mask+lbits_to_go); + putcbuf(lbitbuffer & 0xff,buffer); + n -= lbits_to_go; + lbits_to_go = 8; + } + lbitbuffer <<= n; +/* lbitbuffer |= ( bits & ((1<>(-lbits_to_go)) & 0xff,buffer); + lbits_to_go += 8; + } + buffer->bitbuffer = lbitbuffer; + buffer->bits_to_go = lbits_to_go; + return(0); +} +/*---------------------------------------------------------------------------*/ +/* Flush out the last bits */ + +static int done_outputing_bits(Buffer *buffer) +{ + if(buffer->bits_to_go < 8) { + putcbuf(buffer->bitbuffer<bits_to_go,buffer); + +/* if (putcbuf(buffer->bitbuffer<bits_to_go,buffer) == EOF) + return(EOF); +*/ + } + return(0); +} +/*---------------------------------------------------------------------------*/ +/*----------------------------------------------------------*/ +/* */ +/* START OF SOURCE FILE ORIGINALLY CALLED rdecomp.c */ +/* */ +/*----------------------------------------------------------*/ + +/* @(#) rdecomp.c 1.4 99/03/01 12:38:41 */ +/* rdecomp.c Decompress image line using + * (1) Difference of adjacent pixels + * (2) Rice algorithm coding + * + * Returns 0 on success or 1 on failure + */ + +/* moved these 'includes' to the beginning of the file (WDP) +#include +#include +*/ + +/*---------------------------------------------------------------------------*/ +/* this routine used to be called 'rdecomp' (WDP) */ + +int fits_rdecomp (unsigned char *c, /* input buffer */ + int clen, /* length of input */ + unsigned int array[], /* output array */ + int nx, /* number of output pixels */ + int nblock) /* coding block size */ +{ +/* int bsize; */ +int i, k, imax; +int nbits, nzero, fs; +unsigned char *cend, bytevalue; +unsigned int b, diff, lastpix; +int fsmax, fsbits, bbits; +static int *nonzero_count = (int *)NULL; + + /* + * Original size of each pixel (bsize, bytes) and coding block + * size (nblock, pixels) + * Could make bsize a parameter to allow more efficient + * compression of short & byte images. + */ +/* bsize = 4; */ + +/* nblock = 32; now an input parameter */ + /* + * From bsize derive: + * FSBITS = # bits required to store FS + * FSMAX = maximum value for FS + * BBITS = bits/pixel for direct coding + */ + +/* + switch (bsize) { + case 1: + fsbits = 3; + fsmax = 6; + break; + case 2: + fsbits = 4; + fsmax = 14; + break; + case 4: + fsbits = 5; + fsmax = 25; + break; + default: + ffpmsg("rdecomp: bsize must be 1, 2, or 4 bytes"); + return 1; + } +*/ + + /* move out of switch block, to tweak performance */ + fsbits = 5; + fsmax = 25; + + bbits = 1<=0; ) { + for ( ; i>=k; i--) nonzero_count[i] = nzero; + k = k/2; + nzero--; + } + } + FFUNLOCK; + + /* + * Decode in blocks of nblock pixels + */ + + /* first 4 bytes of input buffer contain the value of the first */ + /* 4 byte integer value, without any encoding */ + + lastpix = 0; + bytevalue = c[0]; + lastpix = lastpix | (bytevalue<<24); + bytevalue = c[1]; + lastpix = lastpix | (bytevalue<<16); + bytevalue = c[2]; + lastpix = lastpix | (bytevalue<<8); + bytevalue = c[3]; + lastpix = lastpix | bytevalue; + + c += 4; + cend = c + clen - 4; + + b = *c++; /* bit buffer */ + nbits = 8; /* number of bits remaining in b */ + for (i = 0; i> nbits) - 1; + + b &= (1< nx) imax = nx; + if (fs<0) { + /* low-entropy case, all zero differences */ + for ( ; i= 0; k -= 8) { + b = *c++; + diff |= b<0) { + b = *c++; + diff |= b>>(-k); + b &= (1<>1; + } else { + diff = ~(diff>>1); + } + array[i] = diff+lastpix; + lastpix = array[i]; + } + } else { + /* normal case, Rice coding */ + for ( ; i>nbits); + b &= (1<>1; + } else { + diff = ~(diff>>1); + } + array[i] = diff+lastpix; + lastpix = array[i]; + } + } + if (c > cend) { + ffpmsg("decompression error: hit end of compressed byte stream"); + return 1; + } + } + if (c < cend) { + ffpmsg("decompression warning: unused bytes at end of compressed buffer"); + } + return 0; +} +/*---------------------------------------------------------------------------*/ +/* this routine used to be called 'rdecomp' (WDP) */ + +int fits_rdecomp_short (unsigned char *c, /* input buffer */ + int clen, /* length of input */ + unsigned short array[], /* output array */ + int nx, /* number of output pixels */ + int nblock) /* coding block size */ +{ +int i, imax; +/* int bsize; */ +int k; +int nbits, nzero, fs; +unsigned char *cend, bytevalue; +unsigned int b, diff, lastpix; +int fsmax, fsbits, bbits; +static int *nonzero_count = (int *)NULL; + + /* + * Original size of each pixel (bsize, bytes) and coding block + * size (nblock, pixels) + * Could make bsize a parameter to allow more efficient + * compression of short & byte images. + */ + +/* bsize = 2; */ + +/* nblock = 32; now an input parameter */ + /* + * From bsize derive: + * FSBITS = # bits required to store FS + * FSMAX = maximum value for FS + * BBITS = bits/pixel for direct coding + */ + +/* + switch (bsize) { + case 1: + fsbits = 3; + fsmax = 6; + break; + case 2: + fsbits = 4; + fsmax = 14; + break; + case 4: + fsbits = 5; + fsmax = 25; + break; + default: + ffpmsg("rdecomp: bsize must be 1, 2, or 4 bytes"); + return 1; + } +*/ + + /* move out of switch block, to tweak performance */ + fsbits = 4; + fsmax = 14; + + bbits = 1<=0; ) { + for ( ; i>=k; i--) nonzero_count[i] = nzero; + k = k/2; + nzero--; + } + } + FFUNLOCK; + /* + * Decode in blocks of nblock pixels + */ + + /* first 2 bytes of input buffer contain the value of the first */ + /* 2 byte integer value, without any encoding */ + + lastpix = 0; + bytevalue = c[0]; + lastpix = lastpix | (bytevalue<<8); + bytevalue = c[1]; + lastpix = lastpix | bytevalue; + + c += 2; + cend = c + clen - 2; + + b = *c++; /* bit buffer */ + nbits = 8; /* number of bits remaining in b */ + for (i = 0; i> nbits) - 1; + + b &= (1< nx) imax = nx; + if (fs<0) { + /* low-entropy case, all zero differences */ + for ( ; i= 0; k -= 8) { + b = *c++; + diff |= b<0) { + b = *c++; + diff |= b>>(-k); + b &= (1<>1; + } else { + diff = ~(diff>>1); + } + array[i] = diff+lastpix; + lastpix = array[i]; + } + } else { + /* normal case, Rice coding */ + for ( ; i>nbits); + b &= (1<>1; + } else { + diff = ~(diff>>1); + } + array[i] = diff+lastpix; + lastpix = array[i]; + } + } + if (c > cend) { + ffpmsg("decompression error: hit end of compressed byte stream"); + return 1; + } + } + if (c < cend) { + ffpmsg("decompression warning: unused bytes at end of compressed buffer"); + } + return 0; +} +/*---------------------------------------------------------------------------*/ +/* this routine used to be called 'rdecomp' (WDP) */ + +int fits_rdecomp_byte (unsigned char *c, /* input buffer */ + int clen, /* length of input */ + unsigned char array[], /* output array */ + int nx, /* number of output pixels */ + int nblock) /* coding block size */ +{ +int i, imax; +/* int bsize; */ +int k; +int nbits, nzero, fs; +unsigned char *cend; +unsigned int b, diff, lastpix; +int fsmax, fsbits, bbits; +static int *nonzero_count = (int *)NULL; + + /* + * Original size of each pixel (bsize, bytes) and coding block + * size (nblock, pixels) + * Could make bsize a parameter to allow more efficient + * compression of short & byte images. + */ + +/* bsize = 1; */ + +/* nblock = 32; now an input parameter */ + /* + * From bsize derive: + * FSBITS = # bits required to store FS + * FSMAX = maximum value for FS + * BBITS = bits/pixel for direct coding + */ + +/* + switch (bsize) { + case 1: + fsbits = 3; + fsmax = 6; + break; + case 2: + fsbits = 4; + fsmax = 14; + break; + case 4: + fsbits = 5; + fsmax = 25; + break; + default: + ffpmsg("rdecomp: bsize must be 1, 2, or 4 bytes"); + return 1; + } +*/ + + /* move out of switch block, to tweak performance */ + fsbits = 3; + fsmax = 6; + + bbits = 1<=0; ) { + for ( ; i>=k; i--) nonzero_count[i] = nzero; + k = k/2; + nzero--; + } + } + FFUNLOCK; + /* + * Decode in blocks of nblock pixels + */ + + /* first byte of input buffer contain the value of the first */ + /* byte integer value, without any encoding */ + + lastpix = c[0]; + c += 1; + cend = c + clen - 1; + + b = *c++; /* bit buffer */ + nbits = 8; /* number of bits remaining in b */ + for (i = 0; i> nbits) - 1; + + b &= (1< nx) imax = nx; + if (fs<0) { + /* low-entropy case, all zero differences */ + for ( ; i= 0; k -= 8) { + b = *c++; + diff |= b<0) { + b = *c++; + diff |= b>>(-k); + b &= (1<>1; + } else { + diff = ~(diff>>1); + } + array[i] = diff+lastpix; + lastpix = array[i]; + } + } else { + /* normal case, Rice coding */ + for ( ; i>nbits); + b &= (1<>1; + } else { + diff = ~(diff>>1); + } + array[i] = diff+lastpix; + lastpix = array[i]; + } + } + if (c > cend) { + ffpmsg("decompression error: hit end of compressed byte stream"); + return 1; + } + } + if (c < cend) { + ffpmsg("decompression warning: unused bytes at end of compressed buffer"); + } + return 0; +} diff --git a/tksao/fitsy++/savefits.C b/tksao/fitsy++/savefits.C new file mode 100644 index 0000000..4653ac8 --- /dev/null +++ b/tksao/fitsy++/savefits.C @@ -0,0 +1,412 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include +using namespace std; + +#include + +#include "file.h" +#include "util.h" +#include "outfile.h" +#include "outchannel.h" +#include "outsocket.h" + +int FitsFile::saveFitsPrimHeader(OutFitsStream& str) +{ + // write fake primary header + char buf[FTY_BLOCK]; + memset(buf,' ',FTY_BLOCK); + + char* hdu = buf; + + memcpy(hdu,"SIMPLE = ",10); + memcpy(hdu+32-3,"T /",3); + hdu += FTY_CARDLEN; + + memcpy(hdu,"BITPIX = ",10); + memcpy(hdu+32-3,"8 /",3); + hdu += FTY_CARDLEN; + + memcpy(hdu,"NAXIS = ",10); + memcpy(hdu+32-3,"0 /",3); + hdu += FTY_CARDLEN; + + memcpy(hdu,"END",3); + str.write(buf, FTY_BLOCK); + + return FTY_BLOCK; +} + +int FitsFile::saveFitsHeader(OutFitsStream& str, int depth) +{ + int cnt =0; + char buf[FTY_CARDLEN]; + + memset(buf,' ',FTY_CARDLEN); + memcpy(buf,"SIMPLE = ",10); + memcpy(buf+32-3,"T /",3); + str.write(buf, FTY_CARDLEN); + cnt += FTY_CARDLEN; + + char* ptr = head()->cards()+FTY_CARDLEN; + char* end = head()->cards() + head()->headbytes(); + while (ptrbitpix() == -16) { + memset(buf,' ',FTY_CARDLEN); + memcpy(buf,"BITPIX = ",10); + memcpy(buf+32-4,"32 /",4); + str.write(buf, FTY_CARDLEN); + } + else if (!strncmp(ptr,"NAXIS ",6)) { + memset(buf,' ',FTY_CARDLEN); + memcpy(buf,"NAXIS = ",10); + if (depth>1) + memcpy(buf+32-3,"3 /",3); + else + if (head()->naxis(1)>1) + memcpy(buf+32-3,"2 /",3); + else + memcpy(buf+32-3,"1 /",3); + str.write(buf, FTY_CARDLEN); + } + else if (!strncmp(ptr,"NAXIS2",6)) { + str.write(ptr, FTY_CARDLEN); + + if (depth>1) { + ostringstream ddstr; + ddstr << depth << " /" << ends; + const char* ddptr = dupstr(ddstr.str().c_str()); + int ll = strlen(ddptr); + + memset(buf,' ',FTY_CARDLEN); + memcpy(buf,"NAXIS3 = ",10); + memcpy(buf+32-ll, ddptr, ll); + str.write(buf, FTY_CARDLEN); + cnt += FTY_CARDLEN; + delete [] ddptr; + } + } + else if (!strncmp(ptr,"NAXIS3",6)) { + // skip + cnt -= FTY_CARDLEN; + } + else if (!strncmp(ptr,"NAXIS4",6)) { + // skip + cnt -= FTY_CARDLEN; + } + else if (!strncmp(ptr,"NAXIS5",6)) { + // skip + cnt -= FTY_CARDLEN; + } + else if (!strncmp(ptr,"PCOUNT",6)) { + // skip + cnt -= FTY_CARDLEN; + } + else if (!strncmp(ptr,"GCOUNT",6)) { + // skip + cnt -= FTY_CARDLEN; + } + else if (!strncmp(ptr,"END ",6)) { + // skip + cnt -= FTY_CARDLEN; + } + else + str.write(ptr, FTY_CARDLEN); + + ptr+=FTY_CARDLEN; + cnt += FTY_CARDLEN; + } + + // final END + memset(buf,' ',FTY_CARDLEN); + memcpy(buf,"END",3); + str.write(buf, FTY_CARDLEN); + cnt += FTY_CARDLEN; + + cnt += saveFitsPad(str,cnt,' '); + + return cnt; +} + +int FitsFile::saveFitsXtHeader(OutFitsStream& str, int depth) +{ + // write xtension header + // the header may be an xtension, or primary, so lets force a + // first line of 'SIMPLE' and then write the rest of the header + int cnt =0; + char buf[FTY_CARDLEN]; + + memset(buf,' ',FTY_CARDLEN); + memcpy(buf,"XTENSION= 'IMAGE '",20); + str.write(buf, FTY_CARDLEN); + cnt += FTY_CARDLEN; + + char* ptr = head()->cards()+FTY_CARDLEN; + char* end = head()->cards() + head()->headbytes(); + while (ptrbitpix() == -16) { + memset(buf,' ',FTY_CARDLEN); + memcpy(buf,"BITPIX = ",10); + memcpy(buf+32-4,"32 /",4); + str.write(buf, FTY_CARDLEN); + } + else if (!strncmp(ptr,"NAXIS ",6)) { + memset(buf,' ',FTY_CARDLEN); + memcpy(buf,"NAXIS = ",10); + if (depth>1) + memcpy(buf+32-3,"3 /",3); + else + if (head()->naxis(1)>1) + memcpy(buf+32-3,"2 /",3); + else + memcpy(buf+32-3,"1 /",3); + str.write(buf, FTY_CARDLEN); + } + else if (!strncmp(ptr,"NAXIS2",6)) { + str.write(ptr, FTY_CARDLEN); + + if (depth>1) { + ostringstream ddstr; + ddstr << depth << " /" << ends; + const char* ddptr = ddstr.str().c_str(); + int ll = strlen(ddptr); + + memset(buf,' ',FTY_CARDLEN); + memcpy(buf,"NAXIS3 = ",10); + memcpy(buf+32-ll, ddptr, ll); + str.write(buf, FTY_CARDLEN); + cnt += FTY_CARDLEN; + } + + memset(buf,' ',FTY_CARDLEN); + memcpy(buf,"PCOUNT = ",10); + memcpy(buf+32-3,"0 /",3); + str.write(buf, FTY_CARDLEN); + cnt += FTY_CARDLEN; + + memset(buf,' ',FTY_CARDLEN); + memcpy(buf,"GCOUNT = ",10); + memcpy(buf+32-3,"1 /",3); + str.write(buf, FTY_CARDLEN); + cnt += FTY_CARDLEN; + } + else if (!strncmp(ptr,"NAXIS3",6)) { + // skip + cnt -= FTY_CARDLEN; + } + else if (!strncmp(ptr,"NAXIS4",6)) { + // skip + cnt -= FTY_CARDLEN; + } + else if (!strncmp(ptr,"NAXIS5",6)) { + // skip + cnt -= FTY_CARDLEN; + } + else if (!strncmp(ptr,"PCOUNT",6)) { + // skip + cnt -= FTY_CARDLEN; + } + else if (!strncmp(ptr,"GCOUNT",6)) { + // skip + cnt -= FTY_CARDLEN; + } + else if (!strncmp(ptr,"END ",6)) { + // skip + cnt -= FTY_CARDLEN; + } + else + str.write(ptr, FTY_CARDLEN); + + ptr+=FTY_CARDLEN; + cnt += FTY_CARDLEN; + } + + // final END + memset(buf,' ',FTY_CARDLEN); + memcpy(buf,"END",3); + str.write(buf, FTY_CARDLEN); + cnt += FTY_CARDLEN; + + cnt += saveFitsPad(str,cnt,' '); + + return cnt; +} + +int FitsFile::saveFits(OutFitsStream& str) +{ + FitsImageHDU* hdu = (FitsImageHDU*)(head()->hdu()); + + if (hdu->bitpix() != -16) { + switch (endian_) { + case BIG: + str.write((char*)data(), hdu->imgbytes()); + break; + case LITTLE: + str.writeSwap((char*)data(), hdu->imgbytes(), head()->bitpix()); + break; + case NATIVE: + break; + } + + return hdu->imgbytes(); + } + + // convert bitpix=-16 to bitpix=32 + int nx = head()->naxis(0); + int ny = head()->naxis(1); + int ss = nx*ny; + int* dest = new int[ss]; + for(int jj=0; jj 0 ) + str.write(buf, npad); + + return npad; +} + +int FitsFile::saveFitsTable(OutFitsStream& str) +{ + int cnt =0; + // primary header + str.write(primary()->cards(), primary()->headbytes()); + cnt += primary()->headbytes(); + + // now, ext header + str.write(head()->cards(), head()->headbytes()); + cnt += head()->headbytes(); + + // write valid data + // our data may be short (mmap or bad fits), so write valid data + // then write the pad, becareful with arch, if array + + switch (endian_) { + case BIG: + str.write((char*)data(), head()->allbytes()); + break; + case LITTLE: + str.writeSwap((char*)data(), head()->allbytes(), head()->bitpix()); + break; + case NATIVE: + break; + } + cnt += head()->allbytes(); + + // we may need to add a buffer to round out to block size + int diff = head()->padbytes(); + if (diff>0) { + char* buf = new char[diff]; + memset(buf,'\0',diff); + str.write(buf, diff); + delete [] buf; + } + cnt += head()->padbytes(); + + return cnt; +} + +int FitsFile::saveFitsIISHeader(OutFitsStream& str) +{ + int cnt =0; + char buf[FTY_CARDLEN]; + + char* ptr = head()->cards(); + char* end = head()->cards() + head()->headbytes(); + while (ptrhdu()); + + unsigned char* src = (unsigned char*)data(); + int size = hdu->imgbytes(); + float* dest = new float[size]; + + for (int ii=0; ii 200) + dest[ii] = NAN; + else + dest[ii] = ((src[ii]-1) * (iisz[1]-iisz[0]))/199 + iisz[0]; + + if (!lsb()) + str.write((char*)dest, size*sizeof(float)); + else + str.writeSwap((char*)dest, size*sizeof(float), -32); + + if (dest) + delete [] dest; + + return size*sizeof(float); +} + +int FitsFile::saveArray(OutFitsStream& str, ArchType which) +{ + // only save one slice + size_t size = head_->naxis(0)*head_->naxis(1)*abs(head_->bitpix()/8); + int bitpix = head_->bitpix(); + + if (which == endian_) + str.write((char*)data(), size); + else + str.writeSwap((char*)data(), size, bitpix); + + return size; +} + diff --git a/tksao/fitsy++/share.C b/tksao/fitsy++/share.C new file mode 100644 index 0000000..549e76f --- /dev/null +++ b/tksao/fitsy++/share.C @@ -0,0 +1,102 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "share.h" + +#if (HAVE_SYS_SHM_H && !__WIN32) +#include +#include +#include + +FitsShareID::FitsShareID(int shmid, const char* filter) +{ + parse(filter); + if (!valid_) + return; + + // reset + valid_ =0; + + // find size + struct shmid_ds info; + if (shmctl(shmid, IPC_STAT, &info)) { + internalError("Fitsy++ share shctl failed"); + return; + } + mapsize_ = info.shm_segsz; + + // Attach the memory segment + if ((long)(mapdata_ = (char*)shmat(shmid, 0, SHM_RDONLY)) == -1) { + internalError("Fitsy++ share shctl failed"); + return; + } + + // so far, so good + valid_ = 1; +} + +FitsShareID::~FitsShareID() +{ + shmdt(mapdata_); +} + +FitsShareKey::FitsShareKey(int key, const char* filter) +{ + parse(filter); + if (!valid_) + return; + + // reset + valid_ =0; + + // get shmid + int shmid; + if ((shmid = shmget(key, 0, 0)) < 0) { + internalError("Fitsy++ share shmget failed"); + return; + } + + // find size + struct shmid_ds info; + if (shmctl(shmid, IPC_STAT, &info)) { + internalError("Fitsy++ share shctl failed"); + return; + } + mapsize_ = info.shm_segsz; + + // Attach the memory segment + if ((long)(mapdata_ = (char*)shmat(shmid, 0, SHM_RDONLY)) == -1) { + internalError("Fitsy++ share shmat failed"); + return; + } + + // so far, so good + valid_ = 1; +} + +FitsShareKey::~FitsShareKey() +{ + if (mapdata_>0) + shmdt(mapdata_); +} + +#else + +FitsShareID::FitsShareID(int shmid, const char* filter) +{ + // shared memory not supported + valid_ = 0; +} + +FitsShareID::~FitsShareID() {} + +FitsShareKey::FitsShareKey(int key, const char* filter) +{ + // shared memory not supported + valid_ = 0; +} + +FitsShareKey::~FitsShareKey() {} + +#endif diff --git a/tksao/fitsy++/share.h b/tksao/fitsy++/share.h new file mode 100644 index 0000000..b7f11b8 --- /dev/null +++ b/tksao/fitsy++/share.h @@ -0,0 +1,98 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsshare_h__ +#define __fitsshare_h__ + +#include "map.h" + +class FitsShareID : public virtual FitsMap { +public: + FitsShareID(int, const char*); + virtual ~FitsShareID(); +}; + +class FitsShareKey : public virtual FitsMap { +public: + FitsShareKey(int, const char*); + virtual ~FitsShareKey(); +}; + +class FitsFitsShare : public virtual FitsMap, public FitsFitsMap { + public: + FitsFitsShare(ScanMode mode) : FitsMap(), FitsFitsMap(mode) {} +}; + +class FitsFitsNextShare : public FitsFitsNextMap { +public: + FitsFitsNextShare(FitsFile* prev) : FitsFitsNextMap(prev) {} +}; + +class FitsArrShare : public virtual FitsMap, public FitsArrMap { + public: + FitsArrShare() : FitsMap(), FitsArrMap() {} +}; + +class FitsNRRDShare : public virtual FitsMap, public FitsNRRDMap { + public: + FitsNRRDShare() : FitsMap(), FitsNRRDMap() {} +}; + +class FitsMosaicShare : public virtual FitsMap, public FitsMosaicMap { + public: + FitsMosaicShare() : FitsMap(), FitsMosaicMap() {} +}; + +class FitsMosaicNextShare : public FitsMosaicNextMap { +public: + FitsMosaicNextShare(FitsFile* prev) : FitsMosaicNextMap(prev) {} +}; + +class FitsFitsShareID : public FitsShareID, public FitsFitsShare { +public: + FitsFitsShareID(int shmid, const char* filter, ScanMode mode) + : FitsShareID(shmid, filter), FitsFitsShare(mode) {} +}; + +class FitsFitsShareKey : public FitsShareKey, public FitsFitsShare { +public: + FitsFitsShareKey(int key, const char* filter, ScanMode mode) + : FitsShareKey(key, filter), FitsFitsShare(mode) {} +}; + +class FitsArrShareID : public FitsShareID, public FitsArrShare { +public: + FitsArrShareID(int shmid, const char* filter) + : FitsShareID(shmid, filter), FitsArrShare() {} +}; + +class FitsArrShareKey : public FitsShareKey, public FitsArrShare { +public: + FitsArrShareKey(int key, const char* filter) + : FitsShareKey(key, filter), FitsArrShare() {} +}; + +class FitsNRRDShareID : public FitsShareID, public FitsNRRDShare { +public: + FitsNRRDShareID(int shmid, const char* filter) + : FitsShareID(shmid, filter), FitsNRRDShare() {} +}; + +class FitsNRRDShareKey : public FitsShareKey, public FitsNRRDShare { +public: + FitsNRRDShareKey(int key, const char* filter) + : FitsShareKey(key, filter), FitsNRRDShare() {} +}; + +class FitsMosaicShareID : public FitsShareID, public FitsMosaicShare { +public: + FitsMosaicShareID(int shmid) : FitsShareID(shmid, ""), FitsMosaicShare() {} +}; + +class FitsMosaicShareKey : public FitsShareKey, public FitsMosaicShare { +public: + FitsMosaicShareKey(int key) : FitsShareKey(key, ""), FitsMosaicShare() {} +}; + +#endif diff --git a/tksao/fitsy++/shmload.C b/tksao/fitsy++/shmload.C new file mode 100644 index 0000000..5099e41 --- /dev/null +++ b/tksao/fitsy++/shmload.C @@ -0,0 +1,84 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +using namespace std; + +main(int argc, char* argv[]) +{ + int q=0; + + // check for args + if (argc != 2 && argc != 3){ + cerr << "usage: shmload [-q] fits" << endl; + exit(1); + } + + if (!strncmp(argv[1],"-q",2)) + q=1; + + // find the file + char* fn = argv[1+q]; + struct stat statb; + if (stat(fn, &statb) < 0){ + cerr << "can't find file: " << fn << endl; + exit(1); + } + size_t fnsize = statb.st_size; + if (!q) + cerr << fn << " size " << fnsize << endl; + + // calculate shmsize + size_t shmsize = ((fnsize/2880)+1)*2880; + + // get shmid + int shmid = shmget(IPC_PRIVATE, shmsize, IPC_CREAT|0666); + + if (shmid == -1) { + // give up, its bad + perror("shmid is bad"); + exit(1); + } + if (!q) + cerr << "shmid " << shmid << endl; + else + cout << shmid << endl; + + // get shm stats + struct shmid_ds sbuf; + if (shmctl(shmid, IPC_STAT, &sbuf)<0) { + perror("shmctl is bad"); + exit(1); + } + if (!q) + cerr << "size of shared segment: " << sbuf.shm_segsz << endl; + + char* addr = (char*)shmat(shmid, NULL, 0); + // if (addr == -1){ + // perror("shmat failed"); + // exit(1); + // } + + // load image + ifstream fd(fn); + fd.read(addr,fnsize); + if (!q) { + cerr << fd.gcount() << " bytes read" << endl; + if (fd.gcount() != fnsize) + cerr << "File read error" << endl; + else + cerr << "success!" << endl; + } +} + diff --git a/tksao/fitsy++/smap.C b/tksao/fitsy++/smap.C new file mode 100644 index 0000000..ae96743 --- /dev/null +++ b/tksao/fitsy++/smap.C @@ -0,0 +1,187 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "smap.h" +#include "head.h" + +FitsSMap::FitsSMap() +{ + hmapdata_ = NULL; + hmapsize_ = 0; + + mapdata_ = NULL; + mapsize_ = 0; +} + +FitsFitsSMap::FitsFitsSMap(FitsHead::Memory mem) +{ + if (!valid_) + return; + + // simple check for fits file + if (strncmp(hmapdata_,"SIMPLE ",8) && strncmp(hmapdata_,"XTENSION",8)) { + data_ = NULL; + + dataSize_ = 0; + dataSkip_ = 0; + + valid_ = 0; + } + + head_ = new FitsHead(hmapdata_, hmapsize_, mem); + if (head_->isValid()) { + data_ = mapdata_; + + dataSize_ = mapsize_; + dataSkip_ = 0; + + inherit_ = head_->inherit(); + valid_ = 1; + return; + } + else { + if (manageHead_ && head_) + delete head_; + head_ = NULL; + + if (managePrimary_ && primary_) + delete primary_; + primary_ = NULL; + + data_ = NULL; + + dataSize_ = 0; + dataSkip_ = 0; + + valid_ = 0; + } +} + +FitsENVISMap::FitsENVISMap() +{ + if (!valid_) + return; + + // reset + valid_ = 0; + + if (hmapsize_<=0 || hmapsize_>32768) + return; + + // header + { + char* buf = new char[hmapsize_+1]; + char* dptr = buf; + char* sptr = hmapdata_; + int cnt =0; + do { + *dptr++ = *sptr++; + cnt++; + } while (cntparseENVI(str); + delete [] buf; + + if (!valid_) + return; + + // reset + valid_ =0; + } + + // check to see if we have a nonzero width, height, and bitpix + if (!validParams()) + return; + + size_t ss = (size_t)pWidth_*pHeight_*pDepth_*abs(pBitpix_)/8; + + // sometimes, offset is not correct + if (pSkip_ == 0) { + if (mapsize_ > ss) + pSkip_ = mapsize_-ss; + } + + // check to see if dimensions equal mapped space + if (ss+pSkip_ > mapsize_) + return; + + // skip to start of data + data_ = mapdata_ + pSkip_; + + dataSize_ = mapsize_; + dataSkip_ = pSkip_; + + // new header + head_ = new FitsHead(pWidth_, pHeight_, pDepth_, pBitpix_); + if (!head_->isValid()) + return; + + // WCS? + if (pCRPIX3_ || pCRVAL3_ || pCDELT3_) { + head_->appendString("CTYPE1","LINEAR", NULL); + head_->appendReal("CRPIX1",1, 9, NULL); + head_->appendReal("CRVAL1",1, 9, NULL); + head_->appendReal("CDELT1",1, 9, NULL); + + head_->appendString("CTYPE2","LINEAR", NULL); + head_->appendReal("CRPIX2",1, 9, NULL); + head_->appendReal("CRVAL2",1, 9, NULL); + head_->appendReal("CDELT2",1, 9, NULL); + + head_->appendString("CTYPE3","WAVELENGTH", NULL); + head_->appendReal("CRPIX3",pCRPIX3_, 9, NULL); + head_->appendReal("CRVAL3",pCRVAL3_, 9, NULL); + head_->appendReal("CDELT3",pCDELT3_, 9, NULL); + } + + // do we byteswap? + setByteSwap(); + + // so far, so good + valid_ = 1; +} + +FitsFitsNextSMap::FitsFitsNextSMap(FitsFile* p) +{ + FitsSMap* prev = (FitsSMap*)p; + + primary_ = prev->primary(); + managePrimary_ = 0; + + head_ = prev->head(); + manageHead_ = 0; + + FitsImageHDU* hdu = (FitsImageHDU*)head_->hdu(); + data_ = (char*)prev->data() + hdu->imgbytes(); + dataSize_ = 0; + dataSkip_ = 0; + + ext_ = prev->ext(); + inherit_ = prev->inherit(); + byteswap_ = prev->byteswap(); + endian_ = prev->endian(); + valid_ = 1; + + pcoord_ = prev->pcoord(); + pxvalid_ = prev->pxvalid(); + pxmin_ = prev->pxmin(); + pxmax_ = prev->pxmax(); + pyvalid_ = prev->pyvalid(); + pymin_ = prev->pymin(); + pymax_ = prev->pymax(); + pzvalid_ = prev->pzvalid(); + pzmin_ = prev->pzmin(); + pzmax_ = prev->pzmax(); + pbvalid_ = prev->pbvalid(); + pblock_ = prev->pblock(); + + mapdata_ = prev->mapdata(); + mapsize_ = prev->mapsize(); + + return; +} + diff --git a/tksao/fitsy++/smap.h b/tksao/fitsy++/smap.h new file mode 100644 index 0000000..cabd0c1 --- /dev/null +++ b/tksao/fitsy++/smap.h @@ -0,0 +1,49 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitssmap_h__ +#define __fitssmap_h__ + +#include "file.h" + +class FitsSMap : public FitsFile { +protected: + char* hmapdata_; + size_t hmapsize_; + + char* mapdata_; + size_t mapsize_; + +public: + FitsSMap(); + virtual ~FitsSMap() {} + + char* mapdata() {return mapdata_;} + size_t mapsize() {return mapsize_;} +}; + +class FitsFitsSMap : public virtual FitsSMap { +public: + FitsFitsSMap(FitsHead::Memory); +}; + +class FitsENVISMap : public virtual FitsSMap { +public: + FitsENVISMap(); +}; + +class FitsFitsNextSMap : public FitsSMap { +public: + FitsFitsNextSMap(FitsFile* prev); +}; + +#endif + + + + + + + + diff --git a/tksao/fitsy++/smmap.C b/tksao/fitsy++/smmap.C new file mode 100644 index 0000000..e1c1fcc --- /dev/null +++ b/tksao/fitsy++/smmap.C @@ -0,0 +1,105 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "smmap.h" + +#ifndef __WIN32 + +#include + +#include +#include +#include +#include + +FitsSMMap::FitsSMMap(const char* hdr, const char* fn) +{ + // reset + valid_ =0; + + // header + { + // Map the header. + int file = open(hdr, O_RDONLY); + if (file == -1) + return; + + struct stat info; + if (fstat(file, &info) < 0) + return; + + // check for empty file + if (info.st_size == 0) + return; + + // map it + hmapsize_ = info.st_size; + hmapdata_ = (char*)mmap(NULL, hmapsize_, PROT_READ, MAP_SHARED, file, 0); + + // close the file + close(file); + + // are we valid? + if ((long)hmapdata_ == -1) + return; + } + + // data + { + // parse the fn and options + parse(fn); + if (!valid_) + return; + + // reset + valid_ =0; + + if (!pName_) + return; + + // Map the file. + int file = open(pName_, O_RDONLY); + if (file == -1) + return; + + struct stat info; + if (fstat(file, &info) < 0) + return; + + // check for empty file + if (info.st_size == 0) + return; + + // map it + mapsize_ = info.st_size; + mapdata_ = (char*)mmap(NULL, mapsize_, PROT_READ, MAP_SHARED, file, 0); + + // close the file + close(file); + + // are we valid? + if ((long)mapdata_ == -1) + return; + } + + // so far, so good + valid_ = 1; +} + +FitsSMMap::~FitsSMMap() +{ + if (mapdata_>0) + munmap((caddr_t)mapdata_, mapsize_); +} + +#else + +FitsSMMap::FitsSMMap(const char* hdr, const char* fn) +{ + valid_ =0; +} + +FitsSMMap::~FitsSMMap() {} + +#endif diff --git a/tksao/fitsy++/smmap.h b/tksao/fitsy++/smmap.h new file mode 100644 index 0000000..698aaa3 --- /dev/null +++ b/tksao/fitsy++/smmap.h @@ -0,0 +1,33 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitssmmap_h__ +#define __fitssmmap_h__ + +#include "smap.h" + +class FitsSMMap : public virtual FitsSMap { +public: + FitsSMMap(const char*, const char*); + virtual ~FitsSMMap(); +}; + +class FitsFitsSMMap : public FitsSMMap, public FitsFitsSMap { +public: + FitsFitsSMMap(const char* hdr, const char* fn) + : FitsSMMap(hdr,fn), FitsFitsSMap(FitsHead::MMAP) {} +}; + +class FitsENVISMMap : public FitsSMMap, public FitsENVISMap { +public: + FitsENVISMMap(const char* hdr, const char* fn) : + FitsSMMap(hdr,fn), FitsENVISMap() {} +}; + +class FitsFitsNextSMMap : public FitsFitsNextSMap { +public: + FitsFitsNextSMMap(FitsFile* prev) : FitsFitsNextSMap(prev) {} +}; + +#endif diff --git a/tksao/fitsy++/socket.C b/tksao/fitsy++/socket.C new file mode 100644 index 0000000..343fe87 --- /dev/null +++ b/tksao/fitsy++/socket.C @@ -0,0 +1,27 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "socket.h" + +#ifndef __WIN32 + +FitsSocket::FitsSocket(int s, const char* ext) +{ + parse(ext); + if (!valid_) + return; + + stream_ = s; + + valid_ = stream_ ? 1 : 0; +} + +#else + +FitsSocket::FitsSocket(int s, const char* ext) +{ + valid_ = 0; +} + +#endif diff --git a/tksao/fitsy++/socket.h b/tksao/fitsy++/socket.h new file mode 100644 index 0000000..f7b1e12 --- /dev/null +++ b/tksao/fitsy++/socket.h @@ -0,0 +1,51 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitssocket_h__ +#define __fitssocket_h__ + +#include "strm.h" + +class FitsSocket : public virtual FitsStream { +public: + FitsSocket(int, const char*); +}; + +class FitsFitsSocket : public FitsSocket, public FitsFitsStream { +public: + FitsFitsSocket(int s, const char* ext, ScanMode mode, FlushMode flush) + : FitsSocket(s, ext), FitsFitsStream(mode, flush) {} +}; + +class FitsFitsNextSocket : public FitsFitsNextStream { +public: + FitsFitsNextSocket(FitsFile* prev) : FitsFitsNextStream(prev) {} +}; + +class FitsArrSocket : public FitsSocket, public FitsArrStream { +public: + FitsArrSocket(int s, const char* ext, FlushMode flush) + : FitsSocket(s, ext), FitsArrStream(flush) {} +}; + +class FitsNRRDSocket : public FitsSocket, public FitsNRRDStream { +public: + FitsNRRDSocket(int s, const char* ext, FlushMode flush) + : FitsSocket(s, ext), FitsNRRDStream(flush) {} +}; + +class FitsMosaicSocket : public FitsSocket, public FitsMosaicStream { +public: + FitsMosaicSocket(int s, FlushMode flush) + : FitsSocket(s, ""), FitsMosaicStream(flush) {} +}; + +class FitsMosaicNextSocket : public FitsMosaicNextStream { +public: + FitsMosaicNextSocket(FitsFile* prev, FlushMode flush) + : FitsMosaicNextStream(prev, flush) {} +}; + +#endif + diff --git a/tksao/fitsy++/socketgz.C b/tksao/fitsy++/socketgz.C new file mode 100644 index 0000000..8bd28af --- /dev/null +++ b/tksao/fitsy++/socketgz.C @@ -0,0 +1,141 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "socketgz.h" + +#ifndef __WIN32 + +#include +#include + +#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ +#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ +#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ +#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ +#define COMMENT 0x10 /* bit 4 set: file comment present */ +#define RESERVED 0xE0 /* bits 5..7: reserved */ + +FitsSocketGZ::FitsSocketGZ(int s, const char* ext) +{ + parse(ext); + if (!valid_) + return; + + // reset + valid_ =0; + + if (!s) + return; + + stream_ = new gzStream_; + stream_->id = s; + stream_->transparent = 0; + memset(stream_->header,'\0',2); + stream_->useHeader = 0; + stream_->buf = new unsigned char[B4KB]; + + // magic bytes + if (recv(stream_->id , stream_->header, 2, 0) != 2) { + internalError("Fitsy++ socketgz can't read magic bytes in header"); + return; + } + + if (stream_->header[0] != 0x1f || stream_->header[1] != 0x8b) { + stream_->transparent = 1; + stream_->useHeader = 1; + } + else { + ((z_stream*)stream_)->next_in = NULL; + ((z_stream*)stream_)->avail_in = 0; + ((z_stream*)stream_)->zalloc = NULL; + ((z_stream*)stream_)->zfree = NULL; + ((z_stream*)stream_)->opaque = NULL; + + if (inflateInit2((z_stream*)stream_, -MAX_WBITS) != Z_OK) { + internalError("Fitsy++ socketgz inflateInit error"); + return; + } + + unsigned char buf[128]; + + // method/flags + if (recv(stream_->id , buf, 2, 0) != 2) { + internalError("Fitsy++ socketgz can't read method/flags bytes in header"); + return; + } + int method = buf[0]; + int flags = buf[1]; + + if (method != Z_DEFLATED || (flags & RESERVED) != 0) { + internalError("Fitsy++ socketgz bad method/flags"); + return; + } + + // Discard time, xflags and OS code + if (recv(stream_->id , buf, 6, 0) != 6) { + internalError("Fitsy++ socketgz can't read time/xflags/os bytes in header"); + return; + } + + // skip the extra field + if ((flags & EXTRA_FIELD) != 0) { + if (recv(stream_->id , buf, 2, 0) != 2) { + internalError("Fitsy++ socketgz can't read extra field length bytes in header"); + return; + } + + int len = buf[0]; + len += buf[1]<<8; + + if (recv(stream_->id , buf, len, 0) != len) { + internalError("Fitsy++ socketgz can't read extra field bytes in header"); + return; + } + } + + // skip the original file name + if ((flags & ORIG_NAME) != 0) { + while (recv(stream_->id , buf, 1, 0) == 1 && buf[0] != 0) ; + } + + // skip the .gz file comment + if ((flags & COMMENT) != 0) { + while (recv(stream_->id , buf, 1, 0) == 1 && buf[0] != 0) ; + } + + // skip the header crc + if ((flags & HEAD_CRC) != 0) { + if (recv(stream_->id , buf, 2, 0) != 2) { + internalError("Fitsy++ socketgz can't read header crc bytes in header"); + return; + } + } + } + + if (DebugGZ) + cerr << "inflateInt Complete" << endl; + + // so far, so good + valid_ = 1; +} + +FitsSocketGZ::~FitsSocketGZ() +{ + if (stream_->buf) + delete [] stream_->buf; + if (stream_) + delete stream_; + stream_ = NULL; +} + +#else + +FitsSocketGZ::FitsSocketGZ(int s, const char* ext) +{ + valid_ =0; +} + +FitsSocketGZ::~FitsSocketGZ() {} + +#endif diff --git a/tksao/fitsy++/socketgz.h b/tksao/fitsy++/socketgz.h new file mode 100644 index 0000000..05d14b7 --- /dev/null +++ b/tksao/fitsy++/socketgz.h @@ -0,0 +1,48 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitssocketgz_h__ +#define __fitssocketgz_h__ + +#include "strm.h" + +class FitsSocketGZ : public virtual FitsStream { +public: + FitsSocketGZ(int, const char*); + virtual ~FitsSocketGZ(); +}; + +class FitsFitsSocketGZ : public FitsSocketGZ, + public FitsFitsStream { +public: + FitsFitsSocketGZ(int s, const char* ext, ScanMode mode, FlushMode flush) + : FitsSocketGZ(s, ext), FitsFitsStream(mode, flush) {} +}; + +class FitsFitsNextSocketGZ : public FitsFitsNextStream { +public: + FitsFitsNextSocketGZ(FitsFile* prev) : FitsFitsNextStream(prev) {} +}; + +class FitsArrSocketGZ : public FitsSocketGZ, public FitsArrStream { +public: + FitsArrSocketGZ(int s, const char* ext, FlushMode flush) + : FitsSocketGZ(s, ext), FitsArrStream(flush) {} +}; + +class FitsMosaicSocketGZ : public FitsSocketGZ, + public FitsMosaicStream { +public: + FitsMosaicSocketGZ(int s, FlushMode flush) + : FitsSocketGZ(s, ""), FitsMosaicStream(flush) {} +}; + +class FitsMosaicNextSocketGZ : public FitsMosaicNextStream { +public: + FitsMosaicNextSocketGZ(FitsFile* prev, FlushMode flush) + : FitsMosaicNextStream(prev, flush) {} +}; + +#endif + diff --git a/tksao/fitsy++/sshare.C b/tksao/fitsy++/sshare.C new file mode 100644 index 0000000..37e3080 --- /dev/null +++ b/tksao/fitsy++/sshare.C @@ -0,0 +1,148 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "sshare.h" + +#if (HAVE_SYS_SHM_H && !__WIN32) +#include +#include +#include + +FitsSShareID::FitsSShareID(int hdrid, int shmid, const char* filter) +{ + // reset + valid_ =0; + + { + // find size + struct shmid_ds info; + if (shmctl(hdrid, IPC_STAT, &info)) { + internalError("Fitsy++ sshare shctl failed"); + return; + } + hmapsize_ = info.shm_segsz; + + // Attach the memory segment + if ((long)(hmapdata_ = (char*)shmat(hdrid, 0, SHM_RDONLY)) == -1) { + internalError("Fitsy++ sshare shmat failed"); + return; + } + } + + { + parse(filter); + if (!valid_) + return; + + // reset + valid_ =0; + + // find size + struct shmid_ds info; + if (shmctl(shmid, IPC_STAT, &info)) { + internalError("Fitsy++ sshare shctl failed"); + return; + } + mapsize_ = info.shm_segsz; + + // Attach the memory segment + if ((long)(mapdata_ = (char*)shmat(shmid, 0, SHM_RDONLY)) == -1) { + internalError("Fitsy++ sshare shmat failed"); + return; + } + } + + // so far so good + valid_ = 1; +} + +FitsSShareID::~FitsSShareID() +{ + shmdt(mapdata_); +} + +FitsSShareKey::FitsSShareKey(int hdr, int key, const char* filter) +{ + // reset + valid_ =0; + + { + // get shmid + int shmid; + if ((shmid = shmget(hdr, 0, 0)) < 0) { + internalError("Fitsy++ sshare shmget failed"); + return; + } + + // find size + struct shmid_ds info; + if (shmctl(shmid, IPC_STAT, &info)) { + internalError("Fitsy++ sshare shctl failed"); + return; + } + mapsize_ = info.shm_segsz; + + // Attach the memory segment + if ((long)(mapdata_ = (char*)shmat(shmid, 0, SHM_RDONLY)) == -1) { + internalError("Fitsy++ sshare shmat failed"); + return; + } + } + + { + parse(filter); + if (!valid_) + return; + + // reset + valid_ =0; + + // get shmid + int shmid; + if ((shmid = shmget(key, 0, 0)) < 0) { + internalError("Fitsy++ sshare shmget failed"); + return; + } + + // find size + struct shmid_ds info; + if (shmctl(shmid, IPC_STAT, &info)) { + internalError("Fitsy++ sshare shmctl failed"); + return; + } + mapsize_ = info.shm_segsz; + + // Attach the memory segment + if ((long)(mapdata_ = (char*)shmat(shmid, 0, SHM_RDONLY)) == -1) { + internalError("Fitsy++ sshare shmat failed"); + return; + } + } + + // so far so good + valid_ = 1; +} + +FitsSShareKey::~FitsSShareKey() +{ + shmdt(mapdata_); +} + +#else + +FitsSShareID::FitsSShareID(int hdrid, int shmid, const char* filter) +{ + valid_ = 0; +} + +FitsSShareID::~FitsSShareID() {} + +FitsSShareKey::FitsSShareKey(int hdr, int key, const char* filter) +{ + valid_ = 0; +} + +FitsSShareKey::~FitsSShareKey() {} + +#endif diff --git a/tksao/fitsy++/sshare.h b/tksao/fitsy++/sshare.h new file mode 100644 index 0000000..bb10fc6 --- /dev/null +++ b/tksao/fitsy++/sshare.h @@ -0,0 +1,44 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitssshare_h__ +#define __fitssshare_h__ + +#include "smap.h" + +class FitsSShareID : public virtual FitsSMap { +public: + FitsSShareID(int, int, const char*); + virtual ~FitsSShareID(); +}; + +class FitsSShareKey : public virtual FitsSMap { +public: + FitsSShareKey(int, int, const char*); + virtual ~FitsSShareKey(); +}; + +class FitsFitsSShare : public virtual FitsSMap, public FitsFitsSMap { + public: + FitsFitsSShare() : FitsSMap(), FitsFitsSMap(FitsHead::SHARE) {} +}; + +class FitsFitsNextSShare : public FitsFitsNextSMap { +public: + FitsFitsNextSShare(FitsFile* prev) : FitsFitsNextSMap(prev) {} +}; + +class FitsFitsSShareID : public FitsSShareID, public FitsFitsSShare { +public: + FitsFitsSShareID(int hdrid, int shmid, const char* filter) + : FitsSShareID(hdrid, shmid, filter), FitsFitsSShare() {} +}; + +class FitsFitsSShareKey : public FitsSShareKey, public FitsFitsSShare { +public: + FitsFitsSShareKey(int hdr, int key, const char* filter) + : FitsSShareKey(hdr, key, filter), FitsFitsSShare() {} +}; + +#endif diff --git a/tksao/fitsy++/strm.C b/tksao/fitsy++/strm.C new file mode 100644 index 0000000..0c6df95 --- /dev/null +++ b/tksao/fitsy++/strm.C @@ -0,0 +1,803 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include + +#ifndef __WIN32 +#include +#endif + +#include + +#include "strm.h" +#include "util.h" + +template FitsStream::FitsStream() +{ + stream_ =0; + flush_ = NOFLUSH; + dataManage_ = 0; +} + +template FitsStream::~FitsStream() +{ + if (dataManage_ && data_) + delete [] (T*)data_; +} + +// FILE* + +template <> size_t FitsStream::read(char* where, size_t size) +{ + // size_t size is unsigned + long long ss =size; + size_t rr = 0; + int r = 0; + + do { + r = fread(where+rr, 1, (ss>B1MB) ? B1MB : ss, stream_); + ss -= r; + rr += r; + } while (r>0 && rr void FitsStream::close() +{ + fclose(stream_); +} + +// Socket + +#ifndef __WIN32 + +template <> size_t FitsStream::read(char* where, size_t size) +{ + // size_t size is unsigned + long long ss =size; + size_t rr =0; + int r; + + do { + r = recv(stream_ , where+rr, (ss>B4KB) ? B4KB : ss, 0); + ss -= r; + rr += r; + } while (r>0 && rr size_t FitsStream::read(char* where, size_t size) +{ + return 0; +} + +#endif + +template <> void FitsStream::close() {} + +// gzStream + +#ifndef __WIN32 + +template <> size_t FitsStream::read(char* where, size_t size) +{ + // size_t size is unsigned + long long ss =size; + size_t rr = 0; + int r = 0; + + if (stream_->transparent) { + if (stream_->useHeader) { + memcpy(where,stream_->header,2); + ss -= 2; + rr += 2; + stream_->useHeader = 0; + } + + do { + r = recv(stream_->id , where+rr, (ss>B4KB) ? B4KB : ss, 0); + ss -= r; + rr += r; + } while (r>0 && rravail_out = size; + ((z_stream*)stream_)->next_out = (unsigned char*)where; + + if (DebugGZ) + cerr << "***read init " << ((z_stream*)stream_)->avail_out + << " bytes" << endl; + + do { + if (((z_stream*)stream_)->avail_in == 0) { + ((z_stream*)stream_)->next_in = stream_->buf; + int aa = recv(stream_->id , stream_->buf, B4KB, 0); + if (aa<0) + return rr; + + ((z_stream*)stream_)->avail_in = aa; + if (DebugGZ) + cerr << " read from socket " << aa << " bytes" << endl; + } + + if (DebugGZ) + cerr << " inflate Start: avail_in " + << ((z_stream*)stream_)->avail_in + << " avail_out " << ((z_stream*)stream_)->avail_out << endl; + + int before = ((z_stream*)stream_)->avail_out; + int result = inflate(((z_stream*)stream_), Z_NO_FLUSH); + r = before - ((z_stream*)stream_)->avail_out; + rr += r; + + switch (result) { + case Z_OK: + if (DebugGZ) + cerr << " inflate OK: avail_in " << ((z_stream*)stream_)->avail_in + << " avail_out " << ((z_stream*)stream_)->avail_out << endl; + break; + case Z_STREAM_END: + if (DebugGZ) + cerr << " inflate STRM_END: avail_in " + << ((z_stream*)stream_)->avail_in + << " avail_out " << ((z_stream*)stream_)->avail_out + << " total_in " << ((z_stream*)stream_)->total_in + << " total_out " << ((z_stream*)stream_)->total_out << endl; + return rr; + default: + internalError("Fitsy++ strm inflate error"); + return rr; + } + } while (r>0 && rr void FitsStream::close() +{ + if (!stream_->transparent) { + if (inflateEnd((z_stream*)stream_) != Z_OK) + internalError("Fitsy++ strm inflateEnd error"); + + if (DebugGZ) + cerr << "inflateEnd: avail_in " << ((z_stream*)stream_)->avail_in + << " avail_out " << ((z_stream*)stream_)->avail_out << endl; + } +} + +#else + +template <> size_t FitsStream::read(char* where, size_t size) +{ + return 0; +} +template <> void FitsStream::close() {} + +#endif + +// Tcl_Channel + +template <> size_t FitsStream::read(char* where, size_t size) +{ + // size_t size is unsigned + long long ss =size; + size_t rr = 0; + int r = 0; + + do { + r = Tcl_Read(stream_, where+rr, (ss>B1MB) ? B1MB : ss); + ss -= r; + rr += r; + } while (r>0 && rr void FitsStream::close() {} + +// gzFile + +template <> size_t FitsStream::read(char* where, size_t size) +{ + // size_t size is unsigned + long long ss =size; + size_t rr = 0; + int r = 0; + + do { + r = gzread(stream_, where+rr, (ss>B1MB) ? B1MB : ss); + ss -= r; + rr += r; + } while (r>0 && rr void FitsStream::close() +{ + gzclose(stream_); +} + +template FitsHead* FitsStream::headRead() +{ + // read first block + char* cards = new char[FTY_BLOCK]; + if (!cards) + return NULL; + + memset(cards, ' ', FTY_BLOCK); + if (read(cards, FTY_BLOCK) != FTY_BLOCK) { + delete [] cards; + return NULL; + } + + // simple FITS file check + if (strncmp(cards, "SIMPLE =", 9) && strncmp(cards, "XTENSION=", 9)) { + delete [] cards; + return NULL; + } + + // read remaining blocks + int numblks = 1; + char* current = cards; + while (1) { + if (findEnd(current)) + break; + + // this is check + // for TCL channels, the stream gets corrupted, so END is never found + // so bail out after an extreme number of blocks have been read + // + // this does not work because some fits files have 100's or 1000's of + // history/comments. lets hope a corrupted stream is caught below + // if (numblks>10) { + // delete [] cards; + // return NULL; + // } + + char* tmp = new char[(numblks+1)*FTY_BLOCK]; + memcpy(tmp, cards, numblks*FTY_BLOCK); + delete [] cards; + cards = tmp; + current = cards + numblks*FTY_BLOCK; + memset(current, ' ', FTY_BLOCK); + + if (read(current, FTY_BLOCK) != FTY_BLOCK) { + delete [] cards; + return NULL; + } + + numblks++; + } + + // create header + FitsHead* fits = new FitsHead(cards, numblks*FTY_BLOCK, FitsHead::ALLOC); + if (!fits->isValid()) { + delete fits; + return NULL; + } + + return fits; +} + +template int FitsStream::dataRead(size_t bytes, int validate) +{ + data_ = NULL; + + dataSize_ = 0; + dataSkip_ = 0; + dataManage_ = 0; + + if (!bytes) + return 0; + + data_ = new char[bytes]; + if (!data_) + return 0; + + size_t rr = read((char*)data_, bytes); + if (validate && rr != bytes) { + delete (char*)data_; + data_ = NULL; + + dataSize_ = 0; + dataSkip_ = 0; + dataManage_ = 0; + + return 0; + } + + dataSize_ = bytes; + dataManage_ = 1; + + return 1; +} + +template void FitsStream::dataSkip(size_t bytes) +{ + // size_t bytes is unsigned + if (bytes) { + char block[FTY_BLOCK]; + + do { + read(block, (bytes < FTY_BLOCK ? bytes : FTY_BLOCK)); + if (bytes>FTY_BLOCK) + bytes -= FTY_BLOCK; + else + break; + } while (1); + } +} + +template void FitsStream::dataSkipBlock(size_t blk) +{ + char block[FTY_BLOCK]; + for (size_t ii=0; ii void FitsStream::skipEnd() +{ + char block[FTY_BLOCK]; + + int bytes; + do + bytes = read(block, FTY_BLOCK); + while (bytes > 0); +} + +template void FitsStream::found() +{ + // only read allbytes, since the data seg maybe short + if (!this->dataRead(head_->allbytes())) { + error(); + return; + } + + // read any dead space til next block + if (head_->padbytes()>0) + this->dataSkip(head_->padbytes()); + + inherit_ = head_->inherit(); + valid_ = 1; + + if (flush_ == FLUSH) + skipEnd(); +} + +template void FitsStream::error() +{ + // try to clean up + if ((flush_ == FLUSH) && (head_ || primary_)) + skipEnd(); + + if (manageHead_ && head_) + delete head_; + head_ = NULL; + + if (managePrimary_ && primary_) + delete primary_; + primary_ = NULL; + + data_ = NULL; + + dataSize_ = 0; + dataSkip_ = 0; + dataManage_ = 0; + + valid_ = 0; +} + +template class FitsStream; +template class FitsStream; +template class FitsStream; +template class FitsStream; +template class FitsStream; + +template FitsFitsStream::FitsFitsStream(FitsFile::ScanMode mode, + FitsFile::FlushMode f) +{ + if (!this->valid_) + return; + + this->flush_ = f; + + if (mode == this->EXACT || this->pExt_ || this->pIndex_>-1) + processExact(); + else + processRelax(); +} + +template void FitsFitsStream::processExact() +{ + if (!(this->pExt_ || (this->pIndex_>0))) { + + // we are only looking for a primary image + if ((this->head_ = this->headRead())) { + this->found(); + return; + } + } + else { + + // we are looking for an extension + // keep the primary header + this->primary_ = this->headRead(); + this->managePrimary_ = 1; + if (!this->primary_) { + this->error(); + return; + } + this->dataSkipBlock(this->primary_->datablocks()); + + if (this->pExt_) { + while (1) { + if (!(this->head_ = this->headRead())) { + this->error(); + return; + } + this->ext_++; + + if (this->head_->extname()) { + char* a = toUpper(this->head_->extname()); + char* b = toUpper(this->pExt_); + if (!strncmp(a,b,strlen(b))) { + delete [] a; + delete [] b; + this->found(); + return; + } + delete [] a; + delete [] b; + } + + this->dataSkipBlock(this->head_->datablocks()); + delete this->head_; + this->head_ = NULL; + } + } + else { + for (int i=1; ipIndex_; i++) { + if (!(this->head_ = this->headRead())) { + this->error(); + return; + } + this->ext_++; + + this->dataSkipBlock(this->head_->datablocks()); + delete this->head_; + this->head_ = NULL; + } + + if ((this->head_ = this->headRead())) { + this->ext_++; + this->found(); + return; + } + } + } + + // we must have an error + this->error(); +} + +template void FitsFitsStream::processRelax() +{ + // check to see if there is an image in the primary + if (!(this->head_ = this->headRead())) { + this->error(); + return; + } + else { + if (this->head_->isValid() && + this->head_->naxes() > 0 && + this->head_->naxis(0) > 0 && + this->head_->naxis(1) > 0) { + this->found(); + return; + } + } + + // ok, no image, save primary and lets check extensions + this->primary_ = this->head_; + this->managePrimary_ = 1; + this->dataSkipBlock(this->head_->datablocks()); + this->head_ = NULL; + + // ok, no image, lets check extensions + while (1) { + if (!(this->head_ = this->headRead())) { + this->error(); + return; + } + this->ext_++; + + if (this->head_->isImage()) { + this->found(); + return; + } + + // else, check for compressed image + if (this->head_->isBinTable() && this->head_->find("ZIMAGE")) { + this->found(); + return; + } + + // else, check for bin table named STDEVT, EVENTS, RAYEVENT + if (this->head_->isBinTable() && this->head_->extname()) { + char* a = toUpper(this->head_->extname()); + if (!strncmp("STDEVT", a, 6) || + !strncmp("EVENTS", a, 6) || + !strncmp("RAYEVENT", a, 8)) { + delete [] a; + this->found(); + return; + } + else + delete [] a; + } + + // else, check for bin table with keyword PIXTYPE = 'HEALPIX ' + if (this->head_->isBinTable() && this->head_->find("PIXTYPE") && + (!strncmp(this->head_->getString("PIXTYPE"),"HEALPIX",4))) { + this->found(); + return; + } + + // else, check for bin table with keyword NSIDE (also HEALPIX) + if (this->head_->isBinTable() && this->head_->find("NSIDE")) { + this->found(); + return; + } + + this->dataSkipBlock(this->head_->datablocks()); + delete this->head_; + this->head_ = NULL; + } + + this->error(); +} + +template class FitsFitsStream; +template class FitsFitsStream; +template class FitsFitsStream; +template class FitsFitsStream; +template class FitsFitsStream; + +template FitsFitsNextStream::FitsFitsNextStream(FitsFile* p) +{ + FitsStream* prev = (FitsStream*)p; + + this->primary_ = prev->primary(); + this->managePrimary_ = 0; + + this->head_ = prev->head(); + this->manageHead_ = 0; + + FitsImageHDU* hdu = (FitsImageHDU*)this->head_->hdu(); + this->data_ = (char*)prev->data() + hdu->imgbytes(); + this->dataSize_ = 0; + this->dataSkip_ = 0; + + this->ext_ = prev->ext(); + this->inherit_ = prev->inherit(); + this->byteswap_ = prev->byteswap(); + this->endian_ = prev->endian(); + this->valid_ = 1; + + this->pcoord_ = prev->pcoord(); + this->pxvalid_ = prev->pxvalid(); + this->pxmin_ = prev->pxmin(); + this->pxmax_ = prev->pxmax(); + this->pyvalid_ = prev->pyvalid(); + this->pymin_ = prev->pymin(); + this->pymax_ = prev->pymax(); + this->pzvalid_ = prev->pzvalid(); + this->pzmin_ = prev->pzmin(); + this->pzmax_ = prev->pzmax(); + this->pbvalid_ = prev->pbvalid(); + this->pblock_ = prev->pblock(); + + this->stream_ = prev->stream(); + this->flush_ = prev->flush(); + this->dataManage_ = 0; +} + +template class FitsFitsNextStream; +template class FitsFitsNextStream; +template class FitsFitsNextStream; +template class FitsFitsNextStream; +template class FitsFitsNextStream; + +template FitsArrStream::FitsArrStream(FitsFile::FlushMode f) +{ + if (!this->valid_) + return; + + this->flush_ = f; + + this->valid_=0; + + // check to see if we have a nonzero width, height, and bitpix + if (!this->validParams()) { + return; + } + + // skip header + if (this->pSkip_) + this->dataSkip(this->pSkip_); + + // read data + if (!this->dataRead((size_t)this->pWidth_*this->pHeight_*this->pDepth_*abs(this->pBitpix_)/8)) { + if ((this->flush_ == this->FLUSH) && this->data_) + this->skipEnd(); + return; + } + + // create blank header + this->head_ = new FitsHead(this->pWidth_, this->pHeight_, + this->pDepth_, this->pBitpix_); + if (!this->head_->isValid()) { + this->error(); + return; + } + + // do we need to byteswap? + this->setByteSwap(); + + // made it this far, must be good + this->valid_ = 1; + + if (this->flush_ == this->FLUSH) + this->skipEnd(); +} + +template class FitsArrStream; +template class FitsArrStream; +template class FitsArrStream; +template class FitsArrStream; +template class FitsArrStream; + +template FitsNRRDStream::FitsNRRDStream(FitsFile::FlushMode f) +{ + if (!this->valid_) + return; + + this->flush_ = f; + + this->valid_=0; + + // header + { + char buf[1024]; + char* dptr = buf; + int cnt =0; + do { + int cc = this->read(dptr,1); + if (cc != 1 || (*dptr == '\n' && *(dptr-1) == '\n')) { + break; + } + cnt++; + dptr++; + } while (cnt<1024); + *dptr = '\0'; + + string x(buf); + istringstream str(x); + this->parseNRRD(str); + } + + // check to see if we have a nonzero width, height, and bitpix + if (!this->validParams()) + return; + + // read data + this->dataRead((size_t)this->pWidth_*this->pHeight_*this->pDepth_*abs(this->pBitpix_)/8, 0); + + // create blank header + this->head_ = new FitsHead(this->pWidth_, this->pHeight_, + this->pDepth_, this->pBitpix_); + if (!this->head_->isValid()) { + this->error(); + return; + } + + // do we need to byteswap? + this->setByteSwap(); + + // made it this far, must be good + this->valid_ = 1; + + if (this->flush_ == this->FLUSH) + this->skipEnd(); +} + +template class FitsNRRDStream; +template class FitsNRRDStream; +template class FitsNRRDStream; +template class FitsNRRDStream; +template class FitsNRRDStream; + +template FitsMosaicStream::FitsMosaicStream(FitsFile::FlushMode f) +{ + if (!this->valid_) + return; + + this->flush_ = f; + this->primary_ = this->headRead(); + this->managePrimary_ = 1; + if (!(this->primary_ && this->primary_->isValid())) { + this->error(); + return; + } + this->dataSkipBlock(this->primary_->datablocks()); + + // first extension + this->head_ = this->headRead(); + if (!(this->head_ && this->head_->isValid())) { + this->error(); + return; + } + this->ext_++; + + // be sure to read all blocks, so that the next call starts on a boundary + if (!this->dataRead(this->head_->datablocks()*FTY_BLOCK)) { + this->error(); + return; + } + + // don't flush, more to come + this->inherit_ = this->head_->inherit(); + this->valid_ = 1; +} + +template class FitsMosaicStream; +template class FitsMosaicStream; +template class FitsMosaicStream; +template class FitsMosaicStream; +template class FitsMosaicStream; + +template FitsMosaicNextStream::FitsMosaicNextStream(FitsFile* p, + FitsFile::FlushMode f) +{ + this->flush_ = f; + FitsStream* prev = (FitsStream*)p; + this->primary_ = prev->primary(); + this->managePrimary_ = 0; + this->stream_ = prev->stream(); + this->ext_ = prev->ext(); + + this->head_ = this->headRead(); + if (!(this->head_ && this->head_->isValid())) { + this->error(); + return; + } + this->ext_++; + + // be sure to read all blocks, so that the next call starts on a boundary + if (!this->dataRead(this->head_->datablocks()*FTY_BLOCK)) { + this->error(); + return; + } + + this->inherit_ = this->head_->inherit(); + this->valid_ = 1; +} + +template class FitsMosaicNextStream; +template class FitsMosaicNextStream; +template class FitsMosaicNextStream; +template class FitsMosaicNextStream; +template class FitsMosaicNextStream; diff --git a/tksao/fitsy++/strm.h b/tksao/fitsy++/strm.h new file mode 100644 index 0000000..55ef4c0 --- /dev/null +++ b/tksao/fitsy++/strm.h @@ -0,0 +1,89 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsstream_h__ +#define __fitsstream_h__ + +#include "file.h" +#include "zlib.h" + +typedef struct gzStream_ { + z_stream zstream; + int id; + int transparent; + unsigned char header[2]; + int useHeader; + unsigned char* buf; +} *gzStream; + +template +class FitsStream : public FitsFile { + protected: + T stream_; + FitsFile::FlushMode flush_; + int dataManage_; // flag, true if we manage data + + FitsHead* headRead(); + int dataRead(size_t bytes, int validate =1); + void dataSkip(size_t); + void dataSkipBlock(size_t); + void skipEnd(); + + size_t read(char*, size_t); + void close(); + void found(); + void error(); + +public: + FitsStream(); + virtual ~FitsStream(); + + T stream() {return stream_;} + FitsFile::FlushMode flush() {return flush_;} + int dataManage() {return dataManage_;} + + void done() {close();} +}; + +template +class FitsFitsStream : public virtual FitsStream { +protected: + void processExact(); + void processRelax(); + +public: + FitsFitsStream(FitsFile::ScanMode, FitsFile::FlushMode); +}; + +template +class FitsFitsNextStream : public FitsStream { +public: + FitsFitsNextStream(FitsFile* prev); +}; + +template +class FitsArrStream : public virtual FitsStream { +public: + FitsArrStream(FitsFile::FlushMode); +}; + +template +class FitsNRRDStream : public virtual FitsStream { +public: + FitsNRRDStream(FitsFile::FlushMode); +}; + +template +class FitsMosaicStream : public virtual FitsStream { +public: + FitsMosaicStream(FitsFile::FlushMode); +}; + +template +class FitsMosaicNextStream : public FitsStream { +public: + FitsMosaicNextStream(FitsFile* prev, FitsFile::FlushMode); +}; + +#endif diff --git a/tksao/fitsy++/var.C b/tksao/fitsy++/var.C new file mode 100644 index 0000000..6f01222 --- /dev/null +++ b/tksao/fitsy++/var.C @@ -0,0 +1,53 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "var.h" + +FitsVar::FitsVar(Tcl_Interp* interp, const char* var, const char* fn) +{ + parse(fn); + if (!valid_) + return; + + // reset + valid_ =0; + + obj = Tcl_GetVar2Ex(interp, (char*)var, NULL, + TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG); + if (!obj) + return; + + // just in case + Tcl_ConvertToType(interp, obj, Tcl_GetObjType("bytearray")); + + typedef struct ByteArray { + int used; /* The number of bytes used in the byte + * array. */ + int allocated; /* The amount of space actually allocated + * minus 1 byte. */ + unsigned char bytes[4]; /* The array of bytes. The actual size of + * this field depends on the 'allocated' field + * above. */ + } ByteArray; + + ByteArray* ba = (ByteArray*)(obj->internalRep.otherValuePtr); + mapsize_ = ba->used; + mapdata_ = (char*)ba->bytes; + + Tcl_IncrRefCount(obj); + + // so far, so good + valid_ = 1; +} + +FitsVar::~FitsVar() +{ + if (obj) + Tcl_DecrRefCount(obj); +} + + + diff --git a/tksao/fitsy++/var.h b/tksao/fitsy++/var.h new file mode 100644 index 0000000..40286dc --- /dev/null +++ b/tksao/fitsy++/var.h @@ -0,0 +1,53 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsvar_h__ +#define __fitsvar_h__ + +#include "map.h" + +class FitsVar : public virtual FitsMap { + Tcl_Obj* obj; + +public: + FitsVar(Tcl_Interp*, const char*, const char*); + virtual ~FitsVar(); +}; + +class FitsFitsVar : public FitsVar, public FitsFitsMap { +public: + FitsFitsVar(Tcl_Interp* interp, const char* var, const char* fn, + ScanMode mode) + : FitsVar(interp, var, fn), FitsFitsMap(mode) {} +}; + +class FitsFitsNextVar : public FitsFitsNextMap { +public: + FitsFitsNextVar(FitsFile* prev) : FitsFitsNextMap(prev) {} +}; + +class FitsArrVar : public FitsVar, public FitsArrMap { +public: + FitsArrVar(Tcl_Interp* interp, const char* var, const char* fn) + : FitsVar(interp, var, fn), FitsArrMap() {} +}; + +class FitsNRRDVar : public FitsVar, public FitsNRRDMap { +public: + FitsNRRDVar(Tcl_Interp* interp, const char* var, const char* fn) + : FitsVar(interp, var, fn), FitsNRRDMap() {} +}; + +class FitsMosaicVar : public FitsVar, public FitsMosaicMap { +public: + FitsMosaicVar(Tcl_Interp* interp, const char* var, const char* fn) + : FitsVar(interp, var, fn), FitsMosaicMap() {} +}; + +class FitsMosaicNextVar : public FitsMosaicNextMap { +public: + FitsMosaicNextVar(FitsFile* prev) : FitsMosaicNextMap(prev) {} +}; + +#endif diff --git a/tksao/frame/annulus.C b/tksao/frame/annulus.C new file mode 100644 index 0000000..a1881bd --- /dev/null +++ b/tksao/frame/annulus.C @@ -0,0 +1,392 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "annulus.h" +#include "fitsimage.h" + +Annulus::Annulus(Base* p, const Vector& ctr, double r1, double r2, int rn) + : BaseEllipse(p, ctr, 0) +{ + numAnnuli_ = rn+1; + annuli_ = new Vector[numAnnuli_]; + + for (int i=0; i& tg, const List& cb) + : BaseEllipse(p, ctr, 0, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = rn+1; + annuli_ = new Vector[numAnnuli_]; + + for (int i=0; i& tg, const List& cb) + : BaseEllipse(p, ctr, 0, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = rn; + annuli_ = new Vector[numAnnuli_]; + + for (int i=0; ioptions->cmdName); + addCallBack(CallBack::EDITCB, analysisRadialCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITENDCB, analysisRadialCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisRadialCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisRadialCB_[1], + parent->options->cmdName); + } + if (analysisRadial_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisRadialCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisRadialCB_[0]); + deleteCallBack(CallBack::EDITENDCB, analysisRadialCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisRadialCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisRadialCB_[1]); + } + + analysisRadial_ = which; + break; + case STATS: + if (!analysisStats_ && which) { + addCallBack(CallBack::MOVECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITENDCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisStatsCB_[1], + parent->options->cmdName); + } + if (analysisStats_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITENDCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisStatsCB_[1]); + } + + analysisStats_ = which; + break; + default: + // na + break; + } +} + +void Annulus::analysisRadial(char* xname, char* yname, char* ename, + Coord::CoordSystem sys) +{ + double* xx; + double* yy; + double* ee; + + BBox* bb = new BBox[numAnnuli_]; + for (int ii=0; iimarkerAnalysisRadial(this, &xx, &yy, &ee, + numAnnuli_-1, annuli_, + bb, sys); + analysisXYEResult(xname, yname, ename, xx, yy, ee, num); +} + +void Annulus::analysisStats(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + ostringstream str; + BBox* bb = new BBox[numAnnuli_]; + for (int ii=0; iimarkerAnalysisStats(this, str, numAnnuli_-1, bb, sys, sky); + str << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +// list + +void Annulus::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 0); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listNonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' << setprecision(10) << vv + << setprecision(3) << fixed; + for (int ii=0; iimapLenFromRef(annuli_[ii][0],sys,Coord::ARCSEC); + str << ',' << rr << '"'; + } + str << ')'; + str.unsetf(ios_base::floatfield); + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' << ra << ',' << dec + << setprecision(3) << fixed; + for (int ii=0; iimapLenFromRef(annuli_[ii][0],sys,Coord::ARCSEC); + str << ',' << rr << '"'; + } + str << ')'; + str.unsetf(ios_base::floatfield); + break; + } + } + else + listNonCel(ptr, str, sys); + } + + listPost(str, conj, strip); +} + +void Annulus::listNonCel(FitsImage* ptr, ostream& str, Coord::CoordSystem sys) +{ + Vector vv = ptr->mapFromRef(center,sys); + str << type_ << '(' << setprecision(8) << vv; + for (int ii=0; iimapLenFromRef(annuli_[ii][0],sys); + str << ',' << rr; + } + str << ')'; +} + +void Annulus::listXML(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format) +{ + FitsImage* ptr = parent->findFits(sys,center); + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowCenter(ptr,sys,sky,format); + XMLRowRadiusX(ptr,sys,annuli_,numAnnuli_); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} + +void Annulus::listCiao(ostream& str, Coord::CoordSystem sys, int strip) +{ + FitsImage* ptr = parent->findFits(); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + Vector vv = ptr->mapFromRef(center,Coord::PHYSICAL); + for (int ii=0; iimapLenFromRef(annuli_[ii][0],Coord::PHYSICAL) << ',' + << ptr->mapLenFromRef(annuli_[ii+1][0],Coord::PHYSICAL) << ')'; + listCiaoPost(str, strip); + } + } + break; + default: + if (ptr->hasWCSCel(sys)) { + listRADEC(ptr,center,sys,Coord::FK5,Coord::SEXAGESIMAL); + for (int ii=0; iimapLenFromRef(annuli_[ii][0],sys,Coord::ARCMIN); + double r2 = ptr->mapLenFromRef(annuli_[ii+1][0],sys,Coord::ARCMIN); + str << type_ << '(' << ra << ',' << dec << ',' + << setprecision(5) << fixed + << r1 << '\'' << ',' << r2 << '\'' + << ')'; + str.unsetf(ios_base::floatfield); + listCiaoPost(str, strip); + } + } + } +} + +void Annulus::listPros(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + int strip) +{ + FitsImage* ptr = parent->findFits(); + + switch (sys) { + case Coord::IMAGE: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + sys = Coord::IMAGE; + case Coord::PHYSICAL: + { + Vector vv = ptr->mapFromRef(center,sys); + coord.listProsCoordSystem(str,sys,sky); + str << "; " << type_ << ' ' << setprecision(8) << vv; + for (int ii=0; iimapLenFromRef(annuli_[ii][0],Coord::IMAGE); + str << ' ' << rr; + } + } + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + coord.listProsCoordSystem(str,sys,sky); + str << "; " << type_ << ' ' << setprecision(10) << setunit('d') << vv + << setprecision(3) << fixed; + for (int ii=0; iimapLenFromRef(annuli_[ii][0],sys,Coord::ARCSEC); + str << ' ' << rr << '"'; + } + str.unsetf(ios_base::floatfield); + } + break; + case Coord::SEXAGESIMAL: + listRADECPros(ptr,center,sys,sky,format); + coord.listProsCoordSystem(str,sys,sky); + str << "; " << type_ << ' ' << ra << ' ' << dec + << setprecision(3) << fixed; + for (int ii=0; iimapLenFromRef(annuli_[ii][0],sys,Coord::ARCSEC); + str << ' ' << rr << '"'; + } + str.unsetf(ios_base::floatfield); + break; + } + } + } + + listProsPost(str, strip); +} + +void Annulus::listSAOimage(ostream& str, int strip) +{ + FitsImage* ptr = parent->findFits(); + listSAOimagePre(str); + + Vector vv = ptr->mapFromRef(center,Coord::IMAGE); + str << type_ << '(' << setprecision(8) << vv; + for (int ii=0; iimapLenFromRef(annuli_[ii][0],Coord::IMAGE); + str << ',' << rr; + } + str << ')'; + + listSAOimagePost(str, strip); +} + +// special composite funtionallity + +void Annulus::setComposite(const Matrix& mx, double aa) +{ + center *= mx; + updateBBox(); +} diff --git a/tksao/frame/annulus.h b/tksao/frame/annulus.h new file mode 100644 index 0000000..e09492d --- /dev/null +++ b/tksao/frame/annulus.h @@ -0,0 +1,54 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __annulus_h__ +#define __annulus_h__ + +#include "baseellipse.h" + +class Annulus : public BaseEllipse { + protected: + void listNonCel(FitsImage*, ostream&, Coord::CoordSystem); + + public: + Annulus(Base* p, const Vector& ctr, double inner, double outer, int num); + Annulus(Base* p, const Vector& ctr, + double inner, double outer, int num, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + Annulus(Base* p, const Vector& ctr, + int rn, double* r, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + Annulus(const Annulus&); + + Marker* dup() {return new Annulus(*this);} + void edit(const Vector&, int); + void editEnd(); + + int addAnnuli(const Vector&); + + void rotateBegin() {} + void rotate(const Vector& v, int h) {} + void rotateEnd() {} + + void analysis(AnalysisTask, int); + void analysisRadial(char*, char*, char*, Coord::CoordSystem sys); + void analysisStats(Coord::CoordSystem, Coord::SkyFrame sky); + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void listCiao(ostream&, Coord::CoordSystem, int); + void listPros(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + void listSAOimage(ostream&, int); + + // special composite funtionality + void setComposite(const Matrix&, double); +}; + +#endif diff --git a/tksao/frame/base.C b/tksao/frame/base.C new file mode 100644 index 0000000..22a0d9d --- /dev/null +++ b/tksao/frame/base.C @@ -0,0 +1,2268 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "base.h" +#include "context.h" +#include "fitsimage.h" +#include "marker.h" +#include "ps.h" + +#include "circle.h" +#include "ellipse.h" +#include "box.h" +#include "annulus.h" +#include "point.h" +#include "vect.h" + +// Debug +int DebugAST= 0; +int DebugBin= 0; +int DebugBlock= 0; +int DebugCompress= 0; +int DebugCrop= 0; +int DebugGZ= 0; +int DebugMosaic= 0; +int DebugPerf= 0; +int DebugRGB= 0; +int DebugWCS= 0; + +// Parser Stuff +#undef yyFlexLexer +#define yyFlexLexer frFlexLexer +#include + +void* frlval; +extern int frparse(Base*, frFlexLexer*); + +int frlex(void* vval, frFlexLexer* ll) +{ + frlval = vval; + return ll ? ll->yylex() : 0; +} + +void frerror(Base* fr, frFlexLexer* ll, const char* m) +{ + fr->error(m); + const char* cmd = ll ? ll->YYText() : (const char*)NULL; + if (cmd && cmd[0] != '\n') { + fr->error(": "); + fr->error(cmd); + } +} + +// Base Member Functions + +Base::Base(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : Widget(i, c, item) +{ + nthreads_ = 8; + + byteorder_ = 0; + bitsperpixel_ = 0; + + baseXImage = NULL; + basePixmap = 0; + needsUpdate = NOUPDATE; + syncUpdate = 0; + + currentContext = NULL; + keyContext = NULL; + keyContextSet =0; + + orientation = Coord::NORMAL; + zoom_ = Vector(1,1); + rotation = 0; + + rotateRotation = 0; + + preservePan = 0; + + panPM = 0; + panGCXOR = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + + rotateGCXOR = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + + pannerPixmap = 0; + pannerXImage = NULL; + pannerWidth = 0; + pannerHeight = 0; + pannerName[0] = '\0'; + usePanner = 0; + pannerGC = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + XSetLineAttributes(display, pannerGC, 1, LineSolid, CapButt, JoinMiter); + + magnifierPixmap = 0; + magnifierXImage = NULL; + magnifierWidth = 0; + magnifierHeight = 0; + magnifierZoom_ = 4; + magnifierName[0] = '\0'; + useMagnifier = 0; + useMagnifierGraphics = 1; + useMagnifierCursor = 1; + magnifierColorName = dupstr("white"); + + wcsSystem_ = Coord::WCS; + wcsSky_ = Coord::FK5; + wcsSkyFormat_ = Coord::DEGREES; + + wcsAlign_ = 0; + + xySystem_ = Coord::IMAGE; + xySky_ = Coord::FK5; + + wcsOrientation = Coord::NORMAL; + wcsRotation = 0; + + irafAlign_ =1; + irafOrientation_ = (Coord::Orientation)-1; + + maskColorName = dupstr("red"); + maskAlpha = 1; + maskMark = 1; + + invert = 0; + + useHighlite = 0; + highliteGC = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + XSetLineAttributes(display, highliteGC, 2, LineSolid, CapButt, JoinMiter); + XSetForeground(display, highliteGC, getColor("blue")); + + useCrosshair = 0; + + markerEpsilon = 3; + showMarkers = 1; + showMarkersText = 1; + centroidAuto = 0; + centroidIteration = 5; + centroidRadius = 10; + preserveMarkers = 0; + + markerGC = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + + markerGCXOR = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + XSetForeground(display, markerGCXOR, getColor("white")); + + selectGCXOR = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + XSetForeground(display, selectGCXOR, getColor("white")); + + grid = NULL; + gridGC = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + + contourGC = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + XSetLineAttributes(display, contourGC, 1, LineSolid, CapButt, JoinMiter); + + bgColorName = dupstr("white"); + bgColor = getXColor("white"); + memset(bgTrueColor_,255,4); + + nanColorName = dupstr("white"); + nanColor = getXColor("white"); + memset(nanTrueColor_,255,4); + + dlist[0] = 8; + dlist[1] = 3; + + colorbartag =NULL; + + markers = &userMarkers; + undoMarkers = &undoUserMarkers; + pasteMarkers = &pasteUserMarkers; + undoMarkerType = NONE; + + editMarker = NULL; + rotateMarker = NULL; + + compositeMarker = NULL; + + imageToData = Translate(-.5, -.5); + dataToImage = Translate( .5, .5); + + inverseScale = NULL; +} + +Base::~Base() +{ + if (basePixmap) + Tk_FreePixmap(display, basePixmap); + + if (baseXImage) + XDestroyImage(baseXImage); + + if (pannerPixmap) + Tk_FreePixmap(display, pannerPixmap); + + if (pannerXImage) + XDestroyImage(pannerXImage); + + if (panPM) + Tk_FreePixmap(display, panPM); + + if (panGCXOR) + XFreeGC(display, panGCXOR); + + if (rotateGCXOR) + XFreeGC(display, rotateGCXOR); + + if (pannerGC) + XFreeGC(display, pannerGC); + + if (magnifierPixmap) + Tk_FreePixmap(display, magnifierPixmap); + + if (magnifierXImage) + XDestroyImage(magnifierXImage); + + if (highliteGC) + XFreeGC(display, highliteGC); + + if (maskColorName) + delete [] maskColorName; + + if (markerGC) + XFreeGC(display, markerGC); + + if (markerGCXOR) + XFreeGC(display, markerGCXOR); + + if (selectGCXOR) + XFreeGC(display, selectGCXOR); + + if (grid) + delete grid; + + if (gridGC) + XFreeGC(display, gridGC); + + if (contourGC) + XFreeGC(display, contourGC); + + if (bgColorName) + delete [] bgColorName; + + if (nanColorName) + delete [] nanColorName; + + if (colorbartag) + delete [] colorbartag; + + if (magnifierColorName) + delete [] magnifierColorName; + + if (inverseScale) + delete inverseScale; + +} + +void Base::alignIRAF() +{ + if (irafAlign_) { + switch (irafOrientation_) { + case Coord::NORMAL: + irafMatrix_.identity(); + break; + case Coord::XX: + irafMatrix_ = FlipX(); + break; + case Coord::YY: + irafMatrix_ = FlipY(); + break; + case Coord::XY: + irafMatrix_ = FlipXY(); + break; + default: + irafMatrix_.identity(); + } + } + else + irafMatrix_.identity(); +} + +void Base::alignWCS() +{ + if (!wcsAlign_ || !context->cfits || !hasWCS(wcsSystem_)) { + wcsOrientation = Coord::NORMAL; + wcsOrientationMatrix.identity(); + wcsRotation = 0; + return; + } + + calcAlignWCS(context->cfits, wcsSystem_, wcsSky_, + &wcsOrientation, &wcsOrientationMatrix, &wcsRotation); +} + +void Base::alignWCS(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + if (!wcsAlign_ || !context->cfits || !hasWCS(sys)) { + wcsOrientation = Coord::NORMAL; + wcsOrientationMatrix.identity(); + wcsRotation = 0; + return; + } + + calcAlignWCS(context->cfits, sys, sky, + &wcsOrientation, &wcsOrientationMatrix, &wcsRotation); +} + +void Base::alignWCS(FitsImage* ptr, Coord::CoordSystem sys) +{ + if (!wcsAlign_ || !ptr || !context->cfits || !hasWCS(wcsSystem_)) { + wcsOrientation = Coord::NORMAL; + wcsOrientationMatrix.identity(); + wcsRotation = 0; + return; + } + + calcAlignWCS(ptr, context->cfits, sys, wcsSystem_, wcsSky_, + &wcsOrientation, &wcsOrientationMatrix, &wcsRotation, &zoom_); +} + +void Base::calcAlignWCS(FitsImage* fits1, + Coord::CoordSystem sys1, Coord::SkyFrame sky, + Coord::Orientation* orientation, Matrix* oo, + double* rotation) +{ + // init + *orientation = Coord::NORMAL; + oo->identity(); + *rotation = 0; + + if (!fits1 || !fits1->hasWCS(sys1)) + return; + + // orientation + *orientation = fits1->getWCSOrientation(sys1,sky); + switch (*orientation) { + case Coord::NORMAL: + oo->identity(); + break; + case Coord::XX: + *oo = FlipX(); + break; + default: + // na + break; + } + + // rotation + switch (*orientation) { + case Coord::NORMAL: + *rotation = fits1->getWCSRotation(sys1,sky); + break; + case Coord::XX: + *rotation = -fits1->getWCSRotation(sys1,sky); + break; + default: + // na + break; + } +} + +void Base::calcAlignWCS(FitsImage* fits1, FitsImage* fits2, + Coord::CoordSystem sys1, Coord::CoordSystem sys2, + Coord::SkyFrame sky, + Coord::Orientation* orientation, Matrix* oo, + double* rotation, Vector* zoom) +{ + // init + *orientation = Coord::NORMAL; + oo->identity(); + *rotation = 0; + + if ((!fits1 || !fits2) || + (fits1 == fits2) || + !(fits1->hasWCS(sys1)) || + !(fits2->hasWCS(sys2))) + return; + + Vector org1 = fits1->center(); + Vector orval1 = fits1->pix2wcs(org1,sys1,sky); + + // orientation + *orientation = fits2->getWCSOrientation(sys2,sky); + switch (*orientation) { + case Coord::NORMAL: + oo->identity(); + break; + case Coord::XX: + *oo = FlipX(); + break; + default: + // na + break; + } + + // rotation + Vector orpix = fits2->wcs2pix(orval1, sys2, sky); + Vector delta = fits2->getWCScdelt(sys2).abs(); + Vector npix = + fits2->wcs2pix(Vector(orval1[0],orval1[1]+delta[1]),sys2,sky); + Vector north = (npix-orpix).normalize(); + Vector epix = + fits2->wcs2pix(Vector(orval1[0]+delta[0],orval1[1]),sys2,sky); + Vector east = (epix-orpix).normalize(); + + // sanity check + Vector diff = (north-east).abs(); + if ((north[0]==0 && north[1]==0) || + (east[0]==0 && east[1]==0) || + (diff[0]<.01 && diff[1]<.01)) { + *rotation = 0; + *orientation = Coord::NORMAL; + oo->identity(); + return; + } + + switch (*orientation) { + case Coord::NORMAL: + *rotation = -(north.angle()-M_PI_2); + break; + case Coord::XX: + *rotation = (north.angle()-M_PI_2); + break; + default: + // na + break; + } + + // zoom + Vector cd1 = fits1->getWCScdelt(sys1); + Vector cd2 = fits2->getWCScdelt(sys2); + *zoom = Vector((*zoom)[0]/fabs(cd1[0]/cd2[0]), + (*zoom)[1]/fabs(cd1[1]/cd2[1])); +} + +Matrix Base::calcAlignWCS(FitsImage* fits1, FitsImage* fits2, + Coord::CoordSystem sys1, Coord::CoordSystem sys2, + Coord::SkyFrame sky) +{ + if ((!fits1 || !fits2) || + (fits1 == fits2) || + !(fits1->hasWCS(sys1)) || + !(fits2->hasWCS(sys2))) + return Matrix(); + + Vector org1 = fits1->center(); + Vector orval1 = fits1->pix2wcs(org1,sys1,sky); + + Vector org2 = fits2->center(); + Vector orval2 = fits2->pix2wcs(org2,sys2,sky); + + // orientation + Coord::Orientation orientation =Coord::NORMAL; + Coord::Orientation o1 = fits1->getWCSOrientation(sys1,sky); + Coord::Orientation o2 = fits2->getWCSOrientation(sys2,sky); + { + switch (o1) { + case Coord::NORMAL: + { + switch (o2) { + case Coord::NORMAL: + orientation = Coord::NORMAL; + break; + case Coord::XX: + orientation = Coord::XX; + break; + default: + // na + break; + } + } + break; + case Coord::XX: + { + switch (o2) { + case Coord::NORMAL: + orientation = Coord::XX; + break; + case Coord::XX: + orientation = Coord::NORMAL; + break; + default: + // na + break; + } + } + break; + default: + // na + break; + } + } + + // zoom + Vector zoom =Vector(1,1); + { + Vector cd1 = fits1->getWCScdelt(sys1); + Vector cd2 = fits2->getWCScdelt(sys2); + zoom = Vector(cd2[0]/cd1[0], cd2[1]/cd1[1]).abs(); + } + + // rotation + double rotation =0; + { + double rr1=0; + { + Vector orpix = fits1->wcs2pix(orval1, sys1, sky); + Vector delta = fits1->getWCScdelt(sys1).abs(); + Vector npix = + fits1->wcs2pix(Vector(orval1[0],orval1[1]+delta[1]),sys1,sky); + Vector north = (npix-orpix).normalize(); + Vector epix = + fits1->wcs2pix(Vector(orval1[0]+delta[0],orval1[1]),sys1,sky); + Vector east = (epix-orpix).normalize(); + + // sanity check + Vector diff = (north-east).abs(); + if ((north[0]==0 && north[1]==0) || + (east[0]==0 && east[1]==0) || + (diff[0]<.01 && diff[1]<.01)) + return Matrix(); + + switch (o1) { + case Coord::NORMAL: + rr1 = -(north.angle()-M_PI_2); + break; + case Coord::XX: + rr1 = (north.angle()-M_PI_2); + break; + default: + // na + break; + } + } + + double rr2 =0; + { + Vector orpix = fits2->wcs2pix(orval1, sys2, sky); + Vector delta = fits2->getWCScdelt(sys2).abs(); + Vector npix = + fits2->wcs2pix(Vector(orval1[0],orval1[1]+delta[1]),sys2,sky); + Vector north = (npix-orpix).normalize(); + Vector epix = + fits2->wcs2pix(Vector(orval1[0]+delta[0],orval1[1]),sys2,sky); + Vector east = (epix-orpix).normalize(); + + // sanity check + Vector diff = (north-east).abs(); + if ((north[0]==0 && north[1]==0) || + (east[0]==0 && east[1]==0) || + (diff[0]<.01 && diff[1]<.01)) + return Matrix(); + + switch (o2) { + case Coord::NORMAL: + rr2 = -(north.angle()-M_PI_2); + break; + case Coord::XX: + rr2 = north.angle()-M_PI_2; + break; + default: + // na + break; + } + } + + switch (o1) { + case Coord::NORMAL: + rotation = rr1-rr2; + break; + case Coord::XX: + rotation = -(rr1-rr2); + break; + default: + // na + break; + } + } + + // origin + Vector origin; + { + Vector orpix1 = fits1->wcs2pix(orval2,sys1,sky) * imageToData; + Vector orpix2 = fits2->wcs2pix(orval2,sys2,sky) * imageToData; + origin = orpix1 - orpix2; + } + + // matrix + { + Matrix flip; + switch (orientation) { + case Coord::NORMAL: + break; + case Coord::XX: + flip = FlipX(); + break; + default: + // na + break; + } + + Vector orpix2 = fits2->wcs2pix(orval2,sys2,sky) * imageToData; + + return + Translate(-orpix2) * + flip * + Scale(zoom) * + Rotate(rotation) * + Translate(orpix2) * + Translate(origin); + } +} + +double Base::calcZoom(Vector src, Vector dest) +{ + // we need to calculate the width and height of the rotated image + // so we can derived a zoom factor to shrink it to fit the requested size + + Vector cc = src/2.; + + Vector ll; + Vector lr(src[0],0); + Vector ur(src); + Vector ul(0,src[1]); + + Matrix mm = Translate(-cc) * Rotate(wcsRotation) * Rotate(rotation); + + BBox bb(ll*mm); + bb.bound(lr*mm); + bb.bound(ur*mm); + bb.bound(ul*mm); + + Vector bs = bb.size(); + double r0 = dest[0]/bs[0]; + double r1 = dest[1]/bs[1]; + + return r0>r1 ? r1:r0; +} + +void Base::centerImage() +{ + if (!keyContext->fits) { + cursor = Vector(); + return; + } + + // This is here because we need mapToRef to be up-to-date + updateMatrices(); + updatePannerMatrices(); + + // imageCenter is in IMAGE coords + Vector aa = imageCenter(keyContext->secMode()); + // always center to center of pixel, even for even sized image + Vector bb = (aa*Translate(.5,.5)).floor(); + // cursor is in REF coords + cursor = keyContext->fits->mapToRef(bb,Coord::IMAGE,Coord::FK5); +} + +void Base::coordToTclArray(FitsImage* ptr, const Vector3d& vv, + Coord::CoordSystem out, + const char* var, const char* base) +{ + Vector rr = ptr->mapFromRef(vv, out); + doubleToTclArray(rr[0], var, base, "x"); + doubleToTclArray(rr[1], var, base, "y"); +} + +void Base::coord3ToTclArray(FitsImage* ptr, const Vector3d& vv, + Coord::CoordSystem out, + const char* var, const char* base) +{ + double ss = ptr->mapFromRef3axis(((Vector3d&)vv)[2],out,2); + doubleToTclArray(ss, var, base, "z"); +} + +int Base::doRender() +{ + return context->cfits ? 1 : 0; +} + +void Base::doubleToTclArray(double d, const char* var, + const char* base, const char* mod) +{ + ostringstream str; + str << base << "," << mod << ends; + + ostringstream vstr; + vstr << fixed << setw(9) << setprecision(3) << d << ends; + Tcl_SetVar2(interp, (char*)var, str.str().c_str(), vstr.str().c_str(), 0); +} + +FitsImage* Base::findFits() +{ + return keyContext->fits; +} + +FitsImage* Base::findFits(Coord::CoordSystem sys, const Vector& vv) +{ + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + return findFits(vv); + default: + if (keyContext->fits && keyContext->fits->hasWCSCel(sys)) + return keyContext->fits; + else + return findFits(vv); + } +} + +FitsImage* Base::findFits(const Vector& vv) +{ + FitsImage* ptr = keyContext->fits; + while (ptr) { + Vector img = vv * ptr->refToData; + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + if (img[0]>=params->xmin && img[0]xmax && + img[1]>=params->ymin && img[1]ymax) + return ptr; + ptr = ptr->nextMosaic(); + } + return keyContext->fits; +} + +FitsImage* Base::findFits(int which) +{ + FitsImage* ptr = keyContext->fits; + for (int ii=1; iinextMosaic(); + return (ptr ? ptr : keyContext->fits); +} + +int Base::findFits(FitsImage* p) +{ + FitsImage* ptr = keyContext->fits; + int rr = 0; + while (ptr) { + rr++; + if (ptr == p) + return rr; + ptr = ptr->nextMosaic(); + } + return rr; +} + +FitsImage* Base::findAllFits(int which) +{ + // modified for medatacube + FitsImage* rr = NULL; + FitsImage* ptr = currentContext->fits; + while (ptr && which) { + FitsImage* sptr = ptr; + while (sptr && which) { + which--; + if (!which) { + rr = sptr; + break; + } + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + + return rr; +} + +int Base::fitsCount() +{ + return currentContext->fitsCount(); +} + +void Base::getInfoClearName(char* var) +{ + Tcl_SetVar2(interp,var,"filename","",0); + Tcl_SetVar2(interp,var,"object","",0); + Tcl_SetVar2(interp,var,"min","",0); + Tcl_SetVar2(interp,var,"max","",0); + Tcl_SetVar2(interp,var,"low","",0); + Tcl_SetVar2(interp,var,"high","",0); +} + +void Base::getInfoClearValue(char* var) +{ + Tcl_SetVar2(interp,var,"value","",0); + Tcl_SetVar2(interp,var,"value,red","",0); + Tcl_SetVar2(interp,var,"value,green","",0); + Tcl_SetVar2(interp,var,"value,blue","",0); + + Tcl_SetVar2(interp,var,"image,x","",0); + Tcl_SetVar2(interp,var,"image,y","",0); + Tcl_SetVar2(interp,var,"image,z","",0); + Tcl_SetVar2(interp,var,"physical,x","",0); + Tcl_SetVar2(interp,var,"physical,y","",0); + Tcl_SetVar2(interp,var,"physical,z","",0); + Tcl_SetVar2(interp,var,"amplifier,x","",0); + Tcl_SetVar2(interp,var,"amplifier,y","",0); + Tcl_SetVar2(interp,var,"amplifier,z","",0); + Tcl_SetVar2(interp,var,"detector,x","",0); + Tcl_SetVar2(interp,var,"detector,y","",0); + Tcl_SetVar2(interp,var,"detector,z","",0); +} + +void Base::getInfoClearWCS(char* var) +{ + for (int ii=0; iirefToData; + + for (int ii=0; iipix2wcs(uu, www, wcsSky_, wcsSkyFormat_, buff); + + int argc; + const char** argv; + Tcl_SplitList(interp, buff, &argc, &argv); + + if (argc > 0 && argv && argv[0]) + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),argv[0],0); + else + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),"",0); + if (argc > 1 && argv && argv[1]) + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),argv[1],0); + else + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),"",0); + // use first slice + coord3ToTclArray(ptr,rr,www,var,"wcs"); + + char* wcsname = (char*)sptr->getWCSName(www); + if (wcsname) + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),wcsname,0); + else if (argc > 2 && argv && argv[2]) + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),argv[2],0); + else + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),"",0); + + Tcl_Free((char*)argv); + } + else { + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),"",0); + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),"",0); + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",z"),"",0); + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),"",0); + } + } +} + +int Base::hasATMV() +{ + return currentContext->cfits && currentContext->cfits->hasATMV(); +} + +int Base::hasContour() +{ + return currentContext->hasContour(); +} + +int Base::hasContourAux() +{ + return currentContext->hasContourAux(); +} + +int Base::hasDTMV() +{ + return currentContext->cfits && currentContext->cfits->hasDTMV(); +} + +int Base::hasLTMV() +{ + return currentContext->cfits && currentContext->cfits->hasLTMV(); +} + +int Base::hasWCS(Coord::CoordSystem sys) +{ + return currentContext->cfits && currentContext->cfits->hasWCS(sys); +} + +int Base::hasWCSEqu(Coord::CoordSystem sys) +{ + return currentContext->cfits && currentContext->cfits->hasWCSEqu(sys); +} + +int Base::hasWCSCel(Coord::CoordSystem sys) +{ + return currentContext->cfits && currentContext->cfits->hasWCSCel(sys); +} + +int Base::hasWCSx(Coord::CoordSystem sys) +{ + return currentContext->cfits && currentContext->cfits->hasWCSx(sys,2); +} + +Vector Base::imageCenter(FrScale::SecMode mode) +{ + return imageBBox(mode).center(); +} + +Vector Base::imageSize(FrScale::SecMode mode) +{ + return imageBBox(mode).size(); +} + +BBox Base::imageBBox(FrScale::SecMode mode) +{ + // returns imageBBox in IMAGE coords + // params are in DATA coords and extends edge to edge + BBox rr; + int first=1; + FitsImage* ptr = context->fits; + while (ptr) { + FitsBound* params = ptr->getDataParams(mode); + Matrix mm = ptr->wcsToRef() * dataToImage; + + Vector aa = Vector(params->xmin,params->ymin) * mm; + if (first) { + rr = BBox(aa,aa); + first = 0; + } + else + rr.bound(aa); + + rr.bound(Vector(params->xmax,params->ymin) * mm); + rr.bound(Vector(params->xmax,params->ymax) * mm); + rr.bound(Vector(params->xmin,params->ymax) * mm); + + ptr = ptr->nextMosaic(); + } + + return rr; +} + +int Base::isIIS() +{ + return 0; +} + +int Base::isCube() +{ + return currentContext->isCube(); +} + +int Base::isBinTable() +{ + return (currentContext->fits && currentContext->fits->isBinTable()) ? 1 : 0; +} + +int Base::isMosaic() +{ + return currentContext->isMosaic(); +} + +FitsImage* Base::isInFits(const Vector& vv, Coord::InternalSystem ref, Vector* rv) +{ + Vector ss = mapToRef(vv,ref); + FitsImage* ptr = currentContext->fits; + + while (ptr) { + Vector rr = ss * ptr->refToData; + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + + if (rr[0]>=params->xmin && rr[0]xmax && + rr[1]>=params->ymin && rr[1]ymax) { + if (rv) + *rv = rr; + return ptr; + } + ptr = ptr->nextMosaic(); + } + + return NULL; +} + +FitsImage* Base::isInCFits(const Vector& vv, Coord::InternalSystem ref, Vector* rv) +{ + Vector ss = mapToRef(vv,ref); + FitsImage* ptr = currentContext->cfits; + + while (ptr) { + Vector rr = ss * ptr->refToData; + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + + if (rr[0]>=params->xmin && rr[0]xmax && + rr[1]>=params->ymin && rr[1]ymax) { + if (rv) + *rv = rr; + return ptr; + } + ptr = ptr->nextMosaic(); + } + + return NULL; +} + +void Base::invalidPixmap() +{ + Widget::invalidPixmap(); + + if (basePixmap) + Tk_FreePixmap(display, basePixmap); + basePixmap = 0; + + if (baseXImage) + XDestroyImage(baseXImage); + baseXImage = NULL; + + needsUpdate = MATRIX; +} + +Coord::Orientation Base::IRAFOrientation(Coord::Orientation oo) +{ + if (irafOrientation_ == (Coord::Orientation)-1) { + irafOrientation_ = oo; + alignIRAF(); + } + + return irafOrientation_; +} + +int Base::parse(istringstream& istr) +{ + result = TCL_OK; + frFlexLexer* ll = new frFlexLexer(&istr); + frparse(this, ll); + delete ll; + + return result; +} + +int Base::postscriptProc(int prepass) +{ + if (!visible) + return TCL_OK; + + if (prepass) + return TCL_OK; + + ps(); + + // Markers & Contours & Grids clip path + ostringstream str; + str << psOrigin() << ' ' + << options->width << ' ' << options->height + << " rectclip" << endl << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + + switch (psLevel) { + case 1: + switch (psColorSpace) { + case BW: + case GRAY: + if (grid) + grid->ps(GRAY); + + currentContext->contourPS(GRAY); + + if (showMarkers) { + psMarkers(&catalogMarkers, GRAY); + psMarkers(&userMarkers, GRAY); + } + // psMarkers(&analysisMarkers, GRAY); + + psCrosshair(GRAY); + psGraphics(GRAY); + + break; + case RGB: + case CMYK: + if (grid) + grid->ps(RGB); + + currentContext->contourPS(RGB); + + if (showMarkers) { + psMarkers(&catalogMarkers, RGB); + psMarkers(&userMarkers, RGB); + } + // psMarkers(&analysisMarkers, RGB); + + psCrosshair(RGB); + psGraphics(RGB); + + break; + } + break; + case 2: + case 3: + if (grid) + grid->ps(psColorSpace); + + currentContext->contourPS(psColorSpace); + + if (showMarkers) { + psMarkers(&catalogMarkers, psColorSpace); + psMarkers(&userMarkers, psColorSpace); + } + // psMarkers(&analysisMarkers, psColorSpace); + + psCrosshair(psColorSpace); + psGraphics(psColorSpace); + + break; + } + + return TCL_OK; +} + +void Base::printCoordSystem(Coord::CoordSystem sys) +{ + Tcl_AppendResult(interp, coord.coordSystemStr(sys), NULL); +} + +void Base::printDouble(double d) +{ + ostringstream str; + str << d << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::printInteger(int i) +{ + ostringstream str; + str << i << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::printSkyFrame(Coord::SkyFrame sky) +{ + Tcl_AppendResult(interp, coord.skyFrameStr(sky), NULL); +} + +void Base::printSkyFormat(Coord::SkyFormat format) +{ + Tcl_AppendResult(interp, coord.skyFormatStr(format), NULL); +} + +void Base::printSkyDist(Coord::SkyDist dist) +{ + Tcl_AppendResult(interp, coord.skyDistStr(dist), NULL); +} + +void Base::printFromRef(FitsImage* ptr, const Vector& vv, + Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + ostringstream str; + ptr->listFromRef(str, vv, sys, sky, format); + str << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::printLenFromRef(FitsImage* ptr, double dd, + Coord::CoordSystem sys, Coord::SkyDist dist) +{ + ostringstream str; + ptr->listLenFromRef(str, dd, sys, dist); + str << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::printLenFromRef(FitsImage* ptr, const Vector& vv, + Coord::CoordSystem sys, Coord::SkyDist dist) +{ + ostringstream str; + ptr->listLenFromRef(str, vv, sys, dist); + str << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::printDistFromRef(FitsImage* ptr, + const Vector& vv1, const Vector& vv2, + Coord::CoordSystem sys, Coord::SkyDist dist) +{ + ostringstream str; + ptr->listDistFromRef(str, vv1, vv2, sys, dist); + str << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::ps() +{ + + if (!currentContext->fits) + return; + + Tcl_AppendResult(interp, "gsave\n", NULL); + + double ss = psResolution / 96.; + int ww = options->width*ss; + int hh = options->height*ss; + + ostringstream str; + + str << psOrigin() << " translate " << 1/ss << ' ' << 1/ss << " scale" << endl; + switch (psLevel) { + case 1: + { + psHead1(str, ww, hh); + NoCompressAsciiHex filter(psLevel); + psImage(str, filter, ww, hh, ss); + } + break; + case 2: + { + psHead2(str, ww, hh, "RunLength", "ASCII85"); + RLEAscii85 filter(psLevel); + psImage(str, filter, ww, hh, ss); + } + break; + case 3: + { + psHead2(str, ww, hh, "Flate", "ASCII85"); + GZIPAscii85 filter(psLevel); + psImage(str, filter, ww, hh, ss); + } + break; + } + + str << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + + Tcl_AppendResult(interp, "grestore\n", NULL); +} + +void Base::psCrosshair(PSColorSpace mode) +{ + if (!useCrosshair) + return; + + Vector rr = mapFromRef(crosshair, Coord::WIDGET); + Vector aa = Vector(rr[0],1) * widgetToCanvas; + Vector bb = Vector(rr[0],options->height) * widgetToCanvas; + Vector cc = Vector(1,rr[1]) * widgetToCanvas; + Vector dd = Vector(options->width,rr[1]) * widgetToCanvas; + + { + ostringstream str; + switch ((PSColorSpace)mode) { + case BW: + case GRAY: + psColorGray(getXColor("green"), str); + str << " setgray"; + break; + case RGB: + psColorRGB(getXColor("green"), str); + str << " setrgbcolor"; + break; + case CMYK: + psColorCMYK(getXColor("green"), str); + str << " setcmykcolor"; + break; + } + str << endl << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + + { + ostringstream str; + str << 1 << " setlinewidth" << endl << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + + { + ostringstream str; + + str << "newpath " + << aa.TkCanvasPs(canvas) << ' ' + << "moveto " + << bb.TkCanvasPs(canvas) << ' ' + << "lineto stroke" << endl + << "newpath " + << cc.TkCanvasPs(canvas) << ' ' + << "moveto " + << dd.TkCanvasPs(canvas) << ' ' + << "lineto stroke" << endl << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } +} + +void Base::psImage(ostream& str, Filter& filter, + int width, int height, float scale) +{ + pushPSMatrices(scale, width, height); + + unsigned char* img = fillImage(width, height, Coord::PS); + if (!img) + return; + unsigned char* ptr = img; + for (long jj=0; jjfits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->updateMatrices(rgbToRef, refToUser, userToWidget, + widgetToCanvas, canvasToWindow); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } +} + +void Base::pushMagnifierMatrices() +{ + FitsImage* ptr = context->fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->updateMagnifierMatrices(refToMagnifier); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } +} + +void Base::pushPannerMatrices() +{ + FitsImage* ptr = context->fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->updatePannerMatrices(refToPanner); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } +} + +void Base::pushPSMatrices(float scale, int width, int height) +{ + Matrix mx = psMatrix(scale, width, height); + + FitsImage* ptr = context->fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->updatePS(mx); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } +} + +void Base::reset() +{ + if (!preservePan) + centerImage(); + + crosshair = cursor; + invert = 0; + + orientation = Coord::NORMAL; + orientationMatrix.identity(); + zoom_ = Vector(1,1); + rotation = 0; + + wcsAlign_ = 0; + + wcsOrientation = Coord::NORMAL; + wcsOrientationMatrix.identity(); + wcsRotation = 0; + + unselectMarkers(&userMarkers); + unselectMarkers(&catalogMarkers); + // unselectMarkers(&analysisMarkers); + + update(MATRIX); +} + +FrScale::SecMode Base::secMode() +{ + return currentContext->secMode(); +} + +void Base::resetSecMode() +{ + currentContext->resetSecMode(); +} + +void Base::setSecMode(FrScale::SecMode mode) +{ + currentContext->setSecMode(mode); +} + +void Base::setSlice(int id, int ss) +{ + // real work done in derived classes + updateMarkers(&userMarkers); + updateMarkers(&catalogMarkers); + // updateMarkers(&analysisMarkers); + + // execute any update callbacks + updateCBMarkers(&userMarkers); + updateCBMarkers(&catalogMarkers); + // updateCBMarkers(&analysisMarkers); +} + +void Base::unloadAllFits() +{ + unloadFits(); +} + +void Base::unloadFits() +{ + if (DebugPerf) + cerr << "Base::unloadFits()" << endl; + + if (!preserveMarkers) { + // delete markers + userMarkers.deleteAll(); + undoUserMarkers.deleteAll(); + pasteUserMarkers.deleteAll(); + } + + catalogMarkers.deleteAll(); + undoCatalogMarkers.deleteAll(); + pasteCatalogMarkers.deleteAll(); + + // analysisMarkers.deleteAll(); + // undoAnalysisMarkers.deleteAll(); + // pasteAnalysisMarkers.deleteAll(); + + if (grid) + delete grid; + grid = NULL; + + irafOrientation_ = (Coord::Orientation)-1; + irafMatrix_.identity(); + + updateColorScale(); +} + +void Base::update(UpdateType flag) +{ + if (DebugPerf) + cerr << "Base::update(" << flag << ')' << endl; + + // Be careful, someone may have already set the flag at a lower level + // therefor, only change the flag if we need more to be done + + if (flag < needsUpdate) + needsUpdate = flag; + redraw(); +} + +void Base::update(UpdateType flag, BBox bb) +{ + if (DebugPerf) + cerr << "Base::update(" << flag << ' ' << bb << ')' << endl; + + // bb is in canvas coords + + if (flag < needsUpdate) + needsUpdate = flag; + redraw(bb); +} + +void Base::updateBase() +{ + if (!widgetGC) + widgetGC = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + + if (DebugPerf) + cerr << "Base::updateBase()..."; + + int& width = options->width; + int& height = options->height; + + if (!basePixmap) { + if (!(basePixmap = Tk_GetPixmap(display, Tk_WindowId(tkwin), + width, height, depth))){ + internalError("Unable to Create Pixmap"); + return; + } + + // Geometry has changed, redefine our marker GCs including clip regions + updateGCs(); + } + + if (!baseXImage) { + if (!(baseXImage = XGetImage(display, basePixmap, 0, 0, width, height, + AllPlanes, ZPixmap))) { + internalError("Unable to Create XImage"); + return; + } + + // we have to wait until now, since the encodings depend on baseXImage + encodeTrueColor(baseXImage->byte_order, baseXImage->bits_per_pixel); + encodeTrueColor(bgColor, bgTrueColor_); + encodeTrueColor(nanColor, nanTrueColor_); + + // we have a race condition. Some Truecolor ColorScales need to know the + // bytes per pixel, RGB masks, and byte order, from XImage struct. + // yet, we receive colormap commands well before we render to the + // screen and have a valid XImage. + // So, we put off creating a colorscale until we are ready to render. + + if (!validColorScale()) + updateColorScale(); + } + + if (doRender()) + ximageToPixmap(basePixmap, baseXImage, Coord::WIDGET); + else { + XSetForeground(display, widgetGC, getColor(bgColorName)); + XFillRectangle(display, basePixmap, widgetGC, 0,0,options->width,options->height); + } + + if (DebugPerf) + cerr << "end" << endl; +} + +void Base::updateBin(const Matrix& mx) +{ + if (keyContext->fits && (keyContext->fits == currentContext->fits)) { + crosshair *= mx; + currentContext->updateContours(mx); + updateMarkerCoords(&userMarkers, mx); + updateMarkerCoords(&catalogMarkers, mx); + // updateMarkerCoords(&analysisMarkers, mx); + } + + alignWCS(); + updateColorScale(); + updateNow(MATRIX); // because we have changed zoom + + // update markers call backs + // wait til matrices have been updated so that any dialogs will print + // the correct coords + updateMarkerCBs(&userMarkers); + updateMarkerCBs(&catalogMarkers); + // updateMarkerCBs(&analysisMarkers); +} + +void Base::updateBlock(const Vector& vv) +{ + Scale mx(vv); + + if (keyContext->fits && (keyContext->fits == currentContext->fits)) { + cursor *= mx; + crosshair *= mx; + currentContext->updateContours(mx); + updateMarkerCoords(&userMarkers, mx); + updateMarkerCoords(&catalogMarkers, mx); + // updateMarkerCoords(&analysisMarkers, mx); + } + + alignWCS(); + updateColorScale(); + updateNow(MATRIX); + + // update markers call backs + // wait til matrices have been updated so that any dialogs will print + // the correct coords + updateMarkerCBs(&userMarkers); + updateMarkerCBs(&catalogMarkers); + // updateMarkerCBs(&analysisMarkers); +} + +void Base::updateGCs() +{ + // widget clip region + BBox bbWidget = BBox(0, 0, options->width, options->height); + Vector sizeWidget = bbWidget.size(); + + rectWidget[0].x = (int)bbWidget.ll[0]; + rectWidget[0].y = (int)bbWidget.ll[1]; + rectWidget[0].width = (int)sizeWidget[0]; + rectWidget[0].height = (int)sizeWidget[1]; + + // window clip region + BBox bbWindow = bbWidget * widgetToWindow; + Vector sizeWindow = bbWindow.size(); + + rectWindow[0].x = (int)bbWindow.ll[0]; + rectWindow[0].y = (int)bbWindow.ll[1]; + rectWindow[0].width = (int)sizeWindow[0]; + rectWindow[0].height = (int)sizeWindow[1]; + + // highliteGC + XSetClipRectangles(display, highliteGC, 0, 0, rectWidget, 1, Unsorted); + + // panGCXOR + XSetClipRectangles(display, panGCXOR, 0, 0, rectWindow, 1, Unsorted); + + // rotateGCXOR + XSetClipRectangles(display, rotateGCXOR, 0, 0, rectWindow, 1, Unsorted); + + // markerGC + XSetClipRectangles(display, markerGC, 0, 0, rectWidget, 1, Unsorted); + XSetClipRectangles(display, markerGCXOR, 0, 0, rectWindow, 1, Unsorted); + + // selectGC + x11Dash(selectGCXOR,1); + XSetClipRectangles(display, selectGCXOR, 0, 0, rectWindow, 1, Unsorted); + + // gridGC + XSetClipRectangles(display, gridGC, 0, 0, rectWidget, 1, Unsorted); + + // contourGC + XSetClipRectangles(display, contourGC, 0, 0, rectWidget, 1, Unsorted); +} + +void Base::updateMagnifier() +{ + updateMagnifier(magnifierCursor); +} + +void Base::updateMagnifier(const Vector& vv) +{ + // vv is in CANVAS coords + // save it, we may need it later + magnifierCursor = vv; + + if (!(magnifierXImage && magnifierPixmap)) + return; + + if (useMagnifier) { + updateMagnifierMatrices(); + + if (doRender()) { + ximageToPixmapMagnifier(); + + if (useMagnifierGraphics) { + // render markers + // markers bounding box is in canvas coords + // map the magnifier to a bounding box in canvas coords + Matrix mm = magnifierToRef * refToCanvas; + + Vector ll = Vector(0,0) * mm; + Vector ur = Vector(magnifierWidth,magnifierHeight) * mm; + BBox bb = BBox(vv,vv); + bb.bound(ll); + bb.bound(ur); + + if (showMarkers) { + x11MagnifierMarkers(&userMarkers, bb); + x11MagnifierMarkers(&catalogMarkers, bb); + } + // x11MagnifierMarkers(&analysisMarkers, bb); + + // render crosshair + if (useCrosshair) + x11Crosshair(magnifierPixmap, Coord::MAGNIFIER, + magnifierWidth, magnifierHeight); + + // render contours + currentContext->contourX11(magnifierPixmap, Coord::MAGNIFIER, + magnifierWidth, magnifierHeight); + } + + // render cursor + if (useMagnifierCursor) + x11MagnifierCursor(vv); + } + else { + XSetForeground(display, widgetGC, getColor(bgColorName)); + XFillRectangle(display, magnifierPixmap, widgetGC, 0, 0, + magnifierXImage->width, magnifierXImage->height); + } + + // notify the magnifier widget + ostringstream str; + str << magnifierName << " update " << (void*)magnifierPixmap << ends; + Tcl_Eval(interp, str.str().c_str()); + } +} + +void Base::updateMatrices() +{ + // refToUser + // flip y axis for X Windows + refToUser = Translate(-cursor) * FlipY() * irafMatrix_; + userToRef = refToUser.invert(); + + // userToWidget + userToWidget = + wcsOrientationMatrix * // flip x/y axis about center + orientationMatrix * // flip x/y axis about cursor position + Rotate(wcsRotation) * // rotate about center position + Rotate(rotation) * // rotate about cursor position + + Scale(zoom_) * // scale about cursor position + // must be int to align with screen pixels + Translate((int)(options->width/2.), (int)(options->height/2.)); + widgetToUser = userToWidget.invert(); + + // widgetToCanvas + widgetToCanvas = Translate(originX, originY); + canvasToWidget = widgetToCanvas.invert(); + + // canvasToWindow + short xx, yy; + Tk_CanvasWindowCoords(canvas, 0, 0, &xx, &yy); + canvasToWindow = Translate(xx, yy); + windowToCanvas = canvasToWindow.invert(); + + // These are derived Transformation Matrices + refToWidget = refToUser * userToWidget; + widgetToRef = refToWidget.invert(); + + refToCanvas = refToWidget * widgetToCanvas; + canvasToRef = refToCanvas.invert(); + + refToWindow = refToCanvas * canvasToWindow; + windowToRef = refToWindow.invert(); + + userToCanvas = userToWidget * widgetToCanvas; + canvasToUser = userToCanvas.invert(); + + widgetToWindow = widgetToCanvas * canvasToWindow; + windowToWidget = widgetToWindow.invert(); + + // Markers + updateMarkers(&userMarkers); + updateMarkers(&catalogMarkers); + // updateMarkers(&analysisMarkers); + + pushMatrices(); +} + +void Base::updateMagnifierMatrices() +{ + // magnifierCursor is in CANVAS + Vector ww = magnifierCursor*canvasToRef; + + // refToUser + Matrix refToUser; + refToUser = Translate(-ww) * FlipY() * irafMatrix_; + + // userToMagnifier + userToMagnifier = + wcsOrientationMatrix * // flip x/y axis about center + orientationMatrix * // flip x/y axis about cursor position + Rotate(wcsRotation) * // rotate about center position + Rotate(rotation) * // rotate about cursor position + + Scale(zoom_) * // scale about cursor position + Scale(magnifierZoom_) * // scale + // must be int to align with screen pixels + Translate((int)(magnifierWidth/2.), (int)(magnifierHeight/2.)); + magnifierToUser = userToMagnifier.invert(); + + refToMagnifier = refToUser * userToMagnifier; + magnifierToRef = refToMagnifier.invert(); + + magnifierToWidget = magnifierToUser * userToWidget; + widgetToMagnifier = magnifierToWidget.invert(); + + pushMagnifierMatrices(); +} + +void Base::updatePannerMatrices() +{ + Vector center = imageCenter(FrScale::IMGSEC) * imageToData; + + // refToUser + Matrix refToUser; + refToUser = Translate(-center) * FlipY() * irafMatrix_; + userToRef = refToUser.invert(); + + // userToPanner + userToPanner = + wcsOrientationMatrix * // flip x/y axis about center + orientationMatrix * // flip x/y axis about cursor position + Rotate(wcsRotation) * // rotate about center position + Rotate(rotation) * // rotate about cursor position + + Scale(calcZoomPanner()) * + // must be int to align with screen pixels + Translate((int)(pannerWidth/2.), (int)(pannerHeight/2.)); + pannerToUser = userToPanner.invert(); + + refToPanner = refToUser * userToPanner; + pannerToRef = refToPanner.invert(); + + pannerToWidget = pannerToRef * refToWidget; + widgetToPanner = pannerToWidget.invert(); + + pushPannerMatrices(); +} + +void Base::updateNow(UpdateType flag) +{ + if (DebugPerf) + cerr << "Base::updateNow(" << flag << ')' << endl; + + if (flag < needsUpdate) + needsUpdate = flag; + redrawNow(); +} + +void Base::updateNow(UpdateType flag, BBox bb) +{ + if (DebugPerf) + cerr << "Base::updateNow(" << flag << ',' << bb << ')' << endl; + + // bb is in canvas coords + if (flag < needsUpdate) + needsUpdate = flag; + redrawNow(bb); +} + +void Base::updatePanner() +{ + if (usePanner) { + if (doRender()) + ximageToPixmap(pannerPixmap, pannerXImage, Coord::PANNER); + else { + XSetForeground(display, pannerGC, getColor(bgColorName)); + XFillRectangle(display, pannerPixmap, pannerGC, 0, 0, + pannerWidth, pannerHeight); + } + } +} + +int Base::updatePixmap(const BBox& bb) +{ + // bbox is in canvas coords + + // Note: lack of breaks-- on purpose. + // If Matrices are update, both Base and Pixmap + // also need to be updated. Same for Base-- ie, pixmap is also updated. + switch (needsUpdate) { + case NOUPDATE: + break; + case MATRIX: + updateMatrices(); + updatePannerMatrices(); + case BASE: + updatePanner(); + case BASEONLY: + updateBase(); + case PIXMAP: + updatePM(bb); + break; + } + + needsUpdate = NOUPDATE; + return TCL_OK; +} + +void Base::updatePM(const BBox& bbox) +{ + // bbox is in Canvas Coords + + if (DebugPerf) + cerr << "Base::updatePM()..."; + + int& width = options->width; + int& height = options->height; + + if (!pixmap) { + if (!(pixmap = Tk_GetPixmap(display, Tk_WindowId(tkwin), + width, height, depth))) { + internalError("Unable to Create Pixmap"); + return; + } + } + + if (!bbox.isEmpty()) { + BBox bb = bbox * canvasToWidget; + int x0 = (int)bb.ll[0] > 0 ? (int)bb.ll[0] : 0; + int y0 = (int)bb.ll[1] > 0 ? (int)bb.ll[1] : 0; + int x1 = (int)bb.ur[0] < width ? (int)bb.ur[0] : width; + int y1 = (int)bb.ur[1] < height ? (int)bb.ur[1] : height; + int sx = x1-x0; + int sy = y1-y0; + + if (DebugPerf) + cerr << ' ' << x0 << ' ' << y0 << ' ' << x1 << ' ' << y1 << ' '; + + XCopyArea(display, basePixmap, pixmap, widgetGC, x0, y0, sx, sy, x0, y0); + } + + // grid + if (grid) + grid->x11(); + + // contours + currentContext->contourX11(pixmap, Coord::WIDGET, + options->width, options->height); + + // markers + if (showMarkers) { + x11Markers(&catalogMarkers, bbox); + x11Markers(&userMarkers, bbox); + } + // x11Markers(&analysisMarkers, bbox); + + // crosshair + x11Crosshair(pixmap, Coord::WIDGET, options->width, options->height); + + // highlite bbox + x11Graphics(); + + if (DebugPerf) + cerr << "end" << endl; +} + +char* Base::varcat(char* buf, char* base, char id, char* mod) +{ + int ll = strlen(base); + strcpy(buf,base); + buf[ll++] = id; + buf[ll++] = '\0'; + strcat(buf,mod); + return buf; +} + +void Base::x11Crosshair(Pixmap pm, Coord::InternalSystem sys, + int width, int height) +{ + if (useCrosshair) { + Vector rr = mapFromRef(crosshair,sys); + + XSetForeground(display, widgetGC, getColor("green")); + if (rr[0]>=0 && rr[0]=0 && rr[1]width-2, options->height-2); +} + +void Base::ximageToPixmap(Pixmap pixmap, XImage* ximage, + Coord::InternalSystem sys) +{ + // we need a colorScale before we can render + if (!validColorScale()) + return; + + unsigned char* img = fillImage(ximage->width, ximage->height, sys); + if (img) { + encodeTrueColor(img, ximage); + delete [] img; + } + + TkPutImage(NULL, 0, display, pixmap, widgetGC, ximage, + 0, 0, 0, 0, ximage->width, ximage->height); +} + +void Base::ximageToPixmapMagnifier() +{ + ximageToPixmap(magnifierPixmap, magnifierXImage, Coord::MAGNIFIER); +} + +#ifdef MAC_OSX_TK +void Base::macosx() +{ + // clip rect + XRectangle* rr = rectWidget; + Vector v1 = Vector(rr->x, rr->y) * widgetToCanvas; + Vector v2 = Vector(rr->x+rr->width, rr->y+rr->height) * widgetToCanvas; + macosxClip(v1,v2-v1); + + if (currentContext->fits) { + // scale + double scale = 150 / 72.; + int width = options->width*scale; + int height = options->height*scale; + + // image + macosxImage(scale, width, height, v1, v2-v1); + } +} + +void Base::macosxCrosshair() +{ + if (!useCrosshair) + return; + + Vector rr = mapFromRef(crosshair,Coord::WIDGET); + Vector aa = Vector(rr[0],1) * widgetToCanvas; + Vector bb = Vector(rr[0],options->height) * widgetToCanvas; + Vector cc = Vector(1,rr[1]) * widgetToCanvas; + Vector dd = Vector(options->width,rr[1]) * widgetToCanvas; + + macosxColor(getXColor("green")); + macosxWidth(1); + macosxDrawLine(aa,bb); + macosxDrawLine(cc,dd); +} + +void Base::macosxImage(float scale, int width, int height, + const Vector& v, const Vector& s) +{ + // we need a colorScale before we can render + if (!validColorScale()) + return; + + pushPSMatrices(scale, width, height); + + // source + unsigned char* src = fillImage(width, height, Coord::PS); + if (!src) + return; + + // destination + unsigned char* dst = new unsigned char[width*height*4]; + if (!dst) + return; + + unsigned char* sptr = src; + unsigned char* dptr = dst; + for (int ii=0; iimacosx(); + + // contours + currentContext->contourMacOSX(); + + // markers + if (showMarkers) { + macosxMarkers(&catalogMarkers); + macosxMarkers(&userMarkers); + } + // macosxMarkers(&analysisMarkers); + + macosxCrosshair(); + macosxGraphics(); + + // cleanup + macosxEnd(); +} +#endif + +#ifdef __WIN32 +void Base::win32() +{ + // clip rect + XRectangle* rr = rectWidget; + Vector v1 = Vector(rr->x, rr->y) * widgetToCanvas; + Vector v2 = Vector(rr->x+rr->width, rr->y+rr->height) * widgetToCanvas; + win32Clip(v1,v2-v1); + + if (currentContext->fits) { + // scale + double scale = 1.0; + int width = options->width*scale; + int height = options->height*scale; + + // image + win32Image(scale, width, height, v1, v2-v1); + } +} + +void Base::win32Crosshair() +{ + if (!useCrosshair) + return; + + Vector rr = mapFromRef(crosshair,Coord::WIDGET); + Vector aa = Vector(rr[0],1) * widgetToCanvas; + Vector bb = Vector(rr[0],options->height) * widgetToCanvas; + Vector cc = Vector(1,rr[1]) * widgetToCanvas; + Vector dd = Vector(options->width,rr[1]) * widgetToCanvas; + + win32Color(getXColor("green")); + win32Width(1); + win32Dash(NULL,0); + win32DrawLine(aa,bb); + win32DrawLine(cc,dd); +} + +void Base::win32Image(float scale, int width, int height, + const Vector& v, const Vector& s) +{ + // we need a colorScale before we can render + if (!validColorScale()) + return; + + pushPSMatrices(scale, width, height); + + // source + unsigned char* src = fillImage(width, height, Coord::PS); + if (!src) + return; + + // destination (width must be aligned on 4-byte DWORD boundary) + int jjwidth=(((width+3)/4)*4); + + // extra alignment padding which we have to skip over for each row + int jjpad=(jjwidth-width)*3; + + unsigned char* dst = new unsigned char[jjwidth*height*3]; + if (!dst) + return; + memset(dst, '\0', jjwidth*height*3); + + unsigned char* sptr = src; + unsigned char* dptr = dst; + unsigned char red, green, blue; + for (int jj=0; jjwin32(); + + // contours + currentContext->contourWin32(); + + // markers + if (showMarkers) { + win32Markers(&userMarkers); + win32Markers(&catalogMarkers); + } + // win32Markers(&analysisMarkers); + + win32Crosshair(); + win32Graphics(); + + // cleanup + win32End(); +} +#endif diff --git a/tksao/frame/base.h b/tksao/frame/base.h new file mode 100644 index 0000000..d5022e9 --- /dev/null +++ b/tksao/frame/base.h @@ -0,0 +1,1707 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __base_h__ +#define __base_h__ + +#include "widget.h" +#include "vector3d.h" + +#include "callback.h" +#include "fvcontour.h" +#include "frscale.h" +#include "grid2d.h" +#include "grid25d.h" +#include "grid3d.h" +#include "hist.h" +#include "inversescale.h" +#include "list.h" +#include "tag.h" +#include "util.h" +#include "point.h" + +extern int DebugAST; +extern int DebugMosaic; +extern int DebugPerf; +extern int DebugWCS; +extern int DebugBin; +extern int DebugBlock; +extern int DebugCompress; +extern int DebugCrop; +extern int DebugGZ; +extern int DebugRGB; + +#define DEFAULTLOW 0 +#define DEFAULTHIGH 100 +#define HISTEQUSIZE 16384 +#define SCALESIZE 16384 + +class Attribute; +class BaseBox; +class BaseEllipse; +class BaseMarker; +class Composite; +class Context; +class Contour; +class ContourLevel; +class Filter; +class FitsImage; +class FitsMask; +class FVContour; +class Grid; +class Grid2d; +class Grid25d; +class Grid3d; +class Marker; + +class Annulus; +class Box; +class BoxAnnulus; +class Bpanda; +class Circle; +class Compass; +class Cpanda; +class Ellipse; +class EllipseAnnulus; +class Epanda; +class Line; +class Point; +class Projection; +class Polygon; +class Ruler; +class Segment; +class Text; +class Vect; + +class Base : public Widget { + friend class Attribute; + friend class BaseBox; + friend class BaseEllipse; + friend class BaseLine; + friend class BaseMarker; + friend class BasePolygon; + friend class Composite; + friend class Context; + friend class Contour; + friend class ContourLevel; + friend class FitsImage; + friend class FitsMask; + friend class FVContour; + friend class Grid; + friend class Grid2d; + friend class Grid25d; + friend class Grid3d; + friend class Marker; + + friend class Annulus; + friend class Box; + friend class BoxAnnulus; + friend class Bpanda; + friend class Circle; + friend class Compass; + friend class Cpanda; + friend class Ellipse; + friend class EllipseAnnulus; + friend class Epanda; + friend class Line; + friend class Point; + friend class Projection; + friend class Polygon; + friend class Ruler; + friend class Segment; + friend class Text; + friend class Vect; + +public: + enum CompressType {NOCOMPRESS, GZ}; + enum FileNameType {ROOTBASE, FULLBASE, ROOT, FULL}; + enum MarkerFormat {DS9, XML, CIAO, SAOTNG, SAOIMAGE, PROS, RAWXY}; + enum MarkerLayer {USER, TEMPLATE, CATALOG, ANALYSIS}; + enum ShmType {SHMID,KEY}; + enum UndoMarkerType {NONE, MOVE, EDIT, DELETE}; + enum UpdateType {MATRIX, BASE, BASEONLY, PIXMAP, NOUPDATE}; + + enum MemType {ALLOC, ALLOCGZ, CHANNEL, MMAP, SMMAP, MMAPINCR, + SHARE, SSHARE, SOCKET, SOCKETGZ, VAR, HIST, POST, PHOTO}; + enum MosaicType {NOMOSAIC, IRAF, WCSMOSAIC, WFPC2}; + enum LayerType {IMG, MASK}; + + private: + InverseScale* inverseScale; + + protected: + Context* context; + int nthreads_; + + int byteorder_; + int bitsperpixel_; + + List* markers; // pointer to current marker stack + List* undoMarkers; // pointer to current marker stack + List* pasteMarkers;// pointer to current marker stack + + List userMarkers; // foreground marker stack + List undoUserMarkers; // remember marker to undo + List pasteUserMarkers; // cut/copy/paste + + List catalogMarkers; // background marker stack + List undoCatalogMarkers; // remember marker to undo + List pasteCatalogMarkers; // cut/copy/paste + + /* + List analysisMarkers; // background marker stack + List undoAnalysisMarkers; // remember marker to undo + List pasteAnalysisMarkers; // cut/copy/paste + */ + + UndoMarkerType undoMarkerType; // type + + Vector markerBegin; // marker move begin in image coords + Marker* editMarker; // pointer to marker currently being edited + Marker* rotateMarker; // pointer to marker currently being rotated + Vector regionBegin; // select region begin in canvas coords + Vector regionEnd; // select region end in canvas coords + + Composite* compositeMarker; // pointer to current composite marker + + Vector cursor; // current cursor position in REF coords + Vector crosshair; // crosshair location in REF coords + + XImage* baseXImage; // ximage of image + Pixmap basePixmap; // pixmap of image + UpdateType needsUpdate; // updateFlags + int syncUpdate; // update 3d syncronously + + Context* currentContext; + Context* keyContext; + int keyContextSet; + + Coord::Orientation orientation; // current image orientation + Matrix orientationMatrix; // current image orientation matrix + double rotation; // current image rotation angle + + double rotateRotation; // tmp cursor for interactive rotation + + int preservePan; // flag to indicate preserve between loads + + Vector zoom_; // current image zoom value + + Pixmap panPM; // tmp pixmap for pan motion + Vector panCursor; // cursor for interactive panning + GC panGCXOR; // GC for interactive panning + + GC rotateGCXOR; // GC for interactive rotation + + Pixmap pannerPixmap; // pixmap for panner + XImage* pannerXImage; // ximage for panner + int pannerWidth; // panner width + int pannerHeight; // panner height + char pannerName[32]; // panner widget name + int usePanner; // panner status + GC pannerGC; + + Pixmap magnifierPixmap; // pixmap for magnifier + XImage* magnifierXImage; // ximage for magnifier + int magnifierWidth; // magnifier width + int magnifierHeight; // magnifier height + double magnifierZoom_; // magnifier zoom factor + char magnifierName[32]; // magnifer widget name + int useMagnifier; // magnifer status + int useMagnifierGraphics; // magnifer marker status + int useMagnifierCursor; // magnifier cursor status + Vector magnifierCursor; // we need to save the last cursor used + char* magnifierColorName; + + Vector cropBegin; + Vector cropEnd; + + Coord::CoordSystem wcsSystem_; + Coord::SkyFrame wcsSky_; + Coord::SkyFormat wcsSkyFormat_; + + int wcsAlign_; // flag to indicate wcs alignment + + Coord::CoordSystem xySystem_; // default marker sys (RAWXY) + Coord::SkyFrame xySky_; // default marker sky (RAWXY) + + Coord::Orientation wcsOrientation; // wcs image orientation + Matrix wcsOrientationMatrix; // wcs image orientation matrix + double wcsRotation; // wcs image rotation angle + + int irafAlign_; + Coord::Orientation irafOrientation_; // orientation of first iraf segment + Matrix irafMatrix_; // orientation matrix for iraf mosaic + + char* maskColorName; + float maskAlpha; + int maskMark; + + int invert; + + int useHighlite; + GC highliteGC; + + XRectangle rectWidget[1]; + XRectangle rectWindow[1]; + + int useCrosshair; + + int markerEpsilon; // mouse tolerance for select/edit + int showMarkers; + int showMarkersText; + int centroidAuto; + int centroidIteration; + float centroidRadius; + int preserveMarkers; // flag to indicate preserve between loads + + GC markerGC; // marker gc + GC markerGCXOR; // marker xor gc + GC selectGCXOR; // select gc + + Grid* grid; + GC gridGC; + + GC contourGC; + + char* bgColorName; + XColor* bgColor; + char bgTrueColor_[4]; // color encoded + + char* nanColorName; + XColor* nanColor; + char nanTrueColor_[4]; // color encoded + + float dlist[2]; + + char* colorbartag; + + Matrix dataToImage; + Matrix imageToData; + + Matrix refToUser; + Matrix userToRef; + Matrix refToWidget; + Matrix widgetToRef; + Matrix refToCanvas; + Matrix canvasToRef; + Matrix refToWindow; + Matrix windowToRef; + + Matrix userToWidget; + Matrix widgetToUser; + Matrix userToCanvas; + Matrix canvasToUser; + + Matrix widgetToCanvas; + Matrix canvasToWidget; + Matrix widgetToWindow; + Matrix windowToWidget; + + Matrix canvasToWindow; + Matrix windowToCanvas; + + Matrix refToMagnifier; + Matrix magnifierToRef; + Matrix userToMagnifier; + Matrix magnifierToUser; + Matrix widgetToMagnifier; + Matrix magnifierToWidget; + + Matrix refToPanner; + Matrix pannerToRef; + Matrix userToPanner; + Matrix pannerToUser; + Matrix widgetToPanner; + Matrix pannerToWidget; + + private: + void bltHist(char*, char*); // frblt.C + + void getInfoClearName(char*); + void getInfoClearValue(char*); + void getInfoClearWCS(char*); + void getInfoWCS(char*, const Vector3d&, FitsImage*, FitsImage*); + + void invalidPixmap(); + + int updatePixmap(const BBox&); + + protected: + void alignIRAF(); + virtual void alignWCS(); + virtual void alignWCS(Coord::CoordSystem, Coord::SkyFrame); + virtual void alignWCS(FitsImage*, Coord::CoordSystem); + + // void analysisMarkersInit(); + + void bltCut(char*, char*, Coord::Orientation, const Vector&); + void bltCutFits(double*, double*, int, Coord::Orientation, const Vector&); + + double calcZoom(Vector,Vector); + virtual double calcZoomPanner() =0; + virtual void cancelDetach() =0; + virtual void centerImage(); + void coordToTclArray(FitsImage*, const Vector3d&, Coord::CoordSystem, + const char*, const char*); + void coord3ToTclArray(FitsImage*, const Vector3d&, Coord::CoordSystem, + const char*, const char*); + void createMarker(Marker*); + void createTemplate(const Vector&, istream&); + void contourCreatePolygon(List&); + + virtual int doRender(); + void doubleToTclArray(double, const char*, const char*, const char*); + + void encodeTrueColor(int oo, int bb) {byteorder_ = oo; bitsperpixel_ = bb;} + virtual void encodeTrueColor(XColor*, char*) =0; + virtual void encodeTrueColor(unsigned char*, XImage*) =0; + + virtual unsigned char* fillImage(int, int, Coord::InternalSystem) =0; + + Coord::Orientation getOrientation() {return orientation;} + double getRotation() {return rotation + wcsRotation;} + Coord::Orientation getWCSOrientation() {return wcsOrientation;} + + int hasATMV(); + int hasContour(); + int hasContourAux(); + int hasDTMV(); + int hasLTMV(); + int hasWCS(Coord::CoordSystem); + int hasWCSEqu(Coord::CoordSystem); + int hasWCSCel(Coord::CoordSystem); + int hasWCSx(Coord::CoordSystem); + + virtual BBox imageBBox(FrScale::SecMode); + Vector imageCenter(FrScale::SecMode); + Vector imageSize(FrScale::SecMode); + + virtual int isIIS(); + FitsImage* isInFits(const Vector&, Coord::InternalSystem, Vector*); + FitsImage* isInCFits(const Vector&, Coord::InternalSystem, Vector*); + virtual int isAzElZero() {return 1;} + virtual int isFrame() {return 0;} + virtual int isFrame3d() {return 0;} + virtual int isFrameRGB() {return 0;} + + void loadDone(int, LayerType); + + void markerAnalysisHistogram(Marker*, double**, double**, const BBox&, int); + int markerAnalysisPlot2d(Marker*, double**, double**, double**, double**, + Vector&, Vector&, int, + Coord::CoordSystem, Coord::SkyFrame, + Marker::AnalysisMethod); + int markerAnalysisPlot3d(Marker*, double**, double**, const BBox&, + Coord::CoordSystem, Marker::AnalysisMethod); + int markerAnalysisRadial(Marker*, double**, double**, double**, + int, Vector*, BBox*, Coord::CoordSystem); + int markerAnalysisPanda(Marker*, double**, double**, double**, + int, Vector*, int, double*, + BBox*, Coord::CoordSystem); + int markerAnalysisStats1(Marker*, FitsImage*, ostream&, + Coord::CoordSystem, Coord::SkyFrame); + void markerAnalysisStats2(FitsImage*, ostream&, Coord::CoordSystem, + int, int, double, int); + void markerAnalysisStats3(ostream&); + void markerAnalysisStats4(ostream&, int, int, double, double, + double, double, double); + void markerAnalysisStats(Marker*, ostream&, const BBox&, + Coord::CoordSystem, Coord::SkyFrame); + void markerAnalysisStats(Marker*, ostream&, int, BBox*, + Coord::CoordSystem, Coord::SkyFrame); + void markerAnalysisStats(Marker*, ostream&, int, int, + BBox*, Coord::CoordSystem, Coord::SkyFrame); + + double mapDistFromRef(const Vector&, const Vector&, Coord::InternalSystem); + double mapLenFromRef(double, Coord::InternalSystem); + Vector mapLenFromRef(const Vector&, Coord::InternalSystem); + double mapLenToRef(double, Coord::InternalSystem); + Vector mapLenToRef(const Vector&, Coord::InternalSystem); + void markerListHeader(ostream&); + void markerListXMLHeader(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void markerListXMLFooter(ostream&); + void markerListSAOtngHeader(ostream&,Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void markerUndo(Marker*, UndoMarkerType); + + void parseMarker(MarkerFormat,istream&); + int postscriptProc(int prepass); + void printCoordSystem(Coord::CoordSystem); + void printDistFromRef(FitsImage*, const Vector&, const Vector&, Coord::CoordSystem, Coord::SkyDist); + void printDouble(double); + void printFromRef(FitsImage*, const Vector&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void printLenFromRef(FitsImage*, double, Coord::CoordSystem, Coord::SkyDist); + void printLenFromRef(FitsImage*, const Vector&, Coord::CoordSystem, Coord::SkyDist); + void printInteger(int); + void printSkyFrame(Coord::SkyFrame); + void printSkyFormat(Coord::SkyFormat); + void printSkyDist(Coord::SkyDist); + void ps(); + void psCrosshair(PSColorSpace); + virtual void psGraphics(PSColorSpace) {} + void psImage(ostream&, Filter&, int, int, float); + void psMarkers(List*, int); + Matrix psMatrix(float scale, int width, int height); + virtual void pushMatrices(); + virtual void pushMagnifierMatrices(); + virtual void pushPannerMatrices(); + virtual void pushPSMatrices(float, int, int); + + virtual void reset(); + void resetSecMode(); + + virtual void setBinCursor() =0; + void setClip(); + FrScale::SecMode secMode(); + void setSecMode(FrScale::SecMode); + virtual void setSlice(int,int); + + void unhighliteMarkers(); + void unselectMarkers(List*); + void update(UpdateType); + void update(UpdateType,BBox); + void updateMarkers(List*); + void updateMarkerCBs(List*); + void updateMarkerCoords(List*, const Matrix&); + virtual void unloadFits(); + virtual void unloadAllFits(); + void updateBase(); + virtual void updateBin(const Matrix&); + virtual void updateBlock(const Vector&); + void updateCBMarkers(List*); + virtual void updateColorScale() =0; + virtual void updateGCs(); + void updateMagnifier(); + void updateMagnifier(const Vector&); + + virtual void updateMatrices(); + virtual void updateMagnifierMatrices(); + virtual void updatePannerMatrices(); + + void updateNow(UpdateType); + void updateNow(UpdateType,BBox); + virtual void updatePanner(); + void updatePM(const BBox&); + + char* varcat(char*, char*, char, char*); + virtual int validColorScale() =0; + + void x11Crosshair(Pixmap, Coord::InternalSystem, int, int); + void x11Dash(GC, int); + virtual void x11Graphics(); + virtual void x11MagnifierCursor(const Vector&) {} + void x11MagnifierMarkers(List*, const BBox& bb); + void x11Markers(List*, const BBox&); + void x11MarkerXOR(Marker*); + void xmlParse(istream&); + void xmlParseFIELD(void*, int*, char**, char**, char**, char**, int); + void xmlParseTR(char**, int*, char**, char**, char**, char**, int); + void xmlSetProps(unsigned short*, unsigned short, char*); + int xmlCount(const char*); + Vector xmlPoint(FitsImage*, const char* x, const char* y, + Coord::CoordSystem sys, Coord::SkyFrame sky, Coord::SkyFormat format, int which=0); + List* xmlVertex(FitsImage*, const char*, const char*, + Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + double xmlAngle(const char*, int, double, Coord::AngleFormat, Coord::CoordSystem, Coord::SkyFrame); + double* xmlAngles(const char*, int, double, int, Coord::AngleFormat, Coord::CoordSystem, Coord::SkyFrame); + double* xmlDistance(FitsImage*, const char*, int, Coord::CoordSystem, Coord::SkyDist); + Vector* xmlDistance(FitsImage*, const char*, const char*, int, Coord::CoordSystem, Coord::SkyDist); + void ximageToPixmap(Pixmap, XImage*, Coord::InternalSystem); + virtual void ximageToPixmapMagnifier(); + + Vector zoom() {return zoom_;} + +#ifdef MAC_OSX_TK + void macosx(); + void macosxCrosshair(); + virtual void macosxGraphics() {} + void macosxImage(float, int, int, const Vector&, const Vector&); + void macosxMarkers(List* ml); +#endif +#ifdef __WIN32 + void win32(); + void win32Crosshair(); + virtual void win32Graphics() {} + void win32Image(float, int, int, const Vector&, const Vector&); + void win32Markers(List* ml); +#endif + + public: + Base(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item); + virtual ~Base(); + + void calcAlignWCS(FitsImage*, Coord::CoordSystem, Coord::SkyFrame, + Coord::Orientation*, Matrix*, double*); + void calcAlignWCS(FitsImage*, FitsImage*, Coord::CoordSystem, Coord::CoordSystem, Coord::SkyFrame, + Coord::Orientation*, Matrix*, double*, Vector*); + Matrix calcAlignWCS(FitsImage*, FitsImage*, Coord::CoordSystem, Coord::CoordSystem, Coord::SkyFrame); + Vector centroid(const Vector&); + + FitsImage* findFits(); + FitsImage* findFits(Coord::CoordSystem, const Vector&); + FitsImage* findFits(const Vector&); + FitsImage* findFits(int); + int findFits(FitsImage*); + FitsImage* findAllFits(int); + int fitsCount(); + + Coord::Orientation IRAFOrientation(Coord::Orientation); + int isMosaic(); + int isCube(); + int isBinTable(); + + virtual Vector mapFromRef(const Vector&, Coord::InternalSystem) =0; + virtual Vector3d mapFromRef3d(const Vector&, Coord::InternalSystem) =0; + virtual Vector mapToRef(const Vector&, Coord::InternalSystem) =0; + virtual Vector3d mapToRef3d(const Vector&, Coord::InternalSystem) =0; + double mapAngleFromRef(double,Coord::CoordSystem,Coord::SkyFrame =Coord::FK5); + double mapAngleToRef(double, Coord::CoordSystem, Coord::SkyFrame =Coord::FK5); + + int parse(istringstream&); + + void resetCompositeMarker() {compositeMarker = NULL;} + + Coord::CoordSystem wcsSystem() {return wcsSystem_;} + Coord::SkyFrame wcsSky() {return wcsSky_;} + Coord::SkyFormat wcsSkyFormat() {return wcsSkyFormat_;} + + Coord::CoordSystem xySystem() {return xySystem_;} + Coord::SkyFrame xySky() {return xySky_;} + + void matchCmd(const char* xxname1, const char* yyname1, + Coord::CoordSystem sys1, Coord::SkyFrame sky1, + const char* xxname2, const char* yyname2, + Coord::CoordSystem sys2, Coord::SkyFrame sky2, + double rad, Coord::CoordSystem sys, Coord::SkyDist dist, + const char* rr); + + // IME Analysis Commands + void analysisMarkersResetCmd(); + void analysisMarkersSelectCmd(const char*, const Vector&); + + // Axes Order + void axesOrderCmd(int); + void getAxesOrderCmd(); + + // Background Commands + void bgColorCmd(const char*); + void getBgColorCmd(); + + // Bin Commands + void binCmd(const Vector&, const char*, const char*, const char*); + void binCmd(const Vector&, const Vector&, const char*, const char*, + const char*); + void binCmd(const Vector&, int, const Vector&, + const char*, const char*, const char*, const char*); + void binCmd(const Vector&, int, const Vector&, const Vector&, + const char*, const char*, const char*, const char*); + void binAboutCmd(); + void binAboutCmd(const Vector&); + void binColsCmd(const char*, const char*, const char*); + void binDepthCmd(int); + void binFactorCmd(const Vector&); + void binFactorAboutCmd(const Vector&, const Vector&); + void binFactorToCmd(const Vector&); + void binFactorToAboutCmd(const Vector&, const Vector&); + void binFunctionCmd(FitsHist::Function); + void binBufferSizeCmd(int); + void binFilterCmd(const char*); + virtual void binToFitCmd() =0; + void getBinDepthCmd(); + void getBinFactorCmd(); + void getBinFunctionCmd(); + void getBinBufferSizeCmd(); + void getBinCursorCmd(); + void getBinFilterCmd(); + void getBinColsCmd(); + void getBinColsMinMaxCmd(const char*); + void getBinColsDimCmd(const char*); + void getBinListCmd(); + void hasBinColCmd(const char*); + + // Block Commands + void blockCmd(const Vector&); + void blockToCmd(const Vector&); + virtual void blockToFitCmd() =0; + void getBlockCmd(); + + // Clip Commands + virtual void clipScopeCmd(FrScale::ClipScope); + void clipModeCmd(float); + void clipModeCmd(FrScale::ClipMode); + void clipMinMaxCmd(FrScale::MinMaxMode, int); + // backward compatibilty backup + void clipMinMaxModeCmd(FrScale::MinMaxMode); + // backward compatibilty backup + void clipMinMaxSampleCmd(int); + void clipUserCmd(double, double); + void clipZScaleCmd(float,int,int); + // backward compatibilty backup + void clipZScaleContrastCmd(float); + // backward compatibilty backup + void clipZScaleSampleCmd(int); + // backward compatibilty backup + void clipZScaleLineCmd(int); + + void getClipCmd(); + void getClipCmd(float); + void getClipCmd(FrScale::ClipMode); + void getClipMinMaxModeCmd(); + void getClipMinMaxSampleCmd(); + void getClipModeCmd(); + void getClipPreserveCmd(); + void getClipScopeCmd(); + void getClipUserCmd(); + void getClipZScaleContrastCmd(); + void getClipZScaleSampleCmd(); + void getClipZScaleLineCmd(); + void getHistogramCmd(char*, char*, int); + void getMinMaxCmd(); + void hasDATAMINCmd(); + void hasIRAFMINCmd(); + + // Colormap Commands + void colorbarTagCmd(const char*); + virtual void colormapCmd(int, float, float, int, unsigned char*, int) {} + virtual void colormapCmd(float, float, float, float, float, float, int, + unsigned char*, int) {} + virtual void colormapBeginCmd() {} + virtual void colormapEndCmd() {} + virtual void colormapMotionCmd(int, float, float, int, unsigned char*, int) {} + virtual void colormapMotionCmd(float, float, float, float, float, float, int, + unsigned char*, int) {} + virtual void getColorbarCmd() =0; + void getColorbarTagCmd(); + + // Contour Commands + void contourAppendCmd(ContourLevel*); + void contourCreateCmd(const char*, int, int, FVContour::Method, int, int, FrScale::ColorScaleType, float, float, Vector, const char*); + void contourCreatePolygonCmd(); + void contourDeleteCmd(); + void contourDeleteAuxCmd(); + void contourLoadCmd(const char*); + void contourLoadCmd(const char*, const char*, int, int); + void contourLoadCmd(const char*, Coord::CoordSystem, Coord::SkyFrame, const char*, int, int); + void contourPasteCmd(const char*); + void contourPasteCmd(const char*, const char*, int, int); + void contourSaveCmd(const char*, Coord::CoordSystem, Coord::SkyFrame); + void contourSaveAuxCmd(const char*, Coord::CoordSystem, Coord::SkyFrame); + + void getContourCmd(Coord::CoordSystem sys, Coord::SkyFrame sky); + void getContourClipCmd(); + void getContourClipModeCmd(); + void getContourColorNameCmd(); + void getContourDashCmd(); + void getContourLevelCmd(); + void getContourLineWidthCmd(); + void getContourMethodCmd(); + void getContourNumLevelCmd(); + void getContourScaleCmd(); + void getContourScaleLogCmd(); + void getContourSmoothCmd(); + void hasContourCmd(); + void hasContourAuxCmd(); + + // Coordinate Commands + void getWCSCmd(); + void wcsCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void getWCSNameCmd(Coord::CoordSystem); + void getWCSAlignPointerCmd(); + void getCoordCmd(const Vector&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void getCoord3axisCmd(double, Coord::CoordSystem, Coord::CoordSystem, int); + virtual void getCursorCmd(Coord::InternalSystem) =0; + virtual void getCursorCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat) =0; + void hasSystemCmd(Coord::CoordSystem); + void hasAmplifierCmd(); + void hasDetectorCmd(); + void hasPhysicalCmd(); + void hasWCSAltCmd(); + void hasWCSCmd(Coord::CoordSystem); + void hasWCSEquCmd(Coord::CoordSystem); + void hasWCSCelCmd(Coord::CoordSystem); + void hasWCSxCmd(Coord::CoordSystem); + + // Crop Commands + void cropCmd(); + void cropCmd(const Vector&, const Vector&, Coord::CoordSystem, Coord::SkyFrame); + void cropCenterCmd(const Vector&, Coord::CoordSystem, Coord::SkyFrame, const Vector&, Coord::CoordSystem, Coord::SkyDist); + void cropBeginCmd(const Vector&); + void cropMotionCmd(const Vector&); + void cropEndCmd(const Vector&); + void crop3dCmd(); + void crop3dCmd(double, double, Coord::CoordSystem); + virtual void crop3dBeginCmd(const Vector&, int) {} + virtual void crop3dMotionCmd(const Vector&, int) {} + virtual void crop3dEndCmd(const Vector&, int) {} + void getCropCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void getCropCenterCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, Coord::CoordSystem, Coord::SkyDist); + void getCrop3dCmd(Coord::CoordSystem); + void hasCropCmd(); + + // CrossHair Commands + void crosshairCmd(int); + void crosshairCmd(const Vector&, Coord::InternalSystem); + void crosshairCmd(const Vector&, Coord::CoordSystem, Coord::SkyFrame =Coord::FK5); + void crosshairWarpCmd(const Vector&); + void getCrosshairCmd(Coord::InternalSystem); + void getCrosshairCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void getCrosshairStatusCmd(); + + // DATASEC Commands + void DATASECCmd(int); + void getDATASECCmd(); + void hasDATASECCmd(); + + // Data Values + void getDataValuesCmd(int, const Vector&, Coord::CoordSystem, + Coord::SkyFrame, const Vector&, char*); + void getDataValuesCmd(const Vector&, Coord::InternalSystem, const Vector&); + + // Fits Commands + void getBitpixCmd(); + void getFitsNAxesCmd(); + void getFitsCountCmd(); + void getFitsCenterCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void getFitsDepthCmd(int); + void getFitsExtCmd(int); + void getFitsExtCmd(const Vector&, Coord::InternalSystem); + void getFitsFileNameCmd(FileNameType); + void getFitsFileNameCmd(int, FileNameType); + void getFitsFileNameCmd(const Vector&, Coord::InternalSystem, FileNameType); + void getFitsHeaderCmd(int); + void getFitsHeaderWCSCmd(int); + void getFitsHeaderKeywordCmd(int,const char*); + void getFitsObjectNameCmd(); + void getFitsSizeCmd(); + void getFitsSizeCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyDist); + void getFitsSliceCmd(int id); + void getFitsSliceCmd(int id, Coord::CoordSystem sys); + void hasFitsCmd(); + void hasFitsHPXCmd(); + void hasFitsBinCmd(); + void hasFitsCubeCmd(); + void hasFitsMosaicCmd(); + + void loadFitsAllocCmd(const char*, const char*, LayerType); + void loadFitsAllocGZCmd(const char*, const char*, LayerType); + void loadFitsChannelCmd(const char*, const char*, LayerType); + void loadFitsMMapCmd(const char*, LayerType); + void loadFitsSMMapCmd(const char*, const char*, LayerType); + void loadFitsMMapIncrCmd(const char*, LayerType); + void loadFitsShareCmd(ShmType, int, const char*, LayerType); + void loadFitsSShareCmd(ShmType, int, int, const char*, LayerType); + void loadFitsSocketCmd(int, const char*, LayerType); + void loadFitsSocketGZCmd(int, const char*, LayerType); + void loadFitsVarCmd(const char*, const char*, LayerType); + + void loadArrAllocCmd(const char*, const char*, LayerType); + void loadArrAllocGZCmd(const char*, const char*, LayerType); + void loadArrChannelCmd(const char*, const char*, LayerType); + void loadArrMMapCmd(const char*, LayerType); + void loadArrMMapIncrCmd(const char*, LayerType); + void loadArrShareCmd(ShmType, int, const char*, LayerType); + void loadArrSocketCmd(int, const char*, LayerType); + void loadArrSocketGZCmd(int, const char*, LayerType); + void loadArrVarCmd(const char*, const char*, LayerType); + + void loadENVISMMapCmd(const char*, const char*); + + void loadNRRDAllocCmd(const char*, const char*, LayerType); + void loadNRRDChannelCmd(const char*, const char*, LayerType); + void loadNRRDMMapCmd(const char*, LayerType); + void loadNRRDShareCmd(ShmType, int, const char*, LayerType); + void loadNRRDSocketCmd(int, const char*, LayerType); + void loadNRRDVarCmd(const char*, const char*, LayerType); + + virtual void loadPhotoCmd(const char*, const char*); + virtual void loadSlicePhotoCmd(const char*, const char*); + + void loadExtCubeAllocCmd(const char*, const char*); + void loadExtCubeAllocGZCmd(const char*, const char*); + void loadExtCubeChannelCmd(const char*, const char*); + void loadExtCubeMMapCmd(const char*); + void loadExtCubeMMapIncrCmd(const char*); + void loadExtCubeShareCmd(ShmType, int, const char*); + void loadExtCubeSocketCmd(int, const char*); + void loadExtCubeSocketGZCmd(int, const char*); + void loadExtCubeVarCmd(const char*, const char*); + + void loadSliceAllocCmd(const char*, const char*); + void loadSliceAllocGZCmd(const char*, const char*); + void loadSliceChannelCmd(const char*, const char*); + void loadSliceMMapCmd(const char*); + void loadSliceSMMapCmd(const char*, const char*); + void loadSliceMMapIncrCmd(const char*); + void loadSliceShareCmd(ShmType, int, const char*); + void loadSliceSShareCmd(ShmType, int, int, const char*); + void loadSliceSocketCmd(int, const char*); + void loadSliceSocketGZCmd(int, const char*); + void loadSliceVarCmd(const char*, const char*); + + void loadMosaicImageAllocCmd(MosaicType, Coord::CoordSystem, const char*, const char*, LayerType); + void loadMosaicImageAllocGZCmd(MosaicType, Coord::CoordSystem, const char*, const char*, LayerType); + void loadMosaicImageChannelCmd(MosaicType, Coord::CoordSystem, const char*, const char*, LayerType); + void loadMosaicImageMMapCmd(MosaicType, Coord::CoordSystem, const char*, LayerType); + void loadMosaicImageMMapIncrCmd(MosaicType, Coord::CoordSystem, const char*, LayerType); + void loadMosaicImageShareCmd(MosaicType, Coord::CoordSystem, ShmType, int, const char*, LayerType); + void loadMosaicImageSocketCmd(MosaicType, Coord::CoordSystem, int, const char*, LayerType); + void loadMosaicImageSocketGZCmd(MosaicType, Coord::CoordSystem, int, const char*, LayerType); + void loadMosaicImageVarCmd(MosaicType, Coord::CoordSystem, const char*,const char*, LayerType); + + void loadMosaicAllocCmd(MosaicType, Coord::CoordSystem, const char*, const char*, LayerType); + void loadMosaicAllocGZCmd(MosaicType, Coord::CoordSystem, const char*, const char*, LayerType); + void loadMosaicChannelCmd(MosaicType, Coord::CoordSystem, const char*, const char*, LayerType); + void loadMosaicMMapCmd(MosaicType, Coord::CoordSystem, const char*, LayerType); + void loadMosaicSMMapCmd(MosaicType, Coord::CoordSystem, const char*, const char*, LayerType); + void loadMosaicMMapIncrCmd(MosaicType, Coord::CoordSystem, const char*, LayerType); + void loadMosaicShareCmd(MosaicType, Coord::CoordSystem, ShmType, int, const char*, LayerType); + void loadMosaicSShareCmd(MosaicType, Coord::CoordSystem, ShmType, int, int, const char*, LayerType); + void loadMosaicSocketCmd(MosaicType, Coord::CoordSystem, int, const char*, LayerType); + void loadMosaicSocketGZCmd(MosaicType, Coord::CoordSystem, int, const char*, LayerType); + void loadMosaicVarCmd(MosaicType, Coord::CoordSystem, const char*, const char*, LayerType); + + void loadMosaicImageWFPC2AllocCmd(const char*, const char*); + void loadMosaicImageWFPC2AllocGZCmd(const char*, const char*); + void loadMosaicImageWFPC2ChannelCmd(const char*, const char*); + void loadMosaicImageWFPC2MMapCmd(const char*); + void loadMosaicImageWFPC2MMapIncrCmd(const char*); + void loadMosaicImageWFPC2ShareCmd(ShmType, int, const char*); + void loadMosaicImageWFPC2SocketCmd(int, const char*); + void loadMosaicImageWFPC2SocketGZCmd(int, const char*); + void loadMosaicImageWFPC2VarCmd(const char*, const char*); + + // Fits RGB + virtual void loadRGBCubeAllocCmd(const char*, const char*) {} + virtual void loadRGBCubeAllocGZCmd(const char*, const char*) {} + virtual void loadRGBCubeChannelCmd(const char*, const char*) {} + virtual void loadRGBCubeMMapCmd(const char*) {} + virtual void loadRGBCubeSMMapCmd(const char*, const char*) {} + virtual void loadRGBCubeMMapIncrCmd(const char*) {} + virtual void loadRGBCubeShareCmd(ShmType, int, const char*) {} + virtual void loadRGBCubeSShareCmd(ShmType,int,int,const char*) {} + virtual void loadRGBCubeSocketCmd(int, const char*) {} + virtual void loadRGBCubeSocketGZCmd(int, const char*) {} + virtual void loadRGBCubeVarCmd(const char*, const char*) {} + + virtual void loadRGBImageAllocCmd(const char*, const char*) {} + virtual void loadRGBImageAllocGZCmd(const char*, const char*) {} + virtual void loadRGBImageChannelCmd(const char*, const char*) {} + virtual void loadRGBImageMMapCmd(const char*) {} + virtual void loadRGBImageMMapIncrCmd(const char*) {} + virtual void loadRGBImageShareCmd(ShmType, int, const char*) {} + virtual void loadRGBImageSocketCmd(int, const char*) {} + virtual void loadRGBImageSocketGZCmd(int, const char*) {} + virtual void loadRGBImageVarCmd(const char*, const char*) {} + + virtual void loadArrayRGBCubeAllocCmd(const char*, const char*) {} + virtual void loadArrayRGBCubeAllocGZCmd(const char*, const char*) {} + virtual void loadArrayRGBCubeChannelCmd(const char*, const char*) {} + virtual void loadArrayRGBCubeMMapCmd(const char*) {} + virtual void loadArrayRGBCubeMMapIncrCmd(const char*) {} + virtual void loadArrayRGBCubeShareCmd(ShmType, int, const char*) {} + virtual void loadArrayRGBCubeSocketCmd(int, const char*) {} + virtual void loadArrayRGBCubeSocketGZCmd(int, const char*) {} + virtual void loadArrayRGBCubeVarCmd(const char*, const char*) {} + + virtual void savePhotoCmd(const char*) {} + + void saveFits(OutFitsStream&); + void saveFitsFileCmd(const char*); + void saveFitsChannelCmd(const char*); + void saveFitsSocketCmd(int); + + void saveFitsTable(OutFitsStream&); + void saveFitsTableFileCmd(const char*); + void saveFitsTableChannelCmd(const char*); + void saveFitsTableSocketCmd(int); + + void saveFitsSlice(OutFitsStream&); + void saveFitsSliceFileCmd(const char*); + void saveFitsSliceChannelCmd(const char*); + void saveFitsSliceSocketCmd(int); + + void saveFitsExtCube(OutFitsStream&); + void saveFitsExtCubeFileCmd(const char*); + void saveFitsExtCubeChannelCmd(const char*); + void saveFitsExtCubeSocketCmd(int); + + void saveFitsMosaic(OutFitsStream&, int); + void saveFitsMosaicFileCmd(const char*, int); + void saveFitsMosaicChannelCmd(const char*, int); + void saveFitsMosaicSocketCmd(int, int); + + void saveFitsMosaicImage(OutFitsStream&); + void saveFitsMosaicImageFileCmd(const char*); + void saveFitsMosaicImageChannelCmd(const char*); + void saveFitsMosaicImageSocketCmd(int); + + virtual void saveFitsRGBImage(OutFitsStream&) {} + virtual void saveFitsRGBImageFileCmd(const char*) {} + virtual void saveFitsRGBImageChannelCmd(const char*) {} + virtual void saveFitsRGBImageSocketCmd(int) {} + + virtual void saveFitsRGBCube(OutFitsStream&) {} + virtual void saveFitsRGBCubeFileCmd(const char*) {} + virtual void saveFitsRGBCubeChannelCmd(const char*) {} + virtual void saveFitsRGBCubeSocketCmd(int) {} + + virtual void saveFitsResampleFileCmd(const char*) {} + virtual void saveFitsResampleChannelCmd(const char*) {} + virtual void saveFitsResampleSocketCmd(int) {} + + void saveArray(OutFitsStream&, FitsFile::ArchType); + void saveArrayFileCmd(const char*, FitsFile::ArchType); + void saveArrayChannelCmd(const char*, FitsFile::ArchType); + void saveArraySocketCmd(int, FitsFile::ArchType); + + virtual void saveArrayRGBCube(OutFitsStream&, FitsFile::ArchType) {} + virtual void saveArrayRGBCubeFileCmd(const char*, FitsFile::ArchType) {} + virtual void saveArrayRGBCubeChannelCmd(const char*, FitsFile::ArchType) {} + virtual void saveArrayRGBCubeSocketCmd(int, FitsFile::ArchType) {} + + void saveNRRD(OutFitsStream&, FitsFile::ArchType); + void saveNRRDFileCmd(const char*, FitsFile::ArchType); + void saveNRRDChannelCmd(const char*, FitsFile::ArchType); + void saveNRRDSocketCmd(int, FitsFile::ArchType); + + void saveENVI(ostream&, OutFitsStream&, FitsFile::ArchType); + void saveENVIFileCmd(const char*, const char*, FitsFile::ArchType); + + void sliceCmd(int, int); + void sliceCmd(int, double, Coord::CoordSystem); + + void updateFitsCmd(int); + void updateFitsCmd(int, BBox, int); + void unloadFitsCmd(); + + // Fitsy Commands + void fitsyHasExtCmd(const char*); + + // Frame Commands + void clearCmd(); + void getFitsHeightCmd(); + virtual void getTypeCmd() =0; + void getFitsWidthCmd(); + void highliteCmd(int); + void warpCmd(const Vector&); + void warpToCmd(const Vector&); + + // Graph Commands + void getHorzCutCmd(char*, char*, const Vector&, Coord::InternalSystem); + void getVertCutCmd(char*, char*, const Vector&, Coord::InternalSystem); + + // Grid Commands + virtual void gridCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, + Grid::GridType, const char*, const char*) =0; + void gridDeleteCmd(); + void getGridCmd(); + void getGridOptionCmd(); + void getGridVarsCmd(); + void hasGridCmd(); + + // IIS Commands + virtual void iisCmd(int, int) {} + virtual void iisCursorModeCmd(int) {} + virtual void iisEraseCmd() {} + virtual void iisGetCmd(char*, int, int, int, int) {} + virtual void iisGetCursorCmd() {} + virtual void iisGetFileNameCmd() {} + virtual void iisGetFileNameCmd(int) {} + virtual void iisGetFileNameCmd(const Vector&) {} + virtual void iisMessageCmd(const char*) {} + virtual void iisSetCmd(const char*, int, int, int, int) {} + virtual void iisSetCursorCmd(const Vector&, Coord::InternalSystem) {} + virtual void iisSetCursorCmd(const Vector&, Coord::CoordSystem) {} + virtual void iisSetFileNameCmd(const char*) {} + virtual void iisSetFileNameCmd(const char*,int) {} + virtual void iisUpdateCmd() {} + virtual void iisWCSCmd(const Matrix&, const Vector&, int) {} + void hasIISCmd(); + + // Info Commands + void getInfoCmd(char*); + virtual void getInfoCmd(const Vector&, Coord::InternalSystem, char*); + void getInfoClipCmd(); + void getValueCmd(const Vector&, Coord::InternalSystem); + + // loadIncr is only used by LICK OBS + // maintained for backward compatibility + void loadIncrDataCmd(int, int, int, int, int); + void loadIncrMinMaxCmd(int, int, int, int, int); + void loadIncrEndCmd(); + + // Magnifier Commands + void magnifierCmd(char*, int, int); + void magnifierCmd(int); + void magnifierGraphicsCmd(int); + void magnifierCursorCmd(int); + void magnifierZoomCmd(double); + void magnifierColorCmd(const char*); + void updateMagnifierCmd(const Vector& v); + + // Marker Commands + // Basic Regions + void createCircleCmd(const Vector&, + double, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createEllipseCmd(const Vector&, + const Vector&, + double, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createBoxCmd(const Vector&, + const Vector&, + double, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createPolygonCmd(const Vector&, + const Vector&, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createPolygonCmd(const List&, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createSegmentCmd(const Vector&, + const Vector&, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createSegmentCmd(const List&, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createLineCmd(const Vector&, + const Vector&, + int, int, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createVectCmd(const Vector&, + const Vector&, + int, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createVectCmd(const Vector&, + double mag, double ang, + int, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createTextCmd(const Vector&, + double, int, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createPointCmd(const Vector&, Point::PointShape, int, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, + const List& cb); + + // Measurement Regions + void createRulerCmd(const Vector&, const Vector&, + Coord::CoordSystem, Coord::SkyFrame, Coord::CoordSystem, Coord::SkyDist, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createCompassCmd(const Vector&, double, + const char*, const char*, + int, int, + Coord::CoordSystem, Coord::SkyFrame, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createProjectionCmd(const Vector&, const Vector&, + double, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, + const List& cb); + + // Annulus Regions + void createAnnulusCmd(const Vector&, + double, double, int, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createAnnulusCmd(const Vector&, + int, double*, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createEllipseAnnulusCmd(const Vector&, + const Vector&, const Vector&, int, + double, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, + const List& cb); + void createEllipseAnnulusCmd(const Vector&, + int, Vector*, + double, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, + const List& cb); + void createBoxAnnulusCmd(const Vector&, + const Vector&, const Vector&, int, + double, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, + const List& cb); + void createBoxAnnulusCmd(const Vector&, + int, Vector*, + double, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, + const List& cb); + + // Panda Regions + void createCpandaCmd(const Vector&, + double, double, int, + double, double, int, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createCpandaCmd(const Vector&, + int, double*, + int, double*, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createEpandaCmd(const Vector&, + double, double, int, + const Vector&, const Vector&, int, + double, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createEpandaCmd(const Vector&, + int, double*, + int, Vector*, + double, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createBpandaCmd(const Vector&, + double, double, int, + const Vector&, const Vector&, int, + double, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createBpandaCmd(const Vector&, + int, double*, + int, Vector*, + double, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + + // Composite Regions + void createCompositeCmd(const Vector&, double, int, + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + void createCompositeCmd( + const char*, int*, int, const char*, + const char*, unsigned short, const char*, + const List&, const List& cb); + + // Template Regions + void createTemplateCmd(const Vector&, const char*); + void createTemplateCmd(const Vector&, Coord::CoordSystem, Coord::SkyFrame, + const char*); + void createTemplateVarCmd(const Vector&, const char* var); + + void getMarkerAnalysisHistogramCmd(char*, char*, int); + void getMarkerAnalysisHistogramCmd(int, char*, char*, int); + void getMarkerAnalysisPlot2dCmd(char*, char*, char*, char*, + Coord::CoordSystem, Coord::SkyFrame, + Marker::AnalysisMethod); + void getMarkerAnalysisPlot2dCmd(int, char*, char*, char*, char*, + Coord::CoordSystem, Coord::SkyFrame, + Marker::AnalysisMethod); + void getMarkerAnalysisPlot3dCmd(char*, char*, + Coord::CoordSystem, + Marker::AnalysisMethod); + void getMarkerAnalysisPlot3dCmd(int, char*, char*, + Coord::CoordSystem, + Marker::AnalysisMethod); + void getMarkerAnalysisPandaCmd(Coord::CoordSystem); + void getMarkerAnalysisPandaCmd(int, Coord::CoordSystem); + void getMarkerAnalysisRadialCmd(char*, char*, char*, Coord::CoordSystem); + void getMarkerAnalysisRadialCmd(int, char*, char*, char*, Coord::CoordSystem); + void getMarkerAnalysisStatsCmd(Coord::CoordSystem, Coord::SkyFrame); + void getMarkerAnalysisStatsCmd(int, Coord::CoordSystem, Coord::SkyFrame); + + void getMarkerAngleCmd(int); + void getMarkerAngleCmd(int, Coord::CoordSystem, Coord::SkyFrame); + void getMarkerAnnulusRadiusCmd(int, Coord::CoordSystem, Coord::SkyDist); + void getMarkerBoxAnnulusRadiusCmd(int, Coord::CoordSystem, Coord::SkyDist); + void getMarkerBoxRadiusCmd(int, Coord::CoordSystem, Coord::SkyDist); + void getMarkerBpandaAnglesCmd(int); + void getMarkerBpandaAnglesCmd(int, Coord::CoordSystem, Coord::SkyFrame); + void getMarkerBpandaRadiusCmd(int, Coord::CoordSystem, Coord::SkyDist); + void getMarkerCenterCmd(int, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void getMarkerCentroidAutoCmd(); + void getMarkerCentroidRadiusCmd(); + void getMarkerCentroidIterationCmd(); + void getMarkerCentroidOptionCmd(); + void getMarkerCircleRadiusCmd(int, Coord::CoordSystem, Coord::SkyDist); + void getMarkerColorCmd(); + void getMarkerColorCmd(const char*); + void getMarkerColorCmd(int); + void getMarkerCompassArrowCmd(int); + void getMarkerCompassLabelCmd(int); + void getMarkerCompassRadiusCmd(int, Coord::CoordSystem, Coord::SkyDist); + void getMarkerCompassSystemCmd(int); + void getMarkerCompositeCmd(int); + void getMarkerCpandaAnglesCmd(int); + void getMarkerCpandaAnglesCmd(int, Coord::CoordSystem, Coord::SkyFrame); + void getMarkerCpandaRadiusCmd(int, Coord::CoordSystem, Coord::SkyDist); + void getMarkerEllipseRadiusCmd(int, Coord::CoordSystem, Coord::SkyDist); + void getMarkerEllipseAnnulusRadiusCmd(int, Coord::CoordSystem,Coord::SkyDist); + void getMarkerEpandaAnglesCmd(int); + void getMarkerEpandaAnglesCmd(int, Coord::CoordSystem, Coord::SkyFrame); + void getMarkerEpandaRadiusCmd(int, Coord::CoordSystem, Coord::SkyDist); + void getMarkerEpsilonCmd(); + void getMarkerFontCmd(); + void getMarkerFontCmd(const char*); + void getMarkerFontCmd(int); + void getMarkerIdCmd(const char*); + void getMarkerIdCmd(const Vector&); + void getMarkerIdAllCmd(); + void getMarkerLineCmd(int, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void getMarkerLineArrowCmd(int); + void getMarkerLineLengthCmd(int, Coord::CoordSystem, Coord::SkyDist); + void getMarkerLineWidthCmd(); + void getMarkerLineWidthCmd(int); + void getMarkerMapLenFromRefCmd(int, double, Coord::CoordSystem, Coord::SkyDist); + void getMarkerNumberCmd(); + void getMarkerPointShapeCmd(int); + void getMarkerPointSizeCmd(int); + void getMarkerPolygonSegmentCmd(const Vector&); + void getMarkerPreserveCmd(); + void getMarkerProjectionPointsCmd(int, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void getMarkerProjectionLengthCmd(int, Coord::CoordSystem, Coord::SkyDist); + void getMarkerProjectionMethodCmd(int); + void getMarkerProjectionWidthCmd(int, Coord::CoordSystem, Coord::SkyDist); + void getMarkerPropertyCmd(unsigned short); + void getMarkerPropertyCmd(const char*, unsigned short); + void getMarkerPropertyCmd(int, unsigned short); + void getMarkerRulerLengthCmd(int, Coord::CoordSystem, Coord::SkyDist); + void getMarkerRulerPointCmd(int, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void getMarkerRulerSystemCmd(int); + void getMarkerSegmentSegmentCmd(const Vector&); + void getMarkerSelectedCmd(); + void getMarkerSelectedCmd(int); + void getMarkerSelectedCmd(const Vector&); + void getMarkerSelectedNumberCmd(); + void getMarkerShowCmd(); + void getMarkerShowTextCmd(); + void getMarkerHandleCmd(const Vector&); + void getMarkerHighlitedCmd(); + void getMarkerHighlitedCmd(int); + void getMarkerHighlitedCmd(const Vector&); + void getMarkerHighlitedNumberCmd(); + void getMarkerTagCmd(const char*); + void getMarkerTagCmd(int); + void getMarkerTagCmd(int,int); + void getMarkerTagDefaultNameCmd(); + void getMarkerTagNumberCmd(const char*); + void getMarkerTagsCmd(); + void getMarkerTextCmd(int); + void getMarkerTextRotateCmd(int); + void getMarkerTypeCmd(int); + void getMarkerVectorCmd(int, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void getMarkerVectorArrowCmd(int); + void getMarkerVectorLengthCmd(int, Coord::CoordSystem, Coord::SkyDist); + + void hasMarkerHighlitedCmd(); + void hasMarkerPasteCmd(); + void hasMarkerSelectedCmd(); + void hasMarkerUndoCmd(); + + void markerLayerCmd(MarkerLayer); + + void markerAnalysisCmd(int, Marker::AnalysisTask, int); + + void markerAngleCmd(int, double); + void markerAngleCmd(int, double, Coord::CoordSystem, Coord::SkyFrame); + void markerAnnulusCreateRadiusCmd(int, const Vector&); + void markerAnnulusDeleteRadiusCmd(int, int); + void markerAnnulusRadiusCmd(int, double, double, int, Coord::InternalSystem); + void markerAnnulusRadiusCmd(int, double, double, int, Coord::CoordSystem, Coord::SkyDist); + void markerAnnulusRadiusCmd(int, const char*, Coord::CoordSystem, Coord::SkyDist); + + void markerBackCmd(); + void markerBackCmd(const char*); + void markerBackCmd(int); + void markerBoxAnnulusRadiusCmd(int, const Vector&, const Vector&, int, + Coord::InternalSystem); + void markerBoxAnnulusRadiusCmd(int, const Vector&, const Vector&, int, + Coord::CoordSystem, Coord::SkyDist); + void markerBoxAnnulusRadiusCmd(int, const char*, Coord::CoordSystem, Coord::SkyDist); + void markerBoxAnnulusCreateRadiusCmd(int, const Vector&); + void markerBoxAnnulusDeleteRadiusCmd(int, int); + void markerBoxRadiusCmd(int, const Vector&, Coord::InternalSystem); + void markerBoxRadiusCmd(int, const Vector&, Coord::CoordSystem, Coord::SkyDist); + void markerBpandaCreateAnglesCmd(int, const Vector&); + void markerBpandaCreateRadiusCmd(int, const Vector&); + void markerBpandaDeleteCmd(int, int); + void markerBpandaEditCmd(int, double, double, int, + const Vector&, const Vector&, int); + void markerBpandaEditCmd(int, double, double, int, + const Vector&, const Vector&, int, + Coord::CoordSystem, Coord::SkyFrame); + void markerBpandaEditCmd(int, const char*, const char*, + Coord::CoordSystem, Coord::SkyFrame, + Coord::CoordSystem, Coord::SkyDist); + + void markerCallBackCmd(int, CallBack::Type, const char*, const char*); + void markerCentroidCmd(); + void markerCentroidCmd(const char*); + void markerCentroidCmd(int); + void markerCentroidAutoCmd(int); + void markerCentroidRadiusCmd(float); + void markerCentroidIterationCmd(int); + void markerCircleRadiusCmd(int, double, Coord::InternalSystem); + void markerCircleRadiusCmd(int, double, Coord::CoordSystem, Coord::SkyDist); + void markerColorCmd(const char*); + void markerColorCmd(const char*, const char*); + void markerColorCmd(int, const char*); + void markerCompassArrowCmd(int, int, int); + void markerCompassLabelCmd(int, const char*, const char*); + void markerCompassRadiusCmd(int, double, Coord::InternalSystem); + void markerCompassRadiusCmd(int, double, Coord::CoordSystem, Coord::SkyDist); + void markerCompassSystemCmd(int, Coord::CoordSystem, Coord::SkyFrame); + void markerCompositeCmd(int, int); + void markerCompositeDeleteCmd(); + void markerCommandCmd(MarkerFormat, const char*); + void markerCommandVarCmd(MarkerFormat, const char*); + void markerCopyCmd(); + void markerCopyCmd(const char*); + void markerCpandaCreateAnglesCmd(int, const Vector&); + void markerCpandaCreateRadiusCmd(int, const Vector&); + void markerCpandaDeleteCmd(int, int); + void markerCpandaEditCmd(int, double, double, int, double, double, int); + void markerCpandaEditCmd(int, double, double, int, double, double, int, + Coord::CoordSystem, Coord::SkyFrame); + void markerCpandaEditCmd(int, const char*, const char*, + Coord::CoordSystem, Coord::SkyFrame,Coord::CoordSystem, Coord::SkyDist); + void markerCutCmd(); + void markerCutCmd(const char*); + + void markerDeleteCmd(); + void markerDeleteCmd(const char*); + void markerDeleteCmd(int); + void markerDeleteAllCmd(); + void markerDeleteLastCmd(); + void markerDeleteCallBackCmd(int, CallBack::Type, const char*); + void markerDeleteTagCmd(int); + void markerDeleteTagCmd(int, const char*); + void markerDeleteTagCmd(int, int); + + void markerEditBeginCmd(int, int); + void markerEditBeginCmd(const Vector&, int); + void markerEditMotionCmd(const Vector&, int); + void markerEditEndCmd(); + void markerEllipseRadiusCmd(int, const Vector&, Coord::InternalSystem); + void markerEllipseRadiusCmd(int, const Vector&, Coord::CoordSystem, Coord::SkyDist); + void markerEllipseAnnulusRadiusCmd(int, const Vector&, const Vector&, int, + Coord::InternalSystem); + void markerEllipseAnnulusRadiusCmd(int, const Vector&, const Vector&, int, + Coord::CoordSystem, Coord::SkyDist); + void markerEllipseAnnulusRadiusCmd(int, const char*, + Coord::CoordSystem, Coord::SkyDist); + void markerEllipseAnnulusCreateRadiusCmd(int, const Vector&); + void markerEllipseAnnulusDeleteRadiusCmd(int, int); + void markerEpandaCreateAnglesCmd(int, const Vector&); + void markerEpandaCreateRadiusCmd(int, const Vector&); + void markerEpandaDeleteCmd(int, int); + void markerEpandaEditCmd(int, double, double, int, + const Vector&, const Vector&, int); + void markerEpandaEditCmd(int, double, double, int, + const Vector&, const Vector&, int, + Coord::CoordSystem, Coord::SkyFrame); + void markerEpandaEditCmd(int, const char*, const char*, + Coord::CoordSystem, Coord::SkyFrame, + Coord::CoordSystem, Coord::SkyDist); + void markerEpsilonCmd(int ee) {markerEpsilon = ee;} + + void markerFontCmd(const char*); + void markerFontCmd(const char*, const char*); + void markerFontCmd(int, const char*); + void markerFrontCmd(); + void markerFrontCmd(const char*); + void markerFrontCmd(int); + + void markerHighliteAllCmd(); // not used + void markerHighliteCmd(int); // not used + void markerHighliteCmd(const char*); // not used + void markerHighliteToggleCmd(const Vector&); + void markerHighliteOnlyCmd(int); + void markerHighliteOnlyCmd(const char*); // not used + void markerHighliteOnlyCmd(const Vector&); // not used + + void markerKeyCmd(); + void markerKeyCmd(const Vector&); + + void markerLineCmd(int, const Vector&, const Vector&, Coord::InternalSystem); + void markerLineCmd(int, const Vector&, const Vector&, Coord::CoordSystem, Coord::SkyFrame); + void markerLineArrowCmd(int, int, int); + void markerLineWidthCmd(int); + void markerLineWidthCmd(int, int); + void markerListCmd(MarkerFormat, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, + int strip, int select, + unsigned short, unsigned short, List&); + void markerLoadCmd(MarkerFormat,const char*); + void markerLoadCmd(MarkerFormat,const char*,Coord::CoordSystem,Coord::SkyFrame); + void markerLoadCmd(MarkerFormat,int); + void markerLoadCmd(MarkerFormat,int,Coord::CoordSystem,Coord::SkyFrame); + void markerLoadFitsCmd(const char*, const char*, int*, int, const char*); + + void markerMoveCmd(const Vector&); + void markerMoveCmd(const char*, const Vector&); + void markerMoveCmd(int id, const Vector&); + void markerMoveBeginCmd(const Vector&); + void markerMoveBeginCmd(int, const Vector&); + void markerMoveMotionCmd(const Vector&); + void markerMoveMotionCmd(int, const Vector&); + void markerMoveEndCmd(); + void markerMoveEndCmd(int); + void markerMoveToCmd(const Vector&, Coord::InternalSystem); + void markerMoveToCmd(const Vector&, Coord::CoordSystem, Coord::SkyFrame); + void markerMoveToCmd(const char*, const Vector&, Coord::InternalSystem); + void markerMoveToCmd(const char*, const Vector&, Coord::CoordSystem, Coord::SkyFrame); + void markerMoveToCmd(int, const Vector&, Coord::InternalSystem); + void markerMoveToCmd(int, const Vector&, Coord::CoordSystem, Coord::SkyFrame); + + void markerPasteCmd(); + void markerPasteCmd(Coord::CoordSystem); + void markerPointShapeCmd(int, Point::PointShape); + void markerPointSizeCmd(int, int); + void markerPolygonCreateVertexCmd(int, int, const Vector&); + void markerPolygonDeleteVertexCmd(int, int); + void markerPolygonResetCmd(int, const Vector&, Coord::InternalSystem); + void markerPolygonResetCmd(int, const Vector&, Coord::CoordSystem, Coord::SkyDist); + void markerPreserveCmd(int r) {preserveMarkers = r;} + void markerPropertyCmd(unsigned short, int); + void markerPropertyCmd(const char*, unsigned short, int); + void markerPropertyCmd(int, unsigned short, int); + void markerPropertyCmd(unsigned short, int, const Vector&); + void markerProjectionCmd(int, const Vector&, const Vector&, + Coord::InternalSystem, double); + void markerProjectionCmd(int, const Vector&, const Vector&, + Coord::CoordSystem, Coord::SkyFrame, + double, Coord::CoordSystem, Coord::SkyDist); + + void markerRotateBeginCmd(int); + void markerRotateBeginCmd(const Vector&); + void markerRotateMotionCmd(const Vector&, int h); + void markerRotateEndCmd(); + void markerRulerPointCmd(int, const Vector&, const Vector&, + Coord::CoordSystem, Coord::SkyFrame); + void markerRulerPointCmd(int, const Vector&, const Vector&, Coord::InternalSystem); + void markerRulerSystemCmd(int, Coord::CoordSystem, Coord::SkyFrame, + Coord::CoordSystem, Coord::SkyDist); + + void markerSaveCmd(const char*, MarkerFormat, Coord::CoordSystem, Coord::SkyFrame, + Coord::SkyFormat, int strip); + void markerSaveTemplateCmd(const char*); + void markerSegmentCreateVertexCmd(int, int, const Vector&); + void markerSegmentDeleteVertexCmd(int, int); + void markerSegmentResetCmd(int, const Vector&, Coord::InternalSystem); + void markerSegmentResetCmd(int, const Vector&, Coord::CoordSystem, Coord::SkyDist); + void markerSelectAllCmd(); + void markerSelectCmd(int); // not used + void markerSelectCmd(const char*); + void markerSelectToggleCmd(); + void markerSelectToggleCmd(const Vector&); + void markerSelectOnlyCmd(int); + void markerSelectOnlyCmd(const char*); + void markerSelectOnlyCmd(const Vector&); + void markerShowCmd(int); + void markerShowTextCmd(int); + + void markerTagCmd(const char*); + void markerTagCmd(int, const char*); + void markerTagEditCmd(const char*, const char*); + void markerTagDeleteCmd(const char*); + void markerTagDeleteAllCmd(); + void markerTagUpdateCmd(const char*); + void markerTextCmd(int, const char*); + void markerTextRotateCmd(int, int); + + void markerUndoCmd(); + void markerUnhighliteAllCmd(); + void markerUnhighliteCmd(int); // not used + void markerUnhighliteCmd(const char*); + void markerUnselectAllCmd(); + void markerUnselectCmd(int); // not used + void markerUnselectCmd(const char*); // not used + + void markerVectorCmd(int, const Vector&, Coord::InternalSystem, double, double); + void markerVectorCmd(int, const Vector&, Coord::CoordSystem, Coord::SkyFrame, + double, Coord::CoordSystem, Coord::SkyDist, double); + void markerVectorArrowCmd(int, int); + + void regionHighliteBeginCmd(const Vector& v) {regionSelectBeginCmd(v);} + void regionHighliteMotionCmd(const Vector& v) {regionSelectMotionCmd(v);} + void regionHighliteEndCmd(); + void regionHighliteShiftEndCmd(); + void regionSelectBeginCmd(const Vector&); + void regionSelectMotionCmd(const Vector&); + void regionSelectEndCmd(); + void regionSelectShiftEndCmd(); + + // Mask Commands + void getMaskColorCmd(); + void getMaskMarkCmd(); + void getMaskTransparencyCmd(); + + void maskColorCmd(const char*); + void maskClearCmd(); + void maskMarkCmd(int m) {maskMark=m;} + void maskTransparencyCmd(float); + + // NaN Commands + void getNANColorCmd(); + void nanColorCmd(const char*); + + // Pan Zoom Rotate Orient Commands + void centerCmd(); + void getOrientCmd(); + void getRotateCmd(); + void getPanPreserveCmd(); + void getZoomCmd(); + void orientCmd(Coord::Orientation); + virtual void panCmd(const Vector&) =0; + virtual void panCmd(const Vector&, const Vector&) =0; + virtual void panCmd(const Vector&, Coord::CoordSystem, Coord::SkyFrame) =0; + virtual void panToCmd(const Vector&) =0; + virtual void panToCmd(const Vector&, Coord::CoordSystem, Coord::SkyFrame) =0; + void panBeginCmd(const Vector&); + void panMotionCmd(const Vector&); + virtual void panEndCmd(const Vector&) =0; + virtual void panBBoxCmd(const Vector&) =0; + void panPreserveCmd(int r) {preservePan = r;} + void rotateCmd(double); + virtual void rotateBeginCmd() {} + virtual void rotateMotionCmd(double) {} + virtual void rotateEndCmd() {} + void rotateToCmd(double); + void getIRAFAlignCmd(); + void irafAlignCmd(int); + void getWCSAlignCmd(); + void wcsAlignCmd(int); + // used by backup + void wcsAlignCmd(int, Coord::CoordSystem, Coord::SkyFrame); + void wcsAlignCmd(int, FitsImage*, Coord::CoordSystem, Coord::SkyFrame); + void zoomCmd(const Vector&); + void zoomToCmd(const Vector&); + virtual void zoomAboutCmd(const Vector&, const Vector&) =0; + virtual void zoomAboutCmd(const Vector&, const Vector&, + Coord::CoordSystem, Coord::SkyFrame) =0; + virtual void zoomToAboutCmd(const Vector&, const Vector&) =0; + virtual void zoomToAboutCmd(const Vector&, const Vector&, + Coord::CoordSystem, Coord::SkyFrame) =0; + virtual void zoomToFitCmd(double) =0; + + // Panner Commands + void pannerCmd(int); + void pannerCmd(char*, int, int); + void updatePannerCmd(); + // backward compatiblity + void pannerCmd(Coord::CoordSystem, Coord::SkyFrame) {} + + // Pixel Table Commands + void getPixelTableCmd(const Vector&, Coord::InternalSystem, int, int, char*); + + // Print Commands +#ifdef MAC_OSX_TK + void macosxPrintCmd(); +#endif +#ifdef __WIN32 + void win32PrintCmd(); +#endif + + // Scale Commands + void colorScaleCmd(FrScale::ColorScaleType); + void colorScaleLogCmd(double); + void getColorMapLevelCmd(int); + void getColorMapLevelCmd(int, double, double, FrScale::ColorScaleType, float); + void getColorMapLevelCmd(int, const Vector&, Coord::InternalSystem); + void getColorScaleCmd(); + void getColorScaleLevelCmd(int, double, double, + FrScale::ColorScaleType, float); + void getColorScaleLogCmd(); + + // Smooth Commands + void getSmoothFunctionCmd(); + void getSmoothRadiusCmd(); + void hasSmoothCmd(); + void smoothCmd(int, int); + void smoothDeleteCmd(); + + // Threads Commands + void getThreadsCmd(); + void threadsCmd(int); + + // WCS + void wcsAppendCmd(int, int); + void wcsAppendCmd(int, const char*); + void wcsAppendTxtCmd(int, const char*); + void wcsReplaceCmd(int, int); + void wcsReplaceCmd(int, const char*); + void wcsReplaceTxtCmd(int, const char*); + void wcsResetCmd(int); + + // RGB Commands + virtual void getRGBChannelCmd() =0; + virtual void getRGBViewCmd() =0; + virtual void getRGBSystemCmd() =0; + virtual void setRGBChannelCmd(const char*) {} + virtual void setRGBViewCmd(int, int, int) {} + virtual void setRGBSystemCmd(Coord::CoordSystem) {} + + // 3d + virtual void get3dBorderCmd() =0; + virtual void get3dBorderColorCmd() =0; + virtual void get3dCompassCmd() =0; + virtual void get3dCompassColorCmd() =0; + virtual void get3dHighliteCmd() =0; + virtual void get3dHighliteColorCmd() =0; + virtual void get3dScaleCmd() =0; + virtual void get3dViewCmd() =0; + virtual void get3dViewPointCmd() =0; + virtual void get3dRenderMethodCmd() =0; + virtual void get3dRenderBackgroundCmd() =0; + virtual void set3dBorderCmd(int) {} + virtual void set3dBorderColorCmd(const char*) {} + virtual void set3dCompassCmd(int) {} + virtual void set3dCompassColorCmd(const char*) {} + virtual void set3dHighliteCmd(int) {} + virtual void set3dHighliteColorCmd(const char*) {} + virtual void set3dScaleCmd(double) {} + virtual void set3dViewCmd(float, float) {} + virtual void set3dViewPointCmd(const Vector3d&, const Vector&) {} + virtual void set3dRenderMethodCmd(int) {} + virtual void set3dRenderBackgroundCmd(int) {} + virtual void set3dPreserveCmd() {} + virtual void view3dBeginCmd(float, float) {} + virtual void view3dMotionCmd(float, float) {} + virtual void view3dEndCmd(float, float) {} +}; + +#endif diff --git a/tksao/frame/basebox.C b/tksao/frame/basebox.C new file mode 100644 index 0000000..6fb3b8b --- /dev/null +++ b/tksao/frame/basebox.C @@ -0,0 +1,313 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "basebox.h" +#include "fitsimage.h" + +BaseBox::BaseBox(Base* p, const Vector& ctr, double ang) + : BaseMarker(p, ctr, ang) +{ + numPoints_ = 5; + vertices_ = NULL; +} + +BaseBox::BaseBox(Base* p, const Vector& ctr, + double ang, + const char* clr, int* dsh, + int w, const char* f, + const char* t, unsigned short prop, const char* c, + const List& tag, const List& cb) + : BaseMarker(p, ctr, ang, clr, dsh, w, f, t, prop, c, tag, cb) +{ + numPoints_ = 5; + vertices_ = NULL; +} + +BaseBox::BaseBox(const BaseBox& a) : BaseMarker(a) +{ + numPoints_ = a.numPoints_; + vertices_ = NULL; +} + +BaseBox::~BaseBox() +{ + deleteVertices(); +} + +void BaseBox::renderX(Drawable drawable, Coord::InternalSystem sys, RenderMode mode) +{ + GC lgc = renderXGC(mode); + + newVertices(); + for (int ii=0; iimapFromRef(vertices_[ii][jj],sys); + pp[jj].x = (short)v[0]; + pp[jj].y = (short)v[1]; + } + XDrawLines(display, drawable, lgc, pp, numPoints_, CoordModeOrigin); + delete [] pp; + } + deleteVertices(); +} + +void BaseBox::renderPS(int mode) +{ + renderPSGC(mode); + + newVertices(); + for (int ii=0; iimapFromRef(vertices_[ii][jj],Coord::CANVAS); + if (jj==0) + str << "newpath " + << v.TkCanvasPs(parent->canvas) << " moveto" << endl; + else + str << v.TkCanvasPs(parent->canvas) << " lineto" << endl; + } + str << "stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } + deleteVertices(); +} + +#ifdef MAC_OSX_TK +void BaseBox::renderMACOSX() +{ + renderMACOSXGC(); + + newVertices(); + for (int ii=0; iimapFromRef(vertices_[ii][jj],Coord::CANVAS); + macosxDrawLines(vv, numPoints_); + delete [] vv; + } + deleteVertices(); +} +#endif + +#ifdef __WIN32 +void BaseBox::renderWIN32() +{ + renderWIN32GC(); + + newVertices(); + for (int ii=0; iimapFromRef(vertices_[ii][jj],Coord::CANVAS); + win32DrawLines(vv, numPoints_); + delete [] vv; + } + deleteVertices(); +} +#endif + +// Support + +void BaseBox::updateHandles() +{ + // handles are in canvas coords + // we can't garantee that the radii have been sorted yet + // also, annuli[i] could be negative + + if (handle) + delete [] handle; + handle = new Vector[numHandle]; + + Vector max; + for(int ii=0; ii1) + for (int ii=0; ii=ss[0]/2 || pp[1]<=-ss[1]/2 || pp[1]>ss[1]/2) + return 0; + else + return 1; +} + +Vector BaseBox::intersect(Vector rr, double aa) +{ + // special cases + if (!rr[0] || !rr[1]) + return Vector(); + + double ang = zeroTWOPI(aa); + double phi = rr.angle(); + + if (ang >= 0 && ang < phi) + return Vector(rr[0],-rr[0]*tan(ang)); + else if (ang >= phi && ang < M_PI-phi) + return Vector(rr[1]/tan(ang),-rr[1]); + else if (ang >= M_PI-phi && ang < M_PI+phi) + return Vector(-rr[0],rr[0]*tan(ang)); + else if (ang >= M_PI+phi && ang < M_TWOPI-phi) + return Vector(-rr[1]/tan(ang),rr[1]); + else + return Vector(rr[0],-rr[0]*tan(ang)); +} + +void BaseBox::newVertices() +{ + if (vertices_) + deleteVertices(); + + if (teq(startAng_,stopAng_-M_TWOPI,FLT_EPSILON)) + newVerticesA(); + else + newVerticesB(); +} + +void BaseBox::newVerticesA() +{ + Matrix mm = fwdMatrix(); + + numPoints_ = 5; + vertices_ = new Vector*[numAnnuli_+1]; + for (int i=0; i=b1) && (a1b1) && (a2<=b2)) + *s2 =1; + + if (((*s1) && (!(*s2))) || ((*s1) && (*s2))) + vertBPrep(a1,a2,b1,b2,ii,cnt); + + if (*s1&&*s2) + *s1=*s2=0; +} + +void BaseBox::vertBPrep(double a1, double a2, double ll, double ul, + int ii, int* cnt) +{ + if (!(a1 >= ll) && (a1 <= ul)) + a1 = ll; + if (!(a2 >= ll) && (a2 <= ul)) + a2 = ul; + + if (a1 > a2) { + vertBSeg(ll,a2,ii,cnt); + vertBSeg(a1,ul,ii,cnt); + } + else + vertBSeg(a1,a2,ii,cnt); +} + +void BaseBox::vertBSeg(double ang1, double ang2, int ii, int* cnt) +{ + Vector rr = (annuli_[ii]/2).abs(); + Matrix mm = fwdMatrix(); + + vertices_[ii][(*cnt)++] = intersect(rr,ang1)*mm; + vertices_[ii][(*cnt)] = intersect(rr,ang2)*mm; +} + +void BaseBox::deleteVertices() +{ + if (vertices_) { + for (int i=0; i& tag, const List& cb); + BaseBox(const BaseBox&); + + virtual ~BaseBox(); + + virtual Marker* dup() =0; + + int isIn(const Vector& vv) + {return isIn(vv, Coord::CANVAS);} + int isIn(const Vector& vv, Coord::InternalSystem sys) + {return isIn(vv,sys,numAnnuli_-1);} + int isIn(const Vector& vv, Coord::InternalSystem sys, int nn) + {return isInRef(bckMap(vv,sys),nn);} + virtual int isIn(const Vector& vv, Coord::InternalSystem sys, int nn, int aa) + {return isInRef(bckMap(vv,sys),nn);} + + // valid for non-fixed only + int isIn(const Vector& vv, const Matrix& bck) + {return isIn(vv,bck,numAnnuli_-1);} + int isIn(const Vector& vv, const Matrix& bck, int nn) + {return isInRef(vv*bck,nn);} + +}; + +#endif diff --git a/tksao/frame/basecommand.C b/tksao/frame/basecommand.C new file mode 100644 index 0000000..be306ba --- /dev/null +++ b/tksao/frame/basecommand.C @@ -0,0 +1,3210 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include "fdstream.hpp" + +#include + +#include "base.h" +#include "context.h" +#include "fitsimage.h" +#include "mmap.h" +#include "outfile.h" +#include "outchannel.h" +#include "outsocket.h" + +#include "sigbus.h" + +void Base::axesOrderCmd(int order) +{ + currentContext->setAxesOrder(order); + if (currentContext->fits) { + if (!preserveMarkers) { + // delete markers + userMarkers.deleteAll(); + undoUserMarkers.deleteAll(); + pasteUserMarkers.deleteAll(); + } + + catalogMarkers.deleteAll(); + undoCatalogMarkers.deleteAll(); + pasteCatalogMarkers.deleteAll(); + + // analysisMarkers.deleteAll(); + // undoAnalysisMarkers.deleteAll(); + // pasteAnalysisMarkers.deleteAll(); + + currentContext->contourDeleteFV(); + currentContext->contourDeleteAux(); + + // don't clear the grid, we can reconstruct a new grid + // if (grid) + // delete grid; + // grid = NULL; + + loadDone(1,IMG); + } +} + +void Base::bgColorCmd(const char* color) +{ + if (bgColorName) + delete [] bgColorName; + bgColorName = dupstr(color); + bgColor = getXColor(bgColorName); + update(BASE); +} + +void Base::binCmd(const Vector& b, const Vector& vv, + const char* x, const char* y, const char* filter) +{ + currentContext->setBinToFactor(b); + currentContext->setBinDepth(1); + if (currentContext->fits) { + currentContext->fits->setBinX(x); + currentContext->fits->setBinY(y); + currentContext->fits->setBinFilter(filter); + } + Matrix mm = currentContext->bin(vv); + updateBin(mm); +} + +void Base::binCmd(const Vector& b, const char* x, const char* y, + const char* filter) +{ + currentContext->setBinToFactor(b); + currentContext->setBinDepth(1); + if (currentContext->fits) { + currentContext->fits->setBinX(x); + currentContext->fits->setBinY(y); + currentContext->fits->setBinFilter(filter); + } + Matrix mm = currentContext->binCenter(); + updateBin(mm); +} + +void Base::binCmd(const Vector& b, int d, const Vector& lim, + const Vector& vv, + const char* x, const char* y, const char* z, + const char* filter) +{ + currentContext->setBinToFactor(b); + currentContext->setBinDepth(d); + if (currentContext->fits) { + currentContext->fits->setBinX(x); + currentContext->fits->setBinY(y); + currentContext->fits->setBinZ(z); + currentContext->fits->setBinFilter(filter); + currentContext->fits->setBinColMinMax(z,lim); + } + Matrix mm = currentContext->bin(vv); + updateBin(mm); +} + +void Base::binCmd(const Vector& b, int d, const Vector& lim, + const char* x, const char* y, const char* z, + const char* filter) +{ + currentContext->setBinToFactor(b); + currentContext->setBinDepth(d); + if (currentContext->fits) { + currentContext->fits->setBinX(x); + currentContext->fits->setBinY(y); + currentContext->fits->setBinZ(z); + currentContext->fits->setBinFilter(filter); + currentContext->fits->setBinColMinMax(z,lim); + } + Matrix mm = currentContext->binCenter(); + updateBin(mm); +} + +void Base::binAboutCmd() +{ + Matrix mm = currentContext->binCenter(); + updateBin(mm); +} + +void Base::binAboutCmd(const Vector& vv) +{ + Matrix mm = currentContext->bin(vv); + updateBin(mm); +} + +void Base::binBufferSizeCmd(int size) +{ + currentContext->setBinBufferSize(size); + Matrix mm = currentContext->binCursor(); + updateBin(mm); +} + +void Base::binColsCmd(const char* x, const char* y, const char* z) +{ + if (currentContext->fits) { + currentContext->fits->setBinX(x); + currentContext->fits->setBinY(y); + currentContext->fits->setBinZ(z); + } + Matrix mm = currentContext->binCursor(); + updateBin(mm); +} + +void Base::binDepthCmd(int d) +{ + currentContext->setBinDepth(d); + Matrix mm = currentContext->binCursor(); + updateBin(mm); +} + +void Base::binFactorCmd(const Vector& bb) +{ + currentContext->setBinFactor(bb); + Matrix mm = currentContext->binCursor(); + updateBin(mm); +} + +void Base::binFactorAboutCmd(const Vector& bb, const Vector& vv) +{ + currentContext->setBinFactor(bb); + Matrix mm = currentContext->bin(vv); + updateBin(mm); +} + +void Base::binFactorToCmd(const Vector& bb) +{ + currentContext->setBinToFactor(bb); + Matrix mm = currentContext->binCursor(); + updateBin(mm); +} + +void Base::binFactorToAboutCmd(const Vector& bb, const Vector& vv) +{ + currentContext->setBinToFactor(bb); + Matrix mm = currentContext->bin(vv); + updateBin(mm); +} + +void Base::binFunctionCmd(FitsHist::Function func) +{ + currentContext->setBinFunction(func); + Matrix mm = currentContext->binCursor(); + updateBin(mm); +} + +void Base::binFilterCmd(const char* filter) +{ + if (currentContext->fits) + currentContext->fits->setBinFilter(filter); + Matrix mm = currentContext->binCursor(); + updateBin(mm); +} + +void Base::blockCmd(const Vector& bb) +{ + Vector vv = currentContext->setBlockFactor(bb); + currentContext->block(); + currentContext->analysis(); + updateBlock(vv); +} + +void Base::blockToCmd(const Vector& bb) +{ + Vector vv = currentContext->setBlockToFactor(bb); + currentContext->block(); + currentContext->analysis(); + updateBlock(vv); +} + +void Base::centerCmd() +{ + centerImage(); + update(MATRIX); +} + +void Base::clearCmd() +{ + unloadAllFits(); + reset(); +} + +void Base::clipScopeCmd(FrScale::ClipScope ss) +{ + if (currentContext->updateClipScope(ss)) { + currentContext->clearHist(); + currentContext->updateClip(); + updateColorScale(); + update(BASE); + } +} + +void Base::clipModeCmd(FrScale::ClipMode mm) +{ + if (currentContext->updateClipMode(mm)) { + currentContext->updateClip(); + updateColorScale(); + update(BASE); + } +} + +void Base::clipModeCmd(float per) +{ + if (currentContext->updateClipMode(per)) { + currentContext->updateClip(); + updateColorScale(); + update(BASE); + } +} + +void Base::clipUserCmd(double ll, double hh) +{ + if (currentContext->updateUser(ll,hh)) { + currentContext->updateClip(); + updateColorScale(); + update(BASE); + } +} + +void Base::clipMinMaxCmd(FrScale::MinMaxMode mm, int ss) +{ + if (currentContext->updateMinMax(mm,ss)) { + currentContext->clearHist(); + currentContext->updateClip(); + updateColorScale(); + update(BASE); + } +} + +// backward compatibility backup +void Base::clipMinMaxModeCmd(FrScale::MinMaxMode mm) +{ + if (currentContext->updateMinMaxMode(mm)) { + currentContext->clearHist(); + currentContext->updateClip(); + updateColorScale(); + update(BASE); + } +} + +// backward compatibility backup +void Base::clipMinMaxSampleCmd(int ss) +{ + if (currentContext->updateMinMaxSample(ss)) { + currentContext->clearHist(); + currentContext->updateClip(); + updateColorScale(); + update(BASE); + } +} + +void Base::clipZScaleCmd(float cc, int ss, int ll) +{ + if (currentContext->updateZscale(cc,ss,ll)) { + currentContext->updateClip(); + updateColorScale(); + update(BASE); + } +} + +// backward compatibility backup +void Base::clipZScaleContrastCmd(float cc) +{ + if (currentContext->updateZscaleContrast(cc)) { + currentContext->updateClip(); + updateColorScale(); + update(BASE); + } +} + +// backward compatibility backup +void Base::clipZScaleSampleCmd(int ss) +{ + if (currentContext->updateZscaleSample(ss)) { + currentContext->updateClip(); + updateColorScale(); + update(BASE); + } +} + +// backward compatibility backup +void Base::clipZScaleLineCmd(int ll) +{ + if (currentContext->updateZscaleLine(ll)) { + currentContext->updateClip(); + updateColorScale(); + update(BASE); + } +} + +void Base::colorbarTagCmd(const char* str) +{ + if (colorbartag) + delete [] colorbartag; + + colorbartag = dupstr(str); +} + +void Base::cropCmd() +{ + currentContext->resetSecMode(); + FitsImage* sptr = currentContext->fits; + while (sptr) { + sptr->setCropParams(currentContext->datasec()); + sptr = sptr->nextSlice(); + } + + currentContext->updateClip(); + currentContext->updateContours(); + updateColorScale(); + update(MATRIX); + + updateMarkerCBs(&userMarkers); + updateMarkerCBs(&catalogMarkers); + // updateMarkerCBs(&analysisMarkers); +} + +// used for Backup +void Base::cropCmd(const Vector& aa, const Vector& bb, + Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + FitsImage* ptr = currentContext->fits; + if (!ptr) + return; + + Vector ss = ptr->mapToRef(aa,sys,sky); + Vector tt = ptr->mapToRef(bb,sys,sky); + + currentContext->setSecMode(FrScale::CROPSEC); + FitsImage* sptr = ptr; + while (sptr) { + sptr->setCropParams(ss*sptr->refToData, tt*sptr->refToData, + currentContext->datasec()); + sptr = sptr->nextSlice(); + } + + currentContext->updateClip(); + currentContext->updateContours(); + updateColorScale(); + update(MATRIX); + + updateMarkerCBs(&userMarkers); + updateMarkerCBs(&catalogMarkers); + // updateMarkerCBs(&analysisMarkers); +} + +void Base::cropCenterCmd(const Vector& vv, + Coord::CoordSystem sys, Coord::SkyFrame sky, + const Vector& wh, + Coord::CoordSystem dsys, Coord::SkyDist dist) +{ + FitsImage* ptr = currentContext->fits; + if (!ptr) + return; + + // params are in DATA coords + Vector cc = ptr->mapToRef(vv,sys,sky)*ptr->refToData; + Vector dd = ptr->mapLenToRef(wh,dsys,dist)*ptr->refToData; + Vector ll = (cc-dd/2).round(); + Vector ur = (cc+dd/2).round(); + + currentContext->setSecMode(FrScale::CROPSEC); + FitsImage* sptr = ptr; + while (sptr) { + sptr->setCropParams(ll,ur,currentContext->datasec()); + sptr = sptr->nextSlice(); + } + + currentContext->updateClip(); + currentContext->updateContours(); + updateColorScale(); + update(MATRIX); + + updateMarkerCBs(&userMarkers); + updateMarkerCBs(&catalogMarkers); + // updateMarkerCBs(&analysisMarkers); +} + +void Base::cropBeginCmd(const Vector& vv) +{ + cropBegin = vv; + cropEnd = vv; +} + +void Base::cropMotionCmd(const Vector& vv) +{ + Vector ss = mapToRef(cropBegin, Coord::CANVAS); + + // erase + if (cropBegin[0]!=cropEnd[0] || cropBegin[1]!=cropEnd[1]) { + Vector tt = mapToRef(cropEnd, Coord::CANVAS); + + Vector ll = mapFromRef(ss, Coord::CANVAS); + Vector lr = mapFromRef(Vector(tt[0],ss[1]), Coord::CANVAS); + Vector ur = mapFromRef(tt, Coord::CANVAS); + Vector ul = mapFromRef(Vector(ss[0],tt[1]), Coord::CANVAS); + + BBox bb(ll); + bb.bound(lr); + bb.bound(ur); + bb.bound(ul); + + redrawNow(bb.expand(2)); + } + + cropEnd = vv; + // and draw to window + { + Vector tt = mapToRef(cropEnd, Coord::CANVAS); + + Vector ll = mapFromRef(ss, Coord::WINDOW); + Vector lr = mapFromRef(Vector(tt[0],ss[1]), Coord::WINDOW); + Vector ur = mapFromRef(tt, Coord::WINDOW); + Vector ul = mapFromRef(Vector(ss[0],tt[1]), Coord::WINDOW); + + XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,ll[0],ll[1],lr[0],lr[1]); + XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,lr[0],lr[1],ur[0],ur[1]); + XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,ur[0],ur[1],ul[0],ul[1]); + XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,ul[0],ul[1],ll[0],ll[1]); + } +} + +void Base::cropEndCmd(const Vector& vv) +{ + Vector ss = mapToRef(cropBegin, Coord::CANVAS); + + // erase + if (cropBegin[0]!=cropEnd[0] || cropBegin[1]!=cropEnd[1]) { + Vector tt = mapToRef(cropEnd, Coord::CANVAS); + + Vector ll = mapFromRef(ss, Coord::CANVAS); + Vector lr = mapFromRef(Vector(tt[0],ss[1]), Coord::CANVAS); + Vector ur = mapFromRef(tt, Coord::CANVAS); + Vector ul = mapFromRef(Vector(ss[0],tt[1]), Coord::CANVAS); + + BBox bb(ll); + bb.bound(lr); + bb.bound(ur); + bb.bound(ul); + redrawNow(bb.expand(2)); + } + + // and crop + cropEnd = vv; + + if (cropBegin[0]!=cropEnd[0] || cropBegin[1]!=cropEnd[1]) { + Vector tt = mapToRef(cropEnd, Coord::CANVAS); + + if (!isMosaic()) { + currentContext->setSecMode(FrScale::CROPSEC); + FitsImage* sptr = currentContext->fits; + while (sptr) { + sptr->setCropParams(ss*sptr->refToData, tt*sptr->refToData, + currentContext->datasec()); + sptr = sptr->nextSlice(); + } + } + else { + FitsImage* ptr1 =NULL; + FitsImage* ptr2 =NULL; + if ((ptr1=isInFits(cropBegin,Coord::CANVAS,NULL)) == + (ptr2=isInFits(cropEnd,Coord::CANVAS,NULL))) { + + currentContext->setSecMode(FrScale::CROPSEC); + // clear any previous params + FitsImage* ptr = currentContext->fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->setCropParams(currentContext->datasec()); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + } + + FitsImage* sptr = ptr1; + while (sptr) { + sptr->setCropParams(ss*sptr->refToData, tt*sptr->refToData, + currentContext->datasec()); + sptr = sptr->nextSlice(); + } + } + } + else { + currentContext->resetSecMode(); + currentContext->setCrop3dParams(); + FitsImage* sptr = currentContext->fits; + while (sptr) { + sptr->setCropParams(currentContext->datasec()); + sptr = sptr->nextSlice(); + } + } + + currentContext->updateClip(); + currentContext->updateContours(); + updateColorScale(); + update(MATRIX); + + updateMarkerCBs(&userMarkers); + updateMarkerCBs(&catalogMarkers); + // updateMarkerCBs(&analysisMarkers); +} + +void Base::crop3dCmd() +{ + currentContext->resetSecMode(); + currentContext->setCrop3dParams(); + + currentContext->updateClip(); + currentContext->updateContours(); + updateColorScale(); + update(MATRIX); + + updateMarkerCBs(&userMarkers); + updateMarkerCBs(&catalogMarkers); + // updateMarkerCBs(&analysisMarkers); +} + +void Base::crop3dCmd(double z0, double z1, Coord::CoordSystem sys) +{ + // use first slice + FitsImage* ptr = currentContext->fits; + if (!ptr) + return; + + // ff/tt ranges 0-n + double ff = ptr->mapToRef3axis(z0,sys,2); + double tt = ptr->mapToRef3axis(z1,sys,2); + + // params is a BBOX in DATA coords 0-n + currentContext->setCrop3dParams(ff-.5,tt+.5); + + // set current slice if needed + // setSlice() IMAGE (ranges 1-n) + // context->slice() IMAGE (ranges 1-n) + double sl = currentContext->slice(2)-.5; + if (sltt) + setSlice(2,tt+.5); + + currentContext->setSecMode(FrScale::CROPSEC); + + currentContext->updateClip(); + updateColorScale(); + update(MATRIX); + + updateMarkerCBs(&userMarkers); + updateMarkerCBs(&catalogMarkers); + // updateMarkerCBs(&analysisMarkers); +} + +void Base::crosshairCmd(int which) +{ + useCrosshair = which ? 1 : 0; + update(PIXMAP); +} + +void Base::crosshairCmd(const Vector& vv, Coord::InternalSystem sys) +{ + useCrosshair = 1; + crosshair = mapToRef(vv, sys); + update(PIXMAP); +} + +void Base::crosshairCmd(const Vector& v, Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + useCrosshair = 1; + if (currentContext->cfits) + crosshair = currentContext->cfits->mapToRef(v, sys, sky); + update(PIXMAP); +} + +void Base::crosshairWarpCmd(const Vector& vv) +{ + useCrosshair = 1; + + // use matrix, not map() for 3d + Vector rr = crosshair*refToCanvas; + rr += vv; + crosshair = rr*canvasToRef; + + update(PIXMAP); + updateMagnifier(); +} + +void Base::colorScaleCmd(FrScale::ColorScaleType s) +{ + if (currentContext->colorScaleType() != s) { + currentContext->setColorScaleType(s); + updateColorScale(); + update(BASE); + } +} + +void Base::colorScaleLogCmd(double exp) +{ + if (currentContext->updateExpo(exp)) { + updateColorScale(); + update(BASE); + } +} + +void Base::contourAppendCmd(ContourLevel* cl) +{ + currentContext->contourAppendAux(cl); + update(PIXMAP); +} + +void Base::contourCreateCmd(const char* color, int width, int dash, + FVContour::Method method, int numlevel, + int smooth, + FrScale::ColorScaleType colorScaleType, + float expo, + float clipMode, Vector limits, + const char* level) +{ + if (DebugPerf) + cerr << "Base::contourCreate()" << endl; + + currentContext->contourCreateFV(color, width, dash, + method, numlevel, + smooth, + colorScaleType, expo, + clipMode, limits, + level); + update(PIXMAP); +} + +void Base::contourDeleteCmd() +{ + currentContext->contourDeleteFV(); + update(PIXMAP); +} + +void Base::contourDeleteAuxCmd() +{ + currentContext->contourDeleteAux(); + update(PIXMAP); +} + +void Base::contourLoadCmd(const char* fn) +{ + ifstream str(fn); + if (str) + currentContext->contourLoadAux(str); + update(PIXMAP); +} + +void Base::contourLoadCmd(const char* fn, const char* color, + int width, int dash) +{ + ifstream str(fn); + if (str) + currentContext->contourLoadAux(str, color, width, dash); + update(PIXMAP); +} + +void Base::contourLoadCmd(const char* fn, + Coord::CoordSystem sys, Coord::SkyFrame sky, + const char* color, int width, int dash) +{ + ifstream str(fn); + if (str) + currentContext->contourLoadAux(str, sys, sky, color, width, dash); + update(PIXMAP); +} + +void Base::contourPasteCmd(const char* var) +{ + const char* ccmd = Tcl_GetVar(interp, var, TCL_LEAVE_ERR_MSG); + if (!ccmd) { + result = TCL_ERROR; + return; + } + + // only make command string as long as needed + // or the rest will be processed as garbage + int len = strlen(ccmd)+2; + char* buf = new char[len]; + memcpy(buf, ccmd, len); + + // add terminator to make parser happy + buf[len-2] = '\n'; + buf[len-1] = '\0'; + + string x(buf); + istringstream str(x); + if (str) + currentContext->contourLoadAux(str); + delete [] buf; + + update(PIXMAP); +} + +void Base::contourPasteCmd(const char* var, const char* color, + int width, int dash) +{ + const char* ccmd = Tcl_GetVar(interp, var, TCL_LEAVE_ERR_MSG); + if (!ccmd) { + result = TCL_ERROR; + return; + } + + // only make command string as long as needed + // or the rest will be processed as garbage + int len = strlen(ccmd)+2; + char* buf = new char[len]; + memcpy(buf, ccmd, len); + + // add terminator to make parser happy + buf[len-2] = '\n'; + buf[len-1] = '\0'; + + string x(buf); + istringstream str(x); + if (str) + currentContext->contourLoadAux(str, color, width, dash); + delete [] buf; + + update(PIXMAP); +} + +void Base::contourSaveCmd(const char* fn, Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + ofstream str(fn); + if (str) + currentContext->contourListFV(str, sys, sky); +} + +void Base::contourSaveAuxCmd(const char* fn, Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + ofstream str(fn); + if (str) + currentContext->contourListAux(str, sys, sky); +} + +void Base::DATASECCmd(int which) +{ + if (currentContext->updateDataSec(which)) { + currentContext->resetSecMode(); + currentContext->updateClip(); + currentContext->updateContours(); + updateColorScale(); + update(MATRIX); + } +} + +void Base::fitsyHasExtCmd(const char* fn) +{ + // verify that we have an ext specified + if (fn && (fn[strlen(fn)-1] != ']')) { + Tcl_AppendResult(interp, "0", NULL); + return; + } + + FitsFile* ext = new FitsFitsMMap(fn, FitsFile::EXACT); + if (ext->isValid()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); + + delete ext; + return; +} + +void Base::getAxesOrderCmd() +{ + printInteger(currentContext->axesOrder()); +} + +void Base::getBgColorCmd() +{ + Tcl_AppendResult(interp, bgColorName, NULL); +} + +void Base::getBinCursorCmd() +{ + if (currentContext->fits) { + ostringstream str; + str << currentContext->fits->getHistCursor() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + else + Tcl_AppendResult(interp, "0 0", NULL); +} + +void Base::getBinColsCmd() +{ + if (currentContext->fits && currentContext->fits->isHist()) { + if (currentContext->binDepth()>1) + Tcl_AppendResult(interp, currentContext->fits->getHistX(), " ", + currentContext->fits->getHistY(), " ", + currentContext->fits->getHistZ(), NULL); + else + Tcl_AppendResult(interp, currentContext->fits->getHistX(), " ", + currentContext->fits->getHistY(), NULL); + } + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getBinColsMinMaxCmd(const char* col) +{ + if (currentContext->fits && col && *col) { + ostringstream str; + str << currentContext->fits->getHistColMinMax(col) << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } +} + +void Base::getBinColsDimCmd(const char* col) +{ + if (currentContext->fits && col && *col) { + ostringstream str; + str << currentContext->fits->getHistColDim(col) << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + else + Tcl_AppendResult(interp, "0 0", NULL); +} + +void Base::getBinDepthCmd() +{ + printDouble(currentContext->binDepth()); +} + +void Base::getBinFactorCmd() +{ + ostringstream str; + str << currentContext->binFactor() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getBinFunctionCmd() +{ + switch (currentContext->binFunction()) { + case FitsHist::AVERAGE: + Tcl_AppendResult(interp, "average", NULL); + return; + case FitsHist::SUM: + Tcl_AppendResult(interp, "sum", NULL); + return; + } +} + +void Base::getBinBufferSizeCmd() +{ + printInteger(currentContext->binBufferSize()); +} + +void Base::getBinFilterCmd() +{ + if (currentContext->fits && currentContext->fits->isHist()) + Tcl_AppendResult(interp, currentContext->fits->getHistFilter(), NULL); + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getBinListCmd() +{ + if (currentContext->fits && currentContext->fits->isHist()) { + char* cols = currentContext->fits->getHistList(); + Tcl_AppendResult(interp, cols, NULL); + delete [] cols; + } + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getBitpixCmd() +{ + if (currentContext->cfits) + printInteger(currentContext->cfits->bitpix()); + else + Tcl_AppendResult(interp, "32", NULL); +} + +void Base::getBlockCmd() +{ + ostringstream str; + str << currentContext->blockFactor() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getClipCmd() +{ + if (DebugPerf) + cerr << "getClipCmd()" << endl; + + ostringstream str; + str << currentContext->getClip() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getClipCmd(float per) +{ + if (DebugPerf) + cerr << "getClipCmd(float)" << endl; + + FrScale::ClipMode cm = (per == 100) ? FrScale::MINMAX : FrScale::AUTOCUT; + float ac = per; + + ostringstream str; + str << currentContext->getClip(cm, ac) << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getClipCmd(FrScale::ClipMode cm) +{ + if (DebugPerf) + cerr << "getClipCmd(FrScale::ClipMode)" << endl; + + ostringstream str; + str << currentContext->getClip(cm, currentContext->autoCutPer()) << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getClipMinMaxModeCmd() +{ + switch (currentContext->minmaxMode()) { + case FrScale::SCAN: + Tcl_AppendResult(interp, "scan", NULL); + return; + case FrScale::SAMPLE: + Tcl_AppendResult(interp, "sample", NULL); + return; + case FrScale::DATAMIN: + Tcl_AppendResult(interp, "datamin", NULL); + return; + case FrScale::IRAFMIN: + Tcl_AppendResult(interp, "irafmin", NULL); + return; + } +} + +void Base::getClipMinMaxSampleCmd() +{ + printInteger(currentContext->minmaxSample()); +} + +void Base::getClipModeCmd() +{ + switch (currentContext->clipMode()) { + case FrScale::MINMAX: + Tcl_AppendResult(interp, "minmax", NULL); + break; + case FrScale::ZSCALE: + Tcl_AppendResult(interp, "zscale", NULL); + break; + case FrScale::ZMAX: + Tcl_AppendResult(interp, "zmax", NULL); + break; + case FrScale::AUTOCUT: + printDouble(currentContext->autoCutPer()); + break; + case FrScale::USERCLIP: + Tcl_AppendResult(interp, "user", NULL); + break; + } +} + +void Base::getClipPreserveCmd() +{ + // backward compatibility + // used by backup + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getClipScopeCmd() +{ + switch (currentContext->clipScope()) { + case FrScale::GLOBAL: + Tcl_AppendResult(interp, "global", NULL); + break; + case FrScale::LOCAL: + Tcl_AppendResult(interp, "local", NULL); + break; + } +} + +void Base::getClipUserCmd() +{ + ostringstream str; + str << currentContext->clipUser() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getClipZScaleContrastCmd() +{ + ostringstream str; + str << currentContext->zContrast() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getClipZScaleSampleCmd() +{ + ostringstream str; + str << currentContext->zSample() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getClipZScaleLineCmd() +{ + ostringstream str; + str << currentContext->zLine() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getColorbarTagCmd() +{ + if (colorbartag) + Tcl_AppendResult(interp, colorbartag, NULL); + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getColorMapLevelCmd(int count) +{ + if (currentContext->cfits) { + getColorMapLevelCmd(count, currentContext->cfits->low(), + currentContext->cfits->high(), + currentContext->colorScaleType(), + currentContext->expo()); + } + else + getColorMapLevelCmd(count, currentContext->low(), + currentContext->high(), + currentContext->colorScaleType(), + currentContext->expo()); +} + +void Base::getColorMapLevelCmd(int count, const Vector& vv, + Coord::InternalSystem ref) +{ + if (currentContext->cfits) { + if (FitsImage* ptr=isInCFits(vv,ref,NULL)) { + getColorMapLevelCmd(count, ptr->low(), ptr->high(), + currentContext->colorScaleType(), + currentContext->expo()); + return; + } + } + + getColorMapLevelCmd(count, currentContext->low(), + currentContext->high(), + currentContext->colorScaleType(), + currentContext->expo()); +} + +void Base::getColorMapLevelCmd(int count, double ll, double hh, + FrScale::ColorScaleType scaleType, + float expo) +{ + if (inverseScale) + delete inverseScale; + inverseScale = NULL; + + switch (scaleType) { + case FrScale::LINEARSCALE: + inverseScale = new LinearInverseScale(count, ll, hh); + break; + case FrScale::LOGSCALE: + inverseScale = new LogInverseScale(count, ll, hh, expo); + break; + case FrScale::POWSCALE: + inverseScale = new PowInverseScale(count, ll, hh, expo); + break; + case FrScale::SQRTSCALE: + inverseScale = new SqrtInverseScale(count, ll, hh); + break; + case FrScale::SQUAREDSCALE: + inverseScale = new SquaredInverseScale(count, ll, hh); + break; + case FrScale::ASINHSCALE: + inverseScale = new AsinhInverseScale(count, ll, hh); + break; + case FrScale::SINHSCALE: + inverseScale = new SinhInverseScale(count, ll, hh); + break; + case FrScale::HISTEQUSCALE: + inverseScale = new HistEquInverseScale(count, ll, hh, + currentContext->histequ(), + HISTEQUSIZE); + break; + case FrScale::IISSCALE: + inverseScale = new IISInverseScale(count, ll, hh, + currentContext->fits->iisz()); + break; + } + + if (inverseScale) { + ostringstream str; + str << inverseScale->size() << ' ' << inverseScale->level() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } +} + +void Base::getColorScaleCmd() +{ + switch (currentContext->colorScaleType()) { + case FrScale::LINEARSCALE: + Tcl_AppendResult(interp, "linear", NULL); + break; + case FrScale::LOGSCALE: + Tcl_AppendResult(interp, "log", NULL); + break; + case FrScale::POWSCALE: + Tcl_AppendResult(interp, "pow", NULL); + break; + case FrScale::SQRTSCALE: + Tcl_AppendResult(interp, "sqrt", NULL); + break; + case FrScale::SQUAREDSCALE: + Tcl_AppendResult(interp, "squared", NULL); + break; + case FrScale::ASINHSCALE: + Tcl_AppendResult(interp, "asinh", NULL); + break; + case FrScale::SINHSCALE: + Tcl_AppendResult(interp, "sinh", NULL); + break; + case FrScale::HISTEQUSCALE: + Tcl_AppendResult(interp, "histequ", NULL); + break; + case FrScale::IISSCALE: + Tcl_AppendResult(interp, "linear", NULL); + break; + } +} + +void Base::getColorScaleLevelCmd(int count, double ll, double hh, + FrScale::ColorScaleType scaleType, + float expo) +{ + InverseScale* scale; + switch (scaleType) { + case FrScale::LINEARSCALE: + scale = new LinearInverseScale(count, ll, hh); + break; + case FrScale::LOGSCALE: + scale = new LogInverseScale(count, ll, hh, expo); + break; + case FrScale::POWSCALE: + scale = new PowInverseScale(count, ll, hh, expo); + break; + case FrScale::SQRTSCALE: + scale = new SqrtInverseScale(count, ll, hh); + break; + case FrScale::SQUAREDSCALE: + scale = new SquaredInverseScale(count, ll, hh); + break; + case FrScale::ASINHSCALE: + scale = new AsinhInverseScale(count, ll, hh); + break; + case FrScale::SINHSCALE: + scale = new SinhInverseScale(count, ll, hh); + break; + case FrScale::HISTEQUSCALE: + scale = new HistEquInverseScale(count, ll, hh, + currentContext->histequ(), + HISTEQUSIZE); + break; + case FrScale::IISSCALE: + scale = new IISInverseScale(count, ll, hh, + currentContext->fits->iisz()); + break; + } + + ostringstream str; + str << *scale << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + + delete scale; +} + +void Base::getColorScaleLogCmd() +{ + ostringstream str; + str << currentContext->expo() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getContourCmd(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + ostringstream str; + currentContext->contourListFV(str, sys, sky); + str << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getContourMethodCmd() +{ + Tcl_AppendResult(interp, currentContext->fvcontour().methodName(), NULL); +} + +void Base::getContourClipCmd() +{ + ostringstream str; + str << currentContext->fvcontour().limits() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getContourClipModeCmd() +{ + if (currentContext->fvcontour().clipMode() == FrScale::MINMAX) + Tcl_AppendResult(interp, "minmax", NULL); + else if (currentContext->fvcontour().clipMode() == FrScale::ZSCALE) + Tcl_AppendResult(interp, "zscale", NULL); + else if (currentContext->fvcontour().clipMode() == FrScale::ZMAX) + Tcl_AppendResult(interp, "zmax", NULL); + else if (currentContext->fvcontour().clipMode() == FrScale::USERCLIP) + Tcl_AppendResult(interp, "user", NULL); + else { + ostringstream str; + str << currentContext->fvcontour().clipMode() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } +} + +void Base::getContourColorNameCmd() +{ + Tcl_AppendResult(interp, currentContext->fvcontour().getColorName(), NULL); +} + +void Base::getContourDashCmd() +{ + if (currentContext->fvcontour().getDash()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getContourLevelCmd() +{ + Tcl_AppendResult(interp, currentContext->fvcontour().level(), NULL); +} + +void Base::getContourLineWidthCmd() +{ + ostringstream str; + str << currentContext->fvcontour().getLineWidth() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getContourNumLevelCmd() +{ + ostringstream str; + str << currentContext->fvcontour().numLevel() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getContourSmoothCmd() +{ + ostringstream str; + str << currentContext->fvcontour().smooth() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getContourScaleCmd() +{ + switch (currentContext->fvcontour().colorScaleType()) { + case FrScale::LINEARSCALE: + Tcl_AppendResult(interp, "linear", NULL); + break; + case FrScale::LOGSCALE: + Tcl_AppendResult(interp, "log", NULL); + break; + case FrScale::POWSCALE: + Tcl_AppendResult(interp, "pow", NULL); + break; + case FrScale::SQRTSCALE: + Tcl_AppendResult(interp, "sqrt", NULL); + break; + case FrScale::SQUAREDSCALE: + Tcl_AppendResult(interp, "squared", NULL); + break; + case FrScale::ASINHSCALE: + Tcl_AppendResult(interp, "asinh", NULL); + break; + case FrScale::SINHSCALE: + Tcl_AppendResult(interp, "sinh", NULL); + break; + case FrScale::HISTEQUSCALE: + Tcl_AppendResult(interp, "histequ", NULL); + break; + case FrScale::IISSCALE: + Tcl_AppendResult(interp, "linear", NULL); + break; + } +} + +void Base::getContourScaleLogCmd() +{ + ostringstream str; + str << currentContext->fvcontour().expo() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getCoordCmd(const Vector& vv, Coord::CoordSystem out, + Coord::SkyFrame sky, Coord::SkyFormat format) +{ + if (FitsImage* ptr=isInCFits(vv,Coord::CANVAS,NULL)) + printFromRef(ptr, mapToRef(vv,Coord::CANVAS), out, sky, format); + else + Tcl_AppendResult(interp, "0 0", NULL); +} + +void Base::getCoord3axisCmd(double vv, Coord::CoordSystem in, + Coord::CoordSystem out, int ss) +{ + if (currentContext->cfits) { + if (in==out) + printDouble(vv); + else { + // use first slice + double rr = currentContext->fits->mapToRef3axis(vv,in,ss); + double tt = currentContext->fits->mapFromRef3axis(rr,out,ss); + printDouble(tt); + } + } + else + Tcl_AppendResult(interp, "0", NULL); +} + +// used for Backup +void Base::getCropCmd(Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + FitsImage* ptr = currentContext->fits; + if (!ptr) + return; + + // params are in DATA coords + FitsBound* params =ptr->getDataParams(currentContext->secMode()); + Vector ll = Vector(params->xmin,params->ymin); + Vector ur = Vector(params->xmax,params->ymax); + + printFromRef(ptr, ll*ptr->dataToRef, sys, sky, format); + Tcl_AppendResult(interp, " ", NULL); + printFromRef(ptr, ur*ptr->dataToRef, sys, sky, format); +} + +void Base::getCropCenterCmd(Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, Coord::CoordSystem dcoord, + Coord::SkyDist dist) +{ + FitsImage* ptr = currentContext->fits; + if (!ptr) + return; + + // params are in DATA coords + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + Vector ll = Vector(params->xmin,params->ymin); + Vector ur = Vector(params->xmax,params->ymax); + Vector cc = (ur-ll)/2.+ll; + Vector dd = ur-ll; + + printFromRef(ptr, cc*ptr->dataToRef, sys, sky, format); + Tcl_AppendResult(interp, " ", NULL); + printLenFromRef(ptr, dd*ptr->dataToRef, dcoord, dist); +} + +void Base::getCrop3dCmd(Coord::CoordSystem sys) +{ + // use first slice + FitsImage* ptr = currentContext->fits; + if (!ptr) + return; + + FitsZBound* zparams = + currentContext->getDataParams(currentContext->secMode()); + double ff = ptr->mapFromRef3axis(zparams->zmin+.5,sys,2); + double tt = ptr->mapFromRef3axis(zparams->zmax-.5,sys,2); + + ostringstream str; + str << ff << ' ' << tt << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getCrosshairCmd(Coord::InternalSystem sys) +{ + ostringstream str; + str << mapFromRef(crosshair, sys) << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getCrosshairCmd(Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + if (currentContext->cfits) + printFromRef(currentContext->cfits, crosshair, sys, sky, format); + else + Tcl_AppendResult(interp, "0 0", NULL); +} + +void Base::getCrosshairStatusCmd() +{ + if (useCrosshair) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getDATASECCmd() +{ + if (currentContext->datasec()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getDataValuesCmd(const Vector& vv, Coord::InternalSystem ref, + const Vector& ss) +{ + Vector rr; + FitsImage* ptr = isInCFits(vv, ref, &rr); + if (!ptr) + return; + + Vector ll = rr - Vector((((Vector&)ss)[0]-1)/2,(((Vector&)ss)[1]-1)/2); + + SETSIGBUS + for (int jj=0; jj<((Vector&)ss)[1]; jj++) { + for (int ii=0; ii<((Vector&)ss)[0]; ii++) { + Vector dd = (ll+Vector(ii,jj)) * ptr->refToData; + FitsBound* params = + ptr->getDataParams(currentContext->secMode()); + + if (dd[0]>=params->xmin && dd[0]xmax && + dd[1]>=params->ymin && dd[1]ymax) + Tcl_AppendResult(interp, (char*)ptr->getValue(dd), " ", NULL); + } + } + CLEARSIGBUS +} + +void Base::getDataValuesCmd(int which, const Vector& vv, + Coord::CoordSystem sys, Coord::SkyFrame sky, + const Vector& dd, char* var) +{ + // clear an previous values + Tcl_UnsetVar(interp,var,0); + + // find anchor point + FitsImage* base = currentContext->cfits; + for (int ii=1; iinextMosaic(); + + if (!base) { + Tcl_SetVar(interp,var,"",0); + result = TCL_ERROR; + return; + } + Vector ll = base->mapLenToRef(dd,sys,Coord::DEGREE); + Vector bb = base->mapToRef(vv,sys,sky); + + SETSIGBUS + for (int ii=0; iilistFromRef(str,rr,sys,sky,Coord::DEGREES); + + int found = 0; + FitsImage* ptr = currentContext->fits; + while (ptr) { + Vector ss = rr * ptr->refToData; + FitsBound* params = + ptr->getDataParams(currentContext->secMode()); + + if (ss[0]>=params->xmin && ss[0]xmax && + ss[1]>=params->ymin && ss[1]ymax) { + Tcl_SetVar2(interp,var,str.str().c_str(),(char*)ptr->getValue(ss),0); + found = 1; + break; + } + ptr = ptr->nextMosaic(); + } + + if (!found) + Tcl_SetVar2(interp,var,str.str().c_str(),"",0); + } + } + CLEARSIGBUS +} + +void Base::getFitsNAxesCmd() +{ + printInteger(currentContext->naxes()); +} + +void Base::getFitsCenterCmd(Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + if (keyContext && keyContext->fits) + printFromRef(keyContext->fits, + imageCenter(keyContext->secMode())* + keyContext->fits->imageToRef, + sys, sky, format); + else + Tcl_AppendResult(interp, "0 0", NULL); +} + +void Base::getFitsCountCmd() +{ + printInteger(fitsCount()); +} + +void Base::getFitsDepthCmd(int ii) +{ + printInteger(currentContext->naxis(ii)); +} + +void Base::getFitsExtCmd(int which) +{ + which = abs(which); + FitsImage* rr = findAllFits(which); + if (rr) { + ostringstream str; + str << rr->ext() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getFitsExtCmd(const Vector& vv, Coord::InternalSystem ref) +{ + if (FitsImage* ptr=isInCFits(vv,ref,NULL)) { + ostringstream str; + str << ptr->ext() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getFitsHeaderCmd(int which) +{ + int prim = which < 0 ? 1:0; + which = abs(which); + + // modified for medatacube + FitsImage* rr = findAllFits(which); + if (rr) { + char* hh = !prim ? rr->displayHeader() : rr->displayPrimary(); + Tcl_AppendResult(interp, hh, NULL); + delete [] hh; + } + else + result = TCL_ERROR; +} + +void Base::getFitsHeaderKeywordCmd(int which, const char* key) +{ + which = abs(which); + + FitsImage* rr = findAllFits(which); + if (rr) { + char* value = rr->getKeyword(key); + if (value) { + Tcl_AppendResult(interp, value, NULL); + delete [] value; + return; + } + } + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getFitsHeaderWCSCmd(int which) +{ + // no primary + FitsImage* rr = findAllFits(which); + if (rr) { + char* hh = rr->displayWCS(); + Tcl_AppendResult(interp, hh, NULL); + delete [] hh; + } + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getFitsHeightCmd() +{ + if (currentContext->cfits) + printInteger(currentContext->cfits->height()); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getFitsFileNameCmd(FileNameType type) +{ + if (currentContext->cfits) + Tcl_AppendResult(interp, currentContext->cfits->getFileName(type), NULL); + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getFitsFileNameCmd(int which, FileNameType type) +{ + FitsImage* rr = findAllFits(which); + if (rr) + Tcl_AppendResult(interp, rr->getFileName(type), NULL); + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getFitsFileNameCmd(const Vector& vv, Coord::InternalSystem ref, + FileNameType type) +{ + if (FitsImage* ptr=isInCFits(vv,ref,NULL)) + Tcl_AppendResult(interp, ptr->getFileName(type), NULL); + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getFitsObjectNameCmd() +{ + if (currentContext->cfits) + Tcl_AppendResult(interp, currentContext->cfits->objectKeyword(), NULL); + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getFitsSizeCmd() +{ + ostringstream str; + if (keyContext->fits) + str << keyContext->fits->size() << ends; + else + str << Vector() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getFitsSizeCmd(Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyDist dist) +{ + if (keyContext->fits) { + if (!keyContext->fits->hasWCSCel(sys)) { + Tcl_AppendResult(interp, "0 0", NULL); + return; + } + + BBox bb = imageBBox(keyContext->secMode()); + Matrix mm = keyContext->fits->imageToRef; + + Vector ll = bb.ll * mm; + Vector lr = bb.lr() * mm; + Vector ur = bb.ur * mm; + Vector ul = bb.ul() * mm; + + Vector ww[4]; + ww[0] = keyContext->fits->mapFromRef(ll,sys,sky); + ww[1] = keyContext->fits->mapFromRef(lr,sys,sky); + ww[2] = keyContext->fits->mapFromRef(ur,sys,sky); + ww[3] = keyContext->fits->mapFromRef(ul,sys,sky); + + // we need to check for the case of crossing 0 in ra + // since ra is returned as 0 > ra > 360 + { + float min = 360; + float max = 0; + for (int ii=0; ii<4; ii++) { + if (ww[ii][0]max) + max=ww[ii][0]; + } + + // ok, we have a problem + if (max-min > 180) + for (int ii=0; ii<4; ii++) + if (ww[ii][0] > 180) + ww[ii][0] -= 360; + } + + BBox wbb(ww[0],ww[0]); + for (int ii=1; ii<4; ii++) + wbb.bound(ww[ii]); + + Vector ss(keyContext->fits->wcsdist(wbb.ll,wbb.lr(),sys), + keyContext->fits->wcsdist(wbb.ll,wbb.ul(),sys)); + + ostringstream str; + str << fixed; + switch (dist) { + case Coord::DEGREE: + str << setprecision(7); + break; + case Coord::ARCMIN: + str << setprecision(5); + ss *= 60; + break; + case Coord::ARCSEC: + str << setprecision(3); + ss *= 60*60; + break; + } + str << ss << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + else + Tcl_AppendResult(interp, "0 0", NULL); +} + +void Base::getFitsSliceCmd(int id) +{ + int ss = currentContext->slice(id); + if (ss>1) + printInteger(ss); + else + Tcl_AppendResult(interp, "1", NULL); +} + +void Base::getFitsSliceCmd(int id, Coord::CoordSystem sys) +{ + if (currentContext->fits) { + int ss = currentContext->slice(id); + double rr = currentContext->fits->mapFromRef3axis(ss,sys,id); + printDouble(rr); + } + else + Tcl_AppendResult(interp, "1", NULL); +} + +void Base::getFitsWidthCmd() +{ + if (currentContext->cfits) + printInteger(currentContext->cfits->width()); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getGridCmd() +{ + if (grid) { + Tcl_AppendElement(interp, coord.coordSystemStr((grid->system()))); + + Tcl_AppendElement(interp, coord.skyFrameStr((grid->sky()))); + + Tcl_AppendElement(interp, coord.skyFormatStr(grid->skyFormat())); + + switch (grid->type()) { + case Grid::ANALYSIS: + Tcl_AppendElement(interp, "analysis"); + break; + case Grid::PUBLICATION: + Tcl_AppendElement(interp, "publication"); + break; + } + } + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getGridOptionCmd() +{ + if (grid) + Tcl_AppendResult(interp, grid->option(), NULL); + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getGridVarsCmd() +{ + if (grid) + Tcl_AppendResult(interp, grid->vars(), NULL); + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getHistogramCmd(char* xName, char* yName, int num) +{ + currentContext->bltHist(xName, yName, num); +} + +void Base::getHorzCutCmd(char* xx, char* yy, const Vector& vv, + Coord::InternalSystem ref) +{ + Vector rr; + if (isInCFits(vv, ref, &rr)) + bltCut(xx, yy, Coord::XX, rr); + else + result = TCL_ERROR; +} + +void Base::getInfoCmd(char* var) +{ + if (currentContext->cfits) { + Tcl_SetVar2(interp,var,"filename",(char*)currentContext->cfits->getFileName(ROOTBASE),0); + Tcl_SetVar2(interp,var,"object", + (char*)currentContext->cfits->objectKeyword(),0); + Tcl_SetVar2(interp,var,"min",(char*)currentContext->cfits->getMin(),0); + Tcl_SetVar2(interp,var,"min,x",(char*)currentContext->cfits->getMinX(),0); + Tcl_SetVar2(interp,var,"min,y",(char*)currentContext->cfits->getMinY(),0); + Tcl_SetVar2(interp,var,"max",(char*)currentContext->cfits->getMax(),0); + Tcl_SetVar2(interp,var,"max,x",(char*)currentContext->cfits->getMaxX(),0); + Tcl_SetVar2(interp,var,"max,y",(char*)currentContext->cfits->getMaxY(),0); + Tcl_SetVar2(interp,var,"low",(char*)currentContext->cfits->getLow(),0); + Tcl_SetVar2(interp,var,"high",(char*)currentContext->cfits->getHigh(),0); + } + else + getInfoClearName(var); + + getInfoClearValue(var); + getInfoClearWCS(var); +} + +void Base::getInfoCmd(const Vector& vv, Coord::InternalSystem ref, char* var) +{ + FitsBound* params; + int mosaic; + + Vector3d rr = mapToRef3d(vv,ref); + + // make sure we have an image + FitsImage* ptr = currentContext->cfits; + FitsImage* sptr = currentContext->cfits; + if (!ptr) + goto noFits; + + mosaic = isMosaic(); + params = sptr->getDataParams(currentContext->secMode()); + + if (!mosaic) { + Tcl_SetVar2(interp,var,"filename",(char*)sptr->getFileName(ROOTBASE),0); + Tcl_SetVar2(interp,var,"object",(char*)sptr->objectKeyword(),0); + Tcl_SetVar2(interp,var,"min",(char*)sptr->getMin(),0); + Tcl_SetVar2(interp,var,"min,x",(char*)sptr->getMinX(),0); + Tcl_SetVar2(interp,var,"min,y",(char*)sptr->getMinY(),0); + Tcl_SetVar2(interp,var,"max",(char*)sptr->getMax(),0); + Tcl_SetVar2(interp,var,"max,x",(char*)sptr->getMaxX(),0); + Tcl_SetVar2(interp,var,"max,y",(char*)sptr->getMaxY(),0); + Tcl_SetVar2(interp,var,"low",(char*)sptr->getLow(),0); + Tcl_SetVar2(interp,var,"high",(char*)sptr->getHigh(),0); + } + + if (((Vector&)vv)[0]<0 && ((Vector&)vv)[1]<0) + goto noImage; + + // clear values + Tcl_SetVar2(interp,var,"value","",0); + Tcl_SetVar2(interp,var,"value,red","",0); + Tcl_SetVar2(interp,var,"value,green","",0); + Tcl_SetVar2(interp,var,"value,blue","",0); + + do { + Vector img = Vector(rr) * sptr->refToData; + + if (img[0]>=params->xmin && img[0]xmax && + img[1]>=params->ymin && img[1]ymax) { + + if (mosaic) { + Tcl_SetVar2(interp,var,"filename",(char*)sptr->getFileName(ROOTBASE),0); + Tcl_SetVar2(interp,var,"object",(char*)sptr->objectKeyword(),0); + Tcl_SetVar2(interp,var,"min",(char*)sptr->getMin(),0); + Tcl_SetVar2(interp,var,"min,x",(char*)sptr->getMinX(),0); + Tcl_SetVar2(interp,var,"min,y",(char*)sptr->getMinY(),0); + Tcl_SetVar2(interp,var,"max",(char*)sptr->getMax(),0); + Tcl_SetVar2(interp,var,"max,x",(char*)sptr->getMaxX(),0); + Tcl_SetVar2(interp,var,"max,y",(char*)sptr->getMaxY(),0); + Tcl_SetVar2(interp,var,"low",(char*)sptr->getLow(),0); + Tcl_SetVar2(interp,var,"high",(char*)sptr->getHigh(),0); + } + + SETSIGBUS + Tcl_SetVar2(interp,var,"value",(char*)sptr->getValue(img),0); + CLEARSIGBUS + + coordToTclArray(sptr,rr,Coord::IMAGE,var,"image"); + // use first slice + coord3ToTclArray(ptr,rr,Coord::IMAGE,var,"image"); + + coordToTclArray(sptr,rr,Coord::PHYSICAL,var,"physical"); + // use first slice + coord3ToTclArray(ptr,rr,Coord::PHYSICAL,var,"physical"); + + if (hasATMV()) { + coordToTclArray(sptr,rr,Coord::AMPLIFIER,var,"amplifier"); + // use first slice + coord3ToTclArray(ptr,rr,Coord::AMPLIFIER,var,"amplifier"); + } + else { + Tcl_SetVar2(interp,var,"amplifier,x","",0); + Tcl_SetVar2(interp,var,"amplifier,y","",0); + Tcl_SetVar2(interp,var,"amplifier,z","",0); + } + + if (hasDTMV()) { + coordToTclArray(sptr,rr,Coord::DETECTOR,var,"detector"); + // use first slice + coord3ToTclArray(ptr,rr,Coord::DETECTOR,var,"detector"); + } + else { + Tcl_SetVar2(interp,var,"detector,x","",0); + Tcl_SetVar2(interp,var,"detector,y","",0); + Tcl_SetVar2(interp,var,"detector,z","",0); + } + + getInfoWCS(var,rr,ptr,sptr); + return; + } + else { + if (mosaic) { + sptr = sptr->nextMosaic(); + if (sptr) + params = sptr->getDataParams(currentContext->secMode()); + } + else { + getInfoWCS(var,rr,ptr,sptr); + goto noImage; + } + } + } + while (mosaic && sptr); + + // mosaic gap + getInfoWCS(var,rr,ptr,ptr); + + // else, return blanks + noFits: + getInfoClearName(var); + + noImage: + getInfoClearValue(var); +} + +void Base::getInfoClipCmd() +{ + if (currentContext->cfits) { + Tcl_AppendElement(interp, (char*)currentContext->cfits->getLow()); + Tcl_AppendElement(interp, (char*)currentContext->cfits->getHigh()); + } + else { + Tcl_AppendElement(interp, "0"); + Tcl_AppendElement(interp, "0"); + } +} + +void Base::getIRAFAlignCmd() +{ + Tcl_AppendResult(interp, (irafAlign_ ? "1" : "0"), NULL); +} + +void Base::getMaskColorCmd() +{ + Tcl_AppendResult(interp, maskColorName, NULL); +} + +void Base::getMaskMarkCmd() +{ + if (maskMark) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getMaskTransparencyCmd() +{ + printDouble((1-maskAlpha)*100.); +} + +void Base::getMinMaxCmd() +{ + ostringstream str; + str << currentContext->getMinMax() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getNANColorCmd() +{ + Tcl_AppendResult(interp, nanColorName, NULL); +} + +void Base::getOrientCmd() +{ + switch (orientation) { + case Coord::NORMAL: + Tcl_AppendResult(interp, "none", NULL); + return; + case Coord::XX: + Tcl_AppendResult(interp, "x", NULL); + return; + case Coord::YY: + Tcl_AppendResult(interp, "y", NULL); + return; + case Coord::XY: + Tcl_AppendResult(interp, "xy", NULL); + return; + } +} + +void Base::getPanPreserveCmd() +{ + if (preservePan) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getPixelTableCmd(const Vector& vv, Coord::InternalSystem ref, + int ww, int hh, char* var) +{ + Vector rr; + FitsImage* ptr = isInCFits(vv, ref, &rr); + if (!ptr) { + // else return blank + for (int jj=0; jj<=hh; jj++) { + for (int ii=0; ii<=ww; ii++) { + ostringstream str; + str << ii << ',' << jj << ends; + Tcl_SetVar2(interp,var,str.str().c_str(),"",0); + } + } + return; + } + + Vector half((ww-1)/2,(hh-1)/2); + Vector ur = rr+half; + Vector ll = rr-half; + int ii,jj; + + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + + // x (columns) + for (ii=0,jj=0; ii=params->xmin && ll[0]xmax && + ur[1]>=params->ymin && ll[1]ymax) { + Vector pt = ((ll+Vector(ii,jj)) * dataToImage).round(); + if (pt[0]>params->xmin && pt[0]<=params->xmax) { + ostringstream lstr; + lstr << pt[0] << ends; + Tcl_SetVar2(interp,var,str.str().c_str(),lstr.str().c_str(),0); + } + else + Tcl_SetVar2(interp,var,str.str().c_str(),"",0); + } + else + Tcl_SetVar2(interp,var,str.str().c_str(),"",0); + } + + // y (rows) + for (ii=0,jj=0; jj=params->xmin && ll[0]xmax && + ur[1]>=params->ymin && ll[1]ymax) { + Vector pt = ((ll+Vector(ii,jj)) * dataToImage).round(); + if (pt[1]>params->ymin && pt[1]<=params->ymax) { + ostringstream lstr; + lstr << pt[1] << ends; + Tcl_SetVar2(interp,var,str.str().c_str(),lstr.str().c_str(),0); + } + else + Tcl_SetVar2(interp,var,str.str().c_str(),"",0); + } + else + Tcl_SetVar2(interp,var,str.str().c_str(),"",0); + } + + // body + + SETSIGBUS + for (jj=0; jj=params->xmin && pt[0]xmax && + pt[1]>=params->ymin && pt[1]ymax) + Tcl_SetVar2(interp,var,str.str().c_str(),(char*)ptr->getValue(pt),0); + else + Tcl_SetVar2(interp,var,str.str().c_str(),"",0); + } + } + CLEARSIGBUS +} + +void Base::getRotateCmd() +{ + printDouble(radToDeg(rotation)); +} + +void Base::getSmoothFunctionCmd() +{ + switch (currentContext->smoothFunction()) { + case Context::BOXCAR: + Tcl_AppendResult(interp, "boxcar", NULL); + return; + case Context::TOPHAT: + Tcl_AppendResult(interp, "tophat", NULL); + return; + case Context::GAUSSIAN: + Tcl_AppendResult(interp, "gaussian", NULL); + return; + } +} + +void Base::getSmoothRadiusCmd() +{ + printInteger(currentContext->smoothRadius()); +} + +void Base::getThreadsCmd() +{ + ostringstream str; + str << nthreads_ << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getValueCmd(const Vector& vv, Coord::InternalSystem sys) +{ + Vector rr; + SETSIGBUS + if (FitsImage* ptr=isInCFits(vv,sys,&rr)) + Tcl_AppendResult(interp, ptr->getValue(rr), NULL); + CLEARSIGBUS +} + +void Base::getVertCutCmd(char* xx, char* yy, const Vector& vv, + Coord::InternalSystem ref) +{ + Vector rr; + if (isInCFits(vv, ref, &rr)) + bltCut(xx, yy, Coord::YY, rr); + else + result = TCL_ERROR; +} + +void Base::getWCSCmd() +{ + Tcl_AppendResult(interp, coord.coordSystemStr(wcsSystem_), " ", + coord.skyFrameStr(wcsSky_), " ", + coord.skyFormatStr(wcsSkyFormat_), NULL); +} + +void Base::getWCSAlignCmd() +{ + Tcl_AppendResult(interp, (wcsAlign_ ? "1" : "0"), NULL); +} + +void Base::getWCSAlignPointerCmd() +{ + ostringstream str; + if (keyContext->fits) + str << (unsigned short*)keyContext->fits << ends; + else + str << (unsigned short*)NULL << ends; + + Tcl_AppendResult(interp, (wcsAlign_ ? "1" : "0"), " ", + str.str().c_str(), " ", + coord.coordSystemStr(wcsSystem_), " ", + coord.skyFrameStr(wcsSky_), NULL); +} + +void Base::getWCSNameCmd(Coord::CoordSystem sys) +{ + if (currentContext->cfits && currentContext->cfits->hasWCS(sys)) { + char* wcsname = (char*)currentContext->cfits->getWCSName(sys); + if (wcsname) { + Tcl_AppendResult(interp, wcsname, NULL); + return; + } + } + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getZoomCmd() +{ + ostringstream str; + str << zoom_ << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::gridDeleteCmd() +{ + if (grid) + delete grid; + grid = NULL; + + update(PIXMAP); +} + +void Base::hasAmplifierCmd() +{ + if (hasATMV()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasBinColCmd(const char* str) +{ + if (currentContext->fits) { + if (currentContext->fits->hasBinCol(str)) { + Tcl_AppendResult(interp, "1", NULL); + return; + } + } + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasContourCmd() +{ + if (hasContour()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasContourAuxCmd() +{ + if (hasContourAux()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasCropCmd() +{ + switch (currentContext->secMode()) { + case FrScale::IMGSEC: + case FrScale::DATASEC: + Tcl_AppendResult(interp, "0", NULL); + break; + case FrScale::CROPSEC: + Tcl_AppendResult(interp, "1", NULL); + break; + } +} + +void Base::hasDATAMINCmd() +{ + if (currentContext->cfits && currentContext->cfits->hasDATAMIN()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasDATASECCmd() +{ + if (currentContext->cfits && currentContext->cfits->hasDATASEC()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasDetectorCmd() +{ + if (hasDTMV()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasFitsCmd() +{ + if (currentContext->fits) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasFitsHPXCmd() +{ + if (currentContext->fits && currentContext->fits->isHPX()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasFitsBinCmd() +{ + if (currentContext->fits && currentContext->fits->isHist()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasFitsCubeCmd() +{ + if (isCube()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasFitsMosaicCmd() +{ + if (isMosaic()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasGridCmd() +{ + if (grid) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasIISCmd() +{ + if (isIIS()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasIRAFMINCmd() +{ + if (currentContext->cfits && currentContext->cfits->hasIRAFMIN()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasPhysicalCmd() +{ + if (hasLTMV()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasSmoothCmd() +{ + if (currentContext->hasSmooth()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasSystemCmd(Coord::CoordSystem sys) +{ + switch (sys) { + case Coord::IMAGE: + Tcl_AppendResult(interp, "1", NULL); + return; + case Coord::PHYSICAL: + hasPhysicalCmd(); + return; + case Coord::AMPLIFIER: + hasAmplifierCmd(); + return; + case Coord::DETECTOR: + hasDetectorCmd(); + return; + default: + hasWCSCmd(sys); + return; + } +} + +void Base::hasWCSCmd(Coord::CoordSystem sys) +{ + Tcl_AppendResult(interp, (hasWCS(sys) ? "1" : "0"), NULL); +} + +void Base::hasWCSAltCmd() +{ + Tcl_AppendResult(interp, (currentContext->cfits && currentContext->cfits->wcsHeader() ? "1" : "0"), NULL); +} + +void Base::hasWCSEquCmd(Coord::CoordSystem sys) +{ + Tcl_AppendResult(interp, (hasWCSEqu(sys) ? "1" : "0"), NULL); +} + +void Base::hasWCSCelCmd(Coord::CoordSystem sys) +{ + Tcl_AppendResult(interp, (hasWCSCel(sys) ? "1" : "0"), NULL); +} + +void Base::hasWCSxCmd(Coord::CoordSystem sys) +{ + Tcl_AppendResult(interp, (hasWCSx(sys) ? "1" : "0"), NULL); +} + +void Base::irafAlignCmd(int which) +{ + irafAlign_ = which; + + alignIRAF(); + update(MATRIX); +} + +// loadIncr is only used by LICK OBS and MMT +// maintained for backward compatibility +void Base::loadIncrDataCmd(int which, int x0, int y0, int x1, int y1) +{ +} + +void Base::loadIncrMinMaxCmd(int which, int x0, int y0, int x1, int y1) +{ +} + +void Base::loadIncrEndCmd() +{ + currentContext->resetSecMode(); + + currentContext->updateClip(); + currentContext->updateContours(); + updateColorScale(); + update(MATRIX); +} + +void Base::highliteCmd(int which) +{ + useHighlite = which ? 1 : 0; + update(PIXMAP); +} + +void Base::magnifierCmd(int s) +{ + useMagnifier = s; + updateMagnifier(); +} + +void Base::magnifierCmd(char* n, int w, int h) +{ + strcpy(magnifierName,n); + magnifierWidth = w; + magnifierHeight = h; + + if (magnifierPixmap) + Tk_FreePixmap(display, magnifierPixmap); + magnifierPixmap = 0; + + if (magnifierXImage) + XDestroyImage(magnifierXImage); + magnifierXImage = NULL; + + if (magnifierWidth > 0 && magnifierHeight > 0) { + magnifierPixmap = Tk_GetPixmap(display, Tk_WindowId(tkwin), + magnifierWidth, magnifierHeight, depth); + if (!magnifierPixmap) { + internalError("Unable to Create Magnifier Pixmap"); + return; + } + + if (!magnifierXImage) { + if (!(magnifierXImage = XGetImage(display, magnifierPixmap, 0, 0, + magnifierWidth, magnifierHeight, + AllPlanes, ZPixmap))){ + internalError("Unable to Create Magnifier XImage"); + return; + } + } + } +} + +void Base::magnifierCursorCmd(int which) +{ + useMagnifierCursor = which; + updateMagnifier(); +} + +void Base::magnifierColorCmd(const char* color) +{ + if (magnifierColorName) + delete [] magnifierColorName; + magnifierColorName = dupstr(color); + updateMagnifier(); +} + +void Base::magnifierGraphicsCmd(int which) +{ + useMagnifierGraphics = which; + updateMagnifier(); +} + +void Base::magnifierZoomCmd(double z) +{ + magnifierZoom_ = fabs(z); + updateMagnifier(); +} + +void Base::matchCmd(const char* xxname1, const char* yyname1, + Coord::CoordSystem sys1, Coord::SkyFrame sky1, + const char* xxname2, const char* yyname2, + Coord::CoordSystem sys2, Coord::SkyFrame sky2, + double rad, Coord::CoordSystem sys, Coord::SkyDist dist, + const char* rrname) +{ + if (keyContext && keyContext->fits) + keyContext->fits->match(xxname1, yyname1, sys1, sky1, + xxname2, yyname2, sys2, sky2, + rad, sys, dist, + rrname); +} + +void Base::maskClearCmd() +{ + currentContext->mask.deleteAll(); + update(BASE); +} + +void Base::maskColorCmd(const char* color) +{ + if (maskColorName) + delete [] maskColorName; + + maskColorName = dupstr(color); +} + +void Base::maskTransparencyCmd(float t) +{ + maskAlpha = 1-(t/100.); + update(BASE); +} + +void Base::nanColorCmd(const char* color) +{ + if (nanColorName) + delete [] nanColorName; + nanColorName = dupstr(color); + nanColor = getXColor(nanColorName); + update(BASE); +} + +void Base::orientCmd(Coord::Orientation which) +{ + orientation = which; + + switch (orientation) { + case Coord::NORMAL: + orientationMatrix.identity(); + break; + case Coord::XX: + orientationMatrix = FlipX(); + break; + case Coord::YY: + orientationMatrix = FlipY(); + break; + case Coord::XY: + orientationMatrix = FlipXY(); + break; + } + + update(MATRIX); +} + +void Base::panBeginCmd(const Vector& vv) +{ + // vv and panCursor are in CANVAS coords + panCursor = vv; + + // copy tmp pixmap + panPM = Tk_GetPixmap(display, Tk_WindowId(tkwin), + options->width, options->height, depth); + if (!panPM) { + internalError("Unable to Create Pan Motion Pixmap"); + return; + } + XCopyArea(display, pixmap, panPM, widgetGC, 0, 0, options->width, + options->height, 0,0); +} + +void Base::panMotionCmd(const Vector& vv) +{ + // vv and panCursor are in CANVAS coords + + // Clear + Vector diff = (vv*canvasToWidget) - (panCursor*canvasToWidget); + + BBox hh,ww; + if (diff[0]>0 && diff[1]>0) { + hh = BBox(Vector(0,0), Vector(options->width, diff[1])); + ww = BBox(Vector(0,0), Vector(diff[0], options->height)); + } else if (diff[0]>0 && diff[1]<0) { + hh = BBox(Vector(options->width,options->height), + Vector(0,options->height+diff[1])); + ww = BBox(Vector(0,0), Vector(diff[0], options->height)); + } else if (diff[0]<0 && diff[1]>0) { + hh = BBox(Vector(0,0), Vector(options->width, diff[1])); + ww = BBox(Vector(options->width,options->height), + Vector(options->width+diff[0], 0)); + } else if (diff[0]<0 && diff[1]<0) { + hh = BBox(Vector(options->width,options->height), + Vector(0,options->height+diff[1])); + ww = BBox(Vector(options->width,options->height), + Vector(options->width+diff[0], 0)); + } + + hh = hh * widgetToWindow; + ww = ww * widgetToWindow; + + XSetForeground(display, widgetGC, getColor(bgColorName)); + + Vector hs = hh.size(); + XFillRectangle(display, Tk_WindowId(tkwin), widgetGC, + (int)hh.ll[0], (int)hh.ll[1], (int)hs[0], (int)hs[1]); + + Vector ws = ww.size(); + XFillRectangle(display, Tk_WindowId(tkwin), widgetGC, + (int)ww.ll[0], (int)ww.ll[1], (int)ws[0], (int)ws[1]); + + // display tmp pixmap at new location + Vector dd = ((vv * canvasToWidget) - (panCursor * canvasToWidget)) * + widgetToWindow; + XCopyArea(display, panPM, Tk_WindowId(tkwin), panGCXOR, + 0, 0, options->width, options->height, dd[0], dd[1]); +} + +void Base::pannerCmd(int s) +{ + usePanner = s; + updatePanner(); +} + +void Base::pannerCmd(char* n, int w, int h) +{ + strcpy(pannerName,n); + pannerWidth = w; + pannerHeight = h; + + if (pannerPixmap) + Tk_FreePixmap(display, pannerPixmap); + pannerPixmap = 0; + + if (pannerXImage) + XDestroyImage(pannerXImage); + pannerXImage = NULL; + + if (pannerWidth > 0 && pannerHeight > 0) { + if (!(pannerPixmap = Tk_GetPixmap(display, Tk_WindowId(tkwin), + pannerWidth, pannerHeight, depth))) { + internalError("Unable to Create Panner Pixmap"); + return; + } + + if (!(pannerXImage = XGetImage(display, pannerPixmap, 0, 0, + pannerWidth, pannerHeight, + AllPlanes, ZPixmap))){ + internalError("Unable to Create Panner XImage"); + return; + } + } + + // update panner matrices + update(MATRIX); +} + +void Base::rotateCmd(double r) +{ + rotation += r; + update(MATRIX); +} + +void Base::rotateToCmd(double r) +{ + rotation = r; + update(MATRIX); +} + +void Base::saveFitsFileCmd(const char* fn) +{ + OutFitsFile str(fn); + saveFits(str); +} + +void Base::saveFitsChannelCmd(const char* ch) +{ + OutFitsChannel str(interp, ch); + saveFits(str); +} + +void Base::saveFitsSocketCmd(int ss) +{ + OutFitsSocket str(ss); + saveFits(str); +} + +void Base::saveFitsTableFileCmd(const char* fn) +{ + OutFitsFile str(fn); + saveFitsTable(str); +} + +void Base::saveFitsTableChannelCmd(const char* ch) +{ + OutFitsChannel str(interp, ch); + saveFitsTable(str); +} + +void Base::saveFitsTableSocketCmd(int ss) +{ + OutFitsSocket str(ss); + saveFitsTable(str); +} + +void Base::saveFitsSliceFileCmd(const char* fn) +{ + OutFitsFile str(fn); + saveFitsSlice(str); +} + +void Base::saveFitsSliceChannelCmd(const char* ch) +{ + OutFitsChannel str(interp, ch); + saveFitsSlice(str); +} + +void Base::saveFitsSliceSocketCmd(int ss) +{ + OutFitsSocket str(ss); + saveFitsSlice(str); +} + +void Base::saveFitsExtCubeFileCmd(const char* fn) +{ + OutFitsFile str(fn); + saveFitsExtCube(str); +} + +void Base::saveFitsExtCubeChannelCmd(const char* ch) +{ + OutFitsChannel str(interp, ch); + saveFitsExtCube(str); +} + +void Base::saveFitsExtCubeSocketCmd(int ss) +{ + OutFitsSocket str(ss); + saveFitsExtCube(str); +} + +void Base::saveFitsMosaicFileCmd(const char* fn, int which) +{ + OutFitsFile str(fn); + saveFitsMosaic(str, which); +} + +void Base::saveFitsMosaicChannelCmd(const char* ch, int which) +{ + OutFitsChannel str(interp, ch); + saveFitsMosaic(str, which); +} + +void Base::saveFitsMosaicSocketCmd(int ss, int which) +{ + OutFitsSocket str(ss); + saveFitsMosaic(str, which); +} + +void Base::saveFitsMosaicImageFileCmd(const char* fn) +{ + OutFitsFile str(fn); + saveFitsMosaicImage(str); +} + +void Base::saveFitsMosaicImageChannelCmd(const char* ch) +{ + OutFitsChannel str(interp, ch); + saveFitsMosaicImage(str); +} + +void Base::saveFitsMosaicImageSocketCmd(int ss) +{ + OutFitsSocket str(ss); + saveFitsMosaicImage(str); +} + +void Base::saveArrayFileCmd(const char* fn, FitsFile::ArchType endian) +{ + if (currentContext->cfits) { + OutFitsFile str(fn); + saveArray(str, endian); + } +} + +void Base::saveArrayChannelCmd(const char* ch, FitsFile::ArchType endian) +{ + OutFitsChannel str(interp, ch); + saveArray(str, endian); +} + +void Base::saveArraySocketCmd(int ss, FitsFile::ArchType endian) +{ + OutFitsSocket str(ss); + saveArray(str, endian); +} + +void Base::saveNRRDFileCmd(const char* fn, FitsFile::ArchType endian) +{ + OutFitsFile str(fn); + saveNRRD(str, endian); +} + +void Base::saveNRRDChannelCmd(const char* ch, FitsFile::ArchType endian) +{ + OutFitsChannel str(interp, ch); + saveNRRD(str, endian); +} + +void Base::saveNRRDSocketCmd(int ss, FitsFile::ArchType endian) +{ + OutFitsSocket str(ss); + saveNRRD(str, endian); +} + +void Base::saveENVIFileCmd(const char* hdr, const char* fn, + FitsFile::ArchType endian) +{ + ofstream str(hdr); + OutFitsFile str2(fn); + saveENVI(str, str2, endian); +} + +void Base::sliceCmd(int id, int ss) +{ + // IMAGE (ranges 1-n) + setSlice(id,ss); + updateMagnifier(); +} + +void Base::sliceCmd(int id, double vv, Coord::CoordSystem sys) +{ + double rr = currentContext->fits->mapToRef3axis(vv,sys,id); + int ss = currentContext->fits->mapFromRef3axis(rr,Coord::IMAGE,id); + + // IMAGE (ranges 1-n) + setSlice(id,ss); + updateMagnifier(); +} + +void Base::smoothCmd(int function, int radius) +{ + currentContext->setSmooth(1, (Context::SmoothFunction)function, radius); + currentContext->analysis(); + updateColorScale(); + // for 3d, rebuffer + update(MATRIX); +} + +void Base::smoothDeleteCmd() +{ + currentContext->setSmooth(0); + currentContext->analysis(); + updateColorScale(); + // for 3d, rebuffer + update(MATRIX); +} + +void Base::threadsCmd(int th) +{ + if (th>=1) + nthreads_ = th; +} + +// not used +// don't know if this is used by anyone else +void Base::unloadFitsCmd() +{ + unloadAllFits(); + update(MATRIX); +} + +void Base::updateFitsCmd(int now) +{ + // for 3d, rebuffer + if (now) { + syncUpdate =1; + updateNow(MATRIX); + syncUpdate =0; + } + else + update(MATRIX); +} + +void Base::updateFitsCmd(int which, BBox bb, int now) +{ + // Note: bb is in IMAGE coords + FitsImage* ptr = currentContext->fits; + if (which > 0) { + for (int ii=0; ii<(which-1); ii++) { + if (ptr) + ptr = ptr->nextMosaic(); + } + } + + if (ptr) { + BBox bbb = bb*ptr->imageToRef; + + Vector ll = mapFromRef(bbb.ll,Coord::CANVAS); + Vector lr = mapFromRef(bbb.lr(),Coord::CANVAS); + Vector ur = mapFromRef(bbb.ur,Coord::CANVAS); + Vector ul = mapFromRef(bbb.ul(),Coord::CANVAS); + + BBox rr(ll); + rr.bound(lr); + rr.bound(ur); + rr.bound(ul); + + if (now) { + syncUpdate =1; + updateNow(BASE, rr); + syncUpdate =0; + } + else + update(BASE, rr); + } +} + +void Base::updateMagnifierCmd(const Vector& v) +{ + updateMagnifier(v); +} + +void Base::updatePannerCmd() +{ + updatePanner(); +} + +void Base::warpCmd(const Vector& vv) +{ + warp((Vector&)vv); +} + +void Base::warpToCmd(const Vector& vv) +{ + Vector rr = vv*canvasToWindow; + warpTo(rr); +} + +void Base::wcsCmd(Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + wcsSystem_ = sys; + if (hasWCSEqu(sys)) { + wcsSky_ = sky; + wcsSkyFormat_ = format; + } + else if (hasWCSCel(sys)) { + wcsSky_ = Coord::GALACTIC; + wcsSkyFormat_ = format; + } + else { + wcsSky_ = sky; + wcsSkyFormat_ = format; + } +} + +void Base::wcsAlignCmd(int which) +{ + wcsAlign_ = which; + + alignWCS(); + update(MATRIX); +} + +// used by backup +void Base::wcsAlignCmd(int which, Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + wcsAlign_ = which; + + alignWCS(sys, sky); + update(MATRIX); +} + +void Base::wcsAlignCmd(int which, FitsImage* ptr, Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + wcsAlign_ = which; + + if (hasWCSEqu(sys)) + wcsSky_ = sky; + else if (hasWCSCel(sys)) + wcsSky_ = Coord::GALACTIC; + else + wcsSky_ = sky; + + alignWCS(ptr, sys); + update(MATRIX); +} + +void Base::wcsAppendCmd(int which, int fd) +{ + if (!currentContext->cfits) + return; + + boost::fdistream str(fd); + if (!str) { + Tcl_AppendResult(interp, " unable to read wcs infomation", NULL); + result = TCL_ERROR; + return; + } + + FitsImage* rr = findAllFits(which); + if (rr) { + while (rr) { + rr->appendWCS(str); + rr=rr->nextSlice(); + } + } + else + result = TCL_ERROR; +} + +void Base::wcsAppendCmd(int which, const char* fn) +{ + if (!currentContext->cfits) + return; + + ifstream str(fn); + if (!str) { + Tcl_AppendResult(interp, " unable to load wcs file ", fn, NULL); + result = TCL_ERROR; + return; + } + + FitsImage* rr = findAllFits(which); + if (rr) { + while (rr) { + rr->appendWCS(str); + rr=rr->nextSlice(); + } + } + else + result = TCL_ERROR; +} + +void Base::wcsAppendTxtCmd(int which, const char* txt) +{ + if (!currentContext->cfits) + return; + + istringstream str(txt); + if (!str) { + Tcl_AppendResult(interp, " unable to process text", NULL); + result = TCL_ERROR; + return; + } + + FitsImage* rr = findAllFits(which); + if (rr) { + while (rr) { + rr->appendWCS(str); + rr=rr->nextSlice(); + } + } + else + result = TCL_ERROR; +} + +void Base::wcsResetCmd(int which) +{ + if (!currentContext->cfits) + return; + + FitsImage* rr = findAllFits(which); + if (rr) + while (rr) { + rr->resetWCS(); + rr=rr->nextSlice(); + } + else + result = TCL_ERROR; +} + +void Base::wcsReplaceCmd(int which, int fd) +{ + if (!currentContext->cfits) + return; + + boost::fdistream str(fd); + if (!str) { + Tcl_AppendResult(interp, " unable to read wcs infomation", NULL); + result = TCL_ERROR; + return; + } + + FitsImage* rr = findAllFits(which); + if (rr) { + while (rr) { + rr->replaceWCS(str); + rr=rr->nextSlice(); + } + } + else + result = TCL_ERROR; +} + +void Base::wcsReplaceCmd(int which, const char* fn) +{ + if (!currentContext->cfits) + return; + + ifstream str(fn); + if (!str) { + Tcl_AppendResult(interp, " unable to load wcs file ", fn, NULL); + result = TCL_ERROR; + return; + } + + FitsImage* rr = findAllFits(which); + if (rr) { + while (rr) { + rr->replaceWCS(str); + rr=rr->nextSlice(); + } + } + else + result = TCL_ERROR; +} + +void Base::wcsReplaceTxtCmd(int which, const char* txt) +{ + if (!currentContext->cfits) + return; + + istringstream str(txt); + if (!str) { + Tcl_AppendResult(interp, " unable to process text", NULL); + result = TCL_ERROR; + return; + } + + FitsImage* rr = findAllFits(which); + if (rr) { + while (rr) { + rr->replaceWCS(str); + rr=rr->nextSlice(); + } + } + else + result = TCL_ERROR; +} + +void Base::zoomCmd(const Vector& z) +{ + Vector az = ((Vector&)z).abs(); + zoom_[0] *= az[0]; + zoom_[1] *= az[1]; + update(MATRIX); +} + +void Base::zoomToCmd(const Vector& z) +{ + zoom_ = ((Vector&)z).abs(); + update(MATRIX); +} diff --git a/tksao/frame/baseellipse.C b/tksao/frame/baseellipse.C new file mode 100644 index 0000000..290bf38 --- /dev/null +++ b/tksao/frame/baseellipse.C @@ -0,0 +1,768 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "baseellipse.h" +#include "fitsimage.h" + +BaseEllipse::BaseEllipse(Base* p, const Vector& ctr, double ang) + : BaseMarker(p, ctr, ang) +{ +} + +BaseEllipse::BaseEllipse(Base* p, const Vector& ctr, + double ang, + const char* clr, int* dsh, + int w, const char* f, + const char* t, unsigned short prop, const char* c, + const List& tag, const List& cb) + : BaseMarker(p, ctr, ang, clr, dsh, w, f, t, prop, c, tag, cb) +{ +} + +BaseEllipse::BaseEllipse(const BaseEllipse& a) : BaseMarker(a) {} + +BaseEllipse::~BaseEllipse() +{ +} + +void BaseEllipse::renderX(Drawable drawable, Coord::InternalSystem sys, + RenderMode mode) +{ + double ang = calcAngle(); + Vector r = annuli_[numAnnuli_-1]; + Vector z = parent->zoom(); + + int isOrient = parent->getOrientation() == Coord::NORMAL && + parent->getWCSOrientation() == Coord::NORMAL; + int isRound = r[0] == r[1]; + int isScale = z[0] == z[1]; + // int isAngle = teq(ang,0,FLT_EPSILON) || teq(ang,M_PI,FLT_EPSILON); + + if (isRound && isScale && isOrient && parent->isAzElZero()) + renderXCircle(drawable, sys, ang, mode); + else + renderXEllipseCurve(drawable, sys, mode); +} + +void BaseEllipse::renderXCircle(Drawable drawable, Coord::InternalSystem sys, + double ang, RenderMode mode) +{ + GC lgc = renderXGC(mode); + + // this routine is only valid for circles with equal zoom in x & y + Vector cc = parent->mapFromRef(center,sys); + + for (int i=0; i=b1 && a1b1 && a2<=b2) + s2 =1; + + if ((s1 && !s2) || (s1 && s2)) + renderXEllipsePrep(drawable, sys, mode, a1,a2,b1,b2,r); + + if (s1&&s2) + s1=s2=0; + } + } +} + +void BaseEllipse::renderXEllipsePrep(Drawable drawable, Coord::InternalSystem sys, + RenderMode mode, + double a1, double a2, + double b1, double b2, + Vector& r) +{ + if (!(a1 >= b1 && a1 <= b2)) + a1 = b1; + if (!(a2 >= b1 && a2 <= b2)) + a2 = b2; + + if (a1>a2) { + renderXEllipseArc(drawable, sys, mode, b1,a2,r); + renderXEllipseArc(drawable, sys, mode, a1,b2,r); + } + else + renderXEllipseArc(drawable, sys, mode, a1,a2,r); +} + +void BaseEllipse::renderXEllipseArc(Drawable drawable, Coord::InternalSystem sys, + RenderMode mode, + double a1, double a2, Vector& rr) +{ + // don't render if zero angle + if (a1==a2) + return; + + // don't render if zero length + if (rr[0]==0 || rr[1]==0) + return; + + // bezier curve, valid for arcs of getColor("red")); + + XDrawLine(display, drawable, lgc, r1[0], r1[1], r2[0], r2[1]); + } +} + +void BaseEllipse::renderPS(int mode) { + Vector r = annuli_[numAnnuli_-1]; + Vector z = parent->zoom(); + + int isOrient = parent->getOrientation() == Coord::NORMAL && + parent->getWCSOrientation() == Coord::NORMAL; + int isRound = r[0] == r[1]; + int isScale = z[0] == z[1]; + + if (isRound && isScale && isOrient && parent->isAzElZero()) + renderPSCircle(mode); + else + renderPSEllipseCurve(mode); +} + +void BaseEllipse::renderPSCircle(int mode) +{ + renderPSGC(mode); + + Vector cc = parent->mapFromRef(center,Coord::CANVAS); + double ang = calcAngle(); + + for (int ii=0; iicanvas) << ' ' + << l << ' ' + << a1 << ' ' << a2 << ' ' + << "arc stroke" << endl << ends; + + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } +} + +void BaseEllipse::renderPSEllipseCurve(int mode) +{ + renderPSGC(mode); + + double a1 = startAng_; + double a2 = stopAng_; + if (a2<=a1) + a2 += M_TWOPI; + + for (int ii=0; ii=b1 && a1b1 && a2<=b2) + s2 =1; + + if ((s1 && !s2) || (s1 && s2)) + renderPSEllipsePrep(a1,a2,b1,b2,r); + + if (s1&&s2) + s1=s2=0; + } + } +} + +void BaseEllipse::renderPSEllipsePrep(double a1, double a2, + double b1, double b2, + Vector& rr) +{ + if (!(a1 >= b1 && a1 <= b2)) + a1 = b1; + if (!(a2 >= b1 && a2 <= b2)) + a2 = b2; + + if (a1>a2) { + renderPSEllipseArc(b1,a2,rr); + renderPSEllipseArc(a1,b2,rr); + } + else + renderPSEllipseArc(a1,a2,rr); +} + +void BaseEllipse::renderPSEllipseArc(double a1, double a2, Vector& rr) + +{ + // don't render zero length arcs + if (a1 == a2) + return; + + if (!rr[0] || !rr[1]) + return; + + // bezier curve, valid for arcs of canvas) << ' ' + << "moveto " + << xx1.TkCanvasPs(parent->canvas) << ' ' + << xx2.TkCanvasPs(parent->canvas) << ' ' + << tt1.TkCanvasPs(parent->canvas) << ' ' + << "curveto stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +void BaseEllipse::renderPSInclude(int mode) +{ + if (!(properties & INCLUDE)) { + double theta = degToRad(45); + Vector r1 = fwdMap(Vector(annuli_[numAnnuli_-1][0]*cos(theta), + annuli_[numAnnuli_-1][1]*sin(theta)), + Coord::CANVAS); + Vector r2 = fwdMap(Vector(-annuli_[numAnnuli_-1][0]*cos(theta), + -annuli_[numAnnuli_-1][1]*sin(theta)), + Coord::CANVAS); + + renderPSColor(mode, parent->getXColor("red")); + + ostringstream str; + str << "newpath " + << r1.TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << r2.TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } +} + +#ifdef MAC_OSX_TK +void BaseEllipse::renderMACOSX() { + Vector r = annuli_[numAnnuli_-1]; + Vector z = parent->zoom(); + + int isOrient = parent->getOrientation() == Coord::NORMAL && + parent->getWCSOrientation() == Coord::NORMAL; + int isRound = r[0] == r[1]; + int isScale = z[0] == z[1]; + + if (isRound && isScale && isOrient & parent->isAzElZero()) + renderMACOSXCircle(); + else + renderMACOSXEllipseCurve(); +} + +void BaseEllipse::renderMACOSXCircle() +{ + renderMACOSXGC(); + + Vector cc = parent->mapFromRef(center,Coord::CANVAS); + double ang = calcAngle(); + + for (int ii=0; ii=b1 && a1b1 && a2<=b2) + s2 =1; + + if ((s1 && !s2) || (s1 && s2)) + renderMACOSXEllipsePrep(a1,a2,b1,b2,r); + + if (s1&&s2) + s1=s2=0; + } + } +} + +void BaseEllipse::renderMACOSXEllipsePrep(double a1, double a2, + double b1, double b2, + Vector& rr) +{ + if (!(a1 >= b1 && a1 <= b2)) + a1 = b1; + if (!(a2 >= b1 && a2 <= b2)) + a2 = b2; + + if (a1>a2) { + renderMACOSXEllipseArc(b1,a2,rr); + renderMACOSXEllipseArc(a1,b2,rr); + } + else + renderMACOSXEllipseArc(a1,a2,rr); +} + +void BaseEllipse::renderMACOSXEllipseArc(double a1, double a2, Vector& rr) + +{ + // don't render zero length arcs + if (a1 == a2) + return; + + if (!rr[0] || !rr[1]) + return; + + // bezier curve, valid for arcs of getXColor("red")); + macosxDrawLine(r1,r2); + } +} +#endif + +#ifdef __WIN32 +void BaseEllipse::renderWIN32() { + Vector r = annuli_[numAnnuli_-1]; + Vector z = parent->zoom(); + + int isOrient = parent->getOrientation() == Coord::NORMAL && + parent->getWCSOrientation() == Coord::NORMAL; + int isRound = r[0] == r[1]; + int isScale = z[0] == z[1]; + + if (isRound && isScale && isOrient && parent->isAzElZero()) + renderWIN32Circle(); + else + renderWIN32EllipseCurve(); +} + +void BaseEllipse::renderWIN32Circle() +{ + renderWIN32GC(); + + Vector cc = parent->mapFromRef(center,Coord::CANVAS); + double ang = calcAngle(); + + for (int i=0; i=b1 && a1b1 && a2<=b2) + s2 =1; + + if ((s1 && !s2) || (s1 && s2)) + renderWIN32EllipsePrep(a1,a2,b1,b2,r); + + if (s1&&s2) + s1=s2=0; + } + } +} + +void BaseEllipse::renderWIN32EllipsePrep(double a1, double a2, + double b1, double b2, + Vector& rr) +{ + if (!(a1 >= b1 && a1 <= b2)) + a1 = b1; + if (!(a2 >= b1 && a2 <= b2)) + a2 = b2; + + if (a1>a2) { + renderWIN32EllipseArc(b1,a2,rr); + renderWIN32EllipseArc(a1,b2,rr); + } + else + renderWIN32EllipseArc(a1,a2,rr); +} + +void BaseEllipse::renderWIN32EllipseArc(double a1, double a2, Vector& rr) + +{ + // don't render zero length arcs + if (a1 == a2) + return; + + if (!rr[0] || !rr[1]) + return; + + // bezier curve, valid for arcs of getXColor("red")); + win32DrawLine(r1,r2); + } +} +#endif + +// Support + +void BaseEllipse::updateHandles() +{ + // handles are in canvas coords + // we can't garantee that the annuli_ have been sorted yet + if (handle) + delete [] handle; + handle = new Vector[numHandle]; + + Vector max; + for(int ii=0; ii1) + for (int ii=0; ii0) + ss = rr[0]*rr[1]/sqrt(tt); + + return Vector(ss*cos(aa),ss*sin(aa)); +} + +void BaseEllipse::XDrawCurve(Drawable drawable, RenderMode mode, + Vector& t1, Vector& x1, + Vector& x2, Vector& t2) +{ + // if dashed, fake it + GC lgc; + if ((properties & SOURCE) && !(properties & DASH)) + lgc = renderXGC(mode); + else { + // set width, color, dash + switch (mode) { + case SRC: + XSetForeground(display, gc, color); + renderXLineNoDash(gc); + lgc = gc; + break; + case XOR: + renderXLineNoDash(gcxor); + lgc = gcxor; + break; + } + } + + float t1x = t1[0]; + float t1y = t1[1]; + float t2x = t2[0]; + float t2y = t2[1]; + + float x1x = x1[0]; + float x1y = x1[1]; + float x2x = x2[0]; + float x2y = x2[1]; + + float rx = t1x; + float ry = t1y; + + Vector dd = (t2-t1).abs(); + float max = dd[0]>dd[1] ? dd[0] : dd[1]; + + // calculate incr + // this is a crude attempt to limit the number of iterations + // we want a min for very small segments, but not that large for + // high zoom or elongated curves + float aa = int(log(max))*5; + float incr = 1./(aa > 2 ? aa : 2); + + int dash=0; + float tt = incr; + while (tt<=1+FLT_EPSILON) { + float xx = pow(tt,3)*(t2x+3*(x1x-x2x)-t1x) + +3*pow(tt,2)*(t1x-2*x1x+x2x) + +3*tt*(x1x-t1x)+t1x; + float yy = pow(tt,3)*(t2y+3*(x1y-x2y)-t1y) + +3*pow(tt,2)*(t1y-2*x1y+x2y) + +3*tt*(x1y-t1y)+t1y; + + // crude attempt to clip unwanted drawlines + // only works for SRC + if ((properties & SOURCE) && !(properties & DASH)) + XDrawLine(display, drawable, lgc, rx, ry, xx, yy); + else { + if (dash) + XDrawLine(display, drawable, lgc, rx, ry, xx, yy); + dash = !dash; + } + + rx = xx; + ry = yy; + + tt += incr; + } +} + +// this routine maps the desired angle to an angle to be used with XDrawArc +double BaseEllipse::xyz(Vector rr, double aa) +{ + // just in case + if (!rr[0] || !rr[1]) + return aa; + + int flip=0; + while (aa>M_PI) { + aa -= M_PI; + flip++; + } + + double tt = rr[1]*rr[1]*cos(aa)*cos(aa)+rr[0]*rr[0]*sin(aa)*sin(aa); + double ss =0; + if (tt>0) + ss = 1./sqrt(tt); + + double bb = rr[1]*ss*cos(aa); + return acos(bb)+M_PI*flip; +} diff --git a/tksao/frame/baseellipse.h b/tksao/frame/baseellipse.h new file mode 100644 index 0000000..85f0040 --- /dev/null +++ b/tksao/frame/baseellipse.h @@ -0,0 +1,92 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __baseellipse_h__ +#define __baseellipse_h__ + +#include "basemarker.h" + +class BaseEllipse : public BaseMarker { + private: + double xyz(Vector rr, double ang); + void XDrawCurve(Drawable, RenderMode, Vector&, Vector&, Vector&, Vector&); + + void renderXCircle(Drawable, Coord::InternalSystem, double, RenderMode); + void renderXEllipseCurve(Drawable, Coord::InternalSystem, RenderMode); + void renderXEllipsePrep(Drawable, Coord::InternalSystem, RenderMode, + double, double, double, double, Vector&); + void renderXEllipseArc(Drawable, Coord::InternalSystem, RenderMode, + double, double, Vector&); + void renderXInclude(Drawable, Coord::InternalSystem, RenderMode); + + void renderPSCircle(int); + void renderPSEllipseCurve(int); + void renderPSEllipsePrep(double, double, double, double, Vector&); + void renderPSEllipseArc(double, double, Vector&); + void renderPSInclude(int); + +#ifdef MAC_OSX_TK + void renderMACOSXCircle(); + void renderMACOSXEllipseCurve(); + void renderMACOSXEllipsePrep(double, double, double, double, Vector&); + void renderMACOSXEllipseArc(double, double, Vector&); + void renderMACOSXInclude(); +#endif + +#ifdef __WIN32 + void renderWIN32Circle(); + void renderWIN32EllipseCurve(); + void renderWIN32EllipsePrep(double, double, double, double, Vector&); + void renderWIN32EllipseArc(double, double, Vector&); + void renderWIN32Include(); +#endif + + protected: + void renderX(Drawable, Coord::InternalSystem, RenderMode); + void renderPS(int); +#ifdef MAC_OSX_TK + void renderMACOSX(); +#endif +#ifdef __WIN32 + void renderWIN32(); +#endif + + virtual void updateHandles(); + Vector intersect(Vector, double); + + int isInRef(const Vector& vv, int); + + public: + BaseEllipse(Base* p, const Vector& ctr, double a); + BaseEllipse(Base* p, const Vector& ctr, + double a, + const char* clr, int* dsh, + int w, const char* f, const char* t, + unsigned short prop, const char* c, + const List& tag, const List& cb); + BaseEllipse(const BaseEllipse&); + + virtual ~BaseEllipse(); + + virtual Marker* dup() =0; + + int isIn(const Vector& vv) + {return isIn(vv, Coord::CANVAS);} + int isIn(const Vector& vv, Coord::InternalSystem sys) + {return isIn(vv,sys,numAnnuli_-1);} + int isIn(const Vector& vv, Coord::InternalSystem sys, int nn) + {return isInRef(bckMap(vv,sys),nn);} + virtual int isIn(const Vector& vv, Coord::InternalSystem sys, int nn, int aa) + {return isInRef(bckMap(vv,sys),nn);} + + // valid for non-fixed only + int isIn(const Vector& vv, const Matrix& bck) + {return isIn(vv,bck,numAnnuli_-1);} + int isIn(const Vector& vv, const Matrix& bck, int nn) + {return isInRef(vv*bck,nn);} +}; + +#endif + + diff --git a/tksao/frame/baseline.C b/tksao/frame/baseline.C new file mode 100644 index 0000000..0a3912a --- /dev/null +++ b/tksao/frame/baseline.C @@ -0,0 +1,124 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "baseline.h" +#include "fitsimage.h" + +BaseLine::BaseLine(Base* p, const Vector& ptr1, const Vector& ptr2) + : Marker(p, ptr1, 0) +{ + p1 = ptr1; + p2 = ptr2; +} + +BaseLine::BaseLine(Base* p, const Vector& ptr1, const Vector& ptr2, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : Marker(p, ptr1, 0, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + p1 = ptr1; + p2 = ptr2; +} + +BaseLine::BaseLine(const BaseLine& a) : Marker(a) +{ + p1 = a.p1; + p2 = a.p2; +} + +void BaseLine::updateCoords(const Matrix& mx) +{ + p1*=mx; + p2*=mx; + + Marker::updateCoords(mx); +} + +void BaseLine::centroid() +{ + p1 = parent->centroid(p1); + p2 = parent->centroid(p2); + + updateBBox(); + doCallBack(CallBack::MOVECB); +} + +void BaseLine::move(const Vector& v) +{ + p1+=v; + p2+=v; + + updateBBox(); + doCallBack(CallBack::MOVECB); +} + +void BaseLine::moveTo(const Vector& v) +{ + // v is the new location of the center + Vector diff = v - center; + p1+=diff; + p2+=diff; + + updateBBox(); + doCallBack(CallBack::MOVECB); +} + +int BaseLine::isIn(const Vector& v) +{ + // do this in canvas coords, not ref coords + Vector l1 = parent->mapFromRef(p1,Coord::CANVAS); + Vector l2 = parent->mapFromRef(p2,Coord::CANVAS); + double a = (l2-l1).angle(); + + Matrix m = Translate(-l1) * Rotate(a); + Vector vv = v*m; + Vector end = l2*m; + return (vv[0]>0 && vv[0]-parent->markerEpsilon && vv[1]markerEpsilon); +} + +void BaseLine::edit(const Vector& v, int h) +{ + switch (h) { + case 1: + p1 = v; + break; + case 2: + p2 = v; + break; + } + + updateBBox(); + doCallBack(CallBack::EDITCB); +} + +void BaseLine::setPoints(const Vector& v1, const Vector& v2) +{ + p1 = v1; + p2 = v2; + + updateBBox(); + doCallBack(CallBack::EDITCB); +} + +void BaseLine::listNonCel(FitsImage* ptr, ostream& str, Coord::CoordSystem sys) +{ + Vector v1 = ptr->mapFromRef(p1,sys); + Vector v2 = ptr->mapFromRef(p2,sys); + str << type_ << '(' << setprecision(8) << v1 << ',' << v2 << ')'; +} + +// special composite funtionallity + +void BaseLine::setComposite(const Matrix& mx, double aa) +{ + p1 *= mx; + p2 *= mx; + + updateBBox(); +} diff --git a/tksao/frame/baseline.h b/tksao/frame/baseline.h new file mode 100644 index 0000000..4750eb9 --- /dev/null +++ b/tksao/frame/baseline.h @@ -0,0 +1,60 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __baseline_h__ +#define __baseline_h__ + +#include "marker.h" + +class BaseLine : public Marker { +protected: + Vector p1; + Vector p2; + + void renderXInclude(Drawable, Coord::InternalSystem, RenderMode) {} + + void renderPSInclude(int) {} + +#ifdef MAC_OSX_TK + void renderMACOSXInclude() {} +#endif + +#ifdef __WIN32 + void renderWIN32Include() {} +#endif + + void updateHandles() {} + + virtual void listNonCel(FitsImage*, ostream&, Coord::CoordSystem); + +public: + BaseLine(Base* p, const Vector& ptr1, const Vector& ptr2); + BaseLine(Base* p, const Vector& ptr1, const Vector& ptr2, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + BaseLine(const BaseLine&); + + virtual void updateCoords(const Matrix&); + virtual int isIn(const Vector&); + + void centroid(); + void move(const Vector&); + void moveTo(const Vector&); + virtual void edit(const Vector&, int); + + void rotateBegin() {} + void rotate(const Vector& v, int h) {} + void rotateEnd() {} + + const Vector& getP1() {return p1;} + const Vector& getP2() {return p2;} + void setPoints(const Vector&, const Vector&); + + // special composite funtionality + void setComposite(const Matrix&, double); +}; + +#endif diff --git a/tksao/frame/basemarker.C b/tksao/frame/basemarker.C new file mode 100644 index 0000000..7a6fd2b --- /dev/null +++ b/tksao/frame/basemarker.C @@ -0,0 +1,347 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "basemarker.h" +#include "base.h" + +// Base Markers Public + +BaseMarker::BaseMarker(Base* p, const Vector& ctr, double ang) + : Marker(p, ctr, ang) +{ + startAng_ = 0; + stopAng_ = M_TWOPI; + + numAnnuli_ = 0; + annuli_ = NULL; + + numAngles_ = 0; + angles_ = NULL; +} + +BaseMarker::BaseMarker(Base* p, const Vector& ctr, double ang, + const char* clr, int* dsh, + int w, const char* f, + const char* t, unsigned short prop, const char* c, + const List& tag, const List& cb) + : Marker(p, ctr, ang, clr, dsh, w, f, t, prop, c, tag, cb) +{ + startAng_ = 0; + stopAng_ = M_TWOPI; + + numAnnuli_ = 0; + annuli_ = NULL; + + numAngles_ = 0; + angles_ = NULL; +} + +BaseMarker::BaseMarker(const BaseMarker& a) : Marker(a) +{ + startAng_ = a.startAng_; + stopAng_ = a.stopAng_; + + numAnnuli_ = a.numAnnuli_; + annuli_ = new Vector[a.numAnnuli_]; + for (int i=0; i4) { + int hh = h-4-1; + + if (numAnnuli_>2 && hhannuli_[j][0]) { + Vector d = annuli_[i]; + annuli_[i] = annuli_[j]; + annuli_[j] = d; + } +} + +int BaseMarker::isInAngle(Vector& vv, int nn) +{ + double aa = -vv.angle(); + while (aa=angles_[nn] && aa1 && angles_[0]==0 && angles_[numAngles_-1]==0) + angles_[numAngles_-1] += M_TWOPI; +} + +void BaseMarker::setAngles(double a1, double a2, int an) +{ + numAngles_ = an+1; + if (angles_) + delete [] angles_; + angles_ = new double[numAngles_]; + + // yes this is really needed + // for a2a1 very small + if (teq(a2,a1,FLT_EPSILON)) { + a1 = zeroTWOPI(a1); + a2 = zeroTWOPI(a2); + if (teq(a2,a1,FLT_EPSILON)) + a2 += M_TWOPI; + } + + for (int ii=0; iirefToCanvas; + return Rotate(calcAngle()) * Translate(cc) * parent->canvasToRef; + } + else + return Marker::fwdMatrix(); +} + +Matrix BaseMarker::bckMatrix() +{ + if (properties & FIXED) { + Vector cc = center * parent->refToCanvas; + return parent->refToCanvas * Translate(-cc) * Rotate(-calcAngle()); + } + else + return Marker::bckMatrix(); +} + +Vector BaseMarker::fwdMap(const Vector& vv, Coord::InternalSystem sys) +{ + if (properties & FIXED) { + Vector cc = center * parent->refToCanvas; + Vector dd = vv * Rotate(calcAngle()) * Translate(cc); + Vector ee = dd*parent->canvasToRef; + return parent->mapFromRef(ee,sys); + } + else + return Marker::fwdMap(vv,sys); +} + +Vector BaseMarker::bckMap(const Vector& vv, Coord::InternalSystem sys) +{ + if (properties & FIXED) { + Vector aa = parent->mapToRef(vv,sys); + Vector bb = aa*parent->refToCanvas; + Vector cc = center * parent->refToCanvas; + return bb * Translate(-cc) * Rotate(-calcAngle()); + } + else + return Marker::bckMap(vv,sys); +} + diff --git a/tksao/frame/basemarker.h b/tksao/frame/basemarker.h new file mode 100644 index 0000000..981cdf3 --- /dev/null +++ b/tksao/frame/basemarker.h @@ -0,0 +1,67 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __basemarker_h__ +#define __basemarker_h__ + +#include "marker.h" + +#define MAXANNULI 512 +#define MAXANGLES 720 + +class BaseMarker : public Marker { +protected: + Vector* annuli_; + int numAnnuli_; + + double *angles_; + int numAngles_; + + double startAng_; + double stopAng_; + +protected: + void sortAnnuli(); + int insertAnnuli(Vector); + + void sortAngles(); + void setAngles(double, double, int); + void setAngles(int, const double*); + void addAngle(double); + void deleteAngle(int); + int isInAngle(Vector&, int); + + Matrix fwdMatrix(); + Matrix bckMatrix(); + Vector fwdMap(const Vector&, Coord::InternalSystem); + Vector bckMap(const Vector&, Coord::InternalSystem); + +public: + BaseMarker(Base*, const Vector&, double); + BaseMarker(Base*, const Vector&, double, + const char*, int* dsh, + int, const char*, const char*, + unsigned short, const char*, + const List&, const List& cb); + BaseMarker(const BaseMarker&); + virtual ~BaseMarker(); + + virtual Marker* dup() =0; + void updateCoords(const Matrix&); + + int numAnnuli() {return numAnnuli_;} + Vector annuli(int i) {return annuli_[i];} + + int numAngles() {return numAngles_;} + double angles(int i) {return angles_[i];} + + void setAnnuli(const Vector&); + void setAnnuli(const Vector&, const Vector&, int); + void setAnnuli(const Vector*, int); + + virtual int addAnnuli(const Vector&) {return 0;} + void deleteAnnuli(int h); +}; + +#endif diff --git a/tksao/frame/basepolygon.C b/tksao/frame/basepolygon.C new file mode 100644 index 0000000..a9901c7 --- /dev/null +++ b/tksao/frame/basepolygon.C @@ -0,0 +1,314 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "basepolygon.h" +#include "fitsimage.h" + +BasePolygon::BasePolygon(Base* p, const Vector& ctr, + const Vector& b) + : Marker(p, ctr, 0) +{ +} + +BasePolygon::BasePolygon(Base* p, const Vector& ctr, + const Vector& b, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : Marker(p, ctr, 0, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ +} + +BasePolygon::BasePolygon(Base* p, const List& v, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : Marker(p, Vector(0,0), 0, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + // Vertex list is in ref coords + angle = 0; + vertex = v; + + // find center + center = Vector(0,0); + vertex.head(); + do + center += vertex.current()->vector; + while (vertex.next()); + center /= vertex.count(); + + // vertices are relative + vertex.head(); + do + vertex.current()->vector *= Translate(-center) * FlipY(); // no rotation + while (vertex.next()); + + updateBBox(); +} + +BasePolygon::BasePolygon(const BasePolygon& a) : Marker(a) +{ + vertex = a.vertex; +} + +void BasePolygon::createVertex(int which, const Vector& v) +{ + // which segment (1 to n) + // v is in ref coords + Matrix mm = bckMatrix(); + + int seg = which-1; + if (seg>=0 && seg4) { + int hh = h-4-1; + + if (vertex.count() > 3) { + Vertex* v = vertex[hh]; + if (v) { + vertex.extractNext(v); + delete v; + + recalcCenter(); + + updateBBox(); + doCallBack(CallBack::EDITCB); + doCallBack(CallBack::MOVECB); // center can change + } + } + } +} + +void BasePolygon::edit(const Vector& v, int h) +{ + if (h < 5) { + Vector s1 = v * bckMatrix(); + Vector s2 = bckMap(handle[h-1],Coord::CANVAS); + + if (s1[0] != 0 && s1[1] != 0 && s2[0] != 0 && s2[1] != 0) { + double a = fabs(s1[0]/s2[0]); + double b = fabs(s1[1]/s2[1]); + double s = a > b ? a : b; + + vertex.head(); + do + vertex.current()->vector *= Scale(s); + while (vertex.next()); + } + + updateBBox(); + doCallBack(CallBack::EDITCB); + } + else { + moveVertex(v,h); + + updateBBox(); + doCallBack(CallBack::EDITCB); + doCallBack(CallBack::MOVECB); // center can change + } +} + +void BasePolygon::moveVertex(const Vector& v, int h) +{ + Matrix mm = bckMatrix(); + + if (vertex[h-5]) + vertex.current()->vector = v * mm; + + recalcCenter(); +} + +void BasePolygon::recalcCenter() +{ + // recalculate center + + Vector nc; + vertex.head(); + do + nc += vertex.current()->vector * Rotate(angle) * FlipY(); + while (vertex.next()); + nc /= vertex.count(); + + center += nc; + + // update all vertices + + vertex.head(); + do + vertex.current()->vector -= nc * FlipY() * Rotate(-angle); + while (vertex.next()); +} + +void BasePolygon::rotate(const Vector& v, int h) +{ + if (h < 5) + Marker::rotate(v,h); + else { + // we need to check this here, because we are really rotating + if (canEdit()) { + moveVertex(v,h); + + updateBBox(); + doCallBack(CallBack::EDITCB); + doCallBack(CallBack::MOVECB); // center can change + } + } +} + +void BasePolygon::updateHandles() +{ + // generate handles + numHandle = 4 + vertex.count(); + if (handle) + delete [] handle; + handle = new Vector[numHandle]; + + // the first four are our control handles + BBox bb; + vertex.head(); + do + bb.bound(vertex.current()->vector); + while (vertex.next()); + + Vector zz = parent->zoom(); + float r = 10/zz.length(); + bb.expand(r); // give us more room + + handle[0] = fwdMap(bb.ll,Coord::CANVAS); + handle[1] = fwdMap(bb.lr(),Coord::CANVAS); + handle[2] = fwdMap(bb.ur,Coord::CANVAS); + handle[3] = fwdMap(bb.ul(),Coord::CANVAS); + + // and the rest are vertices + int i=4; + vertex.head(); + do + handle[i++] = fwdMap(vertex.current()->vector,Coord::CANVAS); + while (vertex.next()); +} + +void BasePolygon::updateCoords(const Matrix& mx) +{ + Scale s(mx); + vertex.head(); + do + vertex.current()->vector *= s; + while (vertex.next()); + + Marker::updateCoords(mx); +} + +void BasePolygon::listBase(FitsImage* ptr, ostream& str, + Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + Matrix mm = fwdMatrix(); + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listBaseNonCel(ptr, str, mm, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + str << type_ << '('; + int first=1; + vertex.head(); + do { + if (!first) + str << ','; + first=0; + + Vector vv = + ptr->mapFromRef(vertex.current()->vector*mm,sys,sky); + str << setprecision(10) << vv; + } + while (vertex.next()); + str << ')'; + } + break; + case Coord::SEXAGESIMAL: + { + str << type_ << '('; + int first=1; + vertex.head(); + do { + if (!first) + str << ','; + first=0; + + listRADEC(ptr,vertex.current()->vector*mm,sys,sky,format); + str << ra << ',' << dec; + } + while (vertex.next()); + str << ')'; + } + break; + } + } + else + listBaseNonCel(ptr, str, mm, sys); + } +} + +void BasePolygon::listBaseNonCel(FitsImage* ptr, ostream& str, Matrix& mm, + Coord::CoordSystem sys) +{ + str << type_ << '('; + int first=1; + vertex.head(); + do { + if (!first) + str << ','; + first=0; + + Vector vv = ptr->mapFromRef(vertex.current()->vector*mm,sys); + str << setprecision(8) << vv; + } + while (vertex.next()); + str << ')'; +} + +void BasePolygon::listXML(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format) +{ + FitsImage* ptr = parent->findFits(sys,center); + Matrix mm = fwdMatrix(); + Vector* vv = new Vector[vertex.count()]; + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + vertex.head(); + int cnt =0; + do + vv[cnt++] =vertex.current()->vector*mm; + while (vertex.next()); + XMLRowPoint(ptr,sys,sky,format,vv,vertex.count()); + delete [] vv; + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} + diff --git a/tksao/frame/basepolygon.h b/tksao/frame/basepolygon.h new file mode 100644 index 0000000..c7a90f8 --- /dev/null +++ b/tksao/frame/basepolygon.h @@ -0,0 +1,59 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __basepolygon_h__ +#define __basepolygon_h__ + +#include "marker.h" +#include "list.h" + +class BasePolygon : public Marker { + protected: + List vertex; + + protected: + void moveVertex(const Vector&, int); + void recalcCenter(); + virtual void renderX(Drawable, Coord::InternalSystem, RenderMode) =0; + virtual void renderPS(int) =0; +#ifdef MAC_OSX_TK + virtual void renderMACOSX() =0; +#endif +#ifdef __WIN32 + virtual void renderWIN32() =0; +#endif + void updateHandles(); + + void listBase(FitsImage*, ostream&, Coord::CoordSystem, + Coord::SkyFrame, Coord::SkyFormat); + void listBaseNonCel(FitsImage*, ostream&, Matrix&, Coord::CoordSystem); + +public: + BasePolygon(Base* p, const Vector& ctr, + const Vector& b); + BasePolygon(Base* p, const Vector& ctr, + const Vector& b, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + BasePolygon(Base* p, const List& v, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + BasePolygon(const BasePolygon&); + + void createVertex(int, const Vector&); + void deleteVertex(int); + void edit(const Vector&, int); + virtual int getSegment(const Vector&) =0; + virtual void reset(const Vector&) =0; + void rotate(const Vector&, int); + void updateCoords(const Matrix&); + + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); +}; + +#endif diff --git a/tksao/frame/box.C b/tksao/frame/box.C new file mode 100644 index 0000000..4a97e48 --- /dev/null +++ b/tksao/frame/box.C @@ -0,0 +1,424 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "box.h" +#include "fitsimage.h" + +Box::Box(Base* p, const Vector& ctr, const Vector& seg, double ang) + : BaseBox(p, ctr, ang) +{ + numAnnuli_ = 1; + annuli_ = new Vector[1]; + annuli_[0] = seg; + + strcpy(type_,"box"); + numHandle = 4; + + updateBBox(); +} + +Box::Box(Base* p, const Vector& ctr, + const Vector& seg, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BaseBox(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = 1; + annuli_ = new Vector[1]; + annuli_[0] = seg; + + strcpy(type_,"box"); + numHandle = 4; + + updateBBox(); +} + +Box::Box(const Box& a) : BaseBox(a) {} + +void Box::editBegin(int h) +{ + switch (h) { + case 1: + return; + case 2: + annuli_[0] = Vector(-annuli_[0][0],annuli_[0][1]); + return; + case 3: + annuli_[0] = -annuli_[0]; + return; + case 4: + annuli_[0] = Vector(annuli_[0][0],-annuli_[0][1]); + return; + } + + doCallBack(CallBack::EDITBEGINCB); +} + +void Box::edit(const Vector& v, int h) +{ + Matrix mm = bckMatrix(); + Matrix nn = mm.invert(); + + // This annuli_s about the opposite node + Vector ov = annuli_[0]/2 * nn; + annuli_[0] = (annuli_[0]/2) - (v*mm); + Vector nv = annuli_[0]/2 * nn; + center -= nv-ov; + + updateBBox(); + doCallBack(CallBack::EDITCB); + doCallBack(CallBack::MOVECB); +} + +void Box::editEnd() +{ + annuli_[0] = annuli_[0].abs(); + + updateBBox(); + doCallBack(CallBack::EDITENDCB); +} + +void Box::analysis(AnalysisTask mm, int which) +{ + switch (mm) { + case HISTOGRAM: + if (!analysisHistogram_ && which) { + addCallBack(CallBack::MOVECB, analysisHistogramCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisHistogramCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisHistogramCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisHistogramCB_[1], + parent->options->cmdName); + } + if (analysisHistogram_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisHistogramCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisHistogramCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisHistogramCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisHistogramCB_[1]); + } + + analysisHistogram_ = which; + break; + case PLOT3D: + if (!analysisPlot3d_ && which) { + addCallBack(CallBack::MOVECB, analysisPlot3dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisPlot3dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisPlot3dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisPlot3dCB_[1], + parent->options->cmdName); + } + if (analysisPlot3d_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisPlot3dCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisPlot3dCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisPlot3dCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisPlot3dCB_[1]); + } + + analysisPlot3d_ = which; + break; + case STATS: + if (!analysisStats_ && which) { + addCallBack(CallBack::MOVECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisStatsCB_[1], + parent->options->cmdName); + } + if (analysisStats_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisStatsCB_[1]); + } + + analysisStats_ = which; + break; + default: + // na + break; + } +} + +void Box::analysisHistogram(char* xname, char* yname, int num) +{ + double* x; + double* y; + Matrix mm = Rotate(angle) * Translate(center); + + // during resize, annuli_ can be negative + Vector vv = annuli_[0].abs(); + BBox bb(-vv * mm); + bb.bound( vv * mm); + bb.bound(Vector( vv[0],-vv[1]) * mm); + bb.bound(Vector(-vv[0], vv[1]) * mm); + + parent->markerAnalysisHistogram(this, &x, &y, bb, num); + analysisXYResult(xname, yname, x, y, num+1); +} + +void Box::analysisPlot3d(char* xname, char* yname, + Coord::CoordSystem sys, + Marker::AnalysisMethod method) +{ + double* x; + double* y; + Matrix mm = Rotate(angle) * Translate(center); + + // during resize, annuli_ can be negative + Vector vv = annuli_[0].abs(); + BBox bb(-vv * mm); + bb.bound( vv * mm); + bb.bound(Vector( vv[0],-vv[1]) * mm); + bb.bound(Vector(-vv[0], vv[1]) * mm); + + int num = parent->markerAnalysisPlot3d(this, &x, &y, bb, sys, method); + analysisXYResult(xname, yname, x, y, num); +} + +void Box::analysisStats(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + ostringstream str; + Matrix mm = Rotate(angle) * Translate(center); + + // during resize, annuli_ can be negative + Vector vv = annuli_[0].abs(); + BBox bb(-vv * mm); + bb.bound( vv * mm); + bb.bound(Vector( vv[0],-vv[1]) * mm); + bb.bound(Vector(-vv[0], vv[1]) * mm); + + parent->markerAnalysisStats(this, str, bb, sys, sky); + str << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +// list + +void Box::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 0); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listNonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + Vector rr = ptr->mapLenFromRef(annuli_[0],sys,Coord::ARCSEC); + double aa = parent->mapAngleFromRef(angle,sys,sky); + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' + << setprecision(10) << vv << ',' + << setprecision(3) << fixed << setunit('"') << rr << ','; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(aa) << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' << setprecision(8) + << ra << ',' << dec << ',' + << setprecision(3) << fixed << setunit('"') << rr << ','; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(aa) << ')'; + break; + } + } + else + listNonCel(ptr, str, sys); + } + + listPost(str, conj, strip); +} + +void Box::listNonCel(FitsImage* ptr, ostream& str, Coord::CoordSystem sys) +{ + Vector vv = ptr->mapFromRef(center,sys); + Vector rr = ptr->mapLenFromRef(annuli_[0],sys); + double aa = parent->mapAngleFromRef(angle,sys); + str << type_ << '(' << setprecision(8) << vv << ',' << rr << ',' + << radToDeg(aa) << ')'; +} + +void Box::listXML(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + FitsImage* ptr = parent->findFits(sys,center); + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowCenter(ptr,sys,sky,format); + XMLRowRadius(ptr,sys,annuli_[0]); + XMLRowAng(sys,sky); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} + +void Box::listCiao(ostream& str, Coord::CoordSystem sys, int strip) +{ + FitsImage* ptr = parent->findFits(); + listCiaoPre(str); + + // radius is always in image coords + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + Vector vv = ptr->mapFromRef(center,Coord::PHYSICAL); + Vector rr = ptr->mapLenFromRef(annuli_[0],Coord::PHYSICAL); + str << type_ << '(' << setprecision(8) << vv << ',' << rr << ',' + << radToDeg(angle) << ')'; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + listRADEC(ptr,center,sys,Coord::FK5,Coord::SEXAGESIMAL); + Vector rr = ptr->mapLenFromRef(annuli_[0],sys,Coord::ARCMIN); + str << type_ << '(' + << ra << ',' << dec << ',' + << setprecision(5) << fixed << setunit('\'') << rr << ','; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(angle) << ')'; + } + } + + listCiaoPost(str, strip); +} + +void Box::listSAOtng(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int strip) +{ + FitsImage* ptr = parent->findFits(); + listSAOtngPre(str, strip); + + // radius is always in image coords + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + Vector vv = ptr->mapFromRef(center,Coord::IMAGE); + Vector rr = ptr->mapLenFromRef(annuli_[0],Coord::IMAGE); + str << type_ << '(' << setprecision(8) << vv << ',' << rr << ',' + << radToDeg(angle) << ')'; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + Vector rr = ptr->mapLenFromRef(annuli_[0],Coord::IMAGE); + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' + << setprecision(10) << vv << ',' + << setprecision(8) << rr << ',' + << setprecision(8) << radToDeg(angle) << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' + << ra << ',' << dec << ',' + << setprecision(8) << rr << ',' + << setprecision(8) << radToDeg(angle) << ')'; + break; + } + } + } + + listSAOtngPost(str,strip); +} + +void Box::listPros(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int strip) +{ + FitsImage* ptr = parent->findFits(); + + switch (sys) { + case Coord::IMAGE: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + sys = Coord::IMAGE; + case Coord::PHYSICAL: + { + Vector vv = ptr->mapFromRef(center,sys); + Vector rr = ptr->mapLenFromRef(annuli_[0],Coord::IMAGE); + coord.listProsCoordSystem(str,sys,sky); + str << "; "<< type_ << ' ' << setprecision(8) << vv << ' ' << rr << ' ' + << radToDeg(angle); + } + break; + default: + if (ptr->hasWCSCel(sys)) { + Vector rr = ptr->mapLenFromRef(annuli_[0],sys,Coord::ARCSEC); + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + coord.listProsCoordSystem(str,sys,sky); + str << "; " << type_ << ' ' + << setprecision(10) << setunit('d') << vv << ' ' + << setprecision(3) << fixed << setunit('"') << rr << ' '; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(angle); + } + break; + case Coord::SEXAGESIMAL: + listRADECPros(ptr,center,sys,sky,format); + coord.listProsCoordSystem(str,sys,sky); + str << "; " << type_ << ' ' + << ra << ' ' << dec << ' ' + << setprecision(3) << fixed << setunit('"') << rr << ' '; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(angle); + break; + } + } + } + + listProsPost(str, strip); +} + +void Box::listSAOimage(ostream& str, int strip) +{ + FitsImage* ptr = parent->findFits(); + listSAOimagePre(str); + + Vector vv = ptr->mapFromRef(center,Coord::IMAGE); + str << type_ << '(' << setprecision(8) << vv << ',' << annuli_[0] << ',' + << radToDeg(angle) << ')'; + + listSAOimagePost(str, strip); +} + diff --git a/tksao/frame/box.h b/tksao/frame/box.h new file mode 100644 index 0000000..d7cd40e --- /dev/null +++ b/tksao/frame/box.h @@ -0,0 +1,43 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __box_h__ +#define __box_h__ + +#include "basebox.h" + +class Box : public BaseBox { + protected: + void listNonCel(FitsImage*, ostream&, Coord::CoordSystem); + +public: + Box(Base* p, const Vector& ctr, const Vector& seg, double ang); + Box(Base* p, const Vector& ctr, + const Vector& seg, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + Box(const Box&); + + virtual Marker* dup() {return new Box(*this);} + void editBegin(int); + void edit(const Vector&, int); + void editEnd(); + + void analysis(AnalysisTask, int); + void analysisHistogram(char*, char*, int); + void analysisPlot3d(char*, char*, Coord::CoordSystem, Marker::AnalysisMethod); + void analysisStats(Coord::CoordSystem, Coord::SkyFrame sky); + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + virtual void listCiao(ostream&, Coord::CoordSystem, int); + virtual void listSAOtng(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + virtual void listPros(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + virtual void listSAOimage(ostream&, int); +}; + +#endif diff --git a/tksao/frame/boxannulus.C b/tksao/frame/boxannulus.C new file mode 100644 index 0000000..f99e190 --- /dev/null +++ b/tksao/frame/boxannulus.C @@ -0,0 +1,461 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "boxannulus.h" +#include "fitsimage.h" + +BoxAnnulus::BoxAnnulus(Base* p, const Vector& ctr, + const Vector& s, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BaseBox(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = 1; + annuli_ = new Vector[1]; + annuli_[0] = s; + + strcpy(type_,"boxannulus"); + numHandle = 4; + + updateBBox(); +} + +BoxAnnulus::BoxAnnulus(Base* p, const Vector& ctr, + const Vector& inner, const Vector& outer, int num, + double ang) + : BaseBox(p, ctr, ang) +{ + numAnnuli_ = num+1; + annuli_ = new Vector[numAnnuli_]; + + for (int i=0; i& tg, const List& cb) + : BaseBox(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = num+1; + annuli_ = new Vector[numAnnuli_]; + + for (int i=0; i& tg, const List& cb) + : BaseBox(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = an; + annuli_ = new Vector[numAnnuli_]; + + for (int i=0; ioptions->cmdName); + addCallBack(CallBack::EDITCB, analysisRadialCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITENDCB, analysisRadialCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisRadialCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisRadialCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisRadialCB_[1], + parent->options->cmdName); + } + if (analysisRadial_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisRadialCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisRadialCB_[0]); + deleteCallBack(CallBack::EDITENDCB, analysisRadialCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisRadialCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisRadialCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisRadialCB_[1]); + } + + analysisRadial_ = which; + break; + case STATS: + if (!analysisStats_ && which) { + addCallBack(CallBack::MOVECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITENDCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisStatsCB_[1], + parent->options->cmdName); + } + if (analysisStats_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITENDCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisStatsCB_[1]); + } + + analysisStats_ = which; + break; + default: + // na + break; + } +} + +void BoxAnnulus::analysisRadial(char* xname, char* yname, char* ename, + Coord::CoordSystem sys) +{ + double* xx; + double* yy; + double* ee; + + BBox* bb = new BBox[numAnnuli_]; + Matrix mm = Rotate(angle) * Translate(center); + + for (int ii=0; iimarkerAnalysisRadial(this, &xx, &yy, &ee, + numAnnuli_-1, annuli_, + bb, sys); + analysisXYEResult(xname, yname, ename, xx, yy, ee, num); +} + +void BoxAnnulus::analysisStats(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + ostringstream str; + BBox* bb = new BBox[numAnnuli_]; + Matrix mm = Rotate(angle) * Translate(center); + + for (int ii=0; iimarkerAnalysisStats(this, str, numAnnuli_-1, bb, sys, sky); + str << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +// list + +void BoxAnnulus::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 0); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listNonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + double aa = parent->mapAngleFromRef(angle,sys,sky); + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << "box(" << setprecision(8) << vv + << setprecision(3) << fixed; + for (int ii=0; iimapLenFromRef(annuli_[ii],sys,Coord::ARCSEC); + str << ',' << setunit('"') << rr; + } + str.unsetf(ios_base::floatfield); + str << setprecision(8) << ',' << radToDeg(aa) << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << "box(" << ra << ',' << dec + << setprecision(3) << fixed; + for (int ii=0; iimapLenFromRef(annuli_[ii],sys,Coord::ARCSEC); + str << ',' << setunit('"') << rr; + } + str.unsetf(ios_base::floatfield); + str << setprecision(8) << ',' << radToDeg(aa) << ')'; + break; + } + } + else + listNonCel(ptr, str, sys); + } + + listPost(str, conj, strip); +} + +void BoxAnnulus::listNonCel(FitsImage* ptr, ostream& str, + Coord::CoordSystem sys) +{ + Vector vv = ptr->mapFromRef(center,sys); + double aa = parent->mapAngleFromRef(angle,sys); + str << "box(" << setprecision(8) << vv; + for (int ii=0; iimapLenFromRef(annuli_[ii],sys); + str << ',' << rr; + } + str << ',' << radToDeg(aa) << ')'; +} + +void BoxAnnulus::listXML(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format) +{ + FitsImage* ptr = parent->findFits(sys,center); + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowCenter(ptr,sys,sky,format); + XMLRowRadius(ptr,sys,annuli_,numAnnuli_); + XMLRowAng(sys,sky); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} + +void BoxAnnulus::listPros(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + int strip) +{ + FitsImage* ptr = parent->findFits(); + + switch (sys) { + case Coord::IMAGE: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + sys = Coord::IMAGE; + case Coord::PHYSICAL: + { + Vector vv = ptr->mapFromRef(center,sys); + for (int ii=0; iimapLenFromRef(annuli_[ii],Coord::IMAGE); + str << "box " << setprecision(8) << vv << ' ' << rr << ' ' + << radToDeg(angle); + + if (ii!=0) { + Vector r1 = ptr->mapLenFromRef(annuli_[ii-1],Coord::IMAGE); + str << " & !box " << setprecision(8) << vv << ' ' << r1 << ' ' + << radToDeg(angle); + } + + listProsPost(str, strip); + } + } + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + for (int ii=0; iimapLenFromRef(annuli_[ii],sys,Coord::ARCSEC); + str << "box " + << setprecision(10) << setunit('d') << vv << ' ' + << setprecision(3) << setunit('"') << fixed << rr << ' '; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(angle); + + if (ii!=0) { + Vector r1 = ptr->mapLenFromRef(annuli_[ii-1],sys,Coord::ARCSEC); + str << " & !box " + << setprecision(8) << setunit('d') << vv << ' ' + << setprecision(3) << setunit('"') << fixed << r1 << ' '; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(angle); + } + + listProsPost(str, strip); + } + } + break; + case Coord::SEXAGESIMAL: + listRADECPros(ptr,center,sys,sky,format); + for (int ii=0; iimapLenFromRef(annuli_[ii],sys,Coord::ARCSEC); + str << "box " << ra << ' ' << dec << ' ' + << setprecision(3) << setunit('"') << fixed << rr << ' '; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(angle); + + if (ii!=0) { + Vector r1 = ptr->mapLenFromRef(annuli_[ii-1],sys,Coord::ARCSEC); + str << " & !box " << ra << ' ' << dec << ' ' + << setprecision(3) << setunit('"') << fixed << r1 << ' '; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(angle); + } + + listProsPost(str, strip); + } + break; + } + } + } +} + +void BoxAnnulus::listSAOimage(ostream& str, int strip) +{ + FitsImage* ptr = parent->findFits(); + listSAOimagePre(str); + + for (int ii=0; iimapFromRef(center,Coord::IMAGE); + str << "box(" << setprecision(8) << vv << ',' + << annuli_[ii] << ',' << radToDeg(angle) << ')'; + + if (ii!=0) + str << " & !box(" << setprecision(8) << vv << ',' + << annuli_[ii-1] << ',' << radToDeg(angle) << ')'; + + listSAOimagePost(str, strip); + } +} + + diff --git a/tksao/frame/boxannulus.h b/tksao/frame/boxannulus.h new file mode 100644 index 0000000..99e40c6 --- /dev/null +++ b/tksao/frame/boxannulus.h @@ -0,0 +1,58 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __boxannulus_h__ +#define __boxannulus_h__ + +#include "basebox.h" + +class BoxAnnulus : public BaseBox { + protected: + void listNonCel(FitsImage*, ostream&, Coord::CoordSystem); + +public: + BoxAnnulus(Base* p, const Vector& ctr, + const Vector& s, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + BoxAnnulus(Base* p, const Vector& ctr, + const Vector& inner, const Vector& outer, int num, + double ang); + BoxAnnulus(Base* p, const Vector& ctr, + const Vector& inner, const Vector& outer, int num, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + BoxAnnulus(Base* p, const Vector& ctr, + int an, Vector* s, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + BoxAnnulus(const BoxAnnulus&); + + Marker* dup() {return new BoxAnnulus(*this);} + void editBegin(int); + void edit(const Vector&, int); + void editEnd(); + + int addAnnuli(const Vector&); + + void analysis(AnalysisTask, int); + void analysisRadial(char*, char*, char*, Coord::CoordSystem sys); + void analysisStats(Coord::CoordSystem, Coord::SkyFrame sky); + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void listPros(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + void listSAOimage(ostream&, int); +}; + +#endif diff --git a/tksao/frame/bpanda.C b/tksao/frame/bpanda.C new file mode 100644 index 0000000..479a215 --- /dev/null +++ b/tksao/frame/bpanda.C @@ -0,0 +1,765 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "bpanda.h" +#include "fitsimage.h" + +Bpanda::Bpanda(Base* p, const Vector& ctr, + double a1, double a2, int an, + const Vector& r1, const Vector& r2, int rn, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BaseBox(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = rn+1; + annuli_ = new Vector[numAnnuli_]; + + for (int i=0; i& tg, const List& cb) + : BaseBox(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = rn; + annuli_ = new Vector[numAnnuli_]; + + for (int i=0; igetColor("red")); + else if (ii == numAngles_-1) + XSetForeground(display, gc, parent->getColor("blue")); + else + XSetForeground(display, gc, color); + } + else + XSetForeground(display, gc, color); + } + + XDrawLine(display, drawable, lgc, rr0[0], rr0[1], rr1[0], rr1[1]); + } +} + +void Bpanda::renderPS(int mode) +{ + BaseBox::renderPS(mode); + + renderPSGC(mode); + + Vector r0 = annuli_[0]/2; + Vector r1 = annuli_[numAnnuli_-1]/2; + + for (int ii=0; iicanvas) << ' ' + << "moveto " + << rr1.TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } +} + +#ifdef MAC_OSX_TK +void Bpanda::renderMACOSX() +{ + BaseBox::renderMACOSX(); + + renderMACOSXGC(); + + Vector r0 = annuli_[0]/2; + Vector r1 = annuli_[numAnnuli_-1]/2; + + for (int ii=0; ii4) { + int hh = h-4-1; + + if (numAnnuli_>2 && hh2 && hh<(numAnnuli_+numAngles_)) { + hh -= numAnnuli_; + deleteAngle(hh); + } + + numHandle = 4 + numAnnuli_ + numAngles_; + + startAng_ = angles_[0]; + stopAng_ = angles_[numAngles_-1]; + + updateBBox(); + doCallBack(CallBack::EDITCB); + } +} + +int Bpanda::isIn(const Vector& vv, Coord::InternalSystem sys, int nn, int aa) +{ + Vector pp = bckMap(vv,sys); + return BaseBox::isIn(vv,sys,nn) && isInAngle(pp,aa); +} + +void Bpanda::analysis(AnalysisTask mm, int which) +{ + switch (mm) { + case PANDA: + if (!analysisPanda_ && which) { + addCallBack(CallBack::MOVECB, analysisPandaCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisPandaCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITENDCB, analysisPandaCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisPandaCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisPandaCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisPandaCB_[1], + parent->options->cmdName); + } + if (analysisPanda_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisPandaCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisPandaCB_[0]); + deleteCallBack(CallBack::EDITENDCB, analysisPandaCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisPandaCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisPandaCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisPandaCB_[1]); + } + + analysisPanda_ = which; + break; + case STATS: + if (!analysisStats_ && which) { + addCallBack(CallBack::MOVECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITENDCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisStatsCB_[1], + parent->options->cmdName); + } + if (analysisStats_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITENDCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisStatsCB_[1]); + } + + analysisStats_ = which; + break; + default: + // na + break; + } +} + +void Bpanda::analysisPanda(Coord::CoordSystem sys) +{ + double* xx; + double* yy; + double* ee; + + BBox* bb = new BBox[numAnnuli_]; + Matrix mm = Rotate(angle) * Translate(center); + + for (int ii=0; iimarkerAnalysisPanda(this, &xx, &yy, &ee, + numAnnuli_-1, annuli_, + numAngles_-1, angles_, + bb, sys); + analysisXYEResult(xx, yy, ee, num); +} + +void Bpanda::analysisStats(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + ostringstream str; + BBox* bb = new BBox[numAnnuli_]; + Matrix mm = Rotate(angle) * Translate(center); + + for (int ii=0; iimarkerAnalysisStats(this, str, numAnnuli_-1, numAngles_-1, bb, sys, sky); + str << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +// list + +void Bpanda::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + int regular = 1; + if (numAngles_>2) { + double delta; + if (angles_[1] > angles_[0]) + delta = angles_[1]-angles_[0]; + else + delta = angles_[1]+M_TWOPI-angles_[0]; + + for (int ii=2; ii angles_[ii-1]) + diff = angles_[ii]-angles_[ii-1]; + else + diff = angles_[ii]+M_TWOPI-angles_[ii-1]; + + if (!teq(diff,delta,FLT_EPSILON)) { + regular = 0; + break; + } + } + } + + if (numAnnuli_>2) { + double delta = annuli_[1][0]-annuli_[0][0]; + for (int i=2; ifindFits(sys,center); + listPre(str, sys, sky, ptr, strip, 0); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listANonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + Vector r1 = ptr->mapLenFromRef(annuli_[0],sys,Coord::ARCSEC); + Vector r2 = ptr->mapLenFromRef(annuli_[numAnnuli_-1],sys,Coord::ARCSEC); + double ang1 = radToDeg(parent->mapAngleFromRef(angles_[0],sys,sky)); + double ang2 = radToDeg(parent->mapAngleFromRef(angles_[numAngles_-1],sys,sky)); + if (ang2<=ang1+FLT_EPSILON) + ang2 += 360; + + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' << setprecision(8) << vv << ',' + << ang1 << ',' << ang2 <<',' << numAngles_-1 << ',' + << setunit('"') << r1 << ',' << setunit('"') << r2 << ',' + << numAnnuli_-1 << ',' + << radToDeg(parent->mapAngleFromRef(angle,sys,sky)) << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' << ra << ',' << dec << ',' + << setprecision(8) + << ang1 << ',' << ang2 <<',' << numAngles_-1 << ',' + << setunit('"') << r1 << ',' << setunit('"') << r2 << ',' + << numAnnuli_-1 << ',' + << radToDeg(parent->mapAngleFromRef(angle,sys,sky)) << ')'; + break; + } + } + else + listANonCel(ptr, str, sys); + } + + listPost(str, conj, strip); +} + +void Bpanda::listANonCel(FitsImage* ptr, ostream& str, Coord::CoordSystem sys) +{ + double a1 = radToDeg(parent->mapAngleFromRef(angles_[0],sys)); + double a2 = radToDeg(parent->mapAngleFromRef(angles_[numAngles_-1],sys)); + if (a2<=a1+FLT_EPSILON) + a2 += 360; + + Vector vv = ptr->mapFromRef(center,sys); + Vector r1 = ptr->mapLenFromRef(annuli_[0],sys); + Vector r2 = ptr->mapLenFromRef(annuli_[numAnnuli_-1],sys); + double aa = parent->mapAngleFromRef(angle,sys); + str << type_ << '(' << setprecision(8) << vv << ',' + << a1 << ',' << a2 << ',' << numAngles_-1 << ',' + << r1 << ',' << r2 << ',' << numAnnuli_-1 << ',' + << radToDeg(aa) << ')'; +} + +void Bpanda::listB(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + FitsImage* ptr = parent->findFits(sys,center); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listBNonCel(ptr, str, sys, sky, format, conj, strip); + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + for (int jj=1; jjmapFromRef(center,sys); + double aa = parent->mapAngleFromRef(angle,sys); + for (int jj=1; jjmapAngleFromRef(angles_[jj-1],sys)); + double a2 = radToDeg(parent->mapAngleFromRef(angles_[jj],sys)); + if (a2<=a1+FLT_EPSILON) + a2 += 360; + + for (int ii=1; iimapLenFromRef(annuli_[ii-1],sys); + Vector r2 = ptr->mapLenFromRef(annuli_[ii],sys); + str << type_ << '(' + << setprecision(8) << vv << ',' + << a1 << ',' << a2 << ",1," + << r1 << ',' << r2 << ",1," + << radToDeg(aa) << ')'; + + if (!strip) { + if (conj) + str << " ||"; + + str << " # bpanda="; + if (ii==1 && jj==1 && !strip) { + str << '('; + for (int kk=0; kkmapAngleFromRef(angles_[kk],sys); + str << radToDeg(ar) << ((kkmapLenFromRef(annuli_[kk],sys); + str << rr << ((kkmapAngleFromRef(angles_[jj-1],sys,sky)); + double a2 = radToDeg(parent->mapAngleFromRef(angles_[jj],sys,sky)); + if (a2<=a1+FLT_EPSILON) + a2 += 360; + + Vector r1 = ptr->mapLenFromRef(annuli_[ii-1],sys,Coord::ARCSEC); + Vector r2 = ptr->mapLenFromRef(annuli_[ii],sys,Coord::ARCSEC); + double aa = parent->mapAngleFromRef(angle,sys,sky); + + str << setprecision(10) << a1 << ',' << a2 << ",1," + << setprecision(3) << fixed << setunit('"') << r1 << ',' + << setunit('"') << r2 << ",1,"; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(aa) << ')'; + + if (!strip) { + if (conj) + str << " ||"; + + str << " # bpanda="; + if (ii==1 && jj==1 && !strip) { + str << '(' << setprecision(8); + for (int kk=0; kkmapAngleFromRef(angles_[kk],sys,sky); + str << radToDeg(ar) << ((kkmapLenFromRef(annuli_[kk],sys,Coord::ARCSEC); + str << setunit('"') << rr << ((kkfindFits(sys,center); + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowCenter(ptr,sys,sky,format); + XMLRowRadius(ptr,sys,annuli_,numAnnuli_); + XMLRowAng(sys,sky); + XMLRowAng(sys,sky,angles_,numAngles_); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} diff --git a/tksao/frame/bpanda.h b/tksao/frame/bpanda.h new file mode 100644 index 0000000..0b574f9 --- /dev/null +++ b/tksao/frame/bpanda.h @@ -0,0 +1,80 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __bpanda_h__ +#define __bpanda_h__ + +#include "basebox.h" + +class Bpanda : public BaseBox { + private: + void renderX(Drawable, Coord::InternalSystem, RenderMode); + void renderPS(int); +#ifdef MAC_OSX_TK + void renderMACOSX(); +#endif +#ifdef __WIN32 + void renderWIN32(); +#endif + + void updateHandles(); + + void listA(ostream&, Coord::CoordSystem, Coord::SkyFrame, + Coord::SkyFormat, int, int); + void listB(ostream&, Coord::CoordSystem, Coord::SkyFrame, + Coord::SkyFormat, int, int); + + void listANonCel(FitsImage*, ostream&, Coord::CoordSystem); + + void listBNonCel(FitsImage*, ostream&, + Coord::CoordSystem, Coord::SkyFrame, + Coord::SkyFormat, int, int); + + void listBCel(FitsImage*, int, int, ostream&, + Coord::CoordSystem, Coord::SkyFrame, + Coord::SkyFormat, int, int); + + public: + Bpanda(const Bpanda&); + Bpanda(Base* p, const Vector& ctr, + double a1, double a2, int an, + const Vector& r1, const Vector& r2, int rn, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + + Bpanda(Base* p, const Vector& ctr, + int an, double* a, + int rn, Vector* r, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + + Marker* dup() {return new Bpanda(*this);} + + int isIn(const Vector& vv, Coord::InternalSystem sys, int nn, int aa); + + void editBegin(int); + void edit(const Vector&, int); + void editEnd(); + + int addAnnuli(const Vector&); + int addAngles(const Vector&); + void setAnglesAnnuli(double, double, int, Vector, Vector, int); + void setAnglesAnnuli(const double*, int, const Vector*, int); + void deleteAnglesAnnuli(int h); + + void analysis(AnalysisTask, int); + void analysisPanda(Coord::CoordSystem sys); + void analysisStats(Coord::CoordSystem, Coord::SkyFrame sky); + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); +}; + +#endif diff --git a/tksao/frame/callback.C b/tksao/frame/callback.C new file mode 100644 index 0000000..3ec3d1f --- /dev/null +++ b/tksao/frame/callback.C @@ -0,0 +1,59 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "callback.h" + +CallBack::CallBack(const CallBack& a) +{ + interp_ = a.interp_; + + type_ = a.type_; + strcpy(proc_, a.proc_); + strcpy(arg_, a.arg_); + + previous_ = NULL; + next_ = NULL; +} + +CallBack& CallBack::operator=(const CallBack& a) +{ + interp_ = a.interp_; + + type_ = a.type_; + strcpy(proc_, a.proc_); + strcpy(arg_, a.arg_); + + previous_ = NULL; + next_ = NULL; + + return *this; +} + +CallBack::CallBack(Tcl_Interp* interp, Type type, + const char* proc, const char* arg) +{ + interp_ = interp; + + type_ = type; + + if (proc) + strncpy(proc_, proc, 32); + else + proc_[0] = '\0'; + + if (arg) + strncpy(arg_, arg, 64); + else + arg_[0] = '\0'; + + previous_ = NULL; + next_ = NULL; +} + +int CallBack::eval(const char* arg2) +{ + return Tcl_VarEval(interp_, proc_, " ", arg_, " ", arg2, NULL); +} diff --git a/tksao/frame/callback.h b/tksao/frame/callback.h new file mode 100644 index 0000000..3bfc6f7 --- /dev/null +++ b/tksao/frame/callback.h @@ -0,0 +1,49 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __callback_h__ +#define __callback_h__ + +#include + +class CallBack { + public: + enum Type {SELECTCB, UNSELECTCB, + HIGHLITECB, UNHIGHLITECB, + EDITBEGINCB, EDITCB, EDITENDCB, + MOVEBEGINCB, MOVECB, MOVEENDCB, + ROTATEBEGINCB, ROTATECB, ROTATEENDCB, + DELETECB, + TEXTCB, COLORCB, LINEWIDTHCB, PROPERTYCB, FONTCB, + KEYCB, + UPDATECB}; + + private: + Tcl_Interp* interp_; + + Type type_; + char proc_[128]; + char arg_[256]; + + CallBack* previous_; + CallBack* next_; + + public: + CallBack(const CallBack&); + CallBack(Tcl_Interp*, Type, const char*, const char*); + CallBack& operator=(const CallBack&); + + int eval(const char*); + + Type type() {return type_;} + const char* proc() {return proc_;} + const char* arg() {return arg_;} + + CallBack* previous() {return previous_;} + void setPrevious(CallBack* cb) {previous_ = cb;} + CallBack* next() {return next_;} + void setNext(CallBack* cb) {next_ = cb;} +}; + +#endif diff --git a/tksao/frame/ciaolex.C b/tksao/frame/ciaolex.C new file mode 100644 index 0000000..ae5cc23 --- /dev/null +++ b/tksao/frame/ciaolex.C @@ -0,0 +1,1898 @@ +#line 2 "frame/ciaolex.C" + +#line 4 "frame/ciaolex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer ciaoFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *ciaoalloc (yy_size_t ); +void *ciaorealloc (void *,yy_size_t ); +void ciaofree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[150] = + { 0, + 0, 0, 52, 50, 46, 49, 50, 45, 50, 50, + 22, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 46, 48, 45, 0, 22, 24, 31, + 27, 23, 22, 0, 25, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, + 0, 47, 24, 33, 29, 23, 32, 28, 26, 0, + 35, 25, 0, 0, 0, 23, 0, 0, 2, 3, + 0, 6, 0, 9, 11, 12, 0, 0, 0, 0, + 0, 0, 34, 30, 37, 36, 0, 24, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 14, 16, 0, + + 0, 0, 0, 38, 0, 39, 0, 0, 0, 0, + 0, 0, 5, 0, 8, 13, 0, 0, 0, 0, + 0, 0, 40, 39, 0, 0, 43, 0, 0, 41, + 0, 4, 0, 0, 0, 18, 19, 20, 0, 44, + 42, 1, 7, 15, 0, 21, 0, 17, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 5, 6, 1, 1, 1, 7, 1, + 1, 1, 8, 1, 8, 9, 1, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 11, 1, 1, + 1, 1, 1, 1, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 1, 1, 21, 22, 23, 24, 25, + 1, 26, 27, 28, 29, 30, 1, 31, 32, 1, + 1, 33, 1, 1, 1, 1, 34, 35, 36, 37, + + 38, 39, 40, 41, 42, 1, 1, 43, 44, 45, + 46, 47, 1, 48, 49, 50, 51, 52, 1, 53, + 54, 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, + 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, 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, 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, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[55] = + { 0, + 1, 1, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[151] = + { 0, + 0, 0, 306, 307, 303, 307, 301, 0, 46, 293, + 52, 35, 36, 44, 49, 45, 49, 53, 53, 59, + 56, 58, 55, 300, 307, 0, 286, 97, 103, 307, + 288, 107, 0, 284, 282, 71, 281, 80, 78, 85, + 102, 95, 104, 104, 307, 108, 106, 114, 101, 116, + 108, 307, 148, 307, 283, 152, 307, 277, 307, 161, + 307, 307, 74, 150, 273, 168, 155, 110, 307, 152, + 141, 154, 155, 307, 307, 156, 148, 153, 162, 170, + 156, 160, 307, 275, 307, 307, 271, 190, 126, 198, + 201, 170, 172, 194, 189, 201, 189, 200, 207, 196, + + 197, 198, 203, 307, 270, 215, 246, 219, 243, 221, + 198, 216, 307, 206, 307, 307, 211, 214, 224, 219, + 225, 228, 216, 137, 248, 250, 307, 251, 252, 307, + 236, 307, 248, 242, 248, 307, 307, 307, 244, 307, + 307, 307, 307, 307, 250, 307, 260, 307, 307, 100 + } ; + +static yyconst flex_int16_t yy_def[151] = + { 0, + 149, 1, 149, 149, 149, 149, 149, 150, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 150, 149, 11, 149, 149, + 149, 149, 11, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 0, 149 + } ; + +static yyconst flex_int16_t yy_nxt[362] = + { 0, + 4, 5, 6, 7, 4, 8, 4, 9, 10, 11, + 4, 12, 13, 14, 15, 16, 17, 4, 4, 4, + 4, 4, 4, 18, 19, 20, 21, 4, 4, 22, + 4, 4, 23, 12, 13, 14, 15, 16, 17, 4, + 4, 4, 4, 4, 4, 18, 19, 20, 21, 4, + 4, 22, 4, 4, 27, 28, 30, 38, 31, 39, + 32, 33, 34, 40, 41, 42, 35, 36, 43, 44, + 37, 50, 46, 51, 48, 45, 47, 52, 65, 38, + 66, 39, 49, 63, 89, 40, 41, 42, 35, 36, + 43, 44, 37, 50, 46, 51, 48, 45, 47, 52, + + 26, 54, 68, 55, 49, 56, 28, 57, 69, 58, + 70, 30, 29, 31, 71, 72, 29, 59, 60, 73, + 74, 62, 36, 75, 68, 76, 77, 78, 80, 81, + 69, 79, 70, 82, 105, 106, 71, 72, 92, 59, + 60, 73, 74, 62, 36, 75, 123, 76, 77, 78, + 80, 81, 83, 79, 84, 82, 54, 53, 55, 64, + 92, 53, 59, 60, 67, 93, 62, 36, 87, 94, + 88, 90, 54, 95, 55, 96, 91, 66, 97, 98, + 99, 100, 101, 102, 59, 60, 103, 93, 62, 36, + 111, 94, 112, 90, 83, 95, 84, 96, 91, 88, + + 97, 98, 99, 100, 101, 102, 107, 108, 103, 109, + 110, 113, 111, 114, 112, 115, 116, 117, 118, 119, + 120, 121, 122, 124, 106, 123, 131, 126, 108, 129, + 110, 132, 133, 113, 134, 114, 135, 115, 116, 117, + 118, 119, 120, 121, 122, 127, 136, 130, 131, 137, + 138, 139, 128, 132, 133, 125, 134, 125, 135, 125, + 128, 128, 142, 143, 144, 145, 146, 127, 136, 130, + 147, 137, 138, 139, 140, 148, 127, 141, 130, 123, + 88, 104, 66, 86, 142, 143, 144, 145, 146, 85, + 67, 64, 147, 63, 61, 53, 140, 148, 127, 141, + + 130, 24, 29, 25, 24, 149, 3, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149 + } ; + +static yyconst flex_int16_t yy_chk[362] = + { 0, + 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, 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, 9, 9, 11, 12, 11, 13, + 11, 11, 11, 14, 15, 16, 11, 11, 17, 18, + 11, 21, 19, 22, 20, 18, 19, 23, 36, 12, + 36, 13, 20, 63, 63, 14, 15, 16, 11, 11, + 17, 18, 11, 21, 19, 22, 20, 18, 19, 23, + + 150, 28, 38, 28, 20, 28, 28, 29, 39, 29, + 40, 32, 29, 32, 41, 42, 32, 29, 29, 43, + 44, 32, 32, 46, 38, 47, 47, 48, 49, 50, + 39, 48, 40, 51, 89, 89, 41, 42, 68, 29, + 29, 43, 44, 32, 32, 46, 124, 47, 47, 48, + 49, 50, 53, 48, 53, 51, 56, 53, 56, 64, + 68, 56, 53, 53, 67, 70, 56, 56, 60, 71, + 60, 64, 66, 72, 66, 73, 67, 66, 76, 77, + 78, 79, 80, 81, 53, 53, 82, 70, 56, 56, + 92, 71, 93, 64, 88, 72, 88, 73, 67, 88, + + 76, 77, 78, 79, 80, 81, 90, 90, 82, 91, + 91, 94, 92, 95, 93, 96, 97, 98, 99, 100, + 101, 102, 103, 106, 106, 123, 111, 108, 108, 110, + 110, 112, 114, 94, 117, 95, 118, 96, 97, 98, + 99, 100, 101, 102, 103, 108, 119, 110, 111, 120, + 121, 122, 109, 112, 114, 107, 117, 125, 118, 126, + 128, 129, 131, 133, 134, 135, 139, 108, 119, 110, + 145, 120, 121, 122, 125, 147, 126, 128, 129, 105, + 87, 84, 65, 58, 131, 133, 134, 135, 139, 55, + 37, 35, 145, 34, 31, 27, 125, 147, 126, 128, + + 129, 24, 10, 7, 5, 3, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "frame/ciaolex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 12 "frame/ciaolex.L" + #include + #include + #include + + #include "util.h" + #include "ciaoparser.H" + + extern YYSTYPE* ciaolval; +/* rules */ +#line 549 "frame/ciaolex.C" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 27 "frame/ciaolex.L" + + +#line 652 "frame/ciaolex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 150 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 149 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 29 "frame/ciaolex.L" +{return ANNULUS_;} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 30 "frame/ciaolex.L" +{return BOX_;} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 31 "frame/ciaolex.L" +{return CIRCLE_;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 32 "frame/ciaolex.L" +{return CIRCLE_;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 33 "frame/ciaolex.L" +{return DEBUG_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 34 "frame/ciaolex.L" +{return ELLIPSE_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 35 "frame/ciaolex.L" +{return ELLIPSE_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 36 "frame/ciaolex.L" +{return FIELD_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 37 "frame/ciaolex.L" +{return OFF_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 38 "frame/ciaolex.L" +{return ON_;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 39 "frame/ciaolex.L" +{return PIE_;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 40 "frame/ciaolex.L" +{return POINT_;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 41 "frame/ciaolex.L" +{return POINT_;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 42 "frame/ciaolex.L" +{return POLYGON_;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 43 "frame/ciaolex.L" +{return POLYGON_;} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 44 "frame/ciaolex.L" +{return RECTANGLE_;} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 45 "frame/ciaolex.L" +{return RECTANGLE_;} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 46 "frame/ciaolex.L" +{return REGION_;} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 47 "frame/ciaolex.L" +{return ROTBOX_;} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 48 "frame/ciaolex.L" +{return SECTOR_;} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 49 "frame/ciaolex.L" +{return VERSION_;} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 51 "frame/ciaolex.L" +{ // Integer + ciaolval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 23: +#line 57 "frame/ciaolex.L" +case 24: +YY_RULE_SETUP +#line 57 "frame/ciaolex.L" +{ // Real Number + ciaolval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 25: +#line 63 "frame/ciaolex.L" +case 26: +YY_RULE_SETUP +#line 63 "frame/ciaolex.L" +{ // degrees + yytext[yyleng-1] = '\0'; + ciaolval->real = atof(yytext); + return ANGDEGREE; + } + YY_BREAK +case 27: +#line 70 "frame/ciaolex.L" +case 28: +#line 71 "frame/ciaolex.L" +case 29: +#line 72 "frame/ciaolex.L" +case 30: +YY_RULE_SETUP +#line 72 "frame/ciaolex.L" +{ // minutes of arc + yytext[yyleng-1] = '\0'; + ciaolval->real = atof(yytext); + return ARCMINUTE; + } + YY_BREAK +case 31: +#line 79 "frame/ciaolex.L" +case 32: +#line 80 "frame/ciaolex.L" +case 33: +#line 81 "frame/ciaolex.L" +case 34: +YY_RULE_SETUP +#line 81 "frame/ciaolex.L" +{ // seconds of arc + yytext[yyleng-1] = '\0'; + ciaolval->real = atof(yytext); + return ARCSECOND; + } + YY_BREAK +case 35: +#line 88 "frame/ciaolex.L" +case 36: +#line 89 "frame/ciaolex.L" +case 37: +#line 90 "frame/ciaolex.L" +case 38: +YY_RULE_SETUP +#line 90 "frame/ciaolex.L" +{ // seconds of arc + yytext[yyleng-1] = '\0'; + ciaolval->real = atof(yytext); + return ARCSECOND; + } + YY_BREAK +case 39: +#line 97 "frame/ciaolex.L" +case 40: +YY_RULE_SETUP +#line 97 "frame/ciaolex.L" +{ // Sexagesimal + int ll = yyleng <(CIAOBUFSIZE-1) ? yyleng:(CIAOBUFSIZE-1); + strncpy(ciaolval->str,yytext,ll); + ciaolval->str[ll] = '\0'; + return SEXSTR; + } + YY_BREAK +case 41: +#line 105 "frame/ciaolex.L" +case 42: +YY_RULE_SETUP +#line 105 "frame/ciaolex.L" +{ // HMS + int ll = yyleng <(CIAOBUFSIZE-1) ? yyleng:(CIAOBUFSIZE-1); + strncpy(ciaolval->str,yytext,ll); + ciaolval->str[ll] = '\0'; + return HMSSTR; + } + YY_BREAK +case 43: +#line 113 "frame/ciaolex.L" +case 44: +YY_RULE_SETUP +#line 113 "frame/ciaolex.L" +{ // DMS + int ll = yyleng <(CIAOBUFSIZE-1) ? yyleng:(CIAOBUFSIZE-1); + strncpy(ciaolval->str,yytext,ll); + ciaolval->str[ll] = '\0'; + return DMSSTR; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 120 "frame/ciaolex.L" +{ // comment, eat it + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 123 "frame/ciaolex.L" +{ // White Spaces + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 126 "frame/ciaolex.L" +{ // fake line feed + return '\n'; + } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 130 "frame/ciaolex.L" +{ // windows line feed + return '\n'; + } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 134 "frame/ciaolex.L" +{ // linefeed + return '\n'; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +#line 138 "frame/ciaolex.L" +{ // eof + return EOF_; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 142 "frame/ciaolex.L" +{ // Else, return the char + return yytext[0]; + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 146 "frame/ciaolex.L" +ECHO; + YY_BREAK +#line 999 "frame/ciaolex.C" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + ciaofree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + ciaofree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + ciaorealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ciaorealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 150 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 150 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 149); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) ciaoalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) ciaoalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + ciaofree((void *) b->yy_ch_buf ); + + ciaofree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)ciaoalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)ciaorealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) ciaoalloc(new_size ); + + else + (yy_start_stack) = (int *) ciaorealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *ciaoalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *ciaorealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void ciaofree (void * ptr ) +{ + free( (char *) ptr ); /* see ciaorealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 146 "frame/ciaolex.L" + + + diff --git a/tksao/frame/ciaolex.L b/tksao/frame/ciaolex.L new file mode 100644 index 0000000..a570c76 --- /dev/null +++ b/tksao/frame/ciaolex.L @@ -0,0 +1,146 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ + +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + + #include "util.h" + #include "ciaoparser.H" + + extern YYSTYPE* ciaolval; +%} + +D [0-9] +E [Ee][+-]?{D}+ + +/* rules */ + +%% + +annulus {return ANNULUS_;} +box {return BOX_;} +cir {return CIRCLE_;} +circle {return CIRCLE_;} +debug {return DEBUG_;} +ell {return ELLIPSE_;} +ellipse {return ELLIPSE_;} +field {return FIELD_;} +off {return OFF_;} +on {return ON_;} +pie {return PIE_;} +poi {return POINT_;} +point {return POINT_;} +poly {return POLYGON_;} +polygon {return POLYGON_;} +rect {return RECTANGLE_;} +rectangle {return RECTANGLE_;} +region {return REGION_;} +rotbox {return ROTBOX_;} +sector {return SECTOR_;} +version {return VERSION_;} + +[+-]?{D}+ { // Integer + ciaolval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + ciaolval->real = atof(yytext); + return REAL; + } + +[+-]?{D}+"."?d | +[+-]?{D}*"."{D}+d { // degrees + yytext[yyleng-1] = '\0'; + ciaolval->real = atof(yytext); + return ANGDEGREE; + } + +{D}+"."?' | +{D}*"."{D}+' | +[+-]?{D}+"."?({E})?' | +[+-]?{D}*"."{D}+({E})?' { // minutes of arc + yytext[yyleng-1] = '\0'; + ciaolval->real = atof(yytext); + return ARCMINUTE; + } + +{D}+"."?\" | +{D}*"."{D}+\" | +[+-]?{D}+"."?({E})?\" | +[+-]?{D}*"."{D}+({E})?\" { // seconds of arc + yytext[yyleng-1] = '\0'; + ciaolval->real = atof(yytext); + return ARCSECOND; + } + +{D}+"."?\'\' | +{D}*"."{D}+\'\' | +[+-]?{D}+"."?({E})?\'\' | +[+-]?{D}*"."{D}+({E})?\'\' { // seconds of arc + yytext[yyleng-1] = '\0'; + ciaolval->real = atof(yytext); + return ARCSECOND; + } + +[+-]?{D}+:{D}+:{D}+"."? | +[+-]?{D}+:{D}+:{D}*"."{D}+ { // Sexagesimal + int ll = yyleng <(CIAOBUFSIZE-1) ? yyleng:(CIAOBUFSIZE-1); + strncpy(ciaolval->str,yytext,ll); + ciaolval->str[ll] = '\0'; + return SEXSTR; + } + +[+-]?{D}+h{D}+m{D}+"."?s | +[+-]?{D}+h{D}+m{D}*"."{D}+s { // HMS + int ll = yyleng <(CIAOBUFSIZE-1) ? yyleng:(CIAOBUFSIZE-1); + strncpy(ciaolval->str,yytext,ll); + ciaolval->str[ll] = '\0'; + return HMSSTR; + } + +[+-]?{D}+d{D}+m{D}+"."?s | +[+-]?{D}+d{D}+m{D}*"."{D}+s { // DMS + int ll = yyleng <(CIAOBUFSIZE-1) ? yyleng:(CIAOBUFSIZE-1); + strncpy(ciaolval->str,yytext,ll); + ciaolval->str[ll] = '\0'; + return DMSSTR; + } + +#.* { // comment, eat it + } + +[ \t]+ { // White Spaces + } + +\\n { // fake line feed + return '\n'; + } + +\r\n { // windows line feed + return '\n'; + } + +\n { // linefeed + return '\n'; + } + +<> { // eof + return EOF_; + } + +. { // Else, return the char + return yytext[0]; + } + +%% diff --git a/tksao/frame/ciaoparser.C b/tksao/frame/ciaoparser.C new file mode 100644 index 0000000..9004b49 --- /dev/null +++ b/tksao/frame/ciaoparser.C @@ -0,0 +1,2031 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse ciaoparse +#define yylex ciaolex +#define yyerror ciaoerror +#define yylval ciaolval +#define yychar ciaochar +#define yydebug ciaodebug +#define yynerrs ciaonerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + ANGDEGREE = 260, + ARCMINUTE = 261, + ARCSECOND = 262, + SEXSTR = 263, + HMSSTR = 264, + DMSSTR = 265, + EOF_ = 266, + ANNULUS_ = 267, + BOX_ = 268, + CIRCLE_ = 269, + DEBUG_ = 270, + ELLIPSE_ = 271, + FIELD_ = 272, + OFF_ = 273, + ON_ = 274, + PIE_ = 275, + POINT_ = 276, + POLYGON_ = 277, + RECTANGLE_ = 278, + REGION_ = 279, + ROTBOX_ = 280, + SECTOR_ = 281, + VERSION_ = 282 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define ANGDEGREE 260 +#define ARCMINUTE 261 +#define ARCSECOND 262 +#define SEXSTR 263 +#define HMSSTR 264 +#define DMSSTR 265 +#define EOF_ 266 +#define ANNULUS_ 267 +#define BOX_ 268 +#define CIRCLE_ 269 +#define DEBUG_ 270 +#define ELLIPSE_ 271 +#define FIELD_ 272 +#define OFF_ 273 +#define ON_ 274 +#define PIE_ 275 +#define POINT_ 276 +#define POLYGON_ 277 +#define RECTANGLE_ 278 +#define REGION_ 279 +#define ROTBOX_ 280 +#define SECTOR_ 281 +#define VERSION_ 282 + + + + +/* Copy the first part of user declarations. */ +#line 10 "frame/ciaoparser.Y" + +#define YYDEBUG 1 + +#define FITSPTR (fr->findFits()) + +#include +#include +#include + +#include "base.h" +#include "fitsimage.h" +#include "basemarker.h" + +#undef yyFlexLexer +#define yyFlexLexer ciaoFlexLexer +#include + +extern int ciaolex(void*, ciaoFlexLexer*); +extern void ciaoerror(Base*, ciaoFlexLexer*, const char*); + +static const char *color = "green"; +static int dash[] = {8,3}; +static const char *font = "helvetica 10 normal roman"; +static const char *text = ""; +static unsigned short props; + +static List polylist; +static List taglist; +static List cblist; + +static void setProps(unsigned short* props, unsigned short prop, int value); + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 43 "frame/ciaoparser.Y" +{ +#define CIAOBUFSIZE 2048 + double real; + int integer; + char str[CIAOBUFSIZE]; + double vector[3]; +} +/* Line 193 of yacc.c. */ +#line 199 "frame/ciaoparser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 212 "frame/ciaoparser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 9 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 148 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 38 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 23 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 60 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 133 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 282 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 28, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 34, 2, 2, 2, 2, 30, 2, + 36, 37, 29, 32, 35, 33, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 31, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 7, 10, 11, 14, 16, 20, 22, + 24, 26, 27, 29, 31, 33, 35, 37, 40, 42, + 44, 46, 48, 50, 52, 54, 56, 57, 59, 61, + 63, 65, 67, 71, 75, 79, 83, 85, 87, 89, + 93, 97, 101, 105, 113, 119, 122, 128, 136, 139, + 151, 155, 156, 161, 167, 170, 173, 181, 188, 192, + 194 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 39, 0, -1, 39, 40, 41, -1, 40, 41, -1, + -1, 15, 44, -1, 27, -1, 48, 42, 56, -1, + 47, -1, 28, -1, 11, -1, -1, 29, -1, 30, + -1, 31, -1, 32, -1, 33, -1, 34, 29, -1, + 34, -1, 4, -1, 3, -1, 19, -1, 18, -1, + 35, -1, 36, -1, 37, -1, -1, 43, -1, 43, + -1, 5, -1, 6, -1, 7, -1, 43, 45, 43, + -1, 5, 45, 5, -1, 6, 45, 6, -1, 7, + 45, 7, -1, 8, -1, 9, -1, 10, -1, 43, + 45, 43, -1, 52, 45, 52, -1, 53, 45, 54, + -1, 5, 45, 5, -1, 12, 46, 55, 45, 50, + 45, 50, -1, 13, 46, 55, 45, 51, -1, 13, + 58, -1, 14, 46, 55, 45, 50, -1, 16, 46, + 55, 45, 51, 45, 49, -1, 17, 46, -1, 20, + 46, 55, 45, 50, 45, 50, 45, 49, 45, 49, + -1, 21, 46, 55, -1, -1, 22, 57, 46, 59, + -1, 23, 46, 55, 45, 55, -1, 24, 46, -1, + 25, 58, -1, 26, 46, 55, 45, 49, 45, 49, + -1, 46, 55, 45, 51, 45, 49, -1, 59, 45, + 60, -1, 60, -1, 55, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 93, 93, 94, 97, 98, 99, 100, 103, 104, + 105, 108, 109, 110, 111, 112, 113, 114, 115, 118, + 119, 122, 123, 126, 129, 132, 135, 146, 149, 150, + 151, 152, 155, 162, 169, 176, 185, 188, 191, 194, + 201, 208, 215, 224, 229, 234, 235, 240, 245, 246, + 251, 256, 256, 261, 268, 269, 270, 273, 280, 281, + 284 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "INT", "REAL", "ANGDEGREE", "ARCMINUTE", + "ARCSECOND", "SEXSTR", "HMSSTR", "DMSSTR", "EOF_", "ANNULUS_", "BOX_", + "CIRCLE_", "DEBUG_", "ELLIPSE_", "FIELD_", "OFF_", "ON_", "PIE_", + "POINT_", "POLYGON_", "RECTANGLE_", "REGION_", "ROTBOX_", "SECTOR_", + "VERSION_", "'\\n'", "'*'", "'&'", "'|'", "'+'", "'-'", "'!'", "','", + "'('", "')'", "$accept", "commands", "command", "terminator", "include", + "numeric", "debug", "sp", "bp", "ep", "init", "angle", "value", "vvalue", + "sexagesimal", "hms", "dms", "coord", "shape", "@1", "rotbox", + "polyNodes", "polyNode", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 10, 42, + 38, 124, 43, 45, 33, 44, 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 38, 39, 39, 40, 40, 40, 40, 41, 41, + 41, 42, 42, 42, 42, 42, 42, 42, 42, 43, + 43, 44, 44, 45, 46, 47, 48, 49, 50, 50, + 50, 50, 51, 51, 51, 51, 52, 53, 54, 55, + 55, 55, 55, 56, 56, 56, 56, 56, 56, 56, + 56, 57, 56, 56, 56, 56, 56, 58, 59, 59, + 60 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 3, 2, 0, 2, 1, 3, 1, 1, + 1, 0, 1, 1, 1, 1, 1, 2, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, + 1, 1, 3, 3, 3, 3, 1, 1, 1, 3, + 3, 3, 3, 7, 5, 2, 5, 7, 2, 11, + 3, 0, 4, 5, 2, 2, 7, 6, 3, 1, + 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 26, 0, 6, 26, 0, 11, 22, 21, 5, 1, + 0, 10, 9, 25, 3, 8, 12, 13, 14, 15, + 16, 18, 0, 2, 17, 0, 0, 0, 0, 0, + 0, 0, 51, 0, 0, 0, 0, 7, 24, 0, + 0, 45, 0, 0, 48, 0, 0, 0, 0, 54, + 0, 55, 0, 20, 19, 0, 36, 37, 0, 0, + 0, 0, 0, 0, 0, 0, 50, 0, 0, 0, + 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 60, 52, 59, 0, 0, 0, 42, 39, 40, + 38, 41, 29, 30, 31, 28, 0, 0, 0, 0, + 0, 44, 46, 0, 0, 0, 53, 0, 27, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 58, 0, + 43, 33, 34, 35, 32, 57, 47, 0, 56, 0, + 0, 0, 49 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 3, 4, 14, 22, 58, 8, 115, 39, 15, + 5, 109, 96, 101, 59, 60, 91, 81, 37, 47, + 41, 82, 83 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -69 +static const yytype_int16 yypact[] = +{ + 49, -17, -69, 73, 59, 104, -69, -69, -69, -69, + 59, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -13, 106, -69, -69, -24, -24, -24, -24, -24, + -24, -24, -69, -24, -24, -24, -24, -69, -69, 31, + 31, -69, 31, 31, -69, 31, 31, -24, 31, -69, + 31, -69, 31, -69, -69, -16, -69, -69, -16, -16, + -16, -16, -16, -16, -16, -16, -69, 31, -16, -16, + -16, -69, 19, 18, 15, 16, 136, 141, 136, 141, + 136, -69, -16, -69, 31, 141, 18, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -16, -16, -16, -16, + -16, -16, -69, -16, -16, 31, -69, -16, -69, -16, + 136, 28, 40, 44, 18, 18, 18, 136, -69, 18, + -69, -69, -69, -69, -69, -69, -69, -16, -69, 18, + -16, 18, -69 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -69, -69, 71, 37, -69, -48, -69, -55, 78, -69, + -69, -37, -60, -68, 6, -69, -69, 13, -69, -69, + 50, -69, -15 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -5 +static const yytype_int16 yytable[] = +{ + 72, 6, 7, 73, 74, 75, 76, 77, 78, 79, + 80, 103, 38, 84, 85, 86, 24, 107, 102, 71, + 104, 53, 54, 56, 87, 88, 90, 105, 95, 100, + 95, 100, 95, 121, 53, 54, 55, 100, 108, 56, + 57, 110, 111, 112, 113, 114, 122, 23, 116, 117, + 120, 123, 61, 62, 119, 63, 64, 127, 65, 66, + -4, 68, 95, 69, 1, 70, 124, 108, 108, 95, + 11, 108, 129, 9, 10, 131, 2, -4, 125, 126, + 89, 108, 128, 108, -4, 51, -4, 12, 1, 0, + 118, 0, 130, 0, 132, 0, 13, 106, 0, 0, + 2, -4, 0, 0, 40, 42, 43, 44, 45, 46, + -4, 48, 49, 50, 52, 0, 0, 0, 25, 26, + 27, 0, 28, 29, 0, 67, 30, 31, 32, 33, + 34, 35, 36, 16, 17, 18, 19, 20, 21, 53, + 54, 92, 93, 94, 53, 54, 97, 98, 99 +}; + +static const yytype_int16 yycheck[] = +{ + 55, 18, 19, 58, 59, 60, 61, 62, 63, 64, + 65, 79, 36, 68, 69, 70, 29, 85, 78, 35, + 80, 3, 4, 8, 5, 73, 10, 82, 76, 77, + 78, 79, 80, 5, 3, 4, 5, 85, 86, 8, + 9, 96, 97, 98, 99, 100, 6, 10, 103, 104, + 110, 7, 39, 40, 109, 42, 43, 117, 45, 46, + 11, 48, 110, 50, 15, 52, 114, 115, 116, 117, + 11, 119, 127, 0, 3, 130, 27, 28, 115, 116, + 74, 129, 119, 131, 11, 35, 37, 28, 15, -1, + 105, -1, 129, -1, 131, -1, 37, 84, -1, -1, + 27, 28, -1, -1, 26, 27, 28, 29, 30, 31, + 37, 33, 34, 35, 36, -1, -1, -1, 12, 13, + 14, -1, 16, 17, -1, 47, 20, 21, 22, 23, + 24, 25, 26, 29, 30, 31, 32, 33, 34, 3, + 4, 5, 6, 7, 3, 4, 5, 6, 7 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 15, 27, 39, 40, 48, 18, 19, 44, 0, + 40, 11, 28, 37, 41, 47, 29, 30, 31, 32, + 33, 34, 42, 41, 29, 12, 13, 14, 16, 17, + 20, 21, 22, 23, 24, 25, 26, 56, 36, 46, + 46, 58, 46, 46, 46, 46, 46, 57, 46, 46, + 46, 58, 46, 3, 4, 5, 8, 9, 43, 52, + 53, 55, 55, 55, 55, 55, 55, 46, 55, 55, + 55, 35, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 55, 59, 60, 45, 45, 45, 5, 43, 52, + 10, 54, 5, 6, 7, 43, 50, 5, 6, 7, + 43, 51, 50, 51, 50, 45, 55, 51, 43, 49, + 45, 45, 45, 45, 45, 45, 45, 45, 60, 45, + 50, 5, 6, 7, 43, 49, 49, 50, 49, 45, + 49, 45, 49 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (fr, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, fr, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, ciaoFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + ciaoFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (fr); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, ciaoFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + ciaoFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Base* fr, ciaoFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, fr, ll) + YYSTYPE *yyvsp; + int yyrule; + Base* fr; + ciaoFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , fr, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, fr, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Base* fr, ciaoFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, fr, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + Base* fr; + ciaoFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (fr); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (Base* fr, ciaoFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (Base* fr, ciaoFlexLexer* ll) +#else +int +yyparse (fr, ll) + Base* fr; + ciaoFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 6: +#line 99 "frame/ciaoparser.Y" + {cerr << "CIAO Regions File 1.0" << endl;;} + break; + + case 10: +#line 105 "frame/ciaoparser.Y" + {YYACCEPT;;} + break; + + case 16: +#line 113 "frame/ciaoparser.Y" + {setProps(&props, Marker::INCLUDE, 0);;} + break; + + case 17: +#line 114 "frame/ciaoparser.Y" + {setProps(&props, Marker::INCLUDE, 0);;} + break; + + case 18: +#line 115 "frame/ciaoparser.Y" + {setProps(&props, Marker::INCLUDE, 0);;} + break; + + case 19: +#line 118 "frame/ciaoparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 20: +#line 119 "frame/ciaoparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].integer);;} + break; + + case 21: +#line 122 "frame/ciaoparser.Y" + {yydebug=1;;} + break; + + case 22: +#line 123 "frame/ciaoparser.Y" + {yydebug=0;;} + break; + + case 26: +#line 135 "frame/ciaoparser.Y" + { + // reset maperr flag + maperr =0; + + props = + Marker::SELECT | Marker::EDIT | Marker::MOVE | + Marker::ROTATE | Marker::DELETE | Marker::HIGHLITE | + Marker::INCLUDE | Marker::SOURCE; + ;} + break; + + case 27: +#line 146 "frame/ciaoparser.Y" + {(yyval.real) = degToRad((yyvsp[(1) - (1)].real));;} + break; + + case 28: +#line 149 "frame/ciaoparser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), Coord::PHYSICAL);;} + break; + + case 29: +#line 150 "frame/ciaoparser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), Coord::WCS, Coord::DEGREE);;} + break; + + case 30: +#line 151 "frame/ciaoparser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), Coord::WCS, Coord::ARCMIN);;} + break; + + case 31: +#line 152 "frame/ciaoparser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), Coord::WCS, Coord::ARCSEC);;} + break; + + case 32: +#line 156 "frame/ciaoparser.Y" + { + Vector rr = FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::PHYSICAL); + (yyval.vector)[0] = rr[0]; + (yyval.vector)[1] = rr[1]; + (yyval.vector)[2] = rr[2]; + ;} + break; + + case 33: +#line 163 "frame/ciaoparser.Y" + { + Vector rr= FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::WCS,Coord::DEGREE); + (yyval.vector)[0] = rr[0]; + (yyval.vector)[1] = rr[1]; + (yyval.vector)[2] = rr[2]; + ;} + break; + + case 34: +#line 170 "frame/ciaoparser.Y" + { + Vector rr = FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::WCS, Coord::ARCMIN); + (yyval.vector)[0] = rr[0]; + (yyval.vector)[1] = rr[1]; + (yyval.vector)[2] = rr[2]; + ;} + break; + + case 35: +#line 177 "frame/ciaoparser.Y" + { + Vector rr = FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::WCS, Coord::ARCSEC); + (yyval.vector)[0] = rr[0]; + (yyval.vector)[1] = rr[1]; + (yyval.vector)[2] = rr[2]; + ;} + break; + + case 36: +#line 185 "frame/ciaoparser.Y" + {(yyval.real) = parseSEXStr((yyvsp[(1) - (1)].str));;} + break; + + case 37: +#line 188 "frame/ciaoparser.Y" + {(yyval.real) = parseHMSStr((yyvsp[(1) - (1)].str));;} + break; + + case 38: +#line 191 "frame/ciaoparser.Y" + {(yyval.real) = parseDMSStr((yyvsp[(1) - (1)].str));;} + break; + + case 39: +#line 195 "frame/ciaoparser.Y" + { + Vector rr = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::PHYSICAL); + (yyval.vector)[0] = rr[0]; + (yyval.vector)[1] = rr[1]; + (yyval.vector)[2] = rr[2]; + ;} + break; + + case 40: +#line 202 "frame/ciaoparser.Y" + { + Vector rr = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real)*360./24.,(yyvsp[(3) - (3)].real)), Coord::WCS,Coord::FK5); + (yyval.vector)[0] = rr[0]; + (yyval.vector)[1] = rr[1]; + (yyval.vector)[2] = rr[2]; + ;} + break; + + case 41: +#line 209 "frame/ciaoparser.Y" + { + Vector rr = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::WCS, Coord::FK5); + (yyval.vector)[0] = rr[0]; + (yyval.vector)[1] = rr[1]; + (yyval.vector)[2] = rr[2]; + ;} + break; + + case 42: +#line 216 "frame/ciaoparser.Y" + { + Vector rr = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::WCS, Coord::FK5); + (yyval.vector)[0] = rr[0]; + (yyval.vector)[1] = rr[1]; + (yyval.vector)[2] = rr[2]; + ;} + break; + + case 43: +#line 225 "frame/ciaoparser.Y" + { + fr->createAnnulusCmd(Vector((yyvsp[(3) - (7)].vector)), (yyvsp[(5) - (7)].real), (yyvsp[(7) - (7)].real), 1, + color,dash,1,font,text,props,NULL,taglist,cblist); + ;} + break; + + case 44: +#line 230 "frame/ciaoparser.Y" + { + fr->createBoxCmd(Vector((yyvsp[(3) - (5)].vector)), (yyvsp[(5) - (5)].vector), 0, + color,dash,1,font,text,props,NULL,taglist,cblist); + ;} + break; + + case 46: +#line 236 "frame/ciaoparser.Y" + { + fr->createCircleCmd(Vector((yyvsp[(3) - (5)].vector)), (yyvsp[(5) - (5)].real), + color,dash,1,font,text,props,NULL,taglist,cblist); + ;} + break; + + case 47: +#line 241 "frame/ciaoparser.Y" + { + fr->createEllipseCmd(Vector((yyvsp[(3) - (7)].vector)), Vector((yyvsp[(5) - (7)].vector)), (yyvsp[(7) - (7)].real), + color,dash,1,font,text,props,NULL,taglist,cblist); + ;} + break; + + case 48: +#line 245 "frame/ciaoparser.Y" + {/* not supported */;} + break; + + case 49: +#line 247 "frame/ciaoparser.Y" + { + fr->createCpandaCmd(Vector((yyvsp[(3) - (11)].vector)), (yyvsp[(9) - (11)].real), (yyvsp[(11) - (11)].real), 1, (yyvsp[(5) - (11)].real), (yyvsp[(7) - (11)].real), 1, + color,dash,1,font,text,props,NULL,taglist,cblist); + ;} + break; + + case 50: +#line 252 "frame/ciaoparser.Y" + { + fr->createPointCmd(Vector((yyvsp[(3) - (3)].vector)), Point::BOXCIRCLE, POINTSIZE, + color,dash,1,font,text,props,NULL,taglist,cblist); + ;} + break; + + case 51: +#line 256 "frame/ciaoparser.Y" + {polylist.deleteAll();;} + break; + + case 52: +#line 257 "frame/ciaoparser.Y" + { + fr->createPolygonCmd(polylist, + color,dash,1,font,text,props,NULL,taglist,cblist); + ;} + break; + + case 53: +#line 262 "frame/ciaoparser.Y" + { + Vector cc = (Vector((yyvsp[(5) - (5)].vector))-Vector((yyvsp[(3) - (5)].vector)))/2.+Vector((yyvsp[(3) - (5)].vector)); + Vector wh = Vector((yyvsp[(5) - (5)].vector))-Vector((yyvsp[(3) - (5)].vector)); + fr->createBoxCmd(cc, wh, 0, + color,dash,1,font,text,props,NULL,taglist,cblist); + ;} + break; + + case 54: +#line 268 "frame/ciaoparser.Y" + {/* not supported */;} + break; + + case 56: +#line 270 "frame/ciaoparser.Y" + {/* not supported */;} + break; + + case 57: +#line 274 "frame/ciaoparser.Y" + { + fr->createBoxCmd(Vector((yyvsp[(2) - (6)].vector)), Vector((yyvsp[(4) - (6)].vector)), (yyvsp[(6) - (6)].real), + color,dash,1,font,text,props,NULL,taglist,cblist); + ;} + break; + + case 60: +#line 284 "frame/ciaoparser.Y" + {polylist.append(new Vertex((yyvsp[(1) - (1)].vector)));;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1808 "frame/ciaoparser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (fr, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (fr, ll, yymsg); + } + else + { + yyerror (fr, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, fr, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, fr, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (fr, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, fr, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, fr, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 287 "frame/ciaoparser.Y" + + +static void setProps(unsigned short* props, unsigned short prop, int value) +{ + if (value) + *props |= prop; + else + *props &= ~prop; +} + diff --git a/tksao/frame/ciaoparser.H b/tksao/frame/ciaoparser.H new file mode 100644 index 0000000..600c925 --- /dev/null +++ b/tksao/frame/ciaoparser.H @@ -0,0 +1,118 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + ANGDEGREE = 260, + ARCMINUTE = 261, + ARCSECOND = 262, + SEXSTR = 263, + HMSSTR = 264, + DMSSTR = 265, + EOF_ = 266, + ANNULUS_ = 267, + BOX_ = 268, + CIRCLE_ = 269, + DEBUG_ = 270, + ELLIPSE_ = 271, + FIELD_ = 272, + OFF_ = 273, + ON_ = 274, + PIE_ = 275, + POINT_ = 276, + POLYGON_ = 277, + RECTANGLE_ = 278, + REGION_ = 279, + ROTBOX_ = 280, + SECTOR_ = 281, + VERSION_ = 282 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define ANGDEGREE 260 +#define ARCMINUTE 261 +#define ARCSECOND 262 +#define SEXSTR 263 +#define HMSSTR 264 +#define DMSSTR 265 +#define EOF_ 266 +#define ANNULUS_ 267 +#define BOX_ 268 +#define CIRCLE_ 269 +#define DEBUG_ 270 +#define ELLIPSE_ 271 +#define FIELD_ 272 +#define OFF_ 273 +#define ON_ 274 +#define PIE_ 275 +#define POINT_ 276 +#define POLYGON_ 277 +#define RECTANGLE_ 278 +#define REGION_ 279 +#define ROTBOX_ 280 +#define SECTOR_ 281 +#define VERSION_ 282 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 43 "frame/ciaoparser.Y" +{ +#define CIAOBUFSIZE 2048 + double real; + int integer; + char str[CIAOBUFSIZE]; + double vector[3]; +} +/* Line 1529 of yacc.c. */ +#line 111 "frame/ciaoparser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/frame/ciaoparser.Y b/tksao/frame/ciaoparser.Y new file mode 100644 index 0000000..7c17fdc --- /dev/null +++ b/tksao/frame/ciaoparser.Y @@ -0,0 +1,295 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {Base* fr} +%lex-param {ciaoFlexLexer* ll} +%parse-param {ciaoFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#define FITSPTR (fr->findFits()) + +#include +#include +#include + +#include "base.h" +#include "fitsimage.h" +#include "basemarker.h" + +#undef yyFlexLexer +#define yyFlexLexer ciaoFlexLexer +#include + +extern int ciaolex(void*, ciaoFlexLexer*); +extern void ciaoerror(Base*, ciaoFlexLexer*, const char*); + +static const char *color = "green"; +static int dash[] = {8,3}; +static const char *font = "helvetica 10 normal roman"; +static const char *text = ""; +static unsigned short props; + +static List polylist; +static List taglist; +static List cblist; + +static void setProps(unsigned short* props, unsigned short prop, int value); +%} + +%union { +#define CIAOBUFSIZE 2048 + double real; + int integer; + char str[CIAOBUFSIZE]; + double vector[3]; +} + +%type numeric + +%type angle +%type value +%type vvalue +%type sexagesimal +%type hms +%type dms +%type coord + +%token INT +%token REAL + +%token ANGDEGREE +%token ARCMINUTE +%token ARCSECOND + +%token SEXSTR +%token HMSSTR +%token DMSSTR + +%token EOF_ + +%token ANNULUS_ +%token BOX_ +%token CIRCLE_ +%token DEBUG_ +%token ELLIPSE_ +%token FIELD_ +%token OFF_ +%token ON_ +%token PIE_ +%token POINT_ +%token POLYGON_ +%token RECTANGLE_ +%token REGION_ +%token ROTBOX_ +%token SECTOR_ +%token VERSION_ + +%% + +commands: commands command terminator + | command terminator + ; + +command : /* empty */ + | DEBUG_ debug + | VERSION_ {cerr << "CIAO Regions File 1.0" << endl;} + | init include shape + ; + +terminator: ep + | '\n' + | EOF_ {YYACCEPT;} + ; + +include : /* empty */ + | '*' /* AND */ + | '&' /* AND */ + | '|' /* OR */ + | '+' /* OR */ + | '-' /* NOT */ {setProps(&props, Marker::INCLUDE, 0);} + | '!''*' /* NOT */ {setProps(&props, Marker::INCLUDE, 0);} + | '!' /* NOT */ {setProps(&props, Marker::INCLUDE, 0);} + ; + +numeric : REAL {$$=$1;} + | INT {$$=$1;} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + ; + +sp : ',' + ; + +bp : '(' + ; + +ep : ')' + ; + +init: { + // reset maperr flag + maperr =0; + + props = + Marker::SELECT | Marker::EDIT | Marker::MOVE | + Marker::ROTATE | Marker::DELETE | Marker::HIGHLITE | + Marker::INCLUDE | Marker::SOURCE; + } + ; + +angle : numeric {$$ = degToRad($1);} + ; + +value : numeric {$$ = FITSPTR->mapLenToRef($1, Coord::PHYSICAL);} + | ANGDEGREE {$$ = FITSPTR->mapLenToRef($1, Coord::WCS, Coord::DEGREE);} + | ARCMINUTE {$$ = FITSPTR->mapLenToRef($1, Coord::WCS, Coord::ARCMIN);} + | ARCSECOND {$$ = FITSPTR->mapLenToRef($1, Coord::WCS, Coord::ARCSEC);} + ; + +vvalue : numeric sp numeric + { + Vector rr = FITSPTR->mapLenToRef(Vector($1,$3), Coord::PHYSICAL); + $$[0] = rr[0]; + $$[1] = rr[1]; + $$[2] = rr[2]; + } + | ANGDEGREE sp ANGDEGREE + { + Vector rr= FITSPTR->mapLenToRef(Vector($1,$3), Coord::WCS,Coord::DEGREE); + $$[0] = rr[0]; + $$[1] = rr[1]; + $$[2] = rr[2]; + } + | ARCMINUTE sp ARCMINUTE + { + Vector rr = FITSPTR->mapLenToRef(Vector($1,$3), Coord::WCS, Coord::ARCMIN); + $$[0] = rr[0]; + $$[1] = rr[1]; + $$[2] = rr[2]; + } + | ARCSECOND sp ARCSECOND + { + Vector rr = FITSPTR->mapLenToRef(Vector($1,$3), Coord::WCS, Coord::ARCSEC); + $$[0] = rr[0]; + $$[1] = rr[1]; + $$[2] = rr[2]; + } + ; + +sexagesimal: SEXSTR {$$ = parseSEXStr($1);} + ; + +hms : HMSSTR {$$ = parseHMSStr($1);} + ; + +dms : DMSSTR {$$ = parseDMSStr($1);} + ; + +coord : numeric sp numeric + { + Vector rr = FITSPTR->mapToRef(Vector($1,$3), Coord::PHYSICAL); + $$[0] = rr[0]; + $$[1] = rr[1]; + $$[2] = rr[2]; + } + | sexagesimal sp sexagesimal + { + Vector rr = FITSPTR->mapToRef(Vector($1*360./24.,$3), Coord::WCS,Coord::FK5); + $$[0] = rr[0]; + $$[1] = rr[1]; + $$[2] = rr[2]; + } + | hms sp dms + { + Vector rr = FITSPTR->mapToRef(Vector($1,$3), Coord::WCS, Coord::FK5); + $$[0] = rr[0]; + $$[1] = rr[1]; + $$[2] = rr[2]; + } + | ANGDEGREE sp ANGDEGREE + { + Vector rr = FITSPTR->mapToRef(Vector($1,$3), Coord::WCS, Coord::FK5); + $$[0] = rr[0]; + $$[1] = rr[1]; + $$[2] = rr[2]; + } + ; + +shape : ANNULUS_ bp coord sp value sp value + { + fr->createAnnulusCmd(Vector($3), $5, $7, 1, + color,dash,1,font,text,props,NULL,taglist,cblist); + } + | BOX_ bp coord sp vvalue + { + fr->createBoxCmd(Vector($3), $5, 0, + color,dash,1,font,text,props,NULL,taglist,cblist); + } + | BOX_ rotbox + | CIRCLE_ bp coord sp value + { + fr->createCircleCmd(Vector($3), $5, + color,dash,1,font,text,props,NULL,taglist,cblist); + } + | ELLIPSE_ bp coord sp vvalue sp angle + { + fr->createEllipseCmd(Vector($3), Vector($5), $7, + color,dash,1,font,text,props,NULL,taglist,cblist); + } + | FIELD_ bp {/* not supported */} + | PIE_ bp coord sp value sp value sp angle sp angle + { + fr->createCpandaCmd(Vector($3), $9, $11, 1, $5, $7, 1, + color,dash,1,font,text,props,NULL,taglist,cblist); + } + | POINT_ bp coord + { + fr->createPointCmd(Vector($3), Point::BOXCIRCLE, POINTSIZE, + color,dash,1,font,text,props,NULL,taglist,cblist); + } + | POLYGON_ {polylist.deleteAll();} bp polyNodes + { + fr->createPolygonCmd(polylist, + color,dash,1,font,text,props,NULL,taglist,cblist); + } + | RECTANGLE_ bp coord sp coord + { + Vector cc = (Vector($5)-Vector($3))/2.+Vector($3); + Vector wh = Vector($5)-Vector($3); + fr->createBoxCmd(cc, wh, 0, + color,dash,1,font,text,props,NULL,taglist,cblist); + } + | REGION_ bp {/* not supported */} + | ROTBOX_ rotbox + | SECTOR_ bp coord sp angle sp angle {/* not supported */} + ; + +rotbox : bp coord sp vvalue sp angle + { + fr->createBoxCmd(Vector($2), Vector($4), $6, + color,dash,1,font,text,props,NULL,taglist,cblist); + } + ; + +polyNodes : polyNodes sp polyNode + | polyNode + ; + +polyNode : coord {polylist.append(new Vertex($1));} + ; + +%% + +static void setProps(unsigned short* props, unsigned short prop, int value) +{ + if (value) + *props |= prop; + else + *props &= ~prop; +} diff --git a/tksao/frame/circle.C b/tksao/frame/circle.C new file mode 100644 index 0000000..aaebdcb --- /dev/null +++ b/tksao/frame/circle.C @@ -0,0 +1,358 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "circle.h" +#include "fitsimage.h" + +Circle::Circle(Base* p, const Vector& ctr, double r) + : BaseEllipse(p, ctr, 0) +{ + numAnnuli_ = 1; + annuli_ = new Vector[1]; + annuli_[0] = Vector(r,r); + + strcpy(type_, "circle"); + numHandle = 4; + + updateBBox(); +} + +Circle::Circle(Base* p, const Vector& ctr, + double r, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BaseEllipse(p, ctr, 0, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = 1; + annuli_ = new Vector[numAnnuli_]; + annuli_[0] = Vector(r,r); + + strcpy(type_, "circle"); + numHandle = 4; + + updateBBox(); +} + +Circle::Circle(const Circle& a) : BaseEllipse(a) {} + +void Circle::edit(const Vector& v, int h) +{ + Matrix mm = bckMatrix(); + + // calc dist between edge of circle and handle + double d = annuli_[0].length() - annuli_[0][0]; + double r = (v * mm).length() - d; + annuli_[0] = Vector(r,r); + + updateBBox(); + doCallBack(CallBack::EDITCB); +} + +void Circle::analysis(AnalysisTask mm, int which) +{ + switch (mm) { + case HISTOGRAM: + if (!analysisHistogram_ && which) { + addCallBack(CallBack::MOVECB, analysisHistogramCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisHistogramCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisHistogramCB_[1], + parent->options->cmdName); + } + if (analysisHistogram_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisHistogramCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisHistogramCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisHistogramCB_[1]); + } + + analysisHistogram_ = which; + break; + case PLOT3D: + if (!analysisPlot3d_ && which) { + addCallBack(CallBack::MOVECB, analysisPlot3dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisPlot3dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisPlot3dCB_[1], + parent->options->cmdName); + } + if (analysisPlot3d_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisPlot3dCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisPlot3dCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisPlot3dCB_[1]); + } + + analysisPlot3d_ = which; + break; + case STATS: + if (!analysisStats_ && which) { + addCallBack(CallBack::MOVECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisStatsCB_[1], + parent->options->cmdName); + } + if (analysisStats_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisStatsCB_[1]); + } + + analysisStats_ = which; + break; + default: + // na + break; + } +} + +void Circle::analysisHistogram(char* xname, char* yname, int num) +{ + double* x; + double* y; + Vector ll = -annuli_[0] * Translate(center); + Vector ur = annuli_[0] * Translate(center); + BBox bb(ll,ur) ; + parent->markerAnalysisHistogram(this, &x, &y, bb, num); + analysisXYResult(xname, yname, x, y, num+1); +} + +void Circle::analysisPlot3d(char* xname, char* yname, + Coord::CoordSystem sys, + Marker::AnalysisMethod method) +{ + double* x; + double* y; + Vector ll = -annuli_[0] * Translate(center); + Vector ur = annuli_[0] * Translate(center); + BBox bb(ll,ur) ; + int num = parent->markerAnalysisPlot3d(this, &x, &y, bb, sys, method); + analysisXYResult(xname, yname, x, y, num); +} + +void Circle::analysisStats(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + ostringstream str; + Vector ll = -annuli_[0] * Translate(center); + Vector ur = annuli_[0] * Translate(center); + BBox bb(ll,ur) ; + parent->markerAnalysisStats(this, str, bb, sys, sky); + str << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +// list + +void Circle::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 0); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listNonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + double rr = ptr->mapLenFromRef(annuli_[0][0],sys,Coord::ARCSEC); + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' + << setprecision(10) << vv << ',' + << setprecision(3) << fixed << rr << '"' << ')'; + str.unsetf(ios_base::floatfield); + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' + << ra << ',' << dec << ',' + << setprecision(3) << fixed << rr << '"' << ')'; + str.unsetf(ios_base::floatfield); + break; + } + } + else + listNonCel(ptr, str, sys); + } + + listPost(str, conj, strip); +} + +void Circle::listNonCel(FitsImage* ptr, ostream& str, Coord::CoordSystem sys) +{ + Vector vv = ptr->mapFromRef(center,sys); + double rr = ptr->mapLenFromRef(annuli_[0][0],sys); + str << type_ << '(' << setprecision(8) << vv << ',' << rr << ')'; +} + +void Circle::listXML(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + FitsImage* ptr = parent->findFits(sys,center); + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowCenter(ptr,sys,sky,format); + XMLRowRadiusX(ptr,sys,annuli_[0]); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} + +void Circle::listCiao(ostream& str, Coord::CoordSystem sys, int strip) +{ + FitsImage* ptr = parent->findFits(); + listCiaoPre(str); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + Vector vv = ptr->mapFromRef(center,Coord::PHYSICAL); + double rr = ptr->mapLenFromRef(annuli_[0][0],Coord::PHYSICAL); + str << type_ << '(' << setprecision(8) << vv << ',' << rr << ')'; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + listRADEC(ptr,center,sys,Coord::FK5,Coord::SEXAGESIMAL); + double rr = ptr->mapLenFromRef(annuli_[0][0],sys,Coord::ARCMIN); + str << type_ << '(' + << ra << ',' << dec << ',' + << setprecision(5) << fixed << rr << '\'' << ')'; + str.unsetf(ios_base::floatfield); + } + } + + listCiaoPost(str, strip); +} + +void Circle::listSAOtng(ostream& str, + Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int strip) +{ + FitsImage* ptr = parent->findFits(); + listSAOtngPre(str, strip); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + Vector vv = ptr->mapFromRef(center,Coord::IMAGE); + double rr = ptr->mapLenFromRef(annuli_[0][0],Coord::IMAGE); + str << type_ << '(' << setprecision(8) << vv << ',' << rr << ')'; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + double rr = ptr->mapLenFromRef(annuli_[0][0],Coord::IMAGE); + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' + << setprecision(10) << vv << ',' + << setprecision(8) << rr << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' + << ra << ',' << dec << ',' + << setprecision(8) << rr << ')'; + break; + } + } + } + + listSAOtngPost(str,strip); +} + +void Circle::listPros(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int strip) +{ + FitsImage* ptr = parent->findFits(); + + switch (sys) { + case Coord::IMAGE: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + sys = Coord::IMAGE; + case Coord::PHYSICAL: + { + Vector vv = ptr->mapFromRef(center,sys); + double rr = ptr->mapLenFromRef(annuli_[0][0],Coord::IMAGE); + coord.listProsCoordSystem(str,sys,sky); + str << "; " << type_ << ' ' << setprecision(8) << vv << ' ' << rr; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + double rr = ptr->mapLenFromRef(annuli_[0][0],sys,Coord::ARCSEC); + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + coord.listProsCoordSystem(str,sys,sky); + str << "; " << type_ << ' ' + << setprecision(10) << setunit('d') << vv << ' ' + << setprecision(3) << fixed << rr << '"'; + str.unsetf(ios_base::floatfield); + } + break; + case Coord::SEXAGESIMAL: + listRADECPros(ptr,center,sys,sky,format); + coord.listProsCoordSystem(str,sys,sky); + str << "; " << type_ << ' ' + << ra << ' ' << dec << ' ' + << setprecision(3) << fixed << rr << '"'; + str.unsetf(ios_base::floatfield); + break; + } + } + } + + listProsPost(str, strip); +} + +void Circle::listSAOimage(ostream& str, int strip) +{ + FitsImage* ptr = parent->findFits(); + listSAOimagePre(str); + + Vector vv = ptr->mapFromRef(center,Coord::IMAGE); + str << type_ << '(' << setprecision(8) << vv << ',' << annuli_[0][0] << ')'; + + listSAOimagePost(str, strip); +} + +// special composite funtionallity + +void Circle::setComposite(const Matrix& mx, double aa) +{ + center *= mx; + updateBBox(); +} + diff --git a/tksao/frame/circle.h b/tksao/frame/circle.h new file mode 100644 index 0000000..a8a3c28 --- /dev/null +++ b/tksao/frame/circle.h @@ -0,0 +1,47 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __circle_h__ +#define __circle_h__ + +#include "baseellipse.h" + +class Circle : public BaseEllipse { + protected: + void listNonCel(FitsImage*, ostream&, Coord::CoordSystem); + +public: + Circle(Base* p, const Vector& ctr, double r); + Circle(Base* p, const Vector& ctr, + double r, + const char* clr, int *dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + Circle(const Circle&); + + virtual Marker* dup() {return new Circle(*this);} + void edit(const Vector&, int); + + void rotateBegin() {} + void rotate(const Vector& v, int h) {} + void rotateEnd() {} + + void analysis(AnalysisTask, int); + void analysisHistogram(char*, char*, int); + void analysisPlot3d(char*, char*, Coord::CoordSystem, Marker::AnalysisMethod); + void analysisStats(Coord::CoordSystem, Coord::SkyFrame sky); + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + virtual void listCiao(ostream&, Coord::CoordSystem, int); + virtual void listSAOtng(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + virtual void listPros(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + virtual void listSAOimage(ostream&, int); + + // special composite funtionality + void setComposite(const Matrix&, double); +}; + +#endif diff --git a/tksao/frame/colorscale.C b/tksao/frame/colorscale.C new file mode 100644 index 0000000..8254a33 --- /dev/null +++ b/tksao/frame/colorscale.C @@ -0,0 +1,207 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "colorscale.h" + +ColorScale::ColorScale(int ss) +{ + size_ = ss; + psColors_ = new unsigned char[ss*3]; + memset(psColors_, '0', size_*3); +} + +ColorScale::~ColorScale() +{ + if (psColors_) + delete [] psColors_; +} + +LinearScale::LinearScale(int ss, unsigned char* colorCells, int count) + : ColorScale(ss) +{ + for (int ii=0; ii=count) + ll = count-1; + memcpy(psColors_+ii*3, colorCells+ll*3, 3); + } +} + +PowScale::PowScale(int ss, unsigned char* colorCells, int count, double exp) + : ColorScale(ss) +{ + for (int ii=0; ii=count) + ll = count-1; + memcpy(psColors_+ii*3, colorCells+ll*3, 3); + } +} + +SqrtScale::SqrtScale(int ss, unsigned char* colorCells, int count) + : ColorScale(ss) +{ + for(int ii=0; ii=count) + ll = count-1; + memcpy(psColors_+ii*3, colorCells+ll*3,3); + } +} + +SinhScale::SinhScale(int ss, unsigned char* colorCells, int count) + : ColorScale(ss) +{ + for(int ii=0; ii=count) + ll = count-1; + memcpy(psColors_+ii*3, colorCells+ll*3,3); + } +} + +HistEquScale::HistEquScale(int ss, unsigned char* colorCells, int count, + double* hist, int histsize) + : ColorScale(ss) +{ + // if no histogram, return linear distribution + if (!hist) + for (int ii=0; ii=count) + ll = count-1; + memcpy(psColors_+ii, colorCells+ll*3+jj,1); + } +} + +PowScaleRGB::PowScaleRGB(int jj, int ss, unsigned char* colorCells, + int count, double exp) + : ColorScaleRGB(ss) +{ + for (int ii=0; ii=count) + ll = count-1; + memcpy(psColors_+ii, colorCells+ll*3+jj,1); + } +} + +SqrtScaleRGB::SqrtScaleRGB(int jj, int ss, unsigned char* colorCells, int count) + : ColorScaleRGB(ss) +{ + for(int ii=0; ii0 ? ((r & rm_) << rs_) : ((r & rm_) >> -rs_); + a |= gs_>0 ? ((g & gm_) << gs_) : ((g & gm_) >> -gs_); + a |= bs_>0 ? ((b & bm_) << bs_) : ((b & bm_) >> -bs_); + + memcpy(colors_+i*2, &a, 2); + } + } + else { + for (int i=0; i0 ? ((r & rm_) << rs_) : ((r & rm_) >> -rs_); + a |= gs_>0 ? ((g & gm_) << gs_) : ((g & gm_) >> -gs_); + a |= bs_>0 ? ((b & bm_) << bs_) : ((b & bm_) >> -bs_); + + unsigned char* rr = (unsigned char*)(&a); + *(colors_+i*2) = *(rr+1); + *(colors_+i*2+1) = *(rr); + } + } +} + +ColorScaleTrueColor16::~ColorScaleTrueColor16() +{ + if (colors_) + delete [] colors_; +} + +LinearScaleTrueColor16::LinearScaleTrueColor16(int s, + unsigned char* colorCells, + int count, + Visual* visual, int msb) + : ColorScale(s), + LinearScale(s, colorCells, count), + ColorScaleTrueColor16(s, visual, msb) +{} + +LogScaleTrueColor16::LogScaleTrueColor16(int s, + unsigned char* colorCells, + int count, double exp, + Visual* visual, int msb) + : ColorScale(s), + LogScale(s, colorCells, count, exp), + ColorScaleTrueColor16(s, visual, msb) +{} + +PowScaleTrueColor16::PowScaleTrueColor16(int s, + unsigned char* colorCells, + int count, double exp, + Visual* visual, int msb) + : ColorScale(s), + PowScale(s, colorCells, count, exp), + ColorScaleTrueColor16(s, visual, msb) +{} + +SqrtScaleTrueColor16::SqrtScaleTrueColor16(int s, + unsigned char* colorCells, + int count, + Visual* visual, int msb) + : ColorScale(s), + SqrtScale(s, colorCells, count), + ColorScaleTrueColor16(s, visual, msb) +{} + +SquaredScaleTrueColor16::SquaredScaleTrueColor16(int s, + unsigned char* colorCells, + int count, + Visual* visual, int msb) + : ColorScale(s), + SquaredScale(s, colorCells, count), + ColorScaleTrueColor16(s, visual, msb) +{} + +AsinhScaleTrueColor16::AsinhScaleTrueColor16(int s, + unsigned char* colorCells, + int count, + Visual* visual, int msb) + : ColorScale(s), + AsinhScale(s, colorCells, count), + ColorScaleTrueColor16(s, visual, msb) +{} + +SinhScaleTrueColor16::SinhScaleTrueColor16(int s, + unsigned char* colorCells, + int count, + Visual* visual, int msb) + : ColorScale(s), + SinhScale(s, colorCells, count), + ColorScaleTrueColor16(s, visual, msb) +{} + +IISScaleTrueColor16::IISScaleTrueColor16(unsigned char* colorCells, + int count, + Visual* visual, int msb) + : ColorScale(IISSIZE), + IISScale(colorCells, count), + ColorScaleTrueColor16(IISSIZE, visual, msb) +{} + +HistEquScaleTrueColor16::HistEquScaleTrueColor16(int s, + unsigned char* colorCells, + int count, + double* hist, int histsize, + Visual* visual, int msb) + : ColorScale(s), + HistEquScale(s, colorCells, count, hist, histsize), + ColorScaleTrueColor16(s, visual, msb) +{} + diff --git a/tksao/frame/colorscaletrue16.h b/tksao/frame/colorscaletrue16.h new file mode 100644 index 0000000..5a4ed43 --- /dev/null +++ b/tksao/frame/colorscaletrue16.h @@ -0,0 +1,89 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __colorscaletrue16_h__ +#define __colorscaletrue16_h__ + +#include "colorscale.h" +#include "truecolor16.h" + +class ColorScaleTrueColor16 : public virtual ColorScale, public TrueColor16 { +public: + ColorScaleTrueColor16(int, Visual*, int); + virtual ~ColorScaleTrueColor16(); +}; + +class LinearScaleTrueColor16 : +public virtual ColorScale, +public LinearScale, +public ColorScaleTrueColor16 { +public: + LinearScaleTrueColor16(int, unsigned char*, int, Visual*, int); +}; + +class LogScaleTrueColor16 : +public virtual ColorScale, +public LogScale, +public ColorScaleTrueColor16 { +public: + LogScaleTrueColor16(int, unsigned char*, int, double, Visual*, int); +}; + +class PowScaleTrueColor16 : +public virtual ColorScale, +public PowScale, +public ColorScaleTrueColor16 { +public: + PowScaleTrueColor16(int, unsigned char*, int, double, Visual*, int); +}; + +class SqrtScaleTrueColor16 : +public virtual ColorScale, +public SqrtScale, +public ColorScaleTrueColor16 { +public: + SqrtScaleTrueColor16(int, unsigned char*, int, Visual*, int); +}; + +class SquaredScaleTrueColor16 : +public virtual ColorScale, +public SquaredScale, +public ColorScaleTrueColor16 { +public: + SquaredScaleTrueColor16(int, unsigned char*, int, Visual*, int); +}; + +class AsinhScaleTrueColor16 : +public virtual ColorScale, +public AsinhScale, +public ColorScaleTrueColor16 { +public: + AsinhScaleTrueColor16(int, unsigned char*, int, Visual*, int); +}; + +class SinhScaleTrueColor16 : +public virtual ColorScale, +public SinhScale, +public ColorScaleTrueColor16 { +public: + SinhScaleTrueColor16(int, unsigned char*, int, Visual*, int); +}; + +class IISScaleTrueColor16 : +public virtual ColorScale, +public IISScale, +public ColorScaleTrueColor16 { +public: + IISScaleTrueColor16(unsigned char*, int, Visual*, int); +}; + +class HistEquScaleTrueColor16 : +public virtual ColorScale, +public HistEquScale, +public ColorScaleTrueColor16 { +public: + HistEquScaleTrueColor16(int, unsigned char*, int, double*, int, Visual*, int); +}; + +#endif diff --git a/tksao/frame/colorscaletrue24.C b/tksao/frame/colorscaletrue24.C new file mode 100644 index 0000000..dd8cea4 --- /dev/null +++ b/tksao/frame/colorscaletrue24.C @@ -0,0 +1,129 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "colorscaletrue24.h" + +ColorScaleTrueColor24::ColorScaleTrueColor24(int s, Visual* visual, int msb) + : ColorScale(s), TrueColor24(visual) +{ + colors_ = new unsigned char[s*3]; + + // we need to check to byteswap when we have cross platforms + if ((!msb && lsb()) || (msb && !lsb())) { + for (int i=0; i> bs_) | // blue + ((psColors_[i*3+1] & gm_) >> gs_) | // green + ((psColors_[i*3+2] & rm_) >> rs_); // red +} + +ColorScaleTrueColor8::~ColorScaleTrueColor8() +{ + if (colors_) + delete [] colors_; +} + +LinearScaleTrueColor8::LinearScaleTrueColor8(int s, + unsigned char* colorCells, + int count, + Visual* visual) + : ColorScale(s), + LinearScale(s, colorCells, count), + ColorScaleTrueColor8(s, visual) +{} + +LogScaleTrueColor8::LogScaleTrueColor8(int s, + unsigned char* colorCells, + int count, double exp, + Visual* visual) + : ColorScale(s), + LogScale(s, colorCells, count, exp), + ColorScaleTrueColor8(s, visual) +{} + + +PowScaleTrueColor8::PowScaleTrueColor8(int s, + unsigned char* colorCells, + int count, double exp, + Visual* visual) + : ColorScale(s), + PowScale(s, colorCells, count, exp), + ColorScaleTrueColor8(s, visual) +{} + +SqrtScaleTrueColor8::SqrtScaleTrueColor8(int s, + unsigned char* colorCells, + int count, + Visual* visual) + : ColorScale(s), + SqrtScale(s, colorCells, count), + ColorScaleTrueColor8(s, visual) +{} + +SquaredScaleTrueColor8::SquaredScaleTrueColor8(int s, + unsigned char* colorCells, + int count, + Visual* visual) + : ColorScale(s), + SquaredScale(s, colorCells, count), + ColorScaleTrueColor8(s, visual) +{} + +AsinhScaleTrueColor8::AsinhScaleTrueColor8(int s, + unsigned char* colorCells, + int count, + Visual* visual) + : ColorScale(s), + AsinhScale(s, colorCells, count), + ColorScaleTrueColor8(s, visual) +{} + +SinhScaleTrueColor8::SinhScaleTrueColor8(int s, + unsigned char* colorCells, + int count, + Visual* visual) + : ColorScale(s), + SinhScale(s, colorCells, count), + ColorScaleTrueColor8(s, visual) +{} + +IISScaleTrueColor8::IISScaleTrueColor8(unsigned char* colorCells, + int count, + Visual* visual) + : ColorScale(IISSIZE), + IISScale(colorCells, count), + ColorScaleTrueColor8(IISSIZE, visual) +{} + +HistEquScaleTrueColor8::HistEquScaleTrueColor8(int s, + unsigned char* colorCells, + int count, + double* hist, int histsize, + Visual* visual) + : ColorScale(s), + HistEquScale(s, colorCells, count, hist, histsize), + ColorScaleTrueColor8(s, visual) +{} + + + diff --git a/tksao/frame/colorscaletrue8.h b/tksao/frame/colorscaletrue8.h new file mode 100644 index 0000000..6a5e8c0 --- /dev/null +++ b/tksao/frame/colorscaletrue8.h @@ -0,0 +1,89 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __colorscaletrue8_h__ +#define __colorscaletrue8_h__ + +#include "colorscale.h" +#include "truecolor8.h" + +class ColorScaleTrueColor8 : public virtual ColorScale, public TrueColor8 { +public: + ColorScaleTrueColor8(int, Visual*); + virtual ~ColorScaleTrueColor8(); +}; + +class LinearScaleTrueColor8 : +public virtual ColorScale, +public LinearScale, +public ColorScaleTrueColor8 { +public: + LinearScaleTrueColor8(int, unsigned char*, int, Visual*); +}; + +class LogScaleTrueColor8 : +public virtual ColorScale, +public LogScale, +public ColorScaleTrueColor8 { +public: + LogScaleTrueColor8(int, unsigned char*, int, double, Visual*); +}; + +class PowScaleTrueColor8 : +public virtual ColorScale, +public PowScale, +public ColorScaleTrueColor8 { +public: + PowScaleTrueColor8(int, unsigned char*, int, double, Visual*); +}; + +class SqrtScaleTrueColor8 : +public virtual ColorScale, +public SqrtScale, +public ColorScaleTrueColor8 { +public: + SqrtScaleTrueColor8(int, unsigned char*, int, Visual*); +}; + +class SquaredScaleTrueColor8 : +public virtual ColorScale, +public SquaredScale, +public ColorScaleTrueColor8 { +public: + SquaredScaleTrueColor8(int, unsigned char*, int, Visual*); +}; + +class AsinhScaleTrueColor8 : +public virtual ColorScale, +public AsinhScale, +public ColorScaleTrueColor8 { +public: + AsinhScaleTrueColor8(int, unsigned char*, int, Visual*); +}; + +class SinhScaleTrueColor8 : +public virtual ColorScale, +public SinhScale, +public ColorScaleTrueColor8 { +public: + SinhScaleTrueColor8(int, unsigned char*, int, Visual*); +}; + +class IISScaleTrueColor8 : +public virtual ColorScale, +public IISScale, +public ColorScaleTrueColor8 { +public: + IISScaleTrueColor8(unsigned char*, int, Visual*); +}; + +class HistEquScaleTrueColor8 : +public virtual ColorScale, +public HistEquScale, +public ColorScaleTrueColor8 { +public: + HistEquScaleTrueColor8(int, unsigned char*, int, double*, int, Visual*); +}; + +#endif diff --git a/tksao/frame/compass.C b/tksao/frame/compass.C new file mode 100644 index 0000000..23c0fee --- /dev/null +++ b/tksao/frame/compass.C @@ -0,0 +1,645 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "compass.h" +#include "fitsimage.h" + +Compass::Compass(const Compass& a) : Marker(a) +{ + p1 = a.p1; + p2 = a.p2; + pp1 = a.pp1; + pp2 = a.pp2; + radius = a.radius; + coordSystem = a.coordSystem; + skyFrame = a.skyFrame; + northText = dupstr(a.northText); + eastText = dupstr(a.eastText); + northArrow = a.northArrow; + eastArrow = a.eastArrow; +} + +Compass::Compass(Base* p, const Vector& ctr, + double r, + const char* n, const char* e, int na, int ea, + Coord::CoordSystem sys, Coord::SkyFrame sky, + const char* clr, int* dsh, + int w, const char* f, const char* t, + unsigned short prop, const char* c, + const List& tag, const List& cb) + : Marker(p, ctr, 0, clr, dsh, w, f, t, prop, c, tag, cb) +{ + coordSystem = sys; + skyFrame = sky; + radius = r; + + northText = dupstr(n); + eastText = dupstr(e); + northArrow = na; + eastArrow = ea; + + strcpy(type_,"compass"); + handle = new Vector[3]; + numHandle = 3; + + updateBBox(); +} + +Compass::~Compass() +{ + if (northText) + delete [] northText; + + if (eastText) + delete [] eastText; +} + +void Compass::renderX(Drawable drawable, Coord::InternalSystem sys, RenderMode mode) +{ + GC lgc = renderXGC(mode); + + Vector aa = parent->mapFromRef(center,sys); + Vector bb = parent->mapFromRef(p1,sys); + Vector cc = parent->mapFromRef(p2,sys); + Vector dd = parent->mapFromRef(pp1,sys); + Vector ee = parent->mapFromRef(pp2,sys); + + if (northArrow) { + bb = modifyArrow(center,p1,sys); + renderXArrow(drawable, center, p1, sys, lgc); + } + + if (eastArrow) { + cc = modifyArrow(center,p2,sys); + renderXArrow(drawable, center, p2, sys, lgc); + } + + XDrawLine(display, drawable, lgc, aa[0], aa[1], bb[0], bb[1]); + XDrawLine(display, drawable, lgc, aa[0], aa[1], cc[0], cc[1]); + + if (tkfont_) { + XSetFont(display, lgc, Tk_FontId(tkfont_)); + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(tkfont_, &metrics); + + if (northText) { + float r1 = Tk_TextWidth(tkfont_, northText, strlen(northText))/2.; + float r2 = metrics.linespace/2.; + double angle = (bb-aa).angle(); + + Vector ddd = dd * + Translate(r1*cos(angle),r2*sin(angle)) * + Translate(-r1,(metrics.ascent-metrics.descent)/2.); + + Tk_DrawChars(display, drawable, lgc, tkfont_, northText, + strlen(northText), ddd[0], ddd[1]); + } + + if (eastText) { + float r1 = Tk_TextWidth(tkfont_, eastText, strlen(eastText))/2.; + float r2 = metrics.linespace/2.; + double angle = (cc-aa).angle(); + Vector eee = ee * + Translate(r1*cos(angle),r2*sin(angle)) * + Translate(-r1,(metrics.ascent-metrics.descent)/2.); + + Tk_DrawChars(display, drawable, lgc, tkfont_, eastText, + strlen(eastText), eee[0], eee[1]); + } + } +} + +GC Compass::renderXGC(RenderMode mode) +{ + switch (mode) { + case SRC: + XSetForeground(display, gc, color); + renderXLineNoDash(gc); + return gc; + + case XOR: + renderXLineDash(gcxor); + return gcxor; + } + + // so compiler will not complain + return gc; +} + +void Compass::renderPS(int mode) +{ + renderPSGC(mode); + + Vector aa = parent->mapFromRef(center,Coord::CANVAS); + Vector bb = parent->mapFromRef(p1,Coord::CANVAS); + Vector cc = parent->mapFromRef(p2,Coord::CANVAS); + Vector dd = parent->mapFromRef(pp1,Coord::CANVAS); + Vector ee = parent->mapFromRef(pp2,Coord::CANVAS); + + if (northArrow) { + bb = modifyArrow(center,p1,Coord::CANVAS); + renderPSArrow(center,p1,Coord::CANVAS); + } + + if (eastArrow) { + cc = modifyArrow(center,p2,Coord::CANVAS); + renderPSArrow(center,p2,Coord::CANVAS); + } + + { + ostringstream str; + str << "newpath " + << aa.TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << bb.TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl + << "newpath " + << aa.TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << cc.TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } + + if (psfont_) { + ostringstream str; + + const char* ff = Tk_NameOfFont(psfont_); + str << '/' << psFontName(ff) + << " findfont " << int(psFontSize(ff)*parent->getDisplayRatio()) + << " scalefont setfont" << endl; + + if (northText) { + double angle = (bb-aa).angle(); + Vector ddd = dd.TkCanvasPs(parent->canvas); + str << "gsave" << endl + << "newpath " << endl + << ddd << " moveto" << endl + << '(' << psQuote(northText) << ')' << endl + // bbox + << "dup true charpath pathbbox " << endl + << "closepath " << endl + // text llx lly urx ury + + // dup bbox + << "3 index 3 index 3 index 3 index " << endl + // text llx lly urx ury llx lly urx ury + + // Translate(-r1,(metrics.ascent-metrics.descent)/2.) + << "3 -1 roll sub 3.6 div neg " << endl + << "3 1 roll sub 2 div exch " << endl + // text llx lly urx ury Sx Sy + + // reorder + << "6 1 roll 6 1 roll " << endl + // text Sx Sy llx lly urx ury + + // Translate(r1*cos(angle),r2*sin(angle)) + << "3 -1 roll sub 2 div neg " << endl + << "3 1 roll sub 2 div exch " << endl + << radToDeg(angle) << " sin mul exch " << endl + << radToDeg(angle) << " cos mul neg exch " << endl + // text Sx Sy Tx Ty + + // add + << "3 -1 roll add " << endl + << "3 1 roll add exch " << endl + // text Fx Fy + + << ddd << " moveto rmoveto show " << endl + << "grestore" << endl; + } + + if (eastText) { + double angle = (cc-aa).angle(); + Vector eee = ee.TkCanvasPs(parent->canvas); + str << "gsave" << endl + << "newpath " << endl + << eee << " moveto" << endl + << '(' << psQuote(eastText) << ')' << endl + << "dup true charpath pathbbox " + << "closepath " << endl + + << "3 index 3 index 3 index 3 index " << endl + + << "3 -1 roll sub 3.6 div neg " + << "3 1 roll sub 2 div exch " << endl + + << "6 1 roll 6 1 roll " << endl + + << "3 -1 roll sub 2 div neg " + << "3 1 roll sub 2 div exch " << endl + << radToDeg(angle) << " sin mul exch " + << radToDeg(angle) << " cos mul neg exch " << endl + + << "3 -1 roll add " + << "3 1 roll add exch " << endl + + << eee << " moveto rmoveto show " << endl + << "grestore" << endl; + } + + str << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } +} + +void Compass::renderPSGC(int mode) +{ + renderPSColor(mode, parent->getXColor(colorName)); + renderPSLineNoDash(); +} + +#ifdef MAC_OSX_TK +void Compass::renderMACOSX() +{ + renderMACOSXGC(); + + Vector aa = parent->mapFromRef(center,Coord::CANVAS); + Vector bb = parent->mapFromRef(p1,Coord::CANVAS); + Vector cc = parent->mapFromRef(p2,Coord::CANVAS); + Vector dd = parent->mapFromRef(pp1,Coord::CANVAS); + Vector ee = parent->mapFromRef(pp2,Coord::CANVAS); + + if (northArrow) { + bb = modifyArrow(center,p1,Coord::CANVAS); + renderMACOSXArrow(center,p1,Coord::CANVAS); + } + + if (eastArrow) { + cc = modifyArrow(center,p2,Coord::CANVAS); + renderMACOSXArrow(center,p2,Coord::CANVAS); + } + + macosxDrawLine(aa,bb); + macosxDrawLine(aa,cc); + + if (psfont_) { + Tcl_DString psdstr; + Tcl_DStringInit(&psdstr); + int psSize = Tk_PostscriptFontName(psfont_, &psdstr); + macosxFont(Tcl_DStringValue(&psdstr), psSize); + Tcl_DStringFree(&psdstr); + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(psfont_, &metrics); + + if (northText) { + float r1 = Tk_TextWidth(psfont_, northText, strlen(northText))/2.; + float r2 = metrics.linespace/2.; + double angle = (bb-aa).angle(); + Vector ddd = dd * + Translate(r1*cos(angle),r2*sin(angle)) * + Translate(-r1,(metrics.ascent-metrics.descent)/2.); + + macosxDrawText(ddd, 0, northText); + } + + if (eastText) { + float r1 = Tk_TextWidth(psfont_, eastText, strlen(eastText))/2.; + float r2 = metrics.linespace/2.; + double angle = (cc-aa).angle(); + Vector eee = ee * + Translate(r1*cos(angle),r2*sin(angle)) * + Translate(-r1,(metrics.ascent-metrics.descent)/2.); + + macosxDrawText(eee, 0, eastText); + } + } +} + +void Compass::renderMACOSXGC() +{ + macosxColor(parent->getXColor(colorName)); + renderMACOSXLineNoDash(); +} +#endif + +#ifdef __WIN32 +void Compass::renderWIN32() +{ + renderWIN32GC(); + + Vector aa = parent->mapFromRef(center,Coord::CANVAS); + Vector bb = parent->mapFromRef(p1,Coord::CANVAS); + Vector cc = parent->mapFromRef(p2,Coord::CANVAS); + Vector dd = parent->mapFromRef(pp1,Coord::CANVAS); + Vector ee = parent->mapFromRef(pp2,Coord::CANVAS); + + if (northArrow) { + bb = modifyArrow(center,p1,Coord::CANVAS); + renderWIN32Arrow(center,p1,Coord::CANVAS); + } + + if (eastArrow) { + cc = modifyArrow(center,p2,Coord::CANVAS); + renderWIN32Arrow(center,p2,Coord::CANVAS); + } + + win32DrawLine(aa,bb); + win32DrawLine(aa,cc); + + if (tkfont_) { + win32Font(tkfont_); + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(tkfont_, &metrics); + + if (northText) { + float r1 = Tk_TextWidth(tkfont_, northText, strlen(northText))/2.; + float r2 = metrics.linespace/2.; + double angle = (bb-aa).angle(); + Vector ddd = dd * + Translate(r1*cos(angle),r2*sin(angle)) * + Translate(-r1,(metrics.ascent-metrics.descent)/2.); + + win32DrawText(ddd, 0, northText); + } + + if (eastText) { + float r1 = Tk_TextWidth(tkfont_, eastText, strlen(eastText))/2.; + float r2 = metrics.linespace/2.; + double angle = (cc-aa).angle(); + Vector eee = ee * + Translate(r1*cos(angle),r2*sin(angle)) * + Translate(-r1,(metrics.ascent-metrics.descent)/2.); + + win32DrawText(eee, 0, eastText); + } + } +} + +void Compass::renderWIN32GC() +{ + win32Color(parent->getXColor(colorName)); + renderWIN32LineNoDash(); +} +#endif + +void Compass::updateHandles() +{ + // calc p1, p2 + FitsImage* ptr = parent->findFits(coordSystem,center); + Vector orval = ptr->mapFromRef(center, coordSystem, skyFrame); + double delta = ptr->mapLenFromRef(1, coordSystem); + Vector npix = ptr->mapToRef(Vector(orval[0],orval[1]+delta), + coordSystem, skyFrame); + Vector epix = ptr->mapToRef(Vector(orval[0]+delta,orval[1]), + coordSystem, skyFrame); + Vector north = (npix - center).normalize(); + Vector east = (epix - center).normalize(); + + // calc text points pp1,pp2 + Matrix r = Scale(radius)*Scale(parent->zoom()).invert(); + Matrix rr = Scale(5)*Scale(parent->zoom()).invert(); + p1 = center + north*r; + p2 = center + east*r; + pp1 = p1 + north*rr; + pp2 = p2 + east*rr; + + // generate handles + handle[0] = parent->mapFromRef(center,Coord::CANVAS); + handle[1] = parent->mapFromRef(p1,Coord::CANVAS); + handle[2] = parent->mapFromRef(p2,Coord::CANVAS); +} + +void Compass::calcAllBBox() +{ + if (tkfont_) { + // make room for text + Tk_FontMetrics metrics; + Tk_GetFontMetrics(tkfont_, &metrics); + + Vector a = parent->mapFromRef(center,Coord::CANVAS); + Vector b = parent->mapFromRef(p1,Coord::CANVAS); + Vector c = parent->mapFromRef(p2,Coord::CANVAS); + Vector bb = parent->mapFromRef(pp1,Coord::CANVAS); + Vector cc = parent->mapFromRef(pp2,Coord::CANVAS); + + if (northText) { + float r1 = Tk_TextWidth(tkfont_, northText, strlen(northText))/2.; + float r2 = metrics.linespace/2.; + double angle = (b-a).angle(); + + Vector bbb = bb * Translate(r1*cos(angle),r2*sin(angle)); + + bbox.bound(bbb * Translate(-r1,(metrics.ascent-metrics.descent)/2.)); + bbox.bound(bbb * Translate(-r1,-metrics.ascent/2.-3*metrics.descent/2.)); + bbox.bound(bbb * Translate(r1,(metrics.ascent-metrics.descent)/2.)); + bbox.bound(bbb * Translate(r1,-metrics.ascent/2.-3*metrics.descent/2.)); + } + + if (eastText) { + float r1 = Tk_TextWidth(tkfont_, eastText, strlen(eastText))/2.; + float r2 = metrics.linespace/2.; + double angle = (c-a).angle(); + + Vector ccc = cc * Translate(r1*cos(angle),r2*sin(angle)); + + bbox.bound(ccc * Translate(-r1,(metrics.ascent-metrics.descent)/2.)); + bbox.bound(ccc * Translate(-r1,-metrics.ascent/2.-3*metrics.descent/2.)); + bbox.bound(ccc * Translate(r1,(metrics.ascent-metrics.descent)/2.)); + bbox.bound(ccc * Translate(r1,-metrics.ascent/2.-3*metrics.descent/2.)); + } + } + + Marker::calcAllBBox(); +} + +void Compass::edit(const Vector& v, int h) +{ + radius = (v * Translate(-center) * Scale(parent->zoom())).length(); + + updateBBox(); + doCallBack(CallBack::EDITCB); +} + +int Compass::isIn(const Vector& vv) +{ + /* + v[0]-- x value of point being tested + v[1]-- y value of point being tested + + This algorithm is from "An Introduction to Ray Tracing", Academic Press, + 1989, edited by Andrew Glassner, pg 53 + -- a point lies in a polygon if a line is extended from the point to + infinite in any direction and the number of intersections with the + polygon is odd. + This is valid for both concave and convex polygons. + Points on a vertex are considered inside. + Points on a edge are considered inside. + */ + + Vector v = parent->mapToRef(vv,Coord::CANVAS); + int crossings = 0; // number of crossings + + Vector bb[4]; + bb[0] = center - v; + bb[1] = p1 - v; + bb[2] = p2 - v; + bb[3] = bb[0]; + + Vector v1; + Vector v2 = bb[0]; + + int sign = ((v2[1])>=0) ? 1 : -1; // init sign + + // for all edges + + for (int j=1; j<4; j++) { + // look at next two vertices + v1 = v2; + v2 = bb[j]; + + int nextSign = (v2[1]>=0) ? 1 : -1; // sign holder for p2 + + if (sign != nextSign) { + if (v1[0]>0 && v2[0]>0) + crossings++; + else if (v1[0]>0 || v2[0]>0) { + if (v1[0]-(v1[1]*(v2[0]-v1[0])/(v2[1]-v1[1])) > 0) + crossings++; + } + sign = nextSign; + } + } + + return fmod(float(crossings),float(2)) ? 1 : 0; // if odd, point is inside +} + +void Compass::setRadius(double r) +{ + radius = r; + + updateBBox(); + doCallBack(CallBack::EDITCB); +} + +void Compass::setArrows(int n, int e) +{ + northArrow = n; + eastArrow = e; + + updateBBox(); + doCallBack(CallBack::EDITCB); +} + +void Compass::setLabels(const char* n, const char* e) +{ + northText = dupstr(n); + eastText = dupstr(e); + + updateBBox(); + doCallBack(CallBack::EDITCB); +} + +void Compass::setCoordSystem(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + coordSystem = sys; + skyFrame = sky; + + updateBBox(); +} + +// list + +void Compass::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + if (!strip) { + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 1); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listNonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + double rr = ptr->mapLenFromRef(radius,sys,Coord::ARCSEC); + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' << setprecision(10) << vv << ',' + << setprecision(3) << fixed << rr << '"' << ')'; + str.unsetf(ios_base::floatfield); + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' << ra << ',' << dec << ',' + << setprecision(3) << fixed << rr << '"' << ')'; + str.unsetf(ios_base::floatfield); + break; + } + } + else + listNonCel(ptr, str, sys); + } + + if (conj) + str << " ||"; + + str << " compass="; + coord.listCoordSystem(str, coordSystem, skyFrame, ptr); + str << " {" << northText << "} {" << eastText << "} " + << northArrow << ' ' << eastArrow; + listProperties(str, 0); + } +} + +void Compass::listNonCel(FitsImage* ptr, ostream& str, Coord::CoordSystem sys) +{ + Vector vv = ptr->mapFromRef(center,sys); + double rr = ptr->mapLenFromRef(radius,sys); + str << type_ << '(' << setprecision(8) << vv << ',' << rr << ')'; +} + +void Compass::listXML(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format) +{ + FitsImage* ptr = parent->findFits(sys,center); + + double rr = ptr->mapLenFromRef(radius,sys,Coord::ARCSEC); + ostringstream pstr; + coord.listCoordSystem(pstr, coordSystem, skyFrame, ptr); + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowCenter(ptr,sys,sky,format); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + XMLRow(XMLR,rr,8); + break; + default: + if (ptr->hasWCS(sys)) { + if (ptr->hasWCSCel(sys)) + XMLRowARCSEC(XMLR,rr); + else + XMLRow(XMLR,rr,8); + } + break; + } + + XMLRow(XMLPARAM,(char*)(pstr.str().c_str())); + XMLRow(XMLPARAM2,northText); + XMLRow(XMLPARAM3,eastText); + XMLRow(XMLPARAM4,northArrow); + XMLRow(XMLPARAM5,eastArrow); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} diff --git a/tksao/frame/compass.h b/tksao/frame/compass.h new file mode 100644 index 0000000..129d2a9 --- /dev/null +++ b/tksao/frame/compass.h @@ -0,0 +1,90 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __compass_h__ +#define __compass_h__ + +#include "marker.h" + +class Compass : public Marker { +private: + Vector p1; + Vector p2; + Vector pp1; + Vector pp2; + + double radius; + Coord::CoordSystem coordSystem; + Coord::SkyFrame skyFrame; + + char* northText; + char* eastText; + int northArrow; + int eastArrow; + +private: + void renderX(Drawable, Coord::InternalSystem, RenderMode); + void renderXInclude(Drawable, Coord::InternalSystem, RenderMode) {} + GC renderXGC(RenderMode); + + void renderPS(int); + void renderPSInclude(int) {} + void renderPSGC(int); + +#ifdef MAC_OSX_TK + void renderMACOSX(); + void renderMACOSXInclude() {} + void renderMACOSXGC(); +#endif + +#ifdef __WIN32 + void renderWIN32(); + void renderWIN32Include() {} + void renderWIN32GC(); +#endif + +void updateHandles(); + + protected: + void listNonCel(FitsImage*, ostream&, Coord::CoordSystem); + +public: + Compass(const Compass&); + Compass(Base* parent, const Vector& ctr, + double r, + const char* n, const char* e, int na, int ea, + Coord::CoordSystem, Coord::SkyFrame, + const char* clr, int* dsh, + int w, const char* f, const char* t, + unsigned short prop, const char* c, + const List& tag, const List& cb); + ~Compass(); + + Marker* dup() {return new Compass(*this);} + void calcAllBBox(); + void edit(const Vector&, int); + + void rotateBegin() {} + void rotate(const Vector& v, int h) {} + void rotateEnd() {} + + int isIn(const Vector&); + + double getRadius() {return radius;} + void setRadius(double); + void setCoordSystem(Coord::CoordSystem, Coord::SkyFrame); + void setLabels(const char*, const char*); + void setArrows(int,int); + Coord::CoordSystem getSystem() {return coordSystem;} + Coord::SkyFrame getSkyFrame() {return skyFrame;} + const char* getNorthText() {return northText;} + const char* getEastText() {return eastText;} + int getNorthArrow() {return northArrow;} + int getEastArrow() {return eastArrow;} + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); +}; + +#endif diff --git a/tksao/frame/composite.C b/tksao/frame/composite.C new file mode 100644 index 0000000..b5e5a6c --- /dev/null +++ b/tksao/frame/composite.C @@ -0,0 +1,317 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "composite.h" +#include "fitsimage.h" + +Composite::Composite(const Composite& a) : Marker(a) +{ + members = a.members; + global = a.global; +} + +Composite::Composite(Base* p, const Vector& ctr, + double ang, int gl, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : Marker(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + strcpy(type_, "composite"); + + global = gl; + + handle = new Vector[4]; + numHandle = 4; + + updateBBox(); +} + +void Composite::x11(Drawable drawable, Coord::InternalSystem sys, + int tt, RenderMode mode, HandleMode hh) +{ + if (properties & HIDDEN) + return; + + if (hh==HANDLES) + renderXHandles(drawable); + if (tt) + renderXText(drawable, sys, mode); + + Marker* mk=members.head(); + while (mk) { + Marker* m = mk->dup(); + m->setComposite(fwdMatrix(), angle); + if (global) + m->setComposite(colorName, lineWidth, highlited); + m->x11(drawable, sys, tt, mode, hh); + delete m; + mk=mk->next(); + } +} + +void Composite::ps(int mode, int tt) +{ + if (tt) + renderPSText(mode); + + Marker* mk=members.head(); + while (mk) { + Marker* m = mk->dup(); + m->setComposite(fwdMatrix(), angle); + if (global) + m->setComposite(colorName, lineWidth, highlited); + m->ps(mode,tt); + delete m; + mk=mk->next(); + } +} + +#ifdef MAC_OSX_TK +void Composite::macosx(int tt) +{ + if (tt) + renderMACOSXText(); + + Marker* mk=members.head(); + while (mk) { + Marker* m = mk->dup(); + m->setComposite(fwdMatrix(), angle); + if (global) + m->setComposite(colorName, lineWidth, highlited); + m->macosx(tt); + delete m; + mk=mk->next(); + } +} +#endif + +#ifdef __WIN32 +void Composite::win32(int tt) +{ + if (tt) + renderWIN32Text(); + + Marker* mk=members.head(); + while (mk) { + Marker* m = mk->dup(); + m->setComposite(fwdMatrix(), angle); + if (global) + m->setComposite(colorName, lineWidth, highlited); + m->win32(tt); + delete m; + mk=mk->next(); + } +} +#endif + +// Support + +void Composite::updateHandles() +{ + BBox bb(center * bckMatrix()); + Marker* mk=members.head(); + while (mk) { + Marker* m = mk->dup(); + m->setComposite(fwdMatrix(), angle); + for(int ii=0; iigetNumHandle(); ii++) + bb.bound(bckMap(m->getHandle(ii),Coord::CANVAS)); + delete m; + mk=mk->next(); + } + bb.expand(3); // a little more room around the edges + + handle[0] = fwdMap(bb.ll,Coord::CANVAS); + handle[1] = fwdMap(bb.lr(),Coord::CANVAS); + handle[2] = fwdMap(bb.ur,Coord::CANVAS); + handle[3] = fwdMap(bb.ul(),Coord::CANVAS); +} + +void Composite::updateCoords(const Matrix& mx) +{ + Marker* mk=members.head(); + while (mk) { + Vector cc = center; + mk->setComposite(fwdMatrix(), angle); + mk->updateCoords(mx); + center = cc*mx; + mk->setComposite(bckMatrix(), -angle); + center = cc; + mk=mk->next(); + } + + Marker::updateCoords(mx); +} + +int Composite::isIn(const Vector& v) +{ + if (!bbox.isIn(v)) + return 0; + + Marker* mk=members.head(); + while (mk) { + Marker* m = mk->dup(); + m->setComposite(fwdMatrix(), angle); + if (m->isIn(v)) { + delete m; + return 1; + } + delete m; + + mk=mk->next(); + } + + return 0; +} + +void Composite::append(Marker* m) +{ + m->setComposite(bckMatrix(), -angle); + members.append(m); +} + +Marker* Composite::extract() +{ + Marker* mk=members.head(); + if (mk) { + members.extractNext(mk); + mk->setComposite(fwdMatrix(), angle); + } + return mk; +} + +// list + +void Composite::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + if (!strip) { + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 1); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + Vector vv = ptr->mapFromRef(center,sys); + str << type_ << '(' << setprecision(8) << vv<< ',' + << radToDeg(parent->mapAngleFromRef(angle,sys)) << ')'; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' << setprecision(8) << vv << ',' + << radToDeg(parent->mapAngleFromRef(angle,sys,sky)) << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' << ra << ',' << dec << ',' + << radToDeg(parent->mapAngleFromRef(angle,sys,sky)) << ')'; + break; + } + } + else { + Vector vv = ptr->mapFromRef(center,sys); + str << type_ << '(' << setprecision(8) << vv << ',' + << radToDeg(parent->mapAngleFromRef(angle,sys)) << ')'; + } + } + + str << " ||"; + str << " composite=" << global; + listProperties(str, 0); + } + + Marker* mk=members.head(); + while (mk) { + Marker* m = mk->dup(); + mk=mk->next(); + + m->setComposite(fwdMatrix(), angle); + m->list(str, sys, sky, format, (mk?1:0), strip); + delete m; + } +} + +void Composite::listCiao(ostream& str, Coord::CoordSystem sys, int strip) +{ + Marker* mk=members.head(); + while (mk) { + Marker* m = mk->dup(); + mk=mk->next(); + + m->setComposite(fwdMatrix(), angle); + m->listCiao(str, sys, strip); + delete m; + } +} + +void Composite::listPros(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + int strip) +{ + Marker* mk=members.head(); + while (mk) { + Marker* m = mk->dup(); + m->setComposite(fwdMatrix(), angle); + m->listPros(str, sys, sky, format, strip); + delete m; + + mk=mk->next(); + } +} + +void Composite::listSAOtng(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + int strip) +{ + Marker* mk=members.head(); + while (mk) { + Marker* m = mk->dup(); + m->setComposite(fwdMatrix(), angle); + m->listSAOtng(str, sys, sky, format, strip); + delete m; + + mk=mk->next(); + } +} + +void Composite::listSAOimage(ostream& str, int strip) +{ + Marker* mk=members.head(); + while (mk) { + Marker* m = mk->dup(); + m->setComposite(fwdMatrix(), angle); + m->listSAOimage(str, strip); + delete m; + + mk=mk->next(); + } +} + +void Composite::listXY(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + int strip) +{ + Marker* mk=members.head(); + while (mk) { + Marker* m = mk->dup(); + m->setComposite(fwdMatrix(), angle); + m->listXY(str, sys, sky, format, strip); + delete m; + + mk=mk->next(); + } +} + diff --git a/tksao/frame/composite.h b/tksao/frame/composite.h new file mode 100644 index 0000000..aa4e4f8 --- /dev/null +++ b/tksao/frame/composite.h @@ -0,0 +1,67 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __composite_h__ +#define __composite_h__ + +#include "marker.h" +#include "list.h" + +class Composite : public Marker { + private: + List members; + int global; + + void renderX(Drawable, Coord::InternalSystem, RenderMode) {} + void renderPS(int mode) {} +#ifdef MAC_OSX_TK + void renderMACOSX() {} +#endif +#ifdef __WIN32 + void renderWIN32() {} +#endif + +protected: + void updateHandles(); + +public: + Composite(const Composite&); + Composite(Base* p, const Vector& ctr, + double ang, int gl, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + + Marker* dup() {return new Composite(*this);} + + void x11(Drawable, Coord::InternalSystem, int, RenderMode, HandleMode); + void ps(int,int); +#ifdef MAC_OSX_TK + void macosx(int); +#endif +#ifdef __WIN32 + void win32(int); +#endif + + void updateCoords(const Matrix&); + int isIn(const Vector& v); + + void append(Marker*); + Marker* extract(); + + void setGlobal(int w) {global = w ? 1 : 0;} + int getGlobal() {return global;} + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat) {} + void listCiao(ostream&, Coord::CoordSystem, int); + void listSAOtng(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + void listSAOimage(ostream&, int); + void listPros(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + void listXY(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + +}; + +#endif diff --git a/tksao/frame/context.C b/tksao/frame/context.C new file mode 100644 index 0000000..b21ca09 --- /dev/null +++ b/tksao/frame/context.C @@ -0,0 +1,3178 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "context.h" +#include "fitsimage.h" +#include "fvcontour.h" + +#include "alloc.h" +#include "allocgz.h" +#include "channel.h" +#include "colorscale.h" +#include "mmap.h" +#include "mmapincr.h" +#include "share.h" +#include "sshare.h" +#include "socket.h" +#include "socketgz.h" +#include "var.h" + +#include "head.h" + +extern "C" { +#include "tkbltVector.h" +} + +// Contour Parser Stuff +#undef yyFlexLexer +#define yyFlexLexer ctFlexLexer +#include + +void* ctlval; +ctFlexLexer* ctlexx; +extern int ctparse(Base*, ctFlexLexer*); + +int ctlex(void* vval, ctFlexLexer* ll) +{ + ctlval = vval; + ctlexx = ll; + return ll ? ll->yylex() : 0; +} + +void cterror(Base* ct, ctFlexLexer* ll, const char* m) +{ + ct->error(m); + const char* cmd = ll ? ll->YYText() : (const char*)NULL; + if (cmd && cmd[0] != '\n') { + ct->error(": "); + ct->error(cmd); + } +} + +typedef struct { + char* dest; + char** sjv; + int ww; + int hh; + int dd; + int bz; + int mm; +} t_reorder_arg; + +ostream& operator<<(ostream& ss, const FitsZBound& bb) +{ + ss << bb.zmin << ' ' << bb.zmax; + return ss; +} + +Context::Context() +{ + parent_ = NULL; + + bfits_ =NULL; + fits =NULL; + cfits =NULL; + + shareWCS_ =0; + + manageAxes_ =0; + axesOrder_ =123; + + loadInit(0, Base::NOMOSAIC, Coord::WCS); + + binFunction_ = FitsHist::SUM; + binFactor_ = Vector(1,1); + binBufferSize_ = 1024; + binDepth_ = 1; + + blockFactor_ = Vector(1,1); + + doSmooth_ =0; + smoothFunction_ =GAUSSIAN; + smoothRadius_ =3; + +#ifndef __WIN32 + thread_ =NULL; +#endif +} + +Context::~Context() +{ +} + +#ifdef __WIN32 + +void Context::analysis() +{ + if (DebugPerf) + cerr << "Context::analysis()" << endl; + + FitsImage* ptr = fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->analysis(doSmooth_); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + + clearHist(); + updateClip(); +} + +#else + +void Context::analysis() +{ + if (DebugPerf) + cerr << "Context::analysis()" << endl; + + if (thread_) + delete [] thread_; + thread_ = new pthread_t[parent_->nthreads_]; + t_smooth_arg* targ = new t_smooth_arg[parent_->nthreads_]; + + int cnt =0; + FitsImage* ptr = fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->analysis(doSmooth_, &thread_[cnt], &targ[cnt]); + + cnt++; + if (cnt == parent_->nthreads_) { + if (doSmooth_) { + for (int ii=0; iinextSlice(); + } + ptr = ptr->nextMosaic(); + } + + if (doSmooth_) { + for (int ii=0; iibin(vv); + binFinish(); + } + return mm; +} + +Matrix Context::binCenter() +{ + Matrix mm; + if (fits) { + mm = fits->binCenter(); + binFinish(); + } + return mm; +} + +Matrix Context::binCursor() +{ + Matrix mm; + if (fits) { + mm = fits->binCursor(); + binFinish(); + } + return mm; +} + +void Context::binFinish() +{ + if (DebugPerf) + cerr << "Context::binFinish()" << endl; + + if (!fits->isHist()) + return; + + // delete any previous slices + { + FitsImage* ptr = fits->nextSlice(); + fits->setNextSlice(NULL); + while (ptr) { + FitsImage* tmp = ptr->nextSlice(); + delete ptr; + ptr = tmp; + } + } + + // finish bin + loadInit(1, Base::NOMOSAIC,Coord::WCS); + cfits = fits; + + // bin data cube + int bd = binDepth_; + if (bd > 1) { + naxis_[2] =1; // first + shareWCS_ =1; + FitsImage* ptr = fits; + for (int ii=1; iiinterp, fits, ptr->baseFile(), ii+1); + if (next->isValid()) { + ptr->setNextSlice(next); + ptr = next; + naxis_[2]++; + } + else { + delete next; + break; + } + } + } + + // fix z params (in data coords) + iparams.set(0,naxis_[2]); + cparams.set(0,naxis_[2]); + + resetSecMode(); + loadFinish(); +} + +#ifdef __WIN32 + +int Context::block() +{ + if (DebugPerf) + cerr << "Context::block()" << endl; + + // primary + FitsImage* ptr = fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->block(); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + + resetSecMode(); + + int rr =1; + switch (mosaicType) { + case Base::IRAF: + case Base::WCSMOSAIC: + rr = processMosaicKeywords(fits); + break; + default: + break; + } + + FitsMask* msk = mask.head(); + if (msk) { + FitsImage* ptr = msk->mask(); + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->block(); + + switch (mosaicType) { + case Base::IRAF: + case Base::WCSMOSAIC: + rr &= processMosaicKeywords(ptr); + break; + default: + break; + } + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + msk = msk->next(); + } + + return rr & blockMask(); +} + +int Context::blockMask() +{ + int rr =1; + + FitsMask* msk = mask.head(); + if (msk) { + FitsImage* ptr = msk->mask(); + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->block(); + + switch (mosaicType) { + case Base::IRAF: + case Base::WCSMOSAIC: + rr &= processMosaicKeywords(ptr); + break; + default: + break; + } + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + msk = msk->next(); + } + + return rr; +} + +#else + +int Context::block() +{ + if (DebugPerf) + cerr << "Context::block()" << endl; + + int doBlock = (blockFactor_[0] != 1 && blockFactor_[1] != 1) ? 1 : 0; + int rr =1; + + // primary + if (thread_) + delete [] thread_; + thread_ = new pthread_t[parent_->nthreads_]; + { + int cnt =0; + FitsImage* ptr = fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->block(&thread_[cnt]); + cnt++; + if (cnt == parent_->nthreads_) { + if (doBlock) { + for (int ii=0; iinextSlice(); + } + ptr = ptr->nextMosaic(); + } + + if (doBlock) { + for (int ii=0; iinthreads_]; + { + int cnt =0; + + FitsMask* msk = mask.head(); + if (msk) { + FitsImage* ptr = msk->mask(); + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->block(&thread_[cnt]); + cnt++; + if (cnt == parent_->nthreads_) { + if (doBlock) { + for (int ii=0; iinextSlice(); + } + ptr = ptr->nextMosaic(); + } + msk = msk->next(); + } + + if (doBlock) { + for (int ii=0; iimask(); + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + switch (mosaicType) { + case Base::IRAF: + case Base::WCSMOSAIC: + rr &= processMosaicKeywords(ptr); + break; + default: + break; + } + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + msk = msk->next(); + } + } + + return rr; +} + +#endif + +void Context::bltHist(char* xname, char* yname, int num) +{ + if (!fits) + return; + + switch (frScale.clipScope()) { + case FrScale::GLOBAL: + frScale.histogram(fits,num); + break; + case FrScale::LOCAL: + frScale.histogram(cfits,num); + break; + } + + int nn = num+1; + double* x = frScale.histogramX(); + double* y = frScale.histogramY(); + + Blt_Vector* xx; + Blt_GetVector(parent_->interp, xname, &xx); + Blt_ResetVector(xx, x, nn, nn*sizeof(double), TCL_VOLATILE); + + Blt_Vector* yy; + Blt_GetVector(parent_->interp, yname, &yy); + Blt_ResetVector(yy, y, nn, nn*sizeof(double), TCL_VOLATILE); +} + +int Context::calcSlice() +{ + int cnt =1; + for (int jj=3; jjnextMosaic(); + while (ptr) { + fvcontour_.append(ptr); + ptr = ptr->nextMosaic(); + } + } + } +} + +void Context::contourDeleteFV() +{ + fvcontour_.lcontourlevel().deleteAll(); +} + +void Context::contourDeleteAux() +{ + auxcontours_.deleteAll(); +} + +void Context::contourListFV(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + if (!cfits) + return; + + contourList(str, sys, sky, fvcontour_.lcontourlevel()); +} + +void Context::contourListAux(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + if (!cfits) + return; + + contourList(str, sys, sky, auxcontours_); +} + +void Context::contourList(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, List& cl) +{ + if (cl.head()) { + str << "# Contour file format: DS9 version 7.5" << endl; + + // just in case + cl.head(); + str << "# levels=( "; + do + str << cl.current()->level() << ' '; + while (cl.next()); + str << ')' << endl; + // reset + cl.head(); + + str << "global color=green width=1 dash=no dashlist=8 3" << endl; + coord.listCoordSystem(str, sys, sky, cfits); + str << endl; + do + cl.current()->list(str, cfits, sys, sky); + while (cl.next()); + } +} + +void Context::contourLoadAux(istream& str) +{ + if (!cfits) + return; + + ctFlexLexer* ll = new ctFlexLexer(&str); + ctparse(parent_, ll); + delete ll; +} + +void Context::contourLoadAux(istream& str, const char* color, + int width, int dash) +{ + if (!cfits) + return; + + // remember where we are + int cnt = auxcontours_.count(); + + ctFlexLexer* ll = new ctFlexLexer(&str); + ctparse(parent_, ll); + delete ll; + + // override line attributes + if (auxcontours_.head()) { + for (int ii=0; iisetColor(color); + auxcontours_.current()->setLineWidth(width); + auxcontours_.current()->setDash(dash); + } + while (auxcontours_.next()); + } +} + +void Context::contourLoadAux(istream& str, + Coord::CoordSystem sys, Coord::SkyFrame sky, + const char* color, int width, int dash) +{ + if (!cfits) + return; + + int dl[2]; + dl[0] =8; + dl[1] =3; + ContourLevel* cl = new ContourLevel(parent_, 0, color, width, dash, dl); + + Contour* cc = new Contour(cl); + while (!str.eof()) { + char buf[64]; + str.getline(buf,64,'\n'); + if (strlen(buf) > 0) { + Vector vv; + string x(buf); + istringstream sstr(x); + + sstr >> vv[0] >> vv[1]; + cc->lvertex().append(new Vertex(fits->mapToRef(vv, sys, sky))); + } + else { + cl->lcontour().append(cc); + cc = new Contour(cl); + } + } + + auxcontours_.append(cl); +} + +void Context::contourPS(Widget::PSColorSpace cs) +{ + if (!cfits) + return; + + // render back to front + // aux contours + if (auxcontours_.tail()) + do + auxcontours_.current()->ps(cs); + while (auxcontours_.previous()); + + List& cc = fvcontour_.lcontourlevel(); + if (cc.head()) + do + cc.current()->ps(cs); + while (cc.next()); +} + +void Context::contourX11(Pixmap pm, Coord::InternalSystem sys, + int width, int height) +{ + if (!cfits) + return; + + // render back to front + // aux contours + if (auxcontours_.tail()) + do + auxcontours_.current()->render(pm, sys, width, height); + while (auxcontours_.previous()); + + List& cc = fvcontour_.lcontourlevel(); + if (cc.head()) + do + cc.current()->render(pm, sys, width, height); + while (cc.next()); +} + +#ifdef MAC_OSX_TK +void Context::contourMacOSX() +{ + if (!cfits) + return; + + // render back to front + // aux contours + if (auxcontours_.tail()) + do + auxcontours_.current()->macosx(); + while (auxcontours_.previous()); + + List& cc = fvcontour_.lcontourlevel(); + if (cc.head()) + do + cc.current()->macosx(); + while (cc.next()); +} +#endif + +#ifdef __WIN32 +void Context::contourWin32() +{ + if (!cfits) + return; + + // render back to front + // aux contours + if (auxcontours_.tail()) + do + auxcontours_.current()->win32(); + while (auxcontours_.previous()); + + List& cc = fvcontour_.lcontourlevel(); + if (cc.head()) + do + cc.current()->win32(); + while (cc.next()); +} +#endif + +int Context::fitsCount() +{ + int cnt =1; + for (int ii=2; iinextSlice(); + while (sptr) { + FitsImage* stmp = sptr->nextSlice(); + delete sptr; + sptr = stmp; + } + + FitsImage* tmp = ptr->nextMosaic(); + delete ptr; + ptr = tmp; + } +} + +Vector Context::getClip() +{ + return Vector(frScale.low(), frScale.high()); +} + +Vector Context::getClip(FrScale::ClipMode cm, float ac) +{ + if (DebugPerf) + cerr << "Context::getClip()" << endl; + + // we already have the scale? + if (frScale.clipMode() == cm && frScale.autoCutPer() == ac) + return Vector(frScale.low(),frScale.high()); + + FrScale cl = frScale; + cl.setClipMode(cm); + cl.setAutoCutPer(ac); + updateClip(&cl); + + // now reset + updateClip(&frScale); + + return Vector(cl.low(),cl.high()); +} + +FitsZBound* Context::getDataParams(FrScale::SecMode which) +{ + switch (which) { + case FrScale::IMGSEC: + case FrScale::DATASEC: + return &iparams; + case FrScale::CROPSEC: + return &cparams; + } +} + +Vector Context::getMinMax() +{ + return Vector(frScale.min(), frScale.max()); +} + +int Context::load(Base::MemType which, const char* fn, + FitsImage* img, Base::LayerType ll) +{ + if (!img || !img->isValid()) { + if (img) + delete img; + + switch (ll) { + case Base::IMG: + unload(); + return 0; + case Base::MASK: + return 0; + } + } + + switch (ll) { + case Base::IMG: + bfits_ = img; + loadInit(1, Base::NOMOSAIC,Coord::WCS); + for (int ii=2; iinaxis(ii); + baxis_[ii] = nn ? nn : 1; + } + + // fix z params (in data coords) + // do it here because of fits section + iparams.set(0,baxis_[2]); + cparams.set(0,baxis_[2]); + break; + + case Base::MASK: + mask.append(new FitsMask(parent_, img, parent_->maskColorName, parent_->maskMark)); + break; + } + + if (img->isHist()) + which = Base::HIST; + else if (img->isPost()) + which = Base::POST; + + if (img->nhdu() > 1) + shareWCS_ =1; + + FitsImage* ptr = img; + for (int ii=1; iinhdu(); ii++) { + FitsImage* next = NULL; + switch (which) { + case Base::ALLOC: + next = new FitsImageFitsNextAlloc(this, parent_->interp, fn, ptr->fitsFile(), ii+1); + break; + case Base::ALLOCGZ: + next = new FitsImageFitsNextAllocGZ(this, parent_->interp, fn, ptr->fitsFile(), ii+1); + break; + case Base::CHANNEL: + next = new FitsImageFitsNextChannel(this, parent_->interp, fn, ptr->fitsFile(), ii+1); + break; + case Base::MMAP: + next = new FitsImageFitsNextMMap(this, parent_->interp, fn, ptr->fitsFile(), ii+1); + break; + case Base::SMMAP: + next = new FitsImageFitsNextSMMap(this, parent_->interp, fn, ptr->fitsFile(), ii+1); + break; + case Base::MMAPINCR: + next = new FitsImageFitsNextMMapIncr(this, parent_->interp, fn, ptr->fitsFile(), ii+1); + break; + case Base::SHARE: + next = new FitsImageFitsNextShare(this, parent_->interp, fn, ptr->fitsFile(), ii+1); + break; + case Base::SSHARE: + next = new FitsImageFitsNextSShare(this, parent_->interp, fn, ptr->fitsFile(), ii+1); + break; + case Base::SOCKET: + next = new FitsImageFitsNextSocket(this, parent_->interp, fn, ptr->fitsFile(), ii+1); + break; + case Base::SOCKETGZ: + next = new FitsImageFitsNextSocketGZ(this, parent_->interp, fn, ptr->fitsFile(), ii+1); + break; + case Base::VAR: + next = new FitsImageFitsNextVar(this, parent_->interp, fn, ptr->fitsFile(), ii+1); + break; + case Base::POST: + next = new FitsImageFitsNextPost(this, parent_->interp, img, ptr->baseFile(), ii+1); + break; + case Base::PHOTO: + next = new FitsImagePhotoCubeNext(this, parent_->interp, fn, ptr->baseFile(), ii+1); + break; + default: + // na + break; + } + + if (next->isValid()) { + ptr->setNextSlice(next); + ptr = next; + } + else { + delete next; + break; + } + } + + // finish up + img->close(); + + switch (ll) { + case Base::IMG: + loadFinish(); + break; + case Base::MASK: + loadFinishMask(); + break; + } + + return 1; +} + +int Context::loadExtCube(Base::MemType which, const char* fn, FitsImage* img) +{ + if (!img || !img->isValid()) { + if (img) + delete img; + + unload(); + return 0; + } + + bfits_ = img; + loadInit(1, Base::NOMOSAIC,Coord::WCS); + + // get the rest + FitsImage* ptr = img; + FitsImage* mptr = ptr; + FitsImage* tmp =NULL; + while (1) { + FitsImage* next = NULL; + switch (which) { + case Base::ALLOC: + next = new FitsImageMosaicNextAlloc(this, parent_->interp, fn, ptr->fitsFile(), FitsFile::NOFLUSH ,1); + break; + case Base::ALLOCGZ: + next = new FitsImageMosaicNextAllocGZ(this, parent_->interp,fn,ptr->fitsFile(), FitsFile::NOFLUSH ,1); + break; + case Base::CHANNEL: + next = new FitsImageMosaicNextChannel(this, parent_->interp,fn,ptr->fitsFile(), FitsFile::NOFLUSH, 1); + break; + case Base::MMAP: + next = new FitsImageMosaicNextMMap(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::MMAPINCR: + next = new FitsImageMosaicNextMMapIncr(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::SHARE: + next = new FitsImageMosaicNextShare(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::SOCKET: + next = new FitsImageMosaicNextSocket(this, parent_->interp, fn,ptr->fitsFile(), FitsFile::FLUSH,1 ); + break; + case Base::SOCKETGZ: + next =new FitsImageMosaicNextSocketGZ(this, parent_->interp,fn,ptr->fitsFile(), FitsFile::FLUSH,1 ); + break; + case Base::VAR: + next = new FitsImageMosaicNextVar(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + default: + // na + break; + } + + // if previous was a unknown table, delete now, we're done with it + if (tmp) { + delete tmp; + tmp =NULL; + } + + // first check if fits_ is a known extension, aka we loaded something + if (next->isImage() || next->isTable()) { + // now check to see if it resolved into an image, no event tables + // since any table can be a valid event table + if (next->isValid() && !next->isHist()) { + mptr->setNextSlice(next); + ptr = next; + mptr = ptr; + baxis_[2]++; + } + else { + // must be a unknown table, just ignore, and delete next time thru + ptr = next; + tmp = next; + } + } + else { + delete next; + break; + } + } + + // finish up + img->close(); + + // fix z params (in data coords) + // must wait untill all loaded + iparams.set(0,baxis_[2]); + cparams.set(0,baxis_[2]); + + loadFinish(); + return 1; +} + +void Context::loadInit(int cnt, Base::MosaicType type, Coord::CoordSystem sys) +{ + shareWCS_ =0; + + mosaicCount_ = cnt; + mosaicType = type; + mosaicSystem = sys; + for (int ii=0; iiisValid()) { + if (img) + delete img; + return 0; + } + + switch (ll) { + case Base::IMG: + if (bfits_) { + FitsImage* ptr = bfits_; + while (ptr && ptr->nextMosaic()) + ptr = ptr->nextMosaic(); + ptr->setNextMosaic(img); + mosaicCount_++; + } + else { + bfits_ = img; + loadInit(1, type,sys); + for (int ii=2; iinaxis(ii); + baxis_[ii] = nn ? nn : 1; + } + + // fix z params (in data coords) + // do it here because of fits section + iparams.set(0,baxis_[2]); + cparams.set(0,baxis_[2]); + } + break; + + case Base::MASK: + FitsMask* msk = mask.tail(); + if (msk) { + FitsImage* mskimg = msk->mask(); + while (mskimg && mskimg->nextMosaic()) + mskimg = mskimg->nextMosaic(); + mskimg->setNextMosaic(img); + } + else + mask.append(new FitsMask(parent_, img, parent_->maskColorName, parent_->maskMark)); + break; + } + + if (img->isPost()) + which = Base::POST; + + // get the rest of slices + if (img->nhdu() > 1) + shareWCS_ =1; + + FitsImage* sptr = img; + for (int ii=1; iinhdu(); ii++) { + FitsImage* next = NULL; + switch (which) { + case Base::ALLOC: + next = new FitsImageFitsNextAlloc(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::ALLOCGZ: + next = new FitsImageFitsNextAllocGZ(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::CHANNEL: + next = new FitsImageFitsNextChannel(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::MMAP: + next = new FitsImageFitsNextMMap(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::SMMAP: + next = new FitsImageFitsNextSMMap(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::MMAPINCR: + next = new FitsImageFitsNextMMapIncr(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::SHARE: + next = new FitsImageFitsNextShare(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::SSHARE: + next = new FitsImageFitsNextSShare(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::SOCKET: + next = new FitsImageFitsNextSocket(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::SOCKETGZ: + next = new FitsImageFitsNextSocketGZ(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::VAR: + next = new FitsImageFitsNextVar(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::POST: + next = new FitsImageFitsNextPost(this, parent_->interp, img, sptr->baseFile(), ii+1); + break; + case Base::PHOTO: + next = new FitsImagePhotoCubeNext(this, parent_->interp, fn, sptr->baseFile(), ii+1); + break; + default: + // na + break; + } + + if (next->isValid()) { + sptr->setNextSlice(next); + sptr = next; + } + else { + delete next; + break; + } + } + + // finish up + img->close(); + + switch (ll) { + case Base::IMG: + loadFinishMosaic(fits); + if (!loadFinish()) { + unload(); + return 0; + } + break; + case Base::MASK: + if (!loadFinishMosaicMask()) + return 0; + break; + } + + return 1; +} + +int Context::loadMosaicImage(Base::MemType which, const char* fn, + FitsImage* img, Base::LayerType ll, + Base::MosaicType type, Coord::CoordSystem sys) +{ + if (!img || !img->isValid()) { + if (img) + delete img; + + switch (ll) { + case Base::IMG: + unload(); + return 0; + case Base::MASK: + return 0; + } + } + + switch (ll) { + case Base::IMG: + bfits_ = img; + loadInit(1, type,sys); + for (int ii=2; iinaxis(ii); + baxis_[ii] = nn ? nn : 1; + } + + // fix z params (in data coords) + // do it here because of fits section + iparams.set(0,baxis_[2]); + cparams.set(0,baxis_[2]); + + break; + + case Base::MASK: + mask.append(new FitsMask(parent_, img, parent_->maskColorName, parent_->maskMark)); + break; + } + + Base::MemType sav = which; + + // get the rest of slices + FitsImage* sptr = img; + if (img->isPost()) + which = Base::POST; + + if (img->nhdu() > 1) + shareWCS_ =1; + + for (int ii=1; iinhdu(); ii++) { + FitsImage* next = NULL; + switch (which) { + case Base::ALLOC: + next = new FitsImageFitsNextAlloc(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::ALLOCGZ: + next = new FitsImageFitsNextAllocGZ(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::CHANNEL: + next = new FitsImageFitsNextChannel(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::MMAP: + next = new FitsImageFitsNextMMap(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::SMMAP: + next = new FitsImageFitsNextSMMap(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::MMAPINCR: + next = new FitsImageFitsNextMMapIncr(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::SHARE: + next = new FitsImageFitsNextShare(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::SSHARE: + next = new FitsImageFitsNextSShare(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::SOCKET: + next = new FitsImageFitsNextSocket(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::SOCKETGZ: + next = new FitsImageFitsNextSocketGZ(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::VAR: + next = new FitsImageFitsNextVar(this, parent_->interp, fn, sptr->fitsFile(), ii+1); + break; + case Base::POST: + next = new FitsImageFitsNextPost(this, parent_->interp, img, sptr->baseFile(), ii+1); + break; + default: + // na + break; + } + + if (next->isValid()) { + sptr->setNextSlice(next); + sptr = next; + } + else { + delete next; + break; + } + } + + // get the rest of mosaic + FitsImage* ptr = img; + FitsImage* tmp =NULL; + while (1) { + // restore which + which = sav; + + FitsImage* next = NULL; + switch (which) { + case Base::ALLOC: + next = new FitsImageMosaicNextAlloc(this, parent_->interp, fn, ptr->fitsFile(), FitsFile::NOFLUSH, 1); + break; + case Base::ALLOCGZ: + next = new FitsImageMosaicNextAllocGZ(this, parent_->interp,fn,ptr->fitsFile(), FitsFile::NOFLUSH, 1); + break; + case Base::CHANNEL: + next = new FitsImageMosaicNextChannel(this, parent_->interp,fn,ptr->fitsFile(), FitsFile::NOFLUSH, 1); + break; + case Base::MMAP: + next = new FitsImageMosaicNextMMap(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::MMAPINCR: + next = new FitsImageMosaicNextMMapIncr(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::SHARE: + next = new FitsImageMosaicNextShare(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::SOCKET: + next = new FitsImageMosaicNextSocket(this, parent_->interp, fn,ptr->fitsFile(), FitsFile::FLUSH, 1); + break; + case Base::SOCKETGZ: + next = new FitsImageMosaicNextSocketGZ(this, parent_->interp,fn,ptr->fitsFile(), FitsFile::FLUSH, 1); + break; + case Base::VAR: + next = new FitsImageMosaicNextVar(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + default: + // na + break; + } + + // if previous was a unknown table, delete now, we're done with it + if (tmp) { + delete tmp; + tmp =NULL; + } + + // first check if fits_ is a known extension, aka we loaded something + if (!next->isImage() && !next->isTable()) { + // ok, we're done + delete next; + break; + } + + // now check to see if it resolved into an image, no event tables + // since any table can be a valid event table + if (!next->isValid() || next->isHist()) { + // must be a unknown table, just ignore, and delete next time thru + ptr = next; + tmp = next; + } + else { + ptr->setNextMosaic(next); + ptr = next; + + if (ll == Base::IMG) + mosaicCount_++; + + if (img->isPost()) + which = Base::POST; + + // get rest of slices + for (int ii=1; iinhdu(); ii++) { + FitsImage* snext = NULL; + switch (which) { + case Base::ALLOC: + snext = new FitsImageFitsNextAlloc(this, parent_->interp, fn, next->fitsFile(),ii+1); + break; + case Base::ALLOCGZ: + snext = new FitsImageFitsNextAllocGZ(this, parent_->interp, fn, next->fitsFile(),ii+1); + break; + case Base::CHANNEL: + snext = new FitsImageFitsNextChannel(this, parent_->interp, fn, next->fitsFile(),ii+1); + break; + case Base::MMAP: + snext = new FitsImageFitsNextMMap(this, parent_->interp, fn, next->fitsFile(),ii+1); + break; + case Base::SMMAP: + snext = new FitsImageFitsNextSMMap(this, parent_->interp, fn, next->fitsFile(),ii+1); + break; + case Base::MMAPINCR: + snext = new FitsImageFitsNextMMapIncr(this, parent_->interp, fn, next->fitsFile(),ii+1); + break; + case Base::SHARE: + snext = new FitsImageFitsNextShare(this, parent_->interp, fn, next->fitsFile(),ii+1); + break; + case Base::SSHARE: + snext = new FitsImageFitsNextSShare(this, parent_->interp, fn, next->fitsFile(),ii+1); + break; + case Base::SOCKET: + snext = new FitsImageFitsNextSocket(this, parent_->interp, fn, next->fitsFile(),ii+1); + break; + case Base::SOCKETGZ: + snext = new FitsImageFitsNextSocketGZ(this, parent_->interp, fn, next->fitsFile(),ii+1); + break; + case Base::VAR: + snext = new FitsImageFitsNextVar(this, parent_->interp, fn, next->fitsFile(),ii+1); + break; + case Base::POST: + snext = new FitsImageFitsNextPost(this, parent_->interp, ptr, next->baseFile(),ii+1); + break; + default: + // na + break; + } + + if (snext->isValid()) { + next->setNextSlice(snext); + next = snext; + } + else { + delete snext; + break; + } + } + } + } + + // finish up + img->close(); + + switch (ll) { + case Base::IMG: + loadFinishMosaic(fits); + if (!loadFinish()) { + unload(); + return 0; + } + break; + case Base::MASK: + if (!loadFinishMosaicMask()) + return 0; + break; + } + + return 1; +} + +int Context::loadMosaicWFPC2(Base::MemType which, const char* fn, + FitsImage* img) +{ + if (!img || !img->isValid()) { + if (img) + delete img; + + unload(); + return 0; + } + + // Its legal, save it + bfits_ = img; + loadInit(1, Base::WFPC2,Coord::WCS); + + // remember in case of compress + Base::MemType sav = which; + + if (img->isPost()) + which = Base::POST; + + // get the rest + { + FitsImage* ptr = img; + for (int i=1; i<4; i++) { + FitsImage* next = NULL; + switch (which) { + case Base::ALLOC: + next = new FitsImageFitsNextAlloc(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::ALLOCGZ: + next = new FitsImageFitsNextAllocGZ(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::CHANNEL: + next = new FitsImageFitsNextChannel(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::MMAP: + next = new FitsImageFitsNextMMap(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::MMAPINCR: + next = new FitsImageFitsNextMMapIncr(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::SHARE: + next = new FitsImageFitsNextShare(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::SOCKET: + next = new FitsImageFitsNextSocket(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::SOCKETGZ: + next = new FitsImageFitsNextSocketGZ(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::VAR: + next = new FitsImageFitsNextVar(this, parent_->interp, fn, ptr->fitsFile(), 1); + break; + case Base::POST: + next = new FitsImageFitsNextPost(this, parent_->interp, img, ptr->baseFile(), 1); + break; + default: + // na + break; + } + + if (next->isValid()) { + ptr->setNextMosaic(next); + ptr = next; + mosaicCount_++; + } + else { + delete next; + break; + } + } + } + + // restore which + which = sav; + + // ok, do we have 4 images? + if (mosaicCount_ != 4) { + unload(); + return 0; + } + + // now, find WCS table + FitsFile* table =NULL; + switch (which) { + case Base::ALLOC: + table = new FitsMosaicNextAlloc(img->fitsFile(), FitsFile::NOFLUSH); + break; + case Base::ALLOCGZ: + table = new FitsMosaicNextAllocGZ(img->fitsFile(), FitsFile::NOFLUSH); + break; + case Base::CHANNEL: + table = new FitsMosaicNextChannel(img->fitsFile(), FitsFile::NOFLUSH); + break; + case Base::MMAP: + table = new FitsMosaicNextMMap(img->fitsFile()); + break; + case Base::MMAPINCR: + table = new FitsMosaicNextMMapIncr(img->fitsFile()); + break; + case Base::SHARE: + table = new FitsMosaicNextShare(img->fitsFile()); + break; + case Base::SOCKET: + table = new FitsMosaicNextSocket(img->fitsFile(), FitsFile::FLUSH); + break; + case Base::SOCKETGZ: + table = new FitsMosaicNextSocketGZ(img->fitsFile(), FitsFile::FLUSH); + break; + case Base::VAR: + table = new FitsMosaicNextVar(img->fitsFile()); + break; + default: + // na + break; + } + + if (!table || !table->isValid() || !table->isAsciiTable()) { + if (table) + delete table; + + unload(); + return 0; + } + + // read WCS from table + { + FitsHead* th = table->head(); + if (th->naxes() != 2) { + if (table) + delete table; + + unload(); + return 0; + } + + FitsTableHDU* thdu = (FitsTableHDU*)th->hdu(); + + FitsColumn* crval1 = thdu->find("CRVAL1"); + FitsColumn* crval2 = thdu->find("CRVAL2"); + FitsColumn* crpix1 = thdu->find("CRPIX1"); + FitsColumn* crpix2 = thdu->find("CRPIX2"); + + FitsColumn* cd1_1 = thdu->find("CD1_1"); + FitsColumn* cd1_2 = thdu->find("CD1_2"); + FitsColumn* cd2_1 = thdu->find("CD2_1"); + FitsColumn* cd2_2 = thdu->find("CD2_2"); + + FitsColumn* ctype1 = thdu->find("CTYPE1"); + FitsColumn* ctype2 = thdu->find("CTYPE2"); + + char* tptr = (char*)table->data(); + int rows = thdu->rows(); + int rowlen = thdu->width(); + + if (rows != 4) { + unload(); + return 0; + } + + FitsImage* ptr = bfits_; + + // reset count for processKeyWords() + mosaicCount_ =0; + + for (int ii=0; iicancelDetach(); + + if (manageAxes_) { + delete [] naxis_; + deleteFits(fits); + manageAxes_ =0; + } + fits = bfits_; + naxis_ = baxis_; + + if (axesOrder_ != 123) + reorderAxes(); + + for (int ii=0; iiprocessKeywordsFitsSection(); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + + analysis(); + + return 1; +} + +void Context::loadFinishMask() +{ + FitsMask* msk = mask.tail(); + if (msk) { + FitsImage* mskimg = msk->mask(); + mskimg->block(); + } +} + +void Context::loadFinishMosaic(FitsImage* ptr) +{ + while (ptr && ptr->nextMosaic()) { + int jj=0; + FitsImage* sptr = ptr; + while (sptr) { + if (sptr->nextMosaic() == NULL) { + // ok, let's figure out next inline + FitsImage* mptr = ptr->nextMosaic(); + for (int nn=0; nnnextSlice(); + sptr->setNextMosaic(mptr); + } + jj++; + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } +} + +int Context::loadFinishMosaicMask() +{ + FitsMask* msk = mask.tail(); + if (msk) + loadFinishMosaic(msk->mask()); + + return blockMask(); +} + +int Context::loadSlice(Base::MemType which, const char* fn, + FitsImage* img) +{ + if (!img || !img->isValid()) { + if (img) + delete img; + return 0; + } + + if (bfits_) { + FitsImage* ptr = bfits_; + while (ptr && ptr->nextSlice()) + ptr = ptr->nextSlice(); + ptr->setNextSlice(img); + baxis_[2]++; + } + else { + bfits_ = img; + loadInit(1, Base::NOMOSAIC,Coord::WCS); + } + + // finish up + img->close(); + + // fix z params (in data coords) + // must wait untill all loaded + iparams.set(0,baxis_[2]); + cparams.set(0,baxis_[2]); + + loadFinish(); + return 1; +} + +int Context::naxes() +{ + for (int ii=FTY_MAXAXES-1; ii>=2; ii--) { + if (naxis_[ii]>1) + return ii+1; + } + return 2; +} + +int Context::nhdu() +{ + int dd =1; + for (int ii=2; ii1) + dd *= naxis_[ii]; + return dd; +} + +int Context::processMosaicKeywords(FitsImage* ptr) +{ + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + switch (mosaicType) { + case Base::IRAF: + if (!sptr->processKeywordsIRAF(fits)) + return 0; + break; + case Base::WCSMOSAIC: + { + if (!sptr->hasWCS(mosaicSystem)) + return 0; + + Matrix mm = parent_->calcAlignWCS(fits, sptr, mosaicSystem, + mosaicSystem, Coord::FK5); + sptr->setwcsToRef(mm); + } + break; + default: + // na + break; + } + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + + return 1; +} + +void* reorder132(void* tt) +{ + t_reorder_arg* targ = (t_reorder_arg*)tt; + char* dest = targ->dest; + char** sjv = targ->sjv; + int ww = targ->ww; + // int hh = targ->hh; + int dd = targ->dd; + int bz = targ->bz; + int jj = targ->mm; + + for (int kk=0; kkdest; + char** sjv = targ->sjv; + int ww = targ->ww; + int hh = targ->hh; + // int dd = targ->dd; + int bz = targ->bz; + int kk = targ->mm; + + for (int ii=0; iidest; + char** sjv = targ->sjv; + int ww = targ->ww; + int hh = targ->hh; + int dd = targ->dd; + int bz = targ->bz; + int ii = targ->mm; + + for (int kk=0; kkdest; + char** sjv = targ->sjv; + int ww = targ->ww; + // int hh = targ->hh; + int dd = targ->dd; + int bz = targ->bz; + int jj = targ->mm; + + for (int ii=0; iidest; + char** sjv = targ->sjv; + int ww = targ->ww; + int hh = targ->hh; + int dd = targ->dd; + int bz = targ->bz; + int ii = targ->mm; + + for (int jj=0; jjnthreads_) { + for (int pp=0; pp<*cnt; pp++) { + if (pthread_join(thread_[pp], NULL)) + internalError("Unable to Join Thread"); + } + *cnt =0; + } + } +} + +void Context::reorderAxis(char* data, char** sjv, int ww, int hh, int dd, + size_t bz) +{ + if (thread_) + delete [] thread_; + thread_ = new pthread_t[parent_->nthreads_]; + t_reorder_arg* targ = new t_reorder_arg[parent_->nthreads_]; + + for (int ii=0; iinthreads_; ii++) { + targ[ii].sjv = sjv; + targ[ii].ww = ww; + targ[ii].hh = hh; + targ[ii].dd = dd; + targ[ii].bz = bz; + } + + int cnt =0; + switch (axesOrder_) { + case 123: + return; + case 132: + naxis_[0] =ww; + naxis_[1] =dd; + naxis_[2] =hh; + reorderThread(targ, data, reorder132, &cnt); + break; + case 213: + naxis_[0] =hh; + naxis_[1] =ww; + naxis_[2] =dd; + reorderThread(targ, data, reorder213, &cnt); + break; + case 231: + naxis_[0] =hh; + naxis_[1] =dd; + naxis_[2] =ww; + reorderThread(targ, data, reorder231, &cnt); + break; + case 312: + naxis_[0] =dd; + naxis_[1] =ww; + naxis_[2] =hh; + reorderThread(targ, data, reorder312, &cnt); + break; + case 321: + naxis_[0] =dd; + naxis_[1] =hh; + naxis_[2] =ww; + reorderThread(targ, data, reorder321, &cnt); + break; + } + + for (int pp=0; ppbaseFile()->head()->bitpix(); + int bz = abs(bitpix)/8; + + int ww = bfits_->baseFile()->head()->naxis(0); + int hh = bfits_->baseFile()->head()->naxis(1); + int dd = baxis_[2]; + size_t sz = (size_t)ww*hh*dd*bz; + + // Data + char* data = new char[sz]; + if (!data) + return; + memset(data,sz,0); + + naxis_ = new int[FTY_MAXAXES]; + for (int ii=0; iibasedata(); + if (sptr) + sptr = sptr->nextSlice(); + } + + reorderAxis(data, sjv, ww, hh, dd, bz); + + // Header + FitsHead* hdr = new FitsHead(*(bfits_->baseFile()->head())); + hdr->setInteger("NAXES", 3, ""); + hdr->setInteger("NAXIS1", naxis_[0], ""); + hdr->setInteger("NAXIS2", naxis_[1], ""); + if (hdr->find("NAXIS3")) + hdr->setInteger("NAXIS3", naxis_[2], ""); + else { + char* n2= hdr->find("NAXIS2"); + hdr->insertInteger("NAXIS3", naxis_[2], "", n2); + } + + for (int ii=0; iifind("CTYPE1") && hdr->find("CTYPE2")) { + char* c2= hdr->find("CTYPE2"); + hdr->insertString("CTYPE1", "LINEAR", "", c2); + } + else if (!hdr->find("CTYPE2") && hdr->find("CTYPE1")) { + char* c1= hdr->find("CTYPE1"); + hdr->insertString("CTYPE2", "LINEAR", "", c1); + } + + // Load it + fits = new FitsImageFitsOrder(this, parent_->interp, bfits_, hdr, data, sz, 1); + FitsImage* ptr = fits; + for (int ii=1; iiinterp, fits, ptr->fitsFile(), ii+1); + + if (next->isValid()) { + ptr->setNextSlice(next); + ptr = next; + } + else { + delete next; + break; + } + } + + // fix z params (in data coords) + iparams.set(0,naxis_[2]); + cparams.set(0,naxis_[2]); + + manageAxes_ =1; +} + +void Context::reorderWCSi(FitsHead* hdr, char* kk, int ii, char ww) +{ + char key[8]; + strcpy(key,kk); + + key[ii+1] = ww; + + key[ii] = '1'; + char* c1 = hdr->find(key); + key[ii] = '2'; + char* c2 = hdr->find(key); + key[ii] = '3'; + char* c3 = hdr->find(key); + + switch (axesOrder_) { + case 123: + return; + case 132: + { + if (c1) { + key[ii] = '1'; + FitsCard(c1).setKey(key); + } + if (c2) { + key[ii] = '3'; + FitsCard(c2).setKey(key); + } + if (c3) { + key[ii] = '2'; + FitsCard(c3).setKey(key); + } + } + break; + case 213: + { + if (c1) { + key[ii] = '2'; + FitsCard(c1).setKey(key); + } + if (c2) { + key[ii] = '1'; + FitsCard(c2).setKey(key); + } + if (c3) { + key[ii] = '3'; + FitsCard(c3).setKey(key); + } + } + break; + case 231: + { + if (c1) { + key[ii] = '3'; + FitsCard(c1).setKey(key); + } + if (c2) { + key[ii] = '1'; + FitsCard(c2).setKey(key); + } + if (c3) { + key[ii] = '2'; + FitsCard(c3).setKey(key); + } + } + break; + case 312: + { + if (c1) { + key[ii] = '2'; + FitsCard(c1).setKey(key); + } + if (c2) { + key[ii] = '3'; + FitsCard(c2).setKey(key); + } + if (c3) { + key[ii] = '1'; + FitsCard(c3).setKey(key); + } + } + break; + case 321: + { + if (c1) { + key[ii] = '3'; + FitsCard(c1).setKey(key); + } + if (c2) { + key[ii] = '2'; + FitsCard(c2).setKey(key); + } + if (c3) { + key[ii] = '1'; + FitsCard(c3).setKey(key); + } + } + break; + } +} + +void Context::reorderWCSij(FitsHead* hdr, char* kk, int ii, char ww) +{ + char key[8]; + strcpy(key,kk); + + key[ii+3] = ww; + + key[ii] = '1'; + key[ii+2] = '1'; + char* c11 = hdr->find(key); + key[ii+2] = '2'; + char* c12 = hdr->find(key); + key[ii+2] = '3'; + char* c13 = hdr->find(key); + + key[ii] = '2'; + key[ii+2] = '1'; + char* c21 = hdr->find(key); + key[ii+2] = '2'; + char* c22 = hdr->find(key); + key[ii+2] = '3'; + char* c23 = hdr->find(key); + + key[ii] = '3'; + key[ii+2] = '1'; + char* c31 = hdr->find(key); + key[ii+2] = '2'; + char* c32 = hdr->find(key); + key[ii+2] = '3'; + char* c33 = hdr->find(key); + + switch (axesOrder_) { + case 123: + return; + case 132: + { + if (c11) { + key[ii] = '1'; + key[ii+2] = '1'; + FitsCard(c11).setKey(key); + } + if (c12) { + key[ii] = '1'; + key[ii+2] = '3'; + FitsCard(c12).setKey(key); + } + if (c13) { + key[ii] = '1'; + key[ii+2] = '2'; + FitsCard(c13).setKey(key); + } + + if (c21) { + key[ii] = '3'; + key[ii+2] = '1'; + FitsCard(c21).setKey(key); + } + if (c22) { + key[ii] = '3'; + key[ii+2] = '3'; + FitsCard(c22).setKey(key); + } + if (c23) { + key[ii] = '3'; + key[ii+2] = '2'; + FitsCard(c23).setKey(key); + } + + if (c31) { + key[ii] = '2'; + key[ii+2] = '1'; + FitsCard(c31).setKey(key); + } + if (c32) { + key[ii] = '2'; + key[ii+2] = '3'; + FitsCard(c32).setKey(key); + } + if (c33) { + key[ii] = '2'; + key[ii+2] = '2'; + FitsCard(c33).setKey(key); + } + } + break; + case 213: + { + if (c11) { + key[ii] = '2'; + key[ii+2] = '2'; + FitsCard(c11).setKey(key); + } + if (c12) { + key[ii] = '2'; + key[ii+2] = '1'; + FitsCard(c12).setKey(key); + } + if (c13) { + key[ii] = '2'; + key[ii+2] = '3'; + FitsCard(c13).setKey(key); + } + + if (c21) { + key[ii] = '1'; + key[ii+2] = '2'; + FitsCard(c21).setKey(key); + } + if (c22) { + key[ii] = '1'; + key[ii+2] = '1'; + FitsCard(c22).setKey(key); + } + if (c23) { + key[ii] = '1'; + key[ii+2] = '3'; + FitsCard(c23).setKey(key); + } + + if (c31) { + key[ii] = '3'; + key[ii+2] = '2'; + FitsCard(c31).setKey(key); + } + if (c32) { + key[ii] = '3'; + key[ii+2] = '1'; + FitsCard(c32).setKey(key); + } + if (c33) { + key[ii] = '3'; + key[ii+2] = '3'; + FitsCard(c33).setKey(key); + } + } + break; + case 231: + { + if (c11) { + key[ii] = '3'; + key[ii+2] = '3'; + FitsCard(c11).setKey(key); + } + if (c12) { + key[ii] = '3'; + key[ii+2] = '1'; + FitsCard(c12).setKey(key); + } + if (c13) { + key[ii] = '3'; + key[ii+2] = '2'; + FitsCard(c13).setKey(key); + } + + if (c21) { + key[ii] = '1'; + key[ii+2] = '3'; + FitsCard(c21).setKey(key); + } + if (c22) { + key[ii] = '1'; + key[ii+2] = '1'; + FitsCard(c22).setKey(key); + } + if (c23) { + key[ii] = '1'; + key[ii+2] = '2'; + FitsCard(c23).setKey(key); + } + + if (c31) { + key[ii] = '2'; + key[ii+2] = '3'; + FitsCard(c31).setKey(key); + } + if (c32) { + key[ii] = '2'; + key[ii+2] = '1'; + FitsCard(c32).setKey(key); + } + if (c33) { + key[ii] = '2'; + key[ii+2] = '2'; + FitsCard(c33).setKey(key); + } + } + break; + case 312: + { + if (c11) { + key[ii] = '2'; + key[ii+2] = '2'; + FitsCard(c11).setKey(key); + } + if (c12) { + key[ii] = '2'; + key[ii+2] = '3'; + FitsCard(c12).setKey(key); + } + if (c13) { + key[ii] = '2'; + key[ii+2] = '1'; + FitsCard(c13).setKey(key); + } + + if (c21) { + key[ii] = '3'; + key[ii+2] = '2'; + FitsCard(c21).setKey(key); + } + if (c22) { + key[ii] = '3'; + key[ii+2] = '3'; + FitsCard(c22).setKey(key); + } + if (c23) { + key[ii] = '3'; + key[ii+2] = '1'; + FitsCard(c23).setKey(key); + } + + if (c31) { + key[ii] = '1'; + key[ii+2] = '2'; + FitsCard(c31).setKey(key); + } + if (c32) { + key[ii] = '1'; + key[ii+2] = '3'; + FitsCard(c32).setKey(key); + } + if (c33) { + key[ii] = '1'; + key[ii+2] = '1'; + FitsCard(c33).setKey(key); + } + } + break; + case 321: + { + if (c11) { + key[ii] = '3'; + key[ii+2] = '3'; + FitsCard(c11).setKey(key); + } + if (c12) { + key[ii] = '3'; + key[ii+2] = '2'; + FitsCard(c12).setKey(key); + } + if (c13) { + key[ii] = '3'; + key[ii+2] = '1'; + FitsCard(c13).setKey(key); + } + + if (c21) { + key[ii] = '2'; + key[ii+2] = '3'; + FitsCard(c21).setKey(key); + } + if (c22) { + key[ii] = '2'; + key[ii+2] = '2'; + FitsCard(c22).setKey(key); + } + if (c23) { + key[ii] = '2'; + key[ii+2] = '1'; + FitsCard(c23).setKey(key); + } + + if (c31) { + key[ii] = '1'; + key[ii+2] = '3'; + FitsCard(c31).setKey(key); + } + if (c32) { + key[ii] = '1'; + key[ii+2] = '2'; + FitsCard(c32).setKey(key); + } + if (c33) { + key[ii] = '1'; + key[ii+2] = '1'; + FitsCard(c33).setKey(key); + } + } + break; + } + + hdr->buildIndex(); +} + +void Context::resetIIS() +{ + frScale.setClipMode(FrScale::MINMAX); + frScale.setMinMaxMode(FrScale::SCAN); + frScale.setULow(DEFAULTLOW); + frScale.setUHigh(DEFAULTHIGH); + frScale.setColorScaleType(FrScale::LINEARSCALE); +} + +void Context::resetSecMode() +{ + frScale.resetSecMode(); + clearHist(); +} + +void Context::setAxesOrder(int order) +{ + switch (order) { + case 123: + case 132: + case 213: + case 231: + case 312: + case 321: + axesOrder_ = order; + break; + default: + axesOrder_ = 123; + break; + } + + if (bfits_) + loadFinish(); +} + +void Context::setBinFactor(const Vector& b) { + Vector bb = b; + binFactor_[0] *= bb[0] <= 0 ? 1 : bb[0]; + binFactor_[1] *= bb[1] <= 0 ? 1 : bb[1]; +} + +void Context::setBinToFactor(const Vector& b) { + Vector bb = b; + binFactor_[0] = bb[0] <= 0 ? 1 : bb[0]; + binFactor_[1] = bb[1] <= 0 ? 1 : bb[1]; +} + +Vector Context::setBlockFactor(const Vector& b) { + Vector bb = b; + Vector old = blockFactor_; + blockFactor_[0] *= bb[0] <= 0 ? 1 : bb[0]; + blockFactor_[1] *= bb[1] <= 0 ? 1 : bb[1]; + + return Vector(old[0]/blockFactor_[0],old[1]/blockFactor_[1]); +} + +Vector Context::setBlockToFactor(const Vector& b) { + Vector bb = b; + Vector old = blockFactor_; + blockFactor_[0] = bb[0] <= 0 ? 1 : bb[0]; + blockFactor_[1] = bb[1] <= 0 ? 1 : bb[1]; + + return Vector(old[0]/blockFactor_[0],old[1]/blockFactor_[1]); +} + +void Context::setCrop3dParams() +{ + // params is a BBOX in DATA coords 0-n + cparams = iparams; +} + +void Context::setCrop3dParams(double z0, double z1) +{ + // params is a BBOX in DATA coords 0-n + double zmin = z0; + double zmax = z1; + + // always have at least 1 + if (zmin+1>zmax) + zmax = z0+1; + + // round to int + cparams.set(int(zmin+.5), int(zmax+.5)); +} + +void Context::setCrop3dParams(int z0, int z1) +{ + // params is a BBOX in DATA coords 0-n + if (z0z1) + z1=z0+1; + } + + if (z1>iparams.zmax) { + z1=iparams.zmax; + if (z0+1>z1) + z0=z1-1; + } + + cparams.set(z0,z1); +} + +void Context::setIIS() +{ + frScale.setClipMode(FrScale::USERCLIP); + frScale.setMinMaxMode(FrScale::SCAN); + frScale.setULow(0); + frScale.setUHigh(IISSIZE); + frScale.setColorScaleType(FrScale::IISSCALE); +} + +void Context::setSecMode(FrScale::SecMode mode) +{ + frScale.setSecMode(mode); + clearHist(); +} + +void Context::unload() +{ + if (DebugPerf) + cerr << "Context::unload()" << endl; + + deleteFits(bfits_); + + if (manageAxes_) { + delete [] naxis_; + deleteFits(fits); + manageAxes_ =0; + } + + bfits_ =NULL; + fits =NULL; + cfits =NULL; + + loadInit(0, Base::NOMOSAIC, Coord::WCS); + + mask.deleteAll(); + + fvcontour_.lcontourlevel().deleteAll(); + auxcontours_.deleteAll(); + + resetSecMode(); + updateClip(); +} + +void Context::updateClip() +{ + if (DebugPerf) + cerr << "Context::updateClip()" << endl; + + updateClip(&frScale); +} + +void Context::updateClip(FrScale* fr) +{ + if (DebugPerf) + cerr << "Context::updateClip(FrScale*)" << endl; + + // no fits + if (!fits) { + if (fr->clipMode() != FrScale::USERCLIP) { + fr->setLow(DEFAULTLOW); + fr->setHigh(DEFAULTHIGH); + } + else { + fr->setLow(fr->ulow()); + fr->setHigh(fr->uhigh()); + } + + return; + } + + // find min/max + fr->setMin(DBL_MAX, Vector()); + fr->setMax(-DBL_MAX, Vector()); + fr->setLow(DBL_MAX); + fr->setHigh(-DBL_MAX); + + switch (fr->clipScope()) { + case FrScale::GLOBAL: + updateClipGlobal(fr); + break; + case FrScale::LOCAL: + updateClipLocal(fr); + break; + } + + if (DebugPerf) + cerr << *fr << endl; +} + +#ifdef __WIN32 + +void Context::updateClipGlobal(FrScale* fr) +{ + FitsImage* ptr = fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->updateClip(fr); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + + // set min/max low/high + ptr = fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + if (fr->min() > sptr->min()) + fr->setMin(sptr->min(), sptr->minXY()); + if (fr->max() < sptr->max()) + fr->setMax(sptr->max(), sptr->maxXY()); + + if (fr->low() > sptr->low()) + fr->setLow(sptr->low()); + if (fr->high() < sptr->high()) + fr->setHigh(sptr->high()); + + sptr = sptr->nextSlice(); + } + + ptr = ptr->nextMosaic(); + } + + // sanity check + if (fr->min() == DBL_MAX && fr->max() == -DBL_MAX) { + fr->setMin(NAN, Vector()); + fr->setMax(NAN, Vector()); + } + if (fr->low() == DBL_MAX && fr->high() == -DBL_MAX) { + fr->setLow(NAN); + fr->setHigh(NAN); + } + + ptr = fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->setClip(fr->low(), fr->high()); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } +} + +void Context::updateClipLocal(FrScale* fr) +{ + FitsImage* ptr = cfits; + while (ptr) { + ptr->updateClip(fr); + ptr = ptr->nextMosaic(); + } + + // set min/max low/high + ptr = cfits; + while (ptr) { + if (fr->min() > ptr->min()) + fr->setMin(ptr->min(), ptr->minXY()); + if (fr->max() < ptr->max()) + fr->setMax(ptr->max(), ptr->maxXY()); + + if (fr->low() > ptr->low()) + fr->setLow(ptr->low()); + if (fr->high() < ptr->high()) + fr->setHigh(ptr->high()); + + ptr = ptr->nextMosaic(); + } + + // sanity check + if (fr->min() == DBL_MAX && fr->max() == -DBL_MAX) { + fr->setMin(NAN, Vector()); + fr->setMax(NAN, Vector()); + } + if (fr->low() == DBL_MAX && fr->high() == -DBL_MAX) { + fr->setLow(NAN); + fr->setHigh(NAN); + } +} + +#else + +void Context::updateClipGlobal(FrScale* fr) +{ + if (thread_) + delete [] thread_; + thread_ = new pthread_t[parent_->nthreads_]; + t_clip_arg* targ = new t_clip_arg[parent_->nthreads_]; + + int cnt =0; + FitsImage* ptr = fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->updateClip(fr, &thread_[cnt], &targ[cnt]); + + cnt++; + if (cnt == parent_->nthreads_) { + for (int ii=0; iinextSlice(); + } + ptr = ptr->nextMosaic(); + } + + for (int ii=0; iimin() > sptr->min()) + fr->setMin(sptr->min(), sptr->minXY()); + if (fr->max() < sptr->max()) + fr->setMax(sptr->max(), sptr->maxXY()); + + if (fr->low() > sptr->low()) + fr->setLow(sptr->low()); + if (fr->high() < sptr->high()) + fr->setHigh(sptr->high()); + + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + + // sanity check + if (fr->min() == DBL_MAX && fr->max() == -DBL_MAX) { + fr->setMin(NAN, Vector()); + fr->setMax(NAN, Vector()); + } + if (fr->low() == DBL_MAX && fr->high() == -DBL_MAX) { + fr->setLow(NAN); + fr->setHigh(NAN); + } + + ptr = fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->setClip(fr->low(), fr->high()); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } +} + +void Context::updateClipLocal(FrScale* fr) +{ + if (thread_) + delete [] thread_; + thread_ = new pthread_t[parent_->nthreads_]; + t_clip_arg* targ = new t_clip_arg[parent_->nthreads_]; + + int cnt =0; + FitsImage* ptr = cfits; + while (ptr) { + ptr->updateClip(fr, &thread_[cnt], &targ[cnt]); + + cnt++; + if (cnt == parent_->nthreads_) { + for (int ii=0; iinextMosaic(); + } + + for (int ii=0; iimin() > ptr->min()) + fr->setMin(ptr->min(), ptr->minXY()); + if (fr->max() < ptr->max()) + fr->setMax(ptr->max(), ptr->maxXY()); + + if (fr->low() > ptr->low()) + fr->setLow(ptr->low()); + if (fr->high() < ptr->high()) + fr->setHigh(ptr->high()); + + ptr = ptr->nextMosaic(); + } + + // sanity check + if (fr->min() == DBL_MAX && fr->max() == -DBL_MAX) { + fr->setMin(NAN, Vector()); + fr->setMax(NAN, Vector()); + } + if (fr->low() == DBL_MAX && fr->high() == -DBL_MAX) { + fr->setLow(NAN); + fr->setHigh(NAN); + } +} + +#endif + +void Context::updateContours() +{ + fvcontour_.update(cfits); +} + +void Context::updateContoursScale() +{ + fvcontour_.update(cfits,&frScale); +} + +void Context::updateContours(const Matrix& mx) +{ + if (!cfits) + return; + + // aux contours + if (auxcontours_.head()) + do + auxcontours_.current()->updateCoords(mx); + while (auxcontours_.next()); + + List& cc = fvcontour_.lcontourlevel(); + if (cc.head()) + do + cc.current()->updateCoords(mx); + while (cc.next()); +} + +void Context::updateSlice(int id, int ss) +{ + // ranges 1-n + if (!fits) + return; + + // check bounds + if (ss<1) + ss = 1; + else if (ss>naxis_[id]) + ss = naxis_[id]; + + slice_[id] = ss; + + int cnt =slice_[2]; + for (int jj=3; jjnextSlice(); +} + +int Context::updateClipScope(FrScale::ClipScope ss) +{ + if (frScale.clipScope() != ss) { + frScale.setClipScope(ss); + return 1; + } + return 0; +} + +int Context::updateClipMode(FrScale::ClipMode mm) +{ + if (frScale.clipMode() != mm) { + frScale.setClipMode(mm); + return 1; + } + return 0; +} + +int Context::updateClipMode(float per) +{ + if (per == 100) + return updateClipMode(FrScale::MINMAX); + else { + if (frScale.clipMode() != FrScale::AUTOCUT || frScale.autoCutPer() != per) { + frScale.setClipMode(FrScale::AUTOCUT); + frScale.setAutoCutPer(per); + return 1; + } + } + return 0; +} + +int Context::updateMinMax(FrScale::MinMaxMode mm, int ss) +{ + if (frScale.minmaxMode() != mm || frScale.minmaxSample() != ss) { + frScale.setMinMaxMode(mm); + frScale.setMinMaxSample(ss); + return 1; + } + return 0; +} + +// backward compatibility backup +int Context::updateMinMaxMode(FrScale::MinMaxMode mm) +{ + if (frScale.minmaxMode() != mm) { + frScale.setMinMaxMode(mm); + return 1; + } + return 0; +} + +// backward compatibility backup +int Context::updateMinMaxSample(int ss) +{ + if (frScale.minmaxSample() != ss) { + frScale.setMinMaxSample(ss); + return 1; + } + return 0; +} + +int Context::updateUser(float ll, float hh) +{ + if (frScale.ulow() != ll || frScale.uhigh() != hh) { + frScale.setULow(ll); + frScale.setUHigh(hh); + return 1; + } + return 0; +} + +int Context::updateZscale(float cc, int ss, int ll) +{ + if (frScale.zContrast() != cc || + frScale.zSample() != ss || + frScale.zLine() != ll) { + frScale.setZContrast(cc); + frScale.setZSample(ss); + frScale.setZLine(ll); + return 1; + } + return 0; +} + +// backward compatibility backup +int Context::updateZscaleContrast(float cc) +{ + if (frScale.zContrast() != cc) { + frScale.setZContrast(cc); + return 1; + } + return 0; +} + +// backward compatibility backup +int Context::updateZscaleSample(int ss) +{ + if (frScale.zSample() != ss) { + frScale.setZSample(ss); + return 1; + } + return 0; +} + +// backward compatibility backup +int Context::updateZscaleLine(int ll) +{ + if (frScale.zLine() != ll) { + frScale.setZLine(ll); + return 1; + } + return 0; +} + +int Context::updateDataSec(int ii) +{ + if (frScale.datasec() != ii) { + frScale.setDataSec(ii); + return 1; + } + return 0; +} + +int Context::updateExpo(double exp) +{ + if (frScale.expo() != exp) { + frScale.setExpo(exp); + return 1; + } + return 0; +} diff --git a/tksao/frame/context.h b/tksao/frame/context.h new file mode 100644 index 0000000..d03bfa1 --- /dev/null +++ b/tksao/frame/context.h @@ -0,0 +1,273 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __context_h__ +#define __context_h__ + +#ifndef __WIN32 +#include +#endif + +#include "base.h" +#include "colorscale.h" +#include "coord.h" +#include "frscale.h" +#include "list.h" +#include "fitsmask.h" +#include "fitsimage.h" +#include "head.h" + +class FVContour; + +class FitsZBound { + public: + int zmin; + int zmax; + + public: + FitsZBound() {zmin= zmax=0;} + FitsZBound(int z0, int z1) {zmin=z0; zmax=z1;} + FitsZBound(const FitsZBound &bb) {zmin=bb.zmin; zmax=bb.zmax;} + void set(int z0, int z1) {zmin=z0; zmax=z1;} +}; +ostream& operator<<(ostream&, const FitsZBound&); + +class Context { + public: + enum SmoothFunction {BOXCAR, TOPHAT, GAUSSIAN}; + + protected: + Base* parent_; + + FrScale frScale; + + int shareWCS_; + + int manageAxes_; + int axesOrder_; + + int baxis_[FTY_MAXAXES]; // the first two are ignored + int* naxis_; // the first two are ignored + int slice_[FTY_MAXAXES]; // the first two are ignored + + int mosaicCount_; + Base::MosaicType mosaicType; + Coord::CoordSystem mosaicSystem; + + FitsHist::Function binFunction_; + Vector binFactor_; + int binBufferSize_; + int binDepth_; + + Vector blockFactor_; + + int doSmooth_; + SmoothFunction smoothFunction_; + int smoothRadius_; + + FitsZBound iparams; // image bbox + FitsZBound cparams; // crop bbox + + FVContour fvcontour_; + List auxcontours_; + + protected: + void binFinish(); + int blockMask(); + int nhdu(); + void loadFinishMask(); + void loadFinishMosaic(FitsImage*); + int loadFinishMosaicMask(); + int processMosaicKeywords(FitsImage*); + void updateClip(FrScale*); + void updateClipGlobal(FrScale*); + void updateClipLocal(FrScale*); + + void contourList(ostream&, Coord::CoordSystem, Coord::SkyFrame, + List&); + + void reorderAxis(char*, char**, int, int, int, size_t); +#ifndef __WIN32 + void reorderThread(void*, char*, void* (void*), int*); +#endif + +#ifndef __WIN32 + pthread_t* thread_; +#endif + + public: + FitsImage* bfits_; + FitsImage* fits; + FitsImage* cfits; + + List mask; + + public: + Context(); + ~Context(); + + FVContour& fvcontour() {return fvcontour_;} + List& auxcontours() {return auxcontours_;} + + void analysis(); + int axesOrder() {return axesOrder_;} + + Matrix bin(const Vector&); + Matrix binCenter(); + Matrix binCursor(); + + int block(); + void bltHist(char*, char*, int); + + int calcSlice(); + void contourAppendAux(ContourLevel*); + void contourCreateFV(const char* color, int width, int dash, + FVContour::Method method, int numlevel, + int smooth, + FrScale::ColorScaleType colorScaleType, + float expo, + float clipMode, Vector limits, + const char* level); + void contourDeleteFV(); + void contourDeleteAux(); + void contourListFV(ostream&, Coord::CoordSystem, Coord::SkyFrame); + void contourListAux(ostream&, Coord::CoordSystem, Coord::SkyFrame); + void contourLoadAux(istream&); + void contourLoadAux(istream&, const char*, int, int); + void contourLoadAux(istream&, Coord::CoordSystem, Coord::SkyFrame, + const char*, int, int); + void contourPS(Widget::PSColorSpace cs); + void contourX11(Pixmap, Coord::InternalSystem, int, int); +#ifdef MAC_OSX_TK + void contourMacOSX(); +#endif +#ifdef __WIN32 + void contourWin32(); +#endif + + void deleteFits(FitsImage*); + + int fitsCount(); + + Vector getClip(FrScale::ClipMode, float); + Vector getClip(); + FitsZBound* getDataParams(FrScale::SecMode); // return bbox in IMAGE + Vector getMinMax(); + + int hasContour() {return !fvcontour_.isEmpty();} + int hasContourAux() {return !auxcontours_.isEmpty();} + double* histequ() {return frScale.histequ(fits);} + + Coord::Orientation IRAFOrientation(Coord::Orientation oo) + {return parent_->IRAFOrientation(oo);} + int isMosaic() {return mosaicCount_>1 ? 1 : 0;} + int isCube() {return nhdu()>1 ? 1 : 0;} + + int load(Base::MemType, const char*, FitsImage*, Base::LayerType); + int loadExtCube(Base::MemType, const char*, FitsImage*); + int loadSlice(Base::MemType, const char*, FitsImage*); + int loadMosaic(Base::MemType, const char*, FitsImage*, + Base::LayerType, Base::MosaicType, Coord::CoordSystem); + int loadMosaicImage(Base::MemType, const char*, FitsImage*, + Base::LayerType, Base::MosaicType, Coord::CoordSystem); + int loadMosaicWFPC2(Base::MemType, const char*, FitsImage*); + void loadInit(int, Base::MosaicType, Coord::CoordSystem); + int loadFinish(); + + int naxis(int ii) {return naxis_[ii];} + int naxes(); + int nthreads() {return parent_->nthreads_;} + + void parent(Base* pp) {parent_ = pp;} + + void reorderAxes(); + void reorderWCSi(FitsHead*, char*, int, char); + void reorderWCSij(FitsHead*, char*, int, char); + void resetSecMode(); + + int slice(int ii) {return slice_[ii];} + + void setAxesOrder(int); + void setBinFunction(FitsHist::Function f) {binFunction_ = f;} + void setBinFactor(const Vector&); + void setBinToFactor(const Vector&); + void setBinBufferSize(int s) {binBufferSize_ = s;} + void setBinDepth(int d) {binDepth_ = d < 1 ? 1 : d;} + FitsHist::Function binFunction() {return binFunction_;} + Vector binFactor() {return binFactor_;} + int binBufferSize() {return binBufferSize_;} + int binDepth() {return binDepth_;} + + Vector setBlockFactor(const Vector&); + Vector setBlockToFactor(const Vector&); + const Vector& blockFactor() {return blockFactor_;} + + void setCrop3dParams(); + void setCrop3dParams(int,int); + void setCrop3dParams(double, double); + + void setIIS(); + void resetIIS(); + + void setSmooth(int ss) {doSmooth_ =ss;} + void setSmooth(int ss, SmoothFunction ff, int rr) + {doSmooth_=ss; smoothFunction_=ff; smoothRadius_=rr;} + int hasSmooth() {return doSmooth_;} + SmoothFunction smoothFunction() {return smoothFunction_;} + int smoothRadius() {return smoothRadius_;} + + int shareWCS() {return shareWCS_;} + + void unload(); + void updateBinFileNames(); + void clearHist(); + void updateClip(); + void updateContours(); + void updateContours(const Matrix&); + void updateContoursScale(); + void updateSlice(int, int); + + int updateClipScope(FrScale::ClipScope); + int updateClipMode(FrScale::ClipMode); + int updateClipMode(float); + int updateMinMax(FrScale::MinMaxMode, int); + // backward compatibility backup + int updateMinMaxMode(FrScale::MinMaxMode); + // backward compatibility backup + int updateMinMaxSample(int); + int updateUser(float,float); + int updateZscale(float, int, int); + // backward compatibility backup + int updateZscaleContrast(float); + // backward compatibility backup + int updateZscaleSample(int); + // backward compatibility backup + int updateZscaleLine(int); + int updateDataSec(int); + int updateExpo(double); + + FrScale::ColorScaleType colorScaleType() {return frScale.colorScaleType();} + FrScale::ClipScope clipScope() {return frScale.clipScope();} + FrScale::ClipMode clipMode() {return frScale.clipMode();} + int datasec() {return frScale.datasec();} + float expo() {return frScale.expo();} + double low() {return frScale.low();} + double high() {return frScale.high();} + int minmaxSample() {return frScale.minmaxSample();} + FrScale::MinMaxMode minmaxMode() {return frScale.minmaxMode();} + FrScale::SecMode secMode() {return frScale.secMode();} + float autoCutPer() {return frScale.autoCutPer();} + float zContrast() {return frScale.zContrast();} + int zSample() {return frScale.zSample();} + int zLine() {return frScale.zLine();} + Vector clipUser() {return Vector(frScale.ulow(), frScale.uhigh());} + + void setClipScope(FrScale::ClipScope ss) {frScale.setClipScope(ss);} + void setColorScaleType(FrScale::ColorScaleType tt) + {frScale.setColorScaleType(tt);} + void setSecMode(FrScale::SecMode); + +}; + +#endif diff --git a/tksao/frame/contour.C b/tksao/frame/contour.C new file mode 100644 index 0000000..d533ef9 --- /dev/null +++ b/tksao/frame/contour.C @@ -0,0 +1,298 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "contour.h" +#include "base.h" +#include "context.h" + +// ContourLevel +ContourLevel::ContourLevel(Base* pp, double lev, const char* cc, int ww, + int dd, int* dl) +{ + parent_ = pp; + gc_ = parent_->contourGC; + + level_ = lev; + colorName_ = dupstr(cc); + color_ = parent_->getColor(colorName_); + lineWidth_ = ww; + dash_ = dd; + dlist_[0] = dl[0]; + dlist_[1] = dl[1]; + + previous_ = NULL; + next_ = NULL; +} + +ContourLevel::~ContourLevel() +{ + if (colorName_) + delete [] colorName_; +} + +void ContourLevel::list(ostream& str, FitsImage* fits, + Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + if (lcontour_.head()) { + str << "level=" << level_ << ' '; + if (strncmp("green", colorName_, 5) || dash_ != 0 || + dlist_[0] != 8 || dlist_[1] != 3 || lineWidth_ != 1) { + if (strncmp("green", colorName_, 5)) + str << "color=" << colorName_ << ' '; + + if (lineWidth_ != 1) + str << "width=" << lineWidth_ << ' '; + + if (dash_ != 0) + str << "dash=" << dash_ << ' '; + + if (dlist_[0] != 8 || dlist_[1] != 3) + str << "dashlist=" << dlist_[0] << ' ' << dlist_[1] << ' '; + } + str << endl; + + do + lcontour_.current()->list(str, fits, sys, sky); + while (lcontour_.next()); + } +} + +void ContourLevel::render(Pixmap pmap, Coord::InternalSystem sys, + int width, int height) +{ + if (lcontour_.head()) { + do + lcontour_.current()->render(pmap, sys, width, height); + while (lcontour_.next()); + } +} + +void ContourLevel::ps(int mode) +{ + if (lcontour_.head()) { + do + lcontour_.current()->ps(mode); + while (lcontour_.next()); + } +} + +void ContourLevel::updateCoords(const Matrix& mx) +{ + if (lcontour_.head()) { + do + lcontour_.current()->updateCoords(mx); + while (lcontour_.next()); + } +} + +void ContourLevel::setColor(const char* clr) +{ + if (colorName_) + delete [] colorName_; + + colorName_ = dupstr(clr); + color_ = parent_->getColor(colorName_); +} + +#ifdef MAC_OSX_TK +void ContourLevel::macosx() +{ + if (lcontour_.head()) { + do + lcontour_.current()->macosx(); + while (lcontour_.next()); + } +} +#endif + +#ifdef __WIN32 +void ContourLevel::win32() +{ + if (lcontour_.head()) { + do + lcontour_.current()->win32(); + while (lcontour_.next()); + } +} +#endif + +// Contour + +Contour::Contour(ContourLevel* cc) +{ + parent_ = cc; + base_ = cc->parent_; + + previous_ = NULL; + next_ = NULL; +} + +Contour::~Contour() +{ +} + +void Contour::list(ostream& str, FitsImage* fits, + Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + if (lvertex_.head()) + str << '(' << endl; + do { + str << ' '; + fits->listFromRef(str, lvertex_.current()->vector, sys, sky, Coord::DEGREES); + str << endl; + } + while (lvertex_.next()); + str << ')' << endl; +} + +void Contour::render(Pixmap pmap, Coord::InternalSystem sys, + int width, int height) +{ + if (lvertex_.head()) { + XSetForeground(base_->display, parent_->gc_, parent_->color_); + int ww = parent_->lineWidth_>=1 ? parent_->lineWidth_ : 1; + + if (!parent_->dash_) + XSetLineAttributes(base_->display, parent_->gc_, + ww, LineSolid, CapButt, JoinMiter); + else { + char dl[2]; + dl[0] = parent_->dlist_[0]; + dl[1] = parent_->dlist_[1]; + + XSetDashes(base_->display, parent_->gc_, 0, dl, 2); + XSetLineAttributes(base_->display, parent_->gc_, + ww, LineOnOffDash, CapButt, JoinMiter); + } + + BBox bb = BBox(0, 0, width, height); + + Vector u1 = lvertex_.current()->vector; + while (lvertex_.next()) { + Vector u2 = lvertex_.current()->vector; + + Vector v1 = base_->mapFromRef(u1,sys); + Vector v2 = base_->mapFromRef(u2,sys); + if (bb.isIn(v1) || bb.isIn(v2)) + XDrawLine(base_->display, pmap, parent_->gc_, + (int)v1[0], (int)v1[1], (int)v2[0], (int)v2[1]); + + u1 = u2; + } + } +} + +void Contour::ps(int mode) +{ + if (!lvertex_.head()) + return; + + ostringstream str; + + switch ((Widget::PSColorSpace)mode) { + case Widget::BW: + case Widget::GRAY: + psColorGray(base_->getXColor(parent_->colorName_), str); + str << " setgray"; + break; + case Widget::RGB: + psColorRGB(base_->getXColor(parent_->colorName_), str); + str << " setrgbcolor"; + break; + case Widget::CMYK: + psColorCMYK(base_->getXColor(parent_->colorName_), str); + str << " setcmykcolor"; + break; + } + str << endl; + + if (!parent_->dash_) + str << parent_->lineWidth_ << " setlinewidth" << endl << "[] 0 setdash"; + else { + str << parent_->lineWidth_ << " setlinewidth" << endl + << '[' << parent_->dlist_[0] << ' ' << parent_->dlist_[1] + << "] 0 setdash"; + } + str << endl; + + Vector v1 = base_->mapFromRef(lvertex_.current()->vector,Coord::CANVAS); + str << "newpath " << endl + << v1.TkCanvasPs(base_->canvas) << " moveto" << endl; + while (lvertex_.next()) { + Vector vv = base_->mapFromRef(lvertex_.current()->vector,Coord::CANVAS); + str << vv.TkCanvasPs(base_->canvas) << " lineto" << endl; + } + str << "stroke" << endl << ends; + Tcl_AppendResult(base_->interp, str.str().c_str(), NULL); +} + +void Contour::updateCoords(const Matrix& mx) +{ + if (lvertex_.head()) { + do { + Vector& vv = lvertex_.current()->vector; + vv *= mx; + } + while (lvertex_.next()); + } +} + +#ifdef MAC_OSX_TK +void Contour::macosx() +{ + if (lvertex_.head()) { + macosxColor(base_->getXColor(parent_->colorName_)); + macosxWidth(parent_->lineWidth_); + if (parent_->dash_) { + float dl[2]; + dl[0] = parent_->dlist_[0]; + dl[1] = parent_->dlist_[1]; + macosxDash(dl,2); + } + else + macosxDash(NULL,0); + + Vector u1 = lvertex_.current()->vector; + while (lvertex_.next()) { + Vector u2 = lvertex_.current()->vector; + + Vector v1 = base_->mapFromRef(u1,Coord::CANVAS); + Vector v2 = base_->mapFromRef(u2,Coord::CANVAS); + macosxDrawLine(v1,v2); + + u1 = u2; + } + } +} +#endif + +#ifdef __WIN32 +void Contour::win32() +{ + if (lvertex_.head()) { + win32Color(base_->getXColor(parent_->colorName_)); + win32Width(parent_->lineWidth_); + if (parent_->dash_) { + float dl[2]; + dl[0] = parent_->dlist_[0]; + dl[1] = parent_->dlist_[1]; + win32Dash(dl,2); + } + else + win32Dash(NULL,0); + + Vector u1 = lvertex_.current()->vector; + while (lvertex_.next()) { + Vector u2 = lvertex_.current()->vector; + + Vector v1 = base_->mapFromRef(u1,Coord::CANVAS); + Vector v2 = base_->mapFromRef(u2,Coord::CANVAS); + win32DrawLine(v1,v2); + + u1 = u2; + } + } +} +#endif + diff --git a/tksao/frame/contour.h b/tksao/frame/contour.h new file mode 100644 index 0000000..853ab22 --- /dev/null +++ b/tksao/frame/contour.h @@ -0,0 +1,103 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __contour_h__ +#define __contour_h__ + +#include +#include + +#include "vector.h" +#include "vector3d.h" +#include "list.h" +#include "coord.h" + +class FitsImage; +class Base; +class Contour; + +class ContourLevel { + friend class Contour; + + protected: + Base* parent_; + List lcontour_; + + double level_; + char* colorName_; + unsigned long color_; + int lineWidth_; + int dash_; + int dlist_[2]; + + GC gc_; + + ContourLevel* previous_; + ContourLevel* next_; + + public: + ContourLevel(Base*, double, const char*, int, int, int*); + virtual ~ContourLevel(); + + List& lcontour() {return lcontour_;} + + void list(ostream& str, FitsImage*, Coord::CoordSystem, Coord::SkyFrame); + void render(Pixmap, Coord::InternalSystem, int, int); + void ps(int); + void updateCoords(const Matrix&); +#ifdef MAC_OSX_TK + void macosx(); +#endif +#ifdef __WIN32 + void win32(); +#endif + + double level() {return level_;} + + const char* colorName() {return colorName_;} + void setColor(const char*); + int dash() {return dash_;} + void setDash(int dd) {dash_ =dd;} + int lineWidth() {return lineWidth_;} + void setLineWidth(int ww) {lineWidth_ =ww;} + + ContourLevel* previous() {return previous_;} + void setPrevious(ContourLevel* m) {previous_ = m;} + ContourLevel* next() {return next_;} + void setNext(ContourLevel* m) {next_ = m;} +}; + +class Contour { + protected: + ContourLevel* parent_; + Base* base_; + List lvertex_; + + Contour* previous_; + Contour* next_; + + public: + Contour(ContourLevel*); + ~Contour(); + + List& lvertex() {return lvertex_;} + + void list(ostream& str, FitsImage*, Coord::CoordSystem, Coord::SkyFrame); + void render(Pixmap, Coord::InternalSystem, int, int); + void ps(int); + void updateCoords(const Matrix&); +#ifdef MAC_OSX_TK + void macosx(); +#endif +#ifdef __WIN32 + void win32(); +#endif + + Contour* previous() {return previous_;} + void setPrevious(Contour* m) {previous_ = m;} + Contour* next() {return next_;} + void setNext(Contour* m) {next_ = m;} +}; + +#endif diff --git a/tksao/frame/contourlex.C b/tksao/frame/contourlex.C new file mode 100644 index 0000000..c936ed4 --- /dev/null +++ b/tksao/frame/contourlex.C @@ -0,0 +1,2449 @@ +#line 2 "frame/contourlex.C" + +#line 4 "frame/contourlex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer ctFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *ctalloc (yy_size_t ); +void *ctrealloc (void *,yy_size_t ); +void ctfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 89 +#define YY_END_OF_BUFFER 90 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[283] = + { 0, + 0, 0, 2, 2, 90, 88, 84, 87, 88, 88, + 88, 88, 88, 88, 62, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 24, 83, 83, + 83, 83, 83, 83, 60, 88, 88, 2, 1, 84, + 85, 0, 80, 0, 0, 81, 0, 62, 64, 63, + 62, 0, 83, 65, 83, 83, 69, 67, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 25, 83, 27, 83, 83, 83, + 83, 83, 83, 83, 86, 0, 82, 2, 0, 65, + 0, 0, 69, 67, 66, 0, 70, 68, 65, 0, + + 83, 0, 63, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 12, 14, 83, 83, 83, 83, 83, 83, + 83, 83, 26, 83, 83, 83, 83, 32, 83, 61, + 77, 0, 63, 0, 0, 64, 0, 83, 83, 83, + 83, 83, 6, 83, 83, 83, 83, 0, 83, 83, + 83, 18, 83, 83, 83, 83, 83, 83, 30, 83, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 83, 0, 0, 0, + 0, 71, 0, 83, 0, 83, 83, 4, 5, 83, + + 8, 83, 83, 11, 0, 83, 83, 83, 19, 20, + 21, 83, 83, 83, 83, 59, 0, 0, 0, 72, + 71, 0, 0, 75, 0, 0, 73, 83, 83, 83, + 83, 0, 83, 16, 83, 22, 23, 83, 83, 83, + 78, 75, 73, 76, 74, 83, 83, 83, 83, 0, + 83, 83, 83, 83, 31, 0, 83, 7, 9, 10, + 13, 15, 83, 28, 83, 0, 3, 83, 83, 0, + 83, 83, 0, 83, 83, 0, 83, 83, 79, 17, + 29, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 5, 6, 1, 1, 1, 7, 1, + 1, 1, 8, 1, 9, 10, 1, 11, 12, 13, + 14, 15, 16, 14, 14, 14, 17, 18, 1, 1, + 1, 1, 1, 1, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 1, 45, 1, 1, 1, 1, 46, 47, 48, 49, + + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 1, 73, 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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[74] = + { 0, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, + 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, + 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 1, 4, 4, 4, 4, 4, + 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[301] = + { 0, + 0, 0, 330, 327, 323, 1369, 306, 1369, 303, 280, + 0, 265, 64, 71, 79, 89, 98, 93, 99, 94, + 117, 120, 133, 113, 142, 144, 147, 149, 154, 158, + 169, 170, 171, 175, 180, 66, 197, 0, 1369, 266, + 1369, 253, 1369, 0, 250, 1369, 203, 226, 277, 328, + 380, 250, 181, 302, 434, 353, 182, 194, 216, 214, + 241, 237, 287, 292, 318, 268, 343, 236, 369, 311, + 263, 370, 391, 395, 285, 414, 314, 394, 401, 400, + 443, 418, 336, 449, 1369, 183, 1369, 0, 0, 457, + 476, 483, 1369, 1369, 1369, 503, 1369, 1369, 1369, 510, + + 519, 527, 541, 568, 557, 405, 555, 550, 551, 579, + 582, 554, 407, 366, 552, 586, 583, 595, 598, 465, + 601, 602, 491, 612, 617, 621, 624, 678, 556, 492, + 0, 739, 666, 746, 767, 774, 795, 803, 812, 821, + 635, 822, 823, 644, 637, 825, 824, 82, 754, 638, + 827, 650, 826, 654, 836, 755, 845, 846, 656, 851, + 758, 782, 785, 847, 852, 861, 863, 873, 874, 878, + 879, 880, 884, 885, 890, 894, 896, 897, 900, 901, + 903, 906, 907, 910, 912, 913, 916, 0, 933, 941, + 924, 949, 959, 967, 975, 1022, 990, 983, 984, 988, + + 985, 987, 989, 999, 88, 1006, 1000, 1003, 1001, 1002, + 1033, 1037, 1040, 1038, 1050, 1054, 0, 1064, 1092, 1100, + 1107, 1120, 1127, 1074, 1134, 1162, 1075, 1142, 1143, 1148, + 1175, 236, 1176, 1077, 1144, 1081, 1145, 1149, 1187, 1172, + 0, 1369, 1369, 1369, 1369, 1191, 1200, 1201, 1202, 172, + 1203, 1217, 1218, 1222, 1207, 0, 1224, 1235, 1236, 1239, + 1369, 1245, 1249, 1248, 1251, 0, 1262, 1267, 1263, 0, + 1268, 1272, 0, 1273, 1278, 0, 1294, 1298, 1369, 1284, + 1289, 1369, 1346, 1350, 224, 1354, 1356, 1360, 1364, 223, + 221, 206, 203, 171, 165, 154, 133, 120, 115, 96 + + } ; + +static yyconst flex_int16_t yy_def[301] = + { 0, + 282, 1, 283, 283, 282, 282, 282, 282, 282, 284, + 285, 286, 282, 282, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 282, 288, 289, 282, 282, + 282, 284, 282, 290, 286, 282, 282, 282, 282, 282, + 287, 282, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 282, 288, 282, 289, 291, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + + 287, 282, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 282, 287, 287, + 292, 282, 282, 282, 282, 282, 282, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 282, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 293, 282, 282, + 282, 282, 282, 287, 282, 287, 287, 287, 287, 287, + + 287, 287, 287, 287, 282, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 294, 282, 282, 282, + 282, 282, 282, 287, 282, 282, 287, 287, 287, 287, + 287, 282, 287, 287, 287, 287, 287, 287, 287, 287, + 295, 282, 282, 282, 282, 287, 287, 287, 287, 282, + 287, 287, 287, 287, 287, 296, 287, 287, 287, 287, + 282, 287, 287, 287, 287, 297, 287, 287, 287, 298, + 287, 287, 299, 287, 287, 300, 287, 287, 282, 287, + 287, 0, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282 + + } ; + +static yyconst flex_int16_t yy_nxt[1443] = + { 0, + 6, 7, 8, 9, 10, 11, 12, 13, 13, 14, + 15, 15, 15, 15, 15, 15, 15, 6, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 26, 28, 29, 30, 26, 26, 31, 32, 26, 33, + 34, 26, 35, 26, 36, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 26, 28, 29, + 30, 26, 26, 31, 32, 26, 33, 34, 26, 35, + 26, 37, 6, 47, 48, 48, 48, 48, 48, 48, + 48, 49, 49, 49, 49, 49, 49, 49, 50, 51, + 51, 51, 51, 51, 51, 51, 52, 85, 282, 279, + + 54, 55, 282, 282, 56, 57, 282, 282, 282, 60, + 282, 282, 58, 205, 64, 282, 282, 62, 276, 59, + 232, 63, 282, 273, 85, 61, 282, 54, 55, 282, + 282, 56, 57, 70, 282, 65, 270, 282, 67, 58, + 205, 64, 282, 71, 62, 66, 59, 232, 63, 68, + 282, 282, 61, 282, 72, 69, 282, 266, 282, 282, + 70, 282, 65, 282, 282, 67, 282, 282, 256, 73, + 71, 282, 66, 74, 241, 282, 68, 76, 282, 282, + 282, 75, 69, 78, 282, 77, 282, 282, 282, 282, + 282, 282, 282, 81, 261, 82, 73, 282, 282, 282, + + 74, 83, 84, 282, 76, 80, 217, 79, 75, 188, + 78, 282, 77, 49, 49, 49, 49, 49, 49, 49, + 81, 261, 82, 282, 131, 282, 89, 44, 83, 84, + 106, 282, 80, 282, 79, 50, 48, 48, 48, 48, + 48, 48, 48, 52, 250, 282, 282, 90, 91, 105, + 282, 92, 93, 282, 282, 87, 46, 43, 282, 94, + 100, 100, 100, 100, 100, 100, 100, 40, 116, 87, + 107, 46, 282, 108, 90, 91, 105, 282, 92, 93, + 282, 119, 113, 114, 43, 282, 94, 49, 49, 49, + 49, 49, 49, 49, 282, 116, 282, 107, 95, 96, + + 108, 282, 282, 97, 282, 41, 109, 40, 119, 282, + 98, 282, 101, 101, 101, 101, 101, 101, 101, 282, + 282, 111, 282, 282, 110, 95, 96, 282, 282, 39, + 97, 282, 39, 109, 282, 282, 282, 98, 49, 49, + 49, 49, 49, 49, 49, 282, 118, 112, 111, 99, + 91, 110, 282, 282, 93, 282, 282, 129, 282, 282, + 282, 94, 282, 104, 104, 104, 104, 104, 104, 104, + 282, 282, 115, 118, 112, 282, 99, 91, 282, 282, + 120, 93, 282, 282, 129, 282, 282, 282, 94, 50, + 51, 51, 51, 51, 51, 51, 51, 52, 117, 115, + + 282, 54, 55, 282, 282, 56, 57, 282, 282, 282, + 282, 282, 282, 58, 282, 148, 282, 282, 282, 282, + 141, 282, 282, 282, 282, 117, 122, 282, 54, 55, + 121, 282, 56, 57, 125, 282, 124, 123, 126, 282, + 58, 102, 102, 282, 103, 103, 103, 103, 103, 103, + 103, 282, 282, 122, 128, 282, 282, 121, 282, 282, + 282, 125, 282, 124, 123, 126, 282, 132, 132, 132, + 132, 132, 132, 132, 282, 154, 282, 282, 127, 282, + 282, 128, 282, 102, 102, 130, 133, 133, 133, 133, + 133, 133, 133, 134, 134, 134, 134, 134, 134, 134, + + 282, 282, 282, 282, 282, 127, 282, 282, 282, 282, + 135, 135, 130, 136, 136, 136, 136, 136, 136, 136, + 100, 100, 100, 100, 100, 100, 100, 137, 282, 101, + 101, 101, 101, 101, 101, 101, 282, 133, 133, 133, + 133, 133, 133, 133, 282, 282, 282, 282, 282, 138, + 282, 103, 103, 103, 103, 103, 103, 103, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 149, 282, 282, 282, 282, 143, 138, 282, 104, 104, + 104, 104, 104, 104, 104, 282, 140, 142, 282, 144, + 147, 282, 282, 187, 282, 282, 282, 149, 139, 282, + + 282, 145, 143, 282, 282, 150, 282, 282, 146, 151, + 282, 282, 282, 140, 142, 282, 144, 147, 282, 282, + 187, 282, 153, 155, 156, 139, 282, 282, 145, 282, + 282, 152, 150, 282, 282, 146, 151, 282, 282, 158, + 282, 282, 282, 159, 282, 198, 282, 282, 157, 153, + 155, 156, 282, 282, 282, 282, 207, 202, 152, 282, + 160, 282, 282, 282, 210, 282, 158, 282, 201, 282, + 159, 282, 282, 282, 282, 157, 133, 133, 133, 133, + 133, 133, 133, 207, 202, 282, 282, 160, 53, 53, + 53, 53, 53, 53, 53, 201, 161, 162, 163, 164, + + 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, + 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, + 185, 186, 282, 161, 162, 163, 164, 165, 166, 167, + 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, + 178, 179, 180, 181, 182, 183, 184, 185, 186, 132, + 132, 132, 132, 132, 132, 132, 134, 134, 134, 134, + 134, 134, 134, 282, 282, 282, 282, 282, 282, 189, + 282, 282, 282, 212, 206, 282, 190, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 282, 282, 282, 282, 282, 189, 282, 282, 282, + + 212, 206, 282, 190, 191, 192, 192, 192, 192, 192, + 192, 192, 193, 194, 194, 194, 194, 194, 194, 194, + 282, 195, 196, 196, 196, 196, 196, 196, 196, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 204, 197, 209, 282, + 282, 282, 200, 282, 282, 282, 282, 199, 203, 208, + 282, 282, 282, 282, 282, 211, 282, 282, 282, 282, + 282, 213, 282, 204, 197, 209, 282, 215, 282, 200, + 282, 214, 282, 282, 199, 203, 208, 282, 282, 282, + 282, 282, 211, 282, 282, 282, 282, 282, 213, 282, + + 282, 282, 282, 282, 215, 282, 282, 282, 214, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 220, 220, 220, 220, 220, 220, + 220, 216, 193, 218, 218, 218, 218, 218, 218, 218, + 195, 219, 219, 219, 219, 219, 219, 219, 221, 192, + 192, 192, 192, 192, 192, 192, 282, 282, 216, 222, + 222, 222, 222, 222, 222, 222, 223, 194, 194, 194, + 194, 194, 194, 194, 282, 225, 225, 225, 225, 225, + 225, 225, 282, 282, 282, 282, 282, 282, 282, 282, + + 282, 282, 282, 224, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 228, 229, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 230, 235, 231, 282, 282, 234, + 224, 226, 196, 196, 196, 196, 196, 196, 196, 282, + 228, 229, 282, 233, 282, 282, 282, 282, 282, 282, + 282, 230, 235, 231, 282, 282, 234, 282, 227, 282, + 238, 282, 239, 282, 282, 282, 282, 282, 282, 236, + 233, 282, 237, 223, 218, 218, 218, 218, 218, 218, + 218, 282, 240, 282, 282, 227, 282, 238, 282, 239, + 282, 282, 282, 282, 282, 282, 236, 282, 282, 237, + + 242, 226, 219, 219, 219, 219, 219, 219, 219, 240, + 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + 220, 220, 220, 220, 282, 282, 282, 242, 243, 282, + 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, + 222, 222, 222, 222, 225, 225, 225, 225, 225, 225, + 225, 282, 282, 282, 282, 243, 244, 282, 282, 282, + 282, 282, 282, 242, 252, 282, 282, 253, 246, 282, + 245, 282, 225, 225, 225, 225, 225, 225, 225, 247, + 248, 282, 282, 244, 282, 282, 282, 282, 282, 282, + 242, 252, 282, 282, 253, 246, 282, 245, 243, 282, + + 282, 249, 251, 255, 282, 254, 247, 248, 282, 282, + 282, 282, 282, 257, 282, 282, 282, 282, 282, 282, + 282, 282, 260, 262, 282, 243, 282, 282, 249, 251, + 255, 282, 254, 282, 282, 282, 259, 258, 282, 282, + 257, 282, 282, 282, 282, 282, 263, 264, 282, 260, + 262, 265, 282, 282, 282, 282, 282, 282, 282, 267, + 282, 282, 282, 259, 258, 282, 282, 282, 282, 269, + 282, 282, 282, 263, 264, 268, 282, 282, 265, 282, + 282, 282, 282, 272, 282, 282, 267, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 269, 282, 282, 277, + + 271, 282, 268, 282, 278, 274, 282, 282, 282, 275, + 272, 282, 282, 282, 280, 282, 282, 282, 281, 282, + 282, 282, 282, 282, 282, 282, 277, 271, 282, 282, + 282, 278, 274, 282, 282, 282, 275, 282, 282, 282, + 282, 280, 282, 282, 282, 281, 38, 38, 38, 38, + 42, 282, 42, 42, 45, 282, 45, 45, 53, 53, + 86, 282, 86, 86, 88, 282, 88, 88, 5, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282 + } ; + +static yyconst flex_int16_t yy_chk[1443] = + { 0, + 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, 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, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, + 13, 14, 14, 14, 14, 14, 14, 14, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 36, 16, 300, + + 15, 15, 18, 20, 15, 15, 16, 17, 19, 17, + 18, 20, 15, 148, 20, 17, 19, 19, 299, 16, + 205, 19, 24, 298, 36, 18, 21, 15, 15, 22, + 24, 15, 15, 24, 21, 21, 297, 22, 22, 15, + 148, 20, 23, 24, 19, 21, 16, 205, 19, 22, + 23, 25, 18, 26, 25, 23, 27, 296, 28, 25, + 24, 26, 21, 29, 27, 22, 28, 30, 295, 27, + 24, 29, 21, 27, 294, 30, 22, 29, 31, 32, + 33, 28, 23, 30, 34, 29, 31, 32, 33, 35, + 53, 57, 34, 33, 250, 34, 27, 35, 53, 57, + + 27, 34, 35, 58, 29, 32, 293, 31, 28, 292, + 30, 58, 29, 47, 47, 47, 47, 47, 47, 47, + 33, 250, 34, 60, 291, 59, 290, 285, 34, 35, + 60, 60, 32, 59, 31, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 232, 68, 62, 48, 48, 59, + 61, 48, 48, 68, 62, 86, 45, 42, 61, 48, + 52, 52, 52, 52, 52, 52, 52, 40, 68, 37, + 61, 12, 71, 62, 48, 48, 59, 66, 48, 48, + 71, 71, 66, 66, 10, 66, 48, 49, 49, 49, + 49, 49, 49, 49, 75, 68, 63, 61, 49, 49, + + 62, 64, 75, 49, 63, 9, 63, 7, 71, 64, + 49, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 70, 64, 5, 77, 63, 49, 49, 65, 70, 4, + 49, 77, 3, 63, 0, 65, 0, 49, 50, 50, + 50, 50, 50, 50, 50, 83, 70, 65, 64, 50, + 50, 63, 67, 83, 50, 0, 0, 83, 0, 0, + 67, 50, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 0, 67, 70, 65, 114, 50, 50, 69, 72, + 72, 50, 0, 114, 83, 0, 69, 72, 50, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 69, 67, + + 73, 51, 51, 78, 74, 51, 51, 0, 73, 80, + 79, 78, 74, 51, 106, 113, 113, 80, 79, 0, + 106, 0, 106, 76, 113, 69, 74, 82, 51, 51, + 73, 76, 51, 51, 79, 82, 78, 76, 80, 0, + 51, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 81, 74, 82, 0, 0, 73, 84, 0, + 81, 79, 0, 78, 76, 80, 84, 90, 90, 90, + 90, 90, 90, 90, 120, 120, 0, 0, 81, 0, + 0, 82, 120, 91, 91, 84, 91, 91, 91, 91, + 91, 91, 91, 92, 92, 92, 92, 92, 92, 92, + + 123, 130, 0, 0, 0, 81, 0, 0, 123, 130, + 96, 96, 84, 96, 96, 96, 96, 96, 96, 96, + 100, 100, 100, 100, 100, 100, 100, 100, 101, 101, + 101, 101, 101, 101, 101, 101, 101, 102, 102, 102, + 102, 102, 102, 102, 0, 0, 0, 0, 0, 101, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 108, + 109, 115, 0, 112, 107, 129, 105, 108, 109, 115, + 115, 112, 107, 129, 105, 108, 101, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 105, 107, 110, 109, + 112, 111, 117, 129, 0, 116, 110, 115, 104, 111, + + 117, 110, 108, 116, 118, 116, 0, 119, 111, 117, + 121, 122, 118, 105, 107, 119, 109, 112, 121, 122, + 129, 124, 119, 121, 122, 104, 125, 0, 110, 124, + 126, 118, 116, 127, 125, 111, 117, 0, 126, 125, + 0, 127, 0, 126, 141, 141, 145, 150, 124, 119, + 121, 122, 141, 144, 145, 150, 150, 145, 118, 152, + 127, 144, 0, 154, 154, 159, 125, 152, 144, 0, + 126, 154, 0, 159, 0, 124, 133, 133, 133, 133, + 133, 133, 133, 150, 145, 0, 0, 127, 128, 128, + 128, 128, 128, 128, 128, 144, 128, 128, 128, 128, + + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 0, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 132, + 132, 132, 132, 132, 132, 132, 134, 134, 134, 134, + 134, 134, 134, 149, 156, 0, 0, 161, 0, 132, + 0, 149, 156, 156, 149, 161, 134, 135, 135, 135, + 135, 135, 135, 135, 136, 136, 136, 136, 136, 136, + 136, 162, 0, 0, 163, 0, 132, 0, 0, 162, + + 156, 149, 163, 134, 137, 137, 137, 137, 137, 137, + 137, 137, 138, 138, 138, 138, 138, 138, 138, 138, + 138, 139, 139, 139, 139, 139, 139, 139, 139, 139, + 140, 142, 143, 147, 146, 153, 151, 0, 140, 142, + 143, 147, 146, 153, 151, 155, 147, 140, 153, 0, + 0, 0, 143, 155, 157, 158, 164, 142, 146, 151, + 160, 165, 157, 158, 164, 155, 0, 0, 160, 165, + 166, 157, 167, 147, 140, 153, 0, 160, 166, 143, + 167, 158, 168, 169, 142, 146, 151, 170, 171, 172, + 168, 169, 155, 173, 174, 170, 171, 172, 157, 175, + + 0, 173, 174, 176, 160, 177, 178, 175, 158, 179, + 180, 176, 181, 177, 178, 182, 183, 179, 180, 184, + 181, 185, 186, 182, 183, 187, 0, 184, 0, 185, + 186, 0, 0, 187, 191, 191, 191, 191, 191, 191, + 191, 187, 189, 189, 189, 189, 189, 189, 189, 189, + 190, 190, 190, 190, 190, 190, 190, 190, 192, 192, + 192, 192, 192, 192, 192, 192, 0, 0, 187, 193, + 193, 193, 193, 193, 193, 193, 194, 194, 194, 194, + 194, 194, 194, 194, 194, 195, 195, 195, 195, 195, + 195, 195, 198, 199, 201, 0, 202, 200, 203, 197, + + 198, 199, 201, 194, 202, 200, 203, 197, 204, 207, + 209, 210, 208, 197, 200, 206, 204, 207, 209, 210, + 208, 0, 0, 206, 202, 208, 203, 0, 0, 207, + 194, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 197, 200, 211, 206, 0, 0, 212, 214, 0, 213, + 211, 202, 208, 203, 212, 214, 207, 213, 196, 215, + 213, 0, 214, 216, 0, 0, 0, 215, 0, 211, + 206, 216, 212, 218, 218, 218, 218, 218, 218, 218, + 218, 0, 215, 224, 227, 196, 234, 213, 0, 214, + 236, 224, 227, 0, 234, 0, 211, 0, 236, 212, + + 218, 219, 219, 219, 219, 219, 219, 219, 219, 215, + 220, 220, 220, 220, 220, 220, 220, 221, 221, 221, + 221, 221, 221, 221, 0, 0, 0, 218, 219, 0, + 222, 222, 222, 222, 222, 222, 222, 223, 223, 223, + 223, 223, 223, 223, 225, 225, 225, 225, 225, 225, + 225, 228, 229, 235, 237, 219, 222, 230, 238, 228, + 229, 235, 237, 223, 235, 230, 238, 238, 228, 0, + 225, 0, 226, 226, 226, 226, 226, 226, 226, 229, + 230, 240, 0, 222, 231, 233, 0, 0, 0, 240, + 223, 235, 231, 233, 238, 228, 239, 225, 226, 0, + + 246, 231, 233, 240, 239, 239, 229, 230, 246, 247, + 248, 249, 251, 246, 0, 0, 255, 247, 248, 249, + 251, 0, 249, 251, 255, 226, 252, 253, 231, 233, + 240, 254, 239, 257, 252, 253, 248, 247, 0, 254, + 246, 257, 0, 0, 258, 259, 252, 253, 260, 249, + 251, 254, 258, 259, 262, 0, 260, 264, 263, 257, + 265, 0, 262, 248, 247, 264, 263, 0, 265, 265, + 0, 267, 269, 252, 253, 263, 268, 271, 254, 267, + 269, 272, 274, 269, 268, 271, 257, 275, 0, 272, + 274, 0, 0, 280, 0, 275, 265, 0, 281, 274, + + 268, 280, 263, 277, 275, 271, 281, 278, 0, 272, + 269, 277, 0, 0, 277, 278, 0, 0, 278, 0, + 0, 0, 0, 0, 0, 0, 274, 268, 0, 0, + 0, 275, 271, 0, 0, 0, 272, 0, 0, 0, + 0, 277, 0, 0, 0, 278, 283, 283, 283, 283, + 284, 0, 284, 284, 286, 0, 286, 286, 287, 287, + 288, 0, 288, 288, 289, 0, 289, 289, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "frame/contourlex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 12 "frame/contourlex.L" + #include + #include + #include + + #include "util.h" + #include "contourparser.H" + + extern YYSTYPE* ctlval; + extern ctFlexLexer* ctlexx; + +/* rules */ +#line 840 "frame/contourlex.C" + +#define INITIAL 0 +#define DISCARD 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 31 "frame/contourlex.L" + + +#line 944 "frame/contourlex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 283 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 282 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +#line 33 "frame/contourlex.L" +{ // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(ctlval->str,""); // feed a blank string + return STRING; + } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 40 "frame/contourlex.L" +{ // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 48 "frame/contourlex.L" +{return AMPLIFIER_;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 49 "frame/contourlex.L" +{return B1950_;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 50 "frame/contourlex.L" +{return COLOR_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 51 "frame/contourlex.L" +{return DASH_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 52 "frame/contourlex.L" +{return DASHLIST_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 53 "frame/contourlex.L" +{return DEBUG_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 54 "frame/contourlex.L" +{return DETECTOR_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 55 "frame/contourlex.L" +{return ECLIPTIC_;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 56 "frame/contourlex.L" +{return FALSE_;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 57 "frame/contourlex.L" +{return FK4_;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 58 "frame/contourlex.L" +{return FK4_NO_E_;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 59 "frame/contourlex.L" +{return FK5_;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 60 "frame/contourlex.L" +{return GALACTIC_;} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 61 "frame/contourlex.L" +{return GLOBAL_;} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 62 "frame/contourlex.L" +{return HELIOECLIPTIC_;} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 63 "frame/contourlex.L" +{return ICRS_;} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 64 "frame/contourlex.L" +{return IMAGE_;} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 65 "frame/contourlex.L" +{return J2000_;} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 66 "frame/contourlex.L" +{return LEVEL_;} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 67 "frame/contourlex.L" +{return LEVELS_;} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 68 "frame/contourlex.L" +{return LINEAR_;} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 69 "frame/contourlex.L" +{return N_;} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 70 "frame/contourlex.L" +{return NO_;} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 71 "frame/contourlex.L" +{return OFF_;} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 72 "frame/contourlex.L" +{return ON_;} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 73 "frame/contourlex.L" +{return PHYSICAL_;} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 74 "frame/contourlex.L" +{return SUPERGALACTIC_;} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 75 "frame/contourlex.L" +{return TRUE_;} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 76 "frame/contourlex.L" +{return VERSION_;} + YY_BREAK +case 32: +YY_RULE_SETUP +#line 77 "frame/contourlex.L" +{return WCS_;} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 78 "frame/contourlex.L" +{return WCSA_;} + YY_BREAK +case 34: +YY_RULE_SETUP +#line 79 "frame/contourlex.L" +{return WCSB_;} + YY_BREAK +case 35: +YY_RULE_SETUP +#line 80 "frame/contourlex.L" +{return WCSC_;} + YY_BREAK +case 36: +YY_RULE_SETUP +#line 81 "frame/contourlex.L" +{return WCSD_;} + YY_BREAK +case 37: +YY_RULE_SETUP +#line 82 "frame/contourlex.L" +{return WCSE_;} + YY_BREAK +case 38: +YY_RULE_SETUP +#line 83 "frame/contourlex.L" +{return WCSF_;} + YY_BREAK +case 39: +YY_RULE_SETUP +#line 84 "frame/contourlex.L" +{return WCSG_;} + YY_BREAK +case 40: +YY_RULE_SETUP +#line 85 "frame/contourlex.L" +{return WCSH_;} + YY_BREAK +case 41: +YY_RULE_SETUP +#line 86 "frame/contourlex.L" +{return WCSI_;} + YY_BREAK +case 42: +YY_RULE_SETUP +#line 87 "frame/contourlex.L" +{return WCSJ_;} + YY_BREAK +case 43: +YY_RULE_SETUP +#line 88 "frame/contourlex.L" +{return WCSK_;} + YY_BREAK +case 44: +YY_RULE_SETUP +#line 89 "frame/contourlex.L" +{return WCSL_;} + YY_BREAK +case 45: +YY_RULE_SETUP +#line 90 "frame/contourlex.L" +{return WCSM_;} + YY_BREAK +case 46: +YY_RULE_SETUP +#line 91 "frame/contourlex.L" +{return WCSN_;} + YY_BREAK +case 47: +YY_RULE_SETUP +#line 92 "frame/contourlex.L" +{return WCSO_;} + YY_BREAK +case 48: +YY_RULE_SETUP +#line 93 "frame/contourlex.L" +{return WCSP_;} + YY_BREAK +case 49: +YY_RULE_SETUP +#line 94 "frame/contourlex.L" +{return WCSQ_;} + YY_BREAK +case 50: +YY_RULE_SETUP +#line 95 "frame/contourlex.L" +{return WCSR_;} + YY_BREAK +case 51: +YY_RULE_SETUP +#line 96 "frame/contourlex.L" +{return WCSS_;} + YY_BREAK +case 52: +YY_RULE_SETUP +#line 97 "frame/contourlex.L" +{return WCST_;} + YY_BREAK +case 53: +YY_RULE_SETUP +#line 98 "frame/contourlex.L" +{return WCSU_;} + YY_BREAK +case 54: +YY_RULE_SETUP +#line 99 "frame/contourlex.L" +{return WCSV_;} + YY_BREAK +case 55: +YY_RULE_SETUP +#line 100 "frame/contourlex.L" +{return WCSW_;} + YY_BREAK +case 56: +YY_RULE_SETUP +#line 101 "frame/contourlex.L" +{return WCSX_;} + YY_BREAK +case 57: +YY_RULE_SETUP +#line 102 "frame/contourlex.L" +{return WCSY_;} + YY_BREAK +case 58: +YY_RULE_SETUP +#line 103 "frame/contourlex.L" +{return WCSZ_;} + YY_BREAK +case 59: +YY_RULE_SETUP +#line 104 "frame/contourlex.L" +{return WIDTH_;} + YY_BREAK +case 60: +YY_RULE_SETUP +#line 105 "frame/contourlex.L" +{return Y_;} + YY_BREAK +case 61: +YY_RULE_SETUP +#line 106 "frame/contourlex.L" +{return YES_;} + YY_BREAK +case 62: +YY_RULE_SETUP +#line 109 "frame/contourlex.L" +{ // Integer + ctlval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 63: +#line 115 "frame/contourlex.L" +case 64: +YY_RULE_SETUP +#line 115 "frame/contourlex.L" +{ // Real Number + ctlval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 65: +#line 121 "frame/contourlex.L" +case 66: +YY_RULE_SETUP +#line 121 "frame/contourlex.L" +{ // degrees + yytext[yyleng-1] = '\0'; + ctlval->real = atof(yytext); + return ANGDEGREE; + } + YY_BREAK +case 67: +#line 128 "frame/contourlex.L" +case 68: +YY_RULE_SETUP +#line 128 "frame/contourlex.L" +{ // physical coords + yytext[yyleng-1] = '\0'; + ctlval->real = atof(yytext); + return PHYCOORD; + } + YY_BREAK +case 69: +#line 135 "frame/contourlex.L" +case 70: +YY_RULE_SETUP +#line 135 "frame/contourlex.L" +{ // image coords + yytext[yyleng-1] = '\0'; + ctlval->real = atof(yytext); + return IMGCOORD; + } + YY_BREAK +case 71: +#line 142 "frame/contourlex.L" +case 72: +YY_RULE_SETUP +#line 142 "frame/contourlex.L" +{ // Sexagesimal + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return SEXSTR; + } + YY_BREAK +case 73: +#line 150 "frame/contourlex.L" +case 74: +YY_RULE_SETUP +#line 150 "frame/contourlex.L" +{ // HMS + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return HMSSTR; + } + YY_BREAK +case 75: +#line 158 "frame/contourlex.L" +case 76: +YY_RULE_SETUP +#line 158 "frame/contourlex.L" +{ // DMS + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return DMSSTR; + } + YY_BREAK +case 77: +YY_RULE_SETUP +#line 165 "frame/contourlex.L" +{ // 8 bit Hex Color + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 78: +YY_RULE_SETUP +#line 172 "frame/contourlex.L" +{ // 16 bit Hex Color + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 79: +YY_RULE_SETUP +#line 179 "frame/contourlex.L" +{ // 32 bit Hex Color + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 80: +#line 187 "frame/contourlex.L" +case 81: +YY_RULE_SETUP +#line 187 "frame/contourlex.L" +{ // Quoted String + int ll = (yyleng-2)<(CTBUFSIZE-1) ? (yyleng-2):(CTBUFSIZE-1); + strncpy(ctlval->str,yytext+1,ll); // skip the " " + ctlval->str[ll] = '\0'; // Remove the '"' + return STRING; + } + YY_BREAK +case 82: +YY_RULE_SETUP +#line 194 "frame/contourlex.L" +{ // Quoted String + int ll = (yyleng-2)<(CTBUFSIZE-1) ? (yyleng-2):(CTBUFSIZE-1); + strncpy(ctlval->str,yytext+1,ll); // skip the '{' + ctlval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + YY_BREAK +case 83: +YY_RULE_SETUP +#line 201 "frame/contourlex.L" +{ // General String + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 84: +YY_RULE_SETUP +#line 208 "frame/contourlex.L" +{ // White Spaces + } + YY_BREAK +case 85: +/* rule 85 can match eol */ +YY_RULE_SETUP +#line 211 "frame/contourlex.L" +{ // windows line feed + return '\n'; + } + YY_BREAK +case 86: +YY_RULE_SETUP +#line 215 "frame/contourlex.L" +{ // fake line feed + return '\n'; + } + YY_BREAK +case 87: +/* rule 87 can match eol */ +YY_RULE_SETUP +#line 219 "frame/contourlex.L" +{ // linefeed + return '\n'; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(DISCARD): +#line 223 "frame/contourlex.L" +{ // eof + return EOF_; + } + YY_BREAK +case 88: +YY_RULE_SETUP +#line 227 "frame/contourlex.L" +{ // Else, return the char + return yytext[0]; + } + YY_BREAK +case 89: +YY_RULE_SETUP +#line 231 "frame/contourlex.L" +ECHO; + YY_BREAK +#line 1537 "frame/contourlex.C" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + ctfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + ctfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + ctrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ctrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 283 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 283 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 282); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) ctalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) ctalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + ctfree((void *) b->yy_ch_buf ); + + ctfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)ctalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)ctrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) ctalloc(new_size ); + + else + (yy_start_stack) = (int *) ctrealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *ctalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *ctrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void ctfree (void * ptr ) +{ + free( (char *) ptr ); /* see ctrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 231 "frame/contourlex.L" + + + +void ctDiscard(int doit) +{ + if (ctlexx) + ctlexx->begin(DISCARD, doit); +} + +void ctFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} + diff --git a/tksao/frame/contourlex.L b/tksao/frame/contourlex.L new file mode 100644 index 0000000..8d097c1 --- /dev/null +++ b/tksao/frame/contourlex.L @@ -0,0 +1,244 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ + +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + + #include "util.h" + #include "contourparser.H" + + extern YYSTYPE* ctlval; + extern ctFlexLexer* ctlexx; +%} + +%x DISCARD + +D [0-9] +E [Ee][+-]?{D}+ +H [0-9a-fA-F] + +/* rules */ + +%% + +[\n] { // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(ctlval->str,""); // feed a blank string + return STRING; + } + +[^\n]* { // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return STRING; + } + +amplifier {return AMPLIFIER_;} +b1950 {return B1950_;} +color {return COLOR_;} +dash {return DASH_;} +dashlist {return DASHLIST_;} +debug {return DEBUG_;} +detector {return DETECTOR_;} +ecliptic {return ECLIPTIC_;} +false {return FALSE_;} +fk4 {return FK4_;} +fk4-no-e {return FK4_NO_E_;} +fk5 {return FK5_;} +galactic {return GALACTIC_;} +global {return GLOBAL_;} +helioecliptic {return HELIOECLIPTIC_;} +icrs {return ICRS_;} +image {return IMAGE_;} +j2000 {return J2000_;} +level {return LEVEL_;} +levels {return LEVELS_;} +linear {return LINEAR_;} +n {return N_;} +no {return NO_;} +off {return OFF_;} +on {return ON_;} +physical {return PHYSICAL_;} +supergalactic {return SUPERGALACTIC_;} +true {return TRUE_;} +version {return VERSION_;} +wcs {return WCS_;} +wcsa {return WCSA_;} +wcsb {return WCSB_;} +wcsc {return WCSC_;} +wcsd {return WCSD_;} +wcse {return WCSE_;} +wcsf {return WCSF_;} +wcsg {return WCSG_;} +wcsh {return WCSH_;} +wcsi {return WCSI_;} +wcsj {return WCSJ_;} +wcsk {return WCSK_;} +wcsl {return WCSL_;} +wcsm {return WCSM_;} +wcsn {return WCSN_;} +wcso {return WCSO_;} +wcsp {return WCSP_;} +wcsq {return WCSQ_;} +wcsr {return WCSR_;} +wcss {return WCSS_;} +wcst {return WCST_;} +wcsu {return WCSU_;} +wcsv {return WCSV_;} +wcsw {return WCSW_;} +wcsx {return WCSX_;} +wcsy {return WCSY_;} +wcsz {return WCSZ_;} +width {return WIDTH_;} +y {return Y_;} +yes {return YES_;} + + +[+-]?{D}+ { // Integer + ctlval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + ctlval->real = atof(yytext); + return REAL; + } + +[+-]?{D}+"."?d | +[+-]?{D}*"."{D}+d { // degrees + yytext[yyleng-1] = '\0'; + ctlval->real = atof(yytext); + return ANGDEGREE; + } + +[+-]?{D}+"."?p | +[+-]?{D}*"."{D}+p { // physical coords + yytext[yyleng-1] = '\0'; + ctlval->real = atof(yytext); + return PHYCOORD; + } + +[+-]?{D}+"."?i | +[+-]?{D}*"."{D}+i { // image coords + yytext[yyleng-1] = '\0'; + ctlval->real = atof(yytext); + return IMGCOORD; + } + +[+-]?{D}+:{D}+:{D}+"."? | +[+-]?{D}+:{D}+:{D}*"."{D}+ { // Sexagesimal + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return SEXSTR; + } + +[+-]?{D}+h{D}+m{D}+"."?s | +[+-]?{D}+h{D}+m{D}*"."{D}+s { // HMS + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return HMSSTR; + } + +[+-]?{D}+d{D}+m{D}+"."?s | +[+-]?{D}+d{D}+m{D}*"."{D}+s { // DMS + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return DMSSTR; + } + +#({H}){3} { // 8 bit Hex Color + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return STRING; + } + +#({H}){6} { // 16 bit Hex Color + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return STRING; + } + +#({H}){12} { // 32 bit Hex Color + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return STRING; + } + +\"[^\"\n]*\" | +\'[^\'\n]*\' { // Quoted String + int ll = (yyleng-2)<(CTBUFSIZE-1) ? (yyleng-2):(CTBUFSIZE-1); + strncpy(ctlval->str,yytext+1,ll); // skip the " " + ctlval->str[ll] = '\0'; // Remove the '"' + return STRING; + } + +\{[^\}\n]*\} { // Quoted String + int ll = (yyleng-2)<(CTBUFSIZE-1) ? (yyleng-2):(CTBUFSIZE-1); + strncpy(ctlval->str,yytext+1,ll); // skip the '{' + ctlval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + +[0-9A-Za-z]+ { // General String + int ll = yyleng <(CTBUFSIZE-1) ? yyleng:(CTBUFSIZE-1); + strncpy(ctlval->str,yytext,ll); + ctlval->str[ll] = '\0'; + return STRING; + } + +[ \t]+ { // White Spaces + } + +\r\n { // windows line feed + return '\n'; + } + +\\n { // fake line feed + return '\n'; + } + +\n { // linefeed + return '\n'; + } + +<> { // eof + return EOF_; + } + +. { // Else, return the char + return yytext[0]; + } + +%% + +void ctDiscard(int doit) +{ + if (ctlexx) + ctlexx->begin(DISCARD, doit); +} + +void ctFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} diff --git a/tksao/frame/contourparser.C b/tksao/frame/contourparser.C new file mode 100644 index 0000000..5a384f6 --- /dev/null +++ b/tksao/frame/contourparser.C @@ -0,0 +1,2486 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse ctparse +#define yylex ctlex +#define yyerror cterror +#define yylval ctlval +#define yychar ctchar +#define yydebug ctdebug +#define yynerrs ctnerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + STRING = 260, + ANGDEGREE = 261, + PHYCOORD = 262, + IMGCOORD = 263, + SEXSTR = 264, + HMSSTR = 265, + DMSSTR = 266, + EOF_ = 267, + AMPLIFIER_ = 268, + B1950_ = 269, + COLOR_ = 270, + DASH_ = 271, + DASHLIST_ = 272, + DEBUG_ = 273, + DETECTOR_ = 274, + ECLIPTIC_ = 275, + FALSE_ = 276, + FK4_ = 277, + FK4_NO_E_ = 278, + FK5_ = 279, + GALACTIC_ = 280, + GLOBAL_ = 281, + HELIOECLIPTIC_ = 282, + ICRS_ = 283, + IMAGE_ = 284, + J2000_ = 285, + LEVEL_ = 286, + LEVELS_ = 287, + LINEAR_ = 288, + N_ = 289, + NO_ = 290, + OFF_ = 291, + ON_ = 292, + PHYSICAL_ = 293, + SUPERGALACTIC_ = 294, + TRUE_ = 295, + VERSION_ = 296, + WCS_ = 297, + WCSA_ = 298, + WCSB_ = 299, + WCSC_ = 300, + WCSD_ = 301, + WCSE_ = 302, + WCSF_ = 303, + WCSG_ = 304, + WCSH_ = 305, + WCSI_ = 306, + WCSJ_ = 307, + WCSK_ = 308, + WCSL_ = 309, + WCSM_ = 310, + WCSN_ = 311, + WCSO_ = 312, + WCSP_ = 313, + WCSQ_ = 314, + WCSR_ = 315, + WCSS_ = 316, + WCST_ = 317, + WCSU_ = 318, + WCSV_ = 319, + WCSW_ = 320, + WCSX_ = 321, + WCSY_ = 322, + WCSZ_ = 323, + WIDTH_ = 324, + Y_ = 325, + YES_ = 326 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define STRING 260 +#define ANGDEGREE 261 +#define PHYCOORD 262 +#define IMGCOORD 263 +#define SEXSTR 264 +#define HMSSTR 265 +#define DMSSTR 266 +#define EOF_ 267 +#define AMPLIFIER_ 268 +#define B1950_ 269 +#define COLOR_ 270 +#define DASH_ 271 +#define DASHLIST_ 272 +#define DEBUG_ 273 +#define DETECTOR_ 274 +#define ECLIPTIC_ 275 +#define FALSE_ 276 +#define FK4_ 277 +#define FK4_NO_E_ 278 +#define FK5_ 279 +#define GALACTIC_ 280 +#define GLOBAL_ 281 +#define HELIOECLIPTIC_ 282 +#define ICRS_ 283 +#define IMAGE_ 284 +#define J2000_ 285 +#define LEVEL_ 286 +#define LEVELS_ 287 +#define LINEAR_ 288 +#define N_ 289 +#define NO_ 290 +#define OFF_ 291 +#define ON_ 292 +#define PHYSICAL_ 293 +#define SUPERGALACTIC_ 294 +#define TRUE_ 295 +#define VERSION_ 296 +#define WCS_ 297 +#define WCSA_ 298 +#define WCSB_ 299 +#define WCSC_ 300 +#define WCSD_ 301 +#define WCSE_ 302 +#define WCSF_ 303 +#define WCSG_ 304 +#define WCSH_ 305 +#define WCSI_ 306 +#define WCSJ_ 307 +#define WCSK_ 308 +#define WCSL_ 309 +#define WCSM_ 310 +#define WCSN_ 311 +#define WCSO_ 312 +#define WCSP_ 313 +#define WCSQ_ 314 +#define WCSR_ 315 +#define WCSS_ 316 +#define WCST_ 317 +#define WCSU_ 318 +#define WCSV_ 319 +#define WCSW_ 320 +#define WCSX_ 321 +#define WCSY_ 322 +#define WCSZ_ 323 +#define WIDTH_ 324 +#define Y_ 325 +#define YES_ 326 + + + + +/* Copy the first part of user declarations. */ +#line 10 "frame/contourparser.Y" + +#define YYDEBUG 1 + +#define FITSPTR (fr->findFits()) +#define DISCARD_(x) {yyclearin; ctDiscard(x);} + +#include +#include +#include + +#include "base.h" +#include "fitsimage.h" +#include "contour.h" + +#undef yyFlexLexer +#define yyFlexLexer ctFlexLexer +#include + +extern int ctlex(void*, ctFlexLexer*); +extern void cterror(Base*, ctFlexLexer*, const char*); +extern void ctDiscard(int); + +static Coord::CoordSystem globalWCS; +static Coord::CoordSystem globalSystem; +static Coord::SkyFrame globalSky; + +static ContourLevel* cl; +static Contour* cc; + +static double localLevel; +static char globalColor[16]; +static char localColor[16]; +static int globalWidth; +static int localWidth; +static int globalDash; +static int localDash; +static int globalDashList[2]; +static int localDashList[2]; + +static Coord::CoordSystem checkWCSSystem(); +static Coord::SkyFrame checkWCSSky(); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 54 "frame/contourparser.Y" +{ +#define CTBUFSIZE 2048 + double real; + int integer; + char str[CTBUFSIZE]; + double vector[3]; +} +/* Line 193 of yacc.c. */ +#line 298 "frame/contourparser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 311 "frame/contourparser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 292 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 79 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 31 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 115 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 175 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 326 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 76, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 75, 2, 2, 2, 2, + 73, 74, 2, 2, 78, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 77, + 2, 72, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 6, 10, 13, 14, 17, 19, 23, + 26, 29, 32, 38, 39, 47, 48, 57, 60, 62, + 65, 66, 70, 74, 76, 77, 81, 83, 86, 87, + 88, 92, 94, 96, 98, 100, 102, 104, 106, 108, + 110, 112, 114, 116, 118, 120, 122, 124, 125, 127, + 129, 131, 133, 134, 135, 137, 139, 141, 143, 145, + 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, + 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, + 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, + 207, 209, 211, 213, 215, 217, 219, 223, 225, 229, + 233, 238, 242, 246, 250, 252, 256, 260, 265, 269, + 273, 277, 281, 285, 289, 293 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 80, 0, -1, 100, 81, -1, 81, 82, 92, -1, + 82, 92, -1, -1, 18, 94, -1, 41, -1, 26, + 105, 90, -1, 102, 90, -1, 104, 90, -1, 33, + 90, -1, 32, 72, 73, 86, 74, -1, -1, 31, + 72, 93, 83, 101, 90, 87, -1, -1, 31, 72, + 93, 84, 101, 107, 90, 87, -1, 73, 90, -1, + 88, -1, 74, 90, -1, -1, 75, 85, 5, -1, + 86, 96, 93, -1, 93, -1, -1, 88, 96, 89, + -1, 89, -1, 109, 90, -1, -1, -1, 75, 91, + 5, -1, 76, -1, 77, -1, 12, -1, 4, -1, + 3, -1, 37, -1, 36, -1, 3, -1, 71, -1, + 70, -1, 37, -1, 40, -1, 35, -1, 34, -1, + 36, -1, 21, -1, -1, 78, -1, 9, -1, 10, + -1, 11, -1, -1, -1, 29, -1, 38, -1, 19, + -1, 13, -1, 103, -1, 42, -1, 43, -1, 44, + -1, 45, -1, 46, -1, 47, -1, 48, -1, 49, + -1, 50, -1, 51, -1, 52, -1, 53, -1, 54, + -1, 55, -1, 56, -1, 57, -1, 58, -1, 59, + -1, 60, -1, 61, -1, 62, -1, 63, -1, 64, + -1, 65, -1, 66, -1, 67, -1, 68, -1, 22, + -1, 14, -1, 23, -1, 24, -1, 30, -1, 28, + -1, 25, -1, 39, -1, 20, -1, 27, -1, 105, + 96, 106, -1, 106, -1, 15, 72, 5, -1, 16, + 72, 95, -1, 17, 72, 3, 3, -1, 42, 72, + 103, -1, 69, 72, 3, -1, 107, 96, 108, -1, + 108, -1, 15, 72, 5, -1, 16, 72, 95, -1, + 17, 72, 3, 3, -1, 69, 72, 3, -1, 97, + 96, 97, -1, 98, 96, 99, -1, 99, 96, 99, + -1, 93, 96, 93, -1, 6, 96, 6, -1, 8, + 96, 8, -1, 7, 96, 7, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 148, 148, 151, 152, 155, 156, 157, 159, 160, + 164, 169, 173, 174, 174, 175, 175, 176, 181, 182, + 187, 187, 190, 191, 195, 202, 203, 206, 213, 214, + 214, 217, 218, 219, 227, 228, 231, 232, 235, 237, + 238, 239, 240, 242, 243, 244, 245, 248, 249, 252, + 255, 258, 261, 275, 284, 285, 286, 287, 288, 291, + 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, 313, 314, 315, 316, 317, 320, 321, 322, 323, + 324, 325, 326, 327, 328, 329, 332, 333, 336, 337, + 338, 339, 340, 343, 344, 347, 348, 349, 350, 353, + 366, 374, 382, 389, 397, 404 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "INT", "REAL", "STRING", "ANGDEGREE", + "PHYCOORD", "IMGCOORD", "SEXSTR", "HMSSTR", "DMSSTR", "EOF_", + "AMPLIFIER_", "B1950_", "COLOR_", "DASH_", "DASHLIST_", "DEBUG_", + "DETECTOR_", "ECLIPTIC_", "FALSE_", "FK4_", "FK4_NO_E_", "FK5_", + "GALACTIC_", "GLOBAL_", "HELIOECLIPTIC_", "ICRS_", "IMAGE_", "J2000_", + "LEVEL_", "LEVELS_", "LINEAR_", "N_", "NO_", "OFF_", "ON_", "PHYSICAL_", + "SUPERGALACTIC_", "TRUE_", "VERSION_", "WCS_", "WCSA_", "WCSB_", "WCSC_", + "WCSD_", "WCSE_", "WCSF_", "WCSG_", "WCSH_", "WCSI_", "WCSJ_", "WCSK_", + "WCSL_", "WCSM_", "WCSN_", "WCSO_", "WCSP_", "WCSQ_", "WCSR_", "WCSS_", + "WCST_", "WCSU_", "WCSV_", "WCSW_", "WCSX_", "WCSY_", "WCSZ_", "WIDTH_", + "Y_", "YES_", "'='", "'('", "')'", "'#'", "'\\n'", "';'", "','", + "$accept", "start", "commands", "command", "@1", "@2", "@3", "levels", + "newcl", "nodes", "node", "comment", "@4", "terminator", "numeric", + "debug", "yesno", "sp", "sexagesimal", "hms", "dms", "initGlobal", + "initLocal", "coordSystem", "wcsSystem", "skyFrame", "global", + "globalProperty", "local", "localProperty", "coord", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 61, 40, 41, 35, 10, 59, 44 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 79, 80, 81, 81, 82, 82, 82, 82, 82, + 82, 82, 82, 83, 82, 84, 82, 82, 82, 82, + 85, 82, 86, 86, 87, 88, 88, 89, 90, 91, + 90, 92, 92, 92, 93, 93, 94, 94, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 96, 96, 97, + 98, 99, 100, 101, 102, 102, 102, 102, 102, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 105, 105, 106, 106, + 106, 106, 106, 107, 107, 108, 108, 108, 108, 109, + 109, 109, 109, 109, 109, 109 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 2, 3, 2, 0, 2, 1, 3, 2, + 2, 2, 5, 0, 7, 0, 8, 2, 1, 2, + 0, 3, 3, 1, 0, 3, 1, 2, 0, 0, + 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, + 1, 1, 0, 0, 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, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 3, 1, 3, 3, + 4, 3, 3, 3, 1, 3, 3, 4, 3, 3, + 3, 3, 3, 3, 3, 3 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 52, 0, 5, 1, 35, 34, 47, 47, 47, 49, + 50, 51, 57, 87, 0, 56, 94, 86, 88, 89, + 92, 0, 95, 91, 54, 90, 0, 0, 28, 55, + 93, 7, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 81, 82, 83, 84, 85, 28, + 28, 20, 5, 0, 47, 26, 47, 47, 47, 47, + 28, 58, 28, 28, 48, 0, 0, 0, 37, 36, + 6, 0, 0, 0, 0, 0, 47, 97, 0, 0, + 29, 11, 17, 19, 0, 0, 33, 31, 32, 4, + 0, 0, 0, 0, 0, 9, 10, 27, 113, 115, + 114, 0, 0, 0, 0, 0, 8, 0, 13, 0, + 0, 21, 3, 25, 112, 109, 110, 111, 98, 38, + 46, 44, 43, 45, 41, 42, 40, 39, 99, 0, + 101, 102, 96, 53, 53, 47, 23, 30, 100, 28, + 0, 12, 0, 24, 0, 0, 0, 0, 47, 104, + 22, 14, 0, 0, 0, 0, 24, 0, 105, 106, + 0, 108, 16, 103, 107 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 1, 62, 63, 143, 144, 94, 145, 161, 64, + 65, 91, 120, 99, 66, 80, 138, 75, 67, 68, + 69, 2, 149, 70, 71, 72, 86, 87, 158, 159, + 73 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -93 +static const yytype_int16 yypact[] = +{ + -93, 21, 190, -93, -93, -93, -70, -70, -70, -93, + -93, -93, -93, -93, -30, -93, -93, -93, -93, -93, + -93, 27, -93, -93, -93, -93, -49, -48, -50, -93, + -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -93, -93, -93, -93, -93, -93, -50, + -50, -93, 117, 8, 5, -93, -70, -70, -70, -70, + -50, -93, -50, -50, -93, 20, 23, 32, -93, -93, + -93, -44, -41, -33, -23, -22, -2, -93, 15, -21, + -93, -93, -93, -93, 46, 8, -93, -93, -93, -93, + 99, 15, 44, 43, 43, -93, -93, -93, -93, -93, + -93, 50, 1, 53, 224, 55, -93, 27, 17, 15, + 58, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -93, -93, -93, -93, -93, -93, 61, + -93, -93, -93, -93, -93, -69, -93, -93, -93, -50, + 31, -93, 15, -93, -6, -5, -4, 16, -2, -93, + -93, -93, 60, 1, 67, 74, -93, 31, -93, -93, + 77, -93, -93, -93, -93 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -93, -93, -93, 25, -93, -93, -93, -93, -77, -93, + -10, -57, -93, -1, -74, -93, -72, -7, -9, -93, + -92, -93, -47, -93, -19, -93, -93, -18, -93, -63, + -93 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -29 +static const yytype_int16 yytable[] = +{ + 76, 77, 92, 93, 129, 151, 78, 79, 74, 74, + -28, 126, 127, 105, 118, 106, 107, -18, 4, 5, + 96, 3, 130, 88, 89, 90, 108, 124, 111, 116, + 109, 112, -15, -15, -15, 131, 132, 133, 134, 113, + 110, 135, 81, 82, 83, 146, 154, 155, 156, 114, + 115, 121, 119, 9, 11, 128, 139, 100, 141, 101, + 102, 103, 104, 147, 148, 168, 162, 163, 164, 84, + 170, 136, 137, 90, -28, -28, 74, 171, 160, 117, + 174, -18, -18, 74, 97, 98, -15, 95, 165, 172, + 123, 169, 153, 125, 122, 140, 85, 150, 0, 142, + 157, 166, 4, 5, 173, 6, 7, 8, 9, 10, + 11, 0, 0, 0, 0, 0, 0, -2, 0, 0, + 4, 5, 0, 6, 7, 8, 9, 10, 11, 0, + 12, 13, 0, 0, 0, 14, 15, 16, 152, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 167, 0, 0, 0, 29, 30, 0, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 0, 0, 0, 0, + 59, 60, 61, 4, 5, 0, 6, 7, 8, 9, + 10, 11, 0, 12, 13, 0, 0, 0, 14, 15, + 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 0, 0, 0, 0, 29, 30, + 0, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 0, + 0, 0, 0, 59, 60, 61, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58 +}; + +static const yytype_int16 yycheck[] = +{ + 7, 8, 59, 60, 3, 74, 36, 37, 78, 78, + 12, 103, 104, 70, 88, 72, 73, 12, 3, 4, + 12, 0, 21, 72, 72, 75, 6, 101, 72, 86, + 7, 72, 15, 16, 17, 34, 35, 36, 37, 72, + 8, 40, 15, 16, 17, 119, 15, 16, 17, 72, + 72, 5, 73, 9, 11, 5, 3, 64, 3, 66, + 67, 68, 69, 5, 3, 5, 72, 72, 72, 42, + 3, 70, 71, 75, 76, 77, 78, 3, 152, 86, + 3, 76, 77, 78, 76, 77, 69, 62, 72, 166, + 100, 163, 149, 102, 95, 114, 69, 144, -1, 117, + 69, 158, 3, 4, 167, 6, 7, 8, 9, 10, + 11, -1, -1, -1, -1, -1, -1, 0, -1, -1, + 3, 4, -1, 6, 7, 8, 9, 10, 11, -1, + 13, 14, -1, -1, -1, 18, 19, 20, 145, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 158, -1, -1, -1, 38, 39, -1, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, -1, -1, -1, -1, + 73, 74, 75, 3, 4, -1, 6, 7, 8, 9, + 10, 11, -1, 13, 14, -1, -1, -1, 18, 19, + 20, -1, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, -1, -1, -1, -1, 38, 39, + -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, -1, + -1, -1, -1, 73, 74, 75, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 80, 100, 0, 3, 4, 6, 7, 8, 9, + 10, 11, 13, 14, 18, 19, 20, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 38, + 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 73, + 74, 75, 81, 82, 88, 89, 93, 97, 98, 99, + 102, 103, 104, 109, 78, 96, 96, 96, 36, 37, + 94, 15, 16, 17, 42, 69, 105, 106, 72, 72, + 75, 90, 90, 90, 85, 82, 12, 76, 77, 92, + 96, 96, 96, 96, 96, 90, 90, 90, 6, 7, + 8, 72, 72, 72, 72, 72, 90, 96, 93, 73, + 91, 5, 92, 89, 93, 97, 99, 99, 5, 3, + 21, 34, 35, 36, 37, 40, 70, 71, 95, 3, + 103, 3, 106, 83, 84, 86, 93, 5, 3, 101, + 101, 74, 96, 90, 15, 16, 17, 69, 107, 108, + 93, 87, 72, 72, 72, 72, 90, 96, 5, 95, + 3, 3, 87, 108, 3 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (fr, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, fr, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, ctFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + ctFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (fr); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, ctFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + ctFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Base* fr, ctFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, fr, ll) + YYSTYPE *yyvsp; + int yyrule; + Base* fr; + ctFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , fr, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, fr, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Base* fr, ctFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, fr, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + Base* fr; + ctFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (fr); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (Base* fr, ctFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (Base* fr, ctFlexLexer* ll) +#else +int +yyparse (fr, ll) + Base* fr; + ctFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 7: +#line 157 "frame/contourparser.Y" + {cerr << "DS9 Contour File 7.5" << endl;;} + break; + + case 9: +#line 161 "frame/contourparser.Y" + { + globalSystem=(Coord::CoordSystem)(yyvsp[(1) - (2)].integer); + ;} + break; + + case 10: +#line 165 "frame/contourparser.Y" + { + globalSystem=globalWCS; + globalSky=(Coord::SkyFrame)(yyvsp[(1) - (2)].integer); + ;} + break; + + case 11: +#line 170 "frame/contourparser.Y" + { + globalSystem=globalWCS; globalSky=Coord::FK5; + ;} + break; + + case 13: +#line 174 "frame/contourparser.Y" + {localLevel = (yyvsp[(3) - (3)].real);} + break; + + case 15: +#line 175 "frame/contourparser.Y" + {localLevel = (yyvsp[(3) - (3)].real);} + break; + + case 17: +#line 177 "frame/contourparser.Y" + { + if (cl) + cc = new Contour(cl); + ;} + break; + + case 19: +#line 183 "frame/contourparser.Y" + { + if (cc && cl) + cl->lcontour().append(cc); + ;} + break; + + case 20: +#line 187 "frame/contourparser.Y" + {DISCARD_(1);;} + break; + + case 24: +#line 195 "frame/contourparser.Y" + { + if (cl) + fr->contourAppendCmd(cl); + cl = new ContourLevel(fr, localLevel, localColor, localWidth, localDash, localDashList); + ;} + break; + + case 27: +#line 207 "frame/contourparser.Y" + { + if (cc) + cc->lvertex().append(new Vertex((yyvsp[(1) - (2)].vector))); + ;} + break; + + case 29: +#line 214 "frame/contourparser.Y" + {DISCARD_(1);;} + break; + + case 33: +#line 220 "frame/contourparser.Y" + { + if (cl) + fr->contourAppendCmd(cl); + YYACCEPT; + ;} + break; + + case 34: +#line 227 "frame/contourparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 35: +#line 228 "frame/contourparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].integer);;} + break; + + case 36: +#line 231 "frame/contourparser.Y" + {yydebug=1;;} + break; + + case 37: +#line 232 "frame/contourparser.Y" + {yydebug=0;;} + break; + + case 38: +#line 235 "frame/contourparser.Y" + {(yyval.integer)=((yyvsp[(1) - (1)].integer) ? 1 : 0);;} + break; + + case 39: +#line 237 "frame/contourparser.Y" + {(yyval.integer)=1;;} + break; + + case 40: +#line 238 "frame/contourparser.Y" + {(yyval.integer)=1;;} + break; + + case 41: +#line 239 "frame/contourparser.Y" + {(yyval.integer)=1;;} + break; + + case 42: +#line 240 "frame/contourparser.Y" + {(yyval.integer)=1;;} + break; + + case 43: +#line 242 "frame/contourparser.Y" + {(yyval.integer)=0;;} + break; + + case 44: +#line 243 "frame/contourparser.Y" + {(yyval.integer)=0;;} + break; + + case 45: +#line 244 "frame/contourparser.Y" + {(yyval.integer)=0;;} + break; + + case 46: +#line 245 "frame/contourparser.Y" + {(yyval.integer)=0;;} + break; + + case 49: +#line 252 "frame/contourparser.Y" + {(yyval.real) = parseSEXStr((yyvsp[(1) - (1)].str));;} + break; + + case 50: +#line 255 "frame/contourparser.Y" + {(yyval.real) = parseHMSStr((yyvsp[(1) - (1)].str));;} + break; + + case 51: +#line 258 "frame/contourparser.Y" + {(yyval.real) = parseDMSStr((yyvsp[(1) - (1)].str));;} + break; + + case 52: +#line 261 "frame/contourparser.Y" + { + cl = NULL; + cc = NULL; + globalSystem = Coord::WCS; + globalWCS = fr->wcsSystem(); + globalSky = fr->wcsSky(); + strcpy(globalColor,"green"); + globalDash = 0; + globalDashList[0] = 8; + globalDashList[1] = 3; + globalWidth = 1; + ;} + break; + + case 53: +#line 275 "frame/contourparser.Y" + { + strcpy(localColor,globalColor); + localDash = globalDash; + localDashList[0] = globalDashList[0]; + localDashList[1] = globalDashList[1]; + localWidth = globalWidth; + ;} + break; + + case 54: +#line 284 "frame/contourparser.Y" + {(yyval.integer) = Coord::IMAGE;;} + break; + + case 55: +#line 285 "frame/contourparser.Y" + {(yyval.integer) = Coord::PHYSICAL;;} + break; + + case 56: +#line 286 "frame/contourparser.Y" + {(yyval.integer) = Coord::DETECTOR;;} + break; + + case 57: +#line 287 "frame/contourparser.Y" + {(yyval.integer) = Coord::AMPLIFIER;;} + break; + + case 58: +#line 288 "frame/contourparser.Y" + {(yyval.integer) = (yyvsp[(1) - (1)].integer); globalWCS = (Coord::CoordSystem)(yyvsp[(1) - (1)].integer);;} + break; + + case 59: +#line 291 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCS;;} + break; + + case 60: +#line 292 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSA;;} + break; + + case 61: +#line 293 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSB;;} + break; + + case 62: +#line 294 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSC;;} + break; + + case 63: +#line 295 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSD;;} + break; + + case 64: +#line 296 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSE;;} + break; + + case 65: +#line 297 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSF;;} + break; + + case 66: +#line 298 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSG;;} + break; + + case 67: +#line 299 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSH;;} + break; + + case 68: +#line 300 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSI;;} + break; + + case 69: +#line 301 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSJ;;} + break; + + case 70: +#line 302 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSK;;} + break; + + case 71: +#line 303 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSL;;} + break; + + case 72: +#line 304 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSM;;} + break; + + case 73: +#line 305 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSN;;} + break; + + case 74: +#line 306 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSO;;} + break; + + case 75: +#line 307 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSP;;} + break; + + case 76: +#line 308 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSQ;;} + break; + + case 77: +#line 309 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSR;;} + break; + + case 78: +#line 310 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSS;;} + break; + + case 79: +#line 311 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCST;;} + break; + + case 80: +#line 312 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSU;;} + break; + + case 81: +#line 313 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSV;;} + break; + + case 82: +#line 314 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSW;;} + break; + + case 83: +#line 315 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSX;;} + break; + + case 84: +#line 316 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSY;;} + break; + + case 85: +#line 317 "frame/contourparser.Y" + {(yyval.integer) = Coord::WCSZ;;} + break; + + case 86: +#line 320 "frame/contourparser.Y" + {(yyval.integer) = Coord::FK4;;} + break; + + case 87: +#line 321 "frame/contourparser.Y" + {(yyval.integer) = Coord::FK4;;} + break; + + case 88: +#line 322 "frame/contourparser.Y" + {(yyval.integer) = Coord::FK4_NO_E;;} + break; + + case 89: +#line 323 "frame/contourparser.Y" + {(yyval.integer) = Coord::FK5;;} + break; + + case 90: +#line 324 "frame/contourparser.Y" + {(yyval.integer) = Coord::FK5;;} + break; + + case 91: +#line 325 "frame/contourparser.Y" + {(yyval.integer) = Coord::ICRS;;} + break; + + case 92: +#line 326 "frame/contourparser.Y" + {(yyval.integer) = Coord::GALACTIC;;} + break; + + case 93: +#line 327 "frame/contourparser.Y" + {(yyval.integer) = Coord::SUPERGALACTIC;;} + break; + + case 94: +#line 328 "frame/contourparser.Y" + {(yyval.integer) = Coord::ECLIPTIC;;} + break; + + case 95: +#line 329 "frame/contourparser.Y" + {(yyval.integer) = Coord::HELIOECLIPTIC;;} + break; + + case 98: +#line 336 "frame/contourparser.Y" + {strncpy(globalColor,(yyvsp[(3) - (3)].str),16);;} + break; + + case 99: +#line 337 "frame/contourparser.Y" + {globalDash = (yyvsp[(3) - (3)].integer);;} + break; + + case 100: +#line 338 "frame/contourparser.Y" + {globalDashList[0] =(yyvsp[(3) - (4)].integer); globalDashList[1] =(yyvsp[(4) - (4)].integer);;} + break; + + case 101: +#line 339 "frame/contourparser.Y" + {globalWCS = (Coord::CoordSystem)(yyvsp[(3) - (3)].integer);;} + break; + + case 102: +#line 340 "frame/contourparser.Y" + {globalWidth = (yyvsp[(3) - (3)].integer);;} + break; + + case 105: +#line 347 "frame/contourparser.Y" + {strncpy(localColor,(yyvsp[(3) - (3)].str),16);;} + break; + + case 106: +#line 348 "frame/contourparser.Y" + {localDash = (yyvsp[(3) - (3)].integer);;} + break; + + case 107: +#line 349 "frame/contourparser.Y" + {localDashList[0] =(yyvsp[(3) - (4)].integer); localDashList[1] =(yyvsp[(4) - (4)].integer);;} + break; + + case 108: +#line 350 "frame/contourparser.Y" + {localWidth = (yyvsp[(3) - (3)].integer);;} + break; + + case 109: +#line 354 "frame/contourparser.Y" + { + Vector r; + Coord::CoordSystem sys = checkWCSSystem(); + Coord::SkyFrame sky = checkWCSSky(); + if (sky == Coord::GALACTIC || sky == Coord::ECLIPTIC) + r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), sys, sky); + else + r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real)*360./24.,(yyvsp[(3) - (3)].real)), sys, sky); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 110: +#line 367 "frame/contourparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), + checkWCSSystem(), checkWCSSky()); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 111: +#line 375 "frame/contourparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), + checkWCSSystem(), checkWCSSky()); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 112: +#line 383 "frame/contourparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), globalSystem, globalSky); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 113: +#line 390 "frame/contourparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), + checkWCSSystem(), checkWCSSky()); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 114: +#line 398 "frame/contourparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::IMAGE); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 115: +#line 405 "frame/contourparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::PHYSICAL); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 2248 "frame/contourparser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (fr, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (fr, ll, yymsg); + } + else + { + yyerror (fr, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, fr, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, fr, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (fr, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, fr, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, fr, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 411 "frame/contourparser.Y" + + +static Coord::CoordSystem checkWCSSystem() +{ + switch (globalSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::WCS; + default: + return globalSystem; + } +} + +static Coord::SkyFrame checkWCSSky() +{ + switch (globalSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::FK5; + default: + return globalSky; + } +} + + diff --git a/tksao/frame/contourparser.H b/tksao/frame/contourparser.H new file mode 100644 index 0000000..3283b02 --- /dev/null +++ b/tksao/frame/contourparser.H @@ -0,0 +1,206 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + STRING = 260, + ANGDEGREE = 261, + PHYCOORD = 262, + IMGCOORD = 263, + SEXSTR = 264, + HMSSTR = 265, + DMSSTR = 266, + EOF_ = 267, + AMPLIFIER_ = 268, + B1950_ = 269, + COLOR_ = 270, + DASH_ = 271, + DASHLIST_ = 272, + DEBUG_ = 273, + DETECTOR_ = 274, + ECLIPTIC_ = 275, + FALSE_ = 276, + FK4_ = 277, + FK4_NO_E_ = 278, + FK5_ = 279, + GALACTIC_ = 280, + GLOBAL_ = 281, + HELIOECLIPTIC_ = 282, + ICRS_ = 283, + IMAGE_ = 284, + J2000_ = 285, + LEVEL_ = 286, + LEVELS_ = 287, + LINEAR_ = 288, + N_ = 289, + NO_ = 290, + OFF_ = 291, + ON_ = 292, + PHYSICAL_ = 293, + SUPERGALACTIC_ = 294, + TRUE_ = 295, + VERSION_ = 296, + WCS_ = 297, + WCSA_ = 298, + WCSB_ = 299, + WCSC_ = 300, + WCSD_ = 301, + WCSE_ = 302, + WCSF_ = 303, + WCSG_ = 304, + WCSH_ = 305, + WCSI_ = 306, + WCSJ_ = 307, + WCSK_ = 308, + WCSL_ = 309, + WCSM_ = 310, + WCSN_ = 311, + WCSO_ = 312, + WCSP_ = 313, + WCSQ_ = 314, + WCSR_ = 315, + WCSS_ = 316, + WCST_ = 317, + WCSU_ = 318, + WCSV_ = 319, + WCSW_ = 320, + WCSX_ = 321, + WCSY_ = 322, + WCSZ_ = 323, + WIDTH_ = 324, + Y_ = 325, + YES_ = 326 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define STRING 260 +#define ANGDEGREE 261 +#define PHYCOORD 262 +#define IMGCOORD 263 +#define SEXSTR 264 +#define HMSSTR 265 +#define DMSSTR 266 +#define EOF_ 267 +#define AMPLIFIER_ 268 +#define B1950_ 269 +#define COLOR_ 270 +#define DASH_ 271 +#define DASHLIST_ 272 +#define DEBUG_ 273 +#define DETECTOR_ 274 +#define ECLIPTIC_ 275 +#define FALSE_ 276 +#define FK4_ 277 +#define FK4_NO_E_ 278 +#define FK5_ 279 +#define GALACTIC_ 280 +#define GLOBAL_ 281 +#define HELIOECLIPTIC_ 282 +#define ICRS_ 283 +#define IMAGE_ 284 +#define J2000_ 285 +#define LEVEL_ 286 +#define LEVELS_ 287 +#define LINEAR_ 288 +#define N_ 289 +#define NO_ 290 +#define OFF_ 291 +#define ON_ 292 +#define PHYSICAL_ 293 +#define SUPERGALACTIC_ 294 +#define TRUE_ 295 +#define VERSION_ 296 +#define WCS_ 297 +#define WCSA_ 298 +#define WCSB_ 299 +#define WCSC_ 300 +#define WCSD_ 301 +#define WCSE_ 302 +#define WCSF_ 303 +#define WCSG_ 304 +#define WCSH_ 305 +#define WCSI_ 306 +#define WCSJ_ 307 +#define WCSK_ 308 +#define WCSL_ 309 +#define WCSM_ 310 +#define WCSN_ 311 +#define WCSO_ 312 +#define WCSP_ 313 +#define WCSQ_ 314 +#define WCSR_ 315 +#define WCSS_ 316 +#define WCST_ 317 +#define WCSU_ 318 +#define WCSV_ 319 +#define WCSW_ 320 +#define WCSX_ 321 +#define WCSY_ 322 +#define WCSZ_ 323 +#define WIDTH_ 324 +#define Y_ 325 +#define YES_ 326 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 54 "frame/contourparser.Y" +{ +#define CTBUFSIZE 2048 + double real; + int integer; + char str[CTBUFSIZE]; + double vector[3]; +} +/* Line 1529 of yacc.c. */ +#line 199 "frame/contourparser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/frame/contourparser.Y b/tksao/frame/contourparser.Y new file mode 100644 index 0000000..3611560 --- /dev/null +++ b/tksao/frame/contourparser.Y @@ -0,0 +1,434 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {Base* fr} +%lex-param {ctFlexLexer* ll} +%parse-param {ctFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#define FITSPTR (fr->findFits()) +#define DISCARD_(x) {yyclearin; ctDiscard(x);} + +#include +#include +#include + +#include "base.h" +#include "fitsimage.h" +#include "contour.h" + +#undef yyFlexLexer +#define yyFlexLexer ctFlexLexer +#include + +extern int ctlex(void*, ctFlexLexer*); +extern void cterror(Base*, ctFlexLexer*, const char*); +extern void ctDiscard(int); + +static Coord::CoordSystem globalWCS; +static Coord::CoordSystem globalSystem; +static Coord::SkyFrame globalSky; + +static ContourLevel* cl; +static Contour* cc; + +static double localLevel; +static char globalColor[16]; +static char localColor[16]; +static int globalWidth; +static int localWidth; +static int globalDash; +static int localDash; +static int globalDashList[2]; +static int localDashList[2]; + +static Coord::CoordSystem checkWCSSystem(); +static Coord::SkyFrame checkWCSSky(); + +%} + +%union { +#define CTBUFSIZE 2048 + double real; + int integer; + char str[CTBUFSIZE]; + double vector[3]; +} + +%type numeric +%type yesno + +%type sexagesimal +%type hms +%type dms +%type coord +%type coordSystem +%type wcsSystem +%type skyFrame + +%token INT +%token REAL +%token STRING + +%token ANGDEGREE +%token PHYCOORD +%token IMGCOORD + +%token SEXSTR +%token HMSSTR +%token DMSSTR + +%token EOF_ +%token AMPLIFIER_ +%token B1950_ +%token COLOR_ +%token DASH_ +%token DASHLIST_ +%token DEBUG_ +%token DETECTOR_ +%token ECLIPTIC_ +%token FALSE_ +%token FK4_ +%token FK4_NO_E_ +%token FK5_ +%token GALACTIC_ +%token GLOBAL_ +%token HELIOECLIPTIC_ +%token ICRS_ +%token IMAGE_ +%token J2000_ +%token LEVEL_ +%token LEVELS_ +%token LINEAR_ +%token N_ +%token NO_ +%token OFF_ +%token ON_ +%token PHYSICAL_ +%token SUPERGALACTIC_ +%token TRUE_ +%token VERSION_ +%token WCS_ +%token WCSA_ +%token WCSB_ +%token WCSC_ +%token WCSD_ +%token WCSE_ +%token WCSF_ +%token WCSG_ +%token WCSH_ +%token WCSI_ +%token WCSJ_ +%token WCSK_ +%token WCSL_ +%token WCSM_ +%token WCSN_ +%token WCSO_ +%token WCSP_ +%token WCSQ_ +%token WCSR_ +%token WCSS_ +%token WCST_ +%token WCSU_ +%token WCSV_ +%token WCSW_ +%token WCSX_ +%token WCSY_ +%token WCSZ_ +%token WIDTH_ +%token Y_ +%token YES_ + +%% + +start : initGlobal commands + ; + +commands: commands command terminator + | command terminator + ; + +command : /* empty */ + | DEBUG_ debug + | VERSION_ {cerr << "DS9 Contour File 7.5" << endl;} + + | GLOBAL_ global comment + | coordSystem comment + { + globalSystem=(Coord::CoordSystem)$1; + } + | skyFrame comment + { + globalSystem=globalWCS; + globalSky=(Coord::SkyFrame)$1; + } + | LINEAR_ comment + { + globalSystem=globalWCS; globalSky=Coord::FK5; + } + | LEVELS_ '=' '(' levels ')' + | LEVEL_ '=' numeric {localLevel = $3} initLocal comment newcl + | LEVEL_ '=' numeric {localLevel = $3} initLocal local comment newcl + | '(' comment + { + if (cl) + cc = new Contour(cl); + } + | nodes + | ')' comment + { + if (cc && cl) + cl->lcontour().append(cc); + } + | '#' {DISCARD_(1);} STRING + ; + +levels : levels sp numeric + | numeric + ; + +newcl : + { + if (cl) + fr->contourAppendCmd(cl); + cl = new ContourLevel(fr, localLevel, localColor, localWidth, localDash, localDashList); + } + ; + +nodes : nodes sp node + | node + ; + +node : coord comment + { + if (cc) + cc->lvertex().append(new Vertex($1)); + } + ; + +comment : /* empty */ + | '#' {DISCARD_(1);} STRING + ; + +terminator: '\n' + | ';' + | EOF_ + { + if (cl) + fr->contourAppendCmd(cl); + YYACCEPT; + } + ; + +numeric : REAL {$$=$1;} + | INT {$$=$1;} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + ; + +yesno : INT {$$=($1 ? 1 : 0);} + + | YES_ {$$=1;} + | Y_ {$$=1;} + | ON_ {$$=1;} + | TRUE_ {$$=1;} + + | NO_ {$$=0;} + | N_ {$$=0;} + | OFF_ {$$=0;} + | FALSE_ {$$=0;} + ; + +sp : /* empty */ + | ',' + ; + +sexagesimal: SEXSTR {$$ = parseSEXStr($1);} + ; + +hms : HMSSTR {$$ = parseHMSStr($1);} + ; + +dms : DMSSTR {$$ = parseDMSStr($1);} + ; + +initGlobal: { + cl = NULL; + cc = NULL; + globalSystem = Coord::WCS; + globalWCS = fr->wcsSystem(); + globalSky = fr->wcsSky(); + strcpy(globalColor,"green"); + globalDash = 0; + globalDashList[0] = 8; + globalDashList[1] = 3; + globalWidth = 1; + } + ; + +initLocal: { + strcpy(localColor,globalColor); + localDash = globalDash; + localDashList[0] = globalDashList[0]; + localDashList[1] = globalDashList[1]; + localWidth = globalWidth; + } + ; + +coordSystem :IMAGE_ {$$ = Coord::IMAGE;} + | PHYSICAL_ {$$ = Coord::PHYSICAL;} + | DETECTOR_ {$$ = Coord::DETECTOR;} + | AMPLIFIER_ {$$ = Coord::AMPLIFIER;} + | wcsSystem {$$ = $1; globalWCS = (Coord::CoordSystem)$1;} + ; + +wcsSystem : WCS_ {$$ = Coord::WCS;} + | WCSA_ {$$ = Coord::WCSA;} + | WCSB_ {$$ = Coord::WCSB;} + | WCSC_ {$$ = Coord::WCSC;} + | WCSD_ {$$ = Coord::WCSD;} + | WCSE_ {$$ = Coord::WCSE;} + | WCSF_ {$$ = Coord::WCSF;} + | WCSG_ {$$ = Coord::WCSG;} + | WCSH_ {$$ = Coord::WCSH;} + | WCSI_ {$$ = Coord::WCSI;} + | WCSJ_ {$$ = Coord::WCSJ;} + | WCSK_ {$$ = Coord::WCSK;} + | WCSL_ {$$ = Coord::WCSL;} + | WCSM_ {$$ = Coord::WCSM;} + | WCSN_ {$$ = Coord::WCSN;} + | WCSO_ {$$ = Coord::WCSO;} + | WCSP_ {$$ = Coord::WCSP;} + | WCSQ_ {$$ = Coord::WCSQ;} + | WCSR_ {$$ = Coord::WCSR;} + | WCSS_ {$$ = Coord::WCSS;} + | WCST_ {$$ = Coord::WCST;} + | WCSU_ {$$ = Coord::WCSU;} + | WCSV_ {$$ = Coord::WCSV;} + | WCSW_ {$$ = Coord::WCSW;} + | WCSX_ {$$ = Coord::WCSX;} + | WCSY_ {$$ = Coord::WCSY;} + | WCSZ_ {$$ = Coord::WCSZ;} + ; + +skyFrame : FK4_ {$$ = Coord::FK4;} + | B1950_ {$$ = Coord::FK4;} + | FK4_NO_E_ {$$ = Coord::FK4_NO_E;} + | FK5_ {$$ = Coord::FK5;} + | J2000_ {$$ = Coord::FK5;} + | ICRS_ {$$ = Coord::ICRS;} + | GALACTIC_ {$$ = Coord::GALACTIC;} + | SUPERGALACTIC_ {$$ = Coord::SUPERGALACTIC;} + | ECLIPTIC_ {$$ = Coord::ECLIPTIC;} + | HELIOECLIPTIC_ {$$ = Coord::HELIOECLIPTIC;} + ; + +global : global sp globalProperty + | globalProperty + ; + +globalProperty : COLOR_ '=' STRING {strncpy(globalColor,$3,16);} + | DASH_ '=' yesno {globalDash = $3;} + | DASHLIST_ '=' INT INT {globalDashList[0] =$3; globalDashList[1] =$4;} + | WCS_ '=' wcsSystem {globalWCS = (Coord::CoordSystem)$3;} + | WIDTH_ '=' INT {globalWidth = $3;} + ; + +local : local sp localProperty + | localProperty + ; + +localProperty : COLOR_ '=' STRING {strncpy(localColor,$3,16);} + | DASH_ '=' yesno {localDash = $3;} + | DASHLIST_ '=' INT INT {localDashList[0] =$3; localDashList[1] =$4;} + | WIDTH_ '=' INT {localWidth = $3;} + ; + +coord : sexagesimal sp sexagesimal + { + Vector r; + Coord::CoordSystem sys = checkWCSSystem(); + Coord::SkyFrame sky = checkWCSSky(); + if (sky == Coord::GALACTIC || sky == Coord::ECLIPTIC) + r = FITSPTR->mapToRef(Vector($1,$3), sys, sky); + else + r = FITSPTR->mapToRef(Vector($1*360./24.,$3), sys, sky); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | hms sp dms + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), + checkWCSSystem(), checkWCSSky()); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | dms sp dms + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), + checkWCSSystem(), checkWCSSky()); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | numeric sp numeric + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), globalSystem, globalSky); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | ANGDEGREE sp ANGDEGREE + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), + checkWCSSystem(), checkWCSSky()); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | IMGCOORD sp IMGCOORD + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), Coord::IMAGE); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | PHYCOORD sp PHYCOORD + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), Coord::PHYSICAL); + $$[0] = r[0]; + $$[1] = r[1]; + } + ; +%% + +static Coord::CoordSystem checkWCSSystem() +{ + switch (globalSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::WCS; + default: + return globalSystem; + } +} + +static Coord::SkyFrame checkWCSSky() +{ + switch (globalSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::FK5; + default: + return globalSky; + } +} + diff --git a/tksao/frame/coord.C b/tksao/frame/coord.C new file mode 100644 index 0000000..9556f99 --- /dev/null +++ b/tksao/frame/coord.C @@ -0,0 +1,405 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "coord.h" +#include "util.h" +#include "fitsimage.h" + +Coord coord; + +static const char* coordSystemStr_[] = { + "data", + "image", + "physical", + "amplifier", + "detector", + "wcs", + "wcsa", + "wcsb", + "wcsc", + "wcsd", + "wcse", + "wcsf", + "wcsg", + "wcsh", + "wcsi", + "wcsj", + "wcsk", + "wcsl", + "wcsm", + "wcsn", + "wcso", + "wcsp", + "wcsq", + "wcsr", + "wcss", + "wcst", + "wcsu", + "wcsv", + "wcsw", + "wcsx", + "wcsy", + "wcsz", + "wcs0" + }; + +static const char* skyFrameStr_[] = { + "fk4", + "fk4-no-e", + "fk5", + "icrs", + "galactic", + "supergalactic", + "ecliptic", + "helioecliptic", + "gappt" + }; + +static const char* skyFormatStr_[] = { + "degrees", + "sexagesimal", + }; + +static const char* skyDistStr_[] = { + "degrees", + "arcmin", + "arcsec" + }; + +const char* Coord::coordSystemStr(int ii) +{ + return coordSystemStr_[ii]; +} + +const char* Coord::skyFrameStr(int ii) +{ + return skyFrameStr_[ii]; +} + +const char* Coord::skyFormatStr(int ii) +{ + return skyFormatStr_[ii]; +} + +const char* Coord::skyDistStr(int ii) +{ + return skyDistStr_[ii]; +} + +void Coord::listCoordSystem(ostream& str, CoordSystem sys, SkyFrame sky, + FitsImage* ptr) +{ + + switch (sys) { + case IMAGE: + str << "image"; + return; + case PHYSICAL: + str << "physical"; + return; + case DETECTOR: + str << "detector"; + return; + case AMPLIFIER: + str << "amplifier"; + return; + default: + if (ptr->hasWCSCel(sys)) { + switch (sky) { + case FK4: + str << "fk4"; + return; + case FK4_NO_E: + str << "fk4-no-e"; + return; + case FK5: + str << "fk5"; + return; + case ICRS: + str << "icrs"; + return; + case GALACTIC: + str << "galactic"; + return; + case SUPERGALACTIC: + str << "supergalactic"; + return; + case ECLIPTIC: + str << "ecliptic"; + return; + case HELIOECLIPTIC: + str << "helioecliptic"; + return; + } + } + else { + str << "wcs"; + if (sys > WCS) + str << (char)(sys-WCS+'`'); + } + return; + } +} + +void Coord::listDistSystem(ostream& str, CoordSystem sys, SkyDist format, + FitsImage* ptr) +{ + switch (sys) { + case IMAGE: + str << "image"; + return; + case PHYSICAL: + str << "physical"; + return; + case DETECTOR: + str << "detector"; + return; + case AMPLIFIER: + str << "amplifier"; + return; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case DEGREE: + str << "degrees"; + return; + case ARCMIN: + str << "arcmin"; + return; + case ARCSEC: + str << "arcsec"; + return; + } + } + else + str << "pixels"; + + return; + } +} + + void Coord::listProsCoordSystem(ostream& str, CoordSystem sys, SkyFrame sky) +{ + switch (sys) { + case IMAGE: + str << "logical"; + return; + case PHYSICAL: + str << "physical"; + return; + case DETECTOR: + str << "detector"; + return; + case AMPLIFIER: + str << "amplifier"; + return; + default: + switch (sky) { + case FK4: + str << "b1950"; + return; + case FK4_NO_E: + str << "fk4-no-e"; + return; + case FK5: + str << "j2000"; + return; + case ICRS: + str << "icrs"; + return; + case GALACTIC: + str << "galactic"; + return; + case SUPERGALACTIC: + str << "supergalactic"; + return; + case ECLIPTIC: + str << "ecliptic"; + return; + case HELIOECLIPTIC: + str << "helioecliptic"; + return; + } + } +} + + void Coord::strToCoordSystem(const char* str, CoordSystem wcssys, + CoordSystem* sys, SkyFrame* sky) +{ + if (!str) { + *sys = PHYSICAL; + *sky = FK5; + } + else if (STRCMP(str,"image",5)) { + *sys = IMAGE; + *sky = FK5; + } + else if (STRCMP(str,"physical",8)) { + *sys = PHYSICAL; + *sky = FK5; + } + else if (STRCMP(str,"amplifier",9)) { + *sys = AMPLIFIER; + *sky = FK5; + } + else if (STRCMP(str,"detector",9)) { + *sys = DETECTOR; + *sky = FK5; + } + else if (STRCMP(str,"fk4-no-e",8)) { + *sys = wcssys; + *sky = FK4_NO_E; + } + else if (STRCMP(str,"fk4",3)) { + *sys = wcssys; + *sky = FK4; + } + else if (STRCMP(str,"fk5",3)) { + *sys = wcssys; + *sky = FK5; + } + else if (STRCMP(str,"icrs",4)) { + *sys = wcssys; + *sky = ICRS; + } + else if (STRCMP(str,"galactic",8)) { + *sys = wcssys; + *sky = GALACTIC; + } + else if (STRCMP(str,"supergalactic",12)) { + *sys = wcssys; + *sky = SUPERGALACTIC; + } + else if (STRCMP(str,"ecliptic",8)) { + *sys = wcssys; + *sky = ECLIPTIC; + } + else if (STRCMP(str,"helioecliptic",12)) { + *sys = wcssys; + *sky = HELIOECLIPTIC; + } + else if (STRCMP(str,"wcs",3)) { + *sys = wcssys; + *sky = FK5; + } + else if (STRCMP(str,"linear",6)) { + *sys = wcssys; + *sky = FK5; + } + else { + *sys = PHYSICAL; + *sky = FK5; + } +} + +void Coord::strToSkyFormat(const char* str, SkyFormat* format) +{ + if (!str) + *format = DEGREES; + else if (STRCMP(str,"degrees",7)) + *format = DEGREES; + else if (STRCMP(str,"degree",6)) + *format = DEGREES; + else if (STRCMP(str,"deg",3)) + *format = DEGREES; + else if (STRCMP(str,"hms",3)) + *format = SEXAGESIMAL; + else if (STRCMP(str,"h:m:s",5)) + *format = SEXAGESIMAL; + else if (STRCMP(str,"\"h:m:s\"",7)) + *format = SEXAGESIMAL; + else if (STRCMP(str,"dms",3)) + *format = SEXAGESIMAL; + else if (STRCMP(str,"d:m:s",5)) + *format = SEXAGESIMAL; + else if (STRCMP(str,"\"d:m:s\"",7)) + *format = SEXAGESIMAL; + else + *format = DEGREES; +} + +void Coord::strToSkyDist(const char* str, SkyDist* dist) +{ + if (!str) + *dist = DEGREE; + else if (STRCMP(str,"degrees",7)) + *dist = DEGREE; + else if (STRCMP(str,"degree",6)) + *dist = DEGREE; + else if (STRCMP(str,"deg",3)) + *dist = DEGREE; + else if (STRCMP(str,"arcminute",9)) + *dist = ARCMIN; + else if (STRCMP(str,"arcmin",6)) + *dist = ARCMIN; + else if (STRCMP(str,"arcsecond",9)) + *dist = ARCSEC; + else if (STRCMP(str,"arcsec",6)) + *dist = ARCSEC; + else + *dist = DEGREE; +} + + void Coord::strToAngleFormat(const char* str, AngleFormat* format) +{ + if (!str) + *format = DEG; + else if (STRCMP(str,"degrees",7)) + *format = DEG; + else if (STRCMP(str,"degree",6)) + *format = DEG; + else if (STRCMP(str,"deg",3)) + *format = DEG; + else if (STRCMP(str,"radian",6)) + *format = RAD; + else if (STRCMP(str,"rad",3)) + *format = RAD; + else + *format = DEG; +} + +void Coord::strToDistSystem(const char* str, CoordSystem wcssys, + CoordSystem* sys, SkyDist* dist) +{ + if (!str) { + *sys = PHYSICAL; + *dist = DEGREE; + } + else if (STRCMP(str,"image",5)) { + *sys = IMAGE; + *dist = DEGREE; + } + else if (STRCMP(str,"physical",8)) { + *sys = PHYSICAL; + *dist = DEGREE; + } + else if (STRCMP(str,"amplifier",9)) { + *sys = AMPLIFIER; + *dist = DEGREE; + } + else if (STRCMP(str,"detector",8)) { + *sys = DETECTOR; + *dist = DEGREE; + } + else if (STRCMP(str,"degrees",7)) { + *sys = wcssys; + *dist = DEGREE; + } + else if (STRCMP(str,"arcmin",6)) { + *sys = wcssys; + *dist = ARCMIN; + } + else if (STRCMP(str,"arcsec",6)) { + *sys = wcssys; + *dist = ARCSEC; + } + else if (STRCMP(str,"pixels",6)) { + *sys = PHYSICAL; + *dist = DEGREE; + } + else { + *sys = PHYSICAL; + *dist = DEGREE; + } +} diff --git a/tksao/frame/coord.h b/tksao/frame/coord.h new file mode 100644 index 0000000..d84f3ed --- /dev/null +++ b/tksao/frame/coord.h @@ -0,0 +1,54 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __coord_h__ +#define __coord_h__ + +#include + +#include +#include +#include +using namespace std; + +class FitsImage; + +class Coord { + public: + enum InternalSystem {WINDOW, CANVAS, WIDGET, USER, REF, + PANNER, MAGNIFIER, PS}; + + enum CoordSystem {DATA, IMAGE, PHYSICAL, AMPLIFIER, DETECTOR, WCS, + WCSA, WCSB, WCSC, WCSD, WCSE, WCSF, WCSG, WCSH, WCSI, + WCSJ, WCSK, WCSL, WCSM, WCSN, WCSO, WCSP, WCSQ, WCSR, + WCSS, WCST, WCSU, WCSV, WCSW, WCSX, WCSY, WCSZ, WCS0}; + + enum SkyFrame {FK4, FK4_NO_E, FK5, ICRS, GALACTIC, SUPERGALACTIC, + ECLIPTIC, HELIOECLIPTIC}; + + enum SkyFormat {DEGREES, SEXAGESIMAL}; + enum SkyDist {DEGREE, ARCMIN, ARCSEC}; + enum AngleFormat {DEG, RAD}; + enum Orientation {NORMAL, XX, YY, XY}; + + public: + void listCoordSystem(ostream&, CoordSystem, SkyFrame, FitsImage*); + void listDistSystem(ostream&, CoordSystem, SkyDist, FitsImage*); + void listProsCoordSystem(ostream&, CoordSystem, SkyFrame); + + void strToCoordSystem(const char*, CoordSystem, CoordSystem*, SkyFrame*); + void strToSkyFormat(const char*, SkyFormat*); + void strToSkyDist(const char*, SkyDist*); + void strToDistSystem(const char*, CoordSystem, CoordSystem*, SkyDist*); + void strToAngleFormat(const char*, AngleFormat*); + + const char* coordSystemStr(int ii); + const char* skyFrameStr(int ii); + const char* skyFormatStr(int ii); + const char* skyDistStr(int ii); +}; + +extern Coord coord; + +#endif diff --git a/tksao/frame/cpanda.C b/tksao/frame/cpanda.C new file mode 100644 index 0000000..2ba2fdb --- /dev/null +++ b/tksao/frame/cpanda.C @@ -0,0 +1,782 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "cpanda.h" +#include "fitsimage.h" + +Cpanda::Cpanda(Base* p, const Vector& ctr, + double a1, double a2, int an, + double r1, double r2, int rn, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BaseEllipse(p, ctr, 0, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = rn+1; + annuli_ = new Vector[numAnnuli_]; + + for (int ii=0; ii& tg, const List& cb) + : BaseEllipse(p, ctr, 0, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = rn; + annuli_ = new Vector[numAnnuli_]; + + for (int ii=0; iigetColor("red")); + else if (ii == numAngles_-1) + XSetForeground(display, gc, parent->getColor("blue")); + else + XSetForeground(display, gc, color); + } + else + XSetForeground(display, gc, color); + } + + XDrawLine(display, drawable, lgc, rr0[0], rr0[1], rr1[0], rr1[1]); + } +} + +void Cpanda::renderPS(int mode) +{ + BaseEllipse::renderPS(mode); + + Vector r0 = annuli_[0]; + Vector r1 = annuli_[numAnnuli_-1]; + + for (int ii=0; iicanvas) << ' ' + << "moveto " + << rr1.TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } +} + +#ifdef MAC_OSX_TK +void Cpanda::renderMACOSX() +{ + BaseEllipse::renderMACOSX(); + + Vector r0 = annuli_[0]; + Vector r1 = annuli_[numAnnuli_-1]; + + for (int ii=0; ii4) { + int hh = h-4-1; + + if (numAnnuli_>2 && hh2 && hh<(numAnnuli_+numAngles_)) { + hh -= numAnnuli_; + deleteAngle(hh); + } + + numHandle = 4 + numAnnuli_ + numAngles_; + + startAng_ = angles_[0]; + stopAng_ = angles_[numAngles_-1]; + + updateBBox(); + doCallBack(CallBack::EDITCB); + } +} + +int Cpanda::isIn(const Vector& vv, Coord::InternalSystem sys, int nn, int aa) +{ + Vector pp = bckMap(vv,sys); + return BaseEllipse::isIn(vv,sys,nn) && isInAngle(pp,aa); +} + +void Cpanda::analysis(AnalysisTask mm, int which) +{ + switch (mm) { + case PANDA: + if (!analysisPanda_ && which) { + addCallBack(CallBack::MOVECB, analysisPandaCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisPandaCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITENDCB, analysisPandaCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisPandaCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisPandaCB_[1], + parent->options->cmdName); + } + if (analysisPanda_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisPandaCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisPandaCB_[0]); + deleteCallBack(CallBack::EDITENDCB, analysisPandaCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisPandaCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisPandaCB_[1]); + } + + analysisPanda_ = which; + break; + case STATS: + if (!analysisStats_ && which) { + addCallBack(CallBack::MOVECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITENDCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisStatsCB_[1], + parent->options->cmdName); + } + if (analysisStats_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITENDCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisStatsCB_[1]); + } + + analysisStats_ = which; + break; + default: + // na + break; + } +} + +void Cpanda::analysisPanda(Coord::CoordSystem sys) +{ + double* xx; + double* yy; + double* ee; + + BBox* bb = new BBox[numAnnuli_]; + for (int ii=0; iimarkerAnalysisPanda(this, &xx, &yy, &ee, + numAnnuli_-1, annuli_, + numAngles_-1, angles_, + bb, sys); + analysisXYEResult(xx, yy, ee, num); +} + +void Cpanda::analysisStats(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + ostringstream str; + BBox* bb = new BBox[numAnnuli_]; + for (int ii=0; iimarkerAnalysisStats(this, str, numAnnuli_-1, numAngles_-1, bb, sys, sky); + str << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +// list +void Cpanda::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + int regular = 1; + if (numAngles_>2) { + double delta; + if (angles_[1] > angles_[0]) + delta = angles_[1]-angles_[0]; + else + delta = angles_[1]+M_TWOPI-angles_[0]; + + for (int ii=2; ii angles_[ii-1]) + diff = angles_[ii]-angles_[ii-1]; + else + diff = angles_[ii]+M_TWOPI-angles_[ii-1]; + + if (!teq(diff,delta,FLT_EPSILON)) { + regular = 0; + break; + } + } + } + + if (numAnnuli_>2) { + double delta = annuli_[1][0]-annuli_[0][0]; + for (int i=2; ifindFits(sys,center); + listPre(str, sys, sky, ptr, strip, 0); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listANonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + double a1 = radToDeg(parent->mapAngleFromRef(angles_[0],sys,sky)); + double a2 = radToDeg(parent->mapAngleFromRef(angles_[numAngles_-1],sys,sky)); + double r1 = ptr->mapLenFromRef(annuli_[0][0],sys,Coord::ARCSEC); + double r2 = ptr->mapLenFromRef(annuli_[numAnnuli_-1][0],sys,Coord::ARCSEC); + if (a2<=a1+FLT_EPSILON) + a2 += 360; + + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' + << setprecision(10) << vv << ',' + << setprecision(8) << a1 << ',' << a2 <<',' << numAngles_-1 << ',' + << setprecision(3) << fixed << r1 << '"' << ',' + << r2 << '"' << ','; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << numAnnuli_-1 << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' + << ra << ',' << dec << ',' + << setprecision(8) << a1 << ',' << a2 <<',' << numAngles_-1 << ',' + << setprecision(3) << fixed << r1 << '"' << ',' + << r2 << '"' << ','; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << numAnnuli_-1 << ')'; + break; + } + } + else + listANonCel(ptr, str, sys); + } + + listPost(str, conj, strip); +} + +void Cpanda::listANonCel(FitsImage* ptr, ostream& str, Coord::CoordSystem sys) +{ + double a1 = radToDeg(parent->mapAngleFromRef(angles_[0],sys)); + double a2 = radToDeg(parent->mapAngleFromRef(angles_[numAngles_-1],sys)); + if (a2<=a1+FLT_EPSILON) + a2 += 360; + + Vector vv = ptr->mapFromRef(center,sys); + double r1 = ptr->mapLenFromRef(annuli_[0][0],sys); + double r2 = ptr->mapLenFromRef(annuli_[numAnnuli_-1][0],sys); + str << type_ << '(' << setprecision(8) << vv << ',' + << a1 << ',' << a2 << ',' << numAngles_-1 << ',' + << r1 << ',' << r2 << ',' << numAnnuli_-1 << ')'; +} + +void Cpanda::listB(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + FitsImage* ptr = parent->findFits(sys,center); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listBNonCel(ptr, str, sys, sky, format, conj, strip); + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + for (int jj=1; jjmapFromRef(center,sys); + for (int jj=1; jjmapAngleFromRef(angles_[jj-1],sys)); + double a2 = radToDeg(parent->mapAngleFromRef(angles_[jj],sys)); + if (a2<=a1+FLT_EPSILON) + a2 += 360; + + for (int ii=1; iimapLenFromRef(annuli_[ii-1][0],sys); + double r2 = ptr->mapLenFromRef(annuli_[ii][0],sys); + str << type_ << '(' + << setprecision(8) << vv << ',' + << a1 << ',' << a2 << ",1," + << r1 << ',' << r2 << ",1)"; + + if (!strip) { + if (conj) + str << " ||"; + + str << " # panda="; + if (ii==1 && jj==1 && !strip) { + str << '('; + for (int kk=0; kkmapAngleFromRef(angles_[kk],sys); + str << radToDeg(ar) << ((kkmapLenFromRef(annuli_[kk][0],sys); + str << rr << ((kkmapAngleFromRef(angles_[jj-1],sys,sky)); + double a2 = radToDeg(parent->mapAngleFromRef(angles_[jj],sys,sky)); + if (a2<=a1+FLT_EPSILON) + a2 += 360; + + double r1 = ptr->mapLenFromRef(annuli_[ii-1][0],sys,Coord::ARCSEC); + double r2 = ptr->mapLenFromRef(annuli_[ii][0],sys,Coord::ARCSEC); + + str << setprecision(10) << a1 << ',' << a2 << ",1," + << setprecision(3) << fixed << r1 << '"' << ',' << r2 << '"' << ",1)"; + str.unsetf(ios_base::floatfield); + + if (!strip) { + if (conj) + str << " ||"; + + str << " # panda="; + if (ii==1 && jj==1 && !strip) { + str << '(' << setprecision(8); + for (int kk=0; kkmapAngleFromRef(angles_[kk],sys,sky); + str << radToDeg(aa) << ((kkmapLenFromRef(annuli_[kk][0],sys,Coord::ARCSEC); + str << rr << '"' << ((kkfindFits(sys,center); + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowCenter(ptr,sys,sky,format); + XMLRowRadiusX(ptr,sys,annuli_,numAnnuli_); + XMLRowAng(sys,sky,angles_,numAngles_); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} + +void Cpanda::listCiao(ostream& str, Coord::CoordSystem sys, int strip) +{ + FitsImage* ptr = parent->findFits(); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + Vector vv = ptr->mapFromRef(center,Coord::PHYSICAL); + for (int ii=0; iimapLenFromRef(annuli_[ii][0],Coord::PHYSICAL); + double r2 = ptr->mapLenFromRef(annuli_[ii+1][0],Coord::PHYSICAL); + for (int jj=0; jjhasWCSCel(sys)) { + listRADEC(ptr,center,sys,Coord::FK5,Coord::SEXAGESIMAL); + for (int ii=0; iimapLenFromRef(annuli_[ii][0],sys,Coord::ARCMIN); + double r2 = ptr->mapLenFromRef(annuli_[ii+1][0],sys,Coord::ARCMIN); + for (int jj=0; jj& tg, const List& cb); + + Cpanda(Base* p, const Vector& ctr, + int an, double* a, + int rn, double* r, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + + Marker* dup() {return new Cpanda(*this);} + + void edit(const Vector&, int); + void editEnd(); + + void rotateBegin() {} + void rotate(const Vector& v, int h) {} + void rotateEnd() {} + + int addAnnuli(const Vector&); + int addAngles(const Vector&); + void setAnglesAnnuli(double, double, int, Vector, Vector, int); + void setAnglesAnnuli(const double*, int, const Vector*, int); + void deleteAnglesAnnuli(int h); + + void analysis(AnalysisTask, int); + void analysisPanda(Coord::CoordSystem sys); + void analysisStats(Coord::CoordSystem, Coord::SkyFrame sky); + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, + int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void listCiao(ostream&, Coord::CoordSystem, int); + + // special composite funtionality + void setComposite(const Matrix&, double); +}; + +#endif diff --git a/tksao/frame/ds9lex.C b/tksao/frame/ds9lex.C new file mode 100644 index 0000000..f856772 --- /dev/null +++ b/tksao/frame/ds9lex.C @@ -0,0 +1,3488 @@ +#line 2 "frame/ds9lex.C" + +#line 4 "frame/ds9lex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer mkFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *mkalloc (yy_size_t ); +void *mkrealloc (void *,yy_size_t ); +void mkfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 153 +#define YY_END_OF_BUFFER 154 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[540] = + { 0, + 0, 0, 2, 2, 154, 152, 148, 151, 152, 152, + 152, 152, 152, 152, 116, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147, 147, 54, 147, + 147, 147, 147, 147, 147, 147, 147, 147, 113, 114, + 152, 152, 2, 1, 148, 149, 0, 144, 0, 0, + 145, 0, 116, 118, 131, 127, 117, 116, 0, 147, + 119, 147, 147, 125, 123, 121, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, + + 147, 147, 147, 55, 147, 57, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 150, 0, 146, 2, + 0, 118, 133, 129, 117, 119, 0, 0, 125, 123, + 121, 132, 128, 120, 0, 126, 124, 122, 119, 0, + 147, 0, 117, 147, 147, 147, 147, 147, 147, 147, + 147, 11, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147, 147, 33, 147, + 147, 147, 147, 37, 39, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 49, 147, 147, 56, 147, + + 147, 60, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 73, 147, 147, 147, 147, 147, 147, 147, + 147, 84, 147, 115, 141, 134, 130, 0, 117, 0, + 0, 118, 0, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 22, 147, 147, 147, 147, 147, 147, 29, 147, + 147, 147, 147, 147, 0, 40, 147, 147, 147, 147, + 45, 147, 147, 147, 147, 51, 53, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 74, 77, 78, 147, 147, 147, 147, 147, 111, + + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 147, 0, 0, 0, + 0, 135, 0, 147, 0, 147, 147, 147, 147, 147, + 7, 8, 147, 10, 147, 147, 147, 147, 17, 147, + 147, 147, 21, 147, 24, 147, 147, 147, 147, 147, + 147, 147, 34, 35, 36, 0, 147, 147, 147, 147, + 147, 48, 147, 50, 147, 58, 147, 147, 62, 147, + 147, 147, 147, 147, 68, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 147, 112, 0, 0, 0, + + 136, 135, 0, 0, 139, 0, 0, 137, 147, 147, + 5, 6, 147, 147, 13, 147, 15, 147, 147, 20, + 147, 147, 26, 147, 147, 147, 147, 32, 0, 147, + 42, 147, 147, 46, 147, 52, 147, 61, 147, 147, + 147, 66, 67, 147, 69, 71, 147, 147, 147, 147, + 147, 81, 79, 147, 142, 139, 137, 140, 138, 147, + 4, 147, 147, 147, 147, 18, 147, 147, 25, 147, + 28, 147, 30, 0, 147, 147, 147, 47, 147, 63, + 147, 147, 70, 147, 147, 147, 147, 147, 80, 0, + 147, 147, 147, 14, 16, 147, 23, 27, 31, 38, + + 41, 147, 44, 59, 147, 65, 147, 147, 147, 147, + 83, 0, 3, 147, 12, 19, 147, 147, 147, 75, + 147, 147, 0, 9, 147, 64, 147, 76, 82, 0, + 147, 147, 0, 147, 147, 143, 43, 72, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 5, 6, 1, 1, 1, 7, 1, + 1, 1, 8, 1, 9, 10, 1, 11, 12, 13, + 14, 15, 16, 17, 17, 17, 18, 19, 1, 1, + 1, 1, 1, 1, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 1, 46, 1, 1, 1, 1, 47, 48, 49, 50, + + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 1, 74, 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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[75] = + { 0, + 1, 1, 2, 1, 3, 1, 3, 1, 1, 3, + 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, + 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 1, 4, 4, 4, 4, + 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[558] = + { 0, + 0, 0, 181, 180, 179, 4306, 176, 4306, 167, 160, + 0, 156, 65, 73, 87, 102, 162, 213, 140, 273, + 331, 170, 211, 388, 113, 195, 201, 233, 266, 274, + 429, 166, 305, 306, 489, 364, 372, 406, 244, 426, + 80, 84, 0, 4306, 155, 4306, 151, 4306, 0, 148, + 4306, 456, 549, 609, 4306, 4306, 669, 729, 489, 337, + 789, 507, 516, 396, 425, 433, 536, 575, 804, 532, + 629, 635, 586, 648, 691, 695, 758, 708, 805, 716, + 864, 766, 815, 823, 830, 857, 840, 865, 892, 899, + 872, 914, 921, 929, 937, 947, 960, 954, 970, 989, + + 978, 997, 1005, 582, 1016, 684, 1026, 1032, 1045, 1051, + 1055, 1073, 1080, 1088, 1103, 1113, 1121, 1144, 1145, 1152, + 1162, 1172, 1183, 1191, 1202, 1221, 4306, 80, 4306, 0, + 0, 1250, 4306, 4306, 1264, 1276, 1287, 1295, 4306, 4306, + 4306, 4306, 4306, 4306, 1306, 4306, 4306, 4306, 4306, 1314, + 84, 1323, 1337, 1345, 1239, 1359, 1360, 1366, 1229, 1376, + 1377, 1402, 1383, 1384, 1430, 1429, 1403, 1440, 1448, 1461, + 1465, 1482, 1488, 1492, 1499, 1516, 1515, 1523, 1531, 1542, + 1550, 1558, 1575, 1557, 1585, 1586, 1593, 1601, 1614, 1624, + 1625, 1631, 1648, 1649, 1665, 1672, 1676, 1689, 1699, 1705, + + 1712, 1716, 1727, 1734, 1738, 1751, 1755, 1774, 1778, 1782, + 1807, 1811, 1817, 1824, 1835, 1841, 1842, 1848, 1859, 1870, + 1877, 1932, 1912, 1888, 0, 4306, 4306, 1994, 2016, 2024, + 1912, 2047, 2033, 2056, 2074, 2088, 2089, 2095, 2105, 2099, + 2120, 2127, 2144, 2150, 2160, 2154, 2177, 2181, 2187, 2204, + 2212, 2232, 2233, 2248, 2255, 2259, 2263, 2282, 1895, 2288, + 2295, 2306, 2324, 2330, 84, 2341, 2349, 2356, 2360, 2376, + 2377, 2383, 2394, 2404, 2405, 2412, 2420, 2430, 2436, 2447, + 2446, 2453, 2463, 2476, 2483, 2489, 2506, 2510, 2514, 2525, + 2521, 2532, 2549, 2557, 2568, 2576, 2583, 2593, 2601, 2594, + + 2609, 2625, 2626, 2632, 2633, 2643, 2650, 2654, 2658, 2665, + 2669, 2673, 2680, 2684, 2688, 2695, 2699, 2703, 2710, 2714, + 2718, 2725, 2729, 2733, 2740, 2744, 2748, 0, 2766, 2775, + 2002, 2793, 2064, 2802, 2783, 2811, 2825, 2826, 2832, 2836, + 2755, 2849, 2864, 2865, 2881, 2889, 2897, 2905, 2915, 2916, + 2932, 2933, 2950, 2954, 2958, 2969, 2979, 2980, 2995, 3003, + 3016, 3024, 3031, 3042, 3046, 85, 3053, 3057, 3063, 3070, + 3086, 3090, 3094, 3101, 3111, 3117, 3121, 3128, 3144, 3145, + 3152, 3162, 3173, 3177, 3181, 3197, 3198, 3204, 3208, 3226, + 3233, 3239, 3246, 3264, 3268, 3272, 3285, 0, 3306, 3324, + + 3296, 3334, 3342, 3352, 3367, 3380, 3388, 3368, 3403, 3404, + 3414, 3420, 3427, 3433, 3444, 3452, 3465, 3471, 3484, 3488, + 3492, 3503, 3509, 3510, 3527, 3528, 3535, 3548, 144, 3556, + 3555, 3571, 3575, 3582, 3593, 3597, 3603, 3614, 3620, 3621, + 3627, 3638, 3642, 3649, 3657, 3664, 3665, 3672, 3685, 3689, + 3695, 3711, 3721, 3722, 0, 4306, 4306, 4306, 4306, 3729, + 3747, 3751, 3755, 3762, 3766, 3783, 3789, 3790, 3796, 3807, + 3815, 3826, 3830, 101, 3847, 3853, 3854, 3860, 3875, 3876, + 3882, 3883, 3893, 3909, 3910, 3916, 3937, 3938, 3945, 0, + 3964, 3965, 3971, 3975, 3981, 3992, 3998, 4002, 4008, 4306, + + 4019, 4025, 4026, 4032, 4042, 4049, 4050, 4067, 4068, 4074, + 4085, 0, 4089, 4104, 4105, 4112, 4123, 4131, 4138, 4142, + 4146, 4162, 0, 4161, 4169, 4185, 4191, 4195, 4202, 0, + 4210, 4217, 0, 4218, 4234, 4306, 4241, 4242, 4306, 4283, + 4287, 144, 4291, 4293, 4297, 4301, 132, 129, 127, 126, + 125, 124, 123, 104, 92, 91, 89 + } ; + +static yyconst flex_int16_t yy_def[558] = + { 0, + 539, 1, 540, 540, 539, 539, 539, 539, 539, 541, + 542, 543, 539, 539, 544, 544, 544, 17, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 21, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 539, 545, 546, 539, 539, 539, 541, 539, 547, 543, + 539, 539, 539, 539, 539, 539, 539, 544, 539, 544, + 544, 61, 61, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 539, 545, 539, 546, + 548, 54, 539, 539, 57, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 61, 539, 61, 61, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 539, 544, 544, 549, 539, 539, 539, 539, 539, + 539, 539, 539, 61, 61, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 539, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 550, 539, 539, + 539, 539, 539, 61, 539, 61, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 539, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 551, 539, 539, + + 539, 539, 539, 539, 544, 539, 539, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 539, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 552, 539, 539, 539, 539, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 539, 544, 544, 544, 544, 544, 544, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 553, + 544, 544, 544, 544, 544, 544, 544, 544, 544, 539, + + 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 554, 544, 544, 544, 544, 544, 544, 544, 544, + 544, 544, 555, 544, 544, 544, 544, 544, 544, 556, + 544, 544, 557, 544, 544, 539, 544, 544, 0, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539 + } ; + +static yyconst flex_int16_t yy_nxt[4381] = + { 0, + 6, 7, 8, 9, 10, 11, 12, 13, 13, 14, + 15, 15, 15, 15, 15, 15, 15, 15, 6, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 32, 41, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 32, 42, 6, 52, 53, 53, 53, 53, 53, + 53, 53, 53, 54, 54, 54, 54, 54, 54, 54, + 54, 55, 536, 56, 533, 530, 57, 58, 58, 58, + + 58, 58, 58, 58, 58, 59, 539, 523, 539, 61, + 62, 539, 127, 63, 64, 234, 366, 539, 429, 539, + 539, 65, 539, 66, 500, 100, 512, 490, 455, 398, + 328, 539, 225, 67, 68, 131, 61, 62, 69, 127, + 63, 64, 234, 366, 539, 429, 539, 49, 65, 539, + 66, 500, 474, 129, 51, 48, 45, 129, 539, 80, + 67, 68, 51, 81, 48, 69, 539, 82, 539, 46, + 539, 539, 539, 70, 539, 539, 539, 45, 539, 539, + 539, 71, 44, 44, 539, 72, 80, 539, 539, 92, + 81, 539, 539, 539, 82, 73, 74, 539, 539, 539, + + 93, 539, 539, 539, 539, 539, 539, 539, 71, 539, + 539, 539, 72, 539, 539, 539, 92, 539, 101, 539, + 539, 539, 73, 74, 60, 539, 539, 93, 102, 539, + 539, 539, 75, 539, 94, 539, 60, 539, 95, 539, + 76, 539, 539, 539, 539, 101, 77, 78, 539, 79, + 539, 539, 539, 539, 539, 102, 539, 539, 539, 75, + 539, 94, 539, 60, 539, 95, 103, 76, 539, 539, + 539, 539, 539, 77, 78, 539, 79, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 103, 83, 84, 539, 539, 105, 104, + + 539, 539, 539, 85, 539, 86, 106, 87, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 83, 84, 539, 539, 105, 104, 539, 539, 114, + 85, 539, 86, 106, 87, 539, 539, 539, 112, 115, + 539, 539, 539, 539, 113, 116, 539, 539, 539, 539, + 88, 539, 539, 539, 539, 539, 114, 539, 89, 539, + 90, 539, 539, 539, 91, 112, 115, 539, 539, 539, + 539, 113, 116, 539, 539, 539, 539, 88, 539, 539, + 539, 539, 539, 539, 539, 89, 539, 90, 539, 539, + 539, 91, 539, 539, 539, 123, 121, 539, 122, 539, + + 539, 539, 539, 539, 539, 539, 539, 539, 539, 96, + 539, 539, 539, 97, 539, 539, 539, 539, 539, 98, + 99, 539, 123, 121, 539, 122, 539, 124, 539, 539, + 539, 539, 539, 125, 539, 539, 96, 539, 539, 539, + 97, 539, 539, 539, 539, 539, 98, 99, 107, 126, + 539, 539, 539, 539, 124, 108, 109, 539, 60, 539, + 125, 539, 110, 539, 539, 111, 132, 132, 132, 132, + 132, 132, 132, 132, 539, 107, 126, 539, 539, 539, + 539, 539, 108, 109, 539, 60, 539, 539, 539, 110, + 539, 539, 111, 539, 539, 539, 539, 539, 539, 150, + + 150, 150, 150, 150, 150, 150, 150, 539, 117, 539, + 539, 539, 118, 539, 152, 152, 119, 153, 153, 153, + 153, 153, 153, 153, 153, 120, 154, 154, 154, 154, + 154, 154, 154, 154, 539, 117, 539, 539, 539, 118, + 539, 539, 539, 119, 539, 539, 539, 539, 539, 159, + 539, 539, 120, 133, 539, 134, 539, 539, 135, 53, + 53, 53, 53, 53, 53, 53, 53, 59, 539, 539, + 155, 136, 137, 539, 539, 138, 139, 539, 539, 539, + 539, 539, 539, 140, 539, 141, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 155, 136, 137, + + 539, 539, 138, 139, 539, 539, 539, 156, 539, 539, + 140, 539, 141, 142, 539, 143, 539, 539, 539, 54, + 54, 54, 54, 54, 54, 54, 54, 539, 162, 539, + 539, 144, 145, 539, 156, 539, 146, 539, 539, 539, + 539, 539, 539, 147, 539, 148, 539, 539, 539, 539, + 160, 539, 539, 539, 539, 162, 539, 539, 144, 145, + 161, 539, 539, 146, 539, 539, 539, 163, 539, 539, + 147, 539, 148, 55, 539, 56, 539, 160, 539, 54, + 54, 54, 54, 54, 54, 54, 54, 161, 539, 539, + 539, 149, 137, 539, 163, 539, 139, 539, 539, 539, + + 539, 539, 539, 140, 539, 141, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 149, 137, + 539, 164, 539, 139, 539, 539, 539, 168, 539, 539, + 140, 165, 141, 55, 539, 56, 539, 539, 57, 58, + 58, 58, 58, 58, 58, 58, 58, 59, 164, 539, + 539, 61, 62, 170, 168, 63, 64, 539, 165, 539, + 539, 539, 539, 65, 539, 66, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 61, 62, + 170, 539, 63, 64, 539, 175, 539, 539, 166, 167, + 65, 539, 66, 539, 539, 539, 539, 539, 539, 151, + + 151, 151, 151, 151, 151, 151, 151, 539, 539, 539, + 539, 539, 175, 539, 539, 166, 167, 539, 539, 539, + 539, 539, 539, 539, 539, 157, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 169, 539, + 158, 539, 539, 539, 539, 176, 539, 539, 539, 539, + 177, 539, 157, 539, 539, 539, 539, 539, 539, 180, + 178, 539, 539, 539, 539, 169, 539, 158, 539, 539, + 539, 539, 176, 539, 539, 539, 539, 177, 539, 179, + 539, 539, 539, 539, 171, 539, 180, 178, 539, 172, + 539, 539, 539, 539, 173, 181, 539, 539, 539, 539, + + 539, 539, 174, 539, 186, 539, 179, 539, 539, 539, + 539, 171, 539, 184, 185, 182, 172, 539, 539, 539, + 539, 173, 181, 539, 539, 539, 539, 539, 539, 174, + 539, 186, 539, 539, 183, 539, 539, 539, 539, 539, + 539, 539, 182, 539, 187, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 188, 539, 539, 539, 539, 189, + 539, 183, 190, 539, 539, 539, 539, 539, 539, 539, + 539, 187, 539, 193, 539, 539, 539, 539, 539, 539, + 539, 188, 539, 191, 539, 539, 189, 539, 539, 190, + 539, 194, 192, 539, 539, 539, 539, 539, 539, 195, + + 193, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 191, 539, 539, 539, 539, 539, 539, 539, 194, 192, + 539, 196, 539, 539, 539, 539, 539, 539, 539, 197, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 199, 539, 539, 539, 539, 198, 539, 539, 196, 539, + 539, 539, 539, 539, 539, 539, 197, 539, 200, 539, + 539, 539, 539, 539, 539, 539, 539, 199, 202, 539, + 539, 539, 198, 539, 539, 201, 539, 539, 204, 539, + 539, 205, 539, 539, 539, 200, 539, 203, 206, 539, + 539, 539, 539, 539, 539, 202, 539, 539, 539, 539, + + 539, 539, 201, 539, 539, 204, 539, 539, 205, 539, + 208, 207, 539, 209, 203, 206, 539, 539, 210, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 208, 207, 539, + 209, 539, 211, 539, 539, 210, 213, 212, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 211, + 539, 539, 539, 213, 212, 215, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 214, 539, 217, 539, + 539, 216, 539, 539, 219, 539, 539, 539, 539, 218, + + 539, 539, 215, 539, 220, 539, 539, 539, 539, 539, + 539, 539, 539, 214, 539, 217, 539, 539, 216, 221, + 539, 219, 539, 539, 223, 539, 218, 539, 222, 539, + 539, 220, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 241, 539, 221, 539, 539, 539, + 539, 223, 539, 539, 226, 222, 227, 539, 224, 539, + 132, 132, 132, 132, 132, 132, 132, 132, 133, 236, + 134, 539, 539, 539, 132, 132, 132, 132, 132, 132, + 132, 132, 539, 539, 539, 224, 228, 228, 228, 228, + 228, 228, 228, 228, 152, 152, 236, 229, 229, 229, + + 229, 229, 229, 229, 229, 230, 230, 230, 230, 230, + 230, 230, 230, 231, 231, 539, 232, 232, 232, 232, + 232, 232, 232, 232, 150, 150, 150, 150, 150, 150, + 150, 150, 233, 229, 229, 229, 229, 229, 229, 229, + 229, 133, 539, 134, 539, 539, 539, 153, 153, 153, + 153, 153, 153, 153, 153, 154, 154, 154, 154, 154, + 154, 154, 154, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 235, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 238, 539, 539, 539, 539, 539, 239, 237, 240, + + 539, 539, 539, 235, 243, 242, 539, 539, 539, 539, + 539, 539, 539, 539, 246, 245, 539, 539, 238, 539, + 539, 539, 539, 244, 239, 237, 240, 539, 539, 539, + 539, 243, 242, 539, 539, 539, 539, 249, 539, 539, + 539, 246, 245, 539, 539, 539, 539, 539, 539, 539, + 244, 247, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 248, 539, 249, 539, 539, 539, 539, 539, + 539, 539, 250, 539, 539, 539, 539, 539, 247, 539, + 539, 539, 539, 539, 539, 251, 539, 252, 539, 248, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 250, + + 539, 539, 539, 539, 253, 539, 539, 539, 539, 539, + 539, 255, 251, 539, 252, 256, 539, 539, 254, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 257, 253, 539, 539, 539, 539, 539, 539, 255, 539, + 539, 539, 256, 258, 539, 254, 539, 539, 539, 539, + 260, 539, 539, 259, 539, 539, 539, 257, 539, 539, + 539, 539, 539, 539, 539, 265, 539, 539, 539, 539, + 258, 539, 539, 539, 261, 539, 539, 260, 539, 539, + 259, 539, 539, 539, 539, 539, 539, 262, 263, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 264, 539, + + 539, 261, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 267, 539, 262, 263, 539, 539, 539, 539, + 539, 268, 539, 539, 266, 264, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 267, + 539, 269, 539, 539, 539, 539, 539, 539, 268, 539, + 270, 266, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 271, 539, 272, 539, 539, 539, 269, 539, + 539, 539, 539, 273, 539, 275, 539, 270, 539, 274, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 271, + 539, 272, 539, 539, 539, 539, 539, 539, 539, 276, + + 273, 539, 539, 539, 539, 539, 274, 539, 539, 539, + 539, 539, 277, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 276, 278, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 277, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 279, + 280, 539, 539, 539, 278, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 281, 539, 539, 539, + 539, 539, 539, 539, 285, 286, 279, 280, 539, 283, + 539, 282, 539, 539, 539, 284, 539, 539, 539, 539, + 539, 539, 539, 281, 539, 539, 539, 287, 539, 539, + + 539, 285, 286, 539, 539, 289, 283, 539, 282, 288, + 539, 539, 284, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 287, 539, 539, 539, 539, 539, + 539, 539, 289, 539, 291, 539, 288, 539, 539, 539, + 539, 539, 539, 290, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 293, 539, + 539, 291, 292, 539, 294, 539, 539, 539, 539, 295, + 290, 296, 539, 539, 539, 539, 539, 539, 297, 539, + 539, 539, 539, 539, 539, 293, 539, 539, 539, 292, + 539, 294, 539, 539, 539, 539, 295, 539, 296, 539, + + 539, 539, 539, 539, 539, 297, 539, 539, 298, 539, + 539, 539, 539, 539, 299, 539, 539, 539, 539, 539, + 539, 539, 232, 232, 232, 232, 232, 232, 232, 232, + 539, 539, 539, 539, 539, 298, 539, 539, 539, 539, + 539, 299, 300, 60, 60, 60, 60, 60, 60, 60, + 327, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, + 320, 321, 322, 323, 324, 325, 326, 327, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, + + 323, 324, 325, 326, 228, 228, 228, 228, 228, 228, + 228, 228, 401, 401, 401, 401, 401, 401, 401, 401, + 133, 539, 134, 539, 539, 329, 229, 229, 229, 229, + 229, 229, 229, 229, 230, 230, 230, 230, 230, 230, + 230, 230, 331, 332, 332, 332, 332, 332, 332, 332, + 332, 226, 329, 227, 539, 330, 539, 232, 232, 232, + 232, 232, 232, 232, 232, 333, 334, 334, 334, 334, + 334, 334, 334, 334, 403, 403, 403, 403, 403, 403, + 403, 403, 330, 335, 336, 336, 336, 336, 336, 336, + 336, 336, 539, 539, 539, 539, 539, 539, 539, 539, + + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 337, 539, 539, 539, 338, + 539, 539, 339, 539, 539, 539, 539, 539, 340, 539, + 342, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 341, 539, 337, 539, 539, 539, 338, 539, 539, 339, + 539, 539, 343, 539, 539, 340, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 341, 539, 539, + 539, 539, 539, 539, 347, 539, 344, 345, 539, 343, + 539, 539, 346, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + + 539, 347, 539, 344, 345, 539, 350, 348, 539, 346, + 539, 539, 539, 539, 539, 539, 539, 349, 539, 539, + 351, 539, 539, 539, 539, 539, 352, 539, 539, 539, + 539, 539, 539, 350, 348, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 349, 539, 539, 351, 539, 353, + 539, 539, 539, 352, 539, 539, 539, 539, 355, 539, + 539, 539, 354, 539, 539, 539, 539, 539, 539, 539, + 539, 356, 539, 539, 539, 539, 353, 539, 539, 539, + 358, 539, 539, 539, 539, 355, 539, 539, 539, 354, + 539, 539, 539, 357, 539, 539, 359, 539, 356, 539, + + 539, 539, 539, 539, 539, 539, 539, 358, 539, 539, + 539, 539, 539, 539, 539, 539, 360, 362, 539, 539, + 357, 539, 361, 359, 539, 539, 539, 539, 539, 363, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 360, 362, 539, 364, 539, 539, 361, + 539, 539, 365, 539, 539, 539, 363, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 367, 539, 539, 364, 539, 368, 539, 539, 539, 365, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 369, 539, 539, 539, 367, 539, 539, + + 539, 539, 368, 539, 539, 539, 370, 539, 539, 539, + 539, 539, 539, 539, 539, 374, 539, 372, 539, 371, + 369, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 375, 539, 370, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 373, 372, 539, 371, 539, 539, 376, + 539, 539, 539, 539, 539, 539, 539, 539, 375, 539, + 539, 539, 539, 377, 539, 539, 539, 539, 539, 539, + 373, 539, 539, 539, 539, 539, 376, 378, 380, 539, + 539, 539, 539, 539, 379, 539, 381, 539, 539, 539, + 377, 539, 539, 539, 539, 539, 539, 539, 539, 382, + + 539, 539, 539, 539, 378, 380, 539, 539, 539, 539, + 539, 379, 539, 381, 539, 539, 539, 539, 539, 539, + 539, 383, 384, 539, 539, 539, 382, 539, 539, 539, + 539, 539, 539, 386, 539, 387, 539, 539, 539, 539, + 539, 539, 385, 539, 539, 539, 388, 539, 383, 384, + 539, 390, 539, 539, 539, 539, 539, 389, 539, 539, + 386, 539, 387, 539, 539, 539, 539, 539, 391, 385, + 539, 539, 539, 388, 539, 539, 539, 539, 390, 539, + 539, 539, 539, 539, 389, 539, 539, 539, 539, 539, + 539, 539, 539, 392, 539, 391, 539, 539, 539, 539, + + 539, 539, 539, 539, 539, 539, 393, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 392, 394, 539, 539, 539, 539, 395, 539, 396, 539, + 539, 539, 539, 393, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 394, 539, + 539, 539, 539, 395, 539, 396, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 397, 333, 399, 399, 399, 399, + 399, 399, 399, 399, 335, 400, 400, 400, 400, 400, + 400, 400, 400, 406, 406, 406, 406, 406, 406, 406, + + 406, 397, 402, 332, 332, 332, 332, 332, 332, 332, + 332, 404, 334, 334, 334, 334, 334, 334, 334, 334, + 407, 336, 336, 336, 336, 336, 336, 336, 336, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 405, + 539, 539, 539, 539, 539, 539, 539, 539, 408, 409, + 539, 539, 539, 539, 539, 539, 539, 412, 539, 539, + 539, 539, 539, 539, 411, 410, 405, 539, 539, 539, + 539, 539, 539, 539, 539, 408, 409, 539, 539, 539, + 539, 539, 539, 539, 412, 539, 539, 539, 539, 539, + 539, 411, 410, 539, 539, 539, 539, 539, 539, 539, + + 413, 539, 539, 539, 539, 539, 539, 539, 415, 539, + 539, 539, 539, 539, 539, 539, 416, 414, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 413, 417, 539, + 539, 539, 539, 539, 539, 415, 539, 539, 539, 539, + 539, 539, 539, 416, 414, 539, 539, 539, 539, 539, + 539, 539, 420, 418, 539, 417, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 419, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 420, + 418, 421, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 422, 539, 539, 539, 419, 539, 539, 539, + + 539, 539, 423, 539, 539, 539, 539, 539, 421, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 424, 422, + 539, 539, 539, 539, 539, 539, 539, 425, 539, 423, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 426, 539, 428, 539, 424, 539, 539, 539, 539, + 539, 539, 539, 427, 425, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 426, 539, + 428, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 427, 539, 539, 539, 539, 539, 432, 431, 539, 539, + 539, 430, 539, 539, 539, 539, 539, 433, 539, 539, + + 539, 539, 539, 539, 539, 539, 539, 539, 539, 434, + 539, 539, 539, 432, 431, 539, 435, 539, 430, 539, + 539, 539, 539, 539, 433, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 434, 539, 539, 539, + 539, 539, 437, 435, 539, 539, 539, 436, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 438, 539, 539, 539, 437, + 539, 539, 539, 440, 436, 539, 539, 539, 439, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 438, 539, 539, 539, 442, 539, 441, 539, + + 440, 539, 539, 539, 539, 439, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 443, + 539, 539, 539, 442, 539, 441, 539, 446, 539, 444, + 539, 539, 539, 447, 539, 539, 445, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 443, 539, 539, 539, + 539, 539, 539, 539, 446, 539, 444, 539, 448, 539, + 447, 539, 539, 445, 539, 450, 449, 539, 539, 451, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 448, 539, 452, 539, 539, + 539, 539, 450, 449, 539, 539, 451, 539, 539, 539, + + 539, 539, 539, 539, 453, 454, 401, 401, 401, 401, + 401, 401, 401, 401, 452, 404, 399, 399, 399, 399, + 399, 399, 399, 399, 539, 539, 539, 539, 539, 539, + 539, 453, 454, 407, 400, 400, 400, 400, 400, 400, + 400, 400, 539, 456, 401, 401, 401, 401, 401, 401, + 401, 401, 403, 403, 403, 403, 403, 403, 403, 403, + 539, 457, 403, 403, 403, 403, 403, 403, 403, 403, + 456, 539, 539, 539, 539, 539, 539, 539, 539, 458, + 539, 539, 539, 539, 539, 539, 539, 539, 457, 456, + 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, + + 406, 406, 406, 406, 406, 406, 458, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 456, 459, 539, 539, + 539, 539, 539, 539, 539, 457, 539, 539, 539, 539, + 460, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 461, 539, 539, 459, 539, 539, 539, 539, 539, + 539, 539, 457, 539, 463, 539, 539, 460, 539, 539, + 462, 539, 539, 539, 539, 539, 539, 539, 461, 539, + 539, 539, 539, 464, 539, 539, 539, 539, 465, 539, + 539, 463, 539, 539, 539, 539, 539, 462, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + + 464, 539, 539, 539, 539, 539, 539, 539, 466, 539, + 539, 467, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 468, + 539, 539, 539, 539, 539, 466, 539, 539, 467, 539, + 469, 539, 539, 470, 539, 539, 539, 539, 539, 471, + 539, 539, 539, 539, 539, 472, 468, 539, 473, 539, + 539, 539, 539, 539, 539, 539, 539, 469, 539, 539, + 470, 539, 539, 539, 539, 539, 471, 539, 539, 539, + 539, 539, 472, 475, 539, 473, 539, 539, 539, 539, + 539, 539, 476, 539, 539, 539, 539, 539, 539, 539, + + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 475, 539, 539, 477, 539, 539, 478, 539, 539, 476, + 539, 539, 479, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 477, 539, 539, 478, 539, 539, 539, 539, 539, 479, + 539, 539, 480, 539, 539, 539, 539, 539, 539, 481, + 539, 539, 539, 539, 539, 482, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 480, + 539, 539, 539, 539, 484, 539, 481, 483, 539, 539, + 539, 539, 482, 539, 539, 539, 539, 485, 539, 539, + + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 484, 539, 539, 483, 539, 488, 539, 539, 487, + 539, 539, 539, 486, 485, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 488, 539, 539, 487, 539, 539, 539, + 486, 539, 491, 539, 489, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 491, + 539, 489, 539, 539, 539, 493, 539, 539, 495, 539, + 492, 494, 539, 539, 539, 539, 539, 539, 539, 539, + + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 493, 539, 539, 495, 539, 492, 494, 539, + 539, 539, 539, 539, 539, 539, 539, 496, 497, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 498, 539, 539, 539, 499, 539, 539, + 539, 539, 539, 539, 496, 497, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 501, 539, + 498, 539, 539, 539, 499, 539, 539, 503, 539, 539, + 539, 539, 539, 502, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 501, 539, 539, 539, 539, + + 539, 539, 539, 539, 503, 504, 539, 539, 539, 505, + 502, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 506, 539, 539, 539, + 539, 539, 504, 539, 539, 509, 505, 539, 539, 507, + 508, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 506, 539, 539, 539, 539, 539, 539, + 539, 539, 509, 539, 510, 539, 507, 508, 539, 539, + 539, 539, 539, 539, 539, 539, 511, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 510, 539, 539, 515, 539, 539, 514, 539, 539, + + 513, 539, 539, 511, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 516, 539, 539, 539, 539, + 539, 515, 539, 539, 514, 539, 539, 513, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 516, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 517, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 519, + 539, 539, 539, 539, 539, 518, 539, 539, 539, 517, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 520, 539, 539, 539, 539, 539, 519, 539, 539, 539, + + 539, 539, 518, 539, 539, 539, 521, 539, 539, 539, + 539, 539, 522, 539, 539, 539, 539, 520, 539, 539, + 539, 539, 539, 539, 539, 539, 524, 539, 539, 539, + 539, 539, 539, 521, 539, 539, 539, 539, 539, 522, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 524, 539, 539, 539, 525, 539, 527, + 539, 539, 539, 526, 539, 539, 539, 539, 539, 528, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 525, 529, 527, 539, 539, 539, + 526, 539, 539, 539, 539, 539, 528, 539, 539, 539, + + 539, 539, 539, 539, 539, 539, 539, 531, 539, 539, + 539, 539, 529, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 532, + 539, 539, 539, 539, 531, 539, 539, 534, 539, 537, + 539, 539, 539, 539, 535, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 538, 532, 539, 539, 539, + 539, 539, 539, 539, 534, 539, 537, 539, 539, 539, + 539, 535, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 538, 43, 43, 43, 43, 47, 539, 47, + 47, 50, 539, 50, 50, 60, 60, 128, 539, 128, + + 128, 130, 539, 130, 130, 5, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539 + } ; + +static yyconst flex_int16_t yy_chk[4381] = + { 0, + 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, 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, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, + 14, 15, 557, 15, 556, 555, 15, 15, 15, 15, + + 15, 15, 15, 15, 15, 15, 16, 554, 16, 15, + 15, 16, 41, 15, 15, 151, 265, 25, 366, 25, + 16, 15, 25, 15, 474, 25, 553, 552, 551, 550, + 549, 25, 548, 16, 16, 547, 15, 15, 16, 41, + 15, 15, 151, 265, 19, 366, 19, 542, 15, 19, + 15, 474, 429, 128, 50, 47, 45, 42, 19, 19, + 16, 16, 12, 19, 10, 16, 17, 19, 17, 9, + 32, 17, 32, 17, 22, 32, 22, 7, 5, 22, + 17, 17, 4, 3, 32, 17, 19, 0, 22, 22, + 19, 0, 0, 0, 19, 17, 17, 0, 0, 26, + + 22, 26, 0, 0, 26, 27, 0, 27, 17, 0, + 27, 0, 17, 26, 0, 23, 22, 23, 26, 27, + 23, 0, 17, 17, 18, 0, 0, 22, 27, 23, + 0, 0, 18, 0, 23, 0, 18, 28, 23, 28, + 18, 0, 28, 0, 0, 26, 18, 18, 39, 18, + 39, 28, 0, 39, 0, 27, 0, 0, 0, 18, + 0, 23, 39, 18, 0, 23, 28, 18, 0, 0, + 29, 0, 29, 18, 18, 29, 18, 20, 30, 20, + 30, 0, 20, 30, 29, 0, 0, 0, 0, 0, + 0, 20, 30, 28, 20, 20, 0, 0, 30, 29, + + 0, 0, 0, 20, 0, 20, 30, 20, 0, 33, + 34, 33, 34, 0, 33, 34, 0, 0, 0, 0, + 0, 20, 20, 33, 34, 30, 29, 0, 0, 34, + 20, 0, 20, 30, 20, 21, 0, 21, 33, 34, + 21, 60, 0, 60, 33, 34, 60, 0, 0, 21, + 21, 0, 0, 0, 0, 60, 34, 0, 21, 0, + 21, 0, 0, 0, 21, 33, 34, 0, 36, 0, + 36, 33, 34, 36, 0, 0, 37, 21, 37, 0, + 0, 37, 36, 0, 0, 21, 0, 21, 0, 0, + 37, 21, 24, 0, 24, 37, 36, 24, 36, 0, + + 64, 0, 64, 0, 0, 64, 24, 0, 0, 24, + 38, 0, 38, 24, 64, 38, 0, 0, 0, 24, + 24, 0, 37, 36, 38, 36, 0, 38, 0, 65, + 40, 65, 40, 38, 65, 40, 24, 66, 0, 66, + 24, 0, 66, 65, 40, 0, 24, 24, 31, 40, + 0, 66, 0, 0, 38, 31, 31, 0, 31, 0, + 38, 0, 31, 0, 0, 31, 52, 52, 52, 52, + 52, 52, 52, 52, 0, 31, 40, 0, 0, 0, + 0, 0, 31, 31, 0, 31, 0, 0, 0, 31, + 0, 0, 31, 35, 0, 35, 0, 0, 35, 59, + + 59, 59, 59, 59, 59, 59, 59, 35, 35, 0, + 0, 0, 35, 0, 62, 62, 35, 62, 62, 62, + 62, 62, 62, 62, 62, 35, 63, 63, 63, 63, + 63, 63, 63, 63, 0, 35, 70, 0, 70, 35, + 67, 70, 67, 35, 0, 67, 0, 0, 0, 70, + 70, 0, 35, 53, 67, 53, 0, 0, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 0, 0, + 67, 53, 53, 0, 0, 53, 53, 0, 0, 68, + 0, 68, 0, 53, 68, 53, 104, 0, 104, 0, + 73, 104, 73, 68, 0, 73, 0, 67, 53, 53, + + 104, 0, 53, 53, 73, 0, 0, 68, 0, 0, + 53, 0, 53, 54, 0, 54, 0, 0, 0, 54, + 54, 54, 54, 54, 54, 54, 54, 0, 73, 0, + 0, 54, 54, 71, 68, 71, 54, 0, 71, 72, + 0, 72, 0, 54, 72, 54, 0, 71, 0, 0, + 71, 0, 74, 72, 74, 73, 0, 74, 54, 54, + 72, 0, 0, 54, 0, 0, 74, 74, 0, 0, + 54, 0, 54, 57, 0, 57, 0, 71, 0, 57, + 57, 57, 57, 57, 57, 57, 57, 72, 106, 0, + 106, 57, 57, 106, 74, 75, 57, 75, 0, 76, + + 75, 76, 106, 57, 76, 57, 0, 0, 0, 75, + 0, 0, 78, 76, 78, 0, 0, 78, 57, 57, + 80, 75, 80, 57, 0, 80, 78, 78, 0, 0, + 57, 76, 57, 58, 80, 58, 0, 0, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 75, 0, + 0, 58, 58, 80, 78, 58, 58, 0, 76, 0, + 0, 0, 77, 58, 77, 58, 0, 77, 0, 0, + 82, 0, 82, 0, 0, 82, 77, 0, 58, 58, + 80, 0, 58, 58, 82, 82, 0, 0, 77, 77, + 58, 0, 58, 61, 0, 61, 0, 0, 61, 61, + + 61, 61, 61, 61, 61, 61, 61, 61, 69, 79, + 69, 79, 82, 69, 79, 77, 77, 0, 0, 83, + 0, 83, 69, 79, 83, 69, 0, 84, 0, 84, + 0, 0, 84, 83, 85, 0, 85, 0, 79, 85, + 69, 84, 0, 0, 87, 83, 87, 0, 85, 87, + 84, 0, 69, 0, 0, 0, 0, 0, 87, 87, + 85, 86, 0, 86, 0, 79, 86, 69, 81, 88, + 81, 88, 83, 81, 88, 86, 91, 84, 91, 86, + 0, 91, 81, 88, 81, 0, 87, 85, 0, 81, + 91, 0, 0, 0, 81, 88, 89, 0, 89, 0, + + 0, 89, 81, 90, 91, 90, 86, 0, 90, 0, + 89, 81, 0, 90, 90, 89, 81, 90, 92, 0, + 92, 81, 88, 92, 0, 93, 0, 93, 0, 81, + 93, 91, 92, 94, 89, 94, 0, 0, 94, 93, + 0, 95, 89, 95, 92, 0, 95, 94, 0, 0, + 0, 96, 0, 96, 93, 95, 96, 0, 98, 94, + 98, 89, 95, 98, 97, 96, 97, 0, 0, 97, + 0, 92, 98, 98, 99, 0, 99, 0, 97, 99, + 0, 93, 101, 96, 101, 0, 94, 101, 99, 95, + 0, 99, 97, 100, 0, 100, 101, 0, 100, 100, + + 98, 102, 0, 102, 0, 0, 102, 100, 0, 103, + 96, 103, 0, 0, 103, 102, 0, 0, 99, 97, + 105, 101, 105, 103, 0, 105, 0, 0, 0, 102, + 107, 0, 107, 0, 105, 107, 108, 0, 108, 0, + 105, 108, 0, 0, 107, 103, 0, 0, 101, 109, + 108, 109, 0, 0, 109, 110, 102, 110, 107, 111, + 110, 111, 0, 109, 111, 0, 0, 105, 109, 110, + 0, 0, 103, 111, 0, 108, 0, 112, 110, 112, + 0, 110, 112, 0, 113, 107, 113, 109, 111, 113, + 0, 112, 114, 0, 114, 109, 0, 114, 113, 0, + + 0, 0, 108, 0, 0, 110, 114, 115, 110, 115, + 113, 112, 115, 114, 109, 111, 0, 116, 114, 116, + 0, 115, 116, 0, 0, 117, 0, 117, 0, 0, + 117, 116, 0, 0, 0, 0, 0, 113, 112, 117, + 114, 0, 115, 0, 0, 114, 117, 116, 118, 119, + 118, 119, 0, 118, 119, 0, 120, 0, 120, 0, + 0, 120, 118, 119, 0, 0, 121, 0, 121, 115, + 120, 121, 0, 117, 116, 119, 122, 0, 122, 0, + 121, 122, 0, 0, 0, 0, 118, 123, 121, 123, + 122, 120, 123, 0, 122, 124, 0, 124, 0, 121, + + 124, 123, 119, 0, 123, 0, 125, 0, 125, 124, + 0, 125, 0, 118, 0, 121, 0, 0, 120, 123, + 125, 122, 0, 0, 125, 126, 121, 126, 124, 0, + 126, 123, 0, 159, 0, 159, 0, 0, 159, 126, + 0, 0, 0, 155, 159, 155, 123, 159, 155, 0, + 0, 125, 0, 0, 132, 124, 132, 155, 126, 0, + 132, 132, 132, 132, 132, 132, 132, 132, 135, 155, + 135, 0, 0, 0, 135, 135, 135, 135, 135, 135, + 135, 135, 0, 0, 0, 126, 136, 136, 136, 136, + 136, 136, 136, 136, 137, 137, 155, 137, 137, 137, + + 137, 137, 137, 137, 137, 138, 138, 138, 138, 138, + 138, 138, 138, 145, 145, 0, 145, 145, 145, 145, + 145, 145, 145, 145, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 152, 152, 152, 152, 152, 152, 152, + 152, 153, 0, 153, 0, 0, 0, 153, 153, 153, + 153, 153, 153, 153, 153, 154, 154, 154, 154, 154, + 154, 154, 154, 156, 157, 156, 157, 0, 156, 157, + 158, 0, 158, 0, 0, 158, 154, 156, 157, 0, + 160, 161, 160, 161, 158, 160, 161, 163, 164, 163, + 164, 157, 163, 164, 160, 161, 0, 157, 156, 158, + + 0, 163, 164, 154, 161, 160, 162, 167, 162, 167, + 0, 162, 167, 0, 164, 163, 0, 0, 157, 0, + 162, 167, 0, 162, 157, 156, 158, 0, 0, 0, + 0, 161, 160, 166, 165, 166, 165, 167, 166, 165, + 0, 164, 163, 0, 168, 0, 168, 166, 165, 168, + 162, 165, 169, 0, 169, 0, 0, 169, 168, 0, + 0, 0, 166, 0, 167, 170, 169, 170, 0, 171, + 170, 171, 168, 0, 171, 0, 0, 0, 165, 170, + 0, 0, 0, 171, 0, 169, 172, 170, 172, 166, + 0, 172, 173, 0, 173, 0, 174, 173, 174, 168, + + 172, 174, 0, 175, 171, 175, 173, 0, 175, 0, + 174, 173, 169, 0, 170, 174, 0, 175, 172, 177, + 176, 177, 176, 0, 177, 176, 0, 178, 0, 178, + 175, 171, 178, 177, 176, 179, 0, 179, 173, 0, + 179, 178, 174, 176, 0, 172, 180, 0, 180, 179, + 178, 180, 0, 177, 181, 0, 181, 175, 0, 181, + 180, 184, 182, 184, 182, 184, 184, 182, 181, 0, + 176, 0, 0, 0, 180, 184, 182, 178, 0, 183, + 177, 183, 0, 0, 183, 0, 0, 181, 182, 185, + 186, 185, 186, 183, 185, 186, 0, 187, 183, 187, + + 0, 180, 187, 185, 186, 188, 0, 188, 0, 0, + 188, 187, 187, 0, 181, 182, 0, 0, 189, 188, + 189, 188, 0, 189, 186, 183, 0, 0, 190, 191, + 190, 191, 189, 190, 191, 192, 0, 192, 0, 187, + 192, 189, 190, 191, 0, 0, 0, 0, 188, 192, + 190, 186, 193, 194, 193, 194, 0, 193, 194, 0, + 0, 0, 191, 0, 192, 0, 193, 194, 189, 195, + 0, 195, 0, 193, 195, 195, 196, 190, 196, 194, + 197, 196, 197, 195, 0, 197, 0, 0, 0, 191, + 196, 192, 0, 198, 197, 198, 0, 0, 198, 197, + + 193, 0, 0, 199, 0, 199, 194, 198, 199, 200, + 0, 200, 198, 0, 200, 0, 201, 199, 201, 0, + 202, 201, 202, 200, 0, 202, 197, 200, 0, 0, + 201, 203, 0, 203, 202, 0, 203, 0, 204, 198, + 204, 0, 205, 204, 205, 203, 0, 205, 0, 201, + 203, 0, 204, 0, 200, 206, 205, 206, 0, 207, + 206, 207, 0, 0, 207, 0, 204, 0, 0, 206, + 0, 0, 0, 207, 207, 207, 201, 203, 208, 206, + 208, 205, 209, 208, 209, 206, 210, 209, 210, 0, + 0, 210, 208, 204, 0, 0, 209, 208, 0, 0, + + 210, 207, 207, 0, 0, 210, 206, 0, 205, 209, + 0, 211, 206, 211, 0, 212, 211, 212, 0, 0, + 212, 213, 0, 213, 208, 211, 213, 0, 214, 212, + 214, 0, 210, 214, 212, 213, 209, 0, 0, 215, + 0, 215, 214, 211, 215, 216, 217, 216, 217, 0, + 216, 217, 218, 215, 218, 0, 0, 218, 215, 216, + 217, 212, 214, 219, 216, 219, 218, 0, 219, 217, + 211, 218, 0, 0, 220, 0, 220, 219, 219, 220, + 0, 221, 0, 221, 0, 215, 221, 0, 220, 214, + 0, 216, 224, 0, 224, 221, 217, 224, 218, 259, + + 0, 259, 0, 0, 259, 219, 224, 0, 220, 0, + 0, 0, 0, 259, 221, 0, 223, 0, 223, 0, + 0, 223, 231, 231, 231, 231, 231, 231, 231, 231, + 223, 0, 0, 0, 0, 220, 0, 0, 0, 0, + 0, 221, 222, 222, 222, 222, 222, 222, 222, 222, + 223, 222, 222, 222, 222, 222, 222, 222, 222, 222, + 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, + 222, 222, 222, 222, 222, 222, 222, 223, 222, 222, + 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, + 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, + + 222, 222, 222, 222, 228, 228, 228, 228, 228, 228, + 228, 228, 331, 331, 331, 331, 331, 331, 331, 331, + 229, 0, 229, 0, 0, 228, 229, 229, 229, 229, + 229, 229, 229, 229, 230, 230, 230, 230, 230, 230, + 230, 230, 233, 233, 233, 233, 233, 233, 233, 233, + 233, 232, 228, 232, 0, 230, 0, 232, 232, 232, + 232, 232, 232, 232, 232, 234, 234, 234, 234, 234, + 234, 234, 234, 234, 333, 333, 333, 333, 333, 333, + 333, 333, 230, 235, 235, 235, 235, 235, 235, 235, + 235, 235, 236, 237, 236, 237, 0, 236, 237, 238, + + 0, 238, 0, 240, 238, 240, 236, 237, 240, 239, + 0, 239, 0, 238, 239, 236, 0, 240, 0, 237, + 0, 0, 238, 239, 241, 0, 241, 0, 239, 241, + 241, 242, 0, 242, 0, 0, 242, 0, 241, 0, + 240, 0, 236, 0, 0, 242, 237, 0, 243, 238, + 243, 0, 242, 243, 244, 239, 244, 0, 246, 244, + 246, 0, 243, 246, 245, 0, 245, 240, 244, 245, + 0, 0, 246, 0, 246, 0, 243, 244, 245, 242, + 0, 247, 245, 247, 0, 248, 247, 248, 0, 0, + 248, 249, 0, 249, 0, 247, 249, 0, 0, 248, + + 0, 246, 0, 243, 244, 249, 249, 247, 250, 245, + 250, 0, 0, 250, 0, 0, 251, 248, 251, 0, + 249, 251, 250, 0, 0, 0, 250, 0, 0, 0, + 251, 0, 0, 249, 247, 0, 252, 253, 252, 253, + 0, 252, 253, 0, 248, 0, 0, 249, 0, 251, + 252, 253, 254, 250, 254, 0, 0, 254, 253, 255, + 0, 255, 252, 256, 255, 256, 254, 257, 256, 257, + 0, 254, 257, 255, 0, 0, 251, 256, 0, 0, + 256, 257, 0, 0, 0, 253, 258, 0, 258, 252, + 0, 258, 260, 255, 260, 0, 257, 260, 254, 261, + + 258, 261, 0, 0, 261, 0, 260, 256, 0, 0, + 262, 0, 262, 261, 0, 262, 258, 261, 0, 0, + 255, 0, 260, 257, 262, 0, 0, 0, 263, 262, + 263, 0, 0, 263, 264, 0, 264, 0, 0, 264, + 0, 0, 263, 258, 261, 266, 263, 266, 264, 260, + 266, 0, 264, 267, 0, 267, 262, 0, 267, 266, + 268, 0, 268, 0, 269, 268, 269, 267, 0, 269, + 267, 0, 0, 263, 268, 268, 0, 0, 269, 264, + 270, 271, 270, 271, 0, 270, 271, 272, 0, 272, + 0, 0, 272, 269, 270, 271, 0, 267, 273, 0, + + 273, 272, 268, 273, 0, 0, 270, 0, 274, 275, + 274, 275, 273, 274, 275, 275, 276, 273, 276, 272, + 269, 276, 274, 275, 277, 0, 277, 0, 0, 277, + 276, 276, 0, 270, 278, 0, 278, 0, 277, 278, + 279, 0, 279, 274, 273, 279, 272, 0, 278, 278, + 281, 280, 281, 280, 279, 281, 280, 282, 276, 282, + 0, 0, 282, 279, 281, 280, 0, 283, 0, 283, + 274, 282, 283, 0, 0, 0, 278, 280, 282, 0, + 284, 283, 284, 0, 281, 284, 283, 285, 0, 285, + 279, 0, 285, 286, 284, 286, 0, 0, 286, 284, + + 0, 285, 0, 0, 280, 282, 0, 286, 0, 0, + 287, 281, 287, 283, 288, 287, 288, 0, 289, 288, + 289, 285, 286, 289, 287, 291, 284, 291, 288, 290, + 291, 290, 289, 288, 290, 289, 292, 0, 292, 291, + 0, 292, 287, 290, 0, 0, 290, 0, 285, 286, + 292, 292, 0, 293, 0, 293, 0, 291, 293, 0, + 288, 294, 289, 294, 0, 0, 294, 293, 292, 287, + 0, 0, 295, 290, 295, 294, 0, 295, 292, 0, + 296, 0, 296, 0, 291, 296, 295, 297, 0, 297, + 0, 0, 297, 295, 296, 292, 0, 298, 300, 298, + + 300, 297, 298, 300, 0, 299, 296, 299, 0, 0, + 299, 298, 300, 301, 0, 301, 0, 0, 301, 299, + 295, 297, 0, 0, 0, 0, 298, 301, 299, 302, + 303, 302, 303, 296, 302, 303, 304, 305, 304, 305, + 0, 304, 305, 302, 303, 0, 0, 306, 297, 306, + 304, 305, 306, 298, 307, 299, 307, 0, 308, 307, + 308, 306, 309, 308, 309, 0, 0, 309, 307, 310, + 0, 310, 308, 311, 310, 311, 309, 312, 311, 312, + 0, 0, 312, 310, 313, 0, 313, 311, 314, 313, + 314, 312, 315, 314, 315, 0, 0, 315, 313, 316, + + 0, 316, 314, 317, 316, 317, 315, 318, 317, 318, + 0, 0, 318, 316, 319, 0, 319, 317, 320, 319, + 320, 318, 321, 320, 321, 0, 0, 321, 319, 322, + 0, 322, 320, 323, 322, 323, 321, 324, 323, 324, + 0, 0, 324, 322, 325, 0, 325, 323, 326, 325, + 326, 324, 327, 326, 327, 0, 0, 327, 325, 341, + 0, 341, 326, 0, 341, 0, 327, 0, 0, 0, + 0, 0, 0, 341, 327, 329, 329, 329, 329, 329, + 329, 329, 329, 329, 330, 330, 330, 330, 330, 330, + 330, 330, 330, 335, 335, 335, 335, 335, 335, 335, + + 335, 327, 332, 332, 332, 332, 332, 332, 332, 332, + 332, 334, 334, 334, 334, 334, 334, 334, 334, 334, + 336, 336, 336, 336, 336, 336, 336, 336, 336, 337, + 338, 337, 338, 0, 337, 338, 339, 0, 339, 334, + 340, 339, 340, 337, 338, 340, 0, 0, 336, 337, + 339, 0, 0, 342, 340, 342, 0, 340, 342, 0, + 0, 0, 0, 0, 339, 338, 334, 342, 343, 344, + 343, 344, 0, 343, 344, 336, 337, 0, 0, 0, + 0, 0, 343, 344, 340, 345, 0, 345, 0, 0, + 345, 339, 338, 346, 0, 346, 0, 0, 346, 345, + + 343, 347, 0, 347, 0, 0, 347, 346, 346, 348, + 0, 348, 0, 0, 348, 347, 347, 345, 0, 349, + 350, 349, 350, 348, 349, 350, 0, 343, 348, 0, + 0, 0, 0, 349, 350, 346, 351, 352, 351, 352, + 0, 351, 352, 347, 345, 0, 0, 0, 0, 0, + 351, 352, 352, 350, 353, 348, 353, 0, 354, 353, + 354, 0, 355, 354, 355, 0, 0, 355, 353, 351, + 0, 0, 354, 356, 0, 356, 355, 0, 356, 352, + 350, 354, 0, 357, 358, 357, 358, 356, 357, 358, + 0, 0, 356, 0, 0, 0, 351, 357, 358, 359, + + 0, 359, 357, 0, 359, 0, 0, 360, 354, 360, + 0, 0, 360, 359, 0, 0, 0, 0, 358, 356, + 361, 360, 361, 0, 0, 361, 0, 359, 362, 357, + 362, 0, 0, 362, 361, 363, 0, 363, 0, 0, + 363, 360, 362, 362, 0, 358, 364, 0, 364, 363, + 365, 364, 365, 361, 359, 365, 0, 367, 0, 367, + 364, 368, 367, 368, 365, 0, 368, 369, 360, 369, + 362, 367, 369, 0, 370, 368, 370, 0, 0, 370, + 361, 369, 0, 0, 0, 0, 369, 368, 370, 0, + 371, 367, 371, 0, 372, 371, 372, 370, 373, 372, + + 373, 0, 0, 373, 371, 374, 0, 374, 372, 371, + 374, 0, 373, 369, 368, 375, 373, 375, 367, 374, + 375, 376, 0, 376, 370, 377, 376, 377, 0, 375, + 377, 0, 378, 0, 378, 376, 371, 378, 0, 377, + 0, 0, 377, 373, 0, 0, 378, 375, 379, 380, + 379, 380, 0, 379, 380, 0, 381, 0, 381, 0, + 0, 381, 379, 380, 0, 378, 382, 0, 382, 377, + 381, 382, 0, 381, 375, 0, 0, 383, 380, 383, + 382, 384, 383, 384, 0, 385, 384, 385, 0, 0, + 385, 383, 378, 0, 0, 384, 383, 0, 382, 385, + + 381, 386, 387, 386, 387, 380, 386, 387, 388, 0, + 388, 0, 389, 388, 389, 386, 387, 389, 0, 384, + 0, 0, 388, 383, 0, 382, 389, 388, 0, 386, + 390, 0, 390, 389, 0, 390, 387, 391, 0, 391, + 0, 0, 391, 392, 390, 392, 384, 0, 392, 0, + 393, 391, 393, 0, 388, 393, 386, 392, 390, 0, + 389, 0, 0, 387, 393, 392, 391, 0, 394, 393, + 394, 0, 395, 394, 395, 0, 396, 395, 396, 0, + 0, 396, 394, 0, 0, 390, 395, 394, 0, 397, + 396, 397, 392, 391, 397, 0, 393, 0, 0, 0, + + 0, 0, 0, 397, 395, 396, 401, 401, 401, 401, + 401, 401, 401, 401, 394, 399, 399, 399, 399, 399, + 399, 399, 399, 399, 0, 0, 0, 0, 0, 0, + 0, 395, 396, 400, 400, 400, 400, 400, 400, 400, + 400, 400, 0, 399, 402, 402, 402, 402, 402, 402, + 402, 402, 403, 403, 403, 403, 403, 403, 403, 403, + 0, 400, 404, 404, 404, 404, 404, 404, 404, 404, + 399, 405, 408, 405, 408, 0, 405, 408, 0, 403, + 0, 0, 0, 0, 0, 405, 408, 0, 400, 404, + 406, 406, 406, 406, 406, 406, 406, 406, 407, 407, + + 407, 407, 407, 407, 407, 407, 403, 409, 410, 409, + 410, 0, 409, 410, 0, 0, 404, 406, 411, 0, + 411, 409, 410, 411, 412, 407, 412, 0, 0, 412, + 409, 413, 411, 413, 0, 0, 413, 414, 412, 414, + 0, 410, 414, 0, 406, 413, 0, 0, 415, 0, + 415, 414, 407, 415, 414, 0, 416, 409, 416, 0, + 413, 416, 415, 0, 0, 0, 0, 0, 410, 417, + 416, 417, 0, 416, 417, 418, 0, 418, 417, 0, + 418, 414, 0, 417, 0, 0, 0, 413, 419, 418, + 419, 0, 420, 419, 420, 0, 421, 420, 421, 0, + + 416, 421, 419, 0, 0, 0, 420, 422, 418, 422, + 421, 419, 422, 423, 424, 423, 424, 0, 423, 424, + 0, 422, 0, 0, 0, 0, 0, 423, 424, 421, + 0, 425, 426, 425, 426, 418, 425, 426, 419, 427, + 422, 427, 0, 424, 427, 425, 426, 0, 0, 425, + 0, 0, 428, 427, 428, 426, 421, 428, 427, 431, + 430, 431, 430, 0, 431, 430, 428, 422, 0, 0, + 424, 0, 0, 431, 430, 432, 425, 432, 0, 433, + 432, 433, 426, 430, 433, 427, 434, 0, 434, 432, + 0, 434, 432, 433, 0, 0, 0, 435, 0, 435, + + 434, 436, 435, 436, 0, 0, 436, 437, 0, 437, + 430, 435, 437, 433, 0, 436, 435, 0, 438, 432, + 438, 437, 437, 438, 439, 440, 439, 440, 0, 439, + 440, 441, 438, 441, 0, 0, 441, 0, 439, 440, + 433, 0, 442, 435, 442, 441, 443, 442, 443, 437, + 0, 443, 439, 444, 0, 444, 442, 0, 444, 440, + 443, 445, 0, 445, 0, 441, 445, 444, 446, 447, + 446, 447, 0, 446, 447, 445, 448, 0, 448, 439, + 0, 448, 446, 447, 447, 0, 440, 444, 0, 449, + 448, 449, 441, 450, 449, 450, 0, 448, 450, 451, + + 0, 451, 0, 449, 451, 0, 0, 450, 0, 0, + 0, 447, 0, 451, 444, 452, 451, 452, 0, 450, + 452, 0, 0, 449, 448, 453, 454, 453, 454, 452, + 453, 454, 0, 460, 0, 460, 0, 0, 460, 453, + 454, 0, 0, 451, 0, 0, 450, 460, 0, 0, + 449, 461, 460, 461, 454, 462, 461, 462, 0, 463, + 462, 463, 0, 0, 463, 461, 464, 0, 464, 462, + 465, 464, 465, 463, 0, 465, 0, 0, 0, 460, + 464, 454, 0, 0, 465, 463, 0, 466, 465, 466, + 462, 464, 466, 467, 468, 467, 468, 0, 467, 468, + + 469, 466, 469, 0, 0, 469, 0, 467, 468, 0, + 0, 470, 463, 470, 469, 465, 470, 462, 464, 471, + 0, 471, 0, 0, 471, 470, 0, 467, 468, 0, + 472, 0, 472, 471, 473, 472, 473, 0, 0, 473, + 0, 0, 0, 470, 472, 0, 0, 472, 473, 0, + 0, 475, 0, 475, 467, 468, 475, 476, 477, 476, + 477, 0, 476, 477, 478, 475, 478, 0, 475, 478, + 470, 476, 477, 0, 472, 0, 0, 477, 478, 479, + 480, 479, 480, 476, 479, 480, 481, 482, 481, 482, + 0, 481, 482, 479, 480, 475, 0, 483, 0, 483, + + 481, 482, 483, 0, 477, 479, 0, 0, 0, 481, + 476, 483, 0, 484, 485, 484, 485, 0, 484, 485, + 486, 0, 486, 0, 0, 486, 482, 484, 485, 0, + 0, 0, 479, 0, 486, 486, 481, 0, 0, 484, + 485, 487, 488, 487, 488, 0, 487, 488, 0, 489, + 0, 489, 0, 482, 489, 487, 488, 0, 0, 0, + 0, 0, 486, 489, 487, 0, 484, 485, 491, 492, + 491, 492, 0, 491, 492, 493, 488, 493, 0, 494, + 493, 494, 491, 492, 494, 495, 0, 495, 0, 493, + 495, 487, 0, 494, 493, 0, 496, 492, 496, 495, + + 491, 496, 497, 488, 497, 0, 498, 497, 498, 0, + 496, 498, 499, 0, 499, 496, 497, 499, 0, 0, + 498, 493, 0, 501, 492, 501, 499, 491, 501, 502, + 503, 502, 503, 0, 502, 503, 504, 501, 504, 0, + 0, 504, 496, 502, 503, 0, 505, 0, 505, 0, + 504, 505, 502, 506, 507, 506, 507, 0, 506, 507, + 505, 0, 0, 0, 0, 0, 0, 506, 507, 507, + 0, 508, 509, 508, 509, 505, 508, 509, 510, 502, + 510, 0, 0, 510, 0, 508, 509, 0, 0, 511, + 508, 511, 510, 513, 511, 513, 507, 0, 513, 0, + + 0, 0, 505, 511, 0, 0, 509, 513, 514, 515, + 514, 515, 510, 514, 515, 0, 516, 508, 516, 0, + 0, 516, 514, 515, 0, 0, 514, 517, 0, 517, + 516, 0, 517, 509, 0, 518, 0, 518, 0, 510, + 518, 517, 519, 0, 519, 0, 520, 519, 520, 518, + 521, 520, 521, 514, 0, 521, 519, 517, 0, 519, + 520, 0, 0, 518, 521, 524, 522, 524, 522, 521, + 524, 522, 0, 525, 0, 525, 0, 0, 525, 524, + 522, 0, 0, 0, 517, 522, 519, 525, 0, 526, + 518, 526, 0, 0, 526, 527, 521, 527, 0, 528, + + 527, 528, 0, 526, 528, 0, 529, 525, 529, 527, + 0, 529, 522, 528, 531, 0, 531, 0, 0, 531, + 529, 532, 534, 532, 534, 0, 532, 534, 531, 527, + 0, 0, 0, 0, 525, 532, 534, 531, 535, 534, + 535, 0, 0, 535, 532, 537, 538, 537, 538, 0, + 537, 538, 535, 0, 0, 535, 527, 0, 0, 537, + 538, 0, 0, 0, 531, 0, 534, 0, 0, 0, + 0, 532, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 535, 540, 540, 540, 540, 541, 0, 541, + 541, 543, 0, 543, 543, 544, 544, 545, 0, 545, + + 545, 546, 0, 546, 546, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 539, 539, 539, 539, 539, 539, 539, 539, 539 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "frame/ds9lex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 12 "frame/ds9lex.L" + #include + #include + #include + + #include "util.h" + #include "ds9parser.H" + + extern YYSTYPE* mklval; + extern mkFlexLexer* mklexx; + +/* rules */ +#line 1568 "frame/ds9lex.C" + +#define INITIAL 0 +#define DISCARD 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 31 "frame/ds9lex.L" + + +#line 1672 "frame/ds9lex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 540 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 539 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +#line 33 "frame/ds9lex.L" +{ // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(mklval->str,""); // feed a blank string + return STRING; + } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 40 "frame/ds9lex.L" +{ // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 48 "frame/ds9lex.L" +{return AMPLIFIER_;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 49 "frame/ds9lex.L" +{return ANNULUS_;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 50 "frame/ds9lex.L" +{return ARCMIN_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 51 "frame/ds9lex.L" +{return ARCSEC_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 52 "frame/ds9lex.L" +{return ARROW_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 53 "frame/ds9lex.L" +{return B1950_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 54 "frame/ds9lex.L" +{return BACKGROUND_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 55 "frame/ds9lex.L" +{return BEGIN_;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 56 "frame/ds9lex.L" +{return BOX_;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 57 "frame/ds9lex.L" +{return BOXCIRCLE_;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 58 "frame/ds9lex.L" +{return BPANDA_;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 59 "frame/ds9lex.L" +{return CALLBACK_;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 60 "frame/ds9lex.L" +{return CIRCLE_;} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 61 "frame/ds9lex.L" +{return CIRCLE3D_;} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 62 "frame/ds9lex.L" +{return COLOR_;} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 63 "frame/ds9lex.L" +{return COMPASS_;} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 64 "frame/ds9lex.L" +{return COMPOSITE_;} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 65 "frame/ds9lex.L" +{return CPANDA_;} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 66 "frame/ds9lex.L" +{return CROSS_;} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 67 "frame/ds9lex.L" +{return DASH_;} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 68 "frame/ds9lex.L" +{return DASHLIST_;} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 69 "frame/ds9lex.L" +{return DEBUG_;} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 70 "frame/ds9lex.L" +{return DEGREES_;} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 71 "frame/ds9lex.L" +{return DELETE_;} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 72 "frame/ds9lex.L" +{return DETECTOR_;} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 73 "frame/ds9lex.L" +{return DIAMOND_;} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 74 "frame/ds9lex.L" +{return EDIT_;} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 75 "frame/ds9lex.L" +{return ELLIPSE_;} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 76 "frame/ds9lex.L" +{return ECLIPTIC_;} + YY_BREAK +case 32: +YY_RULE_SETUP +#line 77 "frame/ds9lex.L" +{return EPANDA_;} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 78 "frame/ds9lex.L" +{return END_;} + YY_BREAK +case 34: +YY_RULE_SETUP +#line 79 "frame/ds9lex.L" +{return FALSE_;} + YY_BREAK +case 35: +YY_RULE_SETUP +#line 80 "frame/ds9lex.L" +{return FIELD_;} + YY_BREAK +case 36: +YY_RULE_SETUP +#line 81 "frame/ds9lex.L" +{return FIXED_;} + YY_BREAK +case 37: +YY_RULE_SETUP +#line 82 "frame/ds9lex.L" +{return FK4_;} + YY_BREAK +case 38: +YY_RULE_SETUP +#line 83 "frame/ds9lex.L" +{return FK4_NO_E_;} + YY_BREAK +case 39: +YY_RULE_SETUP +#line 84 "frame/ds9lex.L" +{return FK5_;} + YY_BREAK +case 40: +YY_RULE_SETUP +#line 85 "frame/ds9lex.L" +{return FONT_;} + YY_BREAK +case 41: +YY_RULE_SETUP +#line 86 "frame/ds9lex.L" +{return GALACTIC_;} + YY_BREAK +case 42: +YY_RULE_SETUP +#line 87 "frame/ds9lex.L" +{return GLOBAL_;} + YY_BREAK +case 43: +YY_RULE_SETUP +#line 88 "frame/ds9lex.L" +{return HELIOECLIPTIC_;} + YY_BREAK +case 44: +YY_RULE_SETUP +#line 89 "frame/ds9lex.L" +{return HIGHLITE_;} + YY_BREAK +case 45: +YY_RULE_SETUP +#line 90 "frame/ds9lex.L" +{return ICRS_;} + YY_BREAK +case 46: +YY_RULE_SETUP +#line 91 "frame/ds9lex.L" +{return IGNORE_;} + YY_BREAK +case 47: +YY_RULE_SETUP +#line 92 "frame/ds9lex.L" +{return INCLUDE_;} + YY_BREAK +case 48: +YY_RULE_SETUP +#line 93 "frame/ds9lex.L" +{return IMAGE_;} + YY_BREAK +case 49: +YY_RULE_SETUP +#line 94 "frame/ds9lex.L" +{return KEY_;} + YY_BREAK +case 50: +YY_RULE_SETUP +#line 95 "frame/ds9lex.L" +{return J2000_;} + YY_BREAK +case 51: +YY_RULE_SETUP +#line 96 "frame/ds9lex.L" +{return LINE_;} + YY_BREAK +case 52: +YY_RULE_SETUP +#line 97 "frame/ds9lex.L" +{return LINEAR_;} + YY_BREAK +case 53: +YY_RULE_SETUP +#line 98 "frame/ds9lex.L" +{return MOVE_;} + YY_BREAK +case 54: +YY_RULE_SETUP +#line 99 "frame/ds9lex.L" +{return N_;} + YY_BREAK +case 55: +YY_RULE_SETUP +#line 100 "frame/ds9lex.L" +{return NO_;} + YY_BREAK +case 56: +YY_RULE_SETUP +#line 101 "frame/ds9lex.L" +{return OFF_;} + YY_BREAK +case 57: +YY_RULE_SETUP +#line 102 "frame/ds9lex.L" +{return ON_;} + YY_BREAK +case 58: +YY_RULE_SETUP +#line 103 "frame/ds9lex.L" +{return CPANDA_;} + YY_BREAK +case 59: +YY_RULE_SETUP +#line 104 "frame/ds9lex.L" +{return PHYSICAL_;} + YY_BREAK +case 60: +YY_RULE_SETUP +#line 105 "frame/ds9lex.L" +{return PIE_;} + YY_BREAK +case 61: +YY_RULE_SETUP +#line 106 "frame/ds9lex.L" +{return PIXELS_;} + YY_BREAK +case 62: +YY_RULE_SETUP +#line 107 "frame/ds9lex.L" +{return POINT_;} + YY_BREAK +case 63: +YY_RULE_SETUP +#line 108 "frame/ds9lex.L" +{return POLYGON_;} + YY_BREAK +case 64: +YY_RULE_SETUP +#line 109 "frame/ds9lex.L" +{return PROJECTION_;} + YY_BREAK +case 65: +YY_RULE_SETUP +#line 110 "frame/ds9lex.L" +{return PROPERTY_;} + YY_BREAK +case 66: +YY_RULE_SETUP +#line 111 "frame/ds9lex.L" +{return ROTATE_;} + YY_BREAK +case 67: +YY_RULE_SETUP +#line 112 "frame/ds9lex.L" +{return ROTBOX_;} + YY_BREAK +case 68: +YY_RULE_SETUP +#line 113 "frame/ds9lex.L" +{return RULER_;} + YY_BREAK +case 69: +YY_RULE_SETUP +#line 114 "frame/ds9lex.L" +{return SELECT_;} + YY_BREAK +case 70: +YY_RULE_SETUP +#line 115 "frame/ds9lex.L" +{return SEGMENT_;} + YY_BREAK +case 71: +YY_RULE_SETUP +#line 116 "frame/ds9lex.L" +{return SOURCE_;} + YY_BREAK +case 72: +YY_RULE_SETUP +#line 117 "frame/ds9lex.L" +{return SUPERGALACTIC_;} + YY_BREAK +case 73: +YY_RULE_SETUP +#line 118 "frame/ds9lex.L" +{return TAG_;} + YY_BREAK +case 74: +YY_RULE_SETUP +#line 119 "frame/ds9lex.L" +{return TEXT_;} + YY_BREAK +case 75: +YY_RULE_SETUP +#line 120 "frame/ds9lex.L" +{return TEXTANGLE_;} + YY_BREAK +case 76: +YY_RULE_SETUP +#line 121 "frame/ds9lex.L" +{return TEXTROTATE_;} + YY_BREAK +case 77: +YY_RULE_SETUP +#line 122 "frame/ds9lex.L" +{return TILE_;} + YY_BREAK +case 78: +YY_RULE_SETUP +#line 123 "frame/ds9lex.L" +{return TRUE_;} + YY_BREAK +case 79: +YY_RULE_SETUP +#line 124 "frame/ds9lex.L" +{return VECTOR_;} + YY_BREAK +case 80: +YY_RULE_SETUP +#line 125 "frame/ds9lex.L" +{return VERSION_;} + YY_BREAK +case 81: +YY_RULE_SETUP +#line 126 "frame/ds9lex.L" +{return UPDATE_;} + YY_BREAK +case 82: +YY_RULE_SETUP +#line 127 "frame/ds9lex.L" +{return UNHIGHLITE_;} + YY_BREAK +case 83: +YY_RULE_SETUP +#line 128 "frame/ds9lex.L" +{return UNSELECT_;} + YY_BREAK +case 84: +YY_RULE_SETUP +#line 129 "frame/ds9lex.L" +{return WCS_;} + YY_BREAK +case 85: +YY_RULE_SETUP +#line 130 "frame/ds9lex.L" +{return WCSA_;} + YY_BREAK +case 86: +YY_RULE_SETUP +#line 131 "frame/ds9lex.L" +{return WCSB_;} + YY_BREAK +case 87: +YY_RULE_SETUP +#line 132 "frame/ds9lex.L" +{return WCSC_;} + YY_BREAK +case 88: +YY_RULE_SETUP +#line 133 "frame/ds9lex.L" +{return WCSD_;} + YY_BREAK +case 89: +YY_RULE_SETUP +#line 134 "frame/ds9lex.L" +{return WCSE_;} + YY_BREAK +case 90: +YY_RULE_SETUP +#line 135 "frame/ds9lex.L" +{return WCSF_;} + YY_BREAK +case 91: +YY_RULE_SETUP +#line 136 "frame/ds9lex.L" +{return WCSG_;} + YY_BREAK +case 92: +YY_RULE_SETUP +#line 137 "frame/ds9lex.L" +{return WCSH_;} + YY_BREAK +case 93: +YY_RULE_SETUP +#line 138 "frame/ds9lex.L" +{return WCSI_;} + YY_BREAK +case 94: +YY_RULE_SETUP +#line 139 "frame/ds9lex.L" +{return WCSJ_;} + YY_BREAK +case 95: +YY_RULE_SETUP +#line 140 "frame/ds9lex.L" +{return WCSK_;} + YY_BREAK +case 96: +YY_RULE_SETUP +#line 141 "frame/ds9lex.L" +{return WCSL_;} + YY_BREAK +case 97: +YY_RULE_SETUP +#line 142 "frame/ds9lex.L" +{return WCSM_;} + YY_BREAK +case 98: +YY_RULE_SETUP +#line 143 "frame/ds9lex.L" +{return WCSN_;} + YY_BREAK +case 99: +YY_RULE_SETUP +#line 144 "frame/ds9lex.L" +{return WCSO_;} + YY_BREAK +case 100: +YY_RULE_SETUP +#line 145 "frame/ds9lex.L" +{return WCSP_;} + YY_BREAK +case 101: +YY_RULE_SETUP +#line 146 "frame/ds9lex.L" +{return WCSQ_;} + YY_BREAK +case 102: +YY_RULE_SETUP +#line 147 "frame/ds9lex.L" +{return WCSR_;} + YY_BREAK +case 103: +YY_RULE_SETUP +#line 148 "frame/ds9lex.L" +{return WCSS_;} + YY_BREAK +case 104: +YY_RULE_SETUP +#line 149 "frame/ds9lex.L" +{return WCST_;} + YY_BREAK +case 105: +YY_RULE_SETUP +#line 150 "frame/ds9lex.L" +{return WCSU_;} + YY_BREAK +case 106: +YY_RULE_SETUP +#line 151 "frame/ds9lex.L" +{return WCSV_;} + YY_BREAK +case 107: +YY_RULE_SETUP +#line 152 "frame/ds9lex.L" +{return WCSW_;} + YY_BREAK +case 108: +YY_RULE_SETUP +#line 153 "frame/ds9lex.L" +{return WCSX_;} + YY_BREAK +case 109: +YY_RULE_SETUP +#line 154 "frame/ds9lex.L" +{return WCSY_;} + YY_BREAK +case 110: +YY_RULE_SETUP +#line 155 "frame/ds9lex.L" +{return WCSZ_;} + YY_BREAK +case 111: +YY_RULE_SETUP +#line 156 "frame/ds9lex.L" +{return WCS0_;} + YY_BREAK +case 112: +YY_RULE_SETUP +#line 157 "frame/ds9lex.L" +{return WIDTH_;} + YY_BREAK +case 113: +YY_RULE_SETUP +#line 158 "frame/ds9lex.L" +{return X_;} + YY_BREAK +case 114: +YY_RULE_SETUP +#line 159 "frame/ds9lex.L" +{return Y_;} + YY_BREAK +case 115: +YY_RULE_SETUP +#line 160 "frame/ds9lex.L" +{return YES_;} + YY_BREAK +case 116: +YY_RULE_SETUP +#line 163 "frame/ds9lex.L" +{ // Integer + mklval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 117: +#line 169 "frame/ds9lex.L" +case 118: +YY_RULE_SETUP +#line 169 "frame/ds9lex.L" +{ // Real Number + mklval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 119: +#line 175 "frame/ds9lex.L" +case 120: +YY_RULE_SETUP +#line 175 "frame/ds9lex.L" +{ // degrees + yytext[yyleng-1] = '\0'; + mklval->real = atof(yytext); + return ANGDEGREE; + } + YY_BREAK +case 121: +#line 182 "frame/ds9lex.L" +case 122: +YY_RULE_SETUP +#line 182 "frame/ds9lex.L" +{ // radians + yytext[yyleng-1] = '\0'; + mklval->real = atof(yytext); + return ANGRADIAN; + } + YY_BREAK +case 123: +#line 189 "frame/ds9lex.L" +case 124: +YY_RULE_SETUP +#line 189 "frame/ds9lex.L" +{ // physical coords + yytext[yyleng-1] = '\0'; + mklval->real = atof(yytext); + return PHYCOORD; + } + YY_BREAK +case 125: +#line 196 "frame/ds9lex.L" +case 126: +YY_RULE_SETUP +#line 196 "frame/ds9lex.L" +{ // image coords + yytext[yyleng-1] = '\0'; + mklval->real = atof(yytext); + return IMGCOORD; + } + YY_BREAK +case 127: +#line 203 "frame/ds9lex.L" +case 128: +#line 204 "frame/ds9lex.L" +case 129: +#line 205 "frame/ds9lex.L" +case 130: +YY_RULE_SETUP +#line 205 "frame/ds9lex.L" +{ // minutes of arc + yytext[yyleng-1] = '\0'; + mklval->real = atof(yytext); + return ARCMINUTE; + } + YY_BREAK +case 131: +#line 212 "frame/ds9lex.L" +case 132: +#line 213 "frame/ds9lex.L" +case 133: +#line 214 "frame/ds9lex.L" +case 134: +YY_RULE_SETUP +#line 214 "frame/ds9lex.L" +{ // seconds of arc + yytext[yyleng-1] = '\0'; + mklval->real = atof(yytext); + return ARCSECOND; + } + YY_BREAK +case 135: +#line 221 "frame/ds9lex.L" +case 136: +YY_RULE_SETUP +#line 221 "frame/ds9lex.L" +{ // Sexagesimal + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return SEXSTR; + } + YY_BREAK +case 137: +#line 229 "frame/ds9lex.L" +case 138: +YY_RULE_SETUP +#line 229 "frame/ds9lex.L" +{ // HMS + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return HMSSTR; + } + YY_BREAK +case 139: +#line 237 "frame/ds9lex.L" +case 140: +YY_RULE_SETUP +#line 237 "frame/ds9lex.L" +{ // DMS + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return DMSSTR; + } + YY_BREAK +case 141: +YY_RULE_SETUP +#line 244 "frame/ds9lex.L" +{ // 8 bit Hex Color + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 142: +YY_RULE_SETUP +#line 251 "frame/ds9lex.L" +{ // 16 bit Hex Color + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 143: +YY_RULE_SETUP +#line 258 "frame/ds9lex.L" +{ // 32 bit Hex Color + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 144: +#line 266 "frame/ds9lex.L" +case 145: +YY_RULE_SETUP +#line 266 "frame/ds9lex.L" +{ // Quoted String + int ll = (yyleng-2)<(MKBUFSIZE-1) ? (yyleng-2):(MKBUFSIZE-1); + strncpy(mklval->str,yytext+1,ll); // skip the " " + mklval->str[ll] = '\0'; // Remove the '"' + return STRING; + } + YY_BREAK +case 146: +YY_RULE_SETUP +#line 273 "frame/ds9lex.L" +{ // Quoted String + int ll = (yyleng-2)<(MKBUFSIZE-1) ? (yyleng-2):(MKBUFSIZE-1); + strncpy(mklval->str,yytext+1,ll); // skip the '{' + mklval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + YY_BREAK +case 147: +YY_RULE_SETUP +#line 280 "frame/ds9lex.L" +{ // General String + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 148: +YY_RULE_SETUP +#line 287 "frame/ds9lex.L" +{ // White Spaces + } + YY_BREAK +case 149: +/* rule 149 can match eol */ +YY_RULE_SETUP +#line 290 "frame/ds9lex.L" +{ // windows line feed + return '\n'; + } + YY_BREAK +case 150: +YY_RULE_SETUP +#line 294 "frame/ds9lex.L" +{ // fake line feed + return '\n'; + } + YY_BREAK +case 151: +/* rule 151 can match eol */ +YY_RULE_SETUP +#line 298 "frame/ds9lex.L" +{ // linefeed + return '\n'; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(DISCARD): +#line 302 "frame/ds9lex.L" +{ // eof + return EOF_; + } + YY_BREAK +case 152: +YY_RULE_SETUP +#line 306 "frame/ds9lex.L" +{ // Else, return the char + return yytext[0]; + } + YY_BREAK +case 153: +YY_RULE_SETUP +#line 310 "frame/ds9lex.L" +ECHO; + YY_BREAK +#line 2576 "frame/ds9lex.C" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + mkfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + mkfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + mkrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) mkrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 540 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 540 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 539); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) mkalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) mkalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + mkfree((void *) b->yy_ch_buf ); + + mkfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)mkalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)mkrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) mkalloc(new_size ); + + else + (yy_start_stack) = (int *) mkrealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *mkalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *mkrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void mkfree (void * ptr ) +{ + free( (char *) ptr ); /* see mkrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 310 "frame/ds9lex.L" + + + +void mkDiscard(int doit) +{ + if (mklexx) + mklexx->begin(DISCARD, doit); +} + +void mkFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} + diff --git a/tksao/frame/ds9lex.L b/tksao/frame/ds9lex.L new file mode 100644 index 0000000..1b38a16 --- /dev/null +++ b/tksao/frame/ds9lex.L @@ -0,0 +1,323 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ + +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + + #include "util.h" + #include "ds9parser.H" + + extern YYSTYPE* mklval; + extern mkFlexLexer* mklexx; +%} + +%x DISCARD + +D [0-9] +E [Ee][+-]?{D}+ +H [0-9a-fA-F] + +/* rules */ + +%% + +[\n] { // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(mklval->str,""); // feed a blank string + return STRING; + } + +[^\n]* { // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return STRING; + } + +amplifier {return AMPLIFIER_;} +ann[u][l][u][s] {return ANNULUS_;} +arcmin {return ARCMIN_;} +arcsec {return ARCSEC_;} +arrow {return ARROW_;} +b1950 {return B1950_;} +background {return BACKGROUND_;} +begin {return BEGIN_;} +box {return BOX_;} +boxcircle {return BOXCIRCLE_;} +bpanda {return BPANDA_;} +callback {return CALLBACK_;} +cir[c][l][e] {return CIRCLE_;} +circle3d {return CIRCLE3D_;} +color {return COLOR_;} +compass {return COMPASS_;} +composite {return COMPOSITE_;} +cpanda {return CPANDA_;} +cross {return CROSS_;} +dash {return DASH_;} +dashlist {return DASHLIST_;} +debug {return DEBUG_;} +degrees {return DEGREES_;} +delete {return DELETE_;} +detector {return DETECTOR_;} +diamond {return DIAMOND_;} +edit {return EDIT_;} +ell[i][p][s][e] {return ELLIPSE_;} +ecliptic {return ECLIPTIC_;} +epanda {return EPANDA_;} +end {return END_;} +false {return FALSE_;} +fie[l][d] {return FIELD_;} +fixed {return FIXED_;} +fk4 {return FK4_;} +fk4-no-e {return FK4_NO_E_;} +fk5 {return FK5_;} +font {return FONT_;} +galactic {return GALACTIC_;} +global {return GLOBAL_;} +helioecliptic {return HELIOECLIPTIC_;} +highlite {return HIGHLITE_;} +icrs {return ICRS_;} +ignore {return IGNORE_;} +include {return INCLUDE_;} +image {return IMAGE_;} +key {return KEY_;} +j2000 {return J2000_;} +lin[e] {return LINE_;} +linear {return LINEAR_;} +move {return MOVE_;} +n {return N_;} +no {return NO_;} +off {return OFF_;} +on {return ON_;} +panda {return CPANDA_;} +physical {return PHYSICAL_;} +pie {return PIE_;} +pixels {return PIXELS_;} +poi[n][t] {return POINT_;} +pol[y][g][o][n] {return POLYGON_;} +projection {return PROJECTION_;} +property {return PROPERTY_;} +rotate {return ROTATE_;} +rotbox {return ROTBOX_;} +ruler {return RULER_;} +select {return SELECT_;} +segment {return SEGMENT_;} +source {return SOURCE_;} +supergalactic {return SUPERGALACTIC_;} +tag {return TAG_;} +text {return TEXT_;} +textangle {return TEXTANGLE_;} +textrotate {return TEXTROTATE_;} +tile {return TILE_;} +true {return TRUE_;} +vector {return VECTOR_;} +version {return VERSION_;} +update {return UPDATE_;} +unhighlite {return UNHIGHLITE_;} +unselect {return UNSELECT_;} +wcs {return WCS_;} +wcsa {return WCSA_;} +wcsb {return WCSB_;} +wcsc {return WCSC_;} +wcsd {return WCSD_;} +wcse {return WCSE_;} +wcsf {return WCSF_;} +wcsg {return WCSG_;} +wcsh {return WCSH_;} +wcsi {return WCSI_;} +wcsj {return WCSJ_;} +wcsk {return WCSK_;} +wcsl {return WCSL_;} +wcsm {return WCSM_;} +wcsn {return WCSN_;} +wcso {return WCSO_;} +wcsp {return WCSP_;} +wcsq {return WCSQ_;} +wcsr {return WCSR_;} +wcss {return WCSS_;} +wcst {return WCST_;} +wcsu {return WCSU_;} +wcsv {return WCSV_;} +wcsw {return WCSW_;} +wcsx {return WCSX_;} +wcsy {return WCSY_;} +wcsz {return WCSZ_;} +wcs0 {return WCS0_;} +width {return WIDTH_;} +x {return X_;} +y {return Y_;} +yes {return YES_;} + + +[+-]?{D}+ { // Integer + mklval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + mklval->real = atof(yytext); + return REAL; + } + +[+-]?{D}+"."?d | +[+-]?{D}*"."{D}+d { // degrees + yytext[yyleng-1] = '\0'; + mklval->real = atof(yytext); + return ANGDEGREE; + } + +[+-]?{D}+"."?r | +[+-]?{D}*"."{D}+r { // radians + yytext[yyleng-1] = '\0'; + mklval->real = atof(yytext); + return ANGRADIAN; + } + +[+-]?{D}+"."?p | +[+-]?{D}*"."{D}+p { // physical coords + yytext[yyleng-1] = '\0'; + mklval->real = atof(yytext); + return PHYCOORD; + } + +[+-]?{D}+"."?i | +[+-]?{D}*"."{D}+i { // image coords + yytext[yyleng-1] = '\0'; + mklval->real = atof(yytext); + return IMGCOORD; + } + +{D}+"."?' | +{D}*"."{D}+' | +[+-]?{D}+"."?({E})?' | +[+-]?{D}*"."{D}+({E})?' { // minutes of arc + yytext[yyleng-1] = '\0'; + mklval->real = atof(yytext); + return ARCMINUTE; + } + +{D}+"."?\" | +{D}*"."{D}+\" | +[+-]?{D}+"."?({E})?\" | +[+-]?{D}*"."{D}+({E})?\" { // seconds of arc + yytext[yyleng-1] = '\0'; + mklval->real = atof(yytext); + return ARCSECOND; + } + +[+-]?{D}+:{D}+:{D}+"."? | +[+-]?{D}+:{D}+:{D}*"."{D}+ { // Sexagesimal + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return SEXSTR; + } + +[+-]?{D}+h{D}+m{D}+"."?s | +[+-]?{D}+h{D}+m{D}*"."{D}+s { // HMS + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return HMSSTR; + } + +[+-]?{D}+d{D}+m{D}+"."?s | +[+-]?{D}+d{D}+m{D}*"."{D}+s { // DMS + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return DMSSTR; + } + +#({H}){3} { // 8 bit Hex Color + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return STRING; + } + +#({H}){6} { // 16 bit Hex Color + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return STRING; + } + +#({H}){12} { // 32 bit Hex Color + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return STRING; + } + +\"[^\"\n]*\" | +\'[^\'\n]*\' { // Quoted String + int ll = (yyleng-2)<(MKBUFSIZE-1) ? (yyleng-2):(MKBUFSIZE-1); + strncpy(mklval->str,yytext+1,ll); // skip the " " + mklval->str[ll] = '\0'; // Remove the '"' + return STRING; + } + +\{[^\}\n]*\} { // Quoted String + int ll = (yyleng-2)<(MKBUFSIZE-1) ? (yyleng-2):(MKBUFSIZE-1); + strncpy(mklval->str,yytext+1,ll); // skip the '{' + mklval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + +[0-9A-Za-z]+ { // General String + int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1); + strncpy(mklval->str,yytext,ll); + mklval->str[ll] = '\0'; + return STRING; + } + +[ \t]+ { // White Spaces + } + +\r\n { // windows line feed + return '\n'; + } + +\\n { // fake line feed + return '\n'; + } + +\n { // linefeed + return '\n'; + } + +<> { // eof + return EOF_; + } + +. { // Else, return the char + return yytext[0]; + } + +%% + +void mkDiscard(int doit) +{ + if (mklexx) + mklexx->begin(DISCARD, doit); +} + +void mkFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} diff --git a/tksao/frame/ds9parser.C b/tksao/frame/ds9parser.C new file mode 100644 index 0000000..3ebed50 --- /dev/null +++ b/tksao/frame/ds9parser.C @@ -0,0 +1,5140 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse mkparse +#define yylex mklex +#define yyerror mkerror +#define yylval mklval +#define yychar mkchar +#define yydebug mkdebug +#define yynerrs mknerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + STRING = 260, + COLOR = 261, + ANGDEGREE = 262, + ANGRADIAN = 263, + ARCMINUTE = 264, + ARCSECOND = 265, + PHYCOORD = 266, + IMGCOORD = 267, + SEXSTR = 268, + HMSSTR = 269, + DMSSTR = 270, + EOF_ = 271, + AMPLIFIER_ = 272, + ANNULUS_ = 273, + ARCMIN_ = 274, + ARCSEC_ = 275, + ARROW_ = 276, + B1950_ = 277, + BACKGROUND_ = 278, + BEGIN_ = 279, + BOX_ = 280, + BOXCIRCLE_ = 281, + BPANDA_ = 282, + CALLBACK_ = 283, + CIRCLE_ = 284, + CIRCLE3D_ = 285, + COLOR_ = 286, + COMPASS_ = 287, + COMPOSITE_ = 288, + CPANDA_ = 289, + CROSS_ = 290, + DASH_ = 291, + DASHLIST_ = 292, + DEBUG_ = 293, + DEGREES_ = 294, + DELETE_ = 295, + DETECTOR_ = 296, + DIAMOND_ = 297, + ECLIPTIC_ = 298, + EDIT_ = 299, + ELLIPSE_ = 300, + END_ = 301, + EPANDA_ = 302, + FALSE_ = 303, + FIELD_ = 304, + FIXED_ = 305, + FK4_ = 306, + FK4_NO_E_ = 307, + FK5_ = 308, + FONT_ = 309, + GALACTIC_ = 310, + GLOBAL_ = 311, + HELIOECLIPTIC_ = 312, + HIGHLITE_ = 313, + ICRS_ = 314, + IGNORE_ = 315, + IMAGE_ = 316, + INCLUDE_ = 317, + J2000_ = 318, + KEY_ = 319, + LINE_ = 320, + LINEAR_ = 321, + MOVE_ = 322, + N_ = 323, + NO_ = 324, + OFF_ = 325, + ON_ = 326, + PHYSICAL_ = 327, + PIE_ = 328, + PIXELS_ = 329, + POINT_ = 330, + POLYGON_ = 331, + PROJECTION_ = 332, + PROPERTY_ = 333, + ROTATE_ = 334, + ROTBOX_ = 335, + RULER_ = 336, + SEGMENT_ = 337, + SELECT_ = 338, + SOURCE_ = 339, + SUPERGALACTIC_ = 340, + TAG_ = 341, + TEXT_ = 342, + TEXTANGLE_ = 343, + TEXTROTATE_ = 344, + TILE_ = 345, + TRUE_ = 346, + VECTOR_ = 347, + VERSION_ = 348, + UNHIGHLITE_ = 349, + UNSELECT_ = 350, + UPDATE_ = 351, + WCS_ = 352, + WCSA_ = 353, + WCSB_ = 354, + WCSC_ = 355, + WCSD_ = 356, + WCSE_ = 357, + WCSF_ = 358, + WCSG_ = 359, + WCSH_ = 360, + WCSI_ = 361, + WCSJ_ = 362, + WCSK_ = 363, + WCSL_ = 364, + WCSM_ = 365, + WCSN_ = 366, + WCSO_ = 367, + WCSP_ = 368, + WCSQ_ = 369, + WCSR_ = 370, + WCSS_ = 371, + WCST_ = 372, + WCSU_ = 373, + WCSV_ = 374, + WCSW_ = 375, + WCSX_ = 376, + WCSY_ = 377, + WCSZ_ = 378, + WCS0_ = 379, + WIDTH_ = 380, + X_ = 381, + Y_ = 382, + YES_ = 383 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define STRING 260 +#define COLOR 261 +#define ANGDEGREE 262 +#define ANGRADIAN 263 +#define ARCMINUTE 264 +#define ARCSECOND 265 +#define PHYCOORD 266 +#define IMGCOORD 267 +#define SEXSTR 268 +#define HMSSTR 269 +#define DMSSTR 270 +#define EOF_ 271 +#define AMPLIFIER_ 272 +#define ANNULUS_ 273 +#define ARCMIN_ 274 +#define ARCSEC_ 275 +#define ARROW_ 276 +#define B1950_ 277 +#define BACKGROUND_ 278 +#define BEGIN_ 279 +#define BOX_ 280 +#define BOXCIRCLE_ 281 +#define BPANDA_ 282 +#define CALLBACK_ 283 +#define CIRCLE_ 284 +#define CIRCLE3D_ 285 +#define COLOR_ 286 +#define COMPASS_ 287 +#define COMPOSITE_ 288 +#define CPANDA_ 289 +#define CROSS_ 290 +#define DASH_ 291 +#define DASHLIST_ 292 +#define DEBUG_ 293 +#define DEGREES_ 294 +#define DELETE_ 295 +#define DETECTOR_ 296 +#define DIAMOND_ 297 +#define ECLIPTIC_ 298 +#define EDIT_ 299 +#define ELLIPSE_ 300 +#define END_ 301 +#define EPANDA_ 302 +#define FALSE_ 303 +#define FIELD_ 304 +#define FIXED_ 305 +#define FK4_ 306 +#define FK4_NO_E_ 307 +#define FK5_ 308 +#define FONT_ 309 +#define GALACTIC_ 310 +#define GLOBAL_ 311 +#define HELIOECLIPTIC_ 312 +#define HIGHLITE_ 313 +#define ICRS_ 314 +#define IGNORE_ 315 +#define IMAGE_ 316 +#define INCLUDE_ 317 +#define J2000_ 318 +#define KEY_ 319 +#define LINE_ 320 +#define LINEAR_ 321 +#define MOVE_ 322 +#define N_ 323 +#define NO_ 324 +#define OFF_ 325 +#define ON_ 326 +#define PHYSICAL_ 327 +#define PIE_ 328 +#define PIXELS_ 329 +#define POINT_ 330 +#define POLYGON_ 331 +#define PROJECTION_ 332 +#define PROPERTY_ 333 +#define ROTATE_ 334 +#define ROTBOX_ 335 +#define RULER_ 336 +#define SEGMENT_ 337 +#define SELECT_ 338 +#define SOURCE_ 339 +#define SUPERGALACTIC_ 340 +#define TAG_ 341 +#define TEXT_ 342 +#define TEXTANGLE_ 343 +#define TEXTROTATE_ 344 +#define TILE_ 345 +#define TRUE_ 346 +#define VECTOR_ 347 +#define VERSION_ 348 +#define UNHIGHLITE_ 349 +#define UNSELECT_ 350 +#define UPDATE_ 351 +#define WCS_ 352 +#define WCSA_ 353 +#define WCSB_ 354 +#define WCSC_ 355 +#define WCSD_ 356 +#define WCSE_ 357 +#define WCSF_ 358 +#define WCSG_ 359 +#define WCSH_ 360 +#define WCSI_ 361 +#define WCSJ_ 362 +#define WCSK_ 363 +#define WCSL_ 364 +#define WCSM_ 365 +#define WCSN_ 366 +#define WCSO_ 367 +#define WCSP_ 368 +#define WCSQ_ 369 +#define WCSR_ 370 +#define WCSS_ 371 +#define WCST_ 372 +#define WCSU_ 373 +#define WCSV_ 374 +#define WCSW_ 375 +#define WCSX_ 376 +#define WCSY_ 377 +#define WCSZ_ 378 +#define WCS0_ 379 +#define WIDTH_ 380 +#define X_ 381 +#define Y_ 382 +#define YES_ 383 + + + + +/* Copy the first part of user declarations. */ +#line 10 "frame/ds9parser.Y" + +#define YYDEBUG 1 + +#define FITSPTR (fr->findFits(globalTile)) +#define DISCARD_(x) {yyclearin; mkDiscard(x);} + +#include +#include +#include + +#include "base.h" +#include "fitsimage.h" +#include "basemarker.h" +#include "point.h" + +#undef yyFlexLexer +#define yyFlexLexer mkFlexLexer +#include + +extern int mklex(void*, mkFlexLexer*); +extern void mkerror(Base*, mkFlexLexer*, const char*); +extern void mkDiscard(int); + +static Coord::CoordSystem globalWCS; + +static Coord::CoordSystem globalSystem; +static Coord::CoordSystem localSystem; +static Coord::SkyFrame globalSky; +static Coord::SkyFrame localSky; + +static int globalTile; + +static unsigned short globalProps; +static unsigned short localProps; + +static int globalDash[2]; +static int localDash[2]; + +static int globalWidth; +static int localWidth; + +static char globalColor[16]; +static char localColor[16]; + +static char globalFont[32]; +static char localFont[32]; + +static char globalText[80]; +static char localText[80]; + +static char localComment[80]; + +static int globalLine1; +static int localLine1; +static int globalLine2; +static int localLine2; + +static int globalVector; +static int localVector; + +static int globalComposite; +static int localComposite; + +static int globalPoint; +static int localPoint; +static int globalPointSize; +static int localPointSize; + +static double globalTextAngle; +static double localTextAngle; +static int globalTextRotate; +static int localTextRotate; + +static Coord::CoordSystem globalRulerCoordSystem; +static Coord::CoordSystem localRulerCoordSystem; +static Coord::SkyFrame globalRulerSkyFrame; +static Coord::SkyFrame localRulerSkyFrame; +static Coord::CoordSystem globalRulerDistSystem; +static Coord::CoordSystem localRulerDistSystem; +static Coord::SkyDist globalRulerDistFormat; +static Coord::SkyDist localRulerDistFormat; + +static Coord::CoordSystem globalCompassCoordSystem; +static Coord::SkyFrame globalCompassSkyFrame; +static char globalCompassNorth[80]; +static char globalCompassEast[80]; +static int globalCompassNArrow; +static int globalCompassEArrow; +static Coord::CoordSystem localCompassCoordSystem; +static Coord::SkyFrame localCompassSkyFrame; +static char localCompassNorth[80]; +static char localCompassEast[80]; +static int localCompassNArrow; +static int localCompassEArrow; + +static int localCpanda; +static int localEpanda; +static int localBpanda; + +static List polylist; +static List taglist; +static List cblist; + +static double aAnnuli[MAXANNULI]; +static Vector aVector[MAXANNULI]; +static int aNum; +static int aNumsao; +static int aStatus; +static int cStatus; +static Vector aCenter; +static double aAngles[MAXANGLES]; +static int aAngNum; +static double aAngle; +static unsigned short aProps; +static char aColor[16]; +static int aWidth; +static int aDash[2]; +static char aFont[32]; +static char aText[80]; +static char aComment[80]; + +static void setProps(unsigned short* props, unsigned short prop, int value); +static Coord::CoordSystem checkWCSSystem(); +static Coord::SkyFrame checkWCSSky(); + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 136 "frame/ds9parser.Y" +{ +#define MKBUFSIZE 2048 + double real; + int integer; + char str[MKBUFSIZE]; + double vector[3]; +} +/* Line 193 of yacc.c. */ +#line 494 "frame/ds9parser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 507 "frame/ds9parser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 2735 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 141 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 73 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 326 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 841 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 383 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 130, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 140, 2, 129, 2, 2, 139, 2, + 133, 134, 2, 137, 132, 138, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 131, + 2, 136, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 135, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 125, 126, 127, 128 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 7, 11, 14, 15, 18, 20, 24, + 27, 28, 32, 33, 37, 38, 42, 45, 49, 53, + 55, 58, 61, 62, 65, 66, 67, 71, 73, 74, + 79, 83, 84, 90, 92, 93, 97, 100, 101, 106, + 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, + 128, 130, 132, 134, 136, 138, 139, 141, 142, 144, + 145, 147, 148, 150, 153, 154, 156, 158, 160, 162, + 164, 166, 168, 170, 172, 174, 178, 182, 186, 190, + 194, 198, 202, 204, 206, 208, 212, 216, 220, 224, + 228, 232, 236, 238, 240, 242, 244, 246, 248, 250, + 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, + 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, + 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, + 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, + 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, + 352, 354, 356, 359, 361, 364, 367, 369, 372, 375, + 377, 380, 382, 384, 386, 388, 390, 392, 394, 396, + 400, 402, 406, 410, 415, 419, 423, 427, 429, 431, + 433, 437, 442, 447, 451, 455, 459, 467, 471, 475, + 479, 484, 487, 490, 493, 496, 499, 502, 504, 506, + 509, 511, 513, 515, 516, 520, 522, 526, 530, 535, + 539, 543, 547, 551, 557, 559, 561, 563, 567, 572, + 577, 581, 585, 589, 597, 601, 605, 609, 613, 617, + 622, 625, 628, 631, 634, 637, 640, 642, 644, 647, + 649, 651, 653, 654, 662, 664, 665, 676, 678, 679, + 690, 692, 693, 695, 697, 699, 701, 703, 705, 707, + 709, 711, 722, 723, 731, 738, 747, 756, 767, 776, + 785, 794, 803, 814, 825, 836, 837, 845, 846, 854, + 863, 874, 881, 882, 892, 899, 907, 915, 923, 931, + 939, 947, 955, 964, 973, 984, 995, 1008, 1021, 1034, + 1049, 1064, 1083, 1096, 1111, 1126, 1145, 1164, 1185, 1206, + 1217, 1230, 1243, 1249, 1258, 1262, 1264, 1266, 1270, 1272, + 1274, 1278, 1280, 1282, 1286, 1288, 1292 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int16 yyrhs[] = +{ + 142, 0, -1, 185, 143, 213, -1, 143, 144, 158, + -1, 144, 158, -1, -1, 38, 160, -1, 93, -1, + 56, 181, 150, -1, 90, 3, -1, -1, 175, 145, + 150, -1, -1, 177, 146, 150, -1, -1, 66, 147, + 150, -1, 196, 201, -1, 196, 198, 201, -1, 196, + 129, 148, -1, 199, -1, 198, 199, -1, 90, 3, + -1, -1, 149, 5, -1, -1, -1, 129, 151, 5, + -1, 213, -1, -1, 129, 153, 5, 213, -1, 129, + 186, 213, -1, -1, 129, 186, 154, 5, 213, -1, + 213, -1, -1, 156, 5, 213, -1, 186, 213, -1, + -1, 186, 157, 5, 213, -1, 130, -1, 131, -1, + 16, -1, 4, -1, 3, -1, 71, -1, 70, -1, + 3, -1, 128, -1, 127, -1, 71, -1, 91, -1, + 69, -1, 68, -1, 70, -1, 48, -1, -1, 132, + -1, -1, 133, -1, -1, 134, -1, -1, 135, -1, + 135, 135, -1, -1, 167, -1, 159, -1, 7, -1, + 8, -1, 159, -1, 11, -1, 12, -1, 7, -1, + 9, -1, 10, -1, 159, 162, 159, -1, 11, 162, + 11, -1, 12, 162, 12, -1, 7, 162, 7, -1, + 9, 162, 9, -1, 10, 162, 10, -1, 68, 136, + 3, -1, 13, -1, 14, -1, 15, -1, 171, 162, + 171, -1, 172, 162, 173, -1, 173, 162, 173, -1, + 159, 162, 159, -1, 7, 162, 7, -1, 12, 162, + 12, -1, 11, 162, 11, -1, 61, -1, 72, -1, + 41, -1, 17, -1, 176, -1, 97, -1, 98, -1, + 99, -1, 100, -1, 101, -1, 102, -1, 103, -1, + 104, -1, 105, -1, 106, -1, 107, -1, 108, -1, + 109, -1, 110, -1, 111, -1, 112, -1, 113, -1, + 114, -1, 115, -1, 116, -1, 117, -1, 118, -1, + 119, -1, 120, -1, 121, -1, 122, -1, 123, -1, + 124, -1, 51, -1, 22, -1, 52, -1, 53, -1, + 63, -1, 59, -1, 55, -1, 85, -1, 43, -1, + 57, -1, 39, -1, 19, -1, 20, -1, 83, -1, + 58, -1, 36, -1, 50, -1, 44, -1, 67, -1, + 79, -1, 40, -1, 62, -1, 84, -1, 83, -1, + 95, -1, 58, -1, 94, -1, 24, 67, -1, 67, + -1, 46, 67, -1, 24, 44, -1, 44, -1, 46, + 44, -1, 24, 79, -1, 79, -1, 46, 79, -1, + 40, -1, 87, -1, 31, -1, 125, -1, 78, -1, + 54, -1, 64, -1, 96, -1, 181, 162, 182, -1, + 182, -1, 179, 136, 161, -1, 31, 136, 5, -1, + 37, 136, 3, 3, -1, 125, 136, 3, -1, 54, + 136, 5, -1, 87, 136, 5, -1, 36, -1, 84, + -1, 23, -1, 75, 136, 197, -1, 75, 136, 197, + 3, -1, 65, 136, 3, 3, -1, 92, 136, 3, + -1, 33, 136, 3, -1, 81, 136, 183, -1, 32, + 136, 184, 5, 5, 3, 3, -1, 88, 136, 167, + -1, 89, 136, 3, -1, 97, 136, 176, -1, 175, + 177, 175, 178, -1, 175, 175, -1, 175, 178, -1, + 177, 175, -1, 177, 178, -1, 66, 175, -1, 66, + 178, -1, 178, -1, 74, -1, 175, 177, -1, 175, + -1, 177, -1, 66, -1, -1, 186, 162, 187, -1, + 187, -1, 179, 136, 161, -1, 31, 136, 5, -1, + 37, 136, 3, 3, -1, 125, 136, 3, -1, 54, + 136, 5, -1, 87, 136, 5, -1, 86, 136, 5, + -1, 28, 136, 180, 5, 5, -1, 36, -1, 84, + -1, 23, -1, 75, 136, 197, -1, 75, 136, 197, + 3, -1, 65, 136, 3, 3, -1, 92, 136, 3, + -1, 33, 136, 3, -1, 81, 136, 188, -1, 32, + 136, 189, 5, 5, 3, 3, -1, 88, 136, 167, + -1, 89, 136, 3, -1, 34, 136, 190, -1, 47, + 136, 192, -1, 27, 136, 194, -1, 175, 177, 175, + 178, -1, 175, 175, -1, 175, 178, -1, 177, 175, + -1, 177, 178, -1, 66, 175, -1, 66, 178, -1, + 178, -1, 74, -1, 175, 177, -1, 175, -1, 177, + -1, 66, -1, -1, 191, 133, 209, 134, 133, 207, + 134, -1, 60, -1, -1, 193, 133, 209, 134, 133, + 211, 134, 133, 167, 134, -1, 60, -1, -1, 195, + 133, 209, 134, 133, 211, 134, 133, 167, 134, -1, + 60, -1, -1, 29, -1, 25, -1, 42, -1, 35, + -1, 126, -1, 21, -1, 26, -1, 137, -1, 138, + -1, 92, 163, 174, 162, 168, 162, 167, 164, 165, + 155, -1, -1, 82, 200, 163, 205, 164, 165, 155, + -1, 87, 163, 174, 164, 165, 155, -1, 81, 163, + 174, 162, 174, 164, 165, 155, -1, 32, 163, 174, + 162, 168, 164, 165, 155, -1, 77, 163, 174, 162, + 174, 162, 168, 164, 165, 155, -1, 30, 163, 174, + 162, 168, 164, 165, 155, -1, 33, 163, 174, 162, + 166, 164, 165, 155, -1, 29, 163, 174, 162, 168, + 164, 165, 152, -1, 30, 163, 174, 162, 168, 164, + 165, 152, -1, 45, 163, 174, 162, 169, 162, 166, + 164, 165, 152, -1, 25, 163, 174, 162, 169, 162, + 166, 164, 165, 152, -1, 80, 163, 174, 162, 169, + 162, 166, 164, 165, 152, -1, -1, 76, 202, 163, + 205, 164, 165, 152, -1, -1, 82, 203, 163, 205, + 164, 165, 152, -1, 65, 163, 174, 162, 174, 164, + 165, 152, -1, 92, 163, 174, 162, 168, 162, 167, + 164, 165, 152, -1, 87, 163, 174, 164, 165, 152, + -1, -1, 87, 163, 174, 162, 5, 164, 204, 165, + 152, -1, 75, 163, 174, 164, 165, 152, -1, 29, + 75, 163, 174, 164, 165, 152, -1, 25, 75, 163, + 174, 164, 165, 152, -1, 42, 75, 163, 174, 164, + 165, 152, -1, 35, 75, 163, 174, 164, 165, 152, + -1, 126, 75, 163, 174, 164, 165, 152, -1, 21, + 75, 163, 174, 164, 165, 152, -1, 26, 75, 163, + 174, 164, 165, 152, -1, 81, 163, 174, 162, 174, + 164, 165, 152, -1, 32, 163, 174, 162, 168, 164, + 165, 152, -1, 77, 163, 174, 162, 174, 162, 168, + 164, 165, 152, -1, 18, 163, 174, 162, 168, 162, + 168, 164, 165, 152, -1, 18, 163, 174, 162, 168, + 162, 168, 162, 207, 164, 165, 152, -1, 18, 163, + 174, 162, 168, 162, 168, 162, 170, 164, 165, 152, + -1, 45, 163, 174, 162, 169, 162, 169, 162, 166, + 164, 165, 152, -1, 45, 163, 174, 162, 169, 162, + 169, 162, 170, 162, 166, 164, 165, 152, -1, 45, + 163, 174, 162, 169, 162, 169, 162, 211, 162, 166, + 164, 165, 152, -1, 45, 163, 174, 162, 169, 162, + 166, 164, 139, 140, 45, 163, 174, 162, 169, 162, + 166, 164, -1, 25, 163, 174, 162, 169, 162, 169, + 162, 166, 164, 165, 152, -1, 25, 163, 174, 162, + 169, 162, 169, 162, 211, 162, 166, 164, 165, 152, + -1, 25, 163, 174, 162, 169, 162, 169, 162, 170, + 162, 166, 164, 165, 152, -1, 25, 163, 174, 162, + 169, 162, 166, 164, 139, 140, 25, 163, 174, 162, + 169, 162, 166, 164, -1, 34, 163, 174, 162, 167, + 162, 167, 162, 3, 162, 168, 162, 168, 162, 3, + 164, 165, 152, -1, 47, 163, 174, 162, 167, 162, + 167, 162, 3, 162, 169, 162, 169, 162, 3, 162, + 166, 164, 165, 152, -1, 27, 163, 174, 162, 167, + 162, 167, 162, 3, 162, 169, 162, 169, 162, 3, + 162, 166, 164, 165, 152, -1, 73, 163, 174, 162, + 167, 162, 167, 164, 165, 152, -1, 73, 163, 174, + 162, 167, 162, 167, 162, 209, 164, 165, 152, -1, + 73, 163, 174, 162, 167, 162, 167, 162, 170, 164, + 165, 152, -1, 49, 163, 164, 165, 152, -1, 33, + 163, 174, 162, 166, 164, 165, 152, -1, 205, 162, + 206, -1, 206, -1, 174, -1, 207, 162, 208, -1, + 208, -1, 168, -1, 209, 162, 210, -1, 210, -1, + 167, -1, 211, 162, 212, -1, 212, -1, 168, 162, + 168, -1, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 297, 297, 300, 301, 304, 305, 306, 308, 309, + 311, 311, 312, 312, 313, 313, 315, 316, 317, 320, + 321, 322, 323, 323, 326, 327, 327, 330, 331, 331, + 332, 333, 333, 336, 337, 337, 338, 339, 339, 342, + 343, 344, 347, 348, 351, 352, 355, 357, 358, 359, + 360, 362, 363, 364, 365, 368, 369, 372, 373, 376, + 377, 380, 381, 382, 385, 386, 389, 390, 391, 394, + 395, 396, 397, 398, 399, 402, 409, 416, 423, 430, + 437, 446, 449, 452, 455, 458, 471, 479, 487, 494, + 502, 509, 517, 518, 519, 520, 521, 524, 525, 526, + 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, + 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, + 547, 548, 549, 550, 551, 554, 555, 556, 557, 558, + 559, 560, 561, 562, 563, 566, 567, 568, 571, 572, + 573, 574, 575, 576, 577, 578, 579, 580, 583, 584, + 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, + 595, 596, 597, 598, 599, 600, 601, 602, 603, 606, + 607, 610, 615, 620, 625, 626, 631, 636, 641, 646, + 651, 652, 657, 662, 663, 667, 668, 677, 678, 679, + 682, 689, 696, 703, 710, 717, 724, 731, 738, 747, + 752, 757, 762, 769, 811, 812, 815, 816, 817, 822, + 823, 824, 825, 826, 828, 829, 830, 832, 833, 834, + 835, 836, 837, 838, 845, 846, 847, 848, 849, 852, + 859, 866, 873, 880, 887, 894, 901, 908, 917, 922, + 927, 932, 939, 939, 940, 943, 943, 945, 948, 948, + 950, 953, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1011, + 1012, 1015, 1023, 1023, 1030, 1037, 1046, 1056, 1064, 1072, + 1081, 1088, 1096, 1119, 1142, 1151, 1151, 1158, 1158, 1166, + 1174, 1182, 1189, 1189, 1197, 1204, 1211, 1218, 1225, 1232, + 1239, 1246, 1253, 1262, 1272, 1280, 1287, 1297, 1305, 1315, + 1325, 1337, 1345, 1355, 1367, 1377, 1386, 1408, 1432, 1457, + 1458, 1459, 1461, 1463, 1472, 1473, 1476, 1479, 1480, 1483, + 1490, 1491, 1494, 1501, 1502, 1505, 1509 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "INT", "REAL", "STRING", "COLOR", + "ANGDEGREE", "ANGRADIAN", "ARCMINUTE", "ARCSECOND", "PHYCOORD", + "IMGCOORD", "SEXSTR", "HMSSTR", "DMSSTR", "EOF_", "AMPLIFIER_", + "ANNULUS_", "ARCMIN_", "ARCSEC_", "ARROW_", "B1950_", "BACKGROUND_", + "BEGIN_", "BOX_", "BOXCIRCLE_", "BPANDA_", "CALLBACK_", "CIRCLE_", + "CIRCLE3D_", "COLOR_", "COMPASS_", "COMPOSITE_", "CPANDA_", "CROSS_", + "DASH_", "DASHLIST_", "DEBUG_", "DEGREES_", "DELETE_", "DETECTOR_", + "DIAMOND_", "ECLIPTIC_", "EDIT_", "ELLIPSE_", "END_", "EPANDA_", + "FALSE_", "FIELD_", "FIXED_", "FK4_", "FK4_NO_E_", "FK5_", "FONT_", + "GALACTIC_", "GLOBAL_", "HELIOECLIPTIC_", "HIGHLITE_", "ICRS_", + "IGNORE_", "IMAGE_", "INCLUDE_", "J2000_", "KEY_", "LINE_", "LINEAR_", + "MOVE_", "N_", "NO_", "OFF_", "ON_", "PHYSICAL_", "PIE_", "PIXELS_", + "POINT_", "POLYGON_", "PROJECTION_", "PROPERTY_", "ROTATE_", "ROTBOX_", + "RULER_", "SEGMENT_", "SELECT_", "SOURCE_", "SUPERGALACTIC_", "TAG_", + "TEXT_", "TEXTANGLE_", "TEXTROTATE_", "TILE_", "TRUE_", "VECTOR_", + "VERSION_", "UNHIGHLITE_", "UNSELECT_", "UPDATE_", "WCS_", "WCSA_", + "WCSB_", "WCSC_", "WCSD_", "WCSE_", "WCSF_", "WCSG_", "WCSH_", "WCSI_", + "WCSJ_", "WCSK_", "WCSL_", "WCSM_", "WCSN_", "WCSO_", "WCSP_", "WCSQ_", + "WCSR_", "WCSS_", "WCST_", "WCSU_", "WCSV_", "WCSW_", "WCSX_", "WCSY_", + "WCSZ_", "WCS0_", "WIDTH_", "X_", "Y_", "YES_", "'#'", "'\\n'", "';'", + "','", "'('", "')'", "'|'", "'='", "'+'", "'-'", "'&'", "'!'", "$accept", + "start", "commands", "command", "@1", "@2", "@3", "hash", "@4", + "comment", "@5", "shapeComment", "@6", "@7", "nonshapeComment", "@8", + "@9", "terminator", "numeric", "debug", "yesno", "sp", "bp", "ep", + "conjunction", "optangle", "angle", "value", "vvalue", "numberof", + "sexagesimal", "hms", "dms", "coord", "coordSystem", "wcsSystem", + "skyFrame", "skyDist", "property", "callBack", "global", + "globalProperty", "globalRuler", "globalCompass", "initGlobal", "local", + "localProperty", "localRuler", "localCompass", "localCpanda", "@10", + "localEpanda", "@11", "localBpanda", "@12", "initLocal", "pointShape", + "include", "nonshape", "@13", "shape", "@14", "@15", "@16", "polyNodes", + "polyNode", "aRads", "aRad", "aAngs", "aAng", "vRads", "vRad", + "postLocal", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, + 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + 375, 376, 377, 378, 379, 380, 381, 382, 383, 35, + 10, 59, 44, 40, 41, 124, 61, 43, 45, 38, + 33 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 141, 142, 143, 143, 144, 144, 144, 144, 144, + 145, 144, 146, 144, 147, 144, 144, 144, 144, 148, + 148, 148, 149, 148, 150, 151, 150, 152, 153, 152, + 152, 154, 152, 155, 156, 155, 155, 157, 155, 158, + 158, 158, 159, 159, 160, 160, 161, 161, 161, 161, + 161, 161, 161, 161, 161, 162, 162, 163, 163, 164, + 164, 165, 165, 165, 166, 166, 167, 167, 167, 168, + 168, 168, 168, 168, 168, 169, 169, 169, 169, 169, + 169, 170, 171, 172, 173, 174, 174, 174, 174, 174, + 174, 174, 175, 175, 175, 175, 175, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 178, 178, 178, 179, 179, + 179, 179, 179, 179, 179, 179, 179, 179, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 181, + 181, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 183, 183, 183, 183, 183, 183, 183, 183, 183, 184, + 184, 184, 184, 185, 186, 186, 187, 187, 187, 187, + 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, + 187, 187, 187, 187, 187, 187, 187, 187, 187, 188, + 188, 188, 188, 188, 188, 188, 188, 188, 189, 189, + 189, 189, 191, 190, 190, 193, 192, 192, 195, 194, + 194, 196, 197, 197, 197, 197, 197, 197, 197, 198, + 198, 199, 200, 199, 199, 199, 199, 199, 199, 199, + 201, 201, 201, 201, 201, 202, 201, 203, 201, 201, + 201, 201, 204, 201, 201, 201, 201, 201, 201, 201, + 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, + 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, + 201, 201, 201, 201, 205, 205, 206, 207, 207, 208, + 209, 209, 210, 211, 211, 212, 213 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 3, 3, 2, 0, 2, 1, 3, 2, + 0, 3, 0, 3, 0, 3, 2, 3, 3, 1, + 2, 2, 0, 2, 0, 0, 3, 1, 0, 4, + 3, 0, 5, 1, 0, 3, 2, 0, 4, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 2, 0, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, + 3, 3, 1, 1, 1, 3, 3, 3, 3, 3, + 3, 3, 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, 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, + 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, + 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, + 1, 3, 3, 4, 3, 3, 3, 1, 1, 1, + 3, 4, 4, 3, 3, 3, 7, 3, 3, 3, + 4, 2, 2, 2, 2, 2, 2, 1, 1, 2, + 1, 1, 1, 0, 3, 1, 3, 3, 4, 3, + 3, 3, 3, 5, 1, 1, 1, 3, 4, 4, + 3, 3, 3, 7, 3, 3, 3, 3, 3, 4, + 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, + 1, 1, 0, 7, 1, 0, 10, 1, 0, 10, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 10, 0, 7, 6, 8, 8, 10, 8, 8, + 8, 8, 10, 10, 10, 0, 7, 0, 7, 8, + 10, 6, 0, 9, 6, 7, 7, 7, 7, 7, + 7, 7, 8, 8, 10, 10, 12, 12, 12, 14, + 14, 18, 12, 14, 14, 18, 18, 20, 20, 10, + 12, 12, 5, 8, 3, 1, 1, 3, 1, 1, + 3, 1, 1, 3, 1, 3, 0 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint16 yydefact[] = +{ + 203, 0, 251, 1, 95, 126, 0, 94, 133, 125, + 127, 128, 131, 0, 134, 130, 92, 129, 14, 93, + 132, 0, 7, 97, 98, 99, 100, 101, 102, 103, + 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, + 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, + 124, 251, 0, 10, 96, 12, 0, 45, 44, 6, + 179, 0, 0, 0, 177, 0, 145, 142, 141, 0, + 139, 146, 0, 143, 0, 144, 0, 138, 178, 0, + 0, 0, 0, 0, 0, 0, 55, 170, 24, 9, + 0, 2, 41, 39, 40, 4, 24, 24, 57, 0, + 57, 0, 57, 57, 57, 57, 57, 57, 0, 0, + 57, 57, 57, 57, 57, 57, 275, 57, 57, 57, + 277, 57, 57, 0, 22, 259, 260, 0, 16, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 25, 56, 8, 0, 15, 3, + 11, 13, 58, 0, 57, 57, 0, 57, 0, 57, + 0, 0, 0, 0, 0, 57, 57, 0, 0, 59, + 0, 0, 0, 57, 0, 0, 0, 57, 0, 0, + 57, 57, 57, 57, 57, 57, 262, 57, 0, 57, + 18, 0, 0, 19, 17, 172, 202, 200, 201, 0, + 184, 0, 175, 0, 257, 253, 258, 252, 255, 254, + 256, 180, 136, 137, 135, 0, 198, 0, 0, 197, + 185, 176, 43, 42, 67, 68, 66, 187, 188, 183, + 189, 174, 46, 54, 52, 51, 53, 49, 50, 48, + 47, 171, 0, 169, 55, 55, 55, 82, 83, 84, + 55, 55, 55, 55, 55, 0, 0, 55, 0, 55, + 0, 55, 55, 55, 55, 55, 0, 0, 55, 55, + 60, 61, 55, 55, 59, 0, 55, 55, 55, 0, + 59, 55, 0, 0, 0, 0, 0, 0, 57, 0, + 21, 0, 23, 20, 199, 0, 173, 182, 181, 195, + 196, 191, 0, 192, 193, 194, 26, 0, 0, 0, + 0, 0, 0, 0, 0, 59, 59, 0, 59, 0, + 59, 0, 0, 0, 64, 0, 59, 59, 0, 0, + 62, 326, 0, 0, 61, 316, 55, 315, 0, 0, + 0, 55, 0, 61, 0, 59, 55, 55, 55, 55, + 55, 0, 59, 55, 0, 0, 89, 91, 90, 88, + 85, 86, 87, 72, 73, 74, 70, 71, 69, 55, + 61, 61, 55, 55, 55, 55, 55, 55, 55, 61, + 55, 61, 59, 59, 59, 59, 65, 55, 61, 61, + 55, 55, 63, 28, 312, 27, 59, 55, 326, 0, + 61, 55, 55, 59, 61, 59, 326, 55, 61, 0, + 0, 64, 0, 0, 59, 61, 0, 0, 190, 0, + 326, 326, 0, 0, 0, 0, 0, 0, 64, 326, + 0, 326, 61, 61, 61, 61, 0, 326, 326, 64, + 0, 216, 0, 0, 0, 0, 0, 0, 214, 0, + 0, 0, 0, 0, 0, 215, 0, 0, 0, 0, + 0, 0, 0, 0, 55, 205, 61, 0, 284, 314, + 326, 0, 64, 61, 326, 282, 281, 0, 326, 59, + 59, 59, 55, 59, 61, 326, 55, 186, 55, 290, + 286, 78, 79, 80, 76, 77, 75, 67, 66, 59, + 55, 291, 55, 285, 326, 326, 326, 326, 55, 288, + 287, 59, 55, 55, 248, 0, 0, 0, 0, 242, + 0, 245, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 326, 0, 0, 0, 30, 326, 55, 276, + 59, 59, 326, 278, 61, 59, 289, 61, 61, 61, + 0, 61, 326, 264, 0, 55, 33, 0, 0, 61, + 61, 64, 0, 270, 271, 293, 313, 0, 61, 64, + 0, 250, 228, 0, 0, 163, 161, 156, 0, 166, + 150, 167, 153, 165, 159, 148, 162, 151, 149, 168, + 164, 0, 207, 241, 239, 240, 0, 221, 244, 226, + 0, 0, 247, 227, 0, 210, 0, 217, 0, 237, + 0, 0, 236, 222, 212, 211, 224, 225, 220, 209, + 29, 206, 326, 204, 279, 0, 61, 61, 61, 292, + 326, 61, 326, 326, 326, 59, 326, 263, 326, 0, + 36, 59, 0, 319, 59, 55, 318, 326, 0, 326, + 72, 69, 59, 55, 55, 55, 324, 55, 55, 0, + 326, 59, 55, 55, 55, 0, 155, 152, 158, 157, + 154, 160, 0, 238, 0, 0, 208, 0, 219, 218, + 234, 235, 230, 0, 231, 232, 233, 32, 322, 59, + 59, 321, 326, 326, 326, 283, 326, 268, 266, 269, + 61, 265, 35, 326, 61, 0, 61, 0, 61, 295, + 0, 273, 61, 0, 64, 64, 0, 0, 0, 272, + 61, 64, 64, 0, 55, 213, 0, 55, 55, 0, + 61, 0, 61, 309, 294, 274, 280, 326, 38, 326, + 81, 326, 317, 326, 57, 326, 325, 59, 59, 323, + 55, 55, 57, 326, 59, 59, 55, 0, 0, 0, + 0, 229, 326, 320, 326, 267, 261, 297, 296, 0, + 302, 61, 61, 0, 0, 0, 298, 61, 61, 0, + 0, 223, 0, 0, 311, 310, 55, 326, 326, 55, + 55, 55, 326, 326, 55, 55, 55, 55, 0, 304, + 303, 0, 0, 0, 299, 300, 0, 0, 0, 243, + 0, 55, 55, 59, 55, 55, 0, 0, 64, 64, + 61, 64, 64, 0, 0, 59, 59, 326, 59, 59, + 249, 246, 305, 61, 306, 301, 61, 326, 326, 308, + 307 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 1, 51, 52, 96, 97, 88, 190, 191, 146, + 242, 394, 462, 534, 553, 554, 639, 95, 250, 59, + 241, 731, 153, 271, 331, 385, 386, 653, 378, 644, + 251, 252, 253, 335, 53, 54, 55, 219, 463, 591, + 86, 87, 220, 199, 2, 555, 465, 613, 596, 599, + 600, 603, 604, 572, 573, 56, 211, 127, 193, 288, + 128, 173, 177, 544, 336, 337, 645, 646, 690, 691, + 655, 656, 395 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -679 +static const yytype_int16 yypact[] = +{ + -679, 40, 1717, -679, -679, -679, 99, -679, -679, -679, + -679, -679, -679, 2582, -679, -679, -679, -679, -679, -679, + -679, 51, -679, -679, -679, -679, -679, -679, -679, -679, + -679, -679, -679, -679, -679, -679, -679, -679, -679, -679, + -679, -679, -679, -679, -679, -679, -679, -679, -679, -679, + -679, 1475, 54, -679, -679, -679, 1667, -679, -679, -679, + -679, -93, -77, -74, -36, -27, -679, -679, -679, -8, + -679, -679, 5, -679, 26, -679, 45, -679, 52, 57, + 68, 75, 86, 103, 115, 129, 127, -679, 4, -679, + 54, -679, -679, -679, -679, -679, 4, 4, 109, 179, + -44, 194, 109, -37, 109, 109, 109, 109, 196, 197, + 109, 109, 109, 109, 109, 109, -679, 109, 109, 109, + -679, 109, 109, 198, 267, -679, -679, 1250, -679, 265, + 2156, 274, 275, 276, 279, 277, 1832, 280, 224, 281, + 290, 2611, 292, 23, -679, -679, -679, 2582, -679, -679, + -679, -679, -679, 603, 109, 109, 603, 109, 603, 109, + 603, 603, 603, 603, 603, 109, 109, 603, 603, 162, + 603, 603, 603, 109, 603, 603, 603, 109, 603, 603, + 109, 109, 109, 109, 109, 109, -679, 109, 304, 109, + -679, 303, 517, -679, -679, -679, -679, 485, -679, 305, + -679, 306, -679, 310, -679, -679, -679, -679, -679, -679, + -679, 311, -679, -679, -679, 2372, -679, 2048, 2372, -679, + -679, -679, -679, -679, -679, -679, -679, -679, -679, -679, + -679, -679, -679, -679, -679, -679, -679, -679, -679, -679, + -679, -679, 312, -679, 186, 186, 186, -679, -679, -679, + 186, 186, 186, 186, 186, 603, 603, 186, 603, 186, + 603, 186, 186, 186, 186, 186, 603, 603, 186, 186, + -679, 185, 186, 186, 162, 603, 186, 186, 186, 603, + 22, 186, 603, 603, 603, 603, 603, 603, 109, 603, + -679, 603, -679, -679, -679, 317, -679, -679, -679, -679, + -679, -679, 2480, -679, -679, -679, -679, 316, 313, 315, + 195, 318, 314, 314, 551, 162, 162, 618, 162, 224, + 162, 551, 551, 551, 224, 224, 162, 162, 618, 224, + 190, 201, 603, 224, 185, -679, 106, -679, 603, 618, + 603, 106, 328, 185, 551, 162, 186, 186, 186, 186, + 186, 603, 162, 186, 331, 56, -679, -679, -679, -679, + -679, -679, -679, -679, -679, -679, -679, -679, -679, 186, + 185, 185, 186, 186, 186, 186, 186, 186, 186, 185, + 186, 185, 162, 162, 162, 162, -679, 186, 185, 185, + 186, 186, -679, 2482, -679, -679, 162, 186, 201, 603, + 185, 186, 186, 162, 185, 162, 201, 186, 185, 551, + 551, 224, 603, 603, 112, 185, 551, 332, -679, 551, + 201, 201, 330, 329, 333, 334, 327, 195, 357, 201, + 224, 201, 185, 185, 185, 185, 224, 201, 201, 357, + 224, -679, 205, 206, 210, 211, 214, 215, -36, 216, + 217, 222, 234, 237, 238, 52, 239, 241, 244, 246, + 252, 253, 387, 257, 82, -679, 185, 224, -679, -679, + 201, 551, 224, 185, 201, -679, -679, 224, 201, 162, + 162, 162, 186, 162, 185, 1595, 186, -679, 106, -679, + -679, -679, -679, -679, -679, -679, -679, 10, 31, 162, + 186, -679, 186, -679, 201, 201, 201, 201, 186, -679, + -679, 162, 186, 186, 337, 1338, 389, 2264, 395, 339, + 404, 348, 405, 406, 277, 1940, 408, 413, 224, 416, + 418, 420, -679, 23, 419, 2482, -679, 201, 106, -679, + 162, 162, 201, -679, 185, 162, -679, 185, 185, 185, + 551, 185, 1595, -679, 424, 94, -679, 224, 38, 185, + -67, 128, 427, -679, -679, -679, -679, 428, 13, 128, + 429, -679, -679, 300, 130, -679, -679, -679, 136, -679, + -679, -679, -679, -679, -679, -679, -679, -679, -679, -679, + -679, 430, -679, -679, 485, -679, 433, -679, -679, -679, + 307, 436, -679, -679, 309, -679, 441, 442, 2372, -679, + 2048, 2372, -679, -679, -679, -679, -679, -679, -679, -679, + -679, -679, -679, -679, -679, 104, 185, 185, 185, -679, + 201, 185, 1595, 1595, 1595, 162, 1595, -679, -679, 443, + -679, 162, 319, -679, 162, 106, -679, 201, 321, 201, + 118, 145, 162, 186, 186, 186, -679, 186, 186, 324, + 201, 162, 186, 186, 186, 224, -679, -679, -679, -679, + -679, -679, 444, -679, 445, 224, -679, 224, -679, -679, + -679, -679, -679, 2480, -679, -679, -679, -679, -679, 162, + 21, -679, 201, 201, 201, -679, 201, -679, -679, -679, + 185, -679, -679, -679, 185, 448, 185, 551, 185, -679, + 421, -679, 185, 551, 224, 515, 618, 551, 422, -679, + 185, 224, 515, 618, -81, -679, 450, -55, 15, 56, + 185, 224, 185, -679, -679, -679, -679, 1595, -679, 1595, + -679, 201, -679, 201, 109, 201, -679, 162, 162, -679, + 186, 186, 109, 201, 162, 162, 186, 325, 462, 335, + 342, -679, 201, -679, 201, -679, -679, -679, -679, 603, + -679, 185, 185, 618, 551, 603, -679, 185, 185, 618, + 551, -679, 551, 551, -679, -679, 186, 201, 201, 186, + 186, 186, 201, 201, 186, 84, 111, 134, 618, -679, + -679, 463, 467, 618, -679, -679, 473, 344, 551, -679, + 346, 186, 186, 162, 186, 186, 224, 224, 224, 224, + 185, 224, 224, 351, 352, 162, 162, 201, 162, 162, + -679, -679, -679, 185, -679, -679, 185, 201, 201, -679, + -679 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -679, -679, -679, 431, -679, -679, -679, -679, -679, 133, + -679, 719, -679, -679, -531, -679, -679, 390, 62, -679, + -46, -86, -99, 546, 616, -359, 7, 345, -282, -496, + 177, -679, -79, 634, -97, 354, -100, -154, -3, -679, + -679, 349, -679, -679, -679, 100, -35, -679, -679, -679, + -679, -679, -679, -679, -679, -679, -25, 380, 320, -679, + 378, -679, -679, -679, -247, 110, -274, -192, -458, -214, + -560, -678, -49 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -327 +static const yytype_int16 yytable[] = +{ + 147, 156, 91, 158, 160, 161, 162, 163, 164, 663, + 85, 167, 168, 169, 170, 171, 172, -55, 174, 175, + 176, 637, 178, 179, -55, -55, 232, -55, -55, -55, + 198, 155, 341, 197, -55, -55, 218, 749, 159, 217, + 3, 222, 223, 129, 749, 363, 390, 364, 365, 366, + 367, 145, 481, 757, 89, 255, 256, 402, 258, 130, + 260, 300, 131, 303, 305, 654, 266, 267, 330, 499, + 92, 233, 648, 662, 275, 212, 213, 145, 279, 759, + 511, 282, 283, 284, 285, 286, 287, -31, 289, 152, + 291, 234, 235, 236, 237, 214, 152, 294, -326, -37, + -140, 697, 698, 699, 414, 701, 642, 222, 223, 132, + -326, 224, 225, 541, 238, -55, -55, 302, 299, -55, + 301, 304, -59, -55, -55, -55, -55, -55, 133, 689, + 749, 222, 223, 144, -67, 650, 225, 364, 365, 366, + 367, 134, 145, -24, 85, 227, 500, 145, 330, 760, + 239, 240, 659, 145, 145, 270, 270, 512, 307, 308, + 309, -66, 135, 145, 310, 311, 312, 313, 314, 57, + 58, 317, 642, 319, 666, 321, 322, 323, 324, 325, + 669, 136, 328, 329, 93, 94, 332, 333, -147, 351, + 338, 339, 340, 137, 342, 344, 642, 667, 222, 223, + 226, 418, 652, 670, 138, 355, 765, 724, 766, 668, + 661, 139, -326, -326, 145, 671, 145, 727, 807, 728, + 795, 148, 140, 797, -326, -326, 145, 222, 223, 150, + 151, 224, 225, 361, 362, -59, -59, -59, 145, 141, + 270, -59, 152, 145, 145, 809, 270, -67, -67, -67, + 399, 142, -67, -67, 154, 399, 144, -24, -24, 145, + 409, 410, 411, 412, 413, 143, 145, 416, 810, 157, + 195, 165, 166, 180, -66, -66, -66, 200, 201, -66, + -66, 202, 203, 419, 228, 221, 422, 423, 424, 425, + 426, 427, 428, 229, 430, 231, 270, 181, 204, 182, + 183, 436, 205, 206, 439, 440, 207, 290, 292, 296, + 295, 467, 208, 297, 298, 471, 472, 306, 145, 209, + 330, 477, 354, 356, 357, 392, 380, 358, 399, 249, + 393, 247, 387, 405, 417, 487, 391, 491, 492, 495, + 397, 514, 515, 493, 184, 494, 516, 517, 185, 186, + 518, 519, 520, 521, 187, 747, 748, 188, 522, 189, + 222, 223, 754, 755, 497, 225, 373, 374, 375, 376, + 523, 612, 359, 524, 525, 526, 368, 527, 535, 377, + 528, 226, 529, 368, 368, 368, 226, 226, 530, 531, + 377, 226, 532, 533, 592, 226, 550, 571, 597, 598, + 557, 377, 558, 210, 125, 126, 368, 601, 602, 606, + 605, 422, 427, 614, 561, 536, 562, 595, 615, 617, + 594, 618, 567, 619, 622, 611, 569, 570, 610, 638, + 657, 658, 664, 665, 750, 672, 556, 502, 674, 676, + 675, 756, 677, 508, 678, 679, 744, 513, 703, 725, + 726, 740, 625, 758, 681, 705, 684, 686, 780, 825, + 826, 710, 828, 829, 718, 781, 812, 752, 782, 535, + 813, 368, 368, 226, 538, 783, 815, 816, 368, 817, + 149, 368, 90, 620, 545, 830, 831, 621, 360, 496, + 498, 789, 226, 464, 673, 230, 243, 794, 226, 607, + 623, 498, 226, 556, 192, 194, 640, 5, 796, 469, + 683, 680, 293, 682, 685, 742, 811, 763, 222, 223, + 0, 814, 650, 225, 364, 365, 366, 367, 8, 226, + 0, 0, 0, 368, 226, 616, 9, 10, 11, 226, + 12, 0, 14, 0, 15, 0, 0, 181, 17, 182, + 183, 0, 0, 0, 222, 223, 0, 0, 363, 707, + 364, 365, 366, 367, 641, 0, 0, 713, 714, 715, + 20, 716, 717, 687, 0, 761, 721, 722, 723, 0, + 0, 0, 0, 556, 556, 556, 729, 556, 0, 702, + 226, 0, 0, 0, 184, 0, 0, 0, 185, 186, + 0, 0, 0, 0, 187, 0, 222, 223, 0, 189, + 244, 0, 368, 0, 245, 246, 247, 248, 249, 226, + 368, 222, 223, 651, 0, 372, 0, 373, 374, 375, + 376, 651, 688, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 769, 0, 0, 0, 0, + 0, 0, 0, 775, 738, 0, 0, 0, 0, 369, + 0, 0, 0, 0, 773, 774, 382, 383, 384, 0, + 779, 0, 688, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 688, 0, 688, 0, 0, 226, 556, 407, + 556, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 798, 0, 0, 801, 802, 803, 0, 0, 806, 808, + 707, 808, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 818, 819, 226, 821, 822, + 0, 0, 0, 0, 0, 0, 0, 226, 688, 226, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 479, 480, 0, 0, 0, 0, + 0, 486, 0, 0, 488, 0, 0, 0, 0, 368, + 0, 0, 0, 0, 0, 368, 226, 651, 377, 368, + 0, 0, 0, 226, 651, 377, 0, 254, 0, 0, + 257, 0, 259, 226, 261, 262, 263, 264, 265, 0, + 0, 268, 269, 0, 272, 273, 274, 0, 276, 277, + 278, 0, 280, 281, 0, 0, 540, 0, 0, 0, + 334, 0, 0, 823, 824, 0, 343, 0, 0, 0, + 0, 0, 0, 0, 0, 377, 368, 0, 0, 0, + 0, 377, 368, 0, 368, 368, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 377, 370, 371, 0, 379, 377, 381, 0, 0, 0, + 368, 0, 388, 389, 0, 0, 0, 0, 226, 226, + 226, 226, 400, 226, 226, 0, 0, 404, 0, 315, + 316, 408, 318, 0, 320, 635, 0, 0, 415, 0, + 326, 327, 0, 643, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 345, 346, 347, 348, + 349, 350, 0, 352, 0, 353, 0, 0, 432, 433, + 434, 435, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 466, 0, 0, 0, 0, 0, 0, 473, + 398, 475, 0, 0, 0, 0, 0, 0, 0, 406, + 484, 0, 0, 0, 0, 0, 396, 0, 0, 0, + 0, 0, 401, 0, 403, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 420, 421, 0, 0, + 0, 0, 0, 0, 0, 429, 0, 431, 0, 0, + 0, 0, 0, 0, 437, 438, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 470, 0, 0, 0, + 474, 0, 0, 0, 478, 547, 548, 549, 0, 551, + 0, 485, 0, 0, 559, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 560, 482, 483, 504, 505, + 506, 507, 643, 0, 0, 0, 0, 568, 746, 0, + 0, 0, 751, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 537, 0, 626, 0, 627, 628, 0, 542, + 0, 631, 0, 0, 0, 0, 0, 0, 0, 0, + 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 468, 0, 790, + 0, 0, 0, 0, 0, 476, 0, 643, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 489, + 490, 0, 0, 0, 0, 0, 0, 0, 501, 0, + 503, 0, 0, 0, 0, 0, 509, 510, 0, 0, + 630, 0, 0, 632, 633, 634, 0, 636, 0, 0, + 0, 0, 0, 0, 0, 647, 649, 0, 0, 0, + 0, 700, 0, 0, 660, 0, 0, 704, 0, 539, + 706, 708, 0, 543, 0, 0, 0, 546, 712, 0, + 0, 0, 0, 0, 0, 0, 0, 720, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 563, 564, 565, 566, 0, 0, 0, + 0, 0, 0, 0, 0, 730, 732, 0, 0, 0, + 0, 0, 692, 693, 694, 0, 0, 696, 0, 0, + 0, 0, 0, 0, 0, 0, 624, 0, 0, 0, + 0, 629, 0, 0, 0, 0, 0, 0, 98, 0, + 0, 99, 0, 0, 0, 100, 101, 102, 0, 103, + 104, 0, 105, 106, 107, 108, 0, 0, 0, 0, + 0, 0, 109, 771, 772, 110, 0, 111, 0, 112, + 777, 778, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 113, 737, 0, 0, 0, + 739, 0, 741, 114, 743, 115, 116, 117, 745, 0, + 118, 119, 120, 0, 0, 0, 753, 121, 0, 0, + 0, 0, 122, 0, 0, 0, 762, 0, 764, 695, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 820, + 0, 0, 574, 0, 0, 0, 709, 0, 711, 575, + 0, 832, 833, 0, 835, 836, 123, 0, 576, 719, + 0, 0, 577, 0, 578, 0, 0, 787, 788, 0, + 0, 0, 579, 792, 793, 0, 580, 0, 0, 0, + 0, 0, 581, 786, 0, 582, 0, 0, 0, 791, + 0, 733, 734, 735, 0, 736, 583, 584, 0, 0, + 0, 585, 0, 0, 0, 586, 0, 0, 0, 0, + 0, 0, 587, 588, 589, 0, 827, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 837, + 0, 0, 838, 0, 0, 0, 0, 0, 0, 0, + 767, 0, 768, 590, 770, 0, 0, 0, 0, 0, + 0, 0, 776, 0, 0, -326, 0, 0, 0, 0, + 0, 784, 0, 785, 0, 0, 0, 0, 0, 0, + 0, -5, 4, 0, 0, 0, 0, 5, 0, 0, + 0, 0, 0, 0, 0, 0, 799, 800, 0, 0, + 0, 804, 805, 6, 0, 0, 7, 0, 8, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 12, 13, 14, 0, 15, 0, 16, 0, 17, 0, + 0, 18, 0, 0, 0, 0, 834, 19, 0, 0, + 0, 0, 0, 0, 0, 0, 839, 840, 0, 0, + 20, 0, 0, 0, 0, 21, 0, 0, 22, 0, + 0, 0, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + -34, 0, 0, 0, 0, -5, -5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 441, 0, + 0, 0, 442, 443, 0, 0, 444, 445, 446, 447, + 0, 448, 449, 0, 0, 66, 0, 0, 0, 67, + 0, 0, 450, 0, 0, 68, 0, 0, 0, 451, + 0, 0, 0, 70, 0, 0, 0, 71, 0, 0, + 452, 0, 73, 0, 0, 0, 0, 0, 0, 0, + 453, 0, 0, 0, 75, 0, 454, 0, 77, 455, + 0, 456, 457, 458, 459, 98, 0, 460, 99, 0, + 0, 0, 100, 101, 102, 0, 103, 104, 0, 105, + 106, 107, 108, 0, 0, 0, 0, 0, 0, 109, + 0, 0, 110, 0, 111, 0, 112, 0, 0, 0, + 461, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 113, -5, 4, 0, 0, 0, 0, 5, + 114, 0, 115, 116, 117, 0, 0, 118, 119, 120, + 0, 0, 0, 0, 121, 6, 0, 0, 7, 122, + 8, 0, 0, 0, 0, 0, 0, 0, 9, 10, + 11, 0, 12, 13, 14, 0, 15, 0, 16, 0, + 17, 0, 0, 18, 0, 0, 0, 0, 0, 19, + 0, 0, 0, 123, 0, 0, 124, 0, 0, 0, + 0, 0, 20, 0, 125, 126, 0, 21, 0, 0, + 22, 0, 0, 0, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 0, 0, 0, 0, 0, -5, -5, 4, + 0, 212, 213, 0, 5, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 214, 0, 7, 0, 8, 0, 0, 0, 0, + 0, 0, 0, 9, 10, 11, 0, 12, 0, 14, + 0, 15, 0, 16, 0, 17, 0, 0, 215, 0, + 0, 0, 0, 0, 19, 0, 216, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 4, 0, 212, + 213, 0, 5, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 214, + 0, 7, 0, 8, 0, 0, 0, 0, 0, 0, + 0, 9, 10, 11, 0, 12, 0, 14, 0, 15, + 0, 16, 0, 17, 0, 0, 608, 0, 0, 0, + 0, 0, 19, 0, 609, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 4, 0, 212, 213, 0, + 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 214, 0, 7, + 0, 8, 0, 0, 0, 0, 0, 0, 0, 9, + 10, 11, 0, 12, 0, 14, 0, 15, 0, 16, + 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, + 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 4, 0, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 7, 0, 8, + 0, 0, 0, 0, 0, 0, 0, 9, 10, 11, + 0, 12, 0, 14, 0, 15, 0, 16, 0, 17, + 0, 0, 196, 0, 0, 0, 0, 0, 19, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 4, 0, 0, 0, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 7, 0, 8, 0, 0, + 0, 0, 0, 0, 0, 9, 10, 11, 0, 12, + 0, 14, 0, 15, 0, 16, 0, 17, 0, 0, + 593, 0, 0, 0, 0, 0, 19, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 4, + 0, 212, 213, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 214, 0, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 4, 0, 0, + 0, 0, 0, 0, 0, 441, 0, 0, 0, 442, + 443, 0, 0, 444, 445, 446, 447, 0, 448, 449, + 0, 7, 66, 0, 0, 0, 67, 0, 0, 450, + 0, 0, 68, 0, 0, 0, 451, 0, 0, 0, + 70, 16, 0, 0, 71, 0, 0, 452, 0, 73, + 0, 0, 19, 0, 0, 0, 0, 453, 0, 0, + 0, 75, 0, 454, 0, 77, 455, 0, 456, 457, + 458, 459, 0, 0, 460, 0, 0, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 60, 0, 461, 0, 0, + 0, 0, 0, 61, 62, 63, 0, 0, 64, 65, + 0, 0, 66, 0, 0, 0, 67, 0, 0, 0, + 0, 0, 68, 0, 0, 0, 69, 0, 0, 0, + 70, 0, 0, 0, 71, 0, 0, 72, 0, 73, + 0, 0, 0, 0, 0, 0, 0, 74, 0, 0, + 0, 75, 0, 76, 0, 77, 78, 0, 0, 79, + 80, 81, 0, 0, 82, 0, 0, 0, 0, 83, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 84, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50 +}; + +static const yytype_int16 yycheck[] = +{ + 86, 100, 51, 102, 103, 104, 105, 106, 107, 569, + 13, 110, 111, 112, 113, 114, 115, 7, 117, 118, + 119, 552, 121, 122, 3, 4, 3, 5, 7, 8, + 130, 75, 279, 130, 3, 4, 136, 715, 75, 136, + 0, 3, 4, 136, 722, 7, 328, 9, 10, 11, + 12, 132, 411, 134, 3, 154, 155, 339, 157, 136, + 159, 215, 136, 217, 218, 561, 165, 166, 135, 428, + 16, 48, 139, 569, 173, 19, 20, 132, 177, 134, + 439, 180, 181, 182, 183, 184, 185, 5, 187, 133, + 189, 68, 69, 70, 71, 39, 133, 197, 16, 5, + 136, 632, 633, 634, 351, 636, 68, 3, 4, 136, + 16, 7, 8, 472, 91, 3, 4, 217, 215, 7, + 217, 218, 16, 11, 12, 13, 14, 15, 136, 625, + 808, 3, 4, 129, 16, 7, 8, 9, 10, 11, + 12, 136, 132, 16, 147, 138, 428, 132, 135, 134, + 127, 128, 139, 132, 132, 134, 134, 439, 244, 245, + 246, 16, 136, 132, 250, 251, 252, 253, 254, 70, + 71, 257, 68, 259, 44, 261, 262, 263, 264, 265, + 44, 136, 268, 269, 130, 131, 272, 273, 136, 288, + 276, 277, 278, 136, 280, 281, 68, 67, 3, 4, + 138, 355, 561, 67, 136, 302, 737, 665, 739, 79, + 569, 136, 130, 131, 132, 79, 132, 675, 134, 677, + 780, 88, 136, 783, 130, 131, 132, 3, 4, 96, + 97, 7, 8, 312, 313, 129, 130, 131, 132, 136, + 134, 135, 133, 132, 132, 134, 134, 129, 130, 131, + 336, 136, 134, 135, 75, 341, 129, 130, 131, 132, + 346, 347, 348, 349, 350, 136, 132, 353, 134, 75, + 5, 75, 75, 75, 129, 130, 131, 3, 3, 134, + 135, 5, 3, 369, 3, 5, 372, 373, 374, 375, + 376, 377, 378, 3, 380, 3, 134, 30, 21, 32, + 33, 387, 25, 26, 390, 391, 29, 3, 5, 3, + 5, 397, 35, 3, 3, 401, 402, 5, 132, 42, + 135, 407, 5, 7, 11, 135, 319, 12, 414, 15, + 129, 13, 325, 5, 3, 3, 329, 7, 9, 12, + 333, 136, 136, 10, 77, 11, 136, 136, 81, 82, + 136, 136, 136, 136, 87, 714, 715, 90, 136, 92, + 3, 4, 721, 722, 7, 8, 9, 10, 11, 12, + 136, 525, 310, 136, 136, 136, 314, 136, 464, 317, + 136, 319, 136, 321, 322, 323, 324, 325, 136, 136, + 328, 329, 5, 136, 5, 333, 482, 60, 3, 60, + 486, 339, 488, 126, 137, 138, 344, 3, 60, 3, + 5, 497, 498, 5, 500, 464, 502, 517, 5, 3, + 517, 3, 508, 3, 5, 525, 512, 513, 525, 5, + 3, 3, 3, 133, 716, 5, 485, 430, 5, 3, + 133, 723, 133, 436, 3, 3, 25, 440, 5, 5, + 5, 3, 538, 3, 608, 136, 610, 611, 133, 818, + 819, 140, 821, 822, 140, 3, 3, 45, 133, 555, + 3, 409, 410, 411, 467, 133, 3, 133, 416, 133, + 90, 419, 51, 532, 477, 134, 134, 533, 311, 427, + 428, 773, 430, 393, 594, 141, 147, 779, 436, 524, + 535, 439, 440, 552, 124, 127, 555, 22, 782, 399, + 610, 608, 192, 610, 611, 707, 798, 731, 3, 4, + -1, 803, 7, 8, 9, 10, 11, 12, 43, 467, + -1, -1, -1, 471, 472, 528, 51, 52, 53, 477, + 55, -1, 57, -1, 59, -1, -1, 30, 63, 32, + 33, -1, -1, -1, 3, 4, -1, -1, 7, 645, + 9, 10, 11, 12, 557, -1, -1, 653, 654, 655, + 85, 657, 658, 622, -1, 729, 662, 663, 664, -1, + -1, -1, -1, 632, 633, 634, 683, 636, -1, 638, + 528, -1, -1, -1, 77, -1, -1, -1, 81, 82, + -1, -1, -1, -1, 87, -1, 3, 4, -1, 92, + 7, -1, 550, -1, 11, 12, 13, 14, 15, 557, + 558, 3, 4, 561, -1, 7, -1, 9, 10, 11, + 12, 569, 625, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 744, -1, -1, -1, -1, + -1, -1, -1, 752, 703, -1, -1, -1, -1, 314, + -1, -1, -1, -1, 750, 751, 321, 322, 323, -1, + 756, -1, 665, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 675, -1, 677, -1, -1, 625, 737, 344, + 739, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 786, -1, -1, 789, 790, 791, -1, -1, 794, 795, + 796, 797, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 811, 812, 665, 814, 815, + -1, -1, -1, -1, -1, -1, -1, 675, 731, 677, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 409, 410, -1, -1, -1, -1, + -1, 416, -1, -1, 419, -1, -1, -1, -1, 707, + -1, -1, -1, -1, -1, 713, 714, 715, 716, 717, + -1, -1, -1, 721, 722, 723, -1, 153, -1, -1, + 156, -1, 158, 731, 160, 161, 162, 163, 164, -1, + -1, 167, 168, -1, 170, 171, 172, -1, 174, 175, + 176, -1, 178, 179, -1, -1, 471, -1, -1, -1, + 274, -1, -1, 816, 817, -1, 280, -1, -1, -1, + -1, -1, -1, -1, -1, 773, 774, -1, -1, -1, + -1, 779, 780, -1, 782, 783, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 798, 315, 316, -1, 318, 803, 320, -1, -1, -1, + 808, -1, 326, 327, -1, -1, -1, -1, 816, 817, + 818, 819, 336, 821, 822, -1, -1, 341, -1, 255, + 256, 345, 258, -1, 260, 550, -1, -1, 352, -1, + 266, 267, -1, 558, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 282, 283, 284, 285, + 286, 287, -1, 289, -1, 291, -1, -1, 382, 383, + 384, 385, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 396, -1, -1, -1, -1, -1, -1, 403, + 334, 405, -1, -1, -1, -1, -1, -1, -1, 343, + 414, -1, -1, -1, -1, -1, 332, -1, -1, -1, + -1, -1, 338, -1, 340, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 370, 371, -1, -1, + -1, -1, -1, -1, -1, 379, -1, 381, -1, -1, + -1, -1, -1, -1, 388, 389, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 400, -1, -1, -1, + 404, -1, -1, -1, 408, 479, 480, 481, -1, 483, + -1, 415, -1, -1, 488, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 499, 412, 413, 432, 433, + 434, 435, 707, -1, -1, -1, -1, 511, 713, -1, + -1, -1, 717, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 466, -1, 538, -1, 540, 541, -1, 473, + -1, 545, -1, -1, -1, -1, -1, -1, -1, -1, + 484, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 398, -1, 774, + -1, -1, -1, -1, -1, 406, -1, 782, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 420, + 421, -1, -1, -1, -1, -1, -1, -1, 429, -1, + 431, -1, -1, -1, -1, -1, 437, 438, -1, -1, + 544, -1, -1, 547, 548, 549, -1, 551, -1, -1, + -1, -1, -1, -1, -1, 559, 560, -1, -1, -1, + -1, 635, -1, -1, 568, -1, -1, 641, -1, 470, + 644, 645, -1, 474, -1, -1, -1, 478, 652, -1, + -1, -1, -1, -1, -1, -1, -1, 661, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 504, 505, 506, 507, -1, -1, -1, + -1, -1, -1, -1, -1, 689, 690, -1, -1, -1, + -1, -1, 626, 627, 628, -1, -1, 631, -1, -1, + -1, -1, -1, -1, -1, -1, 537, -1, -1, -1, + -1, 542, -1, -1, -1, -1, -1, -1, 18, -1, + -1, 21, -1, -1, -1, 25, 26, 27, -1, 29, + 30, -1, 32, 33, 34, 35, -1, -1, -1, -1, + -1, -1, 42, 747, 748, 45, -1, 47, -1, 49, + 754, 755, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 65, 700, -1, -1, -1, + 704, -1, 706, 73, 708, 75, 76, 77, 712, -1, + 80, 81, 82, -1, -1, -1, 720, 87, -1, -1, + -1, -1, 92, -1, -1, -1, 730, -1, 732, 630, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 813, + -1, -1, 24, -1, -1, -1, 647, -1, 649, 31, + -1, 825, 826, -1, 828, 829, 126, -1, 40, 660, + -1, -1, 44, -1, 46, -1, -1, 771, 772, -1, + -1, -1, 54, 777, 778, -1, 58, -1, -1, -1, + -1, -1, 64, 769, -1, 67, -1, -1, -1, 775, + -1, 692, 693, 694, -1, 696, 78, 79, -1, -1, + -1, 83, -1, -1, -1, 87, -1, -1, -1, -1, + -1, -1, 94, 95, 96, -1, 820, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 833, + -1, -1, 836, -1, -1, -1, -1, -1, -1, -1, + 741, -1, 743, 125, 745, -1, -1, -1, -1, -1, + -1, -1, 753, -1, -1, 0, -1, -1, -1, -1, + -1, 762, -1, 764, -1, -1, -1, -1, -1, -1, + -1, 16, 17, -1, -1, -1, -1, 22, -1, -1, + -1, -1, -1, -1, -1, -1, 787, 788, -1, -1, + -1, 792, 793, 38, -1, -1, 41, -1, 43, -1, + -1, -1, -1, -1, -1, -1, 51, 52, 53, -1, + 55, 56, 57, -1, 59, -1, 61, -1, 63, -1, + -1, 66, -1, -1, -1, -1, 827, 72, -1, -1, + -1, -1, -1, -1, -1, -1, 837, 838, -1, -1, + 85, -1, -1, -1, -1, 90, -1, -1, 93, -1, + -1, -1, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 5, -1, -1, -1, -1, 130, 131, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 23, -1, + -1, -1, 27, 28, -1, -1, 31, 32, 33, 34, + -1, 36, 37, -1, -1, 40, -1, -1, -1, 44, + -1, -1, 47, -1, -1, 50, -1, -1, -1, 54, + -1, -1, -1, 58, -1, -1, -1, 62, -1, -1, + 65, -1, 67, -1, -1, -1, -1, -1, -1, -1, + 75, -1, -1, -1, 79, -1, 81, -1, 83, 84, + -1, 86, 87, 88, 89, 18, -1, 92, 21, -1, + -1, -1, 25, 26, 27, -1, 29, 30, -1, 32, + 33, 34, 35, -1, -1, -1, -1, -1, -1, 42, + -1, -1, 45, -1, 47, -1, 49, -1, -1, -1, + 125, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 65, 16, 17, -1, -1, -1, -1, 22, + 73, -1, 75, 76, 77, -1, -1, 80, 81, 82, + -1, -1, -1, -1, 87, 38, -1, -1, 41, 92, + 43, -1, -1, -1, -1, -1, -1, -1, 51, 52, + 53, -1, 55, 56, 57, -1, 59, -1, 61, -1, + 63, -1, -1, 66, -1, -1, -1, -1, -1, 72, + -1, -1, -1, 126, -1, -1, 129, -1, -1, -1, + -1, -1, 85, -1, 137, 138, -1, 90, -1, -1, + 93, -1, -1, -1, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 123, 124, -1, -1, -1, -1, -1, 130, 131, 17, + -1, 19, 20, -1, 22, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 39, -1, 41, -1, 43, -1, -1, -1, -1, + -1, -1, -1, 51, 52, 53, -1, 55, -1, 57, + -1, 59, -1, 61, -1, 63, -1, -1, 66, -1, + -1, -1, -1, -1, 72, -1, 74, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 85, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 97, + 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, + 118, 119, 120, 121, 122, 123, 124, 17, -1, 19, + 20, -1, 22, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 39, + -1, 41, -1, 43, -1, -1, -1, -1, -1, -1, + -1, 51, 52, 53, -1, 55, -1, 57, -1, 59, + -1, 61, -1, 63, -1, -1, 66, -1, -1, -1, + -1, -1, 72, -1, 74, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 97, 98, 99, + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 17, -1, 19, 20, -1, + 22, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 39, -1, 41, + -1, 43, -1, -1, -1, -1, -1, -1, -1, 51, + 52, 53, -1, 55, -1, 57, -1, 59, -1, 61, + -1, 63, -1, -1, -1, -1, -1, -1, -1, -1, + 72, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 97, 98, 99, 100, 101, + 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, + 122, 123, 124, 17, -1, -1, -1, -1, 22, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 41, -1, 43, + -1, -1, -1, -1, -1, -1, -1, 51, 52, 53, + -1, 55, -1, 57, -1, 59, -1, 61, -1, 63, + -1, -1, 66, -1, -1, -1, -1, -1, 72, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 97, 98, 99, 100, 101, 102, 103, + 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, + 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, + 124, 17, -1, -1, -1, -1, 22, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 41, -1, 43, -1, -1, + -1, -1, -1, -1, -1, 51, 52, 53, -1, 55, + -1, 57, -1, 59, -1, 61, -1, 63, -1, -1, + 66, -1, -1, -1, -1, -1, 72, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 85, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 97, 98, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, + 116, 117, 118, 119, 120, 121, 122, 123, 124, 17, + -1, 19, 20, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 39, -1, 41, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 61, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 72, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 97, + 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, + 118, 119, 120, 121, 122, 123, 124, 17, -1, -1, + -1, -1, -1, -1, -1, 23, -1, -1, -1, 27, + 28, -1, -1, 31, 32, 33, 34, -1, 36, 37, + -1, 41, 40, -1, -1, -1, 44, -1, -1, 47, + -1, -1, 50, -1, -1, -1, 54, -1, -1, -1, + 58, 61, -1, -1, 62, -1, -1, 65, -1, 67, + -1, -1, 72, -1, -1, -1, -1, 75, -1, -1, + -1, 79, -1, 81, -1, 83, 84, -1, 86, 87, + 88, 89, -1, -1, 92, -1, -1, 97, 98, 99, + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 23, -1, 125, -1, -1, + -1, -1, -1, 31, 32, 33, -1, -1, 36, 37, + -1, -1, 40, -1, -1, -1, 44, -1, -1, -1, + -1, -1, 50, -1, -1, -1, 54, -1, -1, -1, + 58, -1, -1, -1, 62, -1, -1, 65, -1, 67, + -1, -1, -1, -1, -1, -1, -1, 75, -1, -1, + -1, 79, -1, 81, -1, 83, 84, -1, -1, 87, + 88, 89, -1, -1, 92, -1, -1, -1, -1, 97, + -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, 125, 97, 98, + 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, + 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, + 119, 120, 121, 122, 123, 124 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 142, 185, 0, 17, 22, 38, 41, 43, 51, + 52, 53, 55, 56, 57, 59, 61, 63, 66, 72, + 85, 90, 93, 97, 98, 99, 100, 101, 102, 103, + 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, + 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, + 124, 143, 144, 175, 176, 177, 196, 70, 71, 160, + 23, 31, 32, 33, 36, 37, 40, 44, 50, 54, + 58, 62, 65, 67, 75, 79, 81, 83, 84, 87, + 88, 89, 92, 97, 125, 179, 181, 182, 147, 3, + 144, 213, 16, 130, 131, 158, 145, 146, 18, 21, + 25, 26, 27, 29, 30, 32, 33, 34, 35, 42, + 45, 47, 49, 65, 73, 75, 76, 77, 80, 81, + 82, 87, 92, 126, 129, 137, 138, 198, 201, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 129, 132, 150, 162, 150, 158, + 150, 150, 133, 163, 75, 75, 163, 75, 163, 75, + 163, 163, 163, 163, 163, 75, 75, 163, 163, 163, + 163, 163, 163, 202, 163, 163, 163, 203, 163, 163, + 75, 30, 32, 33, 77, 81, 82, 87, 90, 92, + 148, 149, 198, 199, 201, 5, 66, 175, 177, 184, + 3, 3, 5, 3, 21, 25, 26, 29, 35, 42, + 126, 197, 19, 20, 39, 66, 74, 175, 177, 178, + 183, 5, 3, 4, 7, 8, 159, 167, 3, 3, + 176, 3, 3, 48, 68, 69, 70, 71, 91, 127, + 128, 161, 151, 182, 7, 11, 12, 13, 14, 15, + 159, 171, 172, 173, 174, 163, 163, 174, 163, 174, + 163, 174, 174, 174, 174, 174, 163, 163, 174, 174, + 134, 164, 174, 174, 174, 163, 174, 174, 174, 163, + 174, 174, 163, 163, 163, 163, 163, 163, 200, 163, + 3, 163, 5, 199, 177, 5, 3, 3, 3, 175, + 178, 175, 177, 178, 175, 178, 5, 162, 162, 162, + 162, 162, 162, 162, 162, 174, 174, 162, 174, 162, + 174, 162, 162, 162, 162, 162, 174, 174, 162, 162, + 135, 165, 162, 162, 164, 174, 205, 206, 162, 162, + 162, 205, 162, 164, 162, 174, 174, 174, 174, 174, + 174, 163, 174, 174, 5, 175, 7, 11, 12, 159, + 171, 173, 173, 7, 9, 10, 11, 12, 159, 168, + 164, 164, 7, 9, 10, 11, 12, 159, 169, 164, + 167, 164, 168, 168, 168, 166, 167, 167, 164, 164, + 169, 167, 135, 129, 152, 213, 174, 167, 165, 162, + 164, 174, 169, 174, 164, 5, 165, 168, 164, 162, + 162, 162, 162, 162, 205, 164, 162, 3, 178, 162, + 165, 165, 162, 162, 162, 162, 162, 162, 162, 165, + 162, 165, 164, 164, 164, 164, 162, 165, 165, 162, + 162, 23, 27, 28, 31, 32, 33, 34, 36, 37, + 47, 54, 65, 75, 81, 84, 86, 87, 88, 89, + 92, 125, 153, 179, 186, 187, 164, 162, 152, 206, + 165, 162, 162, 164, 165, 164, 152, 162, 165, 168, + 168, 166, 174, 174, 164, 165, 168, 3, 168, 152, + 152, 7, 9, 10, 11, 12, 159, 7, 159, 166, + 169, 152, 167, 152, 165, 165, 165, 165, 167, 152, + 152, 166, 169, 167, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 5, 136, 154, 162, 213, 165, 167, 152, + 168, 166, 165, 152, 204, 167, 152, 164, 164, 164, + 162, 164, 165, 155, 156, 186, 213, 162, 162, 164, + 164, 162, 162, 152, 152, 152, 152, 162, 164, 162, + 162, 60, 194, 195, 24, 31, 40, 44, 46, 54, + 58, 64, 67, 78, 79, 83, 87, 94, 95, 96, + 125, 180, 5, 66, 175, 177, 189, 3, 60, 190, + 191, 3, 60, 192, 193, 5, 3, 197, 66, 74, + 175, 177, 178, 188, 5, 5, 167, 3, 3, 3, + 213, 161, 5, 187, 152, 162, 164, 164, 164, 152, + 165, 164, 165, 165, 165, 168, 165, 155, 5, 157, + 213, 167, 68, 168, 170, 207, 208, 165, 139, 165, + 7, 159, 166, 168, 170, 211, 212, 3, 3, 139, + 165, 166, 170, 211, 3, 133, 44, 67, 79, 44, + 67, 79, 5, 177, 5, 133, 3, 133, 3, 3, + 175, 178, 175, 177, 178, 175, 178, 213, 167, 170, + 209, 210, 165, 165, 165, 152, 165, 155, 155, 155, + 164, 155, 213, 5, 164, 136, 164, 162, 164, 152, + 140, 152, 164, 162, 162, 162, 162, 162, 140, 152, + 164, 162, 162, 162, 209, 5, 5, 209, 209, 175, + 164, 162, 164, 152, 152, 152, 152, 165, 213, 165, + 3, 165, 208, 165, 25, 165, 168, 166, 166, 212, + 169, 168, 45, 165, 166, 166, 169, 134, 3, 134, + 134, 178, 165, 210, 165, 155, 155, 152, 152, 163, + 152, 164, 164, 162, 162, 163, 152, 164, 164, 162, + 133, 3, 133, 133, 152, 152, 174, 165, 165, 169, + 168, 174, 165, 165, 169, 211, 207, 211, 162, 152, + 152, 162, 162, 162, 152, 152, 162, 134, 162, 134, + 134, 169, 3, 3, 169, 3, 133, 133, 162, 162, + 164, 162, 162, 167, 167, 166, 166, 165, 166, 166, + 134, 134, 164, 164, 152, 164, 164, 165, 165, 152, + 152 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (fr, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, fr, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, mkFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + mkFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (fr); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, mkFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + mkFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Base* fr, mkFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, fr, ll) + YYSTYPE *yyvsp; + int yyrule; + Base* fr; + mkFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , fr, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, fr, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Base* fr, mkFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, fr, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + Base* fr; + mkFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (fr); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (Base* fr, mkFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (Base* fr, mkFlexLexer* ll) +#else +int +yyparse (fr, ll) + Base* fr; + mkFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 7: +#line 306 "frame/ds9parser.Y" + {cerr << "DS9 Regions File 3.2" << endl;;} + break; + + case 9: +#line 309 "frame/ds9parser.Y" + {globalTile = (yyvsp[(2) - (2)].integer);;} + break; + + case 10: +#line 311 "frame/ds9parser.Y" + {globalSystem=(Coord::CoordSystem)(yyvsp[(1) - (1)].integer);;} + break; + + case 12: +#line 312 "frame/ds9parser.Y" + {globalSystem=globalWCS; globalSky=(Coord::SkyFrame)(yyvsp[(1) - (1)].integer);;} + break; + + case 14: +#line 313 "frame/ds9parser.Y" + {globalSystem=globalWCS; globalSky=Coord::FK5;;} + break; + + case 21: +#line 322 "frame/ds9parser.Y" + {globalTile = (yyvsp[(2) - (2)].integer);;} + break; + + case 22: +#line 323 "frame/ds9parser.Y" + {DISCARD_(1);;} + break; + + case 25: +#line 327 "frame/ds9parser.Y" + {DISCARD_(1);;} + break; + + case 28: +#line 331 "frame/ds9parser.Y" + {DISCARD_(1);;} + break; + + case 29: +#line 331 "frame/ds9parser.Y" + {strncpy(localComment,(yyvsp[(3) - (4)].str),80);;} + break; + + case 31: +#line 333 "frame/ds9parser.Y" + {DISCARD_(1);;} + break; + + case 32: +#line 333 "frame/ds9parser.Y" + {strncpy(localComment,(yyvsp[(4) - (5)].str),80);;} + break; + + case 34: +#line 337 "frame/ds9parser.Y" + {DISCARD_(1);;} + break; + + case 35: +#line 337 "frame/ds9parser.Y" + {strncpy(localComment,(yyvsp[(2) - (3)].str),80);;} + break; + + case 37: +#line 339 "frame/ds9parser.Y" + {DISCARD_(1);;} + break; + + case 38: +#line 339 "frame/ds9parser.Y" + {strncpy(localComment,(yyvsp[(3) - (4)].str),80);;} + break; + + case 41: +#line 344 "frame/ds9parser.Y" + {YYACCEPT;;} + break; + + case 42: +#line 347 "frame/ds9parser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 43: +#line 348 "frame/ds9parser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].integer);;} + break; + + case 44: +#line 351 "frame/ds9parser.Y" + {yydebug=1;;} + break; + + case 45: +#line 352 "frame/ds9parser.Y" + {yydebug=0;;} + break; + + case 46: +#line 355 "frame/ds9parser.Y" + {(yyval.integer)=((yyvsp[(1) - (1)].integer) ? 1 : 0);;} + break; + + case 47: +#line 357 "frame/ds9parser.Y" + {(yyval.integer)=1;;} + break; + + case 48: +#line 358 "frame/ds9parser.Y" + {(yyval.integer)=1;;} + break; + + case 49: +#line 359 "frame/ds9parser.Y" + {(yyval.integer)=1;;} + break; + + case 50: +#line 360 "frame/ds9parser.Y" + {(yyval.integer)=1;;} + break; + + case 51: +#line 362 "frame/ds9parser.Y" + {(yyval.integer)=0;;} + break; + + case 52: +#line 363 "frame/ds9parser.Y" + {(yyval.integer)=0;;} + break; + + case 53: +#line 364 "frame/ds9parser.Y" + {(yyval.integer)=0;;} + break; + + case 54: +#line 365 "frame/ds9parser.Y" + {(yyval.integer)=0;;} + break; + + case 61: +#line 380 "frame/ds9parser.Y" + {cStatus = 0;;} + break; + + case 62: +#line 381 "frame/ds9parser.Y" + {cStatus = 1;;} + break; + + case 63: +#line 382 "frame/ds9parser.Y" + {cStatus = 1;;} + break; + + case 64: +#line 385 "frame/ds9parser.Y" + {(yyval.real) = fr->mapAngleToRef(0,localSystem,localSky);;} + break; + + case 65: +#line 386 "frame/ds9parser.Y" + {(yyval.real) = (yyvsp[(1) - (1)].real);;} + break; + + case 66: +#line 389 "frame/ds9parser.Y" + {(yyval.real) = fr->mapAngleToRef(degToRad((yyvsp[(1) - (1)].real)),localSystem,localSky);;} + break; + + case 67: +#line 390 "frame/ds9parser.Y" + {(yyval.real) = fr->mapAngleToRef(degToRad((yyvsp[(1) - (1)].real)),localSystem,localSky);;} + break; + + case 68: +#line 391 "frame/ds9parser.Y" + {(yyval.real) = fr->mapAngleToRef((yyvsp[(1) - (1)].real),localSystem,localSky);;} + break; + + case 69: +#line 394 "frame/ds9parser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), localSystem, Coord::DEGREE);;} + break; + + case 70: +#line 395 "frame/ds9parser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), Coord::PHYSICAL);;} + break; + + case 71: +#line 396 "frame/ds9parser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), Coord::IMAGE);;} + break; + + case 72: +#line 397 "frame/ds9parser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), checkWCSSystem(), Coord::DEGREE);;} + break; + + case 73: +#line 398 "frame/ds9parser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), checkWCSSystem(), Coord::ARCMIN);;} + break; + + case 74: +#line 399 "frame/ds9parser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), checkWCSSystem(), Coord::ARCSEC);;} + break; + + case 75: +#line 403 "frame/ds9parser.Y" + { + Vector r = FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), localSystem, Coord::DEGREE); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 76: +#line 410 "frame/ds9parser.Y" + { + Vector r = FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::PHYSICAL); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 77: +#line 417 "frame/ds9parser.Y" + { + Vector r = FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::IMAGE); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 78: +#line 424 "frame/ds9parser.Y" + { + Vector r=FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)),checkWCSSystem(),Coord::DEGREE); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 79: +#line 431 "frame/ds9parser.Y" + { + Vector r=FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)),checkWCSSystem(),Coord::ARCMIN); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 80: +#line 438 "frame/ds9parser.Y" + { + Vector r=FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)),checkWCSSystem(),Coord::ARCSEC); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 81: +#line 446 "frame/ds9parser.Y" + {(yyval.integer) = (yyvsp[(3) - (3)].integer);;} + break; + + case 82: +#line 449 "frame/ds9parser.Y" + {(yyval.real) = parseSEXStr((yyvsp[(1) - (1)].str));;} + break; + + case 83: +#line 452 "frame/ds9parser.Y" + {(yyval.real) = parseHMSStr((yyvsp[(1) - (1)].str));;} + break; + + case 84: +#line 455 "frame/ds9parser.Y" + {(yyval.real) = parseDMSStr((yyvsp[(1) - (1)].str));;} + break; + + case 85: +#line 459 "frame/ds9parser.Y" + { + Vector r; + Coord::CoordSystem sys = checkWCSSystem(); + Coord::SkyFrame sky = checkWCSSky(); + if (sky == Coord::GALACTIC || sky == Coord::ECLIPTIC) + r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), sys, sky); + else + r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real)*360./24.,(yyvsp[(3) - (3)].real)), sys, sky); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 86: +#line 472 "frame/ds9parser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), + checkWCSSystem(), checkWCSSky()); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 87: +#line 480 "frame/ds9parser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), + checkWCSSystem(), checkWCSSky()); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 88: +#line 488 "frame/ds9parser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), localSystem, localSky); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 89: +#line 495 "frame/ds9parser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), + checkWCSSystem(), checkWCSSky()); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 90: +#line 503 "frame/ds9parser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::IMAGE); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 91: +#line 510 "frame/ds9parser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::PHYSICAL); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + ;} + break; + + case 92: +#line 517 "frame/ds9parser.Y" + {(yyval.integer) = Coord::IMAGE;;} + break; + + case 93: +#line 518 "frame/ds9parser.Y" + {(yyval.integer) = Coord::PHYSICAL;;} + break; + + case 94: +#line 519 "frame/ds9parser.Y" + {(yyval.integer) = Coord::DETECTOR;;} + break; + + case 95: +#line 520 "frame/ds9parser.Y" + {(yyval.integer) = Coord::AMPLIFIER;;} + break; + + case 96: +#line 521 "frame/ds9parser.Y" + {(yyval.integer) = (yyvsp[(1) - (1)].integer); globalWCS = (Coord::CoordSystem)(yyvsp[(1) - (1)].integer);;} + break; + + case 97: +#line 524 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCS;;} + break; + + case 98: +#line 525 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSA;;} + break; + + case 99: +#line 526 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSB;;} + break; + + case 100: +#line 527 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSC;;} + break; + + case 101: +#line 528 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSD;;} + break; + + case 102: +#line 529 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSE;;} + break; + + case 103: +#line 530 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSF;;} + break; + + case 104: +#line 531 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSG;;} + break; + + case 105: +#line 532 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSH;;} + break; + + case 106: +#line 533 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSI;;} + break; + + case 107: +#line 534 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSJ;;} + break; + + case 108: +#line 535 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSK;;} + break; + + case 109: +#line 536 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSL;;} + break; + + case 110: +#line 537 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSM;;} + break; + + case 111: +#line 538 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSN;;} + break; + + case 112: +#line 539 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSO;;} + break; + + case 113: +#line 540 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSP;;} + break; + + case 114: +#line 541 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSQ;;} + break; + + case 115: +#line 542 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSR;;} + break; + + case 116: +#line 543 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSS;;} + break; + + case 117: +#line 544 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCST;;} + break; + + case 118: +#line 545 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSU;;} + break; + + case 119: +#line 546 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSV;;} + break; + + case 120: +#line 547 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSW;;} + break; + + case 121: +#line 548 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSX;;} + break; + + case 122: +#line 549 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSY;;} + break; + + case 123: +#line 550 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCSZ;;} + break; + + case 124: +#line 551 "frame/ds9parser.Y" + {(yyval.integer) = Coord::WCS0;;} + break; + + case 125: +#line 554 "frame/ds9parser.Y" + {(yyval.integer) = Coord::FK4;;} + break; + + case 126: +#line 555 "frame/ds9parser.Y" + {(yyval.integer) = Coord::FK4;;} + break; + + case 127: +#line 556 "frame/ds9parser.Y" + {(yyval.integer) = Coord::FK4_NO_E;;} + break; + + case 128: +#line 557 "frame/ds9parser.Y" + {(yyval.integer) = Coord::FK5;;} + break; + + case 129: +#line 558 "frame/ds9parser.Y" + {(yyval.integer) = Coord::FK5;;} + break; + + case 130: +#line 559 "frame/ds9parser.Y" + {(yyval.integer) = Coord::ICRS;;} + break; + + case 131: +#line 560 "frame/ds9parser.Y" + {(yyval.integer) = Coord::GALACTIC;;} + break; + + case 132: +#line 561 "frame/ds9parser.Y" + {(yyval.integer) = Coord::SUPERGALACTIC;;} + break; + + case 133: +#line 562 "frame/ds9parser.Y" + {(yyval.integer) = Coord::ECLIPTIC;;} + break; + + case 134: +#line 563 "frame/ds9parser.Y" + {(yyval.integer) = Coord::HELIOECLIPTIC;;} + break; + + case 135: +#line 566 "frame/ds9parser.Y" + {(yyval.integer)=Coord::DEGREE;;} + break; + + case 136: +#line 567 "frame/ds9parser.Y" + {(yyval.integer)=Coord::ARCMIN;;} + break; + + case 137: +#line 568 "frame/ds9parser.Y" + {(yyval.integer)=Coord::ARCSEC;;} + break; + + case 138: +#line 571 "frame/ds9parser.Y" + {(yyval.integer) = Marker::SELECT;;} + break; + + case 139: +#line 572 "frame/ds9parser.Y" + {(yyval.integer) = Marker::HIGHLITE;;} + break; + + case 140: +#line 573 "frame/ds9parser.Y" + {(yyval.integer) = Marker::DASH;;} + break; + + case 141: +#line 574 "frame/ds9parser.Y" + {(yyval.integer) = Marker::FIXED;;} + break; + + case 142: +#line 575 "frame/ds9parser.Y" + {(yyval.integer) = Marker::EDIT;;} + break; + + case 143: +#line 576 "frame/ds9parser.Y" + {(yyval.integer) = Marker::MOVE;;} + break; + + case 144: +#line 577 "frame/ds9parser.Y" + {(yyval.integer) = Marker::ROTATE;;} + break; + + case 145: +#line 578 "frame/ds9parser.Y" + {(yyval.integer) = Marker::DELETE;;} + break; + + case 146: +#line 579 "frame/ds9parser.Y" + {(yyval.integer) = Marker::INCLUDE;;} + break; + + case 147: +#line 580 "frame/ds9parser.Y" + {(yyval.integer) = Marker::SOURCE;;} + break; + + case 148: +#line 583 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::SELECTCB;;} + break; + + case 149: +#line 584 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::UNSELECTCB;;} + break; + + case 150: +#line 585 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::HIGHLITECB;;} + break; + + case 151: +#line 586 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::UNHIGHLITECB;;} + break; + + case 152: +#line 587 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::MOVEBEGINCB;;} + break; + + case 153: +#line 588 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::MOVECB;;} + break; + + case 154: +#line 589 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::MOVEENDCB;;} + break; + + case 155: +#line 590 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::EDITBEGINCB;;} + break; + + case 156: +#line 591 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::EDITCB;;} + break; + + case 157: +#line 592 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::EDITENDCB;;} + break; + + case 158: +#line 593 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::ROTATEBEGINCB;;} + break; + + case 159: +#line 594 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::ROTATECB;;} + break; + + case 160: +#line 595 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::ROTATEENDCB;;} + break; + + case 161: +#line 596 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::DELETECB;;} + break; + + case 162: +#line 597 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::TEXTCB;;} + break; + + case 163: +#line 598 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::COLORCB;;} + break; + + case 164: +#line 599 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::LINEWIDTHCB;;} + break; + + case 165: +#line 600 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::PROPERTYCB;;} + break; + + case 166: +#line 601 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::FONTCB;;} + break; + + case 167: +#line 602 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::KEYCB;;} + break; + + case 168: +#line 603 "frame/ds9parser.Y" + {(yyval.integer) = CallBack::UPDATECB;;} + break; + + case 171: +#line 611 "frame/ds9parser.Y" + { + setProps(&globalProps,(yyvsp[(1) - (3)].integer),(yyvsp[(3) - (3)].integer)); + setProps(&localProps,(yyvsp[(1) - (3)].integer),(yyvsp[(3) - (3)].integer)); + ;} + break; + + case 172: +#line 616 "frame/ds9parser.Y" + { + strncpy(globalColor,(yyvsp[(3) - (3)].str),16); + strncpy(localColor,(yyvsp[(3) - (3)].str),16); + ;} + break; + + case 173: +#line 621 "frame/ds9parser.Y" + { + globalDash[0] = localDash[0] =(yyvsp[(3) - (4)].integer); + globalDash[1] = localDash[1] =(yyvsp[(4) - (4)].integer); + ;} + break; + + case 174: +#line 625 "frame/ds9parser.Y" + {globalWidth = localWidth = (yyvsp[(3) - (3)].integer);;} + break; + + case 175: +#line 627 "frame/ds9parser.Y" + { + strncpy(globalFont,(yyvsp[(3) - (3)].str),32); + strncpy(localFont,(yyvsp[(3) - (3)].str),32); + ;} + break; + + case 176: +#line 632 "frame/ds9parser.Y" + { + strncpy(globalText,(yyvsp[(3) - (3)].str),80); + strncpy(localText,(yyvsp[(3) - (3)].str),80); + ;} + break; + + case 177: +#line 637 "frame/ds9parser.Y" + { + setProps(&globalProps,Marker::DASH,1); + setProps(&localProps,Marker::DASH,1); + ;} + break; + + case 178: +#line 642 "frame/ds9parser.Y" + { + setProps(&globalProps,Marker::SOURCE,1); + setProps(&localProps,Marker::SOURCE,1); + ;} + break; + + case 179: +#line 647 "frame/ds9parser.Y" + { + setProps(&globalProps,Marker::SOURCE,0); + setProps(&localProps,Marker::SOURCE,0); + ;} + break; + + case 180: +#line 651 "frame/ds9parser.Y" + {globalPoint = localPoint = (yyvsp[(3) - (3)].integer);;} + break; + + case 181: +#line 653 "frame/ds9parser.Y" + { + globalPoint = localPoint = (yyvsp[(3) - (4)].integer); + globalPointSize = localPointSize = (yyvsp[(4) - (4)].integer); + ;} + break; + + case 182: +#line 658 "frame/ds9parser.Y" + { + globalLine1 = localLine1 = (yyvsp[(3) - (4)].integer); + globalLine2 = localLine2 = (yyvsp[(4) - (4)].integer); + ;} + break; + + case 183: +#line 662 "frame/ds9parser.Y" + {globalVector = localVector = (yyvsp[(3) - (3)].integer);;} + break; + + case 184: +#line 664 "frame/ds9parser.Y" + { + globalComposite = localComposite = (yyvsp[(3) - (3)].integer); + ;} + break; + + case 185: +#line 667 "frame/ds9parser.Y" + {;} + break; + + case 186: +#line 669 "frame/ds9parser.Y" + { + strncpy(globalCompassNorth,(yyvsp[(4) - (7)].str),80); + strncpy(globalCompassEast,(yyvsp[(5) - (7)].str),80); + strncpy(localCompassNorth,(yyvsp[(4) - (7)].str),80); + strncpy(localCompassEast,(yyvsp[(5) - (7)].str),80); + globalCompassNArrow = localCompassNArrow = (yyvsp[(6) - (7)].integer); + globalCompassEArrow = localCompassEArrow = (yyvsp[(7) - (7)].integer); + ;} + break; + + case 187: +#line 677 "frame/ds9parser.Y" + {globalTextAngle = localTextAngle = (yyvsp[(3) - (3)].real);;} + break; + + case 188: +#line 678 "frame/ds9parser.Y" + {globalTextRotate = localTextRotate = (yyvsp[(3) - (3)].integer);;} + break; + + case 189: +#line 679 "frame/ds9parser.Y" + {globalWCS = (Coord::CoordSystem)(yyvsp[(3) - (3)].integer);;} + break; + + case 190: +#line 683 "frame/ds9parser.Y" + { + globalRulerCoordSystem = localRulerCoordSystem = (Coord::CoordSystem)(yyvsp[(1) - (4)].integer); + globalRulerSkyFrame = localRulerSkyFrame = (Coord::SkyFrame)(yyvsp[(2) - (4)].integer); + globalRulerDistSystem = localRulerDistSystem = (Coord::CoordSystem)(yyvsp[(3) - (4)].integer); + globalRulerDistFormat = localRulerDistFormat = (Coord::SkyDist)(yyvsp[(4) - (4)].integer); + ;} + break; + + case 191: +#line 690 "frame/ds9parser.Y" + { + globalRulerCoordSystem = localRulerCoordSystem = (Coord::CoordSystem)(yyvsp[(1) - (2)].integer); + globalRulerSkyFrame = localRulerSkyFrame = Coord::FK5; + globalRulerDistSystem = localRulerDistSystem = (Coord::CoordSystem)(yyvsp[(2) - (2)].integer); + globalRulerDistFormat = localRulerDistFormat = Coord::DEGREE; + ;} + break; + + case 192: +#line 697 "frame/ds9parser.Y" + { + globalRulerCoordSystem = localRulerCoordSystem = (Coord::CoordSystem)(yyvsp[(1) - (2)].integer); + globalRulerSkyFrame = localRulerSkyFrame = Coord::FK5; + globalRulerDistSystem = localRulerDistSystem = Coord::WCS; + globalRulerDistFormat = localRulerDistFormat = (Coord::SkyDist)(yyvsp[(2) - (2)].integer); + ;} + break; + + case 193: +#line 704 "frame/ds9parser.Y" + { + globalRulerCoordSystem = localRulerCoordSystem = Coord::WCS; + globalRulerSkyFrame = localRulerSkyFrame = (Coord::SkyFrame)(yyvsp[(1) - (2)].integer); + globalRulerDistSystem = localRulerDistSystem = (Coord::CoordSystem)(yyvsp[(2) - (2)].integer); + globalRulerDistFormat = localRulerDistFormat = Coord::DEGREE; + ;} + break; + + case 194: +#line 711 "frame/ds9parser.Y" + { + globalRulerCoordSystem = localRulerCoordSystem = Coord::WCS; + globalRulerSkyFrame = localRulerSkyFrame = (Coord::SkyFrame)(yyvsp[(1) - (2)].integer); + globalRulerDistSystem = localRulerDistSystem = Coord::WCS; + globalRulerDistFormat = localRulerDistFormat = (Coord::SkyDist)(yyvsp[(2) - (2)].integer); + ;} + break; + + case 195: +#line 718 "frame/ds9parser.Y" + { + globalRulerCoordSystem = localRulerCoordSystem = Coord::WCS; + globalRulerSkyFrame = localRulerSkyFrame = Coord::FK5; + globalRulerDistSystem = localRulerDistSystem = (Coord::CoordSystem)(yyvsp[(2) - (2)].integer); + globalRulerDistFormat = localRulerDistFormat = Coord::DEGREE; + ;} + break; + + case 196: +#line 725 "frame/ds9parser.Y" + { + globalRulerCoordSystem = localRulerCoordSystem = Coord::WCS; + globalRulerSkyFrame = localRulerSkyFrame = Coord::FK5; + globalRulerDistSystem = localRulerDistSystem = Coord::WCS; + globalRulerDistFormat = localRulerDistFormat = (Coord::SkyDist)(yyvsp[(2) - (2)].integer); + ;} + break; + + case 197: +#line 732 "frame/ds9parser.Y" + { + globalRulerCoordSystem = localRulerCoordSystem = Coord::IMAGE; + globalRulerSkyFrame = localRulerSkyFrame = Coord::FK5; + globalRulerDistSystem = localRulerDistSystem = Coord::WCS; + globalRulerDistFormat = localRulerDistFormat = (Coord::SkyDist)(yyvsp[(1) - (1)].integer); + ;} + break; + + case 198: +#line 739 "frame/ds9parser.Y" + { + globalRulerCoordSystem = localRulerCoordSystem = Coord::IMAGE; + globalRulerSkyFrame = localRulerSkyFrame = Coord::FK5; + globalRulerDistSystem = localRulerDistSystem = Coord::IMAGE; + globalRulerDistFormat = localRulerDistFormat = Coord::DEGREE; + ;} + break; + + case 199: +#line 748 "frame/ds9parser.Y" + { + globalCompassCoordSystem = localCompassCoordSystem = (Coord::CoordSystem)(yyvsp[(1) - (2)].integer); + globalCompassSkyFrame = localCompassSkyFrame = (Coord::SkyFrame)(yyvsp[(2) - (2)].integer); + ;} + break; + + case 200: +#line 753 "frame/ds9parser.Y" + { + globalCompassCoordSystem = localCompassCoordSystem = (Coord::CoordSystem)(yyvsp[(1) - (1)].integer); + globalCompassSkyFrame = localCompassSkyFrame = Coord::FK5; + ;} + break; + + case 201: +#line 758 "frame/ds9parser.Y" + { + globalCompassCoordSystem = localCompassCoordSystem = Coord::WCS; + globalCompassSkyFrame = localCompassSkyFrame = (Coord::SkyFrame)(yyvsp[(1) - (1)].integer); + ;} + break; + + case 202: +#line 763 "frame/ds9parser.Y" + { + globalCompassCoordSystem = localCompassCoordSystem = Coord::WCS; + globalCompassSkyFrame = localCompassSkyFrame = Coord::FK5; + ;} + break; + + case 203: +#line 769 "frame/ds9parser.Y" + { + // global properties + globalSystem = Coord::PHYSICAL; + globalWCS = fr->wcsSystem(); + globalSky = fr->wcsSky(); + globalTile = 1; + globalProps = + Marker::SELECT | Marker::EDIT | Marker::MOVE | + Marker::ROTATE | Marker::DELETE | Marker::HIGHLITE | + Marker::INCLUDE | Marker::SOURCE; + strcpy(globalColor,"green"); + globalDash[0] = 8; + globalDash[1] = 3; + globalWidth = 1; + strcpy(globalFont,"helvetica 10 normal roman"); + strcpy(globalText,""); + + // unique properties + globalLine1 = 0; + globalLine2 = 0; + globalVector = 1; + globalComposite = 1; + globalRulerCoordSystem = Coord::PHYSICAL; + globalRulerSkyFrame = Coord::FK5; + globalRulerDistSystem = Coord::PHYSICAL; + globalRulerDistFormat = Coord::DEGREE; + globalCompassCoordSystem = Coord::PHYSICAL; + globalCompassSkyFrame = Coord::FK5; + strcpy(globalCompassNorth,"N"); + strcpy(globalCompassEast,"E"); + globalCompassNArrow = 1; + globalCompassEArrow = 1; + globalPoint = Point::BOXCIRCLE; + globalPointSize = POINTSIZE; + globalTextAngle=0; + globalTextRotate=1; + + aStatus = 0; + cStatus = 0; + ;} + break; + + case 206: +#line 815 "frame/ds9parser.Y" + {setProps(&localProps,(yyvsp[(1) - (3)].integer),(yyvsp[(3) - (3)].integer));;} + break; + + case 207: +#line 816 "frame/ds9parser.Y" + {strncpy(localColor,(yyvsp[(3) - (3)].str),16);;} + break; + + case 208: +#line 818 "frame/ds9parser.Y" + { + localDash[0] =(yyvsp[(3) - (4)].integer); + localDash[1] =(yyvsp[(4) - (4)].integer); + ;} + break; + + case 209: +#line 822 "frame/ds9parser.Y" + {localWidth = (yyvsp[(3) - (3)].integer);;} + break; + + case 210: +#line 823 "frame/ds9parser.Y" + {strncpy(localFont,(yyvsp[(3) - (3)].str),32);;} + break; + + case 211: +#line 824 "frame/ds9parser.Y" + {strncpy(localText,(yyvsp[(3) - (3)].str),80);;} + break; + + case 212: +#line 825 "frame/ds9parser.Y" + {taglist.append(new Tag((yyvsp[(3) - (3)].str)));;} + break; + + case 213: +#line 826 "frame/ds9parser.Y" + {cblist.append( + new CallBack(fr->getInterp(),(CallBack::Type)(yyvsp[(3) - (5)].integer),(yyvsp[(4) - (5)].str),(yyvsp[(5) - (5)].str)));;} + break; + + case 214: +#line 828 "frame/ds9parser.Y" + {setProps(&localProps,Marker::DASH,1);;} + break; + + case 215: +#line 829 "frame/ds9parser.Y" + {setProps(&localProps,Marker::SOURCE,1);;} + break; + + case 216: +#line 830 "frame/ds9parser.Y" + {setProps(&localProps,Marker::SOURCE,0);;} + break; + + case 217: +#line 832 "frame/ds9parser.Y" + {localPoint = (yyvsp[(3) - (3)].integer);;} + break; + + case 218: +#line 833 "frame/ds9parser.Y" + {localPoint = (yyvsp[(3) - (4)].integer); localPointSize = (yyvsp[(4) - (4)].integer);;} + break; + + case 219: +#line 834 "frame/ds9parser.Y" + {localLine1=(yyvsp[(3) - (4)].integer); localLine2=(yyvsp[(4) - (4)].integer);;} + break; + + case 220: +#line 835 "frame/ds9parser.Y" + {localVector=(yyvsp[(3) - (3)].integer);;} + break; + + case 221: +#line 836 "frame/ds9parser.Y" + {localComposite=(yyvsp[(3) - (3)].integer);;} + break; + + case 223: +#line 839 "frame/ds9parser.Y" + { + strncpy(localCompassNorth,(yyvsp[(4) - (7)].str),80); + strncpy(localCompassEast,(yyvsp[(5) - (7)].str),80); + localCompassNArrow = (yyvsp[(6) - (7)].integer); + localCompassEArrow = (yyvsp[(7) - (7)].integer); + ;} + break; + + case 224: +#line 845 "frame/ds9parser.Y" + {localTextAngle=(yyvsp[(3) - (3)].real);;} + break; + + case 225: +#line 846 "frame/ds9parser.Y" + {localTextRotate=(yyvsp[(3) - (3)].integer);;} + break; + + case 229: +#line 853 "frame/ds9parser.Y" + { + localRulerCoordSystem = (Coord::CoordSystem)(yyvsp[(1) - (4)].integer); + localRulerSkyFrame = (Coord::SkyFrame)(yyvsp[(2) - (4)].integer); + localRulerDistSystem = (Coord::CoordSystem)(yyvsp[(3) - (4)].integer); + localRulerDistFormat = (Coord::SkyDist)(yyvsp[(4) - (4)].integer); + ;} + break; + + case 230: +#line 860 "frame/ds9parser.Y" + { + localRulerCoordSystem = (Coord::CoordSystem)(yyvsp[(1) - (2)].integer); + localRulerSkyFrame = Coord::FK5; + localRulerDistSystem = (Coord::CoordSystem)(yyvsp[(2) - (2)].integer); + localRulerDistFormat = Coord::DEGREE; + ;} + break; + + case 231: +#line 867 "frame/ds9parser.Y" + { + localRulerCoordSystem = (Coord::CoordSystem)(yyvsp[(1) - (2)].integer); + localRulerSkyFrame = Coord::FK5; + localRulerDistSystem = Coord::WCS; + localRulerDistFormat = (Coord::SkyDist)(yyvsp[(2) - (2)].integer); + ;} + break; + + case 232: +#line 874 "frame/ds9parser.Y" + { + localRulerCoordSystem = Coord::WCS; + localRulerSkyFrame = (Coord::SkyFrame)(yyvsp[(1) - (2)].integer); + localRulerDistSystem = (Coord::CoordSystem)(yyvsp[(2) - (2)].integer); + localRulerDistFormat = Coord::DEGREE; + ;} + break; + + case 233: +#line 881 "frame/ds9parser.Y" + { + localRulerCoordSystem = Coord::WCS; + localRulerSkyFrame = (Coord::SkyFrame)(yyvsp[(1) - (2)].integer); + localRulerDistSystem = Coord::WCS; + localRulerDistFormat = (Coord::SkyDist)(yyvsp[(2) - (2)].integer); + ;} + break; + + case 234: +#line 888 "frame/ds9parser.Y" + { + localRulerCoordSystem = Coord::WCS; + localRulerSkyFrame = Coord::FK5; + localRulerDistSystem = (Coord::CoordSystem)(yyvsp[(2) - (2)].integer); + localRulerDistFormat = Coord::DEGREE; + ;} + break; + + case 235: +#line 895 "frame/ds9parser.Y" + { + localRulerCoordSystem = Coord::WCS; + localRulerSkyFrame = Coord::FK5; + localRulerDistSystem = Coord::WCS; + localRulerDistFormat = (Coord::SkyDist)(yyvsp[(2) - (2)].integer); + ;} + break; + + case 236: +#line 902 "frame/ds9parser.Y" + { + localRulerCoordSystem = Coord::IMAGE; + localRulerSkyFrame = Coord::FK5; + localRulerDistSystem = Coord::WCS; + localRulerDistFormat = (Coord::SkyDist)(yyvsp[(1) - (1)].integer); + ;} + break; + + case 237: +#line 909 "frame/ds9parser.Y" + { + localRulerCoordSystem = Coord::IMAGE; + localRulerSkyFrame = Coord::FK5; + localRulerDistSystem = Coord::IMAGE; + localRulerDistFormat = Coord::DEGREE; + ;} + break; + + case 238: +#line 918 "frame/ds9parser.Y" + { + localCompassCoordSystem = (Coord::CoordSystem)(yyvsp[(1) - (2)].integer); + localCompassSkyFrame = (Coord::SkyFrame)(yyvsp[(2) - (2)].integer); + ;} + break; + + case 239: +#line 923 "frame/ds9parser.Y" + { + localCompassCoordSystem = (Coord::CoordSystem)(yyvsp[(1) - (1)].integer); + localCompassSkyFrame = Coord::FK5; + ;} + break; + + case 240: +#line 928 "frame/ds9parser.Y" + { + localCompassCoordSystem = Coord::WCS; + localCompassSkyFrame = (Coord::SkyFrame)(yyvsp[(1) - (1)].integer); + ;} + break; + + case 241: +#line 933 "frame/ds9parser.Y" + { + localCompassCoordSystem = Coord::WCS; + localCompassSkyFrame = Coord::FK5; + ;} + break; + + case 242: +#line 939 "frame/ds9parser.Y" + {aNum=0; aAngNum=0;;} + break; + + case 243: +#line 939 "frame/ds9parser.Y" + {localCpanda = 2;;} + break; + + case 244: +#line 940 "frame/ds9parser.Y" + {localCpanda=0;;} + break; + + case 245: +#line 943 "frame/ds9parser.Y" + {aNum=0; aAngNum=0, aAngle=0;;} + break; + + case 246: +#line 944 "frame/ds9parser.Y" + {aAngle=(yyvsp[(9) - (10)].real);localEpanda=2;;} + break; + + case 247: +#line 945 "frame/ds9parser.Y" + {localEpanda=0;;} + break; + + case 248: +#line 948 "frame/ds9parser.Y" + {aNum=0; aAngNum=0, aAngle=0;;} + break; + + case 249: +#line 949 "frame/ds9parser.Y" + {aAngle=(yyvsp[(9) - (10)].real);localBpanda=2;;} + break; + + case 250: +#line 950 "frame/ds9parser.Y" + {localBpanda=0;;} + break; + + case 251: +#line 953 "frame/ds9parser.Y" + { + // reset maperr flag + maperr = 0; + + // needed for annulus, ellipse annulus, and box annulus + aNum = 2; + + // composite (previous conjunction found?) + if (!cStatus) fr->resetCompositeMarker(); + + // global properties + localSystem = globalSystem; + localSky = globalSky; + localProps = globalProps; + strcpy(localColor,globalColor); + localDash[0] = globalDash[0]; + localDash[1] = globalDash[1]; + localWidth = globalWidth; + strcpy(localFont,globalFont); + strcpy(localText,globalText); + strcpy(localComment,""); + taglist.deleteAll(); + cblist.deleteAll(); + + // unique properties + localLine1 = globalLine1; + localLine2 = globalLine2; + localVector = globalVector; + localComposite = globalComposite; + localPoint = globalPoint; + localPointSize = globalPointSize; + localRulerCoordSystem = globalRulerCoordSystem; + localRulerSkyFrame = globalRulerSkyFrame; + localRulerDistSystem = globalRulerDistSystem; + localRulerDistFormat = globalRulerDistFormat; + localCompassCoordSystem = globalCompassCoordSystem; + localCompassSkyFrame = globalCompassSkyFrame; + strcpy(localCompassNorth,globalCompassNorth); + strcpy(localCompassEast,globalCompassEast); + localCompassNArrow = globalCompassNArrow; + localCompassEArrow = globalCompassEArrow; + localTextAngle = globalTextAngle; + localTextRotate = globalTextRotate; + localCpanda = 1; + localEpanda = 1; + localBpanda = 1; + ;} + break; + + case 252: +#line 1002 "frame/ds9parser.Y" + {(yyval.integer) = Point::CIRCLE;;} + break; + + case 253: +#line 1003 "frame/ds9parser.Y" + {(yyval.integer) = Point::BOX;;} + break; + + case 254: +#line 1004 "frame/ds9parser.Y" + {(yyval.integer) = Point::DIAMOND;;} + break; + + case 255: +#line 1005 "frame/ds9parser.Y" + {(yyval.integer) = Point::CROSS;;} + break; + + case 256: +#line 1006 "frame/ds9parser.Y" + {(yyval.integer) = Point::EX;;} + break; + + case 257: +#line 1007 "frame/ds9parser.Y" + {(yyval.integer) = Point::ARROW;;} + break; + + case 258: +#line 1008 "frame/ds9parser.Y" + {(yyval.integer) = Point::BOXCIRCLE;;} + break; + + case 259: +#line 1011 "frame/ds9parser.Y" + {setProps(&localProps, Marker::INCLUDE, 1);;} + break; + + case 260: +#line 1012 "frame/ds9parser.Y" + {setProps(&localProps, Marker::INCLUDE, 0);;} + break; + + case 261: +#line 1016 "frame/ds9parser.Y" + { + fr->createVectCmd(Vector((yyvsp[(3) - (10)].vector)), + (yyvsp[(5) - (10)].real),(yyvsp[(7) - (10)].real), + localVector, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 262: +#line 1023 "frame/ds9parser.Y" + {polylist.deleteAll();;} + break; + + case 263: +#line 1025 "frame/ds9parser.Y" + { + fr->createSegmentCmd(polylist, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 264: +#line 1031 "frame/ds9parser.Y" + { + fr->createTextCmd(Vector((yyvsp[(3) - (6)].vector)), + localTextAngle,localTextRotate, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 265: +#line 1038 "frame/ds9parser.Y" + { + fr->createRulerCmd(Vector((yyvsp[(3) - (8)].vector)), + Vector((yyvsp[(5) - (8)].vector)), + localRulerCoordSystem, localRulerSkyFrame, + localRulerDistSystem, localRulerDistFormat, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 266: +#line 1047 "frame/ds9parser.Y" + { + fr->createCompassCmd(Vector((yyvsp[(3) - (8)].vector)), + (yyvsp[(5) - (8)].real), + localCompassNorth, localCompassEast, + localCompassNArrow, localCompassEArrow, + localCompassCoordSystem, localCompassSkyFrame, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 267: +#line 1057 "frame/ds9parser.Y" + { + fr->createProjectionCmd(Vector((yyvsp[(3) - (10)].vector)), + Vector((yyvsp[(5) - (10)].vector)), + (yyvsp[(7) - (10)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 268: +#line 1065 "frame/ds9parser.Y" + { + // backward compatibility + fr->createCircleCmd(Vector((yyvsp[(3) - (8)].vector)), + (yyvsp[(5) - (8)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 269: +#line 1073 "frame/ds9parser.Y" + { + fr->createCompositeCmd(Vector((yyvsp[(3) - (8)].vector)), + (yyvsp[(5) - (8)].real), localComposite, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 270: +#line 1082 "frame/ds9parser.Y" + { + fr->createCircleCmd(Vector((yyvsp[(3) - (8)].vector)), + (yyvsp[(5) - (8)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 271: +#line 1089 "frame/ds9parser.Y" + { + // backwards compatibility + fr->createCircleCmd(Vector((yyvsp[(3) - (8)].vector)), + (yyvsp[(5) - (8)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 272: +#line 1097 "frame/ds9parser.Y" + { + // for ellipse annulus + aStatus = 1; + aCenter = Vector((yyvsp[(3) - (10)].vector)); + aAngles[0] = (yyvsp[(7) - (10)].real); + aVector[0] = Vector((yyvsp[(5) - (10)].vector)); + aNumsao = 1; + strncpy(aColor,localColor,16); + aDash[0] = localDash[0]; + aDash[1] = localDash[1]; + aWidth = localWidth; + strncpy(aFont,localFont,32); + strncpy(aText,localText,80); + strncpy(aComment,localComment,80); + aProps = localProps; + + fr->createEllipseCmd(Vector((yyvsp[(3) - (10)].vector)), + Vector((yyvsp[(5) - (10)].vector)), + (yyvsp[(7) - (10)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 273: +#line 1120 "frame/ds9parser.Y" + { + // for box annulus + aStatus = 3; + aCenter = Vector((yyvsp[(3) - (10)].vector)); + aAngles[0] = (yyvsp[(7) - (10)].real); + aVector[0] = Vector((yyvsp[(5) - (10)].vector)); + aNumsao = 1; + strncpy(aColor,localColor,16); + aDash[0] = localDash[0]; + aDash[1] = localDash[1]; + aWidth = localWidth; + strncpy(aFont,localFont,32); + strncpy(aText,localText,80); + strncpy(aComment,localComment,80); + aProps = localProps; + + fr->createBoxCmd(Vector((yyvsp[(3) - (10)].vector)), + Vector((yyvsp[(5) - (10)].vector)), + (yyvsp[(7) - (10)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 274: +#line 1143 "frame/ds9parser.Y" + { + // backwards compatibility + fr->createBoxCmd(Vector((yyvsp[(3) - (10)].vector)), + Vector((yyvsp[(5) - (10)].vector)), + (yyvsp[(7) - (10)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 275: +#line 1151 "frame/ds9parser.Y" + {polylist.deleteAll();;} + break; + + case 276: +#line 1153 "frame/ds9parser.Y" + { + fr->createPolygonCmd(polylist, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 277: +#line 1158 "frame/ds9parser.Y" + {polylist.deleteAll();;} + break; + + case 278: +#line 1160 "frame/ds9parser.Y" + { + fr->createSegmentCmd(polylist, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 279: +#line 1167 "frame/ds9parser.Y" + { + fr->createLineCmd(Vector((yyvsp[(3) - (8)].vector)), + Vector((yyvsp[(5) - (8)].vector)), + localLine1,localLine2, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 280: +#line 1175 "frame/ds9parser.Y" + { + fr->createVectCmd(Vector((yyvsp[(3) - (10)].vector)), + (yyvsp[(5) - (10)].real),(yyvsp[(7) - (10)].real), + localVector, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 281: +#line 1183 "frame/ds9parser.Y" + { + fr->createTextCmd(Vector((yyvsp[(3) - (6)].vector)), + localTextAngle,localTextRotate, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 282: +#line 1189 "frame/ds9parser.Y" + {strncpy(localText,(yyvsp[(5) - (6)].str),80);;} + break; + + case 283: +#line 1191 "frame/ds9parser.Y" + { + fr->createTextCmd(Vector((yyvsp[(3) - (9)].vector)), + localTextAngle,localTextRotate, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 284: +#line 1198 "frame/ds9parser.Y" + { + fr->createPointCmd(Vector((yyvsp[(3) - (6)].vector)), + (Point::PointShape)localPoint, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 285: +#line 1205 "frame/ds9parser.Y" + { + // backwards compatibility + fr->createPointCmd(Vector((yyvsp[(4) - (7)].vector)), Point::CIRCLE, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 286: +#line 1212 "frame/ds9parser.Y" + { + // backwards compatibility + fr->createPointCmd(Vector((yyvsp[(4) - (7)].vector)), Point::BOX, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 287: +#line 1219 "frame/ds9parser.Y" + { + // backwards compatibility + fr->createPointCmd(Vector((yyvsp[(4) - (7)].vector)), Point::DIAMOND, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 288: +#line 1226 "frame/ds9parser.Y" + { + // backwards compatibility + fr->createPointCmd(Vector((yyvsp[(4) - (7)].vector)), Point::CROSS, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 289: +#line 1233 "frame/ds9parser.Y" + { + // backwards compatibility + fr->createPointCmd(Vector((yyvsp[(4) - (7)].vector)), Point::EX, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 290: +#line 1240 "frame/ds9parser.Y" + { + // backwards compatibility + fr->createPointCmd(Vector((yyvsp[(4) - (7)].vector)), Point::ARROW, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 291: +#line 1247 "frame/ds9parser.Y" + { + // backwards compatibility + fr->createPointCmd(Vector((yyvsp[(4) - (7)].vector)), Point::BOXCIRCLE, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 292: +#line 1254 "frame/ds9parser.Y" + { + fr->createRulerCmd(Vector((yyvsp[(3) - (8)].vector)), + Vector((yyvsp[(5) - (8)].vector)), + localRulerCoordSystem, localRulerSkyFrame, + localRulerDistSystem, localRulerDistFormat, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 293: +#line 1263 "frame/ds9parser.Y" + { + fr->createCompassCmd(Vector((yyvsp[(3) - (8)].vector)), + (yyvsp[(5) - (8)].real), + localCompassNorth, localCompassEast, + localCompassNArrow, localCompassEArrow, + localCompassCoordSystem, localCompassSkyFrame, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 294: +#line 1273 "frame/ds9parser.Y" + { + fr->createProjectionCmd(Vector((yyvsp[(3) - (10)].vector)), + Vector((yyvsp[(5) - (10)].vector)), + (yyvsp[(7) - (10)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 295: +#line 1281 "frame/ds9parser.Y" + { + fr->createAnnulusCmd(Vector((yyvsp[(3) - (10)].vector)), + (yyvsp[(5) - (10)].real),(yyvsp[(7) - (10)].real),1, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 296: +#line 1289 "frame/ds9parser.Y" + { + aAnnuli[0] = (yyvsp[(5) - (12)].real); + aAnnuli[1] = (yyvsp[(7) - (12)].real); + fr->createAnnulusCmd(Vector((yyvsp[(3) - (12)].vector)), + aNum,aAnnuli, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 297: +#line 1299 "frame/ds9parser.Y" + { + fr->createAnnulusCmd(Vector((yyvsp[(3) - (12)].vector)), + (yyvsp[(5) - (12)].real),(yyvsp[(7) - (12)].real),(yyvsp[(9) - (12)].integer), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 298: +#line 1307 "frame/ds9parser.Y" + { + // prefered syntax + fr->createEllipseAnnulusCmd(Vector((yyvsp[(3) - (12)].vector)), + Vector((yyvsp[(5) - (12)].vector)),Vector((yyvsp[(7) - (12)].vector)),1, + (yyvsp[(9) - (12)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 299: +#line 1317 "frame/ds9parser.Y" + { + // prefered syntax + fr->createEllipseAnnulusCmd(Vector((yyvsp[(3) - (14)].vector)), + Vector((yyvsp[(5) - (14)].vector)),Vector((yyvsp[(7) - (14)].vector)),(yyvsp[(9) - (14)].integer), + (yyvsp[(11) - (14)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 300: +#line 1327 "frame/ds9parser.Y" + { + // prefered syntax + aVector[0] = Vector((yyvsp[(5) - (14)].vector)); + aVector[1] = Vector((yyvsp[(7) - (14)].vector)); + fr->createEllipseAnnulusCmd(Vector((yyvsp[(3) - (14)].vector)), + aNum,aVector, + (yyvsp[(11) - (14)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 301: +#line 1339 "frame/ds9parser.Y" + { + // backwards compatibility + // old saoimage syntax + aStatus = 2; + aVector[aNumsao++] = Vector((yyvsp[(5) - (18)].vector)); + ;} + break; + + case 302: +#line 1347 "frame/ds9parser.Y" + { + // prefered syntax + fr->createBoxAnnulusCmd(Vector((yyvsp[(3) - (12)].vector)), + Vector((yyvsp[(5) - (12)].vector)),Vector((yyvsp[(7) - (12)].vector)),1, + (yyvsp[(9) - (12)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 303: +#line 1357 "frame/ds9parser.Y" + { + // prefered syntax + aVector[0] = Vector((yyvsp[(5) - (14)].vector)); + aVector[1] = Vector((yyvsp[(7) - (14)].vector)); + fr->createBoxAnnulusCmd(Vector((yyvsp[(3) - (14)].vector)), + aNum,aVector, + (yyvsp[(11) - (14)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 304: +#line 1369 "frame/ds9parser.Y" + { + // prefered syntax + fr->createBoxAnnulusCmd(Vector((yyvsp[(3) - (14)].vector)), + Vector((yyvsp[(5) - (14)].vector)),Vector((yyvsp[(7) - (14)].vector)),(yyvsp[(9) - (14)].integer), + (yyvsp[(11) - (14)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 305: +#line 1379 "frame/ds9parser.Y" + { + // backwards compatibility + // old saoimage syntax + aStatus = 4; + aVector[aNumsao++] = Vector((yyvsp[(5) - (18)].vector)); + ;} + break; + + case 306: +#line 1388 "frame/ds9parser.Y" + { + switch (localCpanda) { + case 0: /* ignore it */ + break; + case 1: /* normal cpanda */ + fr->createCpandaCmd(Vector((yyvsp[(3) - (18)].vector)), + (yyvsp[(5) - (18)].real),(yyvsp[(7) - (18)].real),(yyvsp[(9) - (18)].integer), + (yyvsp[(11) - (18)].real),(yyvsp[(13) - (18)].real),(yyvsp[(15) - (18)].integer), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + break; + case 2: /* one of our special pandas */ + fr->createCpandaCmd(Vector((yyvsp[(3) - (18)].vector)), + aAngNum,aAngles, + aNum,aAnnuli, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + break; + } + ;} + break; + + case 307: +#line 1410 "frame/ds9parser.Y" + { + switch (localEpanda) { + case 0: /* ignore it */ + break; + case 1: /* normal epanda */ + fr->createEpandaCmd(Vector((yyvsp[(3) - (20)].vector)), + (yyvsp[(5) - (20)].real),(yyvsp[(7) - (20)].real),(yyvsp[(9) - (20)].integer), + Vector((yyvsp[(11) - (20)].vector)),Vector((yyvsp[(13) - (20)].vector)),(yyvsp[(15) - (20)].integer), + (yyvsp[(17) - (20)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + break; + case 2: /* one of our special pandas */ + fr->createEpandaCmd(Vector((yyvsp[(3) - (20)].vector)), + aAngNum,aAngles, + aNum,aVector, + aAngle, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + break; + } + ;} + break; + + case 308: +#line 1434 "frame/ds9parser.Y" + { + switch (localBpanda) { + case 0: /* ignore it */ + break; + case 1: /* normal bpanda */ + fr->createBpandaCmd(Vector((yyvsp[(3) - (20)].vector)), + (yyvsp[(5) - (20)].real),(yyvsp[(7) - (20)].real),(yyvsp[(9) - (20)].integer), + Vector((yyvsp[(11) - (20)].vector)),Vector((yyvsp[(13) - (20)].vector)),(yyvsp[(15) - (20)].integer), + (yyvsp[(17) - (20)].real), + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + break; + case 2: /* one of our special pandas */ + fr->createBpandaCmd(Vector((yyvsp[(3) - (20)].vector)), + aAngNum,aAngles, + aNum,aVector, + aAngle, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + break; + } + ;} + break; + + case 313: +#line 1464 "frame/ds9parser.Y" + { + fr->createCompositeCmd(Vector((yyvsp[(3) - (8)].vector)), + (yyvsp[(5) - (8)].real), localComposite, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + ;} + break; + + case 316: +#line 1476 "frame/ds9parser.Y" + {polylist.append(new Vertex((yyvsp[(1) - (1)].vector)));;} + break; + + case 319: +#line 1484 "frame/ds9parser.Y" + { + if (aNum < MAXANNULI) + aAnnuli[aNum++] = (yyvsp[(1) - (1)].real); + ;} + break; + + case 322: +#line 1495 "frame/ds9parser.Y" + { + if (aAngNum < MAXANGLES) + aAngles[aAngNum++] = (yyvsp[(1) - (1)].real); + ;} + break; + + case 325: +#line 1505 "frame/ds9parser.Y" + {aVector[aNum++] = Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real));;} + break; + + case 326: +#line 1509 "frame/ds9parser.Y" + { + // old style annulus + switch (aStatus) { + case 0: // do nothing + break; + case 1: // we found just an ellipse, do nothing + break; + case 2: // ok we have an ellipse annulus + fr->markerDeleteLastCmd(); // delete the previous ellipse + fr->createEllipseAnnulusCmd(aCenter, + aNumsao,aVector, + aAngles[0], + aColor,aDash,aWidth,aFont,aText,aProps,aComment,taglist,cblist); + break; + case 3: // we found just a box, do nothing + break; + case 4: // ok, we have a box annulus + fr->markerDeleteLastCmd(); // delete the previous box + fr->createBoxAnnulusCmd(aCenter, + aNumsao,aVector, + aAngles[0], + aColor,aDash,aWidth,aFont,aText,aProps,aComment,taglist,cblist); + break; + } + aStatus = 0; + ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 4894 "frame/ds9parser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (fr, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (fr, ll, yymsg); + } + else + { + yyerror (fr, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, fr, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, fr, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (fr, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, fr, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, fr, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 1536 "frame/ds9parser.Y" + + +static void setProps(unsigned short* props, unsigned short prop, int value) +{ + if (value) + *props |= prop; + else + *props &= ~prop; +} + +static Coord::CoordSystem checkWCSSystem() +{ + switch (localSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::WCS; + default: + return localSystem; + } +} + +static Coord::SkyFrame checkWCSSky() +{ + switch (localSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::FK5; + default: + return localSky; + } +} + + diff --git a/tksao/frame/ds9parser.H b/tksao/frame/ds9parser.H new file mode 100644 index 0000000..ecfcf00 --- /dev/null +++ b/tksao/frame/ds9parser.H @@ -0,0 +1,320 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + STRING = 260, + COLOR = 261, + ANGDEGREE = 262, + ANGRADIAN = 263, + ARCMINUTE = 264, + ARCSECOND = 265, + PHYCOORD = 266, + IMGCOORD = 267, + SEXSTR = 268, + HMSSTR = 269, + DMSSTR = 270, + EOF_ = 271, + AMPLIFIER_ = 272, + ANNULUS_ = 273, + ARCMIN_ = 274, + ARCSEC_ = 275, + ARROW_ = 276, + B1950_ = 277, + BACKGROUND_ = 278, + BEGIN_ = 279, + BOX_ = 280, + BOXCIRCLE_ = 281, + BPANDA_ = 282, + CALLBACK_ = 283, + CIRCLE_ = 284, + CIRCLE3D_ = 285, + COLOR_ = 286, + COMPASS_ = 287, + COMPOSITE_ = 288, + CPANDA_ = 289, + CROSS_ = 290, + DASH_ = 291, + DASHLIST_ = 292, + DEBUG_ = 293, + DEGREES_ = 294, + DELETE_ = 295, + DETECTOR_ = 296, + DIAMOND_ = 297, + ECLIPTIC_ = 298, + EDIT_ = 299, + ELLIPSE_ = 300, + END_ = 301, + EPANDA_ = 302, + FALSE_ = 303, + FIELD_ = 304, + FIXED_ = 305, + FK4_ = 306, + FK4_NO_E_ = 307, + FK5_ = 308, + FONT_ = 309, + GALACTIC_ = 310, + GLOBAL_ = 311, + HELIOECLIPTIC_ = 312, + HIGHLITE_ = 313, + ICRS_ = 314, + IGNORE_ = 315, + IMAGE_ = 316, + INCLUDE_ = 317, + J2000_ = 318, + KEY_ = 319, + LINE_ = 320, + LINEAR_ = 321, + MOVE_ = 322, + N_ = 323, + NO_ = 324, + OFF_ = 325, + ON_ = 326, + PHYSICAL_ = 327, + PIE_ = 328, + PIXELS_ = 329, + POINT_ = 330, + POLYGON_ = 331, + PROJECTION_ = 332, + PROPERTY_ = 333, + ROTATE_ = 334, + ROTBOX_ = 335, + RULER_ = 336, + SEGMENT_ = 337, + SELECT_ = 338, + SOURCE_ = 339, + SUPERGALACTIC_ = 340, + TAG_ = 341, + TEXT_ = 342, + TEXTANGLE_ = 343, + TEXTROTATE_ = 344, + TILE_ = 345, + TRUE_ = 346, + VECTOR_ = 347, + VERSION_ = 348, + UNHIGHLITE_ = 349, + UNSELECT_ = 350, + UPDATE_ = 351, + WCS_ = 352, + WCSA_ = 353, + WCSB_ = 354, + WCSC_ = 355, + WCSD_ = 356, + WCSE_ = 357, + WCSF_ = 358, + WCSG_ = 359, + WCSH_ = 360, + WCSI_ = 361, + WCSJ_ = 362, + WCSK_ = 363, + WCSL_ = 364, + WCSM_ = 365, + WCSN_ = 366, + WCSO_ = 367, + WCSP_ = 368, + WCSQ_ = 369, + WCSR_ = 370, + WCSS_ = 371, + WCST_ = 372, + WCSU_ = 373, + WCSV_ = 374, + WCSW_ = 375, + WCSX_ = 376, + WCSY_ = 377, + WCSZ_ = 378, + WCS0_ = 379, + WIDTH_ = 380, + X_ = 381, + Y_ = 382, + YES_ = 383 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define STRING 260 +#define COLOR 261 +#define ANGDEGREE 262 +#define ANGRADIAN 263 +#define ARCMINUTE 264 +#define ARCSECOND 265 +#define PHYCOORD 266 +#define IMGCOORD 267 +#define SEXSTR 268 +#define HMSSTR 269 +#define DMSSTR 270 +#define EOF_ 271 +#define AMPLIFIER_ 272 +#define ANNULUS_ 273 +#define ARCMIN_ 274 +#define ARCSEC_ 275 +#define ARROW_ 276 +#define B1950_ 277 +#define BACKGROUND_ 278 +#define BEGIN_ 279 +#define BOX_ 280 +#define BOXCIRCLE_ 281 +#define BPANDA_ 282 +#define CALLBACK_ 283 +#define CIRCLE_ 284 +#define CIRCLE3D_ 285 +#define COLOR_ 286 +#define COMPASS_ 287 +#define COMPOSITE_ 288 +#define CPANDA_ 289 +#define CROSS_ 290 +#define DASH_ 291 +#define DASHLIST_ 292 +#define DEBUG_ 293 +#define DEGREES_ 294 +#define DELETE_ 295 +#define DETECTOR_ 296 +#define DIAMOND_ 297 +#define ECLIPTIC_ 298 +#define EDIT_ 299 +#define ELLIPSE_ 300 +#define END_ 301 +#define EPANDA_ 302 +#define FALSE_ 303 +#define FIELD_ 304 +#define FIXED_ 305 +#define FK4_ 306 +#define FK4_NO_E_ 307 +#define FK5_ 308 +#define FONT_ 309 +#define GALACTIC_ 310 +#define GLOBAL_ 311 +#define HELIOECLIPTIC_ 312 +#define HIGHLITE_ 313 +#define ICRS_ 314 +#define IGNORE_ 315 +#define IMAGE_ 316 +#define INCLUDE_ 317 +#define J2000_ 318 +#define KEY_ 319 +#define LINE_ 320 +#define LINEAR_ 321 +#define MOVE_ 322 +#define N_ 323 +#define NO_ 324 +#define OFF_ 325 +#define ON_ 326 +#define PHYSICAL_ 327 +#define PIE_ 328 +#define PIXELS_ 329 +#define POINT_ 330 +#define POLYGON_ 331 +#define PROJECTION_ 332 +#define PROPERTY_ 333 +#define ROTATE_ 334 +#define ROTBOX_ 335 +#define RULER_ 336 +#define SEGMENT_ 337 +#define SELECT_ 338 +#define SOURCE_ 339 +#define SUPERGALACTIC_ 340 +#define TAG_ 341 +#define TEXT_ 342 +#define TEXTANGLE_ 343 +#define TEXTROTATE_ 344 +#define TILE_ 345 +#define TRUE_ 346 +#define VECTOR_ 347 +#define VERSION_ 348 +#define UNHIGHLITE_ 349 +#define UNSELECT_ 350 +#define UPDATE_ 351 +#define WCS_ 352 +#define WCSA_ 353 +#define WCSB_ 354 +#define WCSC_ 355 +#define WCSD_ 356 +#define WCSE_ 357 +#define WCSF_ 358 +#define WCSG_ 359 +#define WCSH_ 360 +#define WCSI_ 361 +#define WCSJ_ 362 +#define WCSK_ 363 +#define WCSL_ 364 +#define WCSM_ 365 +#define WCSN_ 366 +#define WCSO_ 367 +#define WCSP_ 368 +#define WCSQ_ 369 +#define WCSR_ 370 +#define WCSS_ 371 +#define WCST_ 372 +#define WCSU_ 373 +#define WCSV_ 374 +#define WCSW_ 375 +#define WCSX_ 376 +#define WCSY_ 377 +#define WCSZ_ 378 +#define WCS0_ 379 +#define WIDTH_ 380 +#define X_ 381 +#define Y_ 382 +#define YES_ 383 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 136 "frame/ds9parser.Y" +{ +#define MKBUFSIZE 2048 + double real; + int integer; + char str[MKBUFSIZE]; + double vector[3]; +} +/* Line 1529 of yacc.c. */ +#line 313 "frame/ds9parser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/frame/ds9parser.Y b/tksao/frame/ds9parser.Y new file mode 100644 index 0000000..76d5f66 --- /dev/null +++ b/tksao/frame/ds9parser.Y @@ -0,0 +1,1566 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {Base* fr} +%lex-param {mkFlexLexer* ll} +%parse-param {mkFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#define FITSPTR (fr->findFits(globalTile)) +#define DISCARD_(x) {yyclearin; mkDiscard(x);} + +#include +#include +#include + +#include "base.h" +#include "fitsimage.h" +#include "basemarker.h" +#include "point.h" + +#undef yyFlexLexer +#define yyFlexLexer mkFlexLexer +#include + +extern int mklex(void*, mkFlexLexer*); +extern void mkerror(Base*, mkFlexLexer*, const char*); +extern void mkDiscard(int); + +static Coord::CoordSystem globalWCS; + +static Coord::CoordSystem globalSystem; +static Coord::CoordSystem localSystem; +static Coord::SkyFrame globalSky; +static Coord::SkyFrame localSky; + +static int globalTile; + +static unsigned short globalProps; +static unsigned short localProps; + +static int globalDash[2]; +static int localDash[2]; + +static int globalWidth; +static int localWidth; + +static char globalColor[16]; +static char localColor[16]; + +static char globalFont[32]; +static char localFont[32]; + +static char globalText[80]; +static char localText[80]; + +static char localComment[80]; + +static int globalLine1; +static int localLine1; +static int globalLine2; +static int localLine2; + +static int globalVector; +static int localVector; + +static int globalComposite; +static int localComposite; + +static int globalPoint; +static int localPoint; +static int globalPointSize; +static int localPointSize; + +static double globalTextAngle; +static double localTextAngle; +static int globalTextRotate; +static int localTextRotate; + +static Coord::CoordSystem globalRulerCoordSystem; +static Coord::CoordSystem localRulerCoordSystem; +static Coord::SkyFrame globalRulerSkyFrame; +static Coord::SkyFrame localRulerSkyFrame; +static Coord::CoordSystem globalRulerDistSystem; +static Coord::CoordSystem localRulerDistSystem; +static Coord::SkyDist globalRulerDistFormat; +static Coord::SkyDist localRulerDistFormat; + +static Coord::CoordSystem globalCompassCoordSystem; +static Coord::SkyFrame globalCompassSkyFrame; +static char globalCompassNorth[80]; +static char globalCompassEast[80]; +static int globalCompassNArrow; +static int globalCompassEArrow; +static Coord::CoordSystem localCompassCoordSystem; +static Coord::SkyFrame localCompassSkyFrame; +static char localCompassNorth[80]; +static char localCompassEast[80]; +static int localCompassNArrow; +static int localCompassEArrow; + +static int localCpanda; +static int localEpanda; +static int localBpanda; + +static List polylist; +static List taglist; +static List cblist; + +static double aAnnuli[MAXANNULI]; +static Vector aVector[MAXANNULI]; +static int aNum; +static int aNumsao; +static int aStatus; +static int cStatus; +static Vector aCenter; +static double aAngles[MAXANGLES]; +static int aAngNum; +static double aAngle; +static unsigned short aProps; +static char aColor[16]; +static int aWidth; +static int aDash[2]; +static char aFont[32]; +static char aText[80]; +static char aComment[80]; + +static void setProps(unsigned short* props, unsigned short prop, int value); +static Coord::CoordSystem checkWCSSystem(); +static Coord::SkyFrame checkWCSSky(); +%} + +%union { +#define MKBUFSIZE 2048 + double real; + int integer; + char str[MKBUFSIZE]; + double vector[3]; +} + +%type numeric +%type yesno + +%type angle +%type optangle +%type value +%type vvalue +%type sexagesimal +%type hms +%type dms +%type coord +%type coordSystem +%type wcsSystem +%type skyFrame +%type skyDist +%type property +%type callBack +%type pointShape +%type numberof + +%token INT +%token REAL +%token STRING + +%token ANGDEGREE +%token ANGRADIAN +%token ARCMINUTE +%token ARCSECOND +%token PHYCOORD +%token IMGCOORD + +%token SEXSTR +%token HMSSTR +%token DMSSTR + +%token EOF_ + +%token AMPLIFIER_ +%token ANNULUS_ +%token ARCMIN_ +%token ARCSEC_ +%token ARROW_ +%token B1950_ +%token BACKGROUND_ +%token BEGIN_ +%token BOX_ +%token BOXCIRCLE_ +%token BPANDA_ +%token CALLBACK_ +%token CIRCLE_ +%token CIRCLE3D_ +%token COLOR_ +%token COMPASS_ +%token COMPOSITE_ +%token CPANDA_ +%token CROSS_ +%token DASH_ +%token DASHLIST_ +%token DEBUG_ +%token DEGREES_ +%token DELETE_ +%token DETECTOR_ +%token DIAMOND_ +%token ECLIPTIC_ +%token EDIT_ +%token ELLIPSE_ +%token END_ +%token EPANDA_ +%token FALSE_ +%token FIELD_ +%token FIXED_ +%token FK4_ +%token FK4_NO_E_ +%token FK5_ +%token FONT_ +%token GALACTIC_ +%token GLOBAL_ +%token HELIOECLIPTIC_ +%token HIGHLITE_ +%token ICRS_ +%token IGNORE_ +%token IMAGE_ +%token INCLUDE_ +%token J2000_ +%token KEY_ +%token LINE_ +%token LINEAR_ +%token MOVE_ +%token N_ +%token NO_ +%token OFF_ +%token ON_ +%token PHYSICAL_ +%token PIE_ +%token PIXELS_ +%token POINT_ +%token POLYGON_ +%token PROJECTION_ +%token PROPERTY_ +%token ROTATE_ +%token ROTBOX_ +%token RULER_ +%token SEGMENT_ +%token SELECT_ +%token SOURCE_ +%token SUPERGALACTIC_ +%token TAG_ +%token TEXT_ +%token TEXTANGLE_ +%token TEXTROTATE_ +%token TILE_ +%token TRUE_ +%token VECTOR_ +%token VERSION_ +%token UNHIGHLITE_ +%token UNSELECT_ +%token UPDATE_ +%token WCS_ +%token WCSA_ +%token WCSB_ +%token WCSC_ +%token WCSD_ +%token WCSE_ +%token WCSF_ +%token WCSG_ +%token WCSH_ +%token WCSI_ +%token WCSJ_ +%token WCSK_ +%token WCSL_ +%token WCSM_ +%token WCSN_ +%token WCSO_ +%token WCSP_ +%token WCSQ_ +%token WCSR_ +%token WCSS_ +%token WCST_ +%token WCSU_ +%token WCSV_ +%token WCSW_ +%token WCSX_ +%token WCSY_ +%token WCSZ_ +%token WCS0_ +%token WIDTH_ +%token X_ +%token Y_ +%token YES_ + +%% + +start : initGlobal commands postLocal + ; + +commands: commands command terminator + | command terminator + ; + +command : /* empty */ + | DEBUG_ debug + | VERSION_ {cerr << "DS9 Regions File 3.2" << endl;} + + | GLOBAL_ global comment + | TILE_ INT {globalTile = $2;} + + | coordSystem {globalSystem=(Coord::CoordSystem)$1;} comment + | skyFrame {globalSystem=globalWCS; globalSky=(Coord::SkyFrame)$1;} comment + | LINEAR_ {globalSystem=globalWCS; globalSky=Coord::FK5;} comment + + | initLocal shape + | initLocal include shape + | initLocal '#' hash + ; + +hash : nonshape + | include nonshape + | TILE_ INT {globalTile = $2;} + | {DISCARD_(1);} STRING + ; + +comment : /* empty */ + | '#' {DISCARD_(1);} STRING + ; + +shapeComment : /* empty */ postLocal + | '#' {DISCARD_(1);} STRING postLocal {strncpy(localComment,$3,80);} + | '#' local postLocal + | '#' local {DISCARD_(1);} STRING postLocal {strncpy(localComment,$4,80);} + ; + +nonshapeComment : /* empty */ postLocal + | {DISCARD_(1);} STRING postLocal {strncpy(localComment,$2,80);} + | local postLocal + | local {DISCARD_(1);} STRING postLocal {strncpy(localComment,$3,80);} + ; + +terminator: '\n' + | ';' + | EOF_ {YYACCEPT;} + ; + +numeric : REAL {$$=$1;} + | INT {$$=$1;} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + ; + +yesno : INT {$$=($1 ? 1 : 0);} + + | YES_ {$$=1;} + | Y_ {$$=1;} + | ON_ {$$=1;} + | TRUE_ {$$=1;} + + | NO_ {$$=0;} + | N_ {$$=0;} + | OFF_ {$$=0;} + | FALSE_ {$$=0;} + ; + +sp : /* empty */ + | ',' + ; + +bp : /* empty */ + | '(' + ; + +ep : /* emtpy */ + | ')' + ; + +conjunction : /* empty */ {cStatus = 0;} + | '|' {cStatus = 1;} + | '|' '|' {cStatus = 1;} + ; + +optangle: /* empty */ {$$ = fr->mapAngleToRef(0,localSystem,localSky);} + | angle {$$ = $1;} + ; + +angle : numeric {$$ = fr->mapAngleToRef(degToRad($1),localSystem,localSky);} + | ANGDEGREE {$$ = fr->mapAngleToRef(degToRad($1),localSystem,localSky);} + | ANGRADIAN {$$ = fr->mapAngleToRef($1,localSystem,localSky);} + ; + +value : numeric {$$ = FITSPTR->mapLenToRef($1, localSystem, Coord::DEGREE);} + | PHYCOORD {$$ = FITSPTR->mapLenToRef($1, Coord::PHYSICAL);} + | IMGCOORD {$$ = FITSPTR->mapLenToRef($1, Coord::IMAGE);} + | ANGDEGREE {$$ = FITSPTR->mapLenToRef($1, checkWCSSystem(), Coord::DEGREE);} + | ARCMINUTE {$$ = FITSPTR->mapLenToRef($1, checkWCSSystem(), Coord::ARCMIN);} + | ARCSECOND {$$ = FITSPTR->mapLenToRef($1, checkWCSSystem(), Coord::ARCSEC);} + ; + +vvalue : numeric sp numeric + { + Vector r = FITSPTR->mapLenToRef(Vector($1,$3), localSystem, Coord::DEGREE); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | PHYCOORD sp PHYCOORD + { + Vector r = FITSPTR->mapLenToRef(Vector($1,$3), Coord::PHYSICAL); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | IMGCOORD sp IMGCOORD + { + Vector r = FITSPTR->mapLenToRef(Vector($1,$3), Coord::IMAGE); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | ANGDEGREE sp ANGDEGREE + { + Vector r=FITSPTR->mapLenToRef(Vector($1,$3),checkWCSSystem(),Coord::DEGREE); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | ARCMINUTE sp ARCMINUTE + { + Vector r=FITSPTR->mapLenToRef(Vector($1,$3),checkWCSSystem(),Coord::ARCMIN); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | ARCSECOND sp ARCSECOND + { + Vector r=FITSPTR->mapLenToRef(Vector($1,$3),checkWCSSystem(),Coord::ARCSEC); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + ; + +numberof: N_ '=' INT {$$ = $3;} + ; + +sexagesimal: SEXSTR {$$ = parseSEXStr($1);} + ; + +hms : HMSSTR {$$ = parseHMSStr($1);} + ; + +dms : DMSSTR {$$ = parseDMSStr($1);} + ; + +coord : sexagesimal sp sexagesimal + { + Vector r; + Coord::CoordSystem sys = checkWCSSystem(); + Coord::SkyFrame sky = checkWCSSky(); + if (sky == Coord::GALACTIC || sky == Coord::ECLIPTIC) + r = FITSPTR->mapToRef(Vector($1,$3), sys, sky); + else + r = FITSPTR->mapToRef(Vector($1*360./24.,$3), sys, sky); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | hms sp dms + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), + checkWCSSystem(), checkWCSSky()); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | dms sp dms + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), + checkWCSSystem(), checkWCSSky()); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | numeric sp numeric + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), localSystem, localSky); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | ANGDEGREE sp ANGDEGREE + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), + checkWCSSystem(), checkWCSSky()); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | IMGCOORD sp IMGCOORD + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), Coord::IMAGE); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | PHYCOORD sp PHYCOORD + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), Coord::PHYSICAL); + $$[0] = r[0]; + $$[1] = r[1]; + } + ; + +coordSystem :IMAGE_ {$$ = Coord::IMAGE;} + | PHYSICAL_ {$$ = Coord::PHYSICAL;} + | DETECTOR_ {$$ = Coord::DETECTOR;} + | AMPLIFIER_ {$$ = Coord::AMPLIFIER;} + | wcsSystem {$$ = $1; globalWCS = (Coord::CoordSystem)$1;} + ; + +wcsSystem : WCS_ {$$ = Coord::WCS;} + | WCSA_ {$$ = Coord::WCSA;} + | WCSB_ {$$ = Coord::WCSB;} + | WCSC_ {$$ = Coord::WCSC;} + | WCSD_ {$$ = Coord::WCSD;} + | WCSE_ {$$ = Coord::WCSE;} + | WCSF_ {$$ = Coord::WCSF;} + | WCSG_ {$$ = Coord::WCSG;} + | WCSH_ {$$ = Coord::WCSH;} + | WCSI_ {$$ = Coord::WCSI;} + | WCSJ_ {$$ = Coord::WCSJ;} + | WCSK_ {$$ = Coord::WCSK;} + | WCSL_ {$$ = Coord::WCSL;} + | WCSM_ {$$ = Coord::WCSM;} + | WCSN_ {$$ = Coord::WCSN;} + | WCSO_ {$$ = Coord::WCSO;} + | WCSP_ {$$ = Coord::WCSP;} + | WCSQ_ {$$ = Coord::WCSQ;} + | WCSR_ {$$ = Coord::WCSR;} + | WCSS_ {$$ = Coord::WCSS;} + | WCST_ {$$ = Coord::WCST;} + | WCSU_ {$$ = Coord::WCSU;} + | WCSV_ {$$ = Coord::WCSV;} + | WCSW_ {$$ = Coord::WCSW;} + | WCSX_ {$$ = Coord::WCSX;} + | WCSY_ {$$ = Coord::WCSY;} + | WCSZ_ {$$ = Coord::WCSZ;} + | WCS0_ {$$ = Coord::WCS0;} + ; + +skyFrame : FK4_ {$$ = Coord::FK4;} + | B1950_ {$$ = Coord::FK4;} + | FK4_NO_E_ {$$ = Coord::FK4_NO_E;} + | FK5_ {$$ = Coord::FK5;} + | J2000_ {$$ = Coord::FK5;} + | ICRS_ {$$ = Coord::ICRS;} + | GALACTIC_ {$$ = Coord::GALACTIC;} + | SUPERGALACTIC_ {$$ = Coord::SUPERGALACTIC;} + | ECLIPTIC_ {$$ = Coord::ECLIPTIC;} + | HELIOECLIPTIC_ {$$ = Coord::HELIOECLIPTIC;} + ; + +skyDist : DEGREES_ {$$=Coord::DEGREE;} + | ARCMIN_ {$$=Coord::ARCMIN;} + | ARCSEC_ {$$=Coord::ARCSEC;} + ; + +property : SELECT_ {$$ = Marker::SELECT;} + | HIGHLITE_ {$$ = Marker::HIGHLITE;} + | DASH_ {$$ = Marker::DASH;} + | FIXED_ {$$ = Marker::FIXED;} + | EDIT_ {$$ = Marker::EDIT;} + | MOVE_ {$$ = Marker::MOVE;} + | ROTATE_ {$$ = Marker::ROTATE;} + | DELETE_ {$$ = Marker::DELETE;} + | INCLUDE_ {$$ = Marker::INCLUDE;} + | SOURCE_ {$$ = Marker::SOURCE;} + ; + +callBack : SELECT_ {$$ = CallBack::SELECTCB;} + | UNSELECT_ {$$ = CallBack::UNSELECTCB;} + | HIGHLITE_ {$$ = CallBack::HIGHLITECB;} + | UNHIGHLITE_ {$$ = CallBack::UNHIGHLITECB;} + | BEGIN_ MOVE_ {$$ = CallBack::MOVEBEGINCB;} + | MOVE_ {$$ = CallBack::MOVECB;} + | END_ MOVE_ {$$ = CallBack::MOVEENDCB;} + | BEGIN_ EDIT_ {$$ = CallBack::EDITBEGINCB;} + | EDIT_ {$$ = CallBack::EDITCB;} + | END_ EDIT_ {$$ = CallBack::EDITENDCB;} + | BEGIN_ ROTATE_ {$$ = CallBack::ROTATEBEGINCB;} + | ROTATE_ {$$ = CallBack::ROTATECB;} + | END_ ROTATE_ {$$ = CallBack::ROTATEENDCB;} + | DELETE_ {$$ = CallBack::DELETECB;} + | TEXT_ {$$ = CallBack::TEXTCB;} + | COLOR_ {$$ = CallBack::COLORCB;} + | WIDTH_ {$$ = CallBack::LINEWIDTHCB;} + | PROPERTY_ {$$ = CallBack::PROPERTYCB;} + | FONT_ {$$ = CallBack::FONTCB;} + | KEY_ {$$ = CallBack::KEYCB;} + | UPDATE_ {$$ = CallBack::UPDATECB;} + ; + +global : global sp globalProperty + | globalProperty + ; + +globalProperty : property '=' yesno + { + setProps(&globalProps,$1,$3); + setProps(&localProps,$1,$3); + } + | COLOR_ '=' STRING + { + strncpy(globalColor,$3,16); + strncpy(localColor,$3,16); + } + | DASHLIST_ '=' INT INT + { + globalDash[0] = localDash[0] =$3; + globalDash[1] = localDash[1] =$4; + } + | WIDTH_ '=' INT {globalWidth = localWidth = $3;} + | FONT_ '=' STRING + { + strncpy(globalFont,$3,32); + strncpy(localFont,$3,32); + } + | TEXT_ '=' STRING + { + strncpy(globalText,$3,80); + strncpy(localText,$3,80); + } + | DASH_ + { + setProps(&globalProps,Marker::DASH,1); + setProps(&localProps,Marker::DASH,1); + } + | SOURCE_ + { + setProps(&globalProps,Marker::SOURCE,1); + setProps(&localProps,Marker::SOURCE,1); + } + | BACKGROUND_ + { + setProps(&globalProps,Marker::SOURCE,0); + setProps(&localProps,Marker::SOURCE,0); + } + | POINT_ '=' pointShape {globalPoint = localPoint = $3;} + | POINT_ '=' pointShape INT + { + globalPoint = localPoint = $3; + globalPointSize = localPointSize = $4; + } + | LINE_ '=' INT INT + { + globalLine1 = localLine1 = $3; + globalLine2 = localLine2 = $4; + } + | VECTOR_ '=' INT {globalVector = localVector = $3;} + | COMPOSITE_ '=' INT + { + globalComposite = localComposite = $3; + } + | RULER_ '=' globalRuler {} + | COMPASS_ '=' globalCompass STRING STRING INT INT + { + strncpy(globalCompassNorth,$4,80); + strncpy(globalCompassEast,$5,80); + strncpy(localCompassNorth,$4,80); + strncpy(localCompassEast,$5,80); + globalCompassNArrow = localCompassNArrow = $6; + globalCompassEArrow = localCompassEArrow = $7; + } + | TEXTANGLE_ '=' angle {globalTextAngle = localTextAngle = $3;} + | TEXTROTATE_ '=' INT {globalTextRotate = localTextRotate = $3;} + | WCS_ '=' wcsSystem {globalWCS = (Coord::CoordSystem)$3;} + ; + +globalRuler : coordSystem skyFrame coordSystem skyDist + { + globalRulerCoordSystem = localRulerCoordSystem = (Coord::CoordSystem)$1; + globalRulerSkyFrame = localRulerSkyFrame = (Coord::SkyFrame)$2; + globalRulerDistSystem = localRulerDistSystem = (Coord::CoordSystem)$3; + globalRulerDistFormat = localRulerDistFormat = (Coord::SkyDist)$4; + } + | coordSystem coordSystem + { + globalRulerCoordSystem = localRulerCoordSystem = (Coord::CoordSystem)$1; + globalRulerSkyFrame = localRulerSkyFrame = Coord::FK5; + globalRulerDistSystem = localRulerDistSystem = (Coord::CoordSystem)$2; + globalRulerDistFormat = localRulerDistFormat = Coord::DEGREE; + } + | coordSystem skyDist + { + globalRulerCoordSystem = localRulerCoordSystem = (Coord::CoordSystem)$1; + globalRulerSkyFrame = localRulerSkyFrame = Coord::FK5; + globalRulerDistSystem = localRulerDistSystem = Coord::WCS; + globalRulerDistFormat = localRulerDistFormat = (Coord::SkyDist)$2; + } + | skyFrame coordSystem + { + globalRulerCoordSystem = localRulerCoordSystem = Coord::WCS; + globalRulerSkyFrame = localRulerSkyFrame = (Coord::SkyFrame)$1; + globalRulerDistSystem = localRulerDistSystem = (Coord::CoordSystem)$2; + globalRulerDistFormat = localRulerDistFormat = Coord::DEGREE; + } + | skyFrame skyDist + { + globalRulerCoordSystem = localRulerCoordSystem = Coord::WCS; + globalRulerSkyFrame = localRulerSkyFrame = (Coord::SkyFrame)$1; + globalRulerDistSystem = localRulerDistSystem = Coord::WCS; + globalRulerDistFormat = localRulerDistFormat = (Coord::SkyDist)$2; + } + | LINEAR_ coordSystem + { + globalRulerCoordSystem = localRulerCoordSystem = Coord::WCS; + globalRulerSkyFrame = localRulerSkyFrame = Coord::FK5; + globalRulerDistSystem = localRulerDistSystem = (Coord::CoordSystem)$2; + globalRulerDistFormat = localRulerDistFormat = Coord::DEGREE; + } + | LINEAR_ skyDist + { + globalRulerCoordSystem = localRulerCoordSystem = Coord::WCS; + globalRulerSkyFrame = localRulerSkyFrame = Coord::FK5; + globalRulerDistSystem = localRulerDistSystem = Coord::WCS; + globalRulerDistFormat = localRulerDistFormat = (Coord::SkyDist)$2; + } + | skyDist + { + globalRulerCoordSystem = localRulerCoordSystem = Coord::IMAGE; + globalRulerSkyFrame = localRulerSkyFrame = Coord::FK5; + globalRulerDistSystem = localRulerDistSystem = Coord::WCS; + globalRulerDistFormat = localRulerDistFormat = (Coord::SkyDist)$1; + } + | PIXELS_ + { + globalRulerCoordSystem = localRulerCoordSystem = Coord::IMAGE; + globalRulerSkyFrame = localRulerSkyFrame = Coord::FK5; + globalRulerDistSystem = localRulerDistSystem = Coord::IMAGE; + globalRulerDistFormat = localRulerDistFormat = Coord::DEGREE; + } + ; + +globalCompass : coordSystem skyFrame + { + globalCompassCoordSystem = localCompassCoordSystem = (Coord::CoordSystem)$1; + globalCompassSkyFrame = localCompassSkyFrame = (Coord::SkyFrame)$2; + } + | coordSystem + { + globalCompassCoordSystem = localCompassCoordSystem = (Coord::CoordSystem)$1; + globalCompassSkyFrame = localCompassSkyFrame = Coord::FK5; + } + | skyFrame + { + globalCompassCoordSystem = localCompassCoordSystem = Coord::WCS; + globalCompassSkyFrame = localCompassSkyFrame = (Coord::SkyFrame)$1; + } + | LINEAR_ + { + globalCompassCoordSystem = localCompassCoordSystem = Coord::WCS; + globalCompassSkyFrame = localCompassSkyFrame = Coord::FK5; + } + ; + +initGlobal:{ + // global properties + globalSystem = Coord::PHYSICAL; + globalWCS = fr->wcsSystem(); + globalSky = fr->wcsSky(); + globalTile = 1; + globalProps = + Marker::SELECT | Marker::EDIT | Marker::MOVE | + Marker::ROTATE | Marker::DELETE | Marker::HIGHLITE | + Marker::INCLUDE | Marker::SOURCE; + strcpy(globalColor,"green"); + globalDash[0] = 8; + globalDash[1] = 3; + globalWidth = 1; + strcpy(globalFont,"helvetica 10 normal roman"); + strcpy(globalText,""); + + // unique properties + globalLine1 = 0; + globalLine2 = 0; + globalVector = 1; + globalComposite = 1; + globalRulerCoordSystem = Coord::PHYSICAL; + globalRulerSkyFrame = Coord::FK5; + globalRulerDistSystem = Coord::PHYSICAL; + globalRulerDistFormat = Coord::DEGREE; + globalCompassCoordSystem = Coord::PHYSICAL; + globalCompassSkyFrame = Coord::FK5; + strcpy(globalCompassNorth,"N"); + strcpy(globalCompassEast,"E"); + globalCompassNArrow = 1; + globalCompassEArrow = 1; + globalPoint = Point::BOXCIRCLE; + globalPointSize = POINTSIZE; + globalTextAngle=0; + globalTextRotate=1; + + aStatus = 0; + cStatus = 0; + } + ; + +local : local sp localProperty + | localProperty + ; + +localProperty : property '=' yesno {setProps(&localProps,$1,$3);} + | COLOR_ '=' STRING {strncpy(localColor,$3,16);} + | DASHLIST_ '=' INT INT + { + localDash[0] =$3; + localDash[1] =$4; + } + | WIDTH_ '=' INT {localWidth = $3;} + | FONT_ '=' STRING {strncpy(localFont,$3,32);} + | TEXT_ '=' STRING {strncpy(localText,$3,80);} + | TAG_ '=' STRING {taglist.append(new Tag($3));} + | CALLBACK_ '=' callBack STRING STRING {cblist.append( + new CallBack(fr->getInterp(),(CallBack::Type)$3,$4,$5));} + | DASH_ {setProps(&localProps,Marker::DASH,1);} + | SOURCE_ {setProps(&localProps,Marker::SOURCE,1);} + | BACKGROUND_ {setProps(&localProps,Marker::SOURCE,0);} + + | POINT_ '=' pointShape {localPoint = $3;} + | POINT_ '=' pointShape INT {localPoint = $3; localPointSize = $4;} + | LINE_ '=' INT INT {localLine1=$3; localLine2=$4;} + | VECTOR_ '=' INT {localVector=$3;} + | COMPOSITE_ '=' INT {localComposite=$3;} + | RULER_ '=' localRuler + | COMPASS_ '=' localCompass STRING STRING INT INT + { + strncpy(localCompassNorth,$4,80); + strncpy(localCompassEast,$5,80); + localCompassNArrow = $6; + localCompassEArrow = $7; + } + | TEXTANGLE_ '=' angle {localTextAngle=$3;} + | TEXTROTATE_ '=' INT {localTextRotate=$3;} + | CPANDA_ '=' localCpanda + | EPANDA_ '=' localEpanda + | BPANDA_ '=' localBpanda + ; + +localRuler : coordSystem skyFrame coordSystem skyDist + { + localRulerCoordSystem = (Coord::CoordSystem)$1; + localRulerSkyFrame = (Coord::SkyFrame)$2; + localRulerDistSystem = (Coord::CoordSystem)$3; + localRulerDistFormat = (Coord::SkyDist)$4; + } + | coordSystem coordSystem + { + localRulerCoordSystem = (Coord::CoordSystem)$1; + localRulerSkyFrame = Coord::FK5; + localRulerDistSystem = (Coord::CoordSystem)$2; + localRulerDistFormat = Coord::DEGREE; + } + | coordSystem skyDist + { + localRulerCoordSystem = (Coord::CoordSystem)$1; + localRulerSkyFrame = Coord::FK5; + localRulerDistSystem = Coord::WCS; + localRulerDistFormat = (Coord::SkyDist)$2; + } + | skyFrame coordSystem + { + localRulerCoordSystem = Coord::WCS; + localRulerSkyFrame = (Coord::SkyFrame)$1; + localRulerDistSystem = (Coord::CoordSystem)$2; + localRulerDistFormat = Coord::DEGREE; + } + | skyFrame skyDist + { + localRulerCoordSystem = Coord::WCS; + localRulerSkyFrame = (Coord::SkyFrame)$1; + localRulerDistSystem = Coord::WCS; + localRulerDistFormat = (Coord::SkyDist)$2; + } + | LINEAR_ coordSystem + { + localRulerCoordSystem = Coord::WCS; + localRulerSkyFrame = Coord::FK5; + localRulerDistSystem = (Coord::CoordSystem)$2; + localRulerDistFormat = Coord::DEGREE; + } + | LINEAR_ skyDist + { + localRulerCoordSystem = Coord::WCS; + localRulerSkyFrame = Coord::FK5; + localRulerDistSystem = Coord::WCS; + localRulerDistFormat = (Coord::SkyDist)$2; + } + | skyDist + { + localRulerCoordSystem = Coord::IMAGE; + localRulerSkyFrame = Coord::FK5; + localRulerDistSystem = Coord::WCS; + localRulerDistFormat = (Coord::SkyDist)$1; + } + | PIXELS_ + { + localRulerCoordSystem = Coord::IMAGE; + localRulerSkyFrame = Coord::FK5; + localRulerDistSystem = Coord::IMAGE; + localRulerDistFormat = Coord::DEGREE; + } + ; + +localCompass : coordSystem skyFrame + { + localCompassCoordSystem = (Coord::CoordSystem)$1; + localCompassSkyFrame = (Coord::SkyFrame)$2; + } + | coordSystem + { + localCompassCoordSystem = (Coord::CoordSystem)$1; + localCompassSkyFrame = Coord::FK5; + } + | skyFrame + { + localCompassCoordSystem = Coord::WCS; + localCompassSkyFrame = (Coord::SkyFrame)$1; + } + | LINEAR_ + { + localCompassCoordSystem = Coord::WCS; + localCompassSkyFrame = Coord::FK5; + } + ; + +localCpanda: {aNum=0; aAngNum=0;} '(' aAngs ')' '(' aRads ')' {localCpanda = 2;} + | IGNORE_ {localCpanda=0;} + ; + +localEpanda: {aNum=0; aAngNum=0, aAngle=0;} + '(' aAngs ')' '(' vRads ')' '(' angle ')' {aAngle=$9;localEpanda=2;} + | IGNORE_ {localEpanda=0;} + ; + +localBpanda: {aNum=0; aAngNum=0, aAngle=0;} + '(' aAngs ')' '(' vRads ')' '(' angle ')' {aAngle=$9;localBpanda=2;} + | IGNORE_ {localBpanda=0;} + ; + +initLocal : { + // reset maperr flag + maperr = 0; + + // needed for annulus, ellipse annulus, and box annulus + aNum = 2; + + // composite (previous conjunction found?) + if (!cStatus) fr->resetCompositeMarker(); + + // global properties + localSystem = globalSystem; + localSky = globalSky; + localProps = globalProps; + strcpy(localColor,globalColor); + localDash[0] = globalDash[0]; + localDash[1] = globalDash[1]; + localWidth = globalWidth; + strcpy(localFont,globalFont); + strcpy(localText,globalText); + strcpy(localComment,""); + taglist.deleteAll(); + cblist.deleteAll(); + + // unique properties + localLine1 = globalLine1; + localLine2 = globalLine2; + localVector = globalVector; + localComposite = globalComposite; + localPoint = globalPoint; + localPointSize = globalPointSize; + localRulerCoordSystem = globalRulerCoordSystem; + localRulerSkyFrame = globalRulerSkyFrame; + localRulerDistSystem = globalRulerDistSystem; + localRulerDistFormat = globalRulerDistFormat; + localCompassCoordSystem = globalCompassCoordSystem; + localCompassSkyFrame = globalCompassSkyFrame; + strcpy(localCompassNorth,globalCompassNorth); + strcpy(localCompassEast,globalCompassEast); + localCompassNArrow = globalCompassNArrow; + localCompassEArrow = globalCompassEArrow; + localTextAngle = globalTextAngle; + localTextRotate = globalTextRotate; + localCpanda = 1; + localEpanda = 1; + localBpanda = 1; + } + ; + +pointShape : CIRCLE_ {$$ = Point::CIRCLE;} + | BOX_ {$$ = Point::BOX;} + | DIAMOND_ {$$ = Point::DIAMOND;} + | CROSS_ {$$ = Point::CROSS;} + | X_ {$$ = Point::EX;} + | ARROW_ {$$ = Point::ARROW;} + | BOXCIRCLE_ {$$ = Point::BOXCIRCLE;} + ; + +include : '+' {setProps(&localProps, Marker::INCLUDE, 1);} + | '-' {setProps(&localProps, Marker::INCLUDE, 0);} + ; + +nonshape : VECTOR_ bp coord sp value sp angle ep conjunction nonshapeComment + { + fr->createVectCmd(Vector($3), + $5,$7, + localVector, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | SEGMENT_ {polylist.deleteAll();} bp polyNodes ep conjunction + nonshapeComment + { + fr->createSegmentCmd(polylist, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | TEXT_ bp coord ep conjunction nonshapeComment + { + fr->createTextCmd(Vector($3), + localTextAngle,localTextRotate, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | RULER_ bp coord sp coord ep conjunction nonshapeComment + { + fr->createRulerCmd(Vector($3), + Vector($5), + localRulerCoordSystem, localRulerSkyFrame, + localRulerDistSystem, localRulerDistFormat, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | COMPASS_ bp coord sp value ep conjunction nonshapeComment + { + fr->createCompassCmd(Vector($3), + $5, + localCompassNorth, localCompassEast, + localCompassNArrow, localCompassEArrow, + localCompassCoordSystem, localCompassSkyFrame, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | PROJECTION_ bp coord sp coord sp value ep conjunction nonshapeComment + { + fr->createProjectionCmd(Vector($3), + Vector($5), + $7, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | CIRCLE3D_ bp coord sp value ep conjunction nonshapeComment + { + // backward compatibility + fr->createCircleCmd(Vector($3), + $5, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | COMPOSITE_ bp coord sp optangle ep conjunction nonshapeComment + { + fr->createCompositeCmd(Vector($3), + $5, localComposite, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + ; + +shape : CIRCLE_ bp coord sp value ep conjunction shapeComment + { + fr->createCircleCmd(Vector($3), + $5, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | CIRCLE3D_ bp coord sp value ep conjunction shapeComment + { + // backwards compatibility + fr->createCircleCmd(Vector($3), + $5, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | ELLIPSE_ bp coord sp vvalue sp optangle ep conjunction shapeComment + { + // for ellipse annulus + aStatus = 1; + aCenter = Vector($3); + aAngles[0] = $7; + aVector[0] = Vector($5); + aNumsao = 1; + strncpy(aColor,localColor,16); + aDash[0] = localDash[0]; + aDash[1] = localDash[1]; + aWidth = localWidth; + strncpy(aFont,localFont,32); + strncpy(aText,localText,80); + strncpy(aComment,localComment,80); + aProps = localProps; + + fr->createEllipseCmd(Vector($3), + Vector($5), + $7, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | BOX_ bp coord sp vvalue sp optangle ep conjunction shapeComment + { + // for box annulus + aStatus = 3; + aCenter = Vector($3); + aAngles[0] = $7; + aVector[0] = Vector($5); + aNumsao = 1; + strncpy(aColor,localColor,16); + aDash[0] = localDash[0]; + aDash[1] = localDash[1]; + aWidth = localWidth; + strncpy(aFont,localFont,32); + strncpy(aText,localText,80); + strncpy(aComment,localComment,80); + aProps = localProps; + + fr->createBoxCmd(Vector($3), + Vector($5), + $7, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | ROTBOX_ bp coord sp vvalue sp optangle ep conjunction shapeComment + { + // backwards compatibility + fr->createBoxCmd(Vector($3), + Vector($5), + $7, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | POLYGON_ {polylist.deleteAll();} bp polyNodes ep conjunction + shapeComment + { + fr->createPolygonCmd(polylist, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | SEGMENT_ {polylist.deleteAll();} bp polyNodes ep conjunction + shapeComment + { + fr->createSegmentCmd(polylist, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + + | LINE_ bp coord sp coord ep conjunction shapeComment + { + fr->createLineCmd(Vector($3), + Vector($5), + localLine1,localLine2, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | VECTOR_ bp coord sp value sp angle ep conjunction shapeComment + { + fr->createVectCmd(Vector($3), + $5,$7, + localVector, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | TEXT_ bp coord ep conjunction shapeComment + { + fr->createTextCmd(Vector($3), + localTextAngle,localTextRotate, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | TEXT_ bp coord sp STRING ep {strncpy(localText,$5,80);} conjunction + shapeComment + { + fr->createTextCmd(Vector($3), + localTextAngle,localTextRotate, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | POINT_ bp coord ep conjunction shapeComment + { + fr->createPointCmd(Vector($3), + (Point::PointShape)localPoint, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | CIRCLE_ POINT_ bp coord ep conjunction shapeComment + { + // backwards compatibility + fr->createPointCmd(Vector($4), Point::CIRCLE, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | BOX_ POINT_ bp coord ep conjunction shapeComment + { + // backwards compatibility + fr->createPointCmd(Vector($4), Point::BOX, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | DIAMOND_ POINT_ bp coord ep conjunction shapeComment + { + // backwards compatibility + fr->createPointCmd(Vector($4), Point::DIAMOND, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | CROSS_ POINT_ bp coord ep conjunction shapeComment + { + // backwards compatibility + fr->createPointCmd(Vector($4), Point::CROSS, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | X_ POINT_ bp coord ep conjunction shapeComment + { + // backwards compatibility + fr->createPointCmd(Vector($4), Point::EX, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | ARROW_ POINT_ bp coord ep conjunction shapeComment + { + // backwards compatibility + fr->createPointCmd(Vector($4), Point::ARROW, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | BOXCIRCLE_ POINT_ bp coord ep conjunction shapeComment + { + // backwards compatibility + fr->createPointCmd(Vector($4), Point::BOXCIRCLE, localPointSize, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | RULER_ bp coord sp coord ep conjunction shapeComment + { + fr->createRulerCmd(Vector($3), + Vector($5), + localRulerCoordSystem, localRulerSkyFrame, + localRulerDistSystem, localRulerDistFormat, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | COMPASS_ bp coord sp value ep conjunction shapeComment + { + fr->createCompassCmd(Vector($3), + $5, + localCompassNorth, localCompassEast, + localCompassNArrow, localCompassEArrow, + localCompassCoordSystem, localCompassSkyFrame, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | PROJECTION_ bp coord sp coord sp value ep conjunction shapeComment + { + fr->createProjectionCmd(Vector($3), + Vector($5), + $7, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | ANNULUS_ bp coord sp value sp value ep conjunction shapeComment + { + fr->createAnnulusCmd(Vector($3), + $5,$7,1, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | ANNULUS_ bp coord sp value sp value sp aRads ep conjunction + shapeComment + { + aAnnuli[0] = $5; + aAnnuli[1] = $7; + fr->createAnnulusCmd(Vector($3), + aNum,aAnnuli, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | ANNULUS_ bp coord sp value sp value sp numberof ep conjunction + shapeComment + { + fr->createAnnulusCmd(Vector($3), + $5,$7,$9, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | ELLIPSE_ bp coord sp vvalue sp vvalue sp optangle ep conjunction + shapeComment + { + // prefered syntax + fr->createEllipseAnnulusCmd(Vector($3), + Vector($5),Vector($7),1, + $9, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | ELLIPSE_ bp coord sp vvalue sp vvalue sp + numberof sp optangle ep conjunction shapeComment + { + // prefered syntax + fr->createEllipseAnnulusCmd(Vector($3), + Vector($5),Vector($7),$9, + $11, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | ELLIPSE_ bp coord sp vvalue sp vvalue sp + vRads sp optangle ep conjunction shapeComment + { + // prefered syntax + aVector[0] = Vector($5); + aVector[1] = Vector($7); + fr->createEllipseAnnulusCmd(Vector($3), + aNum,aVector, + $11, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | ELLIPSE_ bp coord sp vvalue sp optangle ep '&' '!' + ELLIPSE_ bp coord sp vvalue sp optangle ep + { + // backwards compatibility + // old saoimage syntax + aStatus = 2; + aVector[aNumsao++] = Vector($5); + } + | BOX_ bp coord sp vvalue sp vvalue sp optangle ep conjunction + shapeComment + { + // prefered syntax + fr->createBoxAnnulusCmd(Vector($3), + Vector($5),Vector($7),1, + $9, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | BOX_ bp coord sp vvalue sp vvalue sp + vRads sp optangle ep conjunction shapeComment + { + // prefered syntax + aVector[0] = Vector($5); + aVector[1] = Vector($7); + fr->createBoxAnnulusCmd(Vector($3), + aNum,aVector, + $11, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | BOX_ bp coord sp vvalue sp vvalue sp + numberof sp optangle ep conjunction shapeComment + { + // prefered syntax + fr->createBoxAnnulusCmd(Vector($3), + Vector($5),Vector($7),$9, + $11, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + | BOX_ bp coord sp vvalue sp optangle ep '&' '!' + BOX_ bp coord sp vvalue sp optangle ep + { + // backwards compatibility + // old saoimage syntax + aStatus = 4; + aVector[aNumsao++] = Vector($5); + } + + | CPANDA_ bp coord sp angle sp angle sp INT sp + value sp value sp INT ep conjunction shapeComment + { + switch (localCpanda) { + case 0: /* ignore it */ + break; + case 1: /* normal cpanda */ + fr->createCpandaCmd(Vector($3), + $5,$7,$9, + $11,$13,$15, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + break; + case 2: /* one of our special pandas */ + fr->createCpandaCmd(Vector($3), + aAngNum,aAngles, + aNum,aAnnuli, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + break; + } + } + | EPANDA_ bp coord sp angle sp angle sp INT sp + vvalue sp vvalue sp INT sp optangle ep conjunction shapeComment + { + switch (localEpanda) { + case 0: /* ignore it */ + break; + case 1: /* normal epanda */ + fr->createEpandaCmd(Vector($3), + $5,$7,$9, + Vector($11),Vector($13),$15, + $17, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + break; + case 2: /* one of our special pandas */ + fr->createEpandaCmd(Vector($3), + aAngNum,aAngles, + aNum,aVector, + aAngle, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + break; + } + } + | BPANDA_ bp coord sp angle sp angle sp INT sp + vvalue sp vvalue sp INT sp optangle ep conjunction shapeComment + { + switch (localBpanda) { + case 0: /* ignore it */ + break; + case 1: /* normal bpanda */ + fr->createBpandaCmd(Vector($3), + $5,$7,$9, + Vector($11),Vector($13),$15, + $17, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + break; + case 2: /* one of our special pandas */ + fr->createBpandaCmd(Vector($3), + aAngNum,aAngles, + aNum,aVector, + aAngle, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + break; + } + } + + | PIE_ bp coord sp angle sp angle ep conjunction shapeComment + | PIE_ bp coord sp angle sp angle sp aAngs ep conjunction shapeComment + | PIE_ bp coord sp angle sp angle sp numberof ep conjunction + shapeComment + | FIELD_ bp ep conjunction shapeComment + + | COMPOSITE_ bp coord sp optangle ep conjunction shapeComment + { + fr->createCompositeCmd(Vector($3), + $5, localComposite, + localColor,localDash,localWidth,localFont, + localText,localProps,localComment,taglist,cblist); + } + ; + +polyNodes : polyNodes sp polyNode + | polyNode + ; + +polyNode : coord {polylist.append(new Vertex($1));} + ; + +aRads : aRads sp aRad + | aRad + ; + +aRad : value + { + if (aNum < MAXANNULI) + aAnnuli[aNum++] = $1; + } + ; + +aAngs : aAngs sp aAng + | aAng + ; + +aAng : angle + { + if (aAngNum < MAXANGLES) + aAngles[aAngNum++] = $1; + } + ; + +vRads : vRads sp vRad + | vRad + ; + +vRad : value sp value {aVector[aNum++] = Vector($1,$3);} + ; + +postLocal : /* empty */ + { + // old style annulus + switch (aStatus) { + case 0: // do nothing + break; + case 1: // we found just an ellipse, do nothing + break; + case 2: // ok we have an ellipse annulus + fr->markerDeleteLastCmd(); // delete the previous ellipse + fr->createEllipseAnnulusCmd(aCenter, + aNumsao,aVector, + aAngles[0], + aColor,aDash,aWidth,aFont,aText,aProps,aComment,taglist,cblist); + break; + case 3: // we found just a box, do nothing + break; + case 4: // ok, we have a box annulus + fr->markerDeleteLastCmd(); // delete the previous box + fr->createBoxAnnulusCmd(aCenter, + aNumsao,aVector, + aAngles[0], + aColor,aDash,aWidth,aFont,aText,aProps,aComment,taglist,cblist); + break; + } + aStatus = 0; + } + ; +%% + +static void setProps(unsigned short* props, unsigned short prop, int value) +{ + if (value) + *props |= prop; + else + *props &= ~prop; +} + +static Coord::CoordSystem checkWCSSystem() +{ + switch (localSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::WCS; + default: + return localSystem; + } +} + +static Coord::SkyFrame checkWCSSky() +{ + switch (localSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::FK5; + default: + return localSky; + } +} + diff --git a/tksao/frame/ellipse.C b/tksao/frame/ellipse.C new file mode 100644 index 0000000..216ba06 --- /dev/null +++ b/tksao/frame/ellipse.C @@ -0,0 +1,388 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "ellipse.h" +#include "fitsimage.h" + +Ellipse::Ellipse(Base* p, const Vector& ctr, const Vector& r, double ang) + : BaseEllipse(p, ctr, ang) +{ + numAnnuli_ = 1; + annuli_ = new Vector[1]; + annuli_[0] = r; + + strcpy(type_,"ellipse"); + numHandle = 4; + + updateBBox(); +} + +Ellipse::Ellipse(Base* p, const Vector& ctr, + const Vector& r, double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BaseEllipse(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = 1; + annuli_ = new Vector[1]; + annuli_[0] = r; + + strcpy(type_,"ellipse"); + numHandle = 4; + + updateBBox(); +} + +Ellipse::Ellipse(const Ellipse& a) : BaseEllipse(a) {} + +void Ellipse::edit(const Vector& v, int h) +{ + Matrix mm = bckMatrix(); + annuli_[0] = (v * mm).abs(); + + updateBBox(); + doCallBack(CallBack::EDITCB); +} + +void Ellipse::analysis(AnalysisTask mm, int which) +{ + switch (mm) { + case HISTOGRAM: + if (!analysisHistogram_ && which) { + addCallBack(CallBack::MOVECB, analysisHistogramCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisHistogramCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisHistogramCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisHistogramCB_[1], + parent->options->cmdName); + } + if (analysisHistogram_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisHistogramCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisHistogramCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisHistogramCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisHistogramCB_[1]); + } + + analysisHistogram_ = which; + break; + case PLOT3D: + if (!analysisPlot3d_ && which) { + addCallBack(CallBack::MOVECB, analysisPlot3dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisPlot3dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisPlot3dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisPlot3dCB_[1], + parent->options->cmdName); + } + if (analysisPlot3d_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisPlot3dCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisPlot3dCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisPlot3dCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisPlot3dCB_[1]); + } + + analysisPlot3d_ = which; + break; + case STATS: + if (!analysisStats_ && which) { + addCallBack(CallBack::MOVECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisStatsCB_[1], + parent->options->cmdName); + } + if (analysisStats_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisStatsCB_[1]); + } + + analysisStats_ = which; + break; + default: + // na + break; + } +} + +void Ellipse::analysisHistogram(char* xname, char* yname, int num) +{ + double* x; + double* y; + Matrix mm = Rotate(angle) * Translate(center); + + Vector vv = annuli_[0]; + BBox bb(-vv * mm); + bb.bound( vv * mm); + bb.bound(Vector( vv[0],-vv[1]) * mm); + bb.bound(Vector(-vv[0], vv[1]) * mm); + + parent->markerAnalysisHistogram(this, &x, &y, bb, num); + analysisXYResult(xname, yname, x, y, num+1); +} + +void Ellipse::analysisPlot3d(char* xname, char* yname, + Coord::CoordSystem sys, + Marker::AnalysisMethod method) +{ + double* x; + double* y; + Matrix mm = Rotate(angle) * Translate(center); + + Vector vv = annuli_[0]; + BBox bb(-vv * mm); + bb.bound( vv * mm); + bb.bound(Vector( vv[0],-vv[1]) * mm); + bb.bound(Vector(-vv[0], vv[1]) * mm); + + int num = parent->markerAnalysisPlot3d(this, &x, &y, bb, sys, method); + analysisXYResult(xname, yname, x, y, num); +} + +void Ellipse::analysisStats(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + ostringstream str; + Matrix mm = Rotate(angle) * Translate(center); + + Vector vv = annuli_[0]; + BBox bb(-vv * mm); + bb.bound( vv * mm); + bb.bound(Vector( vv[0],-vv[1]) * mm); + bb.bound(Vector(-vv[0], vv[1]) * mm); + + parent->markerAnalysisStats(this, str, bb, sys, sky); + str << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +// list + +void Ellipse::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 0); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listNonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + Vector rr = ptr->mapLenFromRef(annuli_[0],sys,Coord::ARCSEC); + double aa = parent->mapAngleFromRef(angle,sys,sky); + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' + << setprecision(10) << vv << ',' + << setprecision(3) << fixed << setunit('"') << rr << ','; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(aa) << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' << setprecision(8) + << ra << ',' << dec << ',' + << setprecision(3) << fixed << setunit('"') << rr << ','; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(aa) << ')'; + break; + } + } + else + listNonCel(ptr, str, sys); + } + + listPost(str, conj, strip); +} + +void Ellipse::listNonCel(FitsImage* ptr, ostream& str, Coord::CoordSystem sys) +{ + Vector vv = ptr->mapFromRef(center,sys); + Vector rr = ptr->mapLenFromRef(annuli_[0],sys); + double aa = parent->mapAngleFromRef(angle,sys); + str << type_ << '(' << setprecision(8) << vv << ',' << rr << ',' + << radToDeg(aa) << ')'; +} + +void Ellipse::listXML(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format) +{ + FitsImage* ptr = parent->findFits(sys,center); + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowCenter(ptr,sys,sky,format); + XMLRowRadius(ptr,sys,annuli_[0]); + XMLRowAng(sys,sky); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} + +void Ellipse::listCiao(ostream& str, Coord::CoordSystem sys, int strip) +{ + FitsImage* ptr = parent->findFits(); + listCiaoPre(str); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + Vector vv = ptr->mapFromRef(center,Coord::PHYSICAL); + Vector rr = ptr->mapLenFromRef(annuli_[0],Coord::PHYSICAL); + str << type_ << '(' << setprecision(8) << vv << ',' << rr << ',' + << radToDeg(angle) << ')'; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + listRADEC(ptr,center,sys,Coord::FK5,Coord::SEXAGESIMAL); + Vector rr = ptr->mapLenFromRef(annuli_[0],sys,Coord::ARCMIN); + str << type_ << '(' + << ra << ',' << dec << ',' + << setprecision(5) << fixed << setunit('\'') << rr << ','; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(angle) << ')'; + } + break; + } + + listCiaoPost(str, strip); +} + +void Ellipse::listSAOtng(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + int strip) +{ + FitsImage* ptr = parent->findFits(); + listSAOtngPre(str, strip); + + // radius is always in image coords + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + Vector vv = ptr->mapFromRef(center,Coord::IMAGE); + Vector rr = ptr->mapLenFromRef(annuli_[0],Coord::IMAGE); + str << type_ << '(' << setprecision(8) << vv << ',' << rr << ',' + << radToDeg(angle) << ')'; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + Vector rr = ptr->mapLenFromRef(annuli_[0],Coord::IMAGE); + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' + << setprecision(10) << vv << ',' + << setprecision(8) << rr << ',' + << setprecision(8) << radToDeg(angle) << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' + << ra << ',' << dec << ',' + << setprecision(8) << rr << ',' + << setprecision(8) << radToDeg(angle) << ')'; + break; + } + } + } + + listSAOtngPost(str, strip); +} + +void Ellipse::listPros(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + int strip) +{ + FitsImage* ptr = parent->findFits(); + + switch (sys) { + case Coord::IMAGE: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + sys = Coord::IMAGE; + case Coord::PHYSICAL: + { + Vector vv = ptr->mapFromRef(center,sys); + Vector rr = ptr->mapLenFromRef(annuli_[0],Coord::IMAGE); + coord.listProsCoordSystem(str,sys,sky); + str << "; " << type_ << ' ' << setprecision(8) << vv << ' ' << rr << ' ' + << radToDeg(angle); + } + break; + default: + if (ptr->hasWCSCel(sys)) { + Vector rr = ptr->mapLenFromRef(annuli_[0],sys,Coord::ARCSEC); + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + coord.listProsCoordSystem(str,sys,sky); + str << "; " << type_ << ' ' + << setprecision(10) << setunit('d') << vv << ' ' + << setprecision(3) << fixed << setunit('"') << rr << ' '; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(angle); + } + break; + case Coord::SEXAGESIMAL: + listRADECPros(ptr,center,sys,sky,format); + coord.listProsCoordSystem(str,sys,sky); + str << "; " << type_ << ' ' + << ra << ' ' << dec << ' ' + << setprecision(3) << fixed << setunit('"') << rr << ' '; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(angle); + break; + } + } + } + + listProsPost(str, strip); +} + +void Ellipse::listSAOimage(ostream& str, int strip) +{ + FitsImage* ptr = parent->findFits(); + listSAOimagePre(str); + + Vector vv = ptr->mapFromRef(center,Coord::IMAGE); + str << type_ << '(' << setprecision(8) << vv << ',' << annuli_[0] << ',' + << radToDeg(angle) << ')'; + + listSAOimagePost(str, strip); +} diff --git a/tksao/frame/ellipse.h b/tksao/frame/ellipse.h new file mode 100644 index 0000000..3c0ff8d --- /dev/null +++ b/tksao/frame/ellipse.h @@ -0,0 +1,42 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __ellipse_h__ +#define __ellipse_h__ + +#include "baseellipse.h" + +class Ellipse : public BaseEllipse { + protected: + void listNonCel(FitsImage*, ostream&, Coord::CoordSystem); + +public: + Ellipse(Base* p, const Vector& ctr, const Vector& r, double ang); + Ellipse(Base* p, const Vector& ctr, + const Vector& r, double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + Ellipse(const Ellipse&); + + virtual Marker* dup() {return new Ellipse(*this);} + void edit(const Vector&, int); + + void analysis(AnalysisTask, int); + void analysisHistogram(char*, char*, int); + void analysisPlot3d(char*, char*, Coord::CoordSystem, Marker::AnalysisMethod); + void analysisStats(Coord::CoordSystem, Coord::SkyFrame sky); + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + virtual void listCiao(ostream&, Coord::CoordSystem, int); + virtual void listSAOtng(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + virtual void listPros(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + virtual void listSAOimage(ostream&, int); +}; + +#endif + + diff --git a/tksao/frame/ellipseannulus.C b/tksao/frame/ellipseannulus.C new file mode 100644 index 0000000..a741016 --- /dev/null +++ b/tksao/frame/ellipseannulus.C @@ -0,0 +1,429 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "ellipseannulus.h" +#include "fitsimage.h" + +EllipseAnnulus::EllipseAnnulus(Base* p, const Vector& ctr, + const Vector& r, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BaseEllipse(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = 1; + annuli_ = new Vector[1]; + + annuli_[0] = r; + + strcpy(type_,"ellipseannulus"); + numHandle = 4; + + updateBBox(); +} + +EllipseAnnulus::EllipseAnnulus(Base* p, const Vector& ctr, + const Vector& inner,const Vector& outer,int num, + double ang) + : BaseEllipse(p, ctr, ang) +{ + numAnnuli_ = num+1; + annuli_ = new Vector[numAnnuli_]; + + for (int i=0; i& tg, const List& cb) + : BaseEllipse(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = num+1; + annuli_ = new Vector[numAnnuli_]; + + for (int i=0; i& tg, const List& cb) + : BaseEllipse(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = an; + annuli_ = new Vector[numAnnuli_]; + + for (int i=0; ioptions->cmdName); + addCallBack(CallBack::EDITCB, analysisRadialCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITENDCB, analysisRadialCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisRadialCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisRadialCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisRadialCB_[1], + parent->options->cmdName); + } + if (analysisRadial_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisRadialCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisRadialCB_[0]); + deleteCallBack(CallBack::EDITENDCB, analysisRadialCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisRadialCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisRadialCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisRadialCB_[1]); + } + + analysisRadial_ = which; + break; + case STATS: + if (!analysisStats_ && which) { + addCallBack(CallBack::MOVECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITENDCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisStatsCB_[1], + parent->options->cmdName); + } + if (analysisStats_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITENDCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisStatsCB_[1]); + } + + analysisStats_ = which; + break; + default: + // na + break; + } +} + +void EllipseAnnulus::analysisRadial(char* xname, char* yname, char* ename, + Coord::CoordSystem sys) +{ + double* xx; + double* yy; + double* ee; + + BBox* bb = new BBox[numAnnuli_]; + Matrix mm = Rotate(angle) * Translate(center); + + for (int ii=0; iimarkerAnalysisRadial(this, &xx, &yy, &ee, + numAnnuli_-1, annuli_, + bb, sys); + analysisXYEResult(xname, yname, ename, xx, yy, ee, num); +} + +void EllipseAnnulus::analysisStats(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + ostringstream str; + BBox* bb = new BBox[numAnnuli_]; + Matrix mm = Rotate(angle) * Translate(center); + + for (int ii=0; iimarkerAnalysisStats(this, str, numAnnuli_-1, bb, sys, sky); + str << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +// list + +void EllipseAnnulus::list(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + int conj, int strip) +{ + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 0); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listNonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + double aa = parent->mapAngleFromRef(angle,sys,sky); + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << "ellipse(" << setprecision(8) << vv + << setprecision(3) << fixed; + for (int ii=0; iimapLenFromRef(annuli_[ii],sys,Coord::ARCSEC); + str << ',' << setunit('"') << rr; + } + str.unsetf(ios_base::floatfield); + str << setprecision(8) << ',' << radToDeg(aa) << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << "ellipse(" << ra << ',' << dec + << setprecision(3) << fixed; + for (int ii=0; iimapLenFromRef(annuli_[ii],sys,Coord::ARCSEC); + str << ',' << setunit('"') << rr; + } + str.unsetf(ios_base::floatfield); + str << setprecision(8) << ',' << radToDeg(aa) << ')'; + break; + } + } + else + listNonCel(ptr, str, sys); + } + + listPost(str, conj, strip); +} + +void EllipseAnnulus::listNonCel(FitsImage* ptr, ostream& str, + Coord::CoordSystem sys) +{ + Vector vv = ptr->mapFromRef(center,sys); + double aa = parent->mapAngleFromRef(angle,sys); + str << "ellipse(" << setprecision(8) << vv; + for (int ii=0; iimapLenFromRef(annuli_[ii],sys); + str << ',' << rr; + } + str << ',' << radToDeg(aa) << ')'; +} + +void EllipseAnnulus::listXML(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format) +{ + FitsImage* ptr = parent->findFits(sys,center); + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowCenter(ptr,sys,sky,format); + XMLRowRadius(ptr,sys,annuli_,numAnnuli_); + XMLRowAng(sys,sky); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} + +void EllipseAnnulus::listPros(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + int strip) +{ + FitsImage* ptr = parent->findFits(); + + switch (sys) { + case Coord::IMAGE: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + sys = Coord::IMAGE; + case Coord::PHYSICAL: + { + Vector vv = ptr->mapFromRef(center,sys); + for (int ii=0; iimapLenFromRef(annuli_[ii],Coord::IMAGE); + str << "ellipse " << setprecision(8) << vv << ' ' << rr << ' ' + << radToDeg(angle); + + if (ii!=0) { + Vector r1 = ptr->mapLenFromRef(annuli_[ii-1],Coord::IMAGE); + str << " & !ellipse " << setprecision(8) << vv << ' ' << r1 << ' ' + << radToDeg(angle); + } + + listProsPost(str, strip); + } + } + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + for (int ii=0; iimapLenFromRef(annuli_[ii],sys,Coord::ARCSEC); + str << "ellipse " + << setprecision(10) << setunit('d') << vv << ' ' + << setprecision(3) << setunit('"') << fixed << rr << ' '; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(angle); + + if (ii!=0) { + Vector r1 = ptr->mapLenFromRef(annuli_[ii-1],sys,Coord::ARCSEC); + str << " & !ellipse " + << setprecision(8) << setunit('d') << vv << ' ' + << setprecision(3) << setunit('"') << fixed << r1 << ' '; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(angle); + } + + listProsPost(str, strip); + } + } + break; + case Coord::SEXAGESIMAL: + listRADECPros(ptr,center,sys,sky,format); + for (int ii=0; iimapLenFromRef(annuli_[ii],sys,Coord::ARCSEC); + str << "ellipse " << ra << ' ' << dec << ' ' + << setprecision(3) << setunit('"') << fixed << rr << ' '; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(angle); + + if (ii!=0) { + Vector r1 = ptr->mapLenFromRef(annuli_[ii-1],sys,Coord::ARCSEC); + str << " & !ellipse " << ra << ' ' << dec << ' ' + << setprecision(3) << setunit('"') << fixed << r1 << ' '; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(angle); + } + + listProsPost(str, strip); + } + break; + } + } + } +} + +void EllipseAnnulus::listSAOimage(ostream& str, int strip) +{ + FitsImage* ptr = parent->findFits(); + listSAOimagePre(str); + + for (int ii=0; iimapFromRef(center,Coord::IMAGE); + str << "ellipse(" << setprecision(8) << vv << ',' + << annuli_[ii] << ',' << radToDeg(angle) << ')'; + + if (ii!=0) + str << " & !ellipse(" << setprecision(8) << vv << ',' + << annuli_[ii-1] << ',' << radToDeg(angle) << ')'; + + listSAOimagePost(str, strip); + } +} + + diff --git a/tksao/frame/ellipseannulus.h b/tksao/frame/ellipseannulus.h new file mode 100644 index 0000000..2b28b6a --- /dev/null +++ b/tksao/frame/ellipseannulus.h @@ -0,0 +1,59 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __ellipseannulus_h__ +#define __ellipseannulus_h__ + +#include "baseellipse.h" + +class EllipseAnnulus : public BaseEllipse { + protected: + void listNonCel(FitsImage*, ostream&, Coord::CoordSystem); + +public: + EllipseAnnulus(Base* p, const Vector& ctr, + const Vector& r, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + EllipseAnnulus(Base* p, const Vector& ctr, + const Vector& inner, const Vector& outer, int num, + double ang); + EllipseAnnulus(Base* p, const Vector& ctr, + const Vector& inner, const Vector& outer, int num, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + EllipseAnnulus(Base* p, const Vector& ctr, + int an, Vector* r, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + EllipseAnnulus(const EllipseAnnulus&); + + Marker* dup() {return new EllipseAnnulus(*this);} + void edit(const Vector&, int); + void editEnd(); + + int addAnnuli(const Vector&); + + void analysis(AnalysisTask, int); + void analysisRadial(char*, char*, char*, Coord::CoordSystem sys); + void analysisStats(Coord::CoordSystem, Coord::SkyFrame sky); + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void listPros(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + void listSAOimage(ostream&, int); +}; + +#endif + + diff --git a/tksao/frame/epanda.C b/tksao/frame/epanda.C new file mode 100644 index 0000000..5ec98d5 --- /dev/null +++ b/tksao/frame/epanda.C @@ -0,0 +1,735 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "epanda.h" +#include "fitsimage.h" + +Epanda::Epanda(Base* p, const Vector& ctr, + double a1, double a2, int an, + const Vector& r1, const Vector& r2, int rn, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BaseEllipse(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = rn+1; + annuli_ = new Vector[numAnnuli_]; + + for (int ii=0; ii& tg, const List& cb) + : BaseEllipse(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + numAnnuli_ = rn; + annuli_ = new Vector[numAnnuli_]; + + for (int ii=0; iigetColor("red")); + else if (ii == numAngles_-1) + XSetForeground(display, gc, parent->getColor("blue")); + else + XSetForeground(display, gc, color); + } + else + XSetForeground(display, gc, color); + } + + XDrawLine(display, drawable, lgc, rr0[0], rr0[1], rr1[0], rr1[1]); + } +} + +void Epanda::renderPS(int mode) +{ + BaseEllipse::renderPS(mode); + + renderPSGC(mode); + + Vector r0 = annuli_[0]; + Vector r1 = annuli_[numAnnuli_-1]; + + for (int ii=0; iicanvas) << ' ' + << "moveto " + << rr1.TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } +} + +#ifdef MAC_OSX_TK +void Epanda::renderMACOSX() +{ + BaseEllipse::renderMACOSX(); + + renderMACOSXGC(); + + Vector r0 = annuli_[0]; + Vector r1 = annuli_[numAnnuli_-1]; + + for (int ii=0; ii4) { + int hh = h-4-1; + + if (numAnnuli_>2 && hh2 && hh<(numAnnuli_+numAngles_)) { + hh -= numAnnuli_; + deleteAngle(hh); + } + + numHandle = 4 + numAnnuli_ + numAngles_; + + startAng_ = angles_[0]; + stopAng_ = angles_[numAngles_-1]; + + updateBBox(); + doCallBack(CallBack::EDITCB); + } +} + +int Epanda::isIn(const Vector& vv, Coord::InternalSystem sys, int nn, int aa) +{ + Vector pp = bckMap(vv,sys); + return BaseEllipse::isIn(vv,sys,nn) && isInAngle(pp,aa); +} + +void Epanda::analysis(AnalysisTask mm, int which) +{ + switch (mm) { + case PANDA: + if (!analysisPanda_ && which) { + addCallBack(CallBack::MOVECB, analysisPandaCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisPandaCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITENDCB, analysisPandaCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisPandaCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisPandaCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisPandaCB_[1], + parent->options->cmdName); + } + if (analysisPanda_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisPandaCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisPandaCB_[0]); + deleteCallBack(CallBack::EDITENDCB, analysisPandaCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisPandaCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisPandaCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisPandaCB_[1]); + } + + analysisPanda_ = which; + break; + case STATS: + if (!analysisStats_ && which) { + addCallBack(CallBack::MOVECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITENDCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisStatsCB_[1], + parent->options->cmdName); + } + if (analysisStats_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITENDCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisStatsCB_[1]); + } + + analysisStats_ = which; + break; + default: + // na + break; + } +} + +void Epanda::analysisPanda(Coord::CoordSystem sys) +{ + double* xx; + double* yy; + double* ee; + + BBox* bb = new BBox[numAnnuli_]; + Matrix mm = Rotate(angle) * Translate(center); + + for (int ii=0; iimarkerAnalysisPanda(this, &xx, &yy, &ee, + numAnnuli_-1, annuli_, + numAngles_-1, angles_, + bb, sys); + analysisXYEResult(xx, yy, ee, num); +} + +void Epanda::analysisStats(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + ostringstream str; + BBox* bb = new BBox[numAnnuli_]; + Matrix mm = Rotate(angle) * Translate(center); + + for (int ii=0; iimarkerAnalysisStats(this, str, numAnnuli_-1, numAngles_-1, bb, sys, sky); + str << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +// list + +void Epanda::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + int regular = 1; + if (numAngles_>2) { + double delta; + if (angles_[1] > angles_[0]) + delta = angles_[1]-angles_[0]; + else + delta = angles_[1]+M_TWOPI-angles_[0]; + + for (int ii=2; ii angles_[ii-1]) + diff = angles_[ii]-angles_[ii-1]; + else + diff = angles_[ii]+M_TWOPI-angles_[ii-1]; + + if (!teq(diff,delta,FLT_EPSILON)) { + regular = 0; + break; + } + } + } + + if (numAnnuli_>2) { + double delta = annuli_[1][0]-annuli_[0][0]; + for (int i=2; ifindFits(sys,center); + listPre(str, sys, sky, ptr, strip, 0); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listANonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + double a1 = radToDeg(parent->mapAngleFromRef(angles_[0],sys,sky)); + double a2 = radToDeg(parent->mapAngleFromRef(angles_[numAngles_-1],sys,sky)); + Vector r1 = ptr->mapLenFromRef(annuli_[0],sys,Coord::ARCSEC); + Vector r2 = ptr->mapLenFromRef(annuli_[numAnnuli_-1],sys,Coord::ARCSEC); + double aa = parent->mapAngleFromRef(angle,sys,sky); + if (a2<=a1+FLT_EPSILON) + a2 += 360; + + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' + << setprecision(10) << vv << ',' + << setprecision(8) << a1 << ',' << a2 <<',' << numAngles_-1 << ',' + << setprecision(3) << fixed << setunit('"') << r1 << ',' + << setunit('"') << r2 << ','; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << numAnnuli_-1 << ',' + << setprecision(8) << radToDeg(aa) << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' + << ra << ',' << dec << ',' + << setprecision(8) << a1 << ',' << a2 <<',' << numAngles_-1 << ',' + << setprecision(3) << fixed << setunit('"') << r1 << ',' + << setunit('"') << r2 << ','; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << numAnnuli_-1 << ',' + << setprecision(8) << radToDeg(aa) << ')'; + break; + } + } + else + listANonCel(ptr, str, sys); + } + + listPost(str, conj, strip); +} + +void Epanda::listANonCel(FitsImage* ptr, ostream& str, Coord::CoordSystem sys) +{ + double a1 = radToDeg(parent->mapAngleFromRef(angles_[0],sys)); + double a2 = radToDeg(parent->mapAngleFromRef(angles_[numAngles_-1],sys)); + if (a2<=a1+FLT_EPSILON) + a2 += 360; + + Vector vv = ptr->mapFromRef(center,sys); + Vector r1 = ptr->mapLenFromRef(annuli_[0],sys); + Vector r2 = ptr->mapLenFromRef(annuli_[numAnnuli_-1],sys); + double aa = parent->mapAngleFromRef(angle,sys); + str << type_ << '(' << setprecision(8) << vv << ',' + << a1 << ',' << a2 << ',' << numAngles_-1 << ',' + << r1 << ',' << r2 << ',' << numAnnuli_-1 << ',' + << radToDeg(aa) << ')'; +} + +void Epanda::listB(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + FitsImage* ptr = parent->findFits(sys,center); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listBNonCel(ptr, str, sys, sky, format, conj, strip); + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + for (int jj=1; jjmapFromRef(center,sys); + double aa = parent->mapAngleFromRef(angle,sys); + for (int jj=1; jjmapAngleFromRef(angles_[jj-1],sys)); + double a2 = radToDeg(parent->mapAngleFromRef(angles_[jj],sys)); + if (a2<=a1+FLT_EPSILON) + a2 += 360; + + for (int ii=1; iimapLenFromRef(annuli_[ii-1],sys); + Vector r2 = ptr->mapLenFromRef(annuli_[ii],sys); + str << type_ << '(' + << setprecision(8) << vv << ',' + << a1 << ',' << a2 << ",1," + << r1 << ',' << r2 << ",1," + << radToDeg(aa) << ')'; + + if (!strip) { + if (conj) + str << " ||"; + + str << " # epanda="; + if (ii==1 && jj==1 && !strip) { + str << '('; + for (int kk=0; kkmapAngleFromRef(angles_[kk],sys); + str << radToDeg(ar) << ((kkmapLenFromRef(annuli_[kk],sys); + str << rr << ((kkmapAngleFromRef(angles_[jj-1],sys,sky)); + double a2 = radToDeg(parent->mapAngleFromRef(angles_[jj],sys,sky)); + if (a2<=a1+FLT_EPSILON) + a2 += 360; + + Vector r1 = ptr->mapLenFromRef(annuli_[ii-1],sys,Coord::ARCSEC); + Vector r2 = ptr->mapLenFromRef(annuli_[ii],sys,Coord::ARCSEC); + double aa = parent->mapAngleFromRef(angle,sys,sky); + + str << setprecision(10) << a1 << ',' << a2 << ",1," + << setprecision(3) << fixed << setunit('"') << r1 << ',' + << setunit('"') << r2 << ",1,"; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(aa) << ')'; + + if (!strip) { + if (conj) + str << " ||"; + + str << " # epanda="; + if (ii==1 && jj==1 && !strip) { + str << '(' << setprecision(8); + for (int kk=0; kkmapAngleFromRef(angles_[kk],sys,sky); + str << radToDeg(ar) << ((kkmapLenFromRef(annuli_[kk],sys,Coord::ARCSEC); + str << setunit('"') << rr << ((kkfindFits(sys,center); + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowCenter(ptr,sys,sky,format); + XMLRowRadius(ptr,sys,annuli_,numAnnuli_); + XMLRowAng(sys,sky); + XMLRowAng(sys,sky,angles_,numAngles_); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} + diff --git a/tksao/frame/epanda.h b/tksao/frame/epanda.h new file mode 100644 index 0000000..178e9e5 --- /dev/null +++ b/tksao/frame/epanda.h @@ -0,0 +1,79 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __epanda_h__ +#define __epanda_h__ + +#include "baseellipse.h" + +class Epanda : public BaseEllipse { + private: + void renderX(Drawable, Coord::InternalSystem, RenderMode); + void renderPS(int); +#ifdef MAC_OSX_TK + void renderMACOSX(); +#endif +#ifdef __WIN32 + void renderWIN32(); +#endif + + void updateHandles(); + + void listA(ostream&, Coord::CoordSystem, Coord::SkyFrame, + Coord::SkyFormat, int, int); + void listB(ostream&, Coord::CoordSystem, Coord::SkyFrame, + Coord::SkyFormat, int, int); + + void listANonCel(FitsImage*, ostream&, Coord::CoordSystem); + + void listBNonCel(FitsImage*, ostream&, + Coord::CoordSystem, Coord::SkyFrame, + Coord::SkyFormat, int, int); + + void listBCel(FitsImage*, int, int, ostream&, + Coord::CoordSystem, Coord::SkyFrame, + Coord::SkyFormat, int, int); + + int isIn(const Vector& vv, Coord::InternalSystem sys, int nn, int aa); + + public: + Epanda(const Epanda&); + Epanda(Base* p, const Vector& ctr, + double a1, double a2, int an, + const Vector& r1, const Vector& r2, int rn, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + + Epanda(Base* p, const Vector& ctr, + int an, double* a, + int rn, Vector* r, + double ang, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + + Marker* dup() {return new Epanda(*this);} + + void edit(const Vector&, int); + void editEnd(); + + int addAnnuli(const Vector&); + int addAngles(const Vector&); + void setAnglesAnnuli(double, double, int, Vector, Vector, int); + void setAnglesAnnuli(const double*, int, const Vector*, int); + void deleteAnglesAnnuli(int h); + + void analysis(AnalysisTask, int); + void analysisPanda(Coord::CoordSystem sys); + void analysisStats(Coord::CoordSystem, Coord::SkyFrame sky); + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); +}; + +#endif diff --git a/tksao/frame/fitsanalysis.C b/tksao/frame/fitsanalysis.C new file mode 100644 index 0000000..d3bc830 --- /dev/null +++ b/tksao/frame/fitsanalysis.C @@ -0,0 +1,231 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __WIN32 +#include +#endif + +#include "fitsimage.h" +#include "analysis.h" +#include "smooth.h" +#include "context.h" + +void* convolve(void* tt); + +#ifdef __WIN32 + +void FitsImage::analysis(int which) +{ + if (DebugPerf) + cerr << "FitsImage::analysis()" << endl; + + if (manageAnalysis_) { + if (analysis_) + delete analysis_; + if (analysisdata_) + delete analysisdata_; + } + manageAnalysis_ =0; + analysis_ = block_; + analysisdata_ = blockdata_; + + if (which) { + analysis_ = new FitsAnalysis(block_); + if (analysis_->isValid()) { + analysisdata_ = new FitsDatam(analysis_, interp_); + + smooth(); + manageAnalysis_ =1; + } + else { + delete analysis_; + analysis_ = block_; + } + } + + image_ = analysis_; + data_ = analysisdata_; +} + +void FitsImage::smooth() +{ + // radius + int r = context_->smoothRadius(); + + int ww = analysis_->head()->naxis(0); + int hh = analysis_->head()->naxis(1); + + // src + double* src = new double[ww*hh]; + double* ptr = src; + for (long jj=0; jjgetValueDouble(jj*ww+ii); + + // dest + double* dest = (double*)analysis_->data(); + + // kernel + // create kernel + int rr = 2*r+1; + double* kernel = new double[rr*rr]; + memset(kernel, 0, rr*rr*sizeof(double)); + + switch (context_->smoothFunction()) { + case Context::BOXCAR: + boxcar(kernel,r); + break; + case Context::TOPHAT: + tophat(kernel,r); + break; + case Context::GAUSSIAN: + gaussian(kernel,r); + break; + } + + // convolve + t_smooth_arg* targ = new t_smooth_arg; + targ->kernel = kernel; + targ->src = src; + targ->dest = dest; + targ->width = ww; + targ->height = hh; + targ->radius = r; + + convolve(targ); + + // clean up + if (targ->kernel) + delete [] targ->kernel; + if (targ->src) + delete [] targ->src; + if (targ) + delete targ; +} + +#else + +void FitsImage::analysis(int which, pthread_t* thread, t_smooth_arg* targ) +{ + if (DebugPerf) + cerr << "FitsImage::analysis()" << endl; + + targ->kernel =NULL; + targ->src =NULL; + targ->dest =NULL; + targ->width =0; + targ->height =0; + targ->radius =0; + + if (manageAnalysis_) { + if (analysis_) + delete analysis_; + if (analysisdata_) + delete analysisdata_; + } + manageAnalysis_ =0; + analysis_ = block_; + analysisdata_ = blockdata_; + + if (which) { + analysis_ = new FitsAnalysis(block_); + if (analysis_->isValid()) { + analysisdata_ = new FitsDatam(analysis_, interp_); + + smooth(thread, targ); + manageAnalysis_ =1; + } + else { + delete analysis_; + analysis_ = block_; + } + } + + image_ = analysis_; + data_ = analysisdata_; +} + +void FitsImage::smooth(pthread_t* thread, t_smooth_arg* targ) +{ + // radius + int r = context_->smoothRadius(); + + int ww = analysis_->head()->naxis(0); + int hh = analysis_->head()->naxis(1); + + // src + double* src = new double[ww*hh]; + double* ptr = src; + for (long jj=0; jjgetValueDouble(jj*ww+ii); + + // dest + double* dest = (double*)analysis_->data(); + + // kernel + // create kernel + int rr = 2*r+1; + double* kernel = new double[rr*rr]; + memset(kernel, 0, rr*rr*sizeof(double)); + + switch (context_->smoothFunction()) { + case Context::BOXCAR: + boxcar(kernel,r); + break; + case Context::TOPHAT: + tophat(kernel,r); + break; + case Context::GAUSSIAN: + gaussian(kernel,r); + break; + } + + // convolve + targ->kernel = kernel; + targ->src = src; + targ->dest = dest; + targ->width = ww; + targ->height = hh; + targ->radius = r; + + int result = pthread_create(thread, NULL, convolve, targ); + if (result) + internalError("Unable to Create Thread"); +} + +#endif + +void* convolve(void* tt) +{ + t_smooth_arg* targ = (t_smooth_arg*)tt; + double* kernel = targ->kernel; + double* src = targ->src; + double* dest = targ->dest; + int width = targ->width; + int height = targ->height; + int r = targ->radius; + + int rr = 2*r+1; + + double* dptr = dest; + for (int jj=0; jj=0 && nn=0 && mmhead(); + if (head) { + FitsTableHDU* hdu = (FitsTableHDU*)(head->hdu()); + if (!hdu->width() || !hdu->rows()) + return; + } + } + + // make sure we have cols to bin on + if (!fits_->pBinX() || !fits_->pBinY()) { + FitsHead* head = fits_->head(); + if (head) { + FitsTableHDU* hdu = (FitsTableHDU*)head->hdu(); + + // try for X and Y + FitsColumn* x = hdu->find("X"); + FitsColumn* y = hdu->find("Y"); + + // next, try for ra and dec + if (!x) + x = hdu->find("RA"); + if (!y) + y = hdu->find("DEC"); + + // last chance, try first and second column + if (!x) + x = hdu->find(0); + if (!y) + y = hdu->find(1); + + if (x) { + char* str = trim(x->ttype()); + fits_->setpBinX(str); + delete [] str; + } + else + return; + + if (y) { + char* str = trim(y->ttype()); + fits_->setpBinY(str); + delete [] str; + } + else + return; + } + } + + if (!fits_->pBinZ()) { + FitsHead* head = fits_->head(); + if (head) { + FitsTableHDU* hdu = (FitsTableHDU*)head->hdu(); + + // try for TIME + FitsColumn* z = hdu->find("TIME"); + + // last chance, try third column + if (!z) + z = hdu->find(2); + + if (z) { + char* str = trim(z->ttype()); + fits_->setpBinZ(str); + delete [] str; + } + } + } + + nextBin(getHistCenter()); +} + +int FitsImage::hasBinCol(const char* str) +{ + if (fits_) { + FitsHead* head = fits_->head(); + if (head) { + FitsTableHDU* hdu = (FitsTableHDU*)head->hdu(); + return hdu->find(str) ? 1 : 0; + } + } + return 0; +} + +void FitsImage::setBinCursor(const Vector& v) +{ + histCursor = v * refToPhysical; +} + +Matrix FitsImage::nextBin(const Vector& c) +{ + if (hist_) + delete hist_; + hist_ = NULL; + + if (manageBlock_) { + if (block_) + delete block_; + if (blockdata_) + delete blockdata_; + } + manageBlock_ =0; + block_ = base_; + blockdata_ = basedata_; + + if (manageAnalysis_) { + if (analysis_) + delete analysis_; + if (analysisdata_) + delete analysisdata_; + } + manageAnalysis_ =0; + + // cursor, c is in bin (physical) coords + // remember where we are pointing + histCursor = c; + + // Vector s = getHistDim()/binFactor_; + Vector d = getHistDim(); + Vector s; + Vector binFactor = context_->binFactor(); + s[0] = d[0]/binFactor[0]; + s[1] = d[1]/binFactor[1]; + + // make sure that we have a width/height of at least 1 + if (s[0]<1) + s[0]=1; + if (s[1]<1) + s[1]=1; + + int bufferSize = context_->binBufferSize(); + int width = (int)(s[0]binDepth(); + + Vector center = Vector(width, height)/2; + + if (DebugBin) { + cerr << "width height: " << width << ' ' << height << endl; + cerr << "center: " << center << endl; + cerr << "center.ceil(): " << center.ceil() << endl; + } + + if (binFactor[0]<1 || binFactor[1]<1) { + actualHistCursor = histCursor; + + if (DebugBin) + cerr << "histCursor: " << histCursor << endl; + } + else { + // force to a bin boundary, then translate to center of bin cell + // actualHistCursor = ((histCursor/binFactor_).floor() * binFactor_) + + // Vector(.5,.5); + actualHistCursor[0] = (floor(histCursor[0]/binFactor[0]) * binFactor[0]) + + .5; + actualHistCursor[1] = (floor(histCursor[1]/binFactor[1]) * binFactor[1]) + + .5; + + // now, figure out any offset due to mod(lowerleft,binFactor_) + FitsTableHDU* hdu = (FitsTableHDU*)(fits_->head())->hdu(); + Vector xd = hdu->dimension(fits_->pBinX()); + Vector yd = hdu->dimension(fits_->pBinY()); + Vector ll(xd[0],yd[0]); + + // Vector a = ((ll/binFactor_).floor() * binFactor_) + Vector(.5,.5); + Vector a; + a[0] = (floor(ll[0]/binFactor[0]) * binFactor[0]) + .5; + a[1] = (floor(ll[1]/binFactor[1]) * binFactor[1]) + .5; + Vector offset = a-ll; + actualHistCursor -= offset; + + if (DebugBin) { + cerr << "histCursor: " << histCursor << endl; + cerr << "actualHistCursor: " << actualHistCursor << endl; + cerr << "ll: " << ll << endl; + cerr << "offset: " << offset << endl; + } + } + + // new physicalToData + Matrix mm = + Translate(-actualHistCursor) * + Scale(1./binFactor[0],1./binFactor[1]) * + Translate(center.ceil()); + + if (DebugBin) + cerr << "mm: " << mm << endl << endl; + + FitsHist::Function binFunction = context_->binFunction(); + hist_ = new FitsHist(fits_, width, height, depth, mm, binFunction, binFactor); + + if (!hist_->isValid()) { + reset(); + return Matrix(); + } + + load(); + + return refToPhysical * mm * dataToRef; +} + +Vector FitsImage::getHistColMinMax(const char* col) +{ + return fits_ ? fits_->getColMinMax(col) : Vector(); +} + +Vector FitsImage::getHistColDim(const char* col) +{ + return fits_ ? fits_->getColDim(col) : Vector(); +} + +Vector FitsImage::getHistDim() +{ + if (!isBinTable()) + return Vector(); + + // assumes we aready have our columns + FitsTableHDU* hdu = (FitsTableHDU*)(fits_->head())->hdu(); + Vector xd = hdu->dimension(fits_->pBinX()); + Vector yd = hdu->dimension(fits_->pBinY()); + + // if DBL_MAX, we will get nan + Vector r(xd[1]-xd[0],yd[1]-yd[0]); + + if (isfinite(r[0]) && isfinite(r[1])) + return r; + else + return Vector(DBL_MAX,DBL_MAX); +} + +Vector FitsImage::getHistCenter() +{ + // return bin (physical) coords + if (!isBinTable()) + return Vector(); + + // assumes we aready have our columns + FitsTableHDU* hdu = (FitsTableHDU*)(fits_->head())->hdu(); + Vector xd = hdu->dimension(fits_->pBinX()); + Vector yd = hdu->dimension(fits_->pBinY()); + + // if DBL_MAX, we will get nan + Vector r = Vector(xd[1]-xd[0],yd[1]-yd[0])/2 + Vector(xd[0],yd[0]); + + if (isfinite(r[0]) && isfinite(r[1])) + return r; + else + return Vector(); +} + +const char* FitsImage::getHistFilter() +{ + return fits_ ? fits_->pFilter() : NULL; +} + +const char* FitsImage::getHistX() +{ + return fits_ ? fits_->pBinX() : NULL; +} + +const char* FitsImage::getHistY() +{ + return fits_ ? fits_->pBinY() : NULL; +} + +const char* FitsImage::getHistZ() +{ + return fits_ ? fits_->pBinZ() : NULL; +} + +char* FitsImage::getHistList() +{ + if (!isHist()) + return NULL; + + FitsHead* head = fits_->head(); + return ((FitsTableHDU*)head->hdu())->list(); +} + + + diff --git a/tksao/frame/fitsblock.C b/tksao/frame/fitsblock.C new file mode 100644 index 0000000..19812b8 --- /dev/null +++ b/tksao/frame/fitsblock.C @@ -0,0 +1,194 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "fitsimage.h" +#include "block.h" +#include "context.h" + +void* blockproc(void* tt); + +void FitsImage::block() +{ + if (DebugPerf) + cerr << "FitsImage::block()" << endl; + + if (manageBlock_) { + if (block_) + delete block_; + if (blockdata_) + delete blockdata_; + } + manageBlock_ =0; + block_ = base_; + blockdata_ = basedata_; + + if (manageAnalysis_) { + if (analysis_) + delete analysis_; + if (analysisdata_) + delete analysisdata_; + } + manageAnalysis_ =0; + + Vector blockFactor = context_->blockFactor(); + + if (blockFactor[0] != 1 && blockFactor[1] != 1) { + block_ = new FitsBlock(base_, blockFactor); + if (block_->isValid()) { + manageBlock_ =1; + + switch (block_->head()->bitpix()) { + case -64: + blockdata_ = new FitsDatam(block_, interp_); + break; + default: + blockdata_ = new FitsDatam(block_, interp_); + break; + } + + t_block_arg* targ = new t_block_arg; + targ->base = base_; + targ->basedata = basedata_; + targ->block = block_; + targ->blockFactor = blockFactor; + + blockproc(targ); + } + else { + delete block_; + block_ = base_; + return; + } + } + + analysis_ = block_; + analysisdata_ = blockdata_; + + image_ = analysis_; + data_ = analysisdata_; + + resetWCS(); + processKeywordsPhysical(); + processKeywordsParams(); +} + +#ifndef __WIN32 + +void FitsImage::block(pthread_t* thread) +{ + if (DebugPerf) + cerr << "FitsImage::block(thread)" << endl; + + if (manageBlock_) { + if (block_) + delete block_; + if (blockdata_) + delete blockdata_; + } + manageBlock_ =0; + block_ = base_; + blockdata_ = basedata_; + + if (manageAnalysis_) { + if (analysis_) + delete analysis_; + if (analysisdata_) + delete analysisdata_; + } + manageAnalysis_ =0; + + Vector blockFactor = context_->blockFactor(); + + if (blockFactor[0] != 1 && blockFactor[1] != 1) { + block_ = new FitsBlock(base_, blockFactor); + if (block_->isValid()) { + manageBlock_ =1; + + switch (block_->head()->bitpix()) { + case -64: + blockdata_ = new FitsDatam(block_, interp_); + break; + default: + blockdata_ = new FitsDatam(block_, interp_); + break; + } + + t_block_arg* targ = new t_block_arg; + targ->base = base_; + targ->basedata = basedata_; + targ->block = block_; + targ->blockFactor = blockFactor; + + int result = pthread_create(thread, NULL, blockproc, targ); + if (result) + internalError("Unable to Create Thread"); + } + else { + delete block_; + block_ = base_; + return; + } + } + + analysis_ = block_; + analysisdata_ = blockdata_; + + image_ = analysis_; + data_ = analysisdata_; + + resetWCS(); + processKeywordsPhysical(); + processKeywordsParams(); +} + +#endif + +void* blockproc(void* tt) +{ + t_block_arg* targ = (t_block_arg*)tt; + FitsFile* base = targ->base; + FitsData* basedata = targ->basedata; + FitsFile* block = targ->block; + Vector blockFactor = targ->blockFactor; + + Matrix mm = Scale(1/blockFactor[0],1/blockFactor[1]); + int srcw = base->head()->naxis(0); + int srch = base->head()->naxis(1); + int ww = block->head()->naxis(0); + int hh = block->head()->naxis(1); + + switch (block->head()->bitpix()) { + case -64: + { + double* dest=(double*)block->data(); + for (int jj=0; jj=0 && cc[0]=0 && cc[1]getValueDouble(jj*srcw+ii); + *(dest+(int(cc[1])*ww + int(cc[0]))) += vv; + } + } + } + } + break; + default: + { + float* dest=(float*)block->data(); + for (int jj=0; jj=0 && cc[0]=0 && cc[1]getValueFloat(jj*srcw+ii); + *(dest+(int(cc[1])*ww + int(cc[0]))) += vv; + } + } + } + } + break; + } + + return NULL; +} + diff --git a/tksao/frame/fitscompress.C b/tksao/frame/fitscompress.C new file mode 100644 index 0000000..62ef786 --- /dev/null +++ b/tksao/frame/fitscompress.C @@ -0,0 +1,130 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "fitsimage.h" +#include "compress.h" +#include "rice.h" +#include "gzip.h" +#include "hcompress.h" +#include "plio.h" + +void FitsImage::initCompress() +{ + int bitpix = fits_->getInteger("ZBITPIX",0); + char* type = fits_->getString("ZCMPTYPE"); + if (!bitpix || !type) { + if (type) + delete [] type; + return ; + } + + if (post_) + delete post_; + post_ = NULL; + + if (!strncmp(type,"RICE_1",6) || !(strncmp(type,"RICE_ONE",8))) + switch (bitpix) { + case 8: + post_ = new FitsRicem(fits_); + break; + case 16: + post_ = new FitsRicem(fits_); + break; + case -16: + post_ = new FitsRicem(fits_); + break; + case 32: + post_ = new FitsRicem(fits_); + break; + case 64: + post_ = new FitsRicem(fits_); + break; + case -32: + post_ = new FitsRicem(fits_); + break; + case -64: + post_ = new FitsRicem(fits_); + break; + } + else if (!strncmp(type,"GZIP_1",6) || !strncmp(type,"GZIP_2",6)) + switch (bitpix) { + case 8: + post_ = new FitsGzipm(fits_); + break; + case 16: + post_ = new FitsGzipm(fits_); + break; + case -16: + post_ = new FitsGzipm(fits_); + break; + case 32: + post_ = new FitsGzipm(fits_); + break; + case 64: + post_ = new FitsGzipm(fits_); + break; + case -32: + post_ = new FitsGzipm(fits_); + break; + case -64: + post_ = new FitsGzipm(fits_); + break; + } + else if (!strncmp(type,"PLIO_1",6)) + switch (bitpix) { + case 8: + post_ = new FitsPliom(fits_); + break; + case 16: + post_ = new FitsPliom(fits_); + break; + case -16: + post_ = new FitsPliom(fits_); + break; + case 32: + post_ = new FitsPliom(fits_); + break; + case 64: + post_ = new FitsPliom(fits_); + break; + case -32: + post_ = new FitsPliom(fits_); + break; + case -64: + post_ = new FitsPliom(fits_); + break; + } + else if (!strncmp(type,"HCOMPRESS_1",11)) + switch (bitpix) { + case 8: + post_ = new FitsHcompressm(fits_); + break; + case 16: + post_ = new FitsHcompressm(fits_); + break; + case -16: + post_ = new FitsHcompressm(fits_); + break; + case 32: + post_ = new FitsHcompressm(fits_); + break; + case 64: + post_ = new FitsHcompressm(fits_); + break; + case -32: + post_ = new FitsHcompressm(fits_); + break; + case -64: + post_ = new FitsHcompressm(fits_); + break; + } + else { + ; // unknown compression type + } + + if (type) + delete [] type; + + return; +} diff --git a/tksao/frame/fitsdata.C b/tksao/frame/fitsdata.C new file mode 100644 index 0000000..0b91834 --- /dev/null +++ b/tksao/frame/fitsdata.C @@ -0,0 +1,2373 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "fitsdata.h" +#include "sigbus.h" + +#ifdef INTERP +#undef INTERP +#endif +#define INTERP interp_ + +// ZSCALE + +#define ZSMAX(a,b) ((a) > (b) ? (a) : (b)) +#define ZSMIN(a,b) ((a) < (b) ? (a) : (b)) +#define ZSMOD(a,b) ((a) % (b)) +#define ZSNINT(a) ((int)(a + 0.5)) +#define ZSINDEF 0 +// smallest permissible sample +#define ZSMIN_NPIXELS 5 +// max frac. of pixels to be rejected +#define ZSMAX_REJECT 0.5 +// k-sigma pixel rejection factor +#define ZSKREJ 2.5 +// maximum number of fitline iterations +#define ZSMAX_ITERATIONS 5 + +ostream& operator<<(ostream& ss, const FitsBound& fb) +{ + ss << ' ' << fb.xmin << ' ' << fb.ymin + << ' ' << fb.xmax << ' ' << fb.ymax; + return ss; +} + +// FitsData + +FitsData::FitsData(FitsFile* fits, Tcl_Interp* pp) +{ + interp_ = pp; + + FitsImageHDU* hdu = (FitsImageHDU*)fits->head()->hdu(); + width_ = hdu->naxis(0); + height_ = hdu->naxis(1); + + buf_[0] = '\0'; + + byteswap_ = fits->byteswap(); + + bscale_ = hdu->bscale(); + bzero_ = hdu->bzero(); + blank_ = hdu->blank(); + + hasscaling_ = hdu->hasscaling(); + switch (hdu->bitpix()) { + case 8: + case 16: + case -16: + case 32: + case 64: + hasblank_ = hdu->hasblank(); + break; + case -32: + case -64: + hasblank_ = 0; + break; + } + + min_ =0; + max_ =0; + + low_ =0; + high_ =0; + + zLow_ = zHigh_ = 0; + aLow_ = aHigh_ = 0; + ulow_ = uhigh_ = 0; + + scanValid_ = 0; + minmaxSample_ = 25; + + zContrast_ = .5; + zSample_ = 600; + zLine_ = 5; + zscaleValid_ = 0; + + autoCutValid_ = 0; + autoCutPer_ = 0; + + clipMode_ = FrScale::MINMAX; + minmaxMode_ = FrScale::SCAN; + + if (fits->find("DATAMIN") && fits->find("DATAMAX")) { + hasdatamin_ = 1; + datamin_ = fits->getReal("DATAMIN", 0); + datamax_ = fits->getReal("DATAMAX", 0); + } + else { + hasdatamin_ = 0; + datamin_ = datamax_ = 0; + } + + if (fits->find("IRAF-MIN") && fits->find("IRAF-MAX")) { + hasirafmin_ = 1; + irafmin_ = fits->getReal("IRAF-MIN", 0); + irafmax_ = fits->getReal("IRAF-MAX", 0); + } + else { + hasirafmin_ = 0; + irafmin_ = irafmax_ = 0; + } + + secMode_ = FrScale::IMGSEC; +} + +FitsData::~FitsData() +{ +} + +const char* FitsData::getLow() +{ + ostringstream str; + str << low_ << ends; + memcpy(buf_,str.str().c_str(),str.str().length()); + return buf_; +} + +const char* FitsData::getHigh() +{ + ostringstream str; + str << high_ << ends; + memcpy(buf_,str.str().c_str(),str.str().length()); + return buf_; +} + +int FitsData::calcIncr() +{ + switch (minmaxMode_) { + case FrScale::SCAN: + case FrScale::DATAMIN: + case FrScale::IRAFMIN: + return 1; + case FrScale::SAMPLE: + return minmaxSample_; + } +} + +// AutoCut +#define AUTOCUTSIZE 10240 +void FitsData::autoCut(FitsBound* params) +{ + double amin = min(); + double amax = max(); + + // bin it up + double hst[AUTOCUTSIZE]; + memset(hst,0,sizeof(double)*AUTOCUTSIZE); + hist(hst, AUTOCUTSIZE, amin, amax, params); + + // find total number of pixels + int total = 0; + for (int ii=0; ii cutoff) + break; + } + + for (hh=AUTOCUTSIZE-1,count=0; hh>ll+1; hh--) { + count += hst[hh]; + if (count > cutoff) + break; + } + + aLow_ = (amax-amin)/AUTOCUTSIZE*ll + amin; + aHigh_ = (amax-amin)/AUTOCUTSIZE*hh + amin; +} + +const char* FitsData::getMin() +{ + ostringstream str; + + switch (minmaxMode_) { + case FrScale::SCAN: + case FrScale::SAMPLE: + str << min_ << ends; + break; + + case FrScale::DATAMIN: + if (hasdatamin_) + str << datamin_ << ends; + else + str << ends; + break; + + case FrScale::IRAFMIN: + if (hasirafmin_) + str << irafmin_ << ends; + else + str << ends; + break; + } + + memcpy(buf_,str.str().c_str(),str.str().length()); + return buf_; +} + +const char* FitsData::getMinX() +{ + ostringstream str; + str << minXY_[0] << ends; + memcpy(buf_,str.str().c_str(),str.str().length()); + return buf_; +} + +const char* FitsData::getMinY() +{ + ostringstream str; + str << minXY_[1] << ends; + memcpy(buf_,str.str().c_str(),str.str().length()); + return buf_; +} + +const char* FitsData::getMax() +{ + ostringstream str; + switch (minmaxMode_) { + case FrScale::SCAN: + case FrScale::SAMPLE: + str << max_ << ends; + break; + + case FrScale::DATAMIN: + if (hasdatamin_) + str << datamax_ << ends; + else + str << ends; + break; + + case FrScale::IRAFMIN: + if (hasirafmin_) + str << irafmax_ << ends; + else + str << ends; + break; + } + + memcpy(buf_,str.str().c_str(),str.str().length()); + return buf_; +} + +const char* FitsData::getMaxX() +{ + ostringstream str; + str << maxXY_[0] << ends; + memcpy(buf_,str.str().c_str(),str.str().length()); + return buf_; +} + +const char* FitsData::getMaxY() +{ + ostringstream str; + str << maxXY_[1] << ends; + memcpy(buf_,str.str().c_str(),str.str().length()); + return buf_; +} + +double FitsData::min() +{ + switch (minmaxMode_) { + case FrScale::SCAN: + case FrScale::SAMPLE: + return min_; + + case FrScale::DATAMIN: + if (hasdatamin_) + return datamin_; + else + return 0; + + case FrScale::IRAFMIN: + if (hasirafmin_) + return irafmin_; + else + return 0; + } +} + +double FitsData::max() +{ + switch (minmaxMode_) { + case FrScale::SCAN: + case FrScale::SAMPLE: + return max_; + + case FrScale::DATAMIN: + if (hasdatamin_) + return datamax_; + else + return 0; + + case FrScale::IRAFMIN: + if (hasirafmin_) + return irafmax_; + return 0; + } +} + +// FitsDatam + +template FitsDatam::FitsDatam(FitsFile* fits, Tcl_Interp* pp) + : FitsData(fits, pp) +{ + data_ = (T*)fits->data(); +} + +// swap (optimized) + +template <> unsigned char FitsDatam::swap(unsigned char* ptr) +{ + return *ptr; +} + +template <> short FitsDatam::swap(short* ptr) +{ + const char* p = (const char*)ptr; + union { + char c[2]; + short s; + } u; + + u.c[1] = *p++; + u.c[0] = *p; + + return u.s; +} + +template <> unsigned short FitsDatam::swap(unsigned short* ptr) +{ + const char* p = (const char*)ptr; + union { + char c[2]; + unsigned short s; + } u; + + u.c[1] = *p++; + u.c[0] = *p; + + return u.s; +} + +template <> int FitsDatam::swap(int* ptr) +{ + const char* p = (const char*)ptr; + union { + char c[4]; + int i; + } u; + + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + return u.i; +} + +template <> long long FitsDatam::swap(long long* ptr) +{ + const char* p = (const char*)ptr; + union { + char c[8]; + long long i; + } u; + + u.c[7] = *p++; + u.c[6] = *p++; + u.c[5] = *p++; + u.c[4] = *p++; + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + return u.i; +} + +template <> float FitsDatam::swap(float* ptr) +{ + const char* p = (const char*)ptr; + union { + char c[4]; + float f; + } u; + + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + return u.f; +} + +template <> double FitsDatam::swap(double* ptr) +{ + const char* p = (const char*)ptr; + union { + char c[8]; + double d; + } u; + + u.c[7] = *p++; + u.c[6] = *p++; + u.c[5] = *p++; + u.c[4] = *p++; + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + return u.d; +} + +// Private/Protected + +// output + +template void FitsDatam::output(ostringstream& str, T value) +{ + str << value << ends; +} + +template <> void FitsDatam::output(ostringstream& str, unsigned char value) +{ + str << (unsigned short)value << ends; +} + +template <> void FitsDatam::output(ostringstream& str, unsigned short value) +{ + str << (unsigned short)value << ends; +} + +// scan (optimized) + +template <> void FitsDatam::scan(FitsBound* params) +{ + min_ = UCHAR_MAX; + max_ = 0; + minXY_.origin(); + maxXY_.origin(); + + int kk =calcIncr(); + + if (DebugPerf) + cerr << "FitsDatam::scan()..." + << " sample=" << minmaxSample_ + << " (" << params->xmin << ',' << params->ymin + << ") to (" << params->xmax << ',' << params->ymax << ") "; + + SETSIGBUS + for (int jj=params->ymin; jjymax; jj+=kk) { + unsigned char* ptr = data_ + jj*long(width_) + long(params->xmin); + for (int ii=params->xmin; iixmax; ii+=kk, ptr+=kk) { + register unsigned char value = *ptr; + + if (hasblank_ && value == blank_) + continue; // skip nan's + + if (value < min_) { + min_ = value; + minXY_ = Vector(ii+1, jj+1); + } + if (value > max_) { + max_ = value; + maxXY_ = Vector(ii+1, jj+1); + } + } + } + CLEARSIGBUS + + // sanity check + if (min_ == UCHAR_MAX && max_ == 0) { + min_ =NAN; + max_ =NAN; + minXY_.origin(); + maxXY_.origin(); + } + else { + if (hasscaling_) { + min_ = min_*bscale_ + bzero_; + max_ = max_*bscale_ + bzero_; + } + } + + if (DebugPerf) { + cerr << "end" << endl; + cerr << "min: " << min_ << " max: " << max_ << endl; + } +} + +template <> void FitsDatam::scan(FitsBound* params) +{ + min_ = SHRT_MAX; + max_ = SHRT_MIN; + minXY_.origin(); + maxXY_.origin(); + + int kk =calcIncr(); + + if (DebugPerf) + cerr << "FitsDatam::scan()..." + << " sample=" << minmaxSample_ + << " (" << params->xmin << ',' << params->ymin + << ") to (" << params->xmax << ',' << params->ymax << ") "; + + SETSIGBUS + for (int jj=params->ymin; jjymax; jj+=kk) { + short* ptr = data_ + jj*long(width_) + long(params->xmin); + for (int ii=params->xmin; iixmax; ii+=kk, ptr+=kk) { + register short value; + + if (!byteswap_) + value = *ptr; + else { + const char* p = (const char*)ptr; + union { + char c[2]; + short s; + } u; + + u.c[1] = *p++; + u.c[0] = *p; + + value = u.s; + } + + if (hasblank_ && value == blank_) + continue; // skip nan's + + if (value < min_) { + min_ = value; + minXY_ = Vector(ii+1, jj+1); + } + if (value > max_) { + max_ = value; + maxXY_ = Vector(ii+1, jj+1); + } + } + } + CLEARSIGBUS + + // sanity check + if (min_ == SHRT_MAX && max_ == SHRT_MIN) { + min_ =NAN; + max_ =NAN; + minXY_.origin(); + maxXY_.origin(); + } + else { + if (hasscaling_) { + min_ = min_*bscale_ + bzero_; + max_ = max_*bscale_ + bzero_; + } + } + + if (DebugPerf) { + cerr << "end" << endl; + cerr << "min: " << min_ << " max: " << max_ << endl; + } +} + +template <> void FitsDatam::scan(FitsBound* params) +{ + min_ = USHRT_MAX; + max_ = 0; + minXY_.origin(); + maxXY_.origin(); + + int kk =calcIncr(); + + if (DebugPerf) + cerr << "FitsDatam::scan()..." + << " sample=" << minmaxSample_ + << " (" << params->xmin << ',' << params->ymin + << ") to (" << params->xmax << ',' << params->ymax << ") "; + + SETSIGBUS + for (int jj=params->ymin; jjymax; jj+=kk) { + unsigned short* ptr = data_ + jj*long(width_) + long(params->xmin); + for (int ii=params->xmin; iixmax; ii+=kk, ptr+=kk) { + register unsigned short value; + + if (!byteswap_) + value = *ptr; + else { + const char* p = (const char*)ptr; + union { + char c[2]; + unsigned short s; + } u; + + u.c[1] = *p++; + u.c[0] = *p; + + value = u.s; + } + + if (hasblank_ && value == blank_) + continue; // skip nan's + + if (value < min_) { + min_ = value; + minXY_ = Vector(ii+1, jj+1); + } + if (value > max_) { + max_ = value; + maxXY_ = Vector(ii+1, jj+1); + } + } + } + CLEARSIGBUS + + // sanity check + if (min_ == USHRT_MAX && max_ == 0) { + min_ =NAN; + max_ =NAN; + minXY_.origin(); + maxXY_.origin(); + } + else { + if (hasscaling_) { + min_ = min_*bscale_ + bzero_; + max_ = max_*bscale_ + bzero_; + } + } + + if (DebugPerf) { + cerr << "end" << endl; + cerr << "min: " << min_ << " max: " << max_ << endl; + } +} + +template <> void FitsDatam::scan(FitsBound* params) +{ + min_ = INT_MAX; + max_ = INT_MIN; + minXY_.origin(); + maxXY_.origin(); + + int kk =calcIncr(); + + if (DebugPerf) + cerr << "FitsDatam::scan()..." + << " sample=" << minmaxSample_ + << " (" << params->xmin << ',' << params->ymin + << ") to (" << params->xmax << ',' << params->ymax << ") "; + + SETSIGBUS + for (int jj=params->ymin; jjymax; jj+=kk) { + int* ptr = data_ + jj*long(width_) + long(params->xmin); + for (int ii=params->xmin; iixmax; ii+=kk, ptr+=kk) { + register int value; + + if (!byteswap_) + value = *ptr; + else { + const char* p = (const char*)ptr; + union { + char c[4]; + int i; + } u; + + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + value = u.i; + } + + if (hasblank_ && value == blank_) + continue; // skip nan's + + if (value < min_) { + min_ = value; + minXY_ = Vector(ii+1, jj+1); + } + if (value > max_) { + max_ = value; + maxXY_ = Vector(ii+1, jj+1); + } + } + } + CLEARSIGBUS + + // sanity check + if (min_ == INT_MAX && max_ == INT_MIN) { + min_ =NAN; + max_ =NAN; + minXY_.origin(); + maxXY_.origin(); + } + else { + if (hasscaling_) { + min_ = min_*bscale_ + bzero_; + max_ = max_*bscale_ + bzero_; + } + } + + if (DebugPerf) { + cerr << "end" << endl; + cerr << "min: " << min_ << " max: " << max_ << endl; + } +} + +template <> void FitsDatam::scan(FitsBound* params) +{ + min_ = LLONG_MAX; + max_ = LLONG_MIN; + minXY_.origin(); + maxXY_.origin(); + + int kk =calcIncr(); + + if (DebugPerf) + cerr << "FitsDatam::scan()..." + << " sample=" << minmaxSample_ + << " (" << params->xmin << ',' << params->ymin + << ") to (" << params->xmax << ',' << params->ymax << ") "; + + SETSIGBUS + for (int jj=params->ymin; jjymax; jj+=kk) { + long long* ptr = data_ + jj*long(width_) + long(params->xmin); + for (int ii=params->xmin; iixmax; ii+=kk, ptr+=kk) { + register long long value; + + if (!byteswap_) + value = *ptr; + else { + const char* p = (const char*)ptr; + union { + char c[8]; + long long i; + } u; + + u.c[7] = *p++; + u.c[6] = *p++; + u.c[5] = *p++; + u.c[4] = *p++; + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + value = u.i; + } + + if (hasblank_ && value == blank_) + continue; // skip nan's + + if (value < min_) { + min_ = value; + minXY_ = Vector(ii+1, jj+1); + } + if (value > max_) { + max_ = value; + maxXY_ = Vector(ii+1, jj+1); + } + } + } + CLEARSIGBUS + + // sanity check + if (min_ == LLONG_MAX && max_ == LLONG_MIN) { + min_ =NAN; + max_ =NAN; + minXY_.origin(); + maxXY_.origin(); + } + else { + if (hasscaling_) { + min_ = min_*bscale_ + bzero_; + max_ = max_*bscale_ + bzero_; + } + } + + if (DebugPerf) { + cerr << "end" << endl; + cerr << "min: " << min_ << " max: " << max_ << endl; + } +} + +template <> void FitsDatam::scan(FitsBound* params) +{ + min_ = FLT_MAX; + max_ = -FLT_MAX; + minXY_.origin(); + maxXY_.origin(); + + int kk =calcIncr(); + + if (DebugPerf) + cerr << "FitsDatam::scan()..." + << " sample=" << minmaxSample_ + << " (" << params->xmin << ',' << params->ymin + << ") to (" << params->xmax << ',' << params->ymax << ") "; + + SETSIGBUS + for (int jj=params->ymin; jjymax; jj+=kk) { + float* ptr = data_ + jj*long(width_) + long(params->xmin); + for (int ii=params->xmin; iixmax; ii+=kk, ptr+=kk) { + register float value; + + if (!byteswap_) + value = *ptr; + else { + const char* p = (const char*)ptr; + union { + char c[4]; + float f; + } u; + + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + value = u.f; + } + + if (isfinite(value)) { + if (value < min_) { + min_ = value; + minXY_ = Vector(ii+1, jj+1); + } + if (value > max_) { + max_ = value; + maxXY_ = Vector(ii+1, jj+1); + } + } + } + } + CLEARSIGBUS + + // sanity check + if (min_ == FLT_MAX && max_ == -FLT_MAX) { + min_ =NAN; + max_ =NAN; + minXY_.origin(); + maxXY_.origin(); + } + else { + if (hasscaling_) { + min_ = min_*bscale_ + bzero_; + max_ = max_*bscale_ + bzero_; + } + } + + if (DebugPerf) { + cerr << "end" << endl; + cerr << "min: " << min_ << " max: " << max_ << endl; + } +} + +template <> void FitsDatam::scan(FitsBound* params) +{ + min_ = DBL_MAX; + max_ = -DBL_MAX; + minXY_.origin(); + maxXY_.origin(); + + int kk =calcIncr(); + + if (DebugPerf) + cerr << "FitsDatam::scan()..." + << " sample=" << minmaxSample_ + << " (" << params->xmin << ',' << params->ymin + << ") to (" << params->xmax << ',' << params->ymax << ") "; + + SETSIGBUS + for (int jj=params->ymin; jjymax; jj+=kk) { + double* ptr = data_ + jj*long(width_) + long(params->xmin); + for (int ii=params->xmin; iixmax; ii+=kk, ptr+=kk) { + register double value; + + if (!byteswap_) + value = *ptr; + else { + const char* p = (const char*)ptr; + union { + char c[8]; + double d; + } u; + + u.c[7] = *p++; + u.c[6] = *p++; + u.c[5] = *p++; + u.c[4] = *p++; + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + value = u.d; + } + + if (isfinite(value)) { + if (value < min_) { + min_ = value; + minXY_ = Vector(ii+1, jj+1); + } + if (value > max_) { + max_ = value; + maxXY_ = Vector(ii+1, jj+1); + } + } + } + } + CLEARSIGBUS + + // sanity check + if (min_ == DBL_MAX && max_ == -DBL_MAX) { + min_ =NAN; + max_ =NAN; + minXY_.origin(); + maxXY_.origin(); + } + else { + if (hasscaling_) { + min_ = min_*bscale_ + bzero_; + max_ = max_*bscale_ + bzero_; + } + } + + if (DebugPerf) { + cerr << "end" << endl; + cerr << "min: " << min_ << " max: " << max_ << endl; + } +} + +// Public + +// updateClip +template void FitsDatam::updateClip(FrScale* fr, FitsBound* params) +{ + if (DebugPerf) + cerr << "FitsDatam::updateClip()" << endl; + + clipMode_ = fr->clipMode(); + ulow_ = fr->ulow(); + uhigh_ = fr->uhigh(); + + // DATASEC + if (secMode_ != fr->secMode()) { + scanValid_ = 0; + zscaleValid_ = 0; + autoCutValid_ = 0; + } + secMode_ = fr->secMode(); + + // MINMAX + if (minmaxMode_ != fr->minmaxMode() || minmaxSample_ != fr->minmaxSample()) + scanValid_ = 0; + minmaxMode_ = fr->minmaxMode(); + minmaxSample_ = fr->minmaxSample(); + + // ZSCALE + if (zContrast_ != fr->zContrast() || + zSample_ != fr->zSample() || + zLine_ != fr->zLine()) + zscaleValid_ = 0; + zContrast_ = fr->zContrast(); + zSample_ = fr->zSample(); + zLine_ = fr->zLine(); + + // AUTOCUT + if (minmaxMode_ != fr->minmaxMode() || autoCutPer_ != fr->autoCutPer()) + autoCutValid_ = 0; + autoCutPer_ = fr->autoCutPer(); + + // always update min/max because everyone needs it + if (!scanValid_) { + scan(params); + scanValid_ = 1; + } + + switch (clipMode_) { + case FrScale::MINMAX: + low_ = min(); + high_ = max(); + break; + + case FrScale::ZSCALE: + if (!zscaleValid_) { + zscale(params); + zscaleValid_ = 1; + } + + low_ = zLow_; + high_ = zHigh_; + break; + + case FrScale::ZMAX: + // set low via zscale, high via minmax + if (!zscaleValid_) { + zscale(params); + zscaleValid_ = 1; + } + + low_ = zLow_; + high_ = max(); + break; + + case FrScale::AUTOCUT: + if (!autoCutValid_) { + autoCut(params); + autoCutValid_ = 1; + } + + low_ = aLow_; + high_ = aHigh_; + break; + + case FrScale::USERCLIP: + low_ = ulow_; + high_ = uhigh_; + break; + } +} + +// getValue + +template const char* FitsDatam::getValue(const Vector& vv) +{ + Vector v(vv); + + long x = (long)v[0]; + long y = (long)v[1]; + + ostringstream str; + + if (x >= 0 && x < width_ && y >= 0 && y < height_) { + register T value = !byteswap_ ? data_[y*width_ + x] : + swap(data_+(y*width_ + x)); + + if (hasblank_ && value == blank_) + str << "blank" << ends; + else if (hasscaling_) + str << value * bscale_ + bzero_ << ends; + else + output(str, value); + } + else + str << ends; + + memcpy(buf_,str.str().c_str(),str.str().length()); + return buf_; +} + +template <> const char* FitsDatam::getValue(const Vector& vv) +{ + Vector v(vv); + + long x = (long)v[0]; + long y = (long)v[1]; + + ostringstream str; + + if (x >= 0 && x < width_ && y >= 0 && y < height_) { + register float value = + !byteswap_ ? data_[y*width_ + x] : swap(data_+(y*width_ + x)); + + if (isinf(value)) + str << "inf" << ends; + else if (isnan(value)) + str << "nan" << ends; + else if (hasscaling_) + str << value * bscale_ + bzero_ << ends; + else + str << value << ends; + } + else + str << ends; + + memcpy(buf_,str.str().c_str(),str.str().length()); + return buf_; +} + +template <> const char* FitsDatam::getValue(const Vector& vv) +{ + Vector v(vv); + + long x = (long)v[0]; + long y = (long)v[1]; + + ostringstream str; + + if (x >= 0 && x < width_ && y >= 0 && y < height_) { + register double value = + !byteswap_ ? data_[y*width_ + x] : swap(data_+(y*width_ + x)); + + if (isinf(value)) + str << "inf" << ends; + else if (isnan(value)) + str << "nan" << ends; + else if (hasscaling_) + str << value * bscale_ + bzero_ << ends; + else + str << value << ends; + } + else + str << ends; + + memcpy(buf_,str.str().c_str(),str.str().length()); + return buf_; +} + +// getValueFloat(long) (optimized) +// no bounds checking, we need the speed + +template <> float FitsDatam::getValueFloat(long i) +{ + if (!hasblank_ && !hasscaling_) + return data_[i]; + + if (hasblank_ && data_[i] == blank_) + return NAN; + else + return hasscaling_ ? data_[i] * bscale_ + bzero_ : data_[i]; +} + +template <> float FitsDatam::getValueFloat(long i) +{ + if (!byteswap_ && !hasblank_ && !hasscaling_) + return data_[i]; + + if (!byteswap_) { + if (hasblank_ && data_[i] == blank_) + return NAN; + else + return hasscaling_ ? data_[i] * bscale_ + bzero_ : data_[i]; + } + else { + const char* p = (const char*)(data_+i); + union { + char c[2]; + short s; + } u; + + u.c[1] = *p++; + u.c[0] = *p; + + if (!hasblank_ && !hasscaling_) + return u.s; + + if (hasblank_ && u.s == blank_) + return NAN; + else + return hasscaling_ ? u.s * bscale_ + bzero_ : u.s; + } +} + +template <> float FitsDatam::getValueFloat(long i) +{ + if (!byteswap_ && !hasblank_ && !hasscaling_) + return data_[i]; + + if (!byteswap_) { + if (hasblank_ && data_[i] == blank_) + return NAN; + else + return hasscaling_ ? data_[i] * bscale_ + bzero_ : data_[i]; + } + else { + const char* p = (const char*)(data_+i); + union { + char c[2]; + unsigned short s; + } u; + + u.c[1] = *p++; + u.c[0] = *p; + + if (!hasblank_ && !hasscaling_) + return u.s; + + if (hasblank_ && u.s == blank_) + return NAN; + else + return hasscaling_ ? u.s * bscale_ + bzero_ : u.s; + } +} + +template <> float FitsDatam::getValueFloat(long i) +{ + if (!byteswap_ && !hasblank_ && !hasscaling_) + return data_[i]; + + if (!byteswap_) { + if (hasblank_ && data_[i] == blank_) + return NAN; + else + return hasscaling_ ? data_[i] * bscale_ + bzero_ : data_[i]; + } + else { + const char* p = (const char*)(data_+i); + union { + char c[4]; + int i; + } u; + + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + if (!hasblank_ && !hasscaling_) + return u.i; + + if (hasblank_ && u.i == blank_) + return NAN; + else + return hasscaling_ ? u.i * bscale_ + bzero_ : u.i; + } +} + +template <> float FitsDatam::getValueFloat(long i) +{ + if (!byteswap_ && !hasblank_ && !hasscaling_) + return data_[i]; + + if (!byteswap_) { + if (hasblank_ && data_[i] == blank_) + return NAN; + else + return hasscaling_ ? data_[i] * bscale_ + bzero_ : data_[i]; + } + else { + const char* p = (const char*)(data_+i); + union { + char c[8]; + long long i; + } u; + + u.c[7] = *p++; + u.c[6] = *p++; + u.c[5] = *p++; + u.c[4] = *p++; + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + if (!hasblank_ && !hasscaling_) + return u.i; + + if (hasblank_ && u.i == blank_) + return NAN; + else + return hasscaling_ ? u.i * bscale_ + bzero_ : u.i; + } +} + +template <> float FitsDatam::getValueFloat(long i) +{ + if (!byteswap_) + if (isfinite(data_[i])) + return hasscaling_ ? data_[i] * bscale_ + bzero_ : data_[i]; + else + return NAN; + else { + const char* p = (const char*)(data_+i); + union { + char c[4]; + float f; + } u; + + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + if (isfinite(u.f)) + return hasscaling_ ? u.f * bscale_ + bzero_ : u.f; + else + return NAN; + } +} + +template <> float FitsDatam::getValueFloat(long i) +{ + if (!byteswap_) + if (isfinite(data_[i])) + return hasscaling_ ? (float)data_[i] * bscale_ + bzero_ : (float)data_[i]; + else + return NAN; + else { + const char* p = (const char*)(data_+i); + union { + char c[8]; + double d; + } u; + + u.c[7] = *p++; + u.c[6] = *p++; + u.c[5] = *p++; + u.c[4] = *p++; + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + if (isfinite(u.d)) + return hasscaling_ ? (float)u.d * bscale_ + bzero_ : (float)u.d; + else + return NAN; + } +} + +// getValueFloat(const Vector&) + +template float FitsDatam::getValueFloat(const Vector& v) +{ + Vector r = v; + long x = (long)r[0]; + long y = (long)r[1]; + + if (x >= 0 && x < width_ && y >= 0 && y < height_) { + register T value = !byteswap_ ? data_[y*width_ + x] : + swap(data_+(y*width_ + x)); + + if (hasblank_ && value == blank_) + return NAN; + + return hasscaling_ ? value * bscale_ + bzero_ : value; + } + else + return NAN; +} + +template <> float FitsDatam::getValueFloat(const Vector& v) +{ + Vector r = v; + long x = (long)r[0]; + long y = (long)r[1]; + + if (x >= 0 && x < width_ && y >= 0 && y < height_) { + register float value = !byteswap_ ? data_[y*width_ + x] : + swap(data_+(y*width_ + x)); + + if (isfinite(value)) + return hasscaling_ ? value * bscale_ + bzero_ : value; + else + return NAN; + } + else + return NAN; +} + +template <> float FitsDatam::getValueFloat(const Vector& v) +{ + Vector r = v; + long x = (long)r[0]; + long y = (long)r[1]; + + if (x >= 0 && x < width_ && y >= 0 && y < height_) { + register double value = !byteswap_ ? data_[y*width_ + x] : + swap(data_+(y*width_ + x)); + + if (isfinite(value)) + return hasscaling_ ? (float)value * bscale_ + bzero_ : (float)value; + else + return NAN; + } + else + return NAN; +} + +// getValueDouble(long) (optimized) +// no bounds checking, we need the speed + +template <> double FitsDatam::getValueDouble(long i) +{ + if (!hasblank_ && !hasscaling_) + return data_[i]; + + if (hasblank_ && data_[i] == blank_) + return NAN; + else + return hasscaling_ ? data_[i] * bscale_ + bzero_ : data_[i]; +} + +template <> double FitsDatam::getValueDouble(long i) +{ + if (!byteswap_ && !hasblank_ && !hasscaling_) + return data_[i]; + + if (!byteswap_) { + if (hasblank_ && data_[i] == blank_) + return NAN; + else + return hasscaling_ ? data_[i] * bscale_ + bzero_ : data_[i]; + } + else { + const char* p = (const char*)(data_+i); + union { + char c[2]; + short s; + } u; + + u.c[1] = *p++; + u.c[0] = *p; + + if (!hasblank_ && !hasscaling_) + return u.s; + + if (hasblank_ && u.s == blank_) + return NAN; + else + return hasscaling_ ? u.s * bscale_ + bzero_ : u.s; + } +} + +template <> double FitsDatam::getValueDouble(long i) +{ + if (!byteswap_ && !hasblank_ && !hasscaling_) + return data_[i]; + + if (!byteswap_) { + if (hasblank_ && data_[i] == blank_) + return NAN; + else + return hasscaling_ ? data_[i] * bscale_ + bzero_ : data_[i]; + } + else { + const char* p = (const char*)(data_+i); + union { + char c[2]; + unsigned short s; + } u; + + u.c[1] = *p++; + u.c[0] = *p; + + if (!hasblank_ && !hasscaling_) + return u.s; + + if (hasblank_ && u.s == blank_) + return NAN; + else + return hasscaling_ ? u.s * bscale_ + bzero_ : u.s; + } +} + +template <> double FitsDatam::getValueDouble(long i) +{ + if (!byteswap_ && !hasblank_ && !hasscaling_) + return data_[i]; + + if (!byteswap_) { + if (hasblank_ && data_[i] == blank_) + return NAN; + else + return hasscaling_ ? data_[i] * bscale_ + bzero_ : data_[i]; + } + else { + const char* p = (const char*)(data_+i); + union { + char c[4]; + int i; + } u; + + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + if (!hasblank_ && !hasscaling_) + return u.i; + + if (hasblank_ && u.i == blank_) + return NAN; + else + return hasscaling_ ? u.i * bscale_ + bzero_ : u.i; + } +} + +template <> double FitsDatam::getValueDouble(long i) +{ + if (!byteswap_ && !hasblank_ && !hasscaling_) + return data_[i]; + + if (!byteswap_) { + if (hasblank_ && data_[i] == blank_) + return NAN; + else + return hasscaling_ ? data_[i] * bscale_ + bzero_ : data_[i]; + } + else { + const char* p = (const char*)(data_+i); + union { + char c[8]; + long long i; + } u; + + u.c[7] = *p++; + u.c[6] = *p++; + u.c[5] = *p++; + u.c[4] = *p++; + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + if (!hasblank_ && !hasscaling_) + return u.i; + + if (hasblank_ && u.i == blank_) + return NAN; + else + return hasscaling_ ? u.i * bscale_ + bzero_ : u.i; + } +} + +template <> double FitsDatam::getValueDouble(long i) +{ + if (!byteswap_ && !hasscaling_) + return (double)data_[i]; + + if (!byteswap_) { + if (isfinite(data_[i])) + return hasscaling_ ? (double)data_[i] * bscale_ + bzero_ : (double)data_[i]; + else + return NAN; + } + else { + const char* p = (const char*)(data_+i); + union { + char c[4]; + float f; + } u; + + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + if (isfinite(u.f)) + return hasscaling_ ? (double)u.f * bscale_ + bzero_ : (double)u.f; + else + return NAN; + } +} + +template <> double FitsDatam::getValueDouble(long i) +{ + if (!byteswap_ && !hasscaling_) + return (double)data_[i]; + + if (!byteswap_) { + if (isfinite(data_[i])) + return hasscaling_ ? data_[i] * bscale_ + bzero_ : data_[i]; + else + return NAN; + } + else { + const char* p = (const char*)(data_+i); + union { + char c[8]; + double d; + } u; + + u.c[7] = *p++; + u.c[6] = *p++; + u.c[5] = *p++; + u.c[4] = *p++; + u.c[3] = *p++; + u.c[2] = *p++; + u.c[1] = *p++; + u.c[0] = *p; + + if (isfinite(u.d)) + return hasscaling_ ? u.d * bscale_ + bzero_ : u.d; + else + return NAN; + } +} + +// getValueDouble(const Vector&) + +template double FitsDatam::getValueDouble(const Vector& v) +{ + Vector r = v; + long x = (long)r[0]; + long y = (long)r[1]; + + if (x >= 0 && x < width_ && y >= 0 && y < height_) { + register T value = !byteswap_ ? data_[y*width_ + x] : + swap(data_+(y*width_ + x)); + + if (hasblank_ && value == blank_) + return NAN; + + return hasscaling_ ? value * bscale_ + bzero_ : value; + } + else + return NAN; +} + +template <> double FitsDatam::getValueDouble(const Vector& v) +{ + Vector r = v; + long x = (long)r[0]; + long y = (long)r[1]; + + if (x >= 0 && x < width_ && y >= 0 && y < height_) { + register float value = !byteswap_ ? data_[y*width_ + x] : + swap(data_+(y*width_ + x)); + + if (isfinite(value)) + return hasscaling_ ? (double)value * bscale_ + bzero_ : (double)value; + else + return NAN; + } + else + return NAN; +} + +template <> double FitsDatam::getValueDouble(const Vector& v) +{ + Vector r = v; + long x = (long)r[0]; + long y = (long)r[1]; + + if (x >= 0 && x < width_ && y >= 0 && y < height_) { + register double value = !byteswap_ ? data_[y*width_ + x] : + swap(data_+(y*width_ + x)); + + if (isfinite(value)) + return hasscaling_ ? value * bscale_ + bzero_ : value; + else + return NAN; + } + else + return NAN; +} + +// getValueMask + +template int FitsDatam::getValueMask(const Vector& v) +{ + Vector r = v; + long x = (long)r[0]; + long y = (long)r[1]; + + if (x >= 0 && x < width_ && y >= 0 && y < height_) + return data_[y*width_ + x] ? 1 : 0; + else + return 0; +} + +template int FitsDatam::getValueMask(double xx, double yy) +{ + long x = (long)xx; + long y = (long)yy; + + if (x >= 0 && x < width_ && y >= 0 && y < height_) + return data_[y*width_ + x] ? 1 : 0; + else + return 0; +} + +template int FitsDatam::getValueMask(long i) +{ + return data_[i] ? 1 : 0; +} + +// bin + +template void FitsDatam::hist(double* arr, int length, double mn, + double mx, FitsBound* params) +{ + if (DebugPerf) + cerr << "FitsDatam::hist()" << endl; + + double diff = mx-mn; + int last = length-1; + int kk =calcIncr(); + + // special case: mx-mn=0 + if (!diff) { + arr[0] = (params->xmax-params->xmin)*(params->ymax-params->ymin); + return; + } + + SETSIGBUS + for (int jj=params->ymin; jjymax; jj+=kk) { + T* ptr = data_ + jj*long(width_) + long(params->xmin); + for (int ii=params->xmin; iixmax; ii+=kk, ptr+=kk) { + + register double value = !byteswap_ ? *ptr : swap(ptr); + if (hasblank_ && value == blank_) + continue; // skip nan's + + if (hasscaling_) + value = value * bscale_ + bzero_; + + if (value>=mn && value <=mx) + arr[(int)((value-mn)/diff*last+.5)]++; + } + } + CLEARSIGBUS +} + +template <> void FitsDatam::hist(double* arr, int length, double mn, + double mx, FitsBound* params) +{ + if (DebugPerf) + cerr << "FitsDatam::hist()" << endl; + + double diff = mx-mn; + // the last location is always 0 + int last = length-2; + int kk =calcIncr(); + + // special case: mx-mn=0 + if (!diff) { + arr[0] = (params->xmax-params->xmin)*(params->ymax-params->ymin); + return; + } + + SETSIGBUS + for (int jj=params->ymin; jjymax; jj+=kk) { + float* ptr = data_ + jj*long(width_) + long(params->xmin); + for (int ii=params->xmin; iixmax; ii+=kk, ptr+=kk) { + + register double value = !byteswap_ ? *ptr : swap(ptr); + if (!isfinite(value)) + continue; // skip nan's + + if (hasscaling_) + value = value * bscale_ + bzero_; + + if (value>=mn && value<=mx) + arr[(int)((value-mn)/diff*last+.5)]++; + } + } + CLEARSIGBUS +} + +template <> void FitsDatam::hist(double* arr, int length, double mn, + double mx, FitsBound* params) +{ + if (DebugPerf) + cerr << "FitsDatam::hist()" << endl; + + double diff = mx-mn; + int last = length-1; + int kk =calcIncr(); + + // special case: mx-mn=0 + if (!diff) { + arr[0] = (params->xmax-params->xmin)*(params->ymax-params->ymin); + return; + } + + SETSIGBUS + for (int jj=params->ymin; jjymax; jj+=kk) { + double* ptr = data_ + jj*long(width_) + long(params->xmin); + for (int ii=params->xmin; iixmax; ii+=kk, ptr+=kk) { + + register double value = !byteswap_ ? *ptr : swap(ptr); + if (!isfinite(value)) + continue; // skip nan's + + if (hasscaling_) + value = value * bscale_ + bzero_; + + if (value>=mn && value <=mx) + arr[(int)((value-mn)/diff*last+.5)]++; + } + } + CLEARSIGBUS +} + +// ZSCALE + +// ZSCALE -- Compute the optimal Z1, Z2 (range of greyscale values to be +// displayed) of an image. For efficiency a statistical subsample of an image +// is used. The pixel sample evenly subsamples the image in x and y. The +// entire image is used if the number of pixels in the image is smaller than +// the desired sample. +// +// The sample is accumulated in a buffer and sorted by greyscale value. +// The median value is the central value of the sorted array. The slope of a +// straight line fitted to the sorted sample is a measure of the standard +// deviation of the sample about the median value. Our algorithm is to sort +// the sample and perform an iterative fit of a straight line to the sample, +// using pixel rejection to omit gross deviants near the endpoints. The fitted +// straight line is the transfer function used to map image Z into display Z. +// If more than half the pixels are rejected the full range is used. The slope +// of the fitted line is divided by the user-supplied contrast factor and the +// final Z1 and Z2 are computed, taking the origin of the fitted line at the +// median value. + +template void FitsDatam::zscale(FitsBound* params) +{ + // Subsample the image + + float* sample; + int npix = zSampleImage(&sample,params); + int center_pixel = ZSMAX(1, (npix + 1) / 2); + + // Sort the sample, compute the minimum, maximum, and median pixel values + + qsort((void*)sample, npix, sizeof(float), fCompare); + float zmin = *sample; + float zmax = *(sample+ZSMAX(npix,1)-1); + + // The median value is the average of the two central values if there + // are an even number of pixels in the sample. + + float* left = &(sample[center_pixel - 1]); + + float median; + if (ZSMOD(npix, 2) == 1 || center_pixel >= npix) + median = *left; + else + median = (*left + *(left+1)) / 2; + + // Fit a line to the sorted sample vector. If more than half of the + // pixels in the sample are rejected give up and return the full range. + // If the user-supplied contrast factor is not 1.0 adjust the scale + // accordingly and compute zLow and zHigh, the y intercepts at indices 1 and + // npix. + + int minpix = ZSMAX(ZSMIN_NPIXELS, (int)(npix * ZSMAX_REJECT)); + int ngrow = ZSMAX(1, ZSNINT(npix * .01)); + float zstart, zslope; + + int ngoodpix = zFitLine(sample, npix, &zstart, &zslope, + ZSKREJ, ngrow, ZSMAX_ITERATIONS); + + if (ngoodpix < minpix) { + zLow_ = zmin; + zHigh_ = zmax; + } + else { + if (zContrast_ > 0) + zslope = zslope / zContrast_; + zLow_ = ZSMAX(zmin, median - (center_pixel - 1) * zslope); + zHigh_ = ZSMIN(zmax, median + (npix - center_pixel) * zslope); + } + + delete [] sample; +} + +// sampleImage -- Extract an evenly gridded subsample of the pixels from +// a two-dimensional image into a one-dimensional vector. + +template int FitsDatam::zSampleImage(float** sample, FitsBound* params) +{ + // Compute the number of pixels each line will contribute to the sample, + // and the subsampling step size for a line. The sampling grid must + // span the whole line on a uniform grid. + + int wd = params->xmax - params->xmin; + int opt_npix_per_line = ZSMAX(1, ZSMIN(wd, zLine_)); + int col_step = ZSMAX(2, (wd + opt_npix_per_line-1) / opt_npix_per_line); + int npix_per_line = ZSMAX(1, (wd + col_step-1) / col_step); + + /* + int opt_npix_per_line = ZSMAX(1, ZSMIN(width, zLine)); + int col_step = ZSMAX(2, (width + opt_npix_per_line-1) / opt_npix_per_line); + int npix_per_line = ZSMAX(1, (width + col_step-1) / col_step); + */ + + // Compute the number of lines to sample and the spacing between lines. + // We must ensure that the image is adequately sampled despite its + // size, hence there is a lower limit on the number of lines in the + // sample. We also want to minimize the number of lines accessed when + // accessing a large image, because each disk seek and read is ex- + // pensive. The number of lines extracted will be roughly the sample + // size divided by zLine, possibly more if the lines are very + // short. + + int hd = params->ymax-params->ymin; + int min_nlines_in_sample = ZSMAX(1, zSample_ / zLine_); + int opt_nlines_in_sample = ZSMAX(min_nlines_in_sample, + ZSMIN(hd, (zSample_ + npix_per_line-1) / + npix_per_line)); + int line_step = ZSMAX(2, hd / opt_nlines_in_sample); + int max_nlines_in_sample = (hd + line_step-1) / line_step; + + /* + int min_nlines_in_sample = ZSMAX(1, zSample / zLine); + int opt_nlines_in_sample = ZSMAX(min_nlines_in_sample, + ZSMIN(height, (zSample + npix_per_line-1) / + npix_per_line)); + int line_step = ZSMAX(2, height / opt_nlines_in_sample); + int max_nlines_in_sample = (height + line_step-1) / line_step; + */ + + // Allocate space for the output vector. Buffer must be freed by our caller. + + int maxpix = npix_per_line * max_nlines_in_sample; + *sample = new float[maxpix]; + // float* row = new float[width]; + float* row = new float[wd]; + + // Extract the vector + + int npix = 0; + float* op = *sample; + + // for (int line = (line_step + 1)/2; line < height; line+=line_step) { + for (int line = (line_step + 1)/2 + params->ymin; line < params->ymax; line+=line_step) { + + // Load a row of values from the image + + // for (int i=0; i < width; i++) { + for (int i=0; ixmin); + T value = !byteswap_ ? *ptr : swap(ptr); + + if (hasblank_ && (value == blank_)) + row[i] = NAN; + else + row[i] = hasscaling_ ? value * bscale_ + bzero_ : value; + } + + int got = zSubSample(row, op, npix_per_line, col_step); + op += got; + npix += got; + if (npix >= maxpix) + break; + } + + delete [] row; + return npix; +} + +template <> int FitsDatam::zSampleImage(float** sample, FitsBound* params) +{ + // Compute the number of pixels each line will contribute to the sample, + // and the subsampling step size for a line. The sampling grid must + // span the whole line on a uniform grid. + + int wd = params->xmax - params->xmin; + int opt_npix_per_line = ZSMAX(1, ZSMIN(wd, zLine_)); + int col_step = ZSMAX(2, (wd + opt_npix_per_line-1) / opt_npix_per_line); + int npix_per_line = ZSMAX(1, (wd + col_step-1) / col_step); + + /* + int opt_npix_per_line = ZSMAX(1, ZSMIN(width, zLine)); + int col_step = ZSMAX(2, (width + opt_npix_per_line-1) / opt_npix_per_line); + int npix_per_line = ZSMAX(1, (width + col_step-1) / col_step); + */ + + // Compute the number of lines to sample and the spacing between lines. + // We must ensure that the image is adequately sampled despite its + // size, hence there is a lower limit on the number of lines in the + // sample. We also want to minimize the number of lines accessed when + // accessing a large image, because each disk seek and read is ex- + // pensive. The number of lines extracted will be roughly the sample + // size divided by zLine, possibly more if the lines are very + // short. + + int hd = params->ymax-params->ymin; + int min_nlines_in_sample = ZSMAX(1, zSample_ / zLine_); + int opt_nlines_in_sample = ZSMAX(min_nlines_in_sample, + ZSMIN(hd, (zSample_ + npix_per_line-1) / + npix_per_line)); + int line_step = ZSMAX(2, hd / opt_nlines_in_sample); + int max_nlines_in_sample = (hd + line_step-1) / line_step; + + /* + int min_nlines_in_sample = ZSMAX(1, zSample / zLine); + int opt_nlines_in_sample = ZSMAX(min_nlines_in_sample, + ZSMIN(height, (zSample + npix_per_line-1) / + npix_per_line)); + int line_step = ZSMAX(2, height / opt_nlines_in_sample); + int max_nlines_in_sample = (height + line_step-1) / line_step; + */ + + // Allocate space for the output vector. Buffer must be freed by our caller. + + int maxpix = npix_per_line * max_nlines_in_sample; + *sample = new float[maxpix]; + // float* row = new float[width]; + float* row = new float[wd]; + + // Extract the vector + + int npix = 0; + float* op = *sample; + + // for (int line = (line_step + 1)/2; line < height; line+=line_step) { + for (int line = (line_step + 1)/2 + params->ymin; line < params->ymax; line+=line_step) { + + // Load a row of values from the image + + // for (int i=0; i < width; i++) { + for (int i=0; ixmin); + float value = !byteswap_ ? *ptr : swap(ptr); + + if (isfinite(value)) + row[i] = hasscaling_ ? value * bscale_ + bzero_ : value; + else + row[i] = NAN; + } + + int got = zSubSample(row, op, npix_per_line, col_step); + op += got; + npix += got; + if (npix >= maxpix) + break; + } + + delete [] row; + return npix; +} + +template <> int FitsDatam::zSampleImage(float** sample, FitsBound* params) +{ + // Compute the number of pixels each line will contribute to the sample, + // and the subsampling step size for a line. The sampling grid must + // span the whole line on a uniform grid. + + int wd = params->xmax - params->xmin; + int opt_npix_per_line = ZSMAX(1, ZSMIN(wd, zLine_)); + int col_step = ZSMAX(2, (wd + opt_npix_per_line-1) / opt_npix_per_line); + int npix_per_line = ZSMAX(1, (wd + col_step-1) / col_step); + + /* + int opt_npix_per_line = ZSMAX(1, ZSMIN(width, zLine)); + int col_step = ZSMAX(2, (width + opt_npix_per_line-1) / opt_npix_per_line); + int npix_per_line = ZSMAX(1, (width + col_step-1) / col_step); + */ + + // Compute the number of lines to sample and the spacing between lines. + // We must ensure that the image is adequately sampled despite its + // size, hence there is a lower limit on the number of lines in the + // sample. We also want to minimize the number of lines accessed when + // accessing a large image, because each disk seek and read is ex- + // pensive. The number of lines extracted will be roughly the sample + // size divided by zLine, possibly more if the lines are very + // short. + + int hd = params->ymax-params->ymin; + int min_nlines_in_sample = ZSMAX(1, zSample_ / zLine_); + int opt_nlines_in_sample = ZSMAX(min_nlines_in_sample, + ZSMIN(hd, (zSample_ + npix_per_line-1) / + npix_per_line)); + int line_step = ZSMAX(2, hd / opt_nlines_in_sample); + int max_nlines_in_sample = (hd + line_step-1) / line_step; + + /* + int min_nlines_in_sample = ZSMAX(1, zSample / zLine); + int opt_nlines_in_sample = ZSMAX(min_nlines_in_sample, + ZSMIN(height, (zSample + npix_per_line-1) / + npix_per_line)); + int line_step = ZSMAX(2, height / opt_nlines_in_sample); + int max_nlines_in_sample = (height + line_step-1) / line_step; + */ + + // Allocate space for the output vector. Buffer must be freed by our caller. + + int maxpix = npix_per_line * max_nlines_in_sample; + *sample = new float[maxpix]; + // float* row = new float[width]; + float* row = new float[wd]; + + // Extract the vector + + int npix = 0; + float* op = *sample; + + // for (int line = (line_step + 1)/2; line < height; line+=line_step) { + for (int line = (line_step + 1)/2 + params->ymin; line < params->ymax; line+=line_step) { + + // Load a row of values from the image + + // for (int i=0; i < width; i++) { + for (int i=0; ixmin); + double value = !byteswap_ ? *ptr : swap(ptr); + + if (isfinite(value)) + row[i] = hasscaling_ ? (float)value * bscale_ + bzero_ : (float)value; + else + row[i] = NAN; + } + + int got = zSubSample(row, op, npix_per_line, col_step); + op += got; + npix += got; + if (npix >= maxpix) + break; + } + + delete [] row; + return npix; +} + +// subSample -- Subsample an image line. Extract the first pixel and +// every "step"th pixel thereafter for a total of npix pixels. + +int FitsData::zSubSample(float* a, float* b, int npix, int step) +{ + if (step <= 1) + step = 1; + + int got = 0; + int ip = 0; + for (int i=0; i 0) { + double rowrat = sumx / sumxsqr; + z0 = (sumz - rowrat * sumxz) / (ngoodpix - rowrat * sumx); + dz = (sumxz - z0 * sumx) / sumxsqr; + } + + if (ngoodpix >= last_ngoodpix || ngoodpix < minpix) + break; + } + + // Transform the line coefficients back to the X range [1:npix] + + *zstart = z0 - dz; + *zslope = dz * xscale; + + delete [] flat; + delete [] normx; + delete [] badpix; + + return ngoodpix; +} + + +// flattenData -- Compute and subtract the fitted line from the data array, +// returned the flattened data in FLAT. + +void FitsData::zFlattenData(float* sampleData, float* flat, float* x, + int npix, float z0, float dz) +{ + for (int i=0; i < npix; i++) + flat[i] = sampleData[i] - (x[i] * dz + z0); +} + +// computeSigma -- Compute the root mean square deviation from the +// mean of a flattened array. Ignore rejected pixels. + +int FitsData::zComputeSigma(float* a, short* badpix, int npix, + float* mean, float* sigma) +{ + int ngoodpix = 0; + double sum = 0.0; + double sumsq = 0.0; + + // Accumulate sum and sum of squares + + for (int i=0; i < npix; i++) + if (badpix[i] == GOOD_PIXEL) { + float pixval = a[i]; + ngoodpix = ngoodpix + 1; + sum = sum + pixval; + sumsq = sumsq + pixval * pixval; + } + + // Compute mean and sigma + + switch (ngoodpix) { + case 0: + *mean = ZSINDEF; + *sigma = ZSINDEF; + break; + case 1: + *mean = sum; + *sigma = ZSINDEF; + break; + default: + *mean = sum / ngoodpix; + double temp = sumsq / (ngoodpix-1) - (sum*sum) / (ngoodpix*(ngoodpix - 1)); + if (temp < 0) // possible with roundoff error + *sigma = 0.0; + else + *sigma = sqrt(temp); + } + + return ngoodpix; +} + +// rejectPixels -- Detect and reject pixels more than "threshold" greyscale +// units from the fitted line. The residuals about the fitted line are given +// by the "flat" array, while the raw data is in "data". Each time a pixel +// is rejected subtract its contributions from the matrix sums and flag the +// pixel as rejected. When a pixel is rejected reject its neighbors out to +// a specified radius as well. This speeds up convergence considerably and +// produces a more stringent rejection criteria which takes advantage of the +// fact that bad pixels tend to be clumped. The number of pixels left in the +// fit is returned as the function value. + +int FitsData::zRejectPixels(float* sampleData, float* flat, float *normx, + short *badpix, int npix, double* sumxsqr, + double* sumxz, double* sumx, double* sumz, + float threshold, int ngrow) +{ + int ngoodpix = npix; + float lcut = -threshold; + float hcut = threshold; + + for (int i=0; i < npix; i++) { + if (badpix[i] == BAD_PIXEL) + ngoodpix = ngoodpix - 1; + else { + float residual = flat[i]; + if (residual < lcut || residual > hcut) { + + // Reject the pixel and its neighbors out to the growing + // radius. We must be careful how we do this to avoid + // directional effects. Do not turn off thresholding on + // pixels in the forward direction; mark them for rejection + // but do not reject until they have been thresholded. + // If this is not done growing will not be symmetric. + + for (int j=ZSMAX(0,i-ngrow); j < ZSMIN(npix,i+ngrow); j++) { + if (badpix[j] != BAD_PIXEL) { + if (j <= i) { + double x = normx[j]; + double z = sampleData[j]; + *sumxsqr = *sumxsqr - (x * x); + *sumxz = *sumxz - z * x; + *sumx = *sumx - x; + *sumz = *sumz - z; + badpix[j] = BAD_PIXEL; + ngoodpix = ngoodpix - 1; + } else + badpix[j] = REJECT_PIXEL; + } + } + } + } + } + + return ngoodpix; +} + +template class FitsDatam; +template class FitsDatam; +template class FitsDatam; +template class FitsDatam; +template class FitsDatam; +template class FitsDatam; +template class FitsDatam; diff --git a/tksao/frame/fitsdata.h b/tksao/frame/fitsdata.h new file mode 100644 index 0000000..230336e --- /dev/null +++ b/tksao/frame/fitsdata.h @@ -0,0 +1,173 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsdata_h__ +#define __fitsdata_h__ + +#include "base.h" +#include "file.h" + +class ColorScale; +class FitsFile; + +class FitsBound { + public: + int xmin; + int xmax; + int ymin; + int ymax; + + public: + FitsBound() {xmin= xmax= ymin= ymax= 0;} + FitsBound(int x0, int y0, int x1, int y1) + {xmin=x0; xmax=x1; ymin=y0; ymax=y1;} + FitsBound(const FitsBound &bb) + {xmin=bb.xmin; xmax=bb.xmax; ymin=bb.ymin; ymax=bb.ymax;} + void set(int x0, int y0, int x1, int y1) {xmin=x0; xmax=x1; ymin=y0; ymax=y1;} +}; +ostream& operator<<(ostream&, const FitsBound&); + +class FitsData { +protected: + Tcl_Interp* interp_; + + long width_; + long height_; + char buf_[32]; + + int byteswap_; + + double bscale_; + double bzero_; + int hasscaling_; + + int blank_; + int hasblank_; + + double min_; // bscale applied + Vector minXY_; + double max_; // bscale applied + Vector maxXY_; + + double high_; // bscale applied + double low_; // bscale applied + + float zHigh_; // bscale applied + float zLow_; // bscale applied + double aLow_; // bscale applied + double aHigh_; // bscale applied + double ulow_; // bscale applied + double uhigh_; // bscale applied + + int scanValid_; + int minmaxSample_; + + float zContrast_; + int zSample_; + int zLine_; + int zscaleValid_; + + int autoCutValid_; + float autoCutPer_; + + FrScale::ClipMode clipMode_; + FrScale::MinMaxMode minmaxMode_; + FrScale::SecMode secMode_; + + double datamin_; // bscale applied + double datamax_; // bscale applied + int hasdatamin_; + + double irafmin_; // bscale applied + double irafmax_; // bscale applied + int hasirafmin_; + + // zscale constants + + enum PixelType {GOOD_PIXEL, BAD_PIXEL, REJECT_PIXEL}; + + int zSubSample(float*, float*, int, int); + int zFitLine(float*, int, float*, float*, float, int, int); + void zFlattenData (float*, float*, float*, int npix, float, float dz); + int zComputeSigma (float*, short*, int npix, float*, float*); + int zRejectPixels (float*, float*, float*, short*, int, double*, + double*, double*, double*, float, int); + + protected: + void autoCut(FitsBound*); + int calcIncr(); + +public: + FitsData(FitsFile*, Tcl_Interp*); + virtual ~FitsData(); + + virtual void* data() =0; + virtual const char* getValue(const Vector&) =0; + virtual float getValueFloat(const Vector&) =0; + virtual double getValueDouble(const Vector&) =0; + virtual int getValueMask(const Vector&) =0; + virtual int getValueMask(double,double) =0; + + virtual float getValueFloat(long) =0; + virtual double getValueDouble(long) =0; + virtual int getValueMask(long) =0; + + double min(); + const Vector& minXY() {return minXY_;} + double max(); + const Vector& maxXY() {return maxXY_;} + + const char* getMin(); + const char* getMinX(); + const char* getMinY(); + const char* getMax(); + const char* getMaxX(); + const char* getMaxY(); + const char* getLow(); + const char* getHigh(); + + double low() {return low_;} + double high() {return high_;} + + void setClip(double ll, double hh) {low_ =ll; high_ =hh;} + + virtual void updateClip(FrScale*, FitsBound*) =0; + int hasDATAMIN() {return hasdatamin_;} + int hasIRAFMIN() {return hasirafmin_;} + + virtual void hist(double*,int,double,double,FitsBound*) =0; +}; + +template +class FitsDatam : public FitsData { + private: + T* data_; + + void scan(FitsBound*); + void output(ostringstream&, T); + void zscale(FitsBound*); + int zSampleImage(float**,FitsBound*); + + public: + FitsDatam(FitsFile*, Tcl_Interp*); + + T swap(T*); + + void* data() {return data_;} + const char* getValue(const Vector&); + + float getValueFloat(const Vector&); + double getValueDouble(const Vector&); + int getValueMask(const Vector&); + int getValueMask(double, double); + + float getValueFloat(long i); + double getValueDouble(long i); + int getValueMask(long i); + + void updateClip(FrScale*, FitsBound*); + void hist(double*, int, double, double, FitsBound*); +}; + +#endif diff --git a/tksao/frame/fitsenvi.C b/tksao/frame/fitsenvi.C new file mode 100644 index 0000000..fd68f4f --- /dev/null +++ b/tksao/frame/fitsenvi.C @@ -0,0 +1,74 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "fitsimage.h" +#include "envi.h" + +void FitsImage::initENVI() +{ + if (post_) + delete post_; + post_ = NULL; + + switch (fits_->pEncoding()) { + case FitsFile::BSQ: + // better not see this + break; + case FitsFile::BIL: + switch (fits_->pBitpix()) { + case 8: + post_ = new FitsENVIBILm(fits_); + break; + case 16: + post_ = new FitsENVIBILm(fits_); + break; + case -16: + post_ = new FitsENVIBILm(fits_); + break; + case 32: + post_ = new FitsENVIBILm(fits_); + break; + case 64: + post_ = new FitsENVIBILm(fits_); + break; + case -32: + post_ = new FitsENVIBILm(fits_); + break; + case -64: + post_ = new FitsENVIBILm(fits_); + break; + } + break; + case FitsFile::BIP: + switch (fits_->pBitpix()) { + case 8: + post_ = new FitsENVIBIPm(fits_); + break; + case 16: + post_ = new FitsENVIBIPm(fits_); + break; + case -16: + post_ = new FitsENVIBIPm(fits_); + break; + case 32: + post_ = new FitsENVIBIPm(fits_); + break; + case 64: + post_ = new FitsENVIBIPm(fits_); + break; + case -32: + post_ = new FitsENVIBIPm(fits_); + break; + case -64: + post_ = new FitsENVIBIPm(fits_); + break; + } + break; + default: + // na + break; + } + + return; +} diff --git a/tksao/frame/fitshealpix.C b/tksao/frame/fitshealpix.C new file mode 100644 index 0000000..db28a46 --- /dev/null +++ b/tksao/frame/fitshealpix.C @@ -0,0 +1,79 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "fitsimage.h" +#include "hpx.h" + +void FitsImage::initHPX() +{ + if (hpx_) + delete hpx_; + hpx_ = NULL; + + // make sure we have rows and cols + FitsHead* head = fits_->head(); + FitsTableHDU* hdu = NULL; + if (head) { + hdu = (FitsTableHDU*)(head->hdu()); + if (!hdu->width() || !hdu->rows()) + return; + } + + // coordinate system identifier? + FitsHPX::CoordSys coord = FitsHPX::UNKNOWN; + if (fits_->pHPXSystem() >= 0) + coord = (FitsHPX::CoordSys)fits_->pHPXSystem(); + else { + char* str = head->getString("COORDSYS"); + if (str) { + if (str[0] == 'G') + coord = FitsHPX::GAL; + else if (str[0] == 'E') + coord = FitsHPX::ECL; + else if (str[0] == 'C') + coord = FitsHPX::EQU; + else if (str[0] == 'Q') + coord = FitsHPX::EQU; + + delete [] str; + } + } + + // Nested or ring order? + FitsHPX::Order order = FitsHPX::RING; + if (fits_->pHPXOrder() >=0) + order = (FitsHPX::Order)fits_->pHPXOrder(); + else { + char* str = head->getString("ORDERING"); + if (str) { + if (str[0] == 'N') + order = FitsHPX::NESTED; + else if (str[0] == 'R') + order = FitsHPX::RING; + + delete [] str; + } + } + + // Layout + FitsHPX::Layout layout = FitsHPX::EQUATOR; + if (fits_->pHPXLayout() >=0) + layout = (FitsHPX::Layout)fits_->pHPXLayout(); + + // Col + int col =0; + if (fits_->pHPXColumn() >=0) + col = fits_->pHPXColumn(); + if (col<0) + col =0; + + // Quad + int quad = 0; + if (fits_->pHPXQuad() >=0) + quad = fits_->pHPXQuad(); + if (quad<0 || quad>3) + quad =0; + + hpx_ = new FitsHPX(fits_, order, coord, layout, col, quad); +} diff --git a/tksao/frame/fitsimage.C b/tksao/frame/fitsimage.C new file mode 100644 index 0000000..76d5843 --- /dev/null +++ b/tksao/frame/fitsimage.C @@ -0,0 +1,4049 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __WIN32 +#include +#endif + +#include "fitsimage.h" +#include "framebase.h" + +#include "context.h" +#include "mmap.h" +#include "smmap.h" +#include "mmapincr.h" +#include "alloc.h" +#include "allocgz.h" +#include "channel.h" +#include "share.h" +#include "sshare.h" +#include "socket.h" +#include "socketgz.h" +#include "var.h" +#include "order.h" +#include "iis.h" +#include "hist.h" +#include "compress.h" +#include "analysis.h" +#include "photo.h" +#include "colorscale.h" + +// this is kluge to speed up doug minks wcssubs 'ksearch' routine +extern "C" { + FitsHead* wcshead = NULL; + FitsHead* wcsprim = NULL; + char* ksearchh(char*, char*); + + char* findit(char* cards, char* key) + { + char* rr = NULL; + if (wcshead) { + if ((rr = wcshead->find(key))) + return rr; + + if (wcsprim) + if ((rr = wcsprim->find(key))) + return rr; + + return NULL; + } + else + return ksearchh(cards, key); + } +}; + +WCSx::WCSx() +{ + for (int ii=0; iifitsFile(), hdr, data, sz); + process(NULL,id); + + rootBaseFileName = dupstr(fi->rootBaseFileName); + fullBaseFileName = dupstr(fi->fullBaseFileName); + iisFileName = dupstr(fi->fullBaseFileName); +} + +// Fits Next + +FitsImageFitsNextAlloc::FitsImageFitsNextAlloc(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsFitsNextAlloc(prev); + process(fn,id); +} + +FitsImageFitsNextAllocGZ::FitsImageFitsNextAllocGZ(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsFitsNextAllocGZ(prev); + process(fn,id); +} + +FitsImageFitsNextChannel::FitsImageFitsNextChannel(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsFitsNextChannel(prev); + process(fn,id); +} + +FitsImageFitsNextMMap::FitsImageFitsNextMMap(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsFitsNextMMap(prev); + process(fn,id); +} + +FitsImageFitsNextSMMap::FitsImageFitsNextSMMap(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsFitsNextSMMap(prev); + process(fn,id); +} + +FitsImageFitsNextMMapIncr::FitsImageFitsNextMMapIncr(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsFitsNextMMapIncr(prev); + process(fn,id); +} + +FitsImageFitsNextShare::FitsImageFitsNextShare(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsFitsNextShare(prev); + process(fn,id); +} + +FitsImageFitsNextSShare::FitsImageFitsNextSShare(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsFitsNextSShare(prev); + process(fn,id); +} + +FitsImageFitsNextSocket::FitsImageFitsNextSocket(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsFitsNextSocket(prev); + process(fn,id); +} + +FitsImageFitsNextSocketGZ::FitsImageFitsNextSocketGZ(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsFitsNextSocketGZ(prev); + process(fn,id); +} + +FitsImageFitsNextVar::FitsImageFitsNextVar(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsFitsNextVar(prev); + process(fn,id); +} + +FitsImageFitsNextHist::FitsImageFitsNextHist(Context* cx, Tcl_Interp* pp, + FitsImage* fi, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsHistNext(prev); + process(NULL,id); + + fits_->setpFilter(fi->getHistFilter()); + fits_->setpBinX(fi->getHistX()); + fits_->setpBinY(fi->getHistY()); + fits_->setpBinZ(fi->getHistZ()); + + rootBaseFileName = dupstr(fi->rootBaseFileName); + fullBaseFileName = dupstr(fi->fullBaseFileName); + iisFileName = dupstr(fi->fullBaseFileName); +} + +FitsImageFitsNextPost::FitsImageFitsNextPost(Context* cx, Tcl_Interp* pp, + FitsImage* fi, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsPostNext(prev); + process(NULL,id); + + rootBaseFileName = dupstr(fi->rootBaseFileName); + fullBaseFileName = dupstr(fi->fullBaseFileName); + iisFileName = dupstr(fi->fullBaseFileName); +} + +FitsImageFitsNextOrder::FitsImageFitsNextOrder(Context* cx, Tcl_Interp* pp, + FitsImage* fi, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsOrderNext(prev); + process(NULL,id); + + rootBaseFileName = dupstr(fi->rootBaseFileName); + fullBaseFileName = dupstr(fi->fullBaseFileName); + iisFileName = dupstr(fi->fullBaseFileName); +} + +// Array + +FitsImageArrAlloc::FitsImageArrAlloc(Context* cx, Tcl_Interp* pp, + const char* ch, const char* fn, + FitsFile::FlushMode flush, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsArrAlloc(ch, flush); + process(fn,id); +} + +FitsImageArrAllocGZ::FitsImageArrAllocGZ(Context* cx, Tcl_Interp* pp, + const char* ch, const char* fn, + FitsFile::FlushMode flush, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsArrAllocGZ(ch, flush); + process(fn,id); +} + +FitsImageArrChannel::FitsImageArrChannel(Context* cx, Tcl_Interp* pp, + const char* ch, const char* fn, + FitsFile::FlushMode flush, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsArrChannel(pp, ch, fn, flush); + process(fn,id); +} + +FitsImageArrMMap::FitsImageArrMMap(Context* cx, Tcl_Interp* pp, + const char* fn, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsArrMMap(fn); + process(fn,id); +} + +FitsImageArrMMapIncr::FitsImageArrMMapIncr(Context* cx, Tcl_Interp* pp, + const char* fn, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsArrMMapIncr(fn); + process(fn,id); +} + +FitsImageArrShare::FitsImageArrShare(Context* cx, Tcl_Interp* pp, + Base::ShmType type, + int sid, const char* fn, int id) + : FitsImage(cx, pp) +{ + switch (type) { + case Base::SHMID: + fits_ = new FitsArrShareID(sid, fn); + break; + case Base::KEY: + fits_ = new FitsArrShareKey(sid, fn); + break; + } + process(fn,id); +} + +FitsImageArrSocket::FitsImageArrSocket(Context* cx, Tcl_Interp* pp, + int s, const char* fn, + FitsFile::FlushMode flush, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsArrSocket(s, fn, flush); + process(fn,id); +} + +FitsImageArrSocketGZ::FitsImageArrSocketGZ(Context* cx, Tcl_Interp* pp, + int s, const char* fn, + FitsFile::FlushMode flush, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsArrSocketGZ(s, fn, flush); + process(fn,id); +} + +FitsImageArrVar::FitsImageArrVar(Context* cx, Tcl_Interp* pp, + const char* var, const char* fn, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsArrVar(pp, var, fn); + process(fn,id); +} + +// ENVI + +FitsImageENVISMMap::FitsImageENVISMMap(Context* cx, Tcl_Interp* pp, + const char* hdr, + const char* fn, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsENVISMMap(hdr,fn); + process(fn,id); +} + +// NRRD + +FitsImageNRRDAlloc::FitsImageNRRDAlloc(Context* cx, Tcl_Interp* pp, + const char* ch, const char* fn, + FitsFile::FlushMode flush, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsNRRDAlloc(ch, flush); + process(fn,id); +} + +FitsImageNRRDChannel::FitsImageNRRDChannel(Context* cx, Tcl_Interp* pp, + const char* ch, const char* fn, + FitsFile::FlushMode flush, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsNRRDChannel(pp, ch, fn, flush); + process(fn,id); +} + +FitsImageNRRDMMap::FitsImageNRRDMMap(Context* cx, Tcl_Interp* pp, + const char* fn, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsNRRDMMap(fn); + process(fn,id); +} + +FitsImageNRRDShare::FitsImageNRRDShare(Context* cx, Tcl_Interp* pp, + Base::ShmType type, + int sid, const char* fn, int id) + : FitsImage(cx, pp) +{ + switch (type) { + case Base::SHMID: + fits_ = new FitsNRRDShareID(sid, fn); + break; + case Base::KEY: + fits_ = new FitsNRRDShareKey(sid, fn); + break; + } + process(fn,id); +} + +FitsImageNRRDSocket::FitsImageNRRDSocket(Context* cx, Tcl_Interp* pp, + int s, const char* fn, + FitsFile::FlushMode flush, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsNRRDSocket(s, fn, flush); + process(fn,id); +} + +FitsImageNRRDVar::FitsImageNRRDVar(Context* cx, Tcl_Interp* pp, + const char* var, const char* fn, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsNRRDVar(pp, var, fn); + process(fn,id); +} + +// Photo + +FitsImagePhoto::FitsImagePhoto(Context* cx, Tcl_Interp* pp, + const char* ph, const char* fn, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsPhoto(pp, ph); + process(fn,id); +} + +FitsImagePhotoCube::FitsImagePhotoCube(Context* cx, Tcl_Interp* pp, + const char* ph, const char* fn, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsPhotoCube(pp, ph); + process(fn,id); +} + +FitsImagePhotoCubeNext::FitsImagePhotoCubeNext(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsPhotoCubeNext(prev); + process(fn,id); +} + +// Mosaic + +FitsImageMosaicAlloc::FitsImageMosaicAlloc(Context* cx, Tcl_Interp* pp, + const char* ch, + const char* fn, + FitsFile::FlushMode flush, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicAlloc(ch, flush); + process(fn,id); +} + +FitsImageMosaicAllocGZ::FitsImageMosaicAllocGZ(Context* cx, Tcl_Interp* pp, + const char* ch, + const char* fn, + FitsFile::FlushMode flush, + int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicAllocGZ(ch, flush); + process(fn,id); +} + +FitsImageMosaicChannel::FitsImageMosaicChannel(Context* cx, Tcl_Interp* pp, + const char* ch, + const char* fn, + FitsFile::FlushMode flush, + int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicChannel(pp, ch, flush); + process(fn,id); +} + +FitsImageMosaicMMap::FitsImageMosaicMMap(Context* cx, Tcl_Interp* pp, + const char* fn, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicMMap(fn); + process(fn,id); +} + +FitsImageMosaicMMapIncr::FitsImageMosaicMMapIncr(Context* cx, Tcl_Interp* pp, + const char* fn, + int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicMMapIncr(fn); + process(fn,id); +} + +FitsImageMosaicShare::FitsImageMosaicShare(Context* cx, Tcl_Interp* pp, + Base::ShmType type, + int sid, const char* fn, int id) + : FitsImage(cx, pp) +{ + switch (type) { + case Base::SHMID: + fits_ = new FitsMosaicShareID(sid); + break; + case Base::KEY: + fits_ = new FitsMosaicShareKey(sid); + break; + } + process(fn,id); +} + +FitsImageMosaicSocket::FitsImageMosaicSocket(Context* cx, Tcl_Interp* pp, + int s, const char* fn, + FitsFile::FlushMode flush, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicSocket(s, flush); + process(fn,id); +} + +FitsImageMosaicSocketGZ::FitsImageMosaicSocketGZ(Context* cx, Tcl_Interp* pp, + int s, const char* fn, + FitsFile::FlushMode flush, + int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicSocketGZ(s, flush); + process(fn,id); +} + +FitsImageMosaicVar::FitsImageMosaicVar(Context* cx, Tcl_Interp* pp, + const char* var, const char* fn, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicVar(pp, var, fn); + process(fn,id); +} + +// Mosaic Next + +FitsImageMosaicNextAlloc::FitsImageMosaicNextAlloc(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, + FitsFile::FlushMode flush, + int id) + + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicNextAlloc(prev, flush); + process(fn,id); +} + +FitsImageMosaicNextAllocGZ::FitsImageMosaicNextAllocGZ(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, + FitsFile::FlushMode flush, + int id) + + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicNextAllocGZ(prev, flush); + process(fn,id); +} + +FitsImageMosaicNextChannel::FitsImageMosaicNextChannel(Context* cx, + Tcl_Interp* pp, + const char* fn, + FitsFile* prev, + FitsFile::FlushMode flush, + int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicNextChannel(prev, flush); + process(fn,id); +} + +FitsImageMosaicNextMMap::FitsImageMosaicNextMMap(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicNextMMap(prev); + process(fn,id); +} + +FitsImageMosaicNextMMapIncr::FitsImageMosaicNextMMapIncr(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, + int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicNextMMapIncr(prev); + process(fn,id); +} + +FitsImageMosaicNextShare::FitsImageMosaicNextShare(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicNextShare(prev); + process(fn,id); +} + +FitsImageMosaicNextSocket::FitsImageMosaicNextSocket(Context* cx, + Tcl_Interp* pp, + const char* fn, + FitsFile* prev, + FitsFile::FlushMode flush, + int id) + + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicNextSocket(prev, flush); + process(fn,id); +} + +FitsImageMosaicNextSocketGZ::FitsImageMosaicNextSocketGZ(Context* cx, + Tcl_Interp* pp, + const char* fn, + FitsFile* prev, + FitsFile::FlushMode flush, + int id) + + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicNextSocketGZ(prev, flush); + process(fn,id); +} + +FitsImageMosaicNextVar::FitsImageMosaicNextVar(Context* cx, Tcl_Interp* pp, + const char* fn, + FitsFile* prev, int id) + : FitsImage(cx, pp) +{ + fits_ = new FitsMosaicNextVar(prev); + process(fn,id); +} + +// IIS + +FitsImageIIS::FitsImageIIS(Context* cx, Tcl_Interp* pp, int w, int h) + : FitsImage(cx, pp) +{ + fits_ = new FitsIIS(w, h); + process("",1); + iisMode_ = 1; +} + +void FitsImageIIS::iisErase() +{ + ((FitsIIS*)fits_)->erase(); +} + +char* FitsImageIIS::iisGet(int xx, int yy, int dx, int dy) +{ + return ((FitsIIS*)fits_)->get(xx, yy, dx, dy); +} + +void FitsImageIIS::iisSet(const char* src, int xx, int yy, int dx, int dy) +{ + ((FitsIIS*)fits_)->set(src, xx, yy, dx, dy); +} + +void FitsImageIIS::iisWCS(const Matrix& mm, const Vector& z, int zt) +{ + Matrix& mx = (Matrix&)mm; + double sx = mx[0][0]; + double sy = mx[1][1]; + double tx = mx[2][0]; + double ty = mx[2][1]; + + imageToPhysical = + Translate(0,-height()/2.) * + FlipY() * + Translate(0,height()/2.) * + Translate(-1,0) * + Scale(sx,sy) * + Translate(tx,ty); + physicalToImage = imageToPhysical.invert(); + iisz_ = z; + iiszt_ = zt; +} + +// FitsImage + +void FitsImage::altWCS(istream& str) +{ + FitsHead* hh = parseWCS(str); + + // Process OBJECT keyword + if (objectKeyword_) + delete [] objectKeyword_; + objectKeyword_ = hh->getString("OBJECT"); + + // Process WCS keywords + if (altHeader_) + delete altHeader_; + + altHeader_ = hh; + initWCS(); +} + +void FitsImage::appendWCS(istream& str) +{ + FitsHead* hh = parseWCS(str); + + // process OBJECT keyword + char* obj = hh->getString("OBJECT"); + if (obj) { + if (objectKeyword_) + delete [] objectKeyword_; + objectKeyword_ = obj; + } + + // Process WCS keywords + FitsHead* hd = image_->head(); + + // append wcs keywords to the end of the header + int ll = hd->headbytes()+hh->headbytes(); + char* cards = new char[ll]; + + // copy default wcs + memcpy(cards, hd->cards(), hd->headbytes()); + + // find first END and zero out + for (int i=0; iheadbytes(); i+=80) + if (!strncmp(cards+i,"END",3)) { + memcpy(cards+i, " ",3); + break; + } + + // copy appended wcs + memcpy(cards+hd->headbytes(), hh->cards(), hh->headbytes()); + + delete hh; + if (wcsHeader_) + delete wcsHeader_; + + wcsHeader_ = new FitsHead(cards,ll,FitsHead::ALLOC); + initWCS(); +} + +char* FitsImage::display(FitsHead* hd) +{ + int size = hd->ncard() * (FTY_CARDLEN+1); + char* lbuf = new char[size+1]; + + char* lptr = lbuf; + char* cptr = hd->cards(); + for (int i=0; incard(); i++,cptr+=FTY_CARDLEN) { + memcpy(lptr, cptr, FTY_CARDLEN); + lptr+=FTY_CARDLEN; + *(lptr++) = '\n'; + } + + lbuf[size] = '\0'; + return lbuf; +} + +char* FitsImage::displayHeader() +{ + Vector blockFactor = context_->blockFactor(); + if (blockFactor[0] != 1 && blockFactor[1] != 1) + return display(image_->head()); + + if (DebugBin || DebugCompress) + return display(image_->head()); + else + return display(fits_->head()); +} + +char* FitsImage::displayPrimary() +{ + return display(fits_->primary()); +} + +char* FitsImage::displayWCS() +{ + if (wcsHeader_) + return display(wcsHeader_); + else if (altHeader_) + return display(altHeader_); + else + return display(image_->head()); +} + +int FitsImage::findKeyword(const char* key) +{ + return fits_->find(key); +} + +FitsBound* FitsImage::getDataParams(FrScale::SecMode which) +{ + switch (which) { + case FrScale::IMGSEC: + return &iparams; + case FrScale::DATASEC: + return &dparams; + case FrScale::CROPSEC: + return &cparams; + } + + // just to satisfy the compiler + return &iparams; +} + +const char* FitsImage::getValue(const Vector& v) +{ + if (!isIIS()) + return data_->getValue(v); + else { + double val = data_->getValueDouble(v); + + ostringstream str; + if (val == 0) + str << ends; + else if (val == 1) + str << '<' << iisz_[0] << ends; + else if (val == IISMAX) + str << '>' << iisz_[1] << ends; + else if (val > IISMAX) + str << ends; + else + str << ((val-1) * (iisz_[1]-iisz_[0]))/(IISMAX-1) + iisz_[0] << ends; + + memcpy(buf,str.str().c_str(), str.str().length()); + return buf; + } +} + +void FitsImage::iisSetFileName(const char* fn) +{ + if (iisFileName) + delete [] iisFileName; + iisFileName = dupstr(fn); +} + +void FitsImage::initWCS() +{ + // free up wcs and ast arrays + if (wcs_) { + for (int ii=0; iishareWCS()) { + FitsImage* ptr = context_->fits; + while (ptr) { + if (ptr == this) + break; + + FitsImage* sptr = ptr->nextSlice(); + while (sptr) { + if (sptr == this) { + for (int ii=0; iiwcs_[ii]; + for (int ii=0; iiwcsx_[ii]; + for (int ii=0; iiast_[ii]; + + initWCSPhysical(); + manageWCS_ =0; + return; + } + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + } + + // WCSx + FitsHead* hd =NULL; + FitsHead* prim =NULL; + if (wcsHeader_) + hd = wcsHeader_; + else if (altHeader_) + hd = altHeader_; + else { + hd = image_->head(); + prim = image_->primary() && image_->inherit() ? image_->primary() : NULL; + } + + // wcsinit is sloooowwww! so try to figure it out first + // look first for default WCS. Let wcsinit figure it out since there can + // be many different non-standard wcs's present + wcshead = hd; + wcsprim = prim; + wcs_[0] = wcsinit(hd->cards()); + wcshead = NULL; + wcsprim = NULL; + + // now look for WCSA - WCSZ + // we can take a short cut here, since only valid FITS wcs's are available + for (int ii=1; iifind(str)) { + wcshead = hd; + wcsprim = prim; + wcs_[ii] = wcsinitc(hd->cards(),str+6); + wcshead = NULL; + wcsprim = NULL; + } + } + + // finally, look for AST def + if (!wcs_[0]) { + char str[] = "BEGAST_A"; + if (hd->find(str)) { + wcs_[0] = wcskinit(100, 100, (char*)"AST--WCS", (char*)"AST--WCS", + 0, 0, 0, 0, NULL, 1, 1, 0, 2000, 0); + wcs_[0]->longpole = 999; + wcs_[0]->latpole = 999; + } + } + + // AST + for (int ii=0; iifind("WCSDEP")) { + char* str = hd->getString("WCSDEP"); + if (str) { + for (int ii=1; iiwcsname) { + if (!strncmp(str,wcs_[ii]->wcsname,strlen(wcs_[ii]->wcsname))) { + if (ast_[0] && ast_[ii]) { + AstFrameSet* dep = (AstFrameSet*)astCopy(ast_[ii]); + astInvert(ast_[0]); + astAddFrame(dep,2,astUnitMap(2,""),ast_[0]); + astSetI(dep,"current",4); + astAnnul(ast_[0]); + ast_[0] = dep; + } + } + } + } + } + delete [] str; + } + } + + // WCSx + char scrpix[] = "CRPIX "; + char scrval[] = "CRVAL "; + char scd[] = "CD _ "; + char spc[] = "PC _ "; + char scdelt[] = "CDELT "; + for (int ii=0; iifind(scrpix) && hd->find(scrval)) { + if (!wcsx_[ii]) + wcsx_[ii] = new WCSx(); + wcsx_[ii]->crpix[jj] = hd->getReal(scrpix,0); + wcsx_[ii]->crval[jj] = hd->getReal(scrval,0); + + float cd = hd->getReal(scd,0); + float pc = hd->getReal(spc,0); + float cdelt = hd->getReal(scdelt,0); + if (cd) + wcsx_[ii]->cd[jj] = cd; + else if (pc && cdelt) + wcsx_[ii]->cd[jj] = pc * cdelt; + else if (cdelt) + wcsx_[ii]->cd[jj] = cdelt; + else + wcsx_[ii]->cd[jj] = 1; + } + } + } + + initWCSPhysical(); + + if (DebugWCS) { + for (int ii=0; iicd[jj]) { + cerr << "wcsx" << (char)(!ii ? ' ' : '@'+ii) + << "[" << ii << "]->crpix[" << jj << "]=" + << wcsx_[ii]->crpix[jj] << endl; + cerr << "wcsx" << (char)(!ii ? ' ' : '@'+ii) + << "[" << ii << "]->crval[" << jj << "]=" + << wcsx_[ii]->crval[jj] << endl; + cerr << "wcsx" << (char)(!ii ? ' ' : '@'+ii) + << "[" << ii << "]->cd[" << jj << "]=" + << wcsx_[ii]->cd[jj] << endl; + } + } + } + } + } +} + +void FitsImage::initWCSPhysical() +{ + // now see if we have a 'physical' wcs, if so, set LTMV keywords + keyLTMV =0; + for (int ii=1; iiwcsname && + !strncmp(wcs_[ii]->wcsname, "PHYSICAL", 8)) { + keyLTMV = 1; + + double ltm11 = wcs_[ii]->cd[0] != 0 ? 1/wcs_[ii]->cd[0] : 0; + double ltm12 = wcs_[ii]->cd[1] != 0 ? 1/wcs_[ii]->cd[1] : 0; + double ltm21 = wcs_[ii]->cd[2] != 0 ? 1/wcs_[ii]->cd[2] : 0; + double ltm22 = wcs_[ii]->cd[3] != 0 ? 1/wcs_[ii]->cd[3] : 0; + + double ltv1 = wcs_[ii]->crpix[0] - + wcs_[ii]->crval[0]*ltm11 - wcs_[ii]->crval[1]*ltm21; + double ltv2 = wcs_[ii]->crpix[1] - + wcs_[ii]->crval[0]*ltm12 - wcs_[ii]->crval[1]*ltm22; + + physicalToImage = Matrix(ltm11, ltm12, ltm21, ltm22, ltv1, ltv2); + imageToPhysical = physicalToImage.invert(); + } + } +} + +void FitsImage::initWCS0(const Vector& pix) +{ + int ii = Coord::WCS0-Coord::WCS; + if (wcs_[ii]) + wcsfree(wcs_[ii]); + wcs_[ii] = NULL; + + if (wcs_[0]) { + Vector cc = mapFromRef(pix, Coord::IMAGE, Coord::FK5); + WorldCoor* ww = wcs_[0]; + wcs_[ii] = wcskinit(ww->nxpix, ww->nypix, + (char*)"RA---TAN", (char*)"DEC--TAN", + cc[0], cc[1], 0, 0, ww->cd, 0, 0, 0, 2000, 2000); + wcs_[ii]->longpole = 999; + wcs_[ii]->latpole = 999; + + if (ast_[ii]) + astAnnul(ast_[ii]); + ast_[ii] = NULL; + astinit0(ii); + + if (DebugWCS) { + if (wcs_[ii]) + wcsShow(wcs_[ii]); + } + } +} + +void FitsImage::load() +{ + if (post_) + base_ = post_; + else if (hpx_) + base_ = hpx_; + else if (hist_) + base_ = hist_; + else + base_ = fits_; + + if (basedata_) + delete basedata_; + + switch (base_->head()->bitpix()) { + case 8: + basedata_ = new FitsDatam(base_, interp_); + break; + case 16: + basedata_ = new FitsDatam(base_, interp_); + break; + case -16: + basedata_ = new FitsDatam(base_, interp_); + break; + case 32: + basedata_ = new FitsDatam(base_, interp_); + break; + case 64: + basedata_ = new FitsDatam(base_, interp_); + break; + case -32: + basedata_ = new FitsDatam(base_, interp_); + break; + case -64: + basedata_ = new FitsDatam(base_, interp_); + break; + } + + // block + block_ = base_; + blockdata_ = basedata_; + + // analysis + analysis_ = block_; + analysisdata_ = blockdata_; + + // image + image_ = analysis_; + data_ = analysisdata_; +} + +void FitsImage::match(const char* xxname1, const char* yyname1, + Coord::CoordSystem sys1, Coord::SkyFrame sky1, + const char* xxname2, const char* yyname2, + Coord::CoordSystem sys2, Coord::SkyFrame sky2, + double rad, Coord::CoordSystem sys, Coord::SkyDist dist, + const char* rrname) +{ + astClearStatus; + + // get lists + Tcl_Obj* listxx1 = + Tcl_GetVar2Ex(interp_, xxname1, NULL, TCL_LEAVE_ERR_MSG); + Tcl_Obj* listyy1 = + Tcl_GetVar2Ex(interp_, yyname1, NULL, TCL_LEAVE_ERR_MSG); + Tcl_Obj* listxx2 = + Tcl_GetVar2Ex(interp_, xxname2, NULL, TCL_LEAVE_ERR_MSG); + Tcl_Obj* listyy2 = + Tcl_GetVar2Ex(interp_, yyname2, NULL, TCL_LEAVE_ERR_MSG); + + // get objects + int nxx1; + Tcl_Obj **objxx1; + Tcl_ListObjGetElements(interp_, listxx1, &nxx1, &objxx1); + int nyy1; + Tcl_Obj **objyy1; + Tcl_ListObjGetElements(interp_, listyy1, &nyy1, &objyy1); + int nxx2; + Tcl_Obj **objxx2; + Tcl_ListObjGetElements(interp_, listxx2, &nxx2, &objxx2); + int nyy2; + Tcl_Obj **objyy2; + Tcl_ListObjGetElements(interp_, listyy2, &nyy2, &objyy2); + + // sanity check + if (nxx1 != nyy1 || nxx2 != nyy2) + return; + + // get doubles + double* ixx1 = new double[nxx1]; + for (int ii=0 ; ii=0 && ast_ && ast_[ss])) + return; + + if (astIsASkyFrame(astGetFrame(ast_[0], AST__CURRENT))) { + setAstSkyFrame(ast_[ss],sky1); + for (int ii=0; ii=0 && ast_ && ast_[ss])) + return; + + if (astIsASkyFrame(astGetFrame(ast_[ss], AST__CURRENT))) { + setAstSkyFrame(ast_[ss],sky2); + for (int ii=0; iihead(); + FitsHead* rr = new FitsHead(hd->naxis(0), hd->naxis(1), + hd->naxis(2), hd->bitpix()); + + // this works for both terminated (\n) and non-terminated (fits) headers + while (!str.eof()) { + char buf[256]; + str.get(buf,80,'\n'); + if (strlen(buf) > 0) { + // check for blank lines + if (*buf == ' ') + break; + + string x(buf); + istringstream sstr(x); + + char keyword[32]; + sstr >> keyword; + + if (strchr(buf,'=')) { + char dummy; + sstr >> dummy; + } + + if (strchr(buf,'\'')) { + char val[64]; + char* ss = strchr(buf,'\'')+1; + char* ee = strrchr(buf,'\''); + int ll = ee-ss; + if (ll<0 || ll>63) + ll =0; + strncpy(val,ss,ll); + val[ll] = '\0'; + rr->appendString(keyword, val, ""); + } + else { + double val; + sstr >> val; + rr->appendReal(keyword, val, 15, ""); + } + + if (strlen(buf) <= 80) { + // eat the \n + char b; + str.get(b); + } + } + else + break; + } + + return rr; +} + +void FitsImage::process(const char* fn, int id) +{ + if (!fits_->isValid()) { + reset(); + return; + } + + if (fits_->isImage()) { + switch (fits_->pEncoding()) { + case FitsFile::RAW: + case FitsFile::BSQ: + break; + case FitsFile::GZIP: + initNRRD(); + if (!post_ || !post_->isValid()) { + reset(); + return; + } + break; + case FitsFile::BIL: + case FitsFile::BIP: + initENVI(); + if (!post_ || !post_->isValid()) { + reset(); + return; + } + break; + default: + reset(); + return; + } + + load(); + } + else if (fits_->isBinTable()) { + // Compress + if (fits_->find("ZIMAGE")) { + initCompress(); + if (!post_ || !post_->isValid()) { + reset(); + return; + } + load(); + } + // HEALPIX + else if ((fits_->find("PIXTYPE") && (!strncmp(fits_->getString("PIXTYPE"),"HEALPIX",4))) || fits_->find("NSIDE")) { + initHPX(); + if (!hpx_ || !hpx_->isValid()) { + reset(); + return; + } + load(); + } + else { + // Bintable + initBin(); + if (!hist_ || !hist_->isValid()) { + reset(); + return; + } + } + } + else if (fits_->isAsciiTable()) { + // HEALPIX + if (fits_->find("NSIDE")) { + initHPX(); + if (!hpx_ || !hpx_->isValid()) { + reset(); + return; + } + load(); + } + } + + // set slice address + for (int ii=1; iifind("LTM1_1") || + image_->find("LTM1_2") || + image_->find("LTM2_1") || + image_->find("LTM2_2") || + image_->find("LTV1") || + image_->find("LTV2")) + keyLTMV = 1; + + double ltm11 = image_->getReal("LTM1_1", 1); + double ltm12 = image_->getReal("LTM1_2", 0); + double ltm21 = image_->getReal("LTM2_1", 0); + double ltm22 = image_->getReal("LTM2_2", 1); + + double ltv1 = image_->getReal("LTV1", 0); + double ltv2 = image_->getReal("LTV2", 0); + + physicalToImage = Matrix(ltm11, ltm12, ltm21, ltm22, ltv1, ltv2); + imageToPhysical = physicalToImage.invert(); + } + + // CDD to Detector (DTM/DTV keywords) + + keyDTMV =0; + if (image_->find("DTM1_1") || + image_->find("DTM1_2") || + image_->find("DTM2_1") || + image_->find("DTM2_2") || + image_->find("DTV1") || + image_->find("DTV2")) + keyDTMV = 1; + + double dtm11 = image_->getReal("DTM1_1", 1); + double dtm12 = image_->getReal("DTM1_2", 0); + double dtm21 = image_->getReal("DTM2_1", 0); + double dtm22 = image_->getReal("DTM2_2", 1); + + double dtv1 = image_->getReal("DTV1", 0); + double dtv2 = image_->getReal("DTV2", 0); + + physicalToDetector = Matrix(dtm11, dtm12, dtm21, dtm22, dtv1, dtv2); + detectorToPhysical = physicalToDetector.invert(); + + // Physical to Amplifier (ATM/ATV keywords) + + keyATMV =0; + if (image_->find("ATM1_1") || + image_->find("ATM1_2") || + image_->find("ATM2_1") || + image_->find("ATM2_2") || + image_->find("ATV1") || + image_->find("ATV2")) + keyATMV = 1; + + double atm11 = image_->getReal("ATM1_1", 1); + double atm12 = image_->getReal("ATM1_2", 0); + double atm21 = image_->getReal("ATM2_1", 0); + double atm22 = image_->getReal("ATM2_2", 1); + + double atv1 = image_->getReal("ATV1", 0); + double atv2 = image_->getReal("ATV2", 0); + + physicalToAmplifier = Matrix(atm11, atm12, atm21, atm22, atv1, atv2); + amplifierToPhysical = physicalToAmplifier.invert(); + + if (DebugMosaic) { + cerr << endl; + cerr << "ATM/V: " << physicalToAmplifier << endl; + cerr << "ATM/V-1: " << amplifierToPhysical << endl; + cerr << "DTM/V: " << physicalToDetector << endl; + cerr << "DTM/V-1: " << detectorToPhysical << endl; + cerr << "LTM/V: " << physicalToImage << endl; + cerr << "LTM/V-1: " << imageToPhysical << endl; + } + + /* + // Radio data? + char* bunit = image_->getString("BUNIT"); + double cdelt1 = fabs(image_->getReal("CDELT1",0)); + char* cunit1 = image_->getString("CUNIT1"); + double cdelt2 = fabs(image_->getReal("CDELT2",0)); + char* cunit2 = image_->getString("CUNIT2"); + double bmaj = image_->getReal("BMAJ",0); + double bmin = image_->getReal("BMIN",0); + + // ok we have a radio map +#define GFACTOR (2.0*sqrt(2.0*log(2.0))) + if (!strncmp(bunit,"JY/BEAM",7) && cdelt1 && cdelt2 && bmaj && bmin) { + // convert from deg to arcsec? + cdelt1 *= 3600; + cdelt2 *= 3600; + bmaj *= 3600; + bmin *= 3600; + jyBeam_ = (2*M_PI*bmaj*bmin)/(GFACTOR*GFACTOR*cdelt1*cdelt2); + } + + if (bunit) + delete [] bunit; + if (cunit1) + delete [] cunit1; + if (cunit2) + delete [] cunit2; + */ +} + +void FitsImage::processKeywordsParams() +{ + // iparams is a BBOX in DATA coords 0-n + iparams.set(0, 0, width(), height()); + + { + char* datstr = image_->getString("DATASEC"); + // default + Vector v1(1,1); + Vector v2(size()); + + keyDATASEC =0; + if (datstr && *datstr && parseSection(datstr,&v1,&v2)) { + // additional check + if (v1[0]<1 || v1[1]<1 || + v1[1]>width() || v2[1]>height() || + v1[0]>v2[0] || v1[1]>v2[1]) { + // default + v1 = Vector(1,1); + v2 = Vector(size()); + keyDATASEC = 0; + } else + keyDATASEC = 1; + } + + // dparams is a BBOX in DATA coords 0-n + datasec = BBox(v1,v2); + v1 -= Vector(1,1); + dparams.set(v1[0],v1[1],v2[0],v2[1]); + + if (datstr) + delete [] datstr; + } + + // DEBUG + if (DebugCrop) { + cerr << "iparams " << iparams << endl; + cerr << "dparams " << dparams << endl; + } +} + +void FitsImage::processKeywordsFitsSection() +{ + Vector ll(dparams.xmin,dparams.ymin); + Vector ur(dparams.xmax,dparams.ymax); + + if (fits_->pcoord() && fits_->pxvalid() && fits_->pyvalid()) { + ll[0] = fits_->pxmin(); + ur[0] = fits_->pxmax(); + ll[1] = fits_->pymin(); + ur[1] = fits_->pymax(); + + ll = ll*physicalToImage*Translate(-1,-1); + ur = ur*physicalToImage; + + context_->setSecMode(FrScale::CROPSEC); + } + if (!fits_->pcoord() && fits_->pxvalid()) { + ll[0] = fits_->pxmin()-1; + ur[0] = fits_->pxmax(); + context_->setSecMode(FrScale::CROPSEC); + } + if (!fits_->pcoord() && fits_->pyvalid()) { + ll[1] = fits_->pymin()-1; + ur[1] = fits_->pymax(); + context_->setSecMode(FrScale::CROPSEC); + } + + // params is a BBOX in DATA coords 0-n + setCropParams(ll,ur,0); + + // DEBUG + if (DebugCrop) + cerr << "cparams " << cparams << endl; + + if (fits_->pzvalid()) { + int zmin = fits_->pzmin()-1; + int zmax = fits_->pzmax(); + context_->setSecMode(FrScale::CROPSEC); + context_->setCrop3dParams(zmin,zmax); + } +} + +int FitsImage::processKeywordsIRAF(FitsImage* fits) +{ + // DETSEC + Coord::Orientation orientation = Coord::NORMAL; + + char* detstr = image_->getString("DETSEC"); + Vector dv1,dv2; + if (!(detstr && *detstr && parseSection(detstr,&dv1,&dv2))) { + if (detstr) + delete [] detstr; + return 0; + } + delete [] detstr; + BBox detsec = BBox(dv1,dv2); + + int xx = (dv1[0] < dv2[0]); + int yy = (dv1[1] < dv2[1]); + + if (xx && yy) + orientation = Coord::NORMAL; + else if (!xx && yy) + orientation = Coord::XX; + else if (!xx && !yy) + orientation = Coord::XY; + else if (xx && !yy) + orientation = Coord::YY; + + // DETSIZE + char* sizestr = image_->getString("DETSIZE"); + Vector sv1(1,1); + Vector sv2(10000,10000); + if (sizestr && *sizestr) { + if (!(parseSection(sizestr,&sv1,&sv2))) { + delete [] sizestr; + return 0; + } + } + if (sizestr) + delete [] sizestr; + BBox detsize = BBox(sv1,sv2); + + // CCDSUM + Vector ccdsum(1,1); + char* ccdstr = image_->getString("CCDSUM"); + if (ccdstr && *ccdstr) { + double Ns, Np, Ns1, Np1; + string x(ccdstr); + istringstream str(x); + + str >> Ns >> Np >> Ns1 >> Np1; + ccdsum = Vector(1/Ns, 1/Np); + } + if (ccdstr) + delete [] ccdstr; + + // origin + Vector origin = detsec.ll * Scale(ccdsum) * Translate(-datasec.ll); + + // matrix + // if the segment is flipped, we can have a discontinuity at + // the edges, due to round off errors, so we 'nudge' it + + Matrix flip; + switch (orientation) { + case Coord::NORMAL: + break; + case Coord::XX: + flip = FlipX(); + break; + case Coord::YY: + flip = FlipY(); + break; + case Coord::XY: + flip = FlipXY(); + break; + } + + // internal flip + Matrix mflip; + switch (context_->IRAFOrientation(orientation)) { + case Coord::NORMAL: + break; + case Coord::XX: + mflip = FlipX(); + break; + case Coord::YY: + mflip = FlipY(); + break; + case Coord::XY: + mflip = FlipXY(); + break; + } + + Vector center = datasec.center() * imageToData; + Vector mcenter = detsize.center() * imageToData * Scale(ccdsum); + + wcsToRef_ = + Translate(-center) * + flip * + Translate(center) * + Translate(origin) * + Translate(-mcenter) * + mflip * + Translate(mcenter); + + // we do this to shift the origin to the middle of the image to match + // the wcs case. Needed by imageBBox() + // first? reset wcsToRef + if (fits == this) { + irafToRef = wcsToRef_.invert(); + wcsToRef_ = Matrix(); + } + else + wcsToRef_ *= fits->irafToRef; + + if (DebugMosaic) { + cerr << "ProcessKeywordsIRAF" << endl + << " datasec: " << datasec << endl + << " ccdsum : " << ccdsum << endl + << " detsize: " << detsize << endl + << " detsec : " << detsec << endl + << " matrix : " << wcsToRef_ << endl; + } + + return 1; +} + +void FitsImage::replaceWCS(istream& str) +{ + FitsHead* hh = parseWCS(str); + + // Process OBJECT keyword + if (objectKeyword_) + delete [] objectKeyword_; + objectKeyword_ = hh->getString("OBJECT"); + + // Process WCS keywords + if (wcsHeader_) + delete wcsHeader_; + + wcsHeader_ = hh; + initWCS(); +} + +void FitsImage::reset() +{ + if (fits_) + delete fits_; + fits_ =NULL; + + if (post_) + delete post_; + post_ =NULL; + if (hpx_) + delete hpx_; + hpx_ =NULL; + if (hist_) + delete hist_; + hist_ =NULL; + + base_ =NULL; + if (basedata_) + delete basedata_; + basedata_ =NULL; + + if (manageBlock_) { + if (block_) + delete block_; + if (blockdata_) + delete blockdata_; + } + manageBlock_ =0; + block_ =NULL; + blockdata_ =NULL; + + if (manageAnalysis_) { + if (analysis_) + delete analysis_; + if (analysisdata_) + delete analysisdata_; + } + manageAnalysis_ =0; + analysis_ =NULL; + analysisdata_ =NULL; + + image_ =NULL; + data_ =NULL; +} + +void FitsImage::resetWCS() +{ + // Process OBJECT keyword + if (objectKeyword_) + delete [] objectKeyword_; + objectKeyword_ = image_->getString("OBJECT"); + + // Process WCS keywords + if (wcsHeader_) + delete wcsHeader_; + + wcsHeader_ = NULL; + initWCS(); +} + +void FitsImage::resetWCS0() +{ + int ii = Coord::WCS0-Coord::WCS; + if (wcs_[ii]) + wcsfree(wcs_[ii]); + wcs_[ii] = NULL; + + if (ast_[ii]) + astAnnul(ast_[ii]); + ast_[ii] = NULL; +} + +char* FitsImage::root(const char* fn) +{ + if (fn) { + const char* ptr = fn; // init the ptr + while(*ptr++); // walk it forward to end of string + ptr--; // backup one + while(*ptr != '/' && ptr != fn) // walk it backward til last / or beginning + ptr--; + if (*ptr == '/') // step it over the last '/' + ptr++; + return dupstr(ptr); // got it! + } + else + return NULL; +} + +void FitsImage::setCropParams(int datasec) +{ + if (!datasec) + cparams = iparams; + else + cparams = dparams; +} + +void FitsImage::setCropParams(const Vector& ss, const Vector& tt, int datasec) +{ + // Coord are in DATA + Vector ll = ss; + Vector ur = tt; + + int xmin = ll[0]; + int xmax = ur[0]; + int ymin = ll[1]; + int ymax = ur[1]; + + if (xmin>xmax) { + xmin = ur[0]; + xmax = ll[0]; + } + if (ymin>ymax) { + ymin = ur[1]; + ymax = ll[1]; + } + + setCropParams(xmin,ymin,xmax,ymax,datasec); +} + +void FitsImage::setCropParams(int x0, int y0, int x1, int y1, int datasec) +{ + FitsBound* params; + if (!datasec) + params = &iparams; + else + params = &dparams; + + // Coords are in DATA + if (x0xmin) + x0=params->xmin; + if (x0>params->xmax) + x0=params->xmax; + if (x1xmin) + x1=params->xmin; + if (x1>params->xmax) + x1=params->xmax; + + if (y0ymin) + y0=params->ymin; + if (y0>params->ymax) + y0=params->ymax; + if (y1ymin) + y1=params->ymin; + if (y1>params->ymax) + y1=params->ymax; + + cparams.set(x0,y0,x1,y1); +} + +void FitsImage::setFileName(const char* fn) +{ + if (fileName) + delete [] fileName; + fileName = NULL; + + if (rootBaseFileName) + delete [] rootBaseFileName; + rootBaseFileName = NULL; + + if (fullBaseFileName) + delete [] fullBaseFileName; + fullBaseFileName = NULL; + + if (iisFileName) + delete [] iisFileName; + iisFileName = NULL; + + // no filename to set + if (!fn) + return; + + // strip any '[]' + char* ffn = strip(fn); + + FitsFile* ptr = post_ ? post_ : fits_; + if (!ptr) + return; + + const char* ext = ptr->extname(); + if (ext) { + { + ostringstream str; + str << ffn << '[' << ext << ']' << ends; + fullBaseFileName = dupstr(str.str().c_str()); + } + { + char* m = root(ffn); + ostringstream str; + str << m << '[' << ext << ']' << ends; + rootBaseFileName = dupstr(str.str().c_str()); + delete [] m; + } + } + else if (ptr->ext()) { + { + ostringstream str; + str << ffn << '[' << ptr->ext() << ']' << ends; + fullBaseFileName = dupstr(str.str().c_str()); + } + { + char* m = root(ffn); + ostringstream str; + str << m << '[' << ptr->ext() << ']' << ends; + rootBaseFileName = dupstr(str.str().c_str()); + delete [] m; + } + } + else { + fullBaseFileName = dupstr(ffn); + rootBaseFileName = root(ffn); + } + + // by default, iisFileName is fullBaseFileName + if (fullBaseFileName) + iisFileName = dupstr(fullBaseFileName); + + delete [] ffn; +} + +void FitsImage::setObjectKeyword(const char* obj) +{ + if (objectKeyword_) + delete [] objectKeyword_; + objectKeyword_ = dupstr(obj); +} + +char* FitsImage::strip(const char* fn) +{ + if (fn) { + char* r = dupstr(fn); // dup the string + char* ptr = r; // init the ptr + while(*ptr != '[' && *ptr) // walk it forward til '[' or end + ptr++; + *ptr = '\0'; // zero out rest + + return r; // got it! + } + else + return NULL; +} + +int FitsImage::nhdu() +{ + int dd =1; + for (int ii=2; iiupdateClip(fr,getDataParams(fr->secMode())); +} + +#ifndef __WIN32 + +void* clipproc(void* tt) +{ + t_clip_arg* targ = (t_clip_arg*)tt; + FitsData* data = targ->data; + FrScale* fr = targ->fr; + FitsBound* bb = targ->bb; + data->updateClip(fr,bb); + + return NULL; +} + +void FitsImage::updateClip(FrScale* fr, pthread_t* thread, t_clip_arg* targ) +{ + targ->data = data_; + targ->fr = fr; + targ->bb = getDataParams(fr->secMode()); + int result = pthread_create(thread, NULL, clipproc, targ); + if (result) + internalError("Unable to Create Thread"); +} + +#endif + +const char* FitsImage::getFileName(Base::FileNameType type) +{ + switch (type) { + case Base::ROOTBASE: + return rootBaseFileName; + case Base::FULLBASE: + return fullBaseFileName; + case Base::ROOT: + case Base::FULL: + // clear the buffer + if (fileName) + delete [] fileName; + fileName =NULL; + + // generate filename + // if FITS bin table cube, be sure to check the first slice + if (context_->fits->isHist()) + return updateFileNameBin(type); + else + return updateFileNameImage(type); + } + + // just to satisfy the compiler + return rootBaseFileName; +} + +const char* FitsImage::updateFileNameImage(Base::FileNameType type) +{ + // 2d/3d section + char* sec =NULL; + switch (context_->secMode()) { + case FrScale::IMGSEC: + case FrScale::DATASEC: + { + Vector blockFactor = context_->blockFactor(); + + if (blockFactor[0] != 1) { + ostringstream str; + str << "*," << blockFactor[0] << ends; + sec = dupstr(str.str().c_str()); + } + } + break; + case FrScale::CROPSEC: + { + FitsBound* params =getDataParams(FrScale::CROPSEC); + + // params is a BBOX in DATA coords 0-n + // xlate to 1-n + Vector ll= Vector(params->xmin,params->ymin) * Translate(1,1); + Vector ur(params->xmax,params->ymax); + Vector blockFactor = context_->blockFactor(); + + if (blockFactor[0] != 1) { + ostringstream str; + str << ll[0] << ':' << ur[0] << ',' + << ll[1] << ':' << ur[1] << ',' + << blockFactor[0] << ends; + sec = dupstr(str.str().c_str()); + } + else { + ostringstream str; + str << ll[0] << ':' << ur[0] << ',' + << ll[1] << ':' << ur[1] << ends; + sec = dupstr(str.str().c_str()); + } + } + break; + } + + // address + char* add =NULL; + { + int doAdd =0; + ostringstream str; + + int jj; + for (jj=FTY_MAXAXES-1; jj>=2; jj--) { + if (address[jj]!=1) + break; + } + jj++; + for (int ii=2; ii=" << ll[0] << ',' + << fits_->pBinX() << "<=" << ur[0] << ',' + << fits_->pBinY() << ">=" << ll[1] << ',' + << fits_->pBinY() << "<=" << ur[1] << ends; + sec = dupstr(str.str().c_str()); + } + break; + } + } + + // z filter + char* slice =NULL; + { + char* zcol = (char*)fits_->pBinZ(); + int bd = context_->binDepth(); + if (bd>1 && zcol) { + // only the first slice will have this + FitsImage* first = context_->fits; + if (first) { + Vector zlim = first->fits_->getColMinMax(zcol); + double zlen = zlim[1]-zlim[0]; + double zdelta = zlen/bd; + + double zptr = zlim[0] + (address[2]-1)*zdelta; + ostringstream str; + str << zcol << ">=" << zptr << '&' << zcol << '<' << zptr+zdelta <pc[0] ? wcs_[ii]->pc[0] : 1; + double pc3 = wcs_[ii]->pc[3] ? wcs_[ii]->pc[3] : 1; + if (!wcs_[ii]->coorflip) + return Vector(wcs_[ii]->cdelt[0]*pc0, wcs_[ii]->cdelt[1]*pc3); + else + return Vector(wcs_[ii]->cdelt[1]*pc3, wcs_[ii]->cdelt[0]*pc0); + } + else + return Vector(); +} + +Coord::Orientation FitsImage::getWCSOrientation(Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + if (hasWCS(sys)) { + Vector orpix = center(); + Vector orval = pix2wcs(orpix, sys, sky); + Vector delta = getWCScdelt(sys).abs(); + Vector npix = wcs2pix(Vector(orval[0],orval[1]+delta[1]), sys, sky); + Vector north = (npix-orpix).normalize(); + Vector epix = wcs2pix(Vector(orval[0]+delta[0],orval[1]), sys, sky); + Vector east = (epix-orpix).normalize(); + + // sanity check + Vector diff = (north-east).abs(); + if ((north[0]==0 && north[1]==0) || + (east[0]==0 && east[1]==0) || + (diff[0]<.01 && diff[1]<.01)) + return Coord::NORMAL; + + // take the cross product and see which way the 3rd axis is pointing + double w = east[0]*north[1]-east[1]*north[0]; + + if (!hasWCSCel(sys)) + return w>0 ? Coord::NORMAL : Coord::XX; + else + return w<0 ? Coord::NORMAL : Coord::XX; + } + + return Coord::NORMAL; +} + +double FitsImage::getWCSRotation(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + if (hasWCS(sys)) { + Vector orpix = center(); + Vector orval = pix2wcs(orpix, sys, sky); + Vector delta = getWCScdelt(sys).abs(); + Vector npix = wcs2pix(Vector(orval[0],orval[1]+delta[1]), sys, sky); + Vector north = (npix-orpix).normalize(); + Vector epix = wcs2pix(Vector(orval[0]+delta[0],orval[1]), sys, sky); + Vector east = (epix-orpix).normalize(); + + // sanity check + Vector diff = (north-east).abs(); + if ((north[0]==0 && north[1]==0) || + (east[0]==0 && east[1]==0) || + (diff[0]<.01 && diff[1]<.01)) + return 0; + + return -(north.angle()-M_PI_2); + } + return 0; +} + +// AST +Vector FitsImage::pix2wcs(Vector in, Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + astClearStatus; + + int ii = sys-Coord::WCS; + if (ii>=0 && ast_ && ast_[ii]) { + double xx =0; + double yy =0; + if (astIsASkyFrame(astGetFrame(ast_[ii], AST__CURRENT))) { + setAstSkyFrame(ast_[ii],sky); + astTran2(ast_[ii], 1, in.v, in.v+1, 1, &xx, &yy); + if (astOK) + if (checkAst(xx,yy)) + return Vector(radToDeg(xx),yy*180./M_PI); + } + else { + astTran2(ast_[ii], 1, in.v, in.v+1, 1, &xx, &yy); + if (astOK) + if (checkAst(xx,yy)) + return Vector(xx,yy); + } + } + + maperr =1; + return Vector(); +} + +Vector* FitsImage::pix2wcs(Vector* in, int num, Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + astClearStatus; + double xin[num]; + double yin[num]; + double xout[num]; + double yout[num]; + + Vector* out = new Vector[num]; + for (int ii=0; ii=0 && ast_ && ast_[ii]) { + if (astIsASkyFrame(astGetFrame(ast_[ii], AST__CURRENT))) { + setAstSkyFrame(ast_[ii],sky); + astTran2(ast_[ii], num, xin, yin, 1, xout, yout); + if (astOK) { + for (int ii=0; ii=0 && ast_ && ast_[ii]) { + double xx =0; + double yy =0; + ostringstream str; + if (astIsASkyFrame(astGetFrame(ast_[ii], AST__CURRENT))) { + setAstSkyFrame(ast_[ii],sky); + astTran2(ast_[ii], 1, in.v, in.v+1, 1, &xx, &yy); + if (!astOK || !checkAst(xx,yy)) { + maperr =1; + lbuf[0] = '\0'; + return lbuf; + } + + switch (format) { + case Coord::DEGREES: + xx =radToDeg(xx); // 0 to 360 + yy *=180./M_PI; + + str << setprecision(8) << xx << ' ' << yy + << ' ' << coord.skyFrameStr(sky) << ends; + break; + + case Coord::SEXAGESIMAL: + switch (sky) { + case Coord::FK4: + case Coord::FK4_NO_E: + case Coord::FK5: + case Coord::ICRS: + xx = zeroTWOPI(xx); + setAstFormat(ast_[ii],1,"hms.3"); + setAstFormat(ast_[ii],2,"+dms.3"); + break; + case Coord::GALACTIC: + case Coord::SUPERGALACTIC: + case Coord::ECLIPTIC: + case Coord::HELIOECLIPTIC: + xx = zeroTWOPI(xx); + setAstFormat(ast_[ii],1,"+dms.3"); + setAstFormat(ast_[ii],2,"+dms.3"); + break; + } + + str << astFormat(ast_[ii], 1, xx) << ' ' << astFormat(ast_[ii], 2, yy) + << ' ' << coord.skyFrameStr(sky) << ends; + break; + } + } + else { + astTran2(ast_[ii], 1, in.v, in.v+1, 1, &xx, &yy); + if (!astOK || !checkAst(xx,yy)) { + maperr =1; + return lbuf; + } + str << setprecision(8) << xx << ' ' << yy << ends; + } + + strncpy(lbuf, str.str().c_str(), str.str().length()); + } + + return lbuf; +} + +Vector FitsImage::wcs2pix(Vector in, Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + astClearStatus; + + int ii = sys-Coord::WCS; + if (ii>=0 && ast_ && ast_[ii]) { + double xx =0; + double yy =0; + if (astIsASkyFrame(astGetFrame(ast_[ii], AST__CURRENT))) { + setAstSkyFrame(ast_[ii],sky); + Vector rr = in*M_PI/180.; + astTran2(ast_[ii], 1, rr.v, &(rr[1]), 0, &xx, &yy); + if (astOK) + if (checkAst(xx,yy)) + return Vector(xx,yy); + } + else { + astTran2(ast_[ii], 1, in.v, in.v+1, 0, &xx, &yy); + if (astOK) + if (checkAst(xx,yy)) + return Vector(xx,yy); + } + } + + maperr =1; + return Vector(); +} + +Vector* FitsImage::wcs2pix(Vector* in, int num, Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + astClearStatus; + double xin[num]; + double yin[num]; + double xout[num]; + double yout[num]; + + Vector* out = new Vector[num]; + for (int ii=0; ii=0 && ast_ && ast_[ii]) { + if (astIsASkyFrame(astGetFrame(ast_[ii], AST__CURRENT))) { + setAstSkyFrame(ast_[ii],sky); + for (int kk=0; kk=0 && ast_ && ast_[ii]) { + if (astIsASkyFrame(astGetFrame(ast_[ii], AST__CURRENT))) { + Vector aa = a*M_PI/180.; + Vector bb = b*M_PI/180.; + rr = astDistance(ast_[ii], aa.v, bb.v) *180./M_PI; + } + else + rr = astDistance(ast_[ii], a.v, b.v); + + if (!astOK) { + maperr =1; + return 0; + } + } + + return rr; +} + +int FitsImage::hasWCS(Coord::CoordSystem sys) +{ + int ii = sys-Coord::WCS; + return (sys>=Coord::WCS && ast_ && ast_[ii]) ? 1 : 0; +} + +int FitsImage::hasWCSEqu(Coord::CoordSystem sys) +{ + astClearStatus; + + int ii = sys-Coord::WCS; + if (ii>=0 && ast_ && ast_[ii]) + if (astIsASkyFrame(astGetFrame(ast_[ii], AST__CURRENT))) { + // special case of xLON/xLAT + char* bb = &(wcs_[ii]->c1type[1]); + if (!strncmp(bb,"LON",3) || !strncmp(bb,"LAT",3)) { + switch (wcs_[ii]->c1type[0]) { + case 'G': + case 'H': + case 'E': + case 'S': + return 1; + default: + return 0; + } + } + + // special case of xyLN/xyLT + char* cc = &(wcs_[ii]->c1type[2]); + if (!strncmp(cc,"LN",2) || !strncmp(cc,"LT",2)) + return 0; + + return 1; + } + + return 0; +} + +int FitsImage::hasWCSCel(Coord::CoordSystem sys) +{ + astClearStatus; + + int ii = sys-Coord::WCS; + if (ii>=0 && ast_ && ast_[ii]) + if (astIsASkyFrame(astGetFrame(ast_[ii], AST__CURRENT))) + return 1; + + return 0; +} + +// WCSX + +int FitsImage::hasWCSx(Coord::CoordSystem sys, int ss) +{ + int ii = sys-Coord::WCS; + return (ss>=2&&ss=Coord::WCS && wcsx_[ii]) ? 1 : 0; +} + +double FitsImage::pix2wcsx(double in, Coord::CoordSystem sys, int ss) +{ + if (hasWCSx(sys,ss)) { + int ii = sys-Coord::WCS; + return (in-wcsx_[ii]->crpix[ss])*wcsx_[ii]->cd[ss] + wcsx_[ii]->crval[ss]; + } + else + return in; +} + +double FitsImage::wcs2pixx(double in, Coord::CoordSystem sys, int ss) +{ + if (hasWCSx(sys,ss)) { + int ii = sys-Coord::WCS; + return (in-wcsx_[ii]->crval[ss])/wcsx_[ii]->cd[ss] + wcsx_[ii]->crpix[ss]; + } + else + return in; +} + +// WCS/AST support + +void FitsImage::wcsShow(WorldCoor* ww) +{ + if (!ww) + return; + + int n = ww->naxes; + int nn = n*n; + + cerr << "wcs->wcsname=" << (ww->wcsname ? ww->wcsname : "") << endl; + cerr << "wcs->naxes=" << ww->naxes << endl; + cerr << "wcs->naxis=" << ww->naxis << endl; + + cerr << "wcs->radecsys=" << ww->radecsys << endl; + cerr << "wcs->equinox=" << ww->equinox << endl; + cerr << "wcs->epoch=" << ww->epoch << endl; + + cerr << "wcs->ctype[0]=" << ww->ctype[0] << endl; + cerr << "wcs->ctype[1]=" << ww->ctype[1] << endl; + cerr << "wcs->c1type=" << ww->c1type << endl; + cerr << "wcs->c2type=" << ww->c2type << endl; + cerr << "wcs->ptype=" << ww->ptype << endl; + + for (int jj=0; jjcrpix[" << jj << "]=" << ww->crpix[jj] << endl; + for (int jj=0; jjcrval[" << jj << "]=" << ww->crval[jj] << endl; + for (int jj=0; jjcdelt[" << jj << "]=" << ww->cdelt[jj] << endl; + + for (int jj=0; jj<4; jj++) + cerr << "wcs->cd[" << jj << "]=" << ww->cd[jj] << endl; + for (int jj=0; jjpc[" << jj << "]=" << ww->pc[jj] << endl; + + cerr << "wcs->longpole=" << ww->longpole << endl; + cerr << "wcs->latpole=" << ww->latpole << endl; + cerr << "wcs->prjcode=" << ww->prjcode << endl; + + cerr << "wcs->rot=" << ww->rot << endl; + cerr << "wcs->coorflip=" << ww->coorflip << endl; + cerr << "wcs->distcode=" << ww->distcode << endl; +} + +void FitsImage::astinit(int ii, FitsHead* hd, FitsHead* prim) +{ + if (!wcs_[ii]) { + ast_[ii] = NULL; + return; + } + + // just in case + if (!hd) + return; + // DSS,PLT,LIN goes straight to AST + // we can't send 3D directly to AST + + if (wcs_[ii]->prjcode==WCS_DSS || + wcs_[ii]->prjcode==WCS_PLT || + (wcs_[ii]->prjcode==WCS_LIN && !strncmp(wcs_[ii]->ptype,"HPX",3)) || + (wcs_[ii]->prjcode==WCS_LIN && !strncmp(wcs_[ii]->ptype,"XPH",3)) || + (wcs_[ii]->prjcode==WCS_LIN && !strncmp(wcs_[ii]->ptype,"TAB",3)) || + (wcs_[ii]->prjcode==WCS_LIN && !strncmp(wcs_[ii]->c1type,"AST",3))) + ast_[ii] = fits2ast(hd); + else + ast_[ii] = buildast(ii, hd, prim); + + if (!ast_[ii]) + return; + + // set default skyframe + if (astIsASkyFrame(astGetFrame(ast_[ii], AST__CURRENT))) + setAstSkyFrame(ast_[ii],Coord::FK5); + + if (DebugAST) + astShow(ast_[ii]); +} + +void FitsImage::astinit0(int ii) +{ + if (!wcs_[ii]) { + ast_[ii] = NULL; + return; + } + + ast_[ii] = buildast0(ii); + + if (!ast_[ii]) + return; + + // set default skyframe + if (astIsASkyFrame(astGetFrame(ast_[ii], AST__CURRENT))) + setAstSkyFrame(ast_[ii],Coord::FK5); + + if (DebugAST) + astShow(ast_[ii]); +} + +int FitsImage::checkAst(double x, double y) +{ + // check for reasonable values + return (fabs(x) < FLT_MAX && fabs(y) < FLT_MAX) ? 1 : 0; +} + +void FitsImage::setAstFormat(AstFrameSet* aa, int id, const char* format) +{ + // is it already set? + // ast is very slow when changing params + { + ostringstream str; + str << "Format(" << id << ")" << ends; + const char* out = astGetC(aa, str.str().c_str()); + if (!strcmp(out,format)) + return; + } + + ostringstream str; + str << "Format(" << id << ")=" << format << ends; + astSet(aa, str.str().c_str()); +} + +void FitsImage::setAstSkyFrame(AstFrameSet* aa, Coord::SkyFrame sky) +{ + // is sky frame + if (!astIsASkyFrame(astGetFrame(aa, AST__CURRENT))) + return; + + // is it already set? + // ast is very slow when changing system,equinox + const char* str = astGetC(aa, "System"); + + // TLON/XLON and HPX will do this + if (!strncmp(str,"Unknown",3)) + return; + + switch (sky) { + case Coord::FK4_NO_E: + if (!strncmp(str,"FK4-NO-E",8)) + return; + astSet(aa, "System=FK4-NO-E, Equinox=B1950"); + return; + case Coord::FK4: + if (!strncmp(str,"FK4",3)) + return; + astSet(aa, "System=FK4, Equinox=B1950"); + return; + case Coord::FK5: + if (!strncmp(str,"FK5",3)) + return; + astSet(aa, "System=FK5, Equinox=J2000"); + return; + case Coord::ICRS: + if (!strncmp(str,"ICRS",4)) + return; + astSet(aa, "System=ICRS"); + return; + case Coord::GALACTIC: + if (!strncmp(str,"GALACTIC",8)) + return; + astSet(aa, "System=GALACTIC"); + return; + case Coord::SUPERGALACTIC: + if (!strncmp(str,"SUPERGALACTIC",13)) + return; + astSet(aa, "System=SUPERGALACTIC"); + return; + case Coord::ECLIPTIC: + if (!strncmp(str,"ECLIPTIC",8)) + return; + astSet(aa, "System=ECLIPTIC"); + // get AST to agree with WCSSUBS + astSetD(aa, "EQUINOX", astGetD(aa, "EPOCH")); + return; + case Coord::HELIOECLIPTIC: + if (!strncmp(str,"HELIOECLIPTIC",13)) + return; + astSet(aa, "System=HELIOECLIPTIC"); + return; + } +} + +AstFrameSet* FitsImage::fits2ast(FitsHead* hd) +{ + // we may have an error, just reset + astClearStatus; + + // new fitschan + AstFitsChan* chan = astFitsChan(NULL, NULL, ""); + if (!astOK || chan == AST__NULL) + return NULL; + + // no warning messages + astClear(chan,"Warnings"); + + // fill up chan + char* cards =NULL; + int ncards =0; + + if (hd) { + cards = hd->cards(); + ncards = hd->ncard(); + } + + if (cards == NULL || ncards == 0) + return NULL; + + for (int i=0; ifind("CTYPE1") && hd->find("CTYPE2") && + hd->find("CRVAL1") && hd->find("CRVAL2") && + hd->find("CRPIX1") && hd->find("CRPIX2")) { + wcs2ast(ii,hd,prim,chan); + fromwcs =1; + } + else + header2ast(hd,chan); + + // rewind chan + astClear(chan, "Card"); + + // parse header + AstFrameSet* frameSet = (AstFrameSet*)astRead(chan); + + // do we have anything? + if (!astOK || frameSet == AST__NULL || + strncmp(astGetC(frameSet,"Class"), "FrameSet", 8)) + return NULL; + + if (fromwcs && wcs_[ii]->coorflip) { + int orr[] = {2,1}; + astPermAxes(frameSet,orr); + } + + // cleanup + astAnnul(chan); + + return frameSet; +} + +AstFrameSet* FitsImage::buildast0(int ii) +{ + if (DebugAST) + cerr << endl << "buildast0()" << endl; + + // read wcs struct into astChannel + // we may have an error, just reset + astClearStatus; + + // new fitschan + AstFitsChan* chan = astFitsChan(NULL, NULL, ""); + if (!astOK || chan == AST__NULL) + return NULL; + + // no warning messages + astClear(chan,"Warnings"); + + // basics (needed by fitschan.c) + putFitsCard(chan, "NAXIS1", (int)naxis(0)); + putFitsCard(chan, "NAXIS2", (int)naxis(1)); + + wcs2ast0(ii,chan); + + // rewind chan + astClear(chan, "Card"); + + // parse header + AstFrameSet* frameSet = (AstFrameSet*)astRead(chan); + + // do we have anything? + if (!astOK || frameSet == AST__NULL || + strncmp(astGetC(frameSet,"Class"), "FrameSet", 8)) + return NULL; + + if (wcs_[ii]->coorflip) { + int orr[] = {2,1}; + astPermAxes(frameSet,orr); + } + + // cleanup + astAnnul(chan); + + return frameSet; +} + +void FitsImage::header2ast(FitsHead* hd, void* chan) +{ + if (DebugAST) + cerr << endl << "header2ast()" << endl; + + for (int ii=0; iifind(key1) && !hd->find(key2)) + continue; + + char* ctype1 = hd->getString(key1); + char* ctype2 = hd->getString(key2); + + if (ctype1 && !strncmp(ctype1,"GLON",4)) { + if (!ctype2 || strncmp(ctype2,"GLAT",4)) { + ctype1 = (char*)linear; + ctype2 = (char*)linear; + } + } + else if (ctype2 && !strncmp(ctype2,"GLON",4)) { + if (!ctype1 || strncmp(ctype1,"GLAT",4)) { + ctype1 = (char*)linear; + ctype2 = (char*)linear; + } + } + else if (ctype1 && !strncmp(ctype1,"GLAT",4)) { + if (!ctype2 || strncmp(ctype2,"GLON",4)) { + ctype1 = (char*)linear; + ctype2 = (char*)linear; + } + } + else if (ctype2 && !strncmp(ctype2,"GLAT",4)) { + if (!ctype1 || strncmp(ctype1,"GLON",4)) { + ctype1 = (char*)linear; + ctype2 = (char*)linear; + } + } + else if (ctype1 && !strncmp(ctype1,"RA",2)) { + if (!ctype2 || strncmp(ctype2,"DEC",3)) { + ctype1 = (char*)linear; + ctype2 = (char*)linear; + } + } + else if (ctype2 && !strncmp(ctype2,"RA",2)) { + if (!ctype1 || strncmp(ctype1,"DEC",3)) { + ctype1 = (char*)linear; + ctype2 = (char*)linear; + } + } + else if (ctype1 && !strncmp(ctype1,"DEC",3)) { + if (!ctype2 || strncmp(ctype2,"RA",2)) { + ctype1 = (char*)linear; + ctype2 = (char*)linear; + } + } + else if (ctype2 && !strncmp(ctype2,"DEC",3)) { + if (!ctype1 || strncmp(ctype1,"RA",2)) { + ctype1 = (char*)linear; + ctype2 = (char*)linear; + } + } + else { + if (!ctype1) + ctype1 =(char*)linear; + if (!ctype2) + ctype2 =(char*)linear; + } + + putFitsCard(chan, key1, ctype1); + putFitsCard(chan, key2, ctype2); + + // CRPIX + strcpy(key1, "CRPIX1 "); + strcpy(key2, "CRPIX2 "); + key1[6] = key2[6] = alt; + putFitsCard(chan, key1, hd->getReal(key1,0)); + putFitsCard(chan, key2, hd->getReal(key2,0)); + + // CRVAL + strcpy(key1, "CRVAL1 "); + strcpy(key2, "CRVAL2 "); + key1[6] = key2[6] = alt; + putFitsCard(chan, key1, hd->getReal(key1,0)); + putFitsCard(chan, key2, hd->getReal(key2,0)); + + // CDELT/CD/PC + strcpy(key1, "CDELT1 "); + strcpy(key2, "CDELT2 "); + key1[6] = key2[6] = alt; + + char pkey1[8]; + char pkey2[8]; + char pkey3[8]; + char pkey4[8]; + strcpy(pkey1, "PC1_1 "); + strcpy(pkey2, "PC1_2 "); + strcpy(pkey3, "PC2_1 "); + strcpy(pkey4, "PC2_2 "); + pkey1[5] = pkey2[5] = pkey3[5] = pkey4[5] = alt; + + char ckey1[8]; + char ckey2[8]; + char ckey3[8]; + char ckey4[8]; + strcpy(ckey1, "CD1_1 "); + strcpy(ckey2, "CD1_2 "); + strcpy(ckey3, "CD2_1 "); + strcpy(ckey4, "CD2_2 "); + ckey1[5] = ckey2[5] = ckey3[5] = ckey4[5] = alt; + + // Give CD priority over CDELT + if (hd->find(ckey1) || + hd->find(ckey2) || + hd->find(ckey3) || + hd->find(ckey4)) { + putFitsCard(chan, ckey1, hd->getReal(ckey1,1)); + putFitsCard(chan, ckey2, hd->getReal(ckey2,0)); + putFitsCard(chan, ckey3, hd->getReal(ckey3,0)); + putFitsCard(chan, ckey4, hd->getReal(ckey4,1)); + } + else if (hd->find(key1) || hd->find(key2)) { + putFitsCard(chan, key1, hd->getReal(key1,1)); + putFitsCard(chan, key2, hd->getReal(key2,1)); + + if (hd->find(pkey1) || + hd->find(pkey2) || + hd->find(pkey3) || + hd->find(pkey4)) { + putFitsCard(chan, pkey1, hd->getReal(pkey1,1)); + putFitsCard(chan, pkey2, hd->getReal(pkey2,1)); + putFitsCard(chan, pkey3, hd->getReal(pkey3,1)); + putFitsCard(chan, pkey4, hd->getReal(pkey4,1)); + } + } + } +} + +void FitsImage::wcs2ast(int ww, FitsHead* hd, FitsHead* prim, void* chan) +{ + if (DebugAST) + cerr << endl << "wcs2ast()" << endl; + + // Alt WCS + char alt = (ww==0) ? ' ' : (char)('@'+ww); + + // CTYPE + if ( + // special case (reorder 3D cube) + (!strncmp(wcs_[ww]->c1type,"GLON",4) && + strncmp(wcs_[ww]->c2type,"GLAT",4)) || + (strncmp(wcs_[ww]->c1type,"GLON",4) && + !strncmp(wcs_[ww]->c2type,"GLAT",4)) || + (!strncmp(wcs_[ww]->c1type,"GLAT",4) && + strncmp(wcs_[ww]->c2type,"GLON",4)) || + (strncmp(wcs_[ww]->c1type,"GLAT",4) && + !strncmp(wcs_[ww]->c2type,"GLON",4)) || + (!strncmp(wcs_[ww]->c1type,"RA",2) && + strncmp(wcs_[ww]->c2type,"DEC",3)) || + (strncmp(wcs_[ww]->c1type,"RA",2) && + !strncmp(wcs_[ww]->c2type,"DEC",3)) || + (!strncmp(wcs_[ww]->c1type,"DEC",3) && + strncmp(wcs_[ww]->c2type,"RA",2)) || + (strncmp(wcs_[ww]->c1type,"DEC",3) && + !strncmp(wcs_[ww]->c2type,"RA",2))) + { + putFitsCard(chan, "CTYPE1", "LINEAR"); + putFitsCard(chan, "CTYPE2", "LINEAR"); + } + else if (wcs_[ww]->prjcode == WCS_TAN && wcs_[ww]->distcode) { + // SIP + { + ostringstream str; + str << wcs_[ww]->ctype[0] << "-SIP" << ends; + putFitsCard(chan, "CTYPE1", str.str().c_str()); + } + { + ostringstream str; + str << wcs_[ww]->ctype[1] << "-SIP" << ends; + putFitsCard(chan, "CTYPE2", str.str().c_str()); + } + } + else if ((wcs_[ww]->prjcode == WCS_LIN) && + (strncmp(wcs_[ww]->ctype[0]+2,"LN",2)) && + (strncmp(wcs_[ww]->ctype[0]+2,"LT",2)) && + (strncmp(wcs_[ww]->ctype[0]+1,"LON",3)) && + (strncmp(wcs_[ww]->ctype[0]+1,"LAT",3))) { + // this is not a mistake + putFitsCard(chan, "CTYPE1", wcs_[ww]->c1type); + putFitsCard(chan, "CTYPE2", wcs_[ww]->c2type); + } + else if (wcs_[ww]->prjcode == WCS_PIX) { + // this is not a mistake + putFitsCard(chan, "CTYPE1", wcs_[ww]->c1type); + putFitsCard(chan, "CTYPE2", wcs_[ww]->c2type); + } + else { + putFitsCard(chan, "CTYPE1", wcs_[ww]->ctype[0]); + putFitsCard(chan, "CTYPE2", wcs_[ww]->ctype[1]); + } + + // CRPIX/CRVAL + putFitsCard(chan, "CRPIX1", wcs_[ww]->crpix[0]); + putFitsCard(chan, "CRPIX2", wcs_[ww]->crpix[1]); + putFitsCard(chan, "CRVAL1", wcs_[ww]->crval[0]); + putFitsCard(chan, "CRVAL2", wcs_[ww]->crval[1]); + + // CD/CDELT/PC + // This is very complicated. AST is very, very, very picky as to which + // keywords it use... + { + ostringstream cd; + cd << "CD1_1" << alt << ends; + ostringstream cdelt; + cdelt << "CDELT1" << alt << ends; + ostringstream pc; + pc << "PC1_1" << alt << ends; + + if (hd->find(cd.str().c_str()) || + (prim && prim->find(cd.str().c_str()))) { + // simple case CD + // no rotation, no poles, no LIN, no inner cd values + if (!wcs_[ww]->cd[1] && !wcs_[ww]->cd[2] && + !wcs_[ww]->rot && + !wcs_[ww]->coorflip && + wcs_[ww]->latpole == 999 && + wcs_[ww]->longpole == 999 && + wcs_[ww]->prjcode != WCS_PIX && + wcs_[ww]->prjcode != WCS_LIN) { + putFitsCard(chan, "CDELT1", wcs_[ww]->cdelt[0]); + putFitsCard(chan, "CDELT2", wcs_[ww]->cdelt[1]); + } + else { + putFitsCard(chan, "CD1_1", wcs_[ww]->cd[0]); + putFitsCard(chan, "CD1_2", wcs_[ww]->cd[1]); + putFitsCard(chan, "CD2_1", wcs_[ww]->cd[2]); + putFitsCard(chan, "CD2_2", wcs_[ww]->cd[3]); + } + } + // CDELT + else if (hd->find(cdelt.str().c_str()) || + (prim && prim->find(cdelt.str().c_str()))) { + putFitsCard(chan, "CDELT1", wcs_[ww]->cdelt[0]); + putFitsCard(chan, "CDELT2", wcs_[ww]->cdelt[1]); + + if (hd->find(pc.str().c_str()) || + (prim && prim->find(pc.str().c_str()))) { + putFitsCard(chan, "PC1_1", wcs_[ww]->pc[0]); + putFitsCard(chan, "PC1_2", wcs_[ww]->pc[1]); + putFitsCard(chan, "PC2_1", wcs_[ww]->pc[2]); + putFitsCard(chan, "PC2_2", wcs_[ww]->pc[3]); + } + else if (!ww && + (hd->find("PC001001") || (prim && prim->find("PC001001")))) { + putFitsCard(chan, "PC001001", wcs_[ww]->pc[0]); + putFitsCard(chan, "PC001002", wcs_[ww]->pc[1]); + putFitsCard(chan, "PC002001", wcs_[ww]->pc[2]); + putFitsCard(chan, "PC002002", wcs_[ww]->pc[3]); + } + else { + if (!ww && + (hd->find("CROTA1") || (prim && prim->find("CROTA1")))) + putFitsCard(chan, "CROTA1", wcs_[ww]->rot); + if (!ww && + (hd->find("CROTA2") || (prim && hd->find("CROTA2")))) + putFitsCard(chan, "CROTA2", wcs_[ww]->rot); + } + } + // sanity check + else if (!wcs_[ww]->cd[0] && + !wcs_[ww]->cd[1] && + !wcs_[ww]->cd[2] && + !wcs_[ww]->cd[3]) { + putFitsCard(chan, "CDELT1", wcs_[ww]->cdelt[0]); + putFitsCard(chan, "CDELT2", wcs_[ww]->cdelt[1]); + putFitsCard(chan, "PC1_1", wcs_[ww]->pc[0]); + putFitsCard(chan, "PC1_2", wcs_[ww]->pc[1]); + putFitsCard(chan, "PC2_1", wcs_[ww]->pc[2]); + putFitsCard(chan, "PC2_2", wcs_[ww]->pc[3]); + } + // fall back + else { + putFitsCard(chan, "CD1_1", wcs_[ww]->cd[0]); + putFitsCard(chan, "CD1_2", wcs_[ww]->cd[1]); + putFitsCard(chan, "CD2_1", wcs_[ww]->cd[2]); + putFitsCard(chan, "CD2_2", wcs_[ww]->cd[3]); + } + } + + // equatorial keywords + if (wcs_[ww]->prjcode>0 && wcs_[ww]->prjcode<34) { + // equiniox + putFitsCard(chan, "EQUINOX", wcs_[ww]->equinox); + + // from wcssub/wcsinit.c line 800 + // wcs[ww]->epoch = 1900.0 + (mjd - 15019.81352) / 365.242198781; + putFitsCard(chan, "MJD-OBS", + (wcs_[ww]->epoch-1900)*365.242198781+15019.81352); + + ostringstream radesys; + radesys << "RADESYS" << alt << ends; + if (hd->find(radesys.str().c_str())) { + // if RADESYS present, use it + putFitsCard(chan, "RADESYS", hd->getString(radesys.str().c_str())); + } + else if (prim && prim->find(radesys.str().c_str())) { + // if RADESYS present, use it + putFitsCard(chan, "RADESYS", prim->getString(radesys.str().c_str())); + } + else if (hd->find("RADECSYS")) { + // look for old RADECSYS + putFitsCard(chan, "RADESYS", hd->getString("RADECSYS")); + } + else if (prim && prim->find("RADECSYS")) { + // look for old RADECSYS + putFitsCard(chan, "RADESYS", prim->getString("RADECSYS")); + } + else { + // fall back on wcssubs + if (!strncmp("RA",wcs_[ww]->ctype[0],2) || + !strncmp("RA",wcs_[ww]->ctype[1],2)) { + if (!strncmp("FK4",wcs_[ww]->radecsys,3) || + !strncmp("FK4-NO-E",wcs_[ww]->radecsys,8) || + !strncmp("FK5",wcs_[ww]->radecsys,3) || + !strncmp("ICRS",wcs_[ww]->radecsys,4)) + putFitsCard(chan, "RADESYS", wcs_[ww]->radecsys); + } + } + } + + // ast is picky about latpole/longpole + if ((wcs_[ww]->latpole == 999 && wcs_[ww]->longpole == 999) || + (wcs_[ww]->latpole == 0 && wcs_[ww]->longpole == 0)) + ; + else { + if (wcs_[ww]->latpole != 999) + putFitsCard(chan, "LATPOLE", wcs_[ww]->latpole); + if (wcs_[ww]->longpole != 999) + putFitsCard(chan, "LONPOLE", wcs_[ww]->longpole); + } + + // Projection parameters- PV, QV, WAT + // TAN+PV (old SCAMP-backward compatibility) + // TPV+PV (new SCAMP) + // xxx+PV (ZPN generic) + // xxx+QV (TAN AUTOASTROM) + // TNX/ZPX+WAT (IRAF) + // TAN/LIN-SIP (SIP) + + // PVx_y (old SCAMP, SCAMP, generic) + // MAXPV defined in wcs.h + for (int ii=1; ii<=2; ii++) { + for (int mm=0; mm<=MAXPV; mm++) { + ostringstream str,str2; + str << "PV" << ii << '_' << mm << alt << ends; + str2 << "PV" << ii << '_' << mm << ends; + if (hd->find(str.str().c_str())) { + double val = hd->getReal(str.str().c_str(),0); + putFitsCard(chan, str2.str().c_str(), val); + } + else if (prim && prim->find(str.str().c_str())) { + double val = prim->getReal(str.str().c_str(),0); + putFitsCard(chan, str2.str().c_str(), val); + } + } + } + + // QVx_y (Autoastrom) + for (int ii=1; ii<=2; ii++) { + for (int mm=0; mm<=MAXPV; mm++) { + ostringstream str,str2; + str << "QV" << ii << '_' << mm << alt << ends; + str2 << "QV" << ii << '_' << mm << ends; + if (hd->find(str.str().c_str())) { + double val = hd->getReal(str.str().c_str(),0); + putFitsCard(chan, str2.str().c_str(), val); + } + else if (prim && prim->find(str.str().c_str())) { + double val = prim->getReal(str.str().c_str(),0); + putFitsCard(chan, str2.str().c_str(), val); + } + } + } + + // WATx_ (IRAF) (primary only) + if ((wcs_[ww]->prjcode == WCS_TNX || wcs_[ww]->prjcode == WCS_ZPX) && !ww) { + for (int jj=0; jj<=2; jj++) { + for (int ii=1; ii<=9; ii++) { + ostringstream str; + str << "WAT" << jj << "_00" << ii << ends; + if (hd->find(str.str().c_str())) { + char* val = hd->getString(str.str().c_str()); + if (val) { + putFitsCard(chan, str.str().c_str(), val); + delete [] val; + } + } + else if (prim && prim->find(str.str().c_str())) { + char* val = prim->getString(str.str().c_str()); + if (val) { + putFitsCard(chan, str.str().c_str(), val); + delete [] val; + } + } + } + } + } + + // SIP (TAN-SIP/LIN-SIP) (primary only) + if ((wcs_[ww]->prjcode == WCS_TAN || wcs_[ww]->prjcode == WCS_LIN) && + !ww && wcs_[ww]->distcode) { + if (hd->find("A_ORDER")) { + int val = hd->getInteger("A_ORDER",0); + putFitsCard(chan, "A_ORDER", val); + } + else if (prim && prim->find("A_ORDER")) { + int val = prim->getInteger("A_ORDER",0); + putFitsCard(chan, "A_ORDER", val); + } + + if (hd->find("AP_ORDER")) { + int val = hd->getInteger("AP_ORDER",0); + putFitsCard(chan, "AP_ORDER", val); + } + else if (prim && prim->find("AP_ORDER")) { + int val = prim->getInteger("AP_ORDER",0); + putFitsCard(chan, "AP_ORDER", val); + } + + if (hd->find("A_DMAX")) { + double val = hd->getReal("A_DMAX",0); + putFitsCard(chan, "A_DMAX", val); + } + else if (prim && prim->find("A_DMAX")) { + double val = prim->getReal("A_DMAX",0); + putFitsCard(chan, "A_DMAX", val); + } + + if (hd->find("B_ORDER")) { + int val = hd->getInteger("B_ORDER",0); + putFitsCard(chan, "B_ORDER", val); + } + else if (prim && prim->find("B_ORDER")) { + int val = prim->getInteger("B_ORDER",0); + putFitsCard(chan, "B_ORDER", val); + } + + if (hd->find("BP_ORDER")) { + int val = hd->getInteger("BP_ORDER",0); + putFitsCard(chan, "BP_ORDER", val); + } + else if (prim && prim->find("BP_ORDER")) { + int val = prim->getInteger("BP_ORDER",0); + putFitsCard(chan, "BP_ORDER", val); + } + + if (hd->find("B_DMAX")) { + double val = hd->getReal("B_DMAX",0); + putFitsCard(chan, "B_DMAX", val); + } + else if (prim && prim->find("B_DMAX")) { + double val = prim->getReal("B_DMAX",0); + putFitsCard(chan, "B_DMAX", val); + } + + for (int jj=0; jj<=9; jj++) { + for (int ii=0; ii<=9; ii++) { + { + ostringstream str; + str << "A_" << jj << "_" << ii << ends; + if (hd->find(str.str().c_str())) { + double val = hd->getReal(str.str().c_str(),0); + putFitsCard(chan, str.str().c_str(), val); + } + else if (prim && prim->find(str.str().c_str())) { + double val = prim->getReal(str.str().c_str(),0); + putFitsCard(chan, str.str().c_str(), val); + } + } + { + ostringstream str; + str << "AP_" << jj << "_" << ii << ends; + if (hd->find(str.str().c_str())) { + double val = hd->getReal(str.str().c_str(),0); + putFitsCard(chan, str.str().c_str(), val); + } + else if (prim && prim->find(str.str().c_str())) { + double val = prim->getReal(str.str().c_str(),0); + putFitsCard(chan, str.str().c_str(), val); + } + } + { + ostringstream str; + str << "B_" << jj << "_" << ii << ends; + if (hd->find(str.str().c_str())) { + double val = hd->getReal(str.str().c_str(),0); + putFitsCard(chan, str.str().c_str(), val); + } + else if (prim && prim->find(str.str().c_str())) { + double val = prim->getReal(str.str().c_str(),0); + putFitsCard(chan, str.str().c_str(), val); + } + } + { + ostringstream str; + str << "BP_" << jj << "_" << ii << ends; + if (hd->find(str.str().c_str())) { + double val = hd->getReal(str.str().c_str(),0); + putFitsCard(chan, str.str().c_str(), val); + } + else if (prim && prim->find(str.str().c_str())) { + double val = prim->getReal(str.str().c_str(),0); + putFitsCard(chan, str.str().c_str(), val); + } + } + } + } + } +} + +void FitsImage::wcs2ast0(int ww, void* chan) +{ + if (DebugAST) + cerr << endl << "wcs2ast0()" << endl; + + putFitsCard(chan, "CTYPE1", wcs_[ww]->ctype[0]); + putFitsCard(chan, "CTYPE2", wcs_[ww]->ctype[1]); + + // CRPIX/CRVAL + putFitsCard(chan, "CRPIX1", wcs_[ww]->crpix[0]); + putFitsCard(chan, "CRPIX2", wcs_[ww]->crpix[1]); + putFitsCard(chan, "CRVAL1", wcs_[ww]->crval[0]); + putFitsCard(chan, "CRVAL2", wcs_[ww]->crval[1]); + + putFitsCard(chan, "CD1_1", wcs_[ww]->cd[0]); + putFitsCard(chan, "CD1_2", wcs_[ww]->cd[1]); + putFitsCard(chan, "CD2_1", wcs_[ww]->cd[2]); + putFitsCard(chan, "CD2_2", wcs_[ww]->cd[3]); + + putFitsCard(chan, "EQUINOX", wcs_[ww]->equinox); + + // from wcssub/wcsinit.c line 800 + // wcs[ww]->epoch = 1900.0 + (mjd - 15019.81352) / 365.242198781; + putFitsCard(chan, "MJD-OBS", + (wcs_[ww]->epoch-1900)*365.242198781+15019.81352); + + putFitsCard(chan, "RADESYS", wcs_[ww]->radecsys); +} + +void FitsImage::putFitsCard(void* chan, const char* key, const char* value) +{ + char buf[80]; + memset(buf,'\0', 80); + + ostringstream str; + str.setf(ios::left,ios::adjustfield); + str.width(8); + str << key << "= '" << value << "'"; + memcpy(buf,str.str().c_str(),str.str().length()); + + astPutFits(chan, buf, 0); + astClearStatus; + + if (DebugAST) + cerr << str.str().c_str() << endl; +} + +void FitsImage::putFitsCard(void* chan, const char* key, int value) +{ + char buf[80]; + memset(buf,'\0', 80); + + ostringstream str; + str.setf(ios::left,ios::adjustfield); + str.width(8); + str << key << "= " << value; + memcpy(buf,str.str().c_str(),str.str().length()); + + astPutFits(chan, buf, 0); + astClearStatus; + + if (DebugAST) + cerr << str.str().c_str() << endl; +} + +void FitsImage::putFitsCard(void* chan, const char* key, double value) +{ + char buf[80]; + memset(buf,'\0', 80); + + ostringstream str; + str.setf(ios::left,ios::adjustfield); + str.setf(ios::scientific,ios::floatfield); + str.width(8); + str.precision(16); + str << key << "= " << value; + memcpy(buf,str.str().c_str(),str.str().length()); + + astPutFits(chan, buf, 0); + astClearStatus; + + if (DebugAST) + cerr << str.str().c_str() << endl; +} diff --git a/tksao/frame/fitsimage.h b/tksao/frame/fitsimage.h new file mode 100644 index 0000000..8d90280 --- /dev/null +++ b/tksao/frame/fitsimage.h @@ -0,0 +1,910 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsimage_h__ +#define __fitsimage_h__ + +#include "vector.h" +#include "vector3d.h" +#include "fitsdata.h" +#include "coord.h" +#include "file.h" +#include "wcs.h" +#include "head.h" + +#include "smooth.h" + +// WCS ' ','A' to 'Z', WCS0 +#define MULTWCS 27 +#define MULTWCSA 28 + +typedef struct { + double* kernel; + double* src; + double* dest; + int width; + int height; + int radius; +} t_smooth_arg; + +typedef struct { + FitsFile* base; + FitsData* basedata; + FitsFile* block; + Vector blockFactor; +} t_block_arg; + +typedef struct { + FitsData* data; + FrScale* fr; + FitsBound* bb; +} t_clip_arg; + +extern "C" { + #include "ast.h" +} + +class WCSx { + public: + double crpix[FTY_MAXAXES]; + double crval[FTY_MAXAXES]; + double cd[FTY_MAXAXES]; + + public: + WCSx(); +}; + +class FitsImage { + protected: + Context* context_; // pointer to context + Tcl_Interp* interp_; + + char* objectKeyword_; // object keyword + + // native fits file + FitsFile* fits_; + FitsFile* post_; // fits post processing + FitsFile* hist_; // fits bin + FitsFile* hpx_; // healpix + + // base + FitsFile* base_; + FitsData* basedata_; + + // block + int manageBlock_; + FitsFile* block_; + FitsData* blockdata_; + + // analysis + int manageAnalysis_; + FitsFile* analysis_; + FitsData* analysisdata_; + + // final + FitsFile* image_; + FitsData* data_; + + Vector histCursor; // start point to bin about (physical coords) + Vector actualHistCursor; // actual bin center (physical coords) + + char buf[32]; // tmp storage for returning strings + + // Mosaic items + int keyLTMV; + int keyATMV; + int keyDTMV; + int keyDATASEC; + + double jyBeam_; // beam area for radio maps + + BBox datasec; // DATASEC keyword + + int iisMode_; // flag to indicate if iis + Vector iisz_; // z1 and z2 + int iiszt_; // 0-Uniary, 1-Linear, 2-Log + + FitsImage* nextMosaic_; // next mosaic + FitsImage* nextSlice_; // next slice + + int address[FTY_MAXAXES]; + + int manageWCS_; + WorldCoor** wcs_; // wcs list + WCSx** wcsx_; // xth Axis WCS + AstFrameSet** ast_; // ast frameset; + FitsHead* wcsHeader_; // alt wcs header + FitsHead* altHeader_; // wcs header for wfpc2 + + Matrix wcsToRef_; // iraf/wcs matrix + + protected: + void reset(); + + void process(const char*, int); + void initCompress(); + void initNRRD(); + void initENVI(); + void initBin(); + void initHPX(); + void initWCS(); + void initWCSPhysical(); + Vector getHistCenter(); + + char* root(const char*); + char* strip(const char*); + +#ifdef __WIN32 + void smooth(); +#else + void smooth(pthread_t*, t_smooth_arg*); +#endif + + void wcsShow(WorldCoor*); + void astinit(int, FitsHead*, FitsHead*); + void astinit0(int); + int checkAst(double, double); + AstFrameSet* fits2ast(FitsHead*); + AstFrameSet* buildast(int, FitsHead*, FitsHead*); + AstFrameSet* buildast0(int); + void wcs2ast(int, FitsHead*, FitsHead*, void*); + void wcs2ast0(int, void*); + void header2ast(FitsHead*, void*); + void putFitsCard(void* chan, const char* key, const char* value); + void putFitsCard(void* chan, const char* key, int value); + void putFitsCard(void* chan, const char* key, double value); + + public: + char* fileName; + char* rootBaseFileName; + char* fullBaseFileName; + char* iisFileName; // alt file name for iis + + Matrix irafToRef; + + Matrix dataToImage; + Matrix imageToData; + + Matrix dataToRef; + Matrix refToData; + Matrix dataToUser; + Matrix userToData; + Matrix dataToWidget; + Matrix widgetToData; + Matrix dataToCanvas; + Matrix canvasToData; + Matrix dataToWindow; + Matrix windowToData; + + Matrix canvasToRef; + Matrix refToCanvas; + + Matrix refToImage; + Matrix imageToRef; + Matrix refToPhysical; + Matrix physicalToRef; + Matrix refToDetector; + Matrix detectorToRef; + Matrix refToAmplifier; + Matrix amplifierToRef; + + Matrix imageToWidget; + Matrix widgetToImage; + + Matrix imageToPhysical; + Matrix physicalToImage; + Matrix imageToDetector; + Matrix detectorToImage; + Matrix imageToAmplifier; + Matrix amplifierToImage; + + Matrix physicalToDetector; + Matrix detectorToPhysical; + Matrix physicalToAmplifier; + Matrix amplifierToPhysical; + + Matrix3d dataToImage3d; + Matrix3d imageToData3d; + + Matrix3d dataToRef3d; + Matrix3d refToData3d; + Matrix3d dataToUser3d; + Matrix3d userToData3d; + Matrix3d dataToWidget3d; + Matrix3d widgetToData3d; + Matrix3d dataToCanvas3d; + Matrix3d canvasToData3d; + Matrix3d dataToWindow3d; + Matrix3d windowToData3d; + + Matrix magnifierToData; + Matrix dataToMagnifier; + Matrix3d magnifierToData3d; + Matrix3d dataToMagnifier3d; + + Matrix pannerToData; + Matrix dataToPanner; + Matrix3d pannerToData3d; + Matrix3d dataToPanner3d; + + Matrix psToData; + Matrix dataToPS; + Matrix3d psToData3d; + Matrix3d dataToPS3d; + + FitsBound iparams; // image bbox + FitsBound dparams; // DATASEC bbox + FitsBound cparams; // crop bbox + + public: + FitsImage(Context*, Tcl_Interp*); + virtual ~FitsImage(); + + void setContext(Context* cx) {context_ = cx;} + + void load(); +#ifdef __WIN32 + void analysis(int); +#else + void analysis(int, pthread_t*, t_smooth_arg*); +#endif + void block(); +#ifndef __WIN32 + void block(pthread_t*); +#endif + + Matrix bin(const Vector&); + Matrix binCenter(); + Matrix binCursor(); + + FitsImage* nextMosaic() {return nextMosaic_;} + FitsImage* nextSlice() {return nextSlice_;} + void setNextMosaic(FitsImage* n) {nextMosaic_ = n;} + void setNextSlice(FitsImage* n) {nextSlice_ = n;} + + FitsFile* fitsFile() {return fits_;} + FitsFile* baseFile() {return base_;} + FitsFile* blockFile() {return block_;} + FitsFile* analysisFile() {return analysis_;} + FitsFile* imageFile() {return image_;} + + // we assume that 'data' is valid + void* basedata() {return basedata_->data();} + void* blockdata() {return blockdata_->data();} + void* analysisdata() {return analysisdata_->data();} + void* imagedata() {return data_->data();} + + // isValid() means "valid image found" + int isValid() {return image_ ? 1 : 0;} + int isPost() {return post_ ? 1 : 0;} + int isHist() {return hist_ ? 1 : 0;} + int isHPX() {return hpx_ ? 1 : 0;} + + int isImage() {return fits_ ? fits_->isImage() : 0;} + int isTable() {return fits_ ? fits_->isTable() : 0;} + int isAsciiTable() {return fits_ ? fits_->isAsciiTable() : 0;} + int isBinTable() {return fits_ ? fits_->isBinTable() : 0;} + + void close() {if (fits_) fits_->done();} + + void match(const char* xxname1, const char* yyname1, + Coord::CoordSystem sys1, Coord::SkyFrame sky1, + const char* xxname2, const char* yyname2, + Coord::CoordSystem sys2, Coord::SkyFrame sky2, + double rad, Coord::CoordSystem sys, Coord::SkyDist dist, + const char* rrname); + + FitsHead* parseWCS(istream&); + + Matrix nextBin(const Vector&); + void calcHistSize(); + Vector getHistDim(); + Vector getHistColMinMax(const char*); + Vector getHistColDim(const char*); + Vector getHistCursor() {return actualHistCursor;} + const char* getHistFilter(); + const char* getHistX(); + const char* getHistY(); + const char* getHistZ(); + char* getHistList(); + + void setBinCursor(const Vector&); + + void setBinX(const char* str) {if (fits_) fits_->setpBinX(str);} + void setBinY(const char* str) {if (fits_) fits_->setpBinY(str);} + void setBinZ(const char* str) {if (fits_) fits_->setpBinZ(str);} + void setBinFilter(const char* fil) {if (fits_) fits_->setpFilter(fil);} + void setBinSliceFilter(const char*); + void setBinColMinMax(const char* str, const Vector& lim) + {if (fits_) fits_->setColMinMax(str,lim);} + + int hasBinCol(const char*); + + const char* objectKeyword() {return objectKeyword_;} + void setObjectKeyword(const char*); + + void setFileName(const char*); + const char* getFileName(Base::FileNameType); + const char* updateFileNameBin(Base::FileNameType); + const char* updateFileNameImage(Base::FileNameType); + const char* iisGetFileName() {return iisFileName;} + void iisSetFileName(const char*); + + long naxis(int ii) {return image_->head()->naxis(ii);} + + long owidth() {return fits_->head()->naxis(0);} + long oheight() {return fits_->head()->naxis(1);} + Vector osize() {return Vector(owidth(),oheight());} + Vector ocenter() {return Vector(owidth(),oheight())/2.;} + + long width() {return image_->head()->naxis(0);} + long height() {return image_->head()->naxis(1);} + long depth() {return naxis(2)>0 ? naxis(2) : 1;} + Vector size() {return Vector(width(),height());} + Vector center() {return Vector(width(),height())/2.;} + + int nhdu(); + + int bitpix() {return image_->head()->bitpix();} + int ext() {return fits_->ext();} + + FitsBound* getDataParams(FrScale::SecMode); // return bbox in IMAGE + void setCropParams(int); + void setCropParams(int,int,int,int,int); + void setCropParams(const Vector&, const Vector&, int); + + int hasLTMV() {return keyLTMV;} + int hasATMV() {return keyATMV;} + int hasDTMV() {return keyDTMV;} + + FitsHead* wcsHeader() {return wcsHeader_;} + WCSx** wcsx() {return wcsx_;} + + int isIIS() {return iisMode_;} + Vector& iisz() {return iisz_;} + + Vector pix2wcs(Vector, Coord::CoordSystem, Coord::SkyFrame); + Vector* pix2wcs(Vector*, int, Coord::CoordSystem, Coord::SkyFrame); + char* pix2wcs(Vector, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, + char*); + + Vector wcs2pix(Vector, Coord::CoordSystem, Coord::SkyFrame); + Vector* wcs2pix(Vector*, int, Coord::CoordSystem, Coord::SkyFrame); + double wcsdist(Vector, Vector, Coord::CoordSystem); + + double pix2wcsx(double, Coord::CoordSystem, int); + double wcs2pixx(double, Coord::CoordSystem, int); + + void altWCS(istream&); + void appendWCS(istream&); + void listWCS(ostream&, Coord::CoordSystem); + void resetWCS(); + void replaceWCS(istream&); + + void initWCS0(const Vector&); + void resetWCS0(); + + void processKeywordsPhysical(); + void processKeywordsParams(); + void processKeywordsFitsSection(); + int processKeywordsIRAF(FitsImage*); + + WorldCoor* getWCS(Coord::CoordSystem sys) + {return (wcs_ && wcs_[sys-Coord::WCS]) ? wcs_[sys-Coord::WCS] : NULL;} + const char* getWCSName(Coord::CoordSystem sys) + {return (wcs_ && wcs_[sys-Coord::WCS]) ? wcs_[sys-Coord::WCS]->wcsname : NULL;} + Coord::Orientation getWCSOrientation(Coord::CoordSystem, Coord::SkyFrame); + double getWCSRotation(Coord::CoordSystem, Coord::SkyFrame); + Vector getWCScdelt(Coord::CoordSystem); + + void setAstSkyFrame(AstFrameSet*, Coord::SkyFrame); + void setAstFormat(AstFrameSet*, int, const char*); + AstFrameSet* getAST(Coord::CoordSystem sys) + {return (ast_ && ast_[sys-Coord::WCS]) ? ast_[sys-Coord::WCS] : NULL;} + + int hasWCS(Coord::CoordSystem); + int hasWCSx(Coord::CoordSystem, int); + int hasWCSEqu(Coord::CoordSystem); + int hasWCSCel(Coord::CoordSystem); + + void updateMatrices(Matrix&, Matrix&, Matrix&, Matrix&, Matrix&); + void updateMatrices(Matrix3d&, Matrix3d&, Matrix3d&, Matrix3d&); + + void updatePannerMatrices(Matrix&); + void updatePannerMatrices(Matrix3d&); + + void updateMagnifierMatrices(Matrix&); + void updateMagnifierMatrices(Matrix3d&); + + void updatePS(Matrix); + void updatePS(Matrix3d); + + Matrix& matrixToData(Coord::InternalSystem); + Matrix& matrixFromData(Coord::InternalSystem sys); + Matrix3d& matrixFromData3d(Coord::InternalSystem); + Matrix3d& matrixToData3d(Coord::InternalSystem); + + Vector mapFromRef(const Vector&, Coord::CoordSystem, Coord::SkyFrame =Coord::FK5); + void mapFromRef(const Vector&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, char*); + Vector mapToRef(const Vector&, Coord::CoordSystem, Coord::SkyFrame =Coord::FK5); + double mapFromRef3axis(double, Coord::CoordSystem, int); + double mapToRef3axis(double, Coord::CoordSystem, int); + double mapLenFromRef(double, Coord::CoordSystem, Coord::SkyDist =Coord::DEGREE); + Vector mapLenFromRef(const Vector&, Coord::CoordSystem, Coord::SkyDist =Coord::DEGREE); + double mapLenToRef(double, Coord::CoordSystem, Coord::SkyDist =Coord::DEGREE); + Vector mapLenToRef(const Vector&, Coord::CoordSystem, Coord::SkyDist =Coord::DEGREE); + double mapDistFromRef(const Vector&, const Vector&, Coord::CoordSystem, + Coord::SkyDist =Coord::DEGREE); + void listFromRef(ostream&, const Vector&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void listLenFromRef(ostream&, double, Coord::CoordSystem, Coord::SkyDist); + void listLenFromRef(ostream&, const Vector&, Coord::CoordSystem, Coord::SkyDist); + void listDistFromRef(ostream&, const Vector&, const Vector&, Coord::CoordSystem, Coord::SkyDist); + + const char* getValue(const Vector& v); + float getValueFloat(const Vector& v) {return data_->getValueFloat(v);} + double getValueDouble(const Vector& v) {return data_->getValueDouble(v);} + int getValueMask(const Vector& v) {return data_->getValueMask(v);} + int getValueMask(double x, double y) {return data_->getValueMask(x,y);} + + float getValueFloat(long i) {return data_->getValueFloat(i);} + double getValueDouble(long i) {return data_->getValueDouble(i);} + int getValueMask(long i) {return data_->getValueMask(i);} + + void setClip(double l, double h) {data_->setClip(l,h);} + + const char* getMin() {return data_ ? data_->getMin() : NULL;} + const char* getMinX() {return data_ ? data_->getMinX() : NULL;} + const char* getMinY() {return data_ ? data_->getMinY() : NULL;} + const char* getMax() {return data_ ? data_->getMax() : NULL;} + const char* getMaxX() {return data_ ? data_->getMaxX() : NULL;} + const char* getMaxY() {return data_ ? data_->getMaxY() : NULL;} + const char* getLow() {return data_ ? data_->getLow() : NULL;} + const char* getHigh() {return data_ ? data_->getHigh() : NULL;} + + double min() {return data_ ? data_->min() : 0;} + Vector minXY() {return data_ ? data_->minXY() : Vector();} + double max() {return data_ ? data_->max() : 0;} + Vector maxXY() {return data_ ? data_->maxXY() : Vector();} + + double low() {return data_ ? data_->low() : 0;} + double high() {return data_ ? data_->high() : 0;} + + void updateClip(FrScale*); +#ifndef __WIN32 + void updateClip(FrScale* fr, pthread_t* thread, t_clip_arg* targ); +#endif + + int hasDATAMIN() {return data_ ? data_->hasDATAMIN() : 0;} + int hasDATASEC() {return keyDATASEC;} + int hasIRAFMIN() {return data_ ? data_->hasIRAFMIN() : 0;} + + void hist(double* b, int l, double mn, double mx, FrScale::SecMode ds) + {data_->hist(b,l,mn,mx,getDataParams(ds));} + + char* display(FitsHead*); + char* displayHeader(); + char* displayPrimary(); + char* displayWCS(); + FitsHead* head() {return image_->head();} + char* getKeyword(const char* key) {return fits_->getKeyword(key);} + int findKeyword(const char*); + + int saveFitsPrimHeader(OutFitsStream& str) + {return image_ ? image_->saveFitsPrimHeader(str) : 0;} + + int saveFitsXtHeader(OutFitsStream& str, int dd) + {return image_ ? image_->saveFitsXtHeader(str, dd) : 0;} + + int saveFitsHeader(OutFitsStream& str, int dd) + {return image_ ? image_->saveFitsHeader(str, dd) : 0;} + + int saveFits(OutFitsStream& str) + {return image_ ? image_->saveFits(str) : 0;} + + int saveFitsPad(OutFitsStream& str, size_t cnt, char fil) + {return image_ ? image_->saveFitsPad(str, cnt, fil) : 0;} + + int saveFitsTable(OutFitsStream& str) + {return fits_ ? fits_->saveFitsTable(str) : 0;} + + int saveArray(OutFitsStream& str, FitsFile::ArchType endian) + {return image_ ? image_->saveArray(str, endian) : 0;} + + int saveFitsIISHeader(OutFitsStream& str) + {return image_ ? image_->saveFitsIISHeader(str) : 0;} + + int saveFitsIIS(OutFitsStream& str) + {return image_ ? image_->saveFitsIIS(str,iisz_) : 0;} + + const Matrix& wcsToRef() {return wcsToRef_;} + void setwcsToRef(Matrix mm) {wcsToRef_ = mm;} +}; + +// Fits + +class FitsImageFitsAlloc : public FitsImage { +public: + FitsImageFitsAlloc(Context*, Tcl_Interp*, const char*, const char*, + FitsFile::FlushMode, int); +}; + +class FitsImageFitsAllocGZ : public FitsImage { +public: + FitsImageFitsAllocGZ(Context*, Tcl_Interp*, const char*, const char*, + FitsFile::FlushMode, int); +}; + +class FitsImageFitsChannel : public FitsImage { +public: + FitsImageFitsChannel(Context*, Tcl_Interp*, const char*, const char*, + FitsFile::FlushMode, int); +}; + +class FitsImageFitsMMap : public FitsImage { +public: + FitsImageFitsMMap(Context*, Tcl_Interp*, const char*, int); +}; + +class FitsImageFitsSMMap : public FitsImage { +public: + FitsImageFitsSMMap(Context*, Tcl_Interp*, const char*, const char*, int); +}; + +class FitsImageFitsMMapIncr : public FitsImage { +public: + FitsImageFitsMMapIncr(Context*, Tcl_Interp*, const char*, int); +}; + +class FitsImageFitsShare : public FitsImage { +public: + FitsImageFitsShare(Context*, Tcl_Interp*, Base::ShmType, int, const char*, int); +}; + +class FitsImageFitsSShare : public FitsImage { +public: + FitsImageFitsSShare(Context*, Tcl_Interp*, Base::ShmType, + int, int, const char*, int); +}; + +class FitsImageFitsSocket : public FitsImage { +public: + FitsImageFitsSocket(Context*, Tcl_Interp*, int, const char*, + FitsFile::FlushMode, int); +}; + +class FitsImageFitsSocketGZ : public FitsImage { +public: + FitsImageFitsSocketGZ(Context*, Tcl_Interp*, int, const char*, + FitsFile::FlushMode, int); +}; + +class FitsImageFitsVar : public FitsImage { +public: + FitsImageFitsVar(Context*, Tcl_Interp*, + const char*, const char*, int); +}; + +class FitsImageFitsOrder : public FitsImage { +public: + FitsImageFitsOrder(Context*, Tcl_Interp*, FitsImage*, FitsHead*, + char*, size_t, int); +}; + +// Fits Next + +class FitsImageFitsNextAlloc : public FitsImage { +public: + FitsImageFitsNextAlloc(Context*, Tcl_Interp*, const char*, FitsFile*, int); +}; + +class FitsImageFitsNextAllocGZ : public FitsImage { +public: + FitsImageFitsNextAllocGZ(Context*, Tcl_Interp*, const char*, FitsFile*, int); +}; + +class FitsImageFitsNextChannel : public FitsImage { +public: + FitsImageFitsNextChannel(Context*, Tcl_Interp*, const char*, FitsFile*, int); +}; + +class FitsImageFitsNextMMap : public FitsImage { +public: + FitsImageFitsNextMMap(Context*, Tcl_Interp*, const char*, FitsFile*, int); +}; + +class FitsImageFitsNextSMMap : public FitsImage { +public: + FitsImageFitsNextSMMap(Context*, Tcl_Interp*, const char*, FitsFile*, int); +}; + +class FitsImageFitsNextMMapIncr : public FitsImage { +public: + FitsImageFitsNextMMapIncr(Context*, Tcl_Interp*, const char*, FitsFile*, int); +}; + +class FitsImageFitsNextShare : public FitsImage { +public: + FitsImageFitsNextShare(Context*, Tcl_Interp*, const char*, FitsFile*, int); +}; + +class FitsImageFitsNextSShare : public FitsImage { +public: + FitsImageFitsNextSShare(Context*, Tcl_Interp*, const char*, FitsFile*, int); +}; + +class FitsImageFitsNextSocket : public FitsImage { +public: + FitsImageFitsNextSocket(Context*, Tcl_Interp*, const char*, FitsFile*, int); +}; + +class FitsImageFitsNextSocketGZ : public FitsImage { +public: + FitsImageFitsNextSocketGZ(Context*, Tcl_Interp*, const char*, FitsFile*, int); +}; + +class FitsImageFitsNextVar : public FitsImage { +public: + FitsImageFitsNextVar(Context*, Tcl_Interp*, const char*, FitsFile*, int); +}; + +class FitsImageFitsNextHist : public FitsImage { +public: + FitsImageFitsNextHist(Context*, Tcl_Interp*, FitsImage*, FitsFile*, int); +}; + +class FitsImageFitsNextPost : public FitsImage { +public: + FitsImageFitsNextPost(Context*, Tcl_Interp*, FitsImage*, FitsFile*, int); +}; + +class FitsImageFitsNextOrder : public FitsImage { +public: + FitsImageFitsNextOrder(Context*, Tcl_Interp*, FitsImage*, FitsFile*, int); +}; + +// Array + +class FitsImageArrAlloc : public FitsImage { +public: + FitsImageArrAlloc(Context*, Tcl_Interp*, const char*, const char*, + FitsFile::FlushMode, int); +}; + +class FitsImageArrAllocGZ : public FitsImage { +public: + FitsImageArrAllocGZ(Context*, Tcl_Interp*, const char*, const char*, + FitsFile::FlushMode, int); +}; + +class FitsImageArrChannel : public FitsImage { +public: + FitsImageArrChannel(Context*, Tcl_Interp*, const char*, const char*, + FitsFile::FlushMode, int); +}; + +class FitsImageArrMMap : public FitsImage { +public: + FitsImageArrMMap(Context*, Tcl_Interp*, const char*, int); +}; + +class FitsImageArrMMapIncr : public FitsImage { +public: + FitsImageArrMMapIncr(Context*, Tcl_Interp*, const char*, int); +}; + +class FitsImageArrShare : public FitsImage { +public: + FitsImageArrShare(Context*, Tcl_Interp*, Base::ShmType, int, const char*, int); +}; + +class FitsImageArrSocket : public FitsImage { +public: + FitsImageArrSocket(Context*, Tcl_Interp*, + int, const char*, FitsFile::FlushMode, int); +}; + +class FitsImageArrSocketGZ : public FitsImage { +public: + FitsImageArrSocketGZ(Context*, Tcl_Interp*, + int, const char*, FitsFile::FlushMode, int); +}; + +class FitsImageArrVar : public FitsImage { +public: + FitsImageArrVar(Context*, Tcl_Interp*, const char*, const char*, int); +}; + +// ENVI + +class FitsImageENVISMMap : public FitsImage { +public: + FitsImageENVISMMap(Context*, Tcl_Interp*, const char*, const char*, int); +}; + +// NRRD + +class FitsImageNRRDAlloc : public FitsImage { +public: + FitsImageNRRDAlloc(Context*, Tcl_Interp*, const char*, const char*, + FitsFile::FlushMode, int); +}; + +class FitsImageNRRDChannel : public FitsImage { +public: + FitsImageNRRDChannel(Context*, Tcl_Interp*, const char*, const char*, + FitsFile::FlushMode, int); +}; + +class FitsImageNRRDMMap : public FitsImage { +public: + FitsImageNRRDMMap(Context*, Tcl_Interp*, const char*, int); +}; + +class FitsImageNRRDShare : public FitsImage { +public: + FitsImageNRRDShare(Context*, Tcl_Interp*, + Base::ShmType, int, const char*, int); +}; + +class FitsImageNRRDSocket : public FitsImage { +public: + FitsImageNRRDSocket(Context*, Tcl_Interp*, + int, const char*, FitsFile::FlushMode, int); +}; + +class FitsImageNRRDVar : public FitsImage { +public: + FitsImageNRRDVar(Context*, Tcl_Interp*, const char*, const char*, int); +}; + +// Photo + +class FitsImagePhoto : public FitsImage { +public: + FitsImagePhoto(Context*, Tcl_Interp*, const char*, const char*, int); +}; + +class FitsImagePhotoCube : public FitsImage { +public: + FitsImagePhotoCube(Context*, Tcl_Interp*, const char*, const char*, int); +}; + +class FitsImagePhotoCubeNext : public FitsImage { +public: + FitsImagePhotoCubeNext(Context*, Tcl_Interp*, + const char*, FitsFile*, int); +}; + +// Mosaic + +class FitsImageMosaicAlloc : public FitsImage { +public: + FitsImageMosaicAlloc(Context*, Tcl_Interp*, + const char*, const char*, + FitsFile::FlushMode, int); +}; + +class FitsImageMosaicAllocGZ : public FitsImage { +public: + FitsImageMosaicAllocGZ(Context*, Tcl_Interp*, + const char*, const char*, + FitsFile::FlushMode, int); +}; + +class FitsImageMosaicChannel : public FitsImage { +public: + FitsImageMosaicChannel(Context*, Tcl_Interp*, + const char*, const char*, + FitsFile::FlushMode, int); +}; + +class FitsImageMosaicMMap : public FitsImage { +public: + FitsImageMosaicMMap(Context*, Tcl_Interp*, + const char*, int); +}; + +class FitsImageMosaicMMapIncr : public FitsImage { +public: + FitsImageMosaicMMapIncr(Context*, Tcl_Interp*, + const char*, int); +}; + +class FitsImageMosaicShare : public FitsImage { +public: + FitsImageMosaicShare(Context*, Tcl_Interp*, + Base::ShmType, int, const char*, int); +}; + +class FitsImageMosaicSocket : public FitsImage { +public: + FitsImageMosaicSocket(Context*, Tcl_Interp*, + int, const char*, FitsFile::FlushMode, int); +}; + +class FitsImageMosaicSocketGZ : public FitsImage { +public: + FitsImageMosaicSocketGZ(Context*, Tcl_Interp*, + int, const char*, FitsFile::FlushMode, int); +}; + +class FitsImageMosaicVar : public FitsImage { +public: + FitsImageMosaicVar(Context*, Tcl_Interp*, + const char*, const char*, int); +}; + +// Mosaic Next + +class FitsImageMosaicNextAlloc : public FitsImage { +public: + FitsImageMosaicNextAlloc(Context*, Tcl_Interp*, + const char*, FitsFile*, + FitsFile::FlushMode, int); +}; + +class FitsImageMosaicNextAllocGZ : public FitsImage { +public: + FitsImageMosaicNextAllocGZ(Context*, Tcl_Interp*, + const char*, FitsFile*, + FitsFile::FlushMode, int); +}; + +class FitsImageMosaicNextChannel : public FitsImage { +public: + FitsImageMosaicNextChannel(Context*, Tcl_Interp*, + const char*, FitsFile*, + FitsFile::FlushMode, int); +}; + +class FitsImageMosaicNextMMap : public FitsImage { +public: + FitsImageMosaicNextMMap(Context*, Tcl_Interp*, + const char*, FitsFile*, int); +}; + +class FitsImageMosaicNextMMapIncr : public FitsImage { +public: + FitsImageMosaicNextMMapIncr(Context*, Tcl_Interp*, + const char*, FitsFile*, int); +}; + +class FitsImageMosaicNextShare : public FitsImage { +public: + FitsImageMosaicNextShare(Context*, Tcl_Interp*, + const char*, FitsFile*, int); +}; + +class FitsImageMosaicNextSocket : public FitsImage { +public: + FitsImageMosaicNextSocket(Context*, Tcl_Interp*, + const char*, FitsFile*, + FitsFile::FlushMode, int); +}; + +class FitsImageMosaicNextSocketGZ : public FitsImage { +public: + FitsImageMosaicNextSocketGZ(Context*, Tcl_Interp*, + const char*, FitsFile*, + FitsFile::FlushMode, int); +}; + +class FitsImageMosaicNextVar : public FitsImage { +public: + FitsImageMosaicNextVar(Context*, Tcl_Interp*, + const char*, FitsFile*, int); +}; + +// IIS + +class FitsImageIIS : public FitsImage { +public: + FitsImageIIS(Context*, Tcl_Interp*, int, int); + void iisErase(); + char* iisGet(int xx, int yy, int dx, int dy); + void iisSet(const char* src, int xx, int yy, int dx, int dy); + void iisWCS(const Matrix&, const Vector&, int); +}; + +#endif diff --git a/tksao/frame/fitsmap.C b/tksao/frame/fitsmap.C new file mode 100644 index 0000000..5bbea75 --- /dev/null +++ b/tksao/frame/fitsmap.C @@ -0,0 +1,393 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "fitsimage.h" + +// Map Point + +Vector FitsImage::mapFromRef(const Vector& vv, Coord::CoordSystem out, + Coord::SkyFrame sky) +{ + switch (out) { + case Coord::IMAGE: + return vv * refToImage; + case Coord::PHYSICAL: + return vv * refToPhysical; + case Coord::AMPLIFIER: + return vv * refToAmplifier; + case Coord::DETECTOR: + return vv * refToDetector; + default: + if (hasWCS(out)) + return pix2wcs(vv * refToImage, out, sky); + } + + maperr =1; + return vv; +} + +void FitsImage::mapFromRef(const Vector& vv, Coord::CoordSystem out, + Coord::SkyFrame sky, Coord::SkyFormat format, + char* buf) +{ + if (hasWCS(out)) { + pix2wcs(vv * refToImage, out, sky, format, buf); + return; + } + + maperr =1; + strcpy(buf,""); +} + +Vector FitsImage::mapToRef(const Vector& vv, Coord::CoordSystem in, + Coord::SkyFrame sky) +{ + switch (in) { + case Coord::IMAGE: + return vv * imageToRef; + case Coord::PHYSICAL: + return vv * physicalToRef; + case Coord::AMPLIFIER: + return vv * amplifierToRef; + case Coord::DETECTOR: + return vv * detectorToRef; + default: + if (hasWCS(in)) + return wcs2pix(vv, in, sky) * imageToRef; + } + + maperr =1; + return vv; +} + +void FitsImage::listFromRef(ostream& str, const Vector& vv, + Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + str << setprecision(8) << mapFromRef(vv, sys); + break; + default: + if (hasWCS(sys)) { + if (hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + str << setprecision(10) << mapFromRef(vv, sys, sky); + break; + case Coord::SEXAGESIMAL: + { + char buf[64]; + buf[0] = '\0'; + mapFromRef(vv, sys, sky, format, buf); + + // grap only the first two items + char* ptr = buf; + while (*ptr) + ptr++; + while (*ptr != ' ' && ptr >= buf) + ptr--; + *ptr = '\0'; + str << buf; + } + break; + } + } + else + str << setprecision(8) << mapFromRef(vv, sys); + } + else + str << "0 0"; + } +} + +// Map Length + +double FitsImage::mapLenFromRef(double dd, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Vector rr = mapLenFromRef(Vector(dd,0),sys,dist); + return rr[0]; +} + +Vector FitsImage::mapLenFromRef(const Vector& vv, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + // really from image coords + switch (sys) { + case Coord::IMAGE: + return mapLen(vv,refToImage); + case Coord::PHYSICAL: + return mapLen(vv,refToPhysical); + case Coord::AMPLIFIER: + return mapLen(vv,refToPhysical * physicalToAmplifier); + case Coord::DETECTOR: + return mapLen(vv,refToPhysical * physicalToDetector); + default: + if (hasWCS(sys)) { + Vector cd = getWCScdelt(sys); + Vector in = mapLen(vv,refToImage); + Vector out = Vector(in[0]*cd[0], in[1]*cd[1]).abs(); + + if (hasWCSCel(sys)) { + switch (dist) { + case Coord::DEGREE: + break; + case Coord::ARCMIN: + out *= 60; + break; + case Coord::ARCSEC: + out *=60*60; + break; + } + } + return out; + } + } + + maperr =1; + return Vector(); +} + +double FitsImage::mapLenToRef(double dd, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Vector rr = mapLenToRef(Vector(dd,0), sys, dist); + return rr[0]; +} + +Vector FitsImage::mapLenToRef(const Vector& vv, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + switch (sys) { + case Coord::IMAGE: + return mapLen(vv,imageToRef); + case Coord::PHYSICAL: + return mapLen(vv,physicalToRef); + case Coord::AMPLIFIER: + return mapLen(vv,amplifierToPhysical * physicalToRef); + case Coord::DETECTOR: + return mapLen(vv,detectorToPhysical * physicalToRef); + default: + if (hasWCS(sys)) { + Vector cd = getWCScdelt(sys); + Vector in = mapLen(vv,refToImage); + Vector out = Vector(in[0]/cd[0], in[1]/cd[1]).abs(); + + if (hasWCSCel(sys)) { + switch (dist) { + case Coord::DEGREE: + break; + case Coord::ARCMIN: + out /= 60; + break; + case Coord::ARCSEC: + out /= 60*60; + break; + } + } + return out; + } + } + + maperr =1; + return Vector(); +} + +void FitsImage::listLenFromRef(ostream& str, double dd, + Coord::CoordSystem sys, Coord::SkyDist dist) +{ + double out = mapLenFromRef(dd, sys, dist); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + str << setprecision(8) << out; + break; + default: + if (hasWCS(sys)) { + if (hasWCSCel(sys)) { + str << fixed; + switch (dist) { + case Coord::DEGREE: + str << setprecision(7); + break; + case Coord::ARCMIN: + str << setprecision(5); + break; + case Coord::ARCSEC: + str << setprecision(3); + break; + } + str << out; + } + else + str << setprecision(8) << out; + } + else + str << "0"; + } +} + +void FitsImage::listLenFromRef(ostream& str, const Vector& vv, + Coord::CoordSystem sys, Coord::SkyDist dist) +{ + Vector out = mapLenFromRef(vv, sys, dist); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + str << setprecision(8) << out; + break; + default: + if (hasWCS(sys)) { + if (hasWCSCel(sys)) { + str << fixed; + switch (dist) { + case Coord::DEGREE: + str << setprecision(7); + break; + case Coord::ARCMIN: + str << setprecision(5); + break; + case Coord::ARCSEC: + str << setprecision(3); + break; + } + str << out; + } + else + str << setprecision(8) << out; + } + else + str << "0 0"; + } +} + +// Map Distance + +double FitsImage::mapDistFromRef(const Vector& vv1, const Vector& vv2, + Coord::CoordSystem sys, Coord::SkyDist dist) +{ + switch (sys) { + case Coord::IMAGE: + { + Vector v1 = vv1 * refToImage; + Vector v2 = vv2 * refToImage; + return (v2-v1).length(); + } + case Coord::PHYSICAL: + { + Vector v1 = vv1 * refToPhysical; + Vector v2 = vv2 * refToPhysical; + return (v2-v1).length(); + } + case Coord::AMPLIFIER: + { + Vector v1 = vv1 * refToPhysical * physicalToAmplifier; + Vector v2 = vv2 * refToPhysical * physicalToAmplifier; + return (v2-v1).length(); + } + case Coord::DETECTOR: + { + Vector v1 = vv1 * refToPhysical * physicalToDetector; + Vector v2 = vv2 * refToPhysical * physicalToDetector; + return (v2-v1).length(); + } + default: + if (hasWCS(sys)) { + Vector v1 = pix2wcs(vv1 * refToImage, sys, Coord::FK5); + Vector v2 = pix2wcs(vv2 * refToImage, sys, Coord::FK5); + + if (hasWCSCel(sys)) { + switch (dist) { + case Coord::DEGREE: + return wcsdist(v1,v2,sys); + case Coord::ARCMIN: + return wcsdist(v1,v2,sys)*60; + case Coord::ARCSEC: + return wcsdist(v1,v2,sys)*60*60; + } + } + else + return wcsdist(v1,v2,sys); + } + } + + maperr =1; + return 0; +} + +void FitsImage::listDistFromRef(ostream& str, + const Vector& vv1, const Vector& vv2, + Coord::CoordSystem sys, Coord::SkyDist dist) +{ + double out = mapDistFromRef(vv1, vv2, sys, dist); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + str << setprecision(8) << out; + break; + default: + if (hasWCS(sys)) { + if (hasWCSCel(sys)) { + str << fixed; + switch (dist) { + case Coord::DEGREE: + str << setprecision(7); + break; + case Coord::ARCMIN: + str << setprecision(5); + break; + case Coord::ARCSEC: + str << setprecision(3); + break; + } + str << out; + } + else + str << setprecision(8) << out; + } + else + str << "0 0"; + } +} + +// 3D + +double FitsImage::mapFromRef3axis(double vv, Coord::CoordSystem out, int ss) +{ + switch (out) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::AMPLIFIER: + case Coord::DETECTOR: + return vv+.5; + default: + return pix2wcsx(vv+.5,out,ss); + } +} + +double FitsImage::mapToRef3axis(double vv, Coord::CoordSystem in, int ss) +{ + switch (in) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::AMPLIFIER: + case Coord::DETECTOR: + return vv-.5; + default: + return wcs2pixx(vv,in,ss) -.5; + } +} diff --git a/tksao/frame/fitsmask.C b/tksao/frame/fitsmask.C new file mode 100644 index 0000000..2aa8633 --- /dev/null +++ b/tksao/frame/fitsmask.C @@ -0,0 +1,50 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "fitsmask.h" +#include "base.h" +#include "fitsimage.h" + +FitsMask::FitsMask(Base* p, FitsImage* fits, char* clr, int mrk) + : parent_(p), mask_(fits) +{ + current_ = mask_; + mptr_ = current_; + colorName_ = dupstr(clr); + color_ = parent_->getXColor(colorName_); + parent_->encodeTrueColor(color_, trueColor_); + mark_ = mrk; + + next_ = NULL; + previous_ = NULL; +} + +FitsMask::~FitsMask() +{ + if (colorName_) + delete [] colorName_; + + FitsImage* ptr = mask_; + while (ptr) { + // better not have more that one slice + FitsImage* sptr = ptr->nextSlice(); + while (sptr) { + FitsImage* stmp = sptr->nextSlice(); + delete sptr; + sptr = stmp; + } + + FitsImage* tmp = ptr->nextMosaic(); + delete ptr; + ptr = tmp; + } +} + +void FitsMask::nextMosaic() { + if (mptr_) + mptr_ = mptr_->nextMosaic(); +} + diff --git a/tksao/frame/fitsmask.h b/tksao/frame/fitsmask.h new file mode 100644 index 0000000..6c754e0 --- /dev/null +++ b/tksao/frame/fitsmask.h @@ -0,0 +1,53 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fitsmask_h__ +#define __fitsmask_h__ + +#include + +class Base; +class FitsImage; + +class FitsMask { + private: + Base* parent_; + + FitsImage* mask_; + FitsImage* current_; + FitsImage* mptr_; + + char* colorName_; + XColor* color_; + char trueColor_[4]; + + int mark_; + + protected: + FitsMask* previous_; + FitsMask* next_; + + public: + FitsMask(Base*, FitsImage*, char*, int); + virtual ~FitsMask(); + + FitsImage* mask() {return mask_;} + FitsImage* current() {return current_;} + FitsImage* mptr() {return mptr_;} + XColor* color() {return color_;} + char* trueColor() {return trueColor_;} + int mark() {return mark_;} + + void initMosaic() {mptr_ = current_;} + void nextMosaic(); + void nextSlice(); + + FitsMask* previous() {return previous_;} + void setPrevious(FitsMask* m) {previous_ = m;} + FitsMask* next() {return next_;} + void setNext(FitsMask* m) {next_ = m;} +}; + +#endif + diff --git a/tksao/frame/fitsnrrd.C b/tksao/frame/fitsnrrd.C new file mode 100644 index 0000000..efd665b --- /dev/null +++ b/tksao/frame/fitsnrrd.C @@ -0,0 +1,47 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "fitsimage.h" +#include "nrrdgzip.h" + +void FitsImage::initNRRD() +{ + if (post_) + delete post_; + post_ = NULL; + + switch (fits_->pEncoding()) { + case FitsFile::RAW: + break; + case FitsFile::GZIP: + switch (fits_->pBitpix()) { + case 8: + post_ = new FitsNRRDGzipm(fits_); + break; + case 16: + post_ = new FitsNRRDGzipm(fits_); + break; + case -16: + post_ = new FitsNRRDGzipm(fits_); + break; + case 32: + post_ = new FitsNRRDGzipm(fits_); + break; + case 64: + post_ = new FitsNRRDGzipm(fits_); + break; + case -32: + post_ = new FitsNRRDGzipm(fits_); + break; + case -64: + post_ = new FitsNRRDGzipm(fits_); + break; + } + break; + default: + break; + } + + return; +} diff --git a/tksao/frame/fr3dcommand.C b/tksao/frame/fr3dcommand.C new file mode 100644 index 0000000..f208583 --- /dev/null +++ b/tksao/frame/fr3dcommand.C @@ -0,0 +1,615 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "frame3dbase.h" +#include "fitsimage.h" +#include "context.h" +#include "marker.h" + +void Frame3dBase::binToFitCmd() +{ + if (!keyContext->fits) + return; + + Vector3d dim(keyContext->fits->getHistDim(), keyContext->binDepth()); + double bf = 1/calcZoom3d(dim, Vector(options->width,options->height)); + + // round up to next power of 2 + if (bf < 1) + keyContext->setBinToFactor(Vector(1,1)); + else { + int p=1; + while (psetBinToFactor(Vector(p,p)); + } + + Matrix mm = keyContext->binCursor(); + updateBin(mm); +} + +void Frame3dBase::blockToFitCmd() +{ + if (!keyContext->fits) + return; + + Vector3d ss(keyContext->fits->osize(),keyContext->naxis(2)); + double bf = 1/calcZoom3d(ss, Vector(options->width,options->height)); + + // round down to next power of 2 + Vector vv; + if (bf < 1) + vv = keyContext->setBlockToFactor(Vector(1,1)); + else { + int p=1; + while (psetBlockToFactor(Vector(p,p)); + } + + keyContext->block(); + keyContext->analysis(); + updateBlock(vv); +} + +void Frame3dBase::crop3dBeginCmd(const Vector& vv, int which) +{ + // which =0 (zmin) which =1 (zmax) + if (!keyContext->fits) + return; + + cropBegin = vv * Scale(zoom_).invert(); + cropEnd = vv * Scale(zoom_).invert(); + + // params is a BBOX in DATA coords 0-n + FitsZBound* zparams = + keyContext->getDataParams(keyContext->secMode()); + if (!which) + cropsl_ = zparams->zmin; + else + cropsl_ = zparams->zmax; +} + +void Frame3dBase::crop3dMotionCmd(const Vector& vv, int which) +{ + // which =0 (zmin) which =1 (zmax) + if (!keyContext->fits) + return; + + // params is a BBOX in DATA coords 0-n + FitsBound* params = + keyContext->fits->getDataParams(keyContext->secMode()); + FitsZBound* zparams = + keyContext->getDataParams(keyContext->secMode()); + Vector ss(params->xmin,params->ymin); + Vector tt(params->xmax,params->ymax); + + // erase + if (cropBegin[0]!=cropEnd[0] || cropBegin[1]!=cropEnd[1]) { + Vector ll = mapFromRef3d(ss,Coord::CANVAS,cropsl_); + Vector lr = mapFromRef3d(Vector(tt[0],ss[1]),Coord::CANVAS,cropsl_); + Vector ur = mapFromRef3d(tt,Coord::CANVAS,cropsl_); + Vector ul = mapFromRef3d(Vector(ss[0],tt[1]),Coord::CANVAS,cropsl_); + + BBox bb(ll); + bb.bound(lr); + bb.bound(ur); + bb.bound(ul); + + redrawNow(bb.expand(2)); + } + + cropEnd = vv * Scale(zoom_).invert(); + Vector diff = cropEnd-cropBegin; + if (!which) + cropsl_ = diff[0]+zparams->zmin; + else + cropsl_ = diff[0]+zparams->zmax; + + // this will be incorrect for multiple ext/file cubes + double depth = keyContext->naxis(2); + if (!which) { + if (cropsl_<0) + cropsl_ = 0; + if (cropsl_>zparams->zmax-1) + cropsl_ = zparams->zmax-1; + } + else { + if (cropsl_zmin+1) + cropsl_ = zparams->zmin+1; + if (cropsl_>depth) + cropsl_ = depth; + } + + // and draw to window + { + Vector ll = mapFromRef3d(ss,Coord::WINDOW,cropsl_); + Vector lr = mapFromRef3d(Vector(tt[0],ss[1]),Coord::WINDOW,cropsl_); + Vector ur = mapFromRef3d(tt,Coord::WINDOW,cropsl_); + Vector ul = mapFromRef3d(Vector(ss[0],tt[1]),Coord::WINDOW,cropsl_); + + XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,ll[0],ll[1],lr[0],lr[1]); + XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,lr[0],lr[1],ur[0],ur[1]); + XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,ur[0],ur[1],ul[0],ul[1]); + XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,ul[0],ul[1],ll[0],ll[1]); + } +} + +void Frame3dBase::crop3dEndCmd(const Vector& vv, int which) +{ + // which =0 (zmin) which =1 (zmax) + if (!keyContext->fits) + return; + + // params is a BBOX in DATA coords 0-n + FitsBound* params = + keyContext->fits->getDataParams(keyContext->secMode()); + FitsZBound* zparams = + keyContext->getDataParams(keyContext->secMode()); + Vector ss(params->xmin,params->ymin); + Vector tt(params->xmax,params->ymax); + + // erase + if (cropBegin[0]!=cropEnd[0] || cropBegin[1]!=cropEnd[1]) { + Vector ll = mapFromRef3d(ss,Coord::CANVAS,cropsl_); + Vector lr = mapFromRef3d(Vector(tt[0],ss[1]),Coord::CANVAS,cropsl_); + Vector ur = mapFromRef3d(tt,Coord::CANVAS,cropsl_); + Vector ul = mapFromRef3d(Vector(ss[0],tt[1]),Coord::CANVAS,cropsl_); + + BBox bb(ll); + bb.bound(lr); + bb.bound(ur); + bb.bound(ul); + + redrawNow(bb.expand(2)); + } + + cropEnd = vv * Scale(zoom_).invert(); + Vector diff = cropEnd-cropBegin; + if (!which) + cropsl_ = diff[0]+zparams->zmin; + else + cropsl_ = diff[0]+zparams->zmax; + + // this will be incorrect for multiple ext/file cubes + double depth = keyContext->naxis(2); + if (!which) { + if (cropsl_<0) + cropsl_ = 0; + if (cropsl_>zparams->zmax-1) + cropsl_ = zparams->zmax-1; + } + else { + if (cropsl_zmin+1) + cropsl_ = zparams->zmin+1; + if (cropsl_>depth) + cropsl_ = depth; + } + + if (cropBegin[0]!=cropEnd[0] || cropBegin[1]!=cropEnd[1]) { + keyContext->setSecMode(FrScale::CROPSEC); + + // params is a BBOX in DATA coords 0-n + if (!which) + keyContext->setCrop3dParams(int(cropsl_+.5),zparams->zmax); + else + keyContext->setCrop3dParams(zparams->zmin,int(cropsl_+.5)); + + // set current slice if needed + // setSlice() IMAGE (ranges 1-n) + // context->slice() IMAGE (ranges 1-n) + // cropsl_ ranges coords 0-n + double sl = keyContext->slice(2)-.5; + if (!which) { + if (sl<=cropsl_) + setSlice(2,int(cropsl_+1.5)); + } + else { + if (sl>cropsl_) + setSlice(2,int(cropsl_)); + } + } + else { + keyContext->resetSecMode(); + keyContext->setCrop3dParams(); + FitsImage* sptr = keyContext->fits; + while (sptr) { + sptr->setCropParams(keyContext->datasec()); + sptr = sptr->nextSlice(); + } + } + + keyContext->updateClip(); + keyContext->updateContours(); + updateColorScale(); + + update(MATRIX); + updateMarkerCBs(&userMarkers); + updateMarkerCBs(&catalogMarkers); + // updateMarkerCBs(&analysisMarkers); +} + +void Frame3dBase::get3dBorderCmd() +{ + if (border_) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Frame3dBase::get3dBorderColorCmd() +{ + Tcl_AppendResult(interp, borderColorName_, NULL); +} + +void Frame3dBase::get3dCompassCmd() +{ + if (compass_) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Frame3dBase::get3dCompassColorCmd() +{ + Tcl_AppendResult(interp, compassColorName_, NULL); +} + +void Frame3dBase::get3dHighliteCmd() +{ + if (highlite_) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Frame3dBase::get3dHighliteColorCmd() +{ + Tcl_AppendResult(interp, highliteColorName_, NULL); +} + +void Frame3dBase::get3dRenderMethodCmd() +{ + ostringstream str; + switch (renderMethod_) { + case MIP: + str << "mip" << ends; + break; + case AIP: + str << "aip" << ends; + break; + } + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Frame3dBase::get3dScaleCmd() +{ + ostringstream str; + str << zscale_ << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Frame3dBase::get3dViewCmd() +{ + ostringstream str; + str << m180To180(radToDeg(az_)) << ' ' << m180To180(radToDeg(el_)) << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Frame3dBase::get3dViewPointCmd() +{ + ostringstream str; + str << vp_ << viewCursor_ << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Frame3dBase::get3dRenderBackgroundCmd() +{ + switch (render_) { + case NONE: + Tcl_AppendResult(interp, "none", NULL); + break; + case AZIMUTH: + Tcl_AppendResult(interp, "azimuth", NULL); + break; + case ELEVATION: + Tcl_AppendResult(interp, "elevation", NULL); + break; + } +} + +void Frame3dBase::getCursorCmd(Coord::InternalSystem sys) +{ + Vector aa = Vector(options->width,options->height)/2.; + Vector bb = mapToRef(aa,Coord::WIDGET); + + ostringstream str; + str << mapFromRef(bb, sys) << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Frame3dBase::getCursorCmd(Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + if (keyContext->fits) { + Vector aa = Vector(options->width,options->height)/2.; + Vector bb = mapToRef(aa,Coord::WIDGET); + printFromRef(keyContext->fits, bb, sys, sky, format); + } +} + +void Frame3dBase::gridCmd(Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, Grid::GridType type, + const char* ops, const char* vars) +{ + if (grid) + delete grid; + + switch (type) { + case Grid::ANALYSIS: + grid = new Grid25d(this, sys, sky, format, type, ops, vars); + break; + case Grid::PUBLICATION: + grid = new Grid3d(this, sys, sky, format, type, ops, vars); + break; + } + + update(PIXMAP); +} + +void Frame3dBase::panCmd(const Vector& v1, const Vector& v2) +{ + viewCursor_ -= (v1-v2)*Scale(1/zoom_[0],1/zoom_[1]); + update(MATRIX); +} + +void Frame3dBase::panCmd(const Vector& vv) +{ + viewCursor_ -= vv*Scale(1/zoom_[0],1/zoom_[1]); + update(MATRIX); +} + +void Frame3dBase::panCmd(const Vector& vv, Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + if (!keyContext->fits) + return; + + Vector cc = Vector(options->width,options->height)/2.; + Vector dd = mapToRef(cc,Coord::WIDGET); + Vector uu = keyContext->fits->mapFromRef(dd, sys, sky); + uu += vv; + Vector ee = keyContext->fits->mapToRef(uu, sys, sky); + Vector ff = mapFromRef(ee,Coord::WIDGET); + viewCursor_ += (cc-ff)*Scale(1/zoom_[0],1/zoom_[1]); + + update(MATRIX); +} + +void Frame3dBase::panToCmd(const Vector& vv) +{ + Vector dd = Vector(options->width,options->height)/2. - vv*canvasToWidget; + viewCursor_ += dd*Scale(1/zoom_[0],1/zoom_[1]); + + update(MATRIX); +} + +void Frame3dBase::panToCmd(const Vector& vv, Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + if (!keyContext->fits) + return; + + Vector aa = keyContext->fits->mapToRef(vv, sys, sky); + Vector dd = Vector(options->width,options->height)/2. - mapFromRef(aa,Coord::WIDGET); + viewCursor_ += dd*Scale(1/zoom_[0],1/zoom_[1]); + + update(MATRIX); +} + +void Frame3dBase::panBBoxCmd(const Vector& vv) +{ + // vv is center of panBBox in panner coordinate + Vector aa = vv*pannerToWidget3d; + Vector dd = Vector(options->width,options->height)/2. - aa; + viewCursor_ += dd*Scale(1/zoom_[0],1/zoom_[1]); + + update(MATRIX); +} + +void Frame3dBase::panEndCmd(const Vector& vv) +{ + if (panPM) + Tk_FreePixmap(display, panPM); + panPM = 0; + + Vector dd = vv*canvasToWidget - panCursor*canvasToWidget; + viewCursor_ += dd*Scale(1/zoom_[0],1/zoom_[1]); + + update(MATRIX); +} + +void Frame3dBase::rotateBeginCmd() +{ + // save the current rotation + rotateRotation = rotation; +} + +void Frame3dBase::rotateMotionCmd(double angle) +{ + rotation = rotateRotation + angle; + update(MATRIX); +} + +void Frame3dBase::rotateEndCmd() +{ + update(MATRIX); +} + +void Frame3dBase::set3dBorderCmd(int hh) +{ + border_ = hh; + update(PIXMAP); +} + +void Frame3dBase::set3dBorderColorCmd(const char* clr) +{ + if (borderColorName_) + delete [] borderColorName_; + borderColorName_ = dupstr(clr); + + if (threedGC) + XSetForeground(display, threedGC, getColor(borderColorName_)); + update(PIXMAP); +} + +void Frame3dBase::set3dCompassCmd(int hh) +{ + compass_ = hh; + update(PIXMAP); +} + +void Frame3dBase::set3dCompassColorCmd(const char* clr) +{ + if (compassColorName_) + delete [] compassColorName_; + compassColorName_ = dupstr(clr); + + if (threedGC) + XSetForeground(display, threedGC, getColor(compassColorName_)); + update(PIXMAP); +} + +void Frame3dBase::set3dHighliteCmd(int hh) +{ + highlite_ = hh; + update(PIXMAP); +} + +void Frame3dBase::set3dHighliteColorCmd(const char* clr) +{ + if (highliteColorName_) + delete [] highliteColorName_; + highliteColorName_ = dupstr(clr); + + if (threedGC) + XSetForeground(display, threedGC, getColor(highliteColorName_)); + update(PIXMAP); +} + +void Frame3dBase::set3dRenderMethodCmd(int m) +{ + RenderMethod mm = (RenderMethod)m; + if (mm!=renderMethod_) { + renderMethod_ = mm; + update(MATRIX); + } +} + +void Frame3dBase::set3dScaleCmd(double ss) +{ + if (zscale_ == ss) + return; + + zscale_ = ss; + // just in case if pending az/el + preservecache_ =0; + update(MATRIX); +} + +void Frame3dBase::set3dViewCmd(float az, float el) +{ + az_ = degToRad(az); + el_ = degToRad(el); + preservecache_ =1; + update(MATRIX); +} + +void Frame3dBase::set3dViewPointCmd(const Vector3d& vv, const Vector& cc) +{ + vp_ = vv; + viewCursor_ = cc; + update(MATRIX); +} + +void Frame3dBase::set3dRenderBackgroundCmd(int which) +{ + if (which != render_) { + render_ = (MotionType)which; + cancelDetach(); + preservecache_ =1; + update(BASE); + } +} + +void Frame3dBase::set3dPreserveCmd() +{ + preservecache_ =1; +} + +void Frame3dBase::zoomAboutCmd(const Vector& zz, const Vector& vv) +{ + Vector dd = Vector(options->width,options->height)/2. - vv*canvasToWidget; + viewCursor_ += dd*Scale(1/zoom_[0],1/zoom_[1]); + + Vector az = ((Vector&)zz).abs(); + zoom_[0] *= az[0]; + zoom_[1] *= az[1]; + + update(MATRIX); +} + +void Frame3dBase::zoomAboutCmd(const Vector& zz, const Vector& vv, + Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + if (!keyContext->fits) + return; + + Vector aa = keyContext->fits->mapToRef(vv, sys, sky); + Vector dd = Vector(options->width,options->height)/2. - mapFromRef(aa,Coord::WIDGET); + viewCursor_ += dd*Scale(1/zoom_[0],1/zoom_[1]); + + Vector az = ((Vector&)zz).abs(); + zoom_[0] *= az[0]; + zoom_[1] *= az[1]; + + update(MATRIX); +} + +void Frame3dBase::zoomToAboutCmd(const Vector& zz, const Vector& vv) +{ + Vector dd = Vector(options->width,options->height)/2. - vv*canvasToWidget; + viewCursor_ += dd*Scale(1/zoom_[0],1/zoom_[1]); + zoom_ = ((Vector&)zz).abs(); + + update(MATRIX); +} + +void Frame3dBase::zoomToAboutCmd(const Vector& zz, const Vector& vv, + Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + if (!keyContext->fits) + return; + + Vector aa = keyContext->fits->mapToRef(vv, sys, sky); + Vector dd = Vector(options->width,options->height)/2. - mapFromRef(aa,Coord::WIDGET); + viewCursor_ += dd*Scale(1/zoom_[0],1/zoom_[1]); + zoom_ = ((Vector&)zz).abs(); + + update(MATRIX); +} + +void Frame3dBase::zoomToFitCmd(double ss) +{ + if (!keyContext->fits) + return; + + centerImage(); + + Vector3d tt = imageSize3d(keyContext->secMode()); + double zz = calcZoom3d(tt,Vector(options->width,options->height)) * ss; + zoom_ = Vector(zz,zz); + + update(MATRIX); +} diff --git a/tksao/frame/fr3dmap.C b/tksao/frame/fr3dmap.C new file mode 100644 index 0000000..9c83d2d --- /dev/null +++ b/tksao/frame/fr3dmap.C @@ -0,0 +1,107 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "context.h" +#include "frame3dbase.h" +#include "fitsimage.h" + +Vector3d Frame3dBase::mapFromRef3d(const Vector& vv, Coord::InternalSystem sys) +{ + // context->slice() IMAGE (ranges 1-n) + double sl = keyContext->slice(2)-.5; + return mapFromRef3d(vv,sys,sl); +} + +Vector3d Frame3dBase::mapFromRef3d(const Vector& vv, Coord::InternalSystem sys, + double sl) +{ + // note: sl is in REF=DATA coordinates + Matrix3d mm; + switch (sys) { + case Coord::REF: + return Vector3d(vv,sl); + case Coord::USER: + mm = refToUser3d; + break; + case Coord::WIDGET: + mm = refToWidget3d; + break; + case Coord::CANVAS: + mm = refToCanvas3d; + break; + case Coord::WINDOW: + mm = refToWindow3d; + break; + case Coord::PANNER: + mm = refToPanner3d; + break; + case Coord::MAGNIFIER: + mm = refToMagnifier3d; + break; + default: + // na + break; + } + + return Vector3d(vv,sl)*mm; +} + +Vector3d Frame3dBase::mapToRef3d(const Vector& vv, Coord::InternalSystem sys) +{ + // context->slice() IMAGE (ranges 1-n) + double sl = keyContext->slice(2)-.5; + return mapToRef3d(vv,sys,sl); +} + +Vector3d Frame3dBase::mapToRef3d(const Vector& vv, Coord::InternalSystem sys, + double sl) +{ + switch (sys) { + case Coord::REF: + return Vector3d(vv,sl); + case Coord::USER: + return Vector3d(vv,sl)*userToRef3d; + default: + break; + } + + // note: sl is in REF=DATA coordinates + Vector3d xx = Vector3d(1,0,sl)*refToWidget3d; + Vector3d yy = Vector3d(0,1,sl)*refToWidget3d; + Vector3d zz = Vector3d(0,0,sl)*refToWidget3d; + + Vector3d ii=xx-zz; + Vector3d jj=yy-zz; + Vector3d nn = cross(jj,ii).normalize(); + double& a = nn[0]; + double& b = nn[1]; + double& c = nn[2]; + double d = -a*xx[0] -b*xx[1] -c*xx[2]; + + Vector ww; + switch (sys) { + case Coord::WIDGET: + ww = vv; + break; + case Coord::CANVAS: + ww = vv*canvasToWidget; + break; + case Coord::WINDOW: + ww = vv*windowToWidget; + break; + case Coord::PANNER: + ww = vv*pannerToWidget; + break; + case Coord::MAGNIFIER: + ww = vv*magnifierToWidget; + break; + default: + // na + break; + } + + double z = (-a*ww[0] -b*ww[1] -d)/c; + return Vector3d(ww,z)*widgetToRef3d; +} + diff --git a/tksao/frame/frame.C b/tksao/frame/frame.C new file mode 100644 index 0000000..dcd489d --- /dev/null +++ b/tksao/frame/frame.C @@ -0,0 +1,783 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "frame.h" +#include "fitsimage.h" +#include "ps.h" + +#include "sigbus.h" + +// Frame Member Functions + +Frame::Frame(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : FrameBase(i,c,item) +{ + context = new Context(); + context->parent(this); + + currentContext = context; + keyContext = context; + keyContextSet =1; + + colormapData =NULL; + + cmapID = 1; + bias = 0.5; + contrast = 1.0; + + colorCount = 0; + colorScale = NULL; + colorCells = NULL; +} + +Frame::~Frame() +{ + if (context) + delete context; + + if (colorScale) + delete colorScale; + + if (colorCells) + delete [] colorCells; + + if (colormapData) + delete [] colormapData; +} + +unsigned char* Frame::blend(unsigned char* src, unsigned char* msk, + int width, int height) +{ + unsigned char* sptr = src; // 3 component + unsigned char* mptr = msk; // 4 component, premultiplied + + for (int jj=0; jjred; + *ptr++ = (unsigned char)bgColor->green; + *ptr++ = (unsigned char)bgColor->blue; + } + } + + if (!context->cfits) + return img; + + // basics + int length = colorScale->size() - 1; + const unsigned char* table = colorScale->psColors(); + + FitsImage* sptr = context->cfits; + int mosaic = isMosaic(); + + // variable + double* mm = sptr->matrixToData(sys).mm(); + FitsBound* params = sptr->getDataParams(context->secMode()); + int srcw = sptr->width(); + + double ll = sptr->low(); + double hh = sptr->high(); + double diff = hh - ll; + + // main loop + unsigned char* dest = img; + + SETSIGBUS + for (long jj=0; jjcfits; + + mm = sptr->matrixToData(sys).mm(); + params = sptr->getDataParams(context->secMode()); + srcw = sptr->width(); + + ll = sptr->low(); + hh = sptr->high(); + diff = hh - ll; + } + + do { + double xx = ii*mm[0] + jj*mm[3] + mm[6]; + double yy = ii*mm[1] + jj*mm[4] + mm[7]; + + if (xx>=params->xmin && xxxmax && + yy>=params->ymin && yyymax) { + double value = sptr->getValueDouble(long(yy)*srcw + long(xx)); + + if (isfinite(diff) && isfinite(value)) { + if (value <= ll) { + *(dest+2) = table[0]; + *(dest+1) = table[1]; + *dest = table[2]; + } + else if (value >= hh) { + *(dest+2) = table[length*3]; + *(dest+1) = table[length*3+1]; + *dest = table[length*3+2]; + } + else { + int l = (int)(((value - ll)/diff * length) + .5); + *(dest+2) = table[l*3]; + *(dest+1) = table[l*3+1]; + *dest = table[l*3+2]; + } + } + else { + *(dest+2) = nanColor->blue; + *(dest+1) = nanColor->green; + *dest = nanColor->red; + } + + break; + } + else { + if (mosaic) { + sptr = sptr->nextMosaic(); + + if (sptr) { + mm = sptr->matrixToData(sys).mm(); + params = sptr->getDataParams(context->secMode()); + srcw = sptr->width(); + + ll = sptr->low(); + hh = sptr->high(); + diff = hh - ll; + } + } + } + } + while (mosaic && sptr); + } + } + CLEARSIGBUS + + if (img) { + if (context->mask.head()) { + FitsMask* mptr = context->mask.tail(); + while (mptr) { + unsigned char* msk = fillMask(mptr, width, height, sys); + blend(img,msk,width,height); + delete [] msk; + mptr = mptr->previous(); + } + } + } + + return img; +} + +unsigned char* Frame::fillMask(FitsMask* msk, int width, int height, + Coord::InternalSystem sys) +{ + FitsImage* currentMsk = msk->current(); + XColor* maskColor = msk->color(); + int mark = msk->mark(); + + // img + unsigned char* img = new unsigned char[width*height*4]; + memset(img,0,width*height*4); + + if (!currentMsk) + return img; + + // basics + FitsImage* sptr = currentMsk; + int mosaic = isMosaic(); + + // variable + double* mm = sptr->matrixToData(sys).mm(); + FitsBound* params = sptr->getDataParams(context->secMode()); + int srcw = sptr->width(); + + // main loop + unsigned char* dest = img; + + SETSIGBUS + for (long jj=0; jjmatrixToData(sys).mm(); + params = sptr->getDataParams(context->secMode()); + srcw = sptr->width(); + } + + do { + double xx = ii*mm[0] + jj*mm[3] + mm[6]; + double yy = ii*mm[1] + jj*mm[4] + mm[7]; + + if (xx>=params->xmin && xxxmax && + yy>=params->ymin && yyymax) { + int value = sptr->getValueMask(long(yy)*srcw + long(xx)); + + if ((mark && value) || (!mark && !value)) { + *dest = ((unsigned char)maskColor->red)*maskAlpha; + *(dest+1) = ((unsigned char)maskColor->green)*maskAlpha; + *(dest+2) = ((unsigned char)maskColor->blue)*maskAlpha; + *(dest+3) = 1; + } + + break; + } + else { + if (mosaic) { + sptr = sptr->nextMosaic(); + + if (sptr) { + mm = sptr->matrixToData(sys).mm(); + params = sptr->getDataParams(context->secMode()); + srcw = sptr->width(); + } + } + } + } + while (mosaic && sptr); + } + } + CLEARSIGBUS + + return img; +} + +int Frame::isIIS() +{ + return context->cfits && context->cfits->isIIS(); +} + +void Frame::pushMatrices() +{ + Base::pushMatrices(); + + // alway identity + Matrix rgbToRef; + + // now any masks + FitsMask* msk = currentContext->mask.tail(); + while (msk) { + FitsImage* mskimg = msk->mask(); + while (mskimg) { + FitsImage* sptr = mskimg; + while (sptr) { + sptr->updateMatrices(rgbToRef, refToUser, userToWidget, + widgetToCanvas, canvasToWindow); + sptr = sptr->nextSlice(); + } + mskimg = mskimg->nextMosaic(); + } + + msk = msk->previous(); + } +} + +void Frame::pushMagnifierMatrices() +{ + Base::pushMagnifierMatrices(); + + FitsMask* msk = context->mask.tail(); + while (msk) { + FitsImage* mskimg = msk->mask(); + while (mskimg) { + FitsImage* sptr = mskimg; + while (sptr) { + sptr->updateMagnifierMatrices(refToMagnifier); + sptr = sptr->nextSlice(); + } + mskimg = mskimg->nextMosaic(); + } + msk = msk->previous(); + } +} + +void Frame::pushPannerMatrices() +{ + Base::pushPannerMatrices(); + + FitsMask* msk = context->mask.tail(); + while (msk) { + FitsImage* mskimg = msk->mask(); + while (mskimg) { + FitsImage* sptr = mskimg; + while (sptr) { + sptr->updatePannerMatrices(refToPanner); + sptr = sptr->nextSlice(); + } + mskimg = mskimg->nextMosaic(); + } + msk = msk->previous(); + } +} + +void Frame::pushPSMatrices(float scale, int width, int height) +{ + Base::pushPSMatrices(scale, width, height); + + Matrix mx = psMatrix(scale, width, height); + FitsMask* msk = context->mask.tail(); + while (msk) { + FitsImage* ptr = msk->current(); + while (ptr) { + ptr->updatePS(mx); + ptr = ptr->nextMosaic(); + } + msk = msk->previous(); + } +} + +void Frame::reset() +{ + cmapID = 1; + bias = 0.5; + contrast = 1.0; + context->resetSecMode(); + context->updateClip(); + + Base::reset(); +} + +void Frame::updateColorCells(unsigned char* cells, int cnt) +{ + colorCount = cnt; + if (colorCells) + delete [] colorCells; + colorCells = new unsigned char[cnt*3]; + if (!colorCells) { + internalError("Unable to Alloc colorCells"); + return; + } + memcpy(colorCells, cells, cnt*3); +} + +void Frame::unloadFits() +{ + if (DebugPerf) + cerr << "Frame::unloadFits()" << endl; + + // clean up from iis if needed + if (isIIS()) + context->resetIIS(); + + context->unload(); + + FrameBase::unloadFits(); +} + +// Commands + +void Frame::colormapCmd(int id, float b, float c, int i, + unsigned char* cells, int cnt) +{ + cmapID = id; + bias = b; + contrast = c; + invert = i; + + updateColorCells(cells, cnt); + updateColorScale(); + update(BASE); +} + +void Frame::colormapBeginCmd() +{ + // we need a colorScale before we can render + if (!validColorScale()) + return; + + // we need some fits data + // we assume the colorScale length will not change during motion calls + if (!context->cfits) + return; + + int width = options->width; + int height = options->height; + + // Create XImage + if (!(colormapXM = XGetImage(display, pixmap, 0, 0, + width, height, AllPlanes, ZPixmap))) { + internalError("Unable to Create Colormap XImage"); + return; + } + + // Create Pixmap + colormapPM = + Tk_GetPixmap(display, Tk_WindowId(tkwin), width, height, depth); + if (!colormapPM) { + internalError("Unable to Create Colormap Pixmap"); + return; + } + + // colormapGCXOR + colormapGCXOR = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + + // Create table index array + if (colormapData) + delete [] colormapData; + colormapData = new long[width*height]; + if (!colormapData) { + internalError("Unable to alloc tmp data array"); + return; + } + + // fill data array + // basics + int bytesPerPixel = colormapXM->bits_per_pixel/8; + + int length = colorScale->size() - 1; + int last = length * bytesPerPixel; + + FitsImage* sptr = context->cfits; + int mosaic = isMosaic(); + + long* dest = colormapData; + + // variable + double* mm = sptr->matrixToData(Coord::WIDGET).mm(); + FitsBound* params = sptr->getDataParams(context->secMode()); + int srcw = sptr->width(); + + double ll = sptr->low(); + double hh = sptr->high(); + double diff = hh - ll; + + // main loop + + SETSIGBUS + for (long jj=0; jjcfits; + + mm = sptr->matrixToData(Coord::WIDGET).mm(); + params = sptr->getDataParams(context->secMode()); + srcw = sptr->width(); + + ll = sptr->low(); + hh = sptr->high(); + diff = hh - ll; + } + + do { + double xx = ii*mm[0] + jj*mm[3] + mm[6]; + double yy = ii*mm[1] + jj*mm[4] + mm[7]; + + if (xx>=params->xmin && xxxmax && + yy>=params->ymin && yyymax) { + double value = sptr->getValueDouble(long(yy)*srcw + long(xx)); + + if (isfinite(diff) && isfinite(value)) { + if (value <= ll) + *dest = 0; + else if (value >= hh) + *dest = last; + else + *dest = (int)(((value - ll)/diff * length) + .5)*bytesPerPixel; + } + else + *dest = -1; + + break; + } + else { + if (mosaic) { + sptr = sptr->nextMosaic(); + + if (sptr) { + mm = sptr->matrixToData(Coord::WIDGET).mm(); + params = sptr->getDataParams(context->secMode()); + srcw = sptr->width(); + + ll = sptr->low(); + hh = sptr->high(); + diff = hh - ll; + } + } + } + } + while (mosaic && sptr); + } + } + CLEARSIGBUS +} + +void Frame::colormapMotionCmd(int id, float b, float c, int i, + unsigned char* cells, int cnt) +{ + // we need a colorScale before we can render + if (!validColorScale()) + return; + + // first check for change + if (cmapID == id && bias == b && contrast == c && invert == i && colorCells) + return; + + // we got a change + cmapID = id; + bias = b; + contrast = c; + invert = i; + + updateColorCells(cells, cnt); + updateColorScale(); + + // if we have no data, stop now + if (!context->cfits) + return; + + // clear ximage + int& width = colormapXM->width; + int& height = colormapXM->height; + char* data = colormapXM->data; + int bytesPerPixel = colormapXM->bits_per_pixel/8; + int& bytesPerLine = colormapXM->bytes_per_line; + + const unsigned char* table = colorScale->colors(); + + long* src = colormapData; + for (long jj=0; jjsetIIS(); + + FitsImage* img = new FitsImageIIS(currentContext, interp, width, height); + + loadDone(currentContext->load(ALLOC, "", img, IMG),IMG); +} + +void Frame::iisEraseCmd() +{ + if (context->cfits) + ((FitsImageIIS*)context->cfits)->iisErase(); +} + +void Frame::iisGetCmd(char* dest, int xx, int yy, int dx, int dy) +{ + if (context->cfits) { + char* buf = ((FitsImageIIS*)context->cfits)->iisGet(xx,yy,dx,dy); + memcpy(dest, buf, dx*dy); + delete [] buf; + } +} + +void Frame::iisSetCmd(const char* src, int xx, int yy, int dx, int dy) +{ + if (context->cfits) + ((FitsImageIIS*)context->cfits)->iisSet(src, xx, yy, dx, dy); +} + +void Frame::iisWCSCmd(const Matrix& mx, const Vector& z, int zt) +{ + if (context->cfits) + ((FitsImageIIS*)context->cfits)->iisWCS(mx, z, zt); +} + +void Frame::savePhotoCmd(const char* ph) +{ + FitsImage* fits = currentContext->cfits; + if (!fits) + return; + + // basics + int length = colorScale->size() - 1; + const unsigned char* table = colorScale->psColors(); + + // variable + FitsBound* params = fits->getDataParams(context->secMode()); + double ll = fits->low(); + double hh = fits->high(); + double diff = hh - ll; + + int width = params->xmax - params->xmin; + int height = params->ymax - params->ymin; + + // photo + if (*ph == '\0') { + Tcl_AppendResult(interp, "bad image name ", NULL); + return; + } + Tk_PhotoHandle photo = Tk_FindPhoto(interp, ph); + if (!photo) { + Tcl_AppendResult(interp, "bad image handle ", NULL); + return; + } + if (Tk_PhotoSetSize(interp, photo, width, height) != TCL_OK) { + Tcl_AppendResult(interp, "bad photo set size ", NULL); + return; + } + Tk_PhotoBlank(photo); + Tk_PhotoImageBlock block; + if (!Tk_PhotoGetImage(photo,&block)) { + Tcl_AppendResult(interp, "bad image block ", NULL); + return; + } + + if (block.pixelSize<4) { + Tcl_AppendResult(interp, "bad pixel size ", NULL); + return; + } + + // main loop + SETSIGBUS + unsigned char* dest = block.pixelPtr; + for (long jj=params->ymax-1; jj>=params->ymin; jj--) { + for (long ii=params->xmin; iixmax; ii++, dest += block.pixelSize) { + double value = fits->getValueDouble(Vector(ii,jj)); + + if (isfinite(diff) && isfinite(value)) { + if (value <= ll) { + *(dest+block.offset[0]) = table[2]; + *(dest+block.offset[1]) = table[1]; + *(dest+block.offset[2]) = table[0]; + *(dest+block.offset[3]) = 255; + } + else if (value >= hh) { + *(dest+block.offset[0]) = table[length*3+2]; + *(dest+block.offset[1]) = table[length*3+1]; + *(dest+block.offset[2]) = table[length*3]; + *(dest+block.offset[3]) = 255; + } + else { + int l = (int)(((value - ll)/diff * length) + .5); + *(dest+block.offset[0]) = table[l*3+2]; + *(dest+block.offset[1]) = table[l*3+1]; + *(dest+block.offset[2]) = table[l*3]; + *(dest+block.offset[3]) = 255; + } + } + else { + *(dest+block.offset[0]) = nanColor->red; + *(dest+block.offset[1]) = nanColor->green; + *(dest+block.offset[2]) = nanColor->blue; + *(dest+block.offset[3]) = 255; + } + } + } + CLEARSIGBUS + + if (Tk_PhotoPutBlock(interp, photo, &block, 0, 0, width, height, + TK_PHOTO_COMPOSITE_SET) != TCL_OK) { + Tcl_AppendResult(interp, "bad put block ", NULL); + return; + } +} + + + diff --git a/tksao/frame/frame.h b/tksao/frame/frame.h new file mode 100644 index 0000000..6359530 --- /dev/null +++ b/tksao/frame/frame.h @@ -0,0 +1,69 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __frame_h__ +#define __frame_h__ + +#include "context.h" +#include "framebase.h" +#include "colorscale.h" + +// Frame + +class Frame : public FrameBase { + protected: + int cmapID; // current colormap id + float bias; // current colormap bias + float contrast; // current colormap contrast + + long* colormapData; + + int colorCount; // number of dynamic colors + ColorScale* colorScale; // current color scale + unsigned char* colorCells; // current color values + + private: + unsigned char* blend(unsigned char*, unsigned char*, int, int); + int isIIS(); + void pushMatrices(); + void pushMagnifierMatrices(); + void pushPannerMatrices(); + void pushPSMatrices(float, int, int); + void reset(); + void setKeyFits() {} + void unloadFits(); + + protected: + int isFrame() {return 1;} + + unsigned char* fillImage(int width, int height, Coord::InternalSystem); + unsigned char* fillMask(FitsMask*, int, int, Coord::InternalSystem); + int validColorScale() {return colorScale ? 1 : 0;} + void updateColorCells(unsigned char*, int); + + public: + Frame(Tcl_Interp*, Tk_Canvas, Tk_Item*); + virtual ~Frame(); + + void colormapCmd(int, float, float, int, unsigned char*, int); + void colormapBeginCmd(); + void colormapMotionCmd(int, float, float, int, unsigned char*, int); + void colormapEndCmd(); + + void getColorbarCmd(); + void getRGBChannelCmd(); + void getRGBViewCmd(); + void getRGBSystemCmd(); + void getTypeCmd(); + + void iisCmd(int, int); + void iisEraseCmd(); + void iisGetCmd(char*, int, int, int, int); + void iisSetCmd(const char*, int, int, int, int); + void iisWCSCmd(const Matrix&, const Vector&, int); + + void savePhotoCmd(const char*); +}; + +#endif diff --git a/tksao/frame/frame3d.C b/tksao/frame/frame3d.C new file mode 100644 index 0000000..de2a299 --- /dev/null +++ b/tksao/frame/frame3d.C @@ -0,0 +1,1329 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "frame3d.h" +#include "fitsimage.h" +#include "ps.h" +#include "sigbus.h" + +#ifndef __WIN32 +#include +#endif + +#ifndef __WIN32 +void render3dTimer(void* ptr) { + int rr = ((Frame3d*)ptr)->processDetach(); + if (rr) { + Tcl_TimerToken tt = Tcl_CreateTimerHandler(125,render3dTimer,ptr); + ((Frame3d*)ptr)->setTimer(tt); + } + else + ((Frame3d*)ptr)->setTimer(0); +} +#endif + +Frame3d::Frame3d(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : Frame3dBase(i,c,item) +{ + context = new Context(); + context->parent(this); + + currentContext = context; + keyContext = context; + keyContextSet =1; + + cmapID = 1; + bias = 0.5; + contrast = 1.0; + + colormapData = NULL; + + colorCount = 0; + colorScale = NULL; + colorCells = NULL; + +#ifndef __WIN32 + thread_ =NULL; +#endif + + targ_ =NULL; + status_ = 0; + nrays_ =0; + xid_ =NULL; + yid_ =NULL; + timer_ =0; + + rt_ =NULL; + rtb_ =NULL; + rtbcnt_ = 0; + + // scope is alway global + keyContext->setClipScope(FrScale::GLOBAL); +} + +Frame3d::~Frame3d() +{ + if (context) + delete context; + + if (colorScale) + delete colorScale; + + if (colormapData) + delete [] colormapData; + + if (colorCells) + delete [] colorCells; + +#ifndef __WIN32 + if (thread_) + delete [] thread_; +#endif + + if (targ_) + delete [] targ_; + + if (xid_) + delete [] xid_; + if (yid_) + delete [] yid_; + + if (rt_) + delete rt_; + if (rtb_) + delete rtb_; +} + +#ifdef __WIN32 + +unsigned char* Frame3d::fillImage(int width, int height, + Coord::InternalSystem sys) +{ + unsigned char* img =NULL; + Matrix3d mm = context->fits->matrixToData3d(sys); + + switch (sys) { + case Coord::WIDGET: + { + RayTrace* rt = findInCache(cache_, az_, el_); + if (!rt) { + BBox3d bb = imageBounds(width, height, mm); + rt = new RayTrace(az_, el_, width, height, mm, bb); + if (!fillImageJoin(rt)) + return NULL; + cacheIt(cache_, rt); + } + img = fillImageColor(rt); + } + break; + case Coord::PANNER: + { + RayTrace* rt = findInCache(pannerCache_, az_, el_); + if (!rt) { + BBox3d bb = imageBounds(width, height, mm); + rt = new RayTrace(az_, el_, width, height, mm, bb); + if (!fillImageJoin(rt)) + return NULL; + cacheIt(pannerCache_, rt); + } + img = fillImageColor(rt); + } + break; + case Coord::PS: + { + BBox3d bb = imageBounds(width, height, mm); + RayTrace* rt = new RayTrace(az_, el_, width, height, mm, bb); + if (!fillImageJoin(rt)) + return NULL; + img = fillImageColor(rt); + if (rt) + delete rt; + } + break; + default: + // na + break; + } + + return img; +} + +#else + +unsigned char* Frame3d::fillImage(int width, int height, + Coord::InternalSystem sys) +{ + unsigned char* img =NULL; + Matrix3d mm = context->fits->matrixToData3d(sys); + + switch (sys) { + case Coord::WIDGET: + if (syncUpdate) { + RayTrace* rt = findInCache(cache_, az_, el_); + if (!rt) { + BBox3d bb = imageBounds(width, height, mm); + rt = new RayTrace(az_, el_, width, height, mm, bb); + if (!fillImageJoin(rt)) + return NULL; + cacheIt(cache_, rt); + } + img = fillImageColor(rt); + } + else { + if (!rt_) { + RayTrace* ptr = findInCache(cache_, az_, el_); + if (ptr) { + img = fillImageColor(ptr); + + // start background + switch (render_) { + case NONE: + break; + case AZIMUTH: + case ELEVATION: + if (timer_) { + if (!status_) + status_ = 2; + } + else { + status_ = 2; + render3dTimer(this); + } + break; + } + } + else { + // just in case + if (thread_) + cancelDetach(); + + BBox3d bb = imageBounds(width, height, mm); + rt_ = new RayTrace(az_, el_, width, height, mm, bb); + + // are we very small? + if (bb.volume() < 1.25e7*nthreads_) { + // yes, just do it + if (!fillImageJoin(rt_)) + return NULL; + img = fillImageColor(rt_); + cacheIt(cache_, rt_); + rt_ =NULL; + + // start background + switch (render_) { + case NONE: + break; + case AZIMUTH: + case ELEVATION: + status_ = 2; + if (!timer_) + render3dTimer(this); + break; + } + } + else { + // ok, start the build process + fillImageDetach(rt_); + img = fillImageColor(rt_); + + // start primary + status_ = 1; + if (!timer_) + render3dTimer(this); + } + } + } + else + img = fillImageColor(rt_); + } + break; + case Coord::PANNER: + { + RayTrace* rt = findInCache(pannerCache_, az_, el_); + if (!rt) { + BBox3d bb = imageBounds(width, height, mm); + rt = new RayTrace(az_, el_, width, height, mm, bb); + if (!fillImageJoin(rt)) + return NULL; + cacheIt(pannerCache_, rt); + } + img = fillImageColor(rt); + } + break; + case Coord::PS: + { + BBox3d bb = imageBounds(width, height, mm); + RayTrace* rt = new RayTrace(az_, el_, width, height, mm, bb); + if (!fillImageJoin(rt)) + return NULL; + img = fillImageColor(rt); + if (rt) + delete rt; + } + break; + default: + // na + break; + } + + return img; +} + +#endif + +void* raytrace(void* arg) +{ + t_arg* targ = (t_arg*)arg; + Frame3dBase::RenderMethod renderMethod = targ->renderMethod; + int width = targ->width; + float* zbuf = targ->zbuf; + unsigned char* mkzbuf = targ->mkzbuf; + Context* context = targ->context; + + int* xid = targ->xid; + int* yid = targ->yid; + int start = targ->start; + int stop = targ->stop; + int zstart = targ->zstart; + int zstop = targ->zstop; + + // this will be incorrect for multiple ext/file cubes + int srcd = context->naxis(2); + double* mm = targ->matrix.mm(); + + FitsImage* ptr = context->fits; + + // if more than 3 axes, walk it forward + int num = context->calcSlice(); + for (int ii=1; iinextSlice(); + + // slice jump vector + FitsImage* sjv[srcd]; + FitsImage* sptr = ptr; + int ii=0; + while (sptr) { + sjv[ii++] = sptr; + if (sptr) + sptr = sptr->nextSlice(); + } + + FitsBound* params = context->fits->getDataParams(context->secMode()); + FitsZBound* zparams = context->getDataParams(context->secMode()); + int srcw = context->fits->width(); + + targ->rays =0; + for (int ll=start; ll<=stop; ll++, targ->rays++) { + int& jj = yid[ll]; + int& ii = xid[ll]; + + double ii0 = ii*mm[0]; + double ii1 = ii*mm[1]; + double ii2 = ii*mm[2]; + double jj4 = jj*mm[4]; + double jj5 = jj*mm[5]; + double jj6 = jj*mm[6]; + + int cnt=0; + float acc=0; + float max = -FLT_MAX; + + int kks = zstart; + int kkt = zstop; + + // good abort point + if (targ->abort) { + targ->done =1; + return 0; + } + + int inside =0; + for (int kk=kks; kk=params->xmin && xxxmax && + yy>=params->ymin && yyymax && + zz>=zparams->zmin && zzzmax) { + float value = sjv[int(zz)]->getValueDouble(long(yy)*srcw+long(xx)); + inside =1; + + // ignore nan + if (isfinite(value)) { + if (value>max) + max = value; + cnt++; + acc+=value; + } + } + else { + // early determination + if (inside) + break; + } + } + + if (cnt) { + float* dest = zbuf + jj*width + ii; + unsigned char* mkdest = mkzbuf + jj*width + ii; + + switch (renderMethod) { + case Frame3dBase::MIP: + *dest =max; + break; + case Frame3dBase::AIP: + *dest =acc/cnt; + break; + } + + *mkdest=1; + } + } + + targ->done=1; + return NULL; +} + +#ifdef __WIN32 + +int Frame3d::fillImageJoin(RayTrace* rt) +{ + BBox3d& bb = rt->bb_; + + Vector3d dd=bb.size(); + int ww = dd[0]; + int hh = dd[1]; + int zz = dd[2]; + + // sanity check + if (!ww || !hh || !zz) + return 1; + + // local var overide + int nrays = ww*hh; + int* xid = new int[nrays]; + int* yid = new int[nrays]; + int x=bb.ll[0]+.5; // don't know why; + int y=bb.ll[1]+.5; // don't know why + + // init array + for (int jj=0; jjwidth_; + targ.zbuf = rt->zbuf_; + targ.mkzbuf = rt->mkzbuf_; + targ.context = context; + + targ.matrix = rt->mm_; + + targ.xid = xid; + targ.yid = yid; + targ.start = 0; + targ.stop = nrays-1; + targ.zstart = bb.ll[2]; + targ.zstop = bb.ur[2]; + + targ.rays =0; + targ.abort =0; + targ.done =0; + + raytrace(&targ); + + if (xid) + delete [] xid; + if (yid) + delete [] yid; + + return 1; +} + +#else + +int Frame3d::fillImageJoin(RayTrace* rt) +{ + BBox3d& bb = rt->bb_; + + Vector3d dd=bb.size(); + int ww = dd[0]; + int hh = dd[1]; + int zz = dd[2]; + + // sanity check + if (!ww || !hh || !zz) + return 1; + + // local var overide + int nrays = ww*hh; + float incr = nrays/nthreads_; + int* xid = new int[nrays]; + int* yid = new int[nrays]; + int x=bb.ll[0]+.5; // don't know why; + int y=bb.ll[1]+.5; // don't know why + + // init array + for (int jj=0; jjwidth_; + targ[ii].zbuf = rt->zbuf_; + targ[ii].mkzbuf = rt->mkzbuf_; + targ[ii].context = context; + + targ[ii].matrix = rt->mm_; + + targ[ii].xid = xid; + targ[ii].yid = yid; + targ[ii].start = incr*ii; + if (ii+1bb_; + + Vector3d dd=bb.size(); + int ww = dd[0]; + int hh = dd[1]; + int zz = dd[2]; + + // sanity check + if (!ww || !hh || !zz) + return; + + nrays_ = ww*hh; + float incr = nrays_/nthreads_; + if (xid_) + delete [] xid_; + xid_ = new int[nrays_]; + if (yid_) + delete [] yid_; + yid_ = new int[nrays_]; + int x=bb.ll[0]+.5; // don't know why + int y=bb.ll[1]+.5; // don't know why + + // init array + for (int jj=0; jj0; kk--) { + int ll = rand() % (kk+1); // 0 <= ll <= kk + if (ll!=kk) { + int tx = xid_[kk]; + int ty = yid_[kk]; + xid_[kk]=xid_[ll]; + yid_[kk]=yid_[ll]; + xid_[ll]=tx; + yid_[ll]=ty; + } + } + + // init threads + thread_ = new pthread_t[nthreads_]; + targ_ = new t_arg[nthreads_]; + + for (int ii=0; iiwidth_; + targ_[ii].zbuf = rt->zbuf_; + targ_[ii].mkzbuf = rt->mkzbuf_; + targ_[ii].context = context; + + targ_[ii].matrix = rt->mm_; + + targ_[ii].xid = xid_; + targ_[ii].yid = yid_; + targ_[ii].start = incr*ii; + if (ii+1180) + org = org-360; + int cnt =1; + while (!((org+cnt)>180 && (org-cnt)<-180)) { + if ((org+cnt)<=180) + if (bkgDetach(degToRad(org+cnt),el_)) + return 1; + + if ((org-cnt)>=-180) + if (bkgDetach(degToRad(org-cnt),el_)) + return 1; + + cnt++; + } + } + break; + + case ELEVATION: + { + int org = floor(radToDeg(el_)); + if (org>180) + org = org-360; + int cnt =1; + while (!((org+cnt)>90 && (org-cnt)<-90)) { + if ((org+cnt)<=90) + if (bkgDetach(az_,degToRad(org+cnt))) + return 1; + + if ((org-cnt)>=-90) + if (bkgDetach(az_,degToRad(org-cnt))) + return 1; + + cnt++; + } + } + break; + } + + status_ = 0; + return 1; + } + + case 3: + // process background + { + if (!thread_) { + // cache + cacheIt(cache_, rtb_); + rtb_ =NULL; + + // and do the next one + status_ = 2; + } + else { + // we done yet? + int sum=0; + for (int ii=0; iiwidth/2.), (int)(options->height/2.), + (int)(zdepth_/2.)); + + Matrix3d refToWidget3d = refToUser3d * userToWidget3d; + Matrix3d mm = (context->fits->dataToRef3d * refToWidget3d).invert(); + BBox3d bb = imageBounds(options->width, options->height, mm); + + rtb_ = new RayTrace(az, el, options->width, options->height, mm, bb); + fillImageDetach(rtb_); + + status_ =3; + return 1; + } + + rtbcnt_++; + return 0; +} + +#endif + +void Frame3d::cacheIt(List& cache, RayTrace* rt) +{ + // hard coded + int max = (render_ == NONE) ? 256 : 361+181; + + if (rt) { + cache.append(rt); + if (cache.count() >= max) { + RayTrace* ptr = cache.fifo(); + if (ptr) + delete ptr; + } + } +} + +unsigned char* Frame3d::fillImageColor(RayTrace* rt) +{ + int width = rt->width_; + int height = rt->height_; + float* zbuf = rt->zbuf_; + unsigned char* mkzbuf = rt->mkzbuf_; + + unsigned char* img = new unsigned char[width*height*3]; + if (!img) + return NULL; + memset(img, 0, width*height*3); + + int length = colorScale->size() - 1; + const unsigned char* table = colorScale->psColors(); + + double ll = keyContext->fits->low(); + double hh = keyContext->fits->high(); + double diff = hh - ll; + + register unsigned char red = (unsigned char)bgColor->red; + register unsigned char green = (unsigned char)bgColor->green; + register unsigned char blue = (unsigned char)bgColor->blue; + + unsigned char* dest = img; + float* src = zbuf; + unsigned char* mksrc = mkzbuf; + + for (int jj=0; jj= hh) { + *(dest+2) = table[length*3]; + *(dest+1) = table[length*3+1]; + *dest = table[length*3+2]; + } + else { + int l = (int)(((value - ll)/diff * length) + .5); + *(dest+2) = table[l*3]; + *(dest+1) = table[l*3+1]; + *dest = table[l*3+2]; + } + } + } + } + } + + return img; +} + +RayTrace* Frame3d::findInCache(List& cache, double az, double el) +{ + double rr = degToRad(.5); + RayTrace* ptr = cache.head(); + while (ptr) { + double raz = ptr->az_ - az; + double rel = ptr->el_ - el; + if ((raz*raz + rel*rel) < rr*rr) + return ptr; + ptr=ptr->next(); + } + + return NULL; +} + +BBox3d Frame3d::imageBounds(int width, int height, Matrix3d mm) +{ + Matrix3d mx = mm.invert(); + + FitsBound* params = keyContext->fits->getDataParams(keyContext->secMode()); + FitsZBound* zparams = keyContext->getDataParams(keyContext->secMode()); + + // add a buffer around due to round off + int xmin = params->xmin -1; + int xmax = params->xmax +1; + int ymin = params->ymin -1; + int ymax = params->ymax +1; + int zmin = zparams->zmin -1; + int zmax = zparams->zmax +1; + + Vector3d llf = Vector3d(xmin,ymin,zmin) * mx; + Vector3d lrf = Vector3d(xmax,ymin,zmin) * mx; + Vector3d urf = Vector3d(xmax,ymax,zmin) * mx; + Vector3d ulf = Vector3d(xmin,ymax,zmin) * mx; + + Vector3d llb = Vector3d(xmin,ymin,zmax) * mx; + Vector3d lrb = Vector3d(xmax,ymin,zmax) * mx; + Vector3d urb = Vector3d(xmax,ymax,zmax) * mx; + Vector3d ulb = Vector3d(xmin,ymax,zmax) * mx; + + BBox3d bb(llf); + bb.bound(lrf); + bb.bound(urf); + bb.bound(ulf); + bb.bound(llb); + bb.bound(lrb); + bb.bound(urb); + bb.bound(ulb); + + if (bb.ll[0]<0) + bb.ll[0] = 0; + if (bb.ll[1]<0) + bb.ll[1] = 0; + + if (bb.ur[0]>width) + bb.ur[0] = width; + if (bb.ur[1]>height) + bb.ur[1] = height; + + // try to limit the z depth, sometime will fail + double zz0 = zdepth_; + double zz1 = 0; + for (int kk=zmin; kk<=zmax; kk++) { + // 4 corners + ibv3d(Vector3d(xmin,ymin,kk), mx, width, height, &zz0, &zz1); + ibv3d(Vector3d(xmax,ymin,kk), mx, width, height, &zz0, &zz1); + ibv3d(Vector3d(xmax,ymax,kk), mx, width, height, &zz0, &zz1); + ibv3d(Vector3d(xmin,ymax,kk), mx, width, height, &zz0, &zz1); + // center + ibv3d(Vector3d((xmax-xmin)/2.,(ymax-ymin)/2.,kk), mx, width, height, + &zz0, &zz1); + } + + if (zz0=0 && vv[0]<=ww && vv[1]>=0 && vv[1]<=hh) { + if (vv[2] < *zz0) + *zz0 = vv[2]; + if (vv[2] > *zz1) + *zz1 = vv[2]; + } +} + +void Frame3d::reset() +{ + cmapID = 1; + bias = 0.5; + contrast = 1.0; + keyContext->resetSecMode(); + keyContext->updateClip(); + + Base::reset(); +} + +void Frame3d::updateColorCells(unsigned char* cells, int cnt) +{ + colorCount = cnt; + if (colorCells) + delete [] colorCells; + colorCells = new unsigned char[cnt*3]; + if (!colorCells) { + internalError("Unable to Alloc colorCells"); + return; + } + memcpy(colorCells, cells, cnt*3); +} + +void Frame3d::pushMatrices() +{ + Base::pushMatrices(); + + FitsImage* ptr = keyContext->fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->updateMatrices(refToUser3d, userToWidget3d, widgetToCanvas3d, canvasToWindow3d); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } +} + +void Frame3d::pushPannerMatrices() +{ + Base::pushPannerMatrices(); + + FitsImage* ptr = keyContext->fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->updatePannerMatrices(refToPanner3d); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } +} + +void Frame3d::pushMagnifierMatrices() +{ + Base::pushMagnifierMatrices(); + + FitsImage* ptr = keyContext->fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->updateMagnifierMatrices(refToMagnifier3d); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } +} + +void Frame3d::pushPSMatrices(float scale, int width, int height) +{ + Base::pushPSMatrices(scale, width, height); + + Matrix3d mx = psMatrix(scale, width, height); + FitsImage* ptr = keyContext->fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->updatePS(mx); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } +} + +void Frame3d::unloadFits() +{ + if (DebugPerf) + cerr << "Frame3d::unloadFits()" << endl; + + // kill any active threads + cancelDetach(); + + keyContext->unload(); + + Base::unloadFits(); +} + +// Commands + +void Frame3d::colormapCmd(int id, float b, float c, int i, + unsigned char* cells, int cnt) +{ + cmapID = id; + bias = b; + contrast = c; + invert = i; + + updateColorCells(cells, cnt); + updateColorScale(); + update(BASE); +} + +void Frame3d::colormapEndCmd() +{ + update(BASE); +} + +void Frame3d::getColorbarCmd() +{ + ostringstream str; + str << cmapID << ' ' << bias << ' ' << contrast << ' ' << invert << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Frame3d::getRGBChannelCmd() +{ + Tcl_AppendResult(interp, "red", NULL); +} + +void Frame3d::getRGBViewCmd() +{ + Tcl_AppendResult(interp, "1 1 1", NULL); +} + +void Frame3d::getRGBSystemCmd() +{ + Tcl_AppendResult(interp, "image", NULL); +} + +void Frame3d::getTypeCmd() +{ + Tcl_AppendResult(interp, "3d", NULL); +} + +void Frame3d::savePhotoCmd(const char* ph) +{ + FitsImage* fits = currentContext->cfits; + if (!fits) + return; + + // basics + int length = colorScale->size() - 1; + const unsigned char* table = colorScale->psColors(); + + // variable + FitsBound* params = fits->getDataParams(context->secMode()); + double ll = fits->low(); + double hh = fits->high(); + double diff = hh - ll; + + int width = params->xmax - params->xmin; + int height = params->ymax - params->ymin; + + // photo + if (*ph == '\0') { + Tcl_AppendResult(interp, "bad image name ", NULL); + return; + } + Tk_PhotoHandle photo = Tk_FindPhoto(interp, ph); + if (!photo) { + Tcl_AppendResult(interp, "bad image handle ", NULL); + return; + } + if (Tk_PhotoSetSize(interp, photo, width, height) != TCL_OK) { + Tcl_AppendResult(interp, "bad photo set size ", NULL); + return; + } + Tk_PhotoBlank(photo); + Tk_PhotoImageBlock block; + if (!Tk_PhotoGetImage(photo,&block)) { + Tcl_AppendResult(interp, "bad image block ", NULL); + return; + } + + if (block.pixelSize<4) { + Tcl_AppendResult(interp, "bad pixel size ", NULL); + return; + } + + // main loop + SETSIGBUS + unsigned char* dest = block.pixelPtr; + for (long jj=params->ymax-1; jj>=params->ymin; jj--) { + for (long ii=params->xmin; iixmax; ii++, dest += block.pixelSize) { + double value = fits->getValueDouble(Vector(ii,jj)); + + if (isfinite(value)) { + if (value <= ll) { + *(dest+block.offset[0]) = table[2]; + *(dest+block.offset[1]) = table[1]; + *(dest+block.offset[2]) = table[0]; + *(dest+block.offset[3]) = 255; + } + else if (value >= hh) { + *(dest+block.offset[0]) = table[length*3+2]; + *(dest+block.offset[1]) = table[length*3+1]; + *(dest+block.offset[2]) = table[length*3]; + *(dest+block.offset[3]) = 255; + } + else { + int l = (int)(((value - ll)/diff * length) + .5); + *(dest+block.offset[0]) = table[l*3+2]; + *(dest+block.offset[1]) = table[l*3+1]; + *(dest+block.offset[2]) = table[l*3]; + *(dest+block.offset[3]) = 255; + } + } + else { + *(dest+block.offset[0]) = nanColor->red; + *(dest+block.offset[1]) = nanColor->green; + *(dest+block.offset[2]) = nanColor->blue; + *(dest+block.offset[3]) = 255; + } + } + } + CLEARSIGBUS + + if (Tk_PhotoPutBlock(interp, photo, &block, 0, 0, width, height, + TK_PHOTO_COMPOSITE_SET) != TCL_OK) { + Tcl_AppendResult(interp, "bad put block ", NULL); + return; + } +} diff --git a/tksao/frame/frame3d.h b/tksao/frame/frame3d.h new file mode 100644 index 0000000..9b97b42 --- /dev/null +++ b/tksao/frame/frame3d.h @@ -0,0 +1,119 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __frame3d_h__ +#define __frame3d_h__ + +#include "context.h" +#include "frame3dbase.h" +#include "colorscale.h" + +typedef struct { + Frame3dBase::RenderMethod renderMethod; + int width; + float* zbuf; + unsigned char* mkzbuf; + Context* context; + + Matrix3d matrix; + + int* xid; + int* yid; + int start; + int stop; + int zstart; + int zstop; + + int rays; + int abort; + int done; +} t_arg; + +class Frame3d : public Frame3dBase { + protected: + int cmapID; // current colormap id + float bias; // current colormap bias + float contrast; // current colormap contrast + + long* colormapData; + + int colorCount; // number of dynamic colors + ColorScale* colorScale; // current color scale + unsigned char* colorCells; // current color values + +#ifndef __WIN32 + pthread_t* thread_; +#endif + + int status_; + t_arg* targ_; + int nrays_; + int* xid_; + int* yid_; + Tcl_TimerToken timer_; + RayTrace* rt_; + RayTrace* rtb_; + int rtbcnt_; + + private: +#ifndef __WIN32 + void cancelDetach(); + void fillImageDetach(RayTrace*); + int bkgDetach(double az, double el); +#else + void cancelDetach() {} +#endif + + BBox3d imageBounds(int, int, Matrix3d); + void ibv3d(Vector3d, Matrix3d&, int, int, double*, double*); + int fillImageJoin(RayTrace*); + unsigned char* fillImageColor(RayTrace*); + RayTrace* findInCache(List&, double, double); + void cacheIt(List&, RayTrace*); + + void reset(); + + void setKeyFits() {} + + void pushMatrices(); + void pushMagnifierMatrices(); + void pushPannerMatrices(); + void pushPSMatrices(float, int, int); + + void unloadFits(); + + + protected: + int isFrame3d() {return 1;} + + unsigned char* fillImage(int width, int height, Coord::InternalSystem); + + void updateColorCells(unsigned char*, int); + int validColorScale() {return colorScale ? 1 : 0;} + + public: + Frame3d(Tcl_Interp*, Tk_Canvas, Tk_Item*); + virtual ~Frame3d(); + + void setTimer(Tcl_TimerToken tt) {timer_ = tt;} +#ifndef __WIN32 + int processDetach(); +#endif + + void getColorbarCmd(); + void getRGBChannelCmd(); + void getRGBSystemCmd(); + void getRGBViewCmd(); + void getTypeCmd(); + + void colormapCmd(int, float, float, int, unsigned char*, int); + void colormapEndCmd(); + void colormapMotionCmd(int id, float b, float c, int i, + unsigned char* cells, int cnt) + {colormapCmd(id, b, c, i, cells, cnt);} + + void savePhotoCmd(const char*); +}; + +#endif diff --git a/tksao/frame/frame3dbase.C b/tksao/frame/frame3dbase.C new file mode 100644 index 0000000..e1a599e --- /dev/null +++ b/tksao/frame/frame3dbase.C @@ -0,0 +1,1277 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "frame3dbase.h" +#include "fitsimage.h" +#include "marker.h" +#include "context.h" +#include "ps.h" + +Frame3dBase::Frame3dBase(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : Base(i, c, item) +{ + // zdepth_ =100000; + zdepth_ =200000; + zzoom_ =1; + zscale_ =1; + + az_ =0; + el_ =0; + renderMethod_ = MIP; + + preservecache_ =0; + render_ =NONE; + + threedGC = NULL; + + border_ =0; + borderColorName_ = dupstr("blue"); + compass_ =0; + compassColorName_ = dupstr("green"); + highlite_ =1; + highliteColorName_ = dupstr("cyan"); + + cropsl_ =0; + + imageToData3d = Translate3d(-.5, -.5, -.5); + dataToImage3d = Translate3d( .5, .5, .5); +} + +Frame3dBase::~Frame3dBase() +{ + if (threedGC) + XFreeGC(display, threedGC); + + if (borderColorName_) + delete [] borderColorName_; + if (compassColorName_) + delete [] compassColorName_; + if (highliteColorName_) + delete [] highliteColorName_; + + cache_.deleteAll(); + pannerCache_.deleteAll(); +} + + +void Frame3dBase::calcBorder(Coord::InternalSystem sys, FrScale::SecMode mode, + Vector3d* vv, int* dd) +{ + if (!keyContext->fits) + return; + + FitsBound* params = keyContext->fits->getDataParams(mode); + FitsZBound* zparams = keyContext->getDataParams(mode); + + Vector3d llf(params->xmin,params->ymin,zparams->zmin); + Vector3d lrf(params->xmax,params->ymin,zparams->zmin); + Vector3d urf(params->xmax,params->ymax,zparams->zmin); + Vector3d ulf(params->xmin,params->ymax,zparams->zmin); + + Vector3d llb(params->xmin,params->ymin,zparams->zmax); + Vector3d lrb(params->xmax,params->ymin,zparams->zmax); + Vector3d urb(params->xmax,params->ymax,zparams->zmax); + Vector3d ulb(params->xmin,params->ymax,zparams->zmax); + + Matrix3d& mm = keyContext->fits->matrixFromData3d(sys); + vv[0] = llf * mm; + vv[1] = lrf * mm; + vv[2] = urf * mm; + vv[3] = ulf * mm; + vv[4] = llb * mm; + vv[5] = lrb * mm; + vv[6] = urb * mm; + vv[7] = ulb * mm; + + // init for dash + for (int ii=0; ii<12; ii++) + dd[ii] =1; + + // front + { + Vector3d aa = vv[1]-vv[0]; + Vector3d cc = vv[3]-vv[0]; + Vector3d ff = cross(aa,cc); + for (int ii=0; ii<4; ii++) + dd[ii] &= ff[2]>0; + } + + // right + { + Vector3d aa = vv[5]-vv[1]; + Vector3d cc = vv[2]-vv[1]; + Vector3d ff = cross(aa,cc); + int ww = ff[2]>0; + dd[1] &= ww; + dd[9] &= ww; + dd[5] &= ww; + dd[10] &= ww; + } + + // top + { + Vector3d aa = vv[6]-vv[2]; + Vector3d cc = vv[3]-vv[2]; + Vector3d ff = cross(aa,cc); + int ww = ff[2]>0; + dd[2] &= ww; + dd[10] &= ww; + dd[6] &= ww; + dd[11] &= ww; + } + + // left + { + Vector3d aa = vv[7]-vv[3]; + Vector3d cc = vv[0]-vv[3]; + Vector3d ff = cross(aa,cc); + int ww = ff[2]>0; + dd[3] &= ww; + dd[8] &= ww; + dd[7] &= ww; + dd[11] &= ww; + } + + // bottom + { + Vector3d aa = vv[4]-vv[0]; + Vector3d cc = vv[1]-vv[0]; + Vector3d ff = cross(aa,cc); + int ww = ff[2]>0; + dd[0] &= ww; + dd[9] &= ww; + dd[4] &= ww; + dd[8] &= ww; + } + + // back + { + Vector3d aa = vv[4]-vv[5]; + Vector3d cc = vv[6]-vv[5]; + Vector3d ff = cross(aa,cc); + for (int ii=4; ii<8; ii++) + dd[ii] &= ff[2]>0; + } +} + +void Frame3dBase::calcHighlite(Coord::InternalSystem sys, Vector* vv, int* rr) +{ + if (!keyContext->fits) + return; + + FitsBound* params = keyContext->fits->getDataParams(keyContext->secMode()); + Vector ss(params->xmin,params->ymin); + Vector tt(params->xmax,params->ymax); + + Vector ll = mapFromRef3d(ss,sys); + Vector lr = mapFromRef3d(Vector(tt[0],ss[1]),sys); + Vector ur = mapFromRef3d(tt,sys); + Vector ul = mapFromRef3d(Vector(ss[0],tt[1]),sys); + + // context->slice() IMAGE (ranges 1-n) + double sl = keyContext->slice(2)-.5; + Vector3d ll1 = mapFromRef3d(ss,sys); + Vector3d lr1 = mapFromRef3d(Vector(tt[0],ss[1]),sys); + Vector3d ur1 = mapFromRef3d(tt,sys); + Vector3d ul1 = mapFromRef3d(Vector3d(ss[0],tt[1]),sys); + Vector3d ll0 = mapFromRef3d(ss,sys,sl-1); + Vector3d lr0 = mapFromRef3d(Vector3d(tt[0],ss[1]),sys,sl-1); + Vector3d ur0 = mapFromRef3d(tt,sys,sl-1); + Vector3d ul0 = mapFromRef3d(Vector3d(ss[0],tt[1]),sys,sl-1); + + Vector3d aa1 = (ll0-ll1).normalize(); + Vector3d aa2 = (lr0-lr1).normalize(); + Vector3d aa3 = (ur0-ur1).normalize(); + Vector3d aa4 = (ul0-ul1).normalize(); + Vector3d bb1 = (lr1-ll1).normalize(); + Vector3d bb2 = (ur1-lr1).normalize(); + Vector3d bb3 = (ul1-ur1).normalize(); + Vector3d bb4 = (ll1-ul1).normalize(); + + Vector3d cc1 = cross(bb1,aa1); + Vector3d cc2 = cross(bb2,aa2); + Vector3d cc3 = cross(bb3,aa3); + Vector3d cc4 = cross(bb4,aa4); + + vv[0] = ll; + vv[1] = lr; + vv[2] = ur; + vv[3] = ul; + + rr[0] = cc1[2]>0; + rr[1] = cc2[2]>0; + rr[2] = cc3[2]>0; + rr[3] = cc4[2]>0; +} + +double Frame3dBase::calcZoom3d(Vector3d src, Vector dest) +{ + Vector3d cc = src/2.; + + Vector3d llf(0,0,0); + Vector3d lrf(0,src[1],0); + Vector3d urf(src[0],src[1],0); + Vector3d ulf(src[0],0,0); + + Vector3d llb(0,0,src[2]); + Vector3d lrb(0,src[1],src[2]); + Vector3d urb(src[0],src[1],src[2]); + Vector3d ulb(src[0],0,src[2]); + + Matrix3d mx = + Translate3d(-cc) * + RotateZ3d(-wcsRotation) * + RotateZ3d(-rotation) * + RotateY3d(az_) * + RotateX3d(el_); + + BBox3d bb(llf*mx); + bb.bound(lrf*mx); + bb.bound(urf*mx); + bb.bound(ulf*mx); + bb.bound(llb*mx); + bb.bound(lrb*mx); + bb.bound(urb*mx); + bb.bound(ulb*mx); + + Vector3d bs = bb.size(); + double r0 = dest[0]/bs[0]; + double r1 = dest[1]/bs[1]; + + return r0>r1 ? r1:r0; +} + +double Frame3dBase::calcZoomPanner() +{ + if (!keyContext->fits) + return 1; + + if (!pannerPixmap) + return 1; + + Vector3d src = imageSize3d(keyContext->datasec() ? FrScale::DATASEC : FrScale::IMGSEC) * Scale3d(1,zscale_); + Vector dest(pannerWidth,pannerHeight); + + Vector3d cc = src/2.; + + Vector3d llf = Vector3d(0,0,0); + Vector3d lrf = Vector3d(0,src[1],0); + Vector3d urf = Vector3d(src[0],src[1],0); + Vector3d ulf = Vector3d(src[0],0,0); + + Vector3d llb = Vector3d(0,0,src[2]); + Vector3d lrb = Vector3d(0,src[1],src[2]); + Vector3d urb = Vector3d(src[0],src[1],src[2]); + Vector3d ulb = Vector3d(src[0],0,src[2]); + + BBox3d bb; + + // 0, 0 + Matrix3d m0000 = + Translate3d(-cc) * + RotateY3d(degToRad(0)) * + RotateX3d(degToRad(0)); + bb.bound(llf*m0000); + bb.bound(llf*m0000); + bb.bound(lrf*m0000); + bb.bound(urf*m0000); + bb.bound(ulf*m0000); + bb.bound(llb*m0000); + bb.bound(lrb*m0000); + bb.bound(urb*m0000); + bb.bound(ulb*m0000); + + // 0, 90 + Matrix3d m0090 = + Translate3d(-cc) * + RotateY3d(degToRad(90)) * + RotateX3d(degToRad(0)); + bb.bound(llf*m0090); + bb.bound(llf*m0090); + bb.bound(lrf*m0090); + bb.bound(urf*m0090); + bb.bound(ulf*m0090); + bb.bound(llb*m0090); + bb.bound(lrb*m0090); + bb.bound(urb*m0090); + bb.bound(ulb*m0090); + + // 90, 0 + Matrix3d m9000 = + Translate3d(-cc) * + RotateY3d(degToRad(0)) * + RotateX3d(-degToRad(90)); + bb.bound(llf*m9000); + bb.bound(llf*m9000); + bb.bound(lrf*m9000); + bb.bound(urf*m9000); + bb.bound(ulf*m9000); + bb.bound(llb*m9000); + bb.bound(lrb*m9000); + bb.bound(urb*m9000); + bb.bound(ulb*m9000); + + // 45, 45 + Matrix3d m4545 = + Translate3d(-cc) * + RotateY3d(degToRad(45)) * + RotateX3d(-degToRad(45)); + bb.bound(llf*m4545); + bb.bound(llf*m4545); + bb.bound(lrf*m4545); + bb.bound(urf*m4545); + bb.bound(ulf*m4545); + bb.bound(llb*m4545); + bb.bound(lrb*m4545); + bb.bound(urb*m4545); + bb.bound(ulb*m4545); + + // 45, 90 + Matrix3d m4590 = + Translate3d(-cc) * + RotateY3d(degToRad(90)) * + RotateX3d(-degToRad(45)); + bb.bound(llf*m4590); + bb.bound(lrf*m4590); + bb.bound(urf*m4590); + bb.bound(ulf*m4590); + bb.bound(llb*m4590); + bb.bound(lrb*m4590); + bb.bound(urb*m4590); + bb.bound(ulb*m4590); + + // 90, 45 + Matrix3d m9045 = + Translate3d(-cc) * + RotateY3d(degToRad(45)) * + RotateX3d(-degToRad(90)); + bb.bound(llf*m9045); + bb.bound(lrf*m9045); + bb.bound(urf*m9045); + bb.bound(ulf*m9045); + bb.bound(llb*m9045); + bb.bound(lrb*m9045); + bb.bound(urb*m9045); + bb.bound(ulb*m9045); + + Vector3d bs = bb.size(); + double ll = bs[0] > bs[1] ? bs[0] : bs[1]; + double mm = dest[0] > dest[1] ? dest[0] : dest[1]; + + return 1/ll*mm; +} + +void Frame3dBase::centerImage() +{ + Base::centerImage(); + + viewCursor_ = Vector(); + if (keyContext->fits) { + // imageCenter is in IMAGE coords + Vector3d aa = imageCenter3d(keyContext->secMode()); + // always center to center of pixel, even for even sized image + Vector3d bb = (aa*Translate3d(.5,.5,.5)).floor(); + // vp_ is in REF coords + vp_ = bb*imageToData3d; + } + else + vp_ = Vector(); +} + +Vector3d Frame3dBase::imageCenter3d(FrScale::SecMode mode) +{ + if (!keyContext->fits) + return Vector3d(); + + // params is a BBOX in DATA coords 0-n + FitsBound* pp = keyContext->fits->getDataParams(mode); + FitsZBound* zz = keyContext->getDataParams(mode); + + // Note: imageCenter() is in IMAGE coords + return Vector3d((pp->xmax - pp->xmin)/2.+pp->xmin, + (pp->ymax - pp->ymin)/2.+pp->ymin, + (zz->zmax - zz->zmin)/2.+zz->zmin) * dataToImage3d; +} + +Vector3d Frame3dBase::imageSize3d(FrScale::SecMode mode ) +{ + if (!keyContext->fits) + return Vector3d(); + + // params is a BBOX in DATA coords 0-n + FitsBound* params = keyContext->fits->getDataParams(mode); + FitsZBound* zparams = keyContext->getDataParams(mode); + + // return in IMAGE coords and extends edge to edge + return Vector3d(params->xmax-params->xmin, params->ymax-params->ymin, + zparams->zmax-zparams->zmin); +} + +void Frame3dBase::psColor(PSColorSpace mode, const char* color) +{ + ostringstream str; + switch (mode) { + case BW: + case GRAY: + psColorGray(getXColor(color), str); + str << " setgray"; + break; + case RGB: + psColorRGB(getXColor(color), str); + str << " setrgbcolor"; + break; + case CMYK: + psColorCMYK(getXColor(color), str); + str << " setcmykcolor"; + break; + } + str << endl << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Frame3dBase::psLine(Vector& ss, Vector& tt, int dd) +{ + ostringstream str; + if (dd) + str << '[' << dlist[0] << ' ' << dlist[1] << "] 0 setdash" << endl; + else + str << "[] 0 setdash" << endl; + + str << "newpath " + << ss.TkCanvasPs(canvas) << " moveto" << endl + << tt.TkCanvasPs(canvas) << " lineto stroke" << endl << ends; + + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Frame3dBase::psWidth(int dd) +{ + ostringstream str; + str << dd << " setlinewidth" << endl << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Frame3dBase::psGraphics(PSColorSpace mode) +{ + if (!keyContext->fits) + return; + + if (border_) + psBorder(mode); + if (compass_) + psCompass(mode); + if (highlite_) + psHighlite(mode); +} + +void Frame3dBase::psBorder(PSColorSpace mode) +{ + Vector3d vv[8]; + int dd[12]; + calcBorder(Coord::WIDGET, keyContext->secMode(), vv, dd); + + Vector uu[8]; + for (int ii=0; ii<8; ii++) + uu[ii] = Vector(vv[ii])*widgetToCanvas; + + psColor(mode, borderColorName_); + psWidth(1); + + // front + psLine(uu[0],uu[1],dd[0]); + psLine(uu[1],uu[2],dd[1]); + psLine(uu[2],uu[3],dd[2]); + psLine(uu[3],uu[0],dd[3]); + + // back + psLine(uu[4],uu[5],dd[4]); + psLine(uu[5],uu[6],dd[5]); + psLine(uu[6],uu[7],dd[6]); + psLine(uu[7],uu[4],dd[7]); + + // other + psLine(uu[0],uu[4],dd[8]); + psLine(uu[1],uu[5],dd[9]); + psLine(uu[2],uu[6],dd[10]); + psLine(uu[3],uu[7],dd[11]); +} + +void Frame3dBase::psCompass(PSColorSpace mode) +{ + Matrix3d& mm = keyContext->fits->dataToWidget3d; + + double ss = 100./(zoom_[0]+zoom_[1]); + + Vector3d oo = vp_*mm; + Vector3d xx = Vector3d(1,0,0) * Scale3d(ss) * Translate3d(vp_) * mm; + Vector3d yy = Vector3d(0,1,0) * Scale3d(ss) * Translate3d(vp_) * mm; + Vector3d zz = Vector3d(0,0,1) * Scale3d(ss) * Translate3d(vp_) * mm; + + Vector o = Vector(oo)*widgetToCanvas; + Vector x = Vector(xx)*widgetToCanvas; + Vector y = Vector(yy)*widgetToCanvas; + Vector z = Vector(zz)*widgetToCanvas; + + psColor(mode, compassColorName_); + psWidth(1); + + psLine(o,x,0); + psLine(o,y,0); + psLine(o,z,0); +} + +void Frame3dBase::psHighlite(PSColorSpace mode) +{ + Vector vv[4]; + int rr[4]; + calcHighlite(Coord::CANVAS,vv,rr); + + psColor(mode, highliteColorName_); + psWidth(1); + psLine(vv[0],vv[1],rr[0]); + psLine(vv[1],vv[2],rr[1]); + psLine(vv[2],vv[3],rr[2]); + psLine(vv[3],vv[0],rr[3]); +} + +Matrix3d Frame3dBase::psMatrix(float scale, int width, int height) +{ + Matrix3d userToPS3d = + Matrix3d(wcsOrientationMatrix) * + Matrix3d(orientationMatrix) * + RotateZ3d(-wcsRotation) * + RotateZ3d(-rotation) * + + RotateY3d(az_) * + RotateX3d(el_) * + + Translate3d(viewCursor_) * + Scale3d(zoom_, zzoom_) * + Scale3d(scale,1) * + + FlipY3d() * + Translate3d(width/2., height/2., zdepth_/2.); + + return refToUser3d*userToPS3d; +} + +void Frame3dBase::setSlice(int id, int ss) +{ + // IMAGE (ranges 1-n) + currentContext->updateSlice(id, ss); + + if (id==2) { + currentContext->updateContours(); + update(BASEONLY); + } + else { + // load the next cube + currentContext->updateClip(); + currentContext->updateContoursScale(); + updateColorScale(); + update(MATRIX); + } + + Base::setSlice(id,ss); +} + +void Frame3dBase::updateBin(const Matrix& mx) +{ + centerImage(); + Base::updateBin(mx); +} + +void Frame3dBase::updateBlock(const Vector& vv) +{ + centerImage(); + Base::updateBlock(vv); +} + +void Frame3dBase::updateGCs() +{ + Base::updateGCs(); + + // widget clip region + BBox bbWidget = BBox(0, 0, options->width, options->height); + Vector sizeWidget = bbWidget.size(); + + rectWidget[0].x = (int)bbWidget.ll[0]; + rectWidget[0].y = (int)bbWidget.ll[1]; + rectWidget[0].width = (int)sizeWidget[0]; + rectWidget[0].height = (int)sizeWidget[1]; + +// window clip region + BBox bbWindow = bbWidget * widgetToWindow; + Vector sizeWindow = bbWindow.size(); + + rectWindow[0].x = (int)bbWindow.ll[0]; + rectWindow[0].y = (int)bbWindow.ll[1]; + rectWindow[0].width = (int)sizeWindow[0]; + rectWindow[0].height = (int)sizeWindow[1]; + + // 3d highlite + if (!threedGC) { + threedGC = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + XSetLineAttributes(display, threedGC, 1, LineSolid, CapButt, JoinMiter); + } + XSetClipRectangles(display, threedGC, 0, 0, rectWidget, 1, Unsorted); +} + +void Frame3dBase::updateMatrices() +{ + if (DebugPerf) + cerr << "Frame3dBase::updateMatrices()..." << endl; + + zzoom_ = (zoom_[0]+zoom_[1])/2.; + if (zzoom_<1) + zzoom_ = 1; + + // if othogonal, reset zzoom + if ((teq(az_,0,.001) || + teq(fabs(az_),M_PI_2,.001) || + teq(fabs(az_),M_PI,.001)) && + (teq(el_,0,.001) || + teq(fabs(el_),M_PI_2,.001))) + zzoom_ =1; + + // These are the basic tranformation matrices + // Note: imageCenter() is in IMAGE coords + refToUser3d = + Translate3d(-vp_) * + Scale3d(1,zscale_) * + FlipY3d(); + userToRef3d = refToUser3d.invert(); + + // userToWidget3d + userToWidget3d = + Matrix3d(wcsOrientationMatrix) * + Matrix3d(orientationMatrix) * + RotateZ3d(-wcsRotation) * + RotateZ3d(-rotation) * + + RotateY3d(az_) * + RotateX3d(el_) * + + Translate3d(viewCursor_) * + Scale3d(zoom_, zzoom_) * + + // must be int to align with screen pixels + Translate3d((int)(options->width/2.), (int)(options->height/2.), + (int)(zdepth_/2.)); + widgetToUser3d = userToWidget3d.invert(); + + // widgetToCanvas + widgetToCanvas3d = Translate3d(originX, originY, 0); + canvasToWidget3d = widgetToCanvas3d.invert(); + + // canvasToWindow + short xx, yy; + Tk_CanvasWindowCoords(canvas, 0, 0, &xx, &yy); + canvasToWindow3d = Translate3d(xx, yy, 0); + windowToCanvas3d = canvasToWindow3d.invert(); + + // These are derived Transformation Matrices + refToWidget3d = refToUser3d * userToWidget3d; + widgetToRef3d = refToWidget3d.invert(); + + refToCanvas3d = refToWidget3d * widgetToCanvas3d; + canvasToRef3d = refToCanvas3d.invert(); + + refToWindow3d = refToCanvas3d * canvasToWindow3d; + windowToRef3d = refToWindow3d.invert(); + + userToCanvas3d = userToWidget3d * widgetToCanvas3d; + canvasToUser3d = userToCanvas3d.invert(); + + userToWindow3d = userToCanvas3d * canvasToWindow3d; + windowToUser3d = userToWindow3d.invert(); + + widgetToWindow3d = widgetToCanvas3d * canvasToWindow3d; + windowToWidget3d = widgetToWindow3d.invert(); + + Base::updateMatrices(); + + // delete current zbuffer since matrices have changed + cancelDetach(); + + // preserve cache? + if (!preservecache_) { + cache_.deleteAll(); + pannerCache_.deleteAll(); + } + preservecache_ =0; + + if (DebugPerf) + cerr << "updateMatrices end" << endl; +} + +void Frame3dBase::updateMagnifierMatrices() +{ + // vv is in CANVAS coords + Vector ww = magnifierCursor*canvasToRef; + + // refToUser3d + Matrix3d refToUser3d = Translate3d(Vector3d(-ww,-vp_[2])) * FlipY3d(); + + // userToMagnifier + userToMagnifier3d = + Matrix3d(wcsOrientationMatrix) * + Matrix3d(orientationMatrix) * + RotateZ3d(-wcsRotation) * + RotateZ3d(-rotation) * + + RotateY3d(az_) * + RotateX3d(el_) * + + Translate3d(viewCursor_) * + Scale3d(zoom_, zzoom_) * + Scale3d(magnifierZoom_,magnifierZoom_) * + + Translate3d((int)(magnifierWidth/2.), (int)(magnifierHeight/2.), + (int)(zdepth_/2.)); + magnifierToUser3d = userToMagnifier3d.invert(); + + refToMagnifier3d = refToUser3d * userToMagnifier3d; + magnifierToRef3d = refToMagnifier3d.invert(); + + magnifierToWidget3d = magnifierToRef3d * refToWidget3d; + widgetToMagnifier3d = magnifierToWidget3d.invert(); + + Base::updateMagnifierMatrices(); +} + +void Frame3dBase::updatePannerMatrices() +{ + Vector3d center = imageCenter3d(FrScale::IMGSEC) * imageToData3d; + + // refToUser3d + Matrix3d refToUser3d = + Translate3d(-center) * + Scale3d(1,zscale_) * + FlipY3d(); + + // userToPanner3d + double pz = calcZoomPanner(); + double zz = zzoom_*pz; + if (zz<1) + zz =1; + + userToPanner3d = + Matrix3d(wcsOrientationMatrix) * + Matrix3d(orientationMatrix) * + RotateZ3d(-wcsRotation) * + RotateZ3d(-rotation) * + + RotateY3d(az_) * + RotateX3d(el_) * + + Scale3d(pz, zz) * + + Translate3d((int)(pannerWidth/2.), (int)(pannerHeight/2.), + (int)(zdepth_/2.)); + pannerToUser3d = userToPanner3d.invert(); + + refToPanner3d = refToUser3d * userToPanner3d; + pannerToRef3d = refToPanner3d.invert(); + + pannerToWidget3d = pannerToRef3d * refToWidget3d; + widgetToPanner3d = pannerToWidget3d.invert(); + + Base::updatePannerMatrices(); +} + +void Frame3dBase::updatePanner() +{ + // do this first + Base::updatePanner(); + + // always render (to update panner background color) + if (usePanner) { + if (keyContext->fits) { + XSetForeground(display, pannerGC, getColor("black")); + x11Border(Coord::PANNER,FrScale::IMGSEC,pannerGC,pannerPixmap); + } + + ostringstream str; + str << pannerName << " update " << (void*)pannerPixmap << ';'; + + // calculate bbox + Vector ll = Vector(0,0) * widgetToPanner3d; + Vector lr = Vector(options->width,0) * widgetToPanner3d; + Vector ur = Vector(options->width,options->height) * widgetToPanner3d; + Vector ul = Vector(0,options->height) * widgetToPanner3d; + + str << pannerName << " update bbox " + << ll << ' ' << lr << ' ' << ur << ' ' << ul << ';'; + + // calculate image compass vectors + Matrix3d mm = + Matrix3d(wcsOrientationMatrix) * + Matrix3d(orientationMatrix) * + RotateZ3d(wcsRotation) * + RotateZ3d(rotation) * + RotateY3d(az_) * + RotateX3d(-el_) * + FlipY3d(); + + Vector xx = (Vector3d(1,0,0)*mm).normalize(); + Vector yy = (Vector3d(0,1,0)*mm).normalize(); + Vector zz = (Vector3d(0,0,1)*mm).normalize(); + + str << pannerName << " update image compass " + << xx << ' ' << yy << ' ' << zz << ';'; + + if (keyContext->fits && keyContext->fits->hasWCS(wcsSystem_)) { + Vector orpix = keyContext->fits->center(); + Vector orval=keyContext->fits->pix2wcs(orpix, wcsSystem_, wcsSky_); + Vector orpix2 = keyContext->fits->wcs2pix(orval, wcsSystem_,wcsSky_); + Vector delta = keyContext->fits->getWCScdelt(wcsSystem_).abs(); + + // find normalized north + Vector npix = keyContext->fits->wcs2pix(Vector(orval[0],orval[1]+delta[1]), wcsSystem_,wcsSky_); + Vector north = (Vector3d(npix-orpix2)*mm).normalize(); + + // find normalized east + Vector epix = keyContext->fits->wcs2pix(Vector(orval[0]+delta[0],orval[1]), wcsSystem_,wcsSky_); + Vector east = (Vector3d(epix-orpix2)*mm).normalize(); + + // sanity check + Vector diff = (north-east).abs(); + if ((north[0]==0 && north[1]==0) || + (east[0]==0 && east[1]==0) || + (diff[0]<.01 && diff[1]<.01)) { + north = (Vector3d(0,1)*mm).normalize(); + east = (Vector3d(-1,0)*mm).normalize(); + } + + // and update the panner + str << pannerName << " update wcs compass " + << north << ' ' << east << ends; + } + else + str << pannerName << " update wcs compass invalid" << ends; + + Tcl_Eval(interp, str.str().c_str()); + } +} + +void Frame3dBase::x11Graphics() +{ + Base::x11Graphics(); + + if (!keyContext->fits) + return; + + if (border_) { + XSetForeground(display, threedGC, getColor(borderColorName_)); + x11Border(Coord::WIDGET, keyContext->secMode(), threedGC, pixmap); + } + if (compass_) + x11Compass(); + if (highlite_) + x11Highlite(); +} + +void Frame3dBase::x11Line(Vector ss, Vector tt, int dd, GC gc, Pixmap pm) +{ + if (clip(&ss,&tt,options->width,options->height)) { + x11Dash(gc, dd); + XDrawLine(display, pm, gc, ss[0], ss[1], tt[0], tt[1]); + } +} + +void Frame3dBase::x11Border(Coord::InternalSystem sys, + FrScale::SecMode mode, GC gc, Pixmap pm) +{ + Vector3d vv[8]; + int dd[12]; + calcBorder(sys, mode, vv, dd); + + // front + x11Line(vv[0], vv[1], dd[0], gc, pm); + x11Line(vv[1], vv[2], dd[1], gc, pm); + x11Line(vv[2], vv[3], dd[2], gc, pm); + x11Line(vv[3], vv[0], dd[3], gc, pm); + + // back + x11Line(vv[4], vv[5], dd[4], gc, pm); + x11Line(vv[5], vv[6], dd[5], gc, pm); + x11Line(vv[6], vv[7], dd[6], gc, pm); + x11Line(vv[7], vv[4], dd[7], gc, pm); + + // other + x11Line(vv[0], vv[4], dd[8], gc, pm); + x11Line(vv[1], vv[5], dd[9], gc, pm); + x11Line(vv[2], vv[6], dd[10], gc, pm); + x11Line(vv[3], vv[7], dd[11], gc, pm); +} + +void Frame3dBase::x11Compass() +{ + Matrix3d& mm = keyContext->fits->dataToWidget3d; + + double ss = 100./(zoom_[0]+zoom_[1]); + + Vector3d oo = vp_*mm; + Vector3d xx = Vector3d(1,0,0) * Scale3d(ss) * Translate3d(vp_) * mm; + Vector3d yy = Vector3d(0,1,0) * Scale3d(ss) * Translate3d(vp_) * mm; + Vector3d zz = Vector3d(0,0,1) * Scale3d(ss) * Translate3d(vp_) * mm; + + x11Dash(threedGC, 0); + XSetForeground(display, threedGC, getColor(compassColorName_)); + + XDrawLine(display, pixmap, threedGC, oo[0], oo[1], xx[0], xx[1]); + XDrawLine(display, pixmap, threedGC, oo[0], oo[1], yy[0], yy[1]); + XDrawLine(display, pixmap, threedGC, oo[0], oo[1], zz[0], zz[1]); +} + +/* +void Frame3dBase::renderArm(int length, Vector center, Rotate rot, + const char* str, int color) +{ + if (!tkfont_) { + ostringstream fstr; + fstr << '{' << options->helvetica << '}' << " 9 roman normal" << ends; + tkfont_ = Tk_GetFont(interp, tkwin, fstr.str().c_str()); + if (tkfont_) + Tk_GetFontMetrics(tkfont_, &metric); + } + + if (!compassGC) { + compassGC = XCreateGC(display, pixmap, 0, NULL); + XSetLineAttributes(display, compassGC, 1, LineSolid, CapButt, JoinMiter); + if (tkfont_) + XSetFont(display, compassGC, Tk_FontId(tkfont_)); + } + + + if (length<=0) + return; + + // set GC + XSetForeground(display, compassGC, color); + const int textOffset = 15; // Text offset + const int tip = 6; // length from end of line to tip of arrow + const int tail = 2; // length from end of line to tails of arrow + const int wc = 2; // width of arrow at end of line + const int wt = 3; // width of arrow at tails + + // Arrow-- oriented on Y axis + Vector arrow[6]; + arrow[0] = Vector(0, tip); + arrow[1] = Vector(-wc, 0); + arrow[2] = Vector(-wt, -tail); + arrow[3] = Vector(0, 0); + arrow[4] = Vector(wt, -tail); + arrow[5] = Vector(wc, 0); + + // Staff-- oriented on X axis + XPoint arrowArray[6]; + Matrix arrowMatrix = Rotate(M_PI_2) * + Translate(length,0) * + rot * + Translate(center); + for (int i=0; i<6; i++) { + Vector r = (arrow[i] * arrowMatrix).round(); + arrowArray[i].x = (int)r[0]; + arrowArray[i].y = (int)r[1]; + } + + Vector c = ((Vector&)center).round(); + Vector end = (Vector(length, 0) * rot * Translate(center)).round(); + XDrawLine(display, pixmap, compassGC, (int)c[0], (int)c[1], + (int)end[0], (int)end[1]); + XFillPolygon(display, pixmap, compassGC, arrowArray, 6, + Nonconvex, CoordModeOrigin); + + if (useFont && tkfont_) { + Vector et = Vector((length + textOffset), 0) * rot * Translate(center) * + Translate(-Tk_TextWidth(tkfont_, str, 1)/2., metric.ascent/2.); + Tk_DrawChars(display, pixmap, compassGC, tkfont_, str, 1, + (int)et[0], (int)et[1]); + } +} +*/ + +void Frame3dBase::x11Highlite() +{ + Vector vv[4]; + int rr[4]; + calcHighlite(Coord::WIDGET,vv,rr); + + XSetForeground(display, threedGC, getColor(highliteColorName_)); + + x11Line(vv[0], vv[1], rr[0], threedGC, pixmap); + x11Line(vv[1], vv[2], rr[1], threedGC, pixmap); + x11Line(vv[2], vv[3], rr[2], threedGC, pixmap); + x11Line(vv[3], vv[0], rr[3], threedGC, pixmap); +} + +void Frame3dBase::ximageToPixmapMagnifier() +{ + if (!basePixmap || !baseXImage || !magnifierPixmap || !magnifierXImage) + return; + + // magnifier + int& ww = magnifierXImage->width; + int& hh = magnifierXImage->height; + Vector wh(ww,hh); + Vector cc = magnifierCursor * canvasToWidget; + Vector ll =cc-wh/2.; + Vector ur =cc+wh/2.; + + // clip to base + BBox bb(0,0,baseXImage->width,baseXImage->height); + Vector uu(ll); + Vector vv(ur); + uu.clip(bb); + vv.clip(bb); + Vector zz = vv-uu; + Vector oo = uu-ll; + + // sanity check + if (zz[0]<=0 || zz[1]<=0) + return; + + XImage* srcXImage = XGetImage(display, basePixmap, uu[0], uu[1], + zz[0], zz[1], AllPlanes, ZPixmap); + + char* src = srcXImage->data; + int srcBytesPerLine = srcXImage->bytes_per_line; + + char* dst = magnifierXImage->data; + int dstBytesPerLine = magnifierXImage->bytes_per_line; + int bytesPerPixel = magnifierXImage->bits_per_pixel/8; + + Matrix mx = Translate(-wh/2.) * + Translate(oo) * + Translate(-.5,-.5) * + Scale(magnifierZoom_) * + Translate(wh/2.); + Matrix mm = mx.invert(); + + for (int jj=0; jj= 0 && vv[0] < zz[0] && vv[1] >= 0 && vv[1] < zz[1]) { + // I really don't understand this +#if MAC_OSX_TK + char* sptr = src + ((int)vv[1])*srcBytesPerLine + + ((int)vv[0])*bytesPerPixel; + + *(dest+0) = *(sptr+3); + *(dest+1) = *(sptr+0); + *(dest+2) = *(sptr+1); + *(dest+3) = *(sptr+2); +#else + memcpy(dest, src + ((int)vv[1])*srcBytesPerLine + + ((int)vv[0])*bytesPerPixel, bytesPerPixel); +#endif + } + else + memcpy(dest, bgTrueColor_, bytesPerPixel); + } + } + + TkPutImage(NULL, 0, display, magnifierPixmap, widgetGC, magnifierXImage, + 0, 0, 0, 0, magnifierXImage->width, magnifierXImage->height); + + if (srcXImage) + XDestroyImage(srcXImage); +} + +#ifdef MAC_OSX_TK +void Frame3dBase::macosxLine(Vector& ss, Vector& tt, int dd) +{ + if (dd) + macosxDash(dlist,2); + else + macosxDash(NULL,0); + macosxDrawLine(ss,tt); +} + +void Frame3dBase::macosxGraphics() +{ + if (!keyContext->fits) + return; + + if (border_) + macosxBorder(); + if (compass_) + macosxCompass(); + if (highlite_) + macosxHighlite(); +} + +void Frame3dBase::macosxBorder() +{ + Vector3d vv[8]; + int dd[12]; + calcBorder(Coord::WIDGET, keyContext->secMode(), vv, dd); + + Vector uu[8]; + for (int ii=0; ii<8; ii++) + uu[ii] = Vector(vv[ii])*widgetToCanvas; + + macosxColor(getXColor(borderColorName_)); + macosxWidth(1); + + // front + macosxLine(uu[0],uu[1],dd[0]); + macosxLine(uu[1],uu[2],dd[1]); + macosxLine(uu[2],uu[3],dd[2]); + macosxLine(uu[3],uu[0],dd[3]); + + // back + macosxLine(uu[4],uu[5],dd[4]); + macosxLine(uu[5],uu[6],dd[5]); + macosxLine(uu[6],uu[7],dd[6]); + macosxLine(uu[7],uu[4],dd[7]); + + // other + macosxLine(uu[0],uu[4],dd[8]); + macosxLine(uu[1],uu[5],dd[9]); + macosxLine(uu[2],uu[6],dd[10]); + macosxLine(uu[3],uu[7],dd[11]); +} + +void Frame3dBase::macosxCompass() +{ + Matrix3d& mm = keyContext->fits->dataToWidget3d; + + double ss = 100./(zoom_[0]+zoom_[1]); + + Vector3d oo = vp_*mm; + Vector3d xx = Vector3d(1,0,0) * Scale3d(ss) * Translate3d(vp_) * mm; + Vector3d yy = Vector3d(0,1,0) * Scale3d(ss) * Translate3d(vp_) * mm; + Vector3d zz = Vector3d(0,0,1) * Scale3d(ss) * Translate3d(vp_) * mm; + + Vector o = Vector(oo)*widgetToCanvas; + Vector x = Vector(xx)*widgetToCanvas; + Vector y = Vector(yy)*widgetToCanvas; + Vector z = Vector(zz)*widgetToCanvas; + + macosxColor(getXColor(compassColorName_)); + macosxWidth(1); + + macosxLine(o,x,0); + macosxLine(o,y,0); + macosxLine(o,z,0); +} + +void Frame3dBase::macosxHighlite() +{ + Vector vv[4]; + int rr[4]; + calcHighlite(Coord::CANVAS,vv,rr); + + macosxColor(getXColor(highliteColorName_)); + macosxWidth(1); + + macosxLine(vv[0],vv[1],rr[0]); + macosxLine(vv[1],vv[2],rr[1]); + macosxLine(vv[2],vv[3],rr[2]); + macosxLine(vv[3],vv[0],rr[3]); +} +#endif + +#ifdef __WIN32 +void Frame3dBase::win32Line(Vector& ss, Vector& tt, int dd) +{ + if (dd) + win32Dash(dlist,2); + else + win32Dash(NULL,0); + win32DrawLine(ss,tt); +} + +void Frame3dBase::win32Graphics() +{ + if (!keyContext->fits) + return; + + if (border_) + win32Border(); + if (compass_) + win32Compass(); + if (highlite_) + win32Highlite(); +} + +void Frame3dBase::win32Border() +{ + Vector3d vv[8]; + int dd[12]; + calcBorder(Coord::WIDGET, keyContext->secMode(), vv, dd); + + Vector uu[8]; + for (int ii=0; ii<8; ii++) + uu[ii] = Vector(vv[ii])*widgetToCanvas; + + win32Color(getXColor(borderColorName_)); + win32Width(1); + + // front + win32Line(uu[0],uu[1],dd[0]); + win32Line(uu[1],uu[2],dd[1]); + win32Line(uu[2],uu[3],dd[2]); + win32Line(uu[3],uu[0],dd[3]); + + // back + win32Line(uu[4],uu[5],dd[4]); + win32Line(uu[5],uu[6],dd[5]); + win32Line(uu[6],uu[7],dd[6]); + win32Line(uu[7],uu[4],dd[7]); + + // other + win32Line(uu[0],uu[4],dd[8]); + win32Line(uu[1],uu[5],dd[9]); + win32Line(uu[2],uu[6],dd[10]); + win32Line(uu[3],uu[7],dd[11]); +} + +void Frame3dBase::win32Compass() +{ + Matrix3d& mm = keyContext->fits->dataToWidget3d; + + double ss = 100./(zoom_[0]+zoom_[1]); + + Vector3d oo = vp_*mm; + Vector3d xx = Vector3d(1,0,0) * Scale3d(ss) * Translate3d(vp_) * mm; + Vector3d yy = Vector3d(0,1,0) * Scale3d(ss) * Translate3d(vp_) * mm; + Vector3d zz = Vector3d(0,0,1) * Scale3d(ss) * Translate3d(vp_) * mm; + + Vector o = Vector(oo)*widgetToCanvas; + Vector x = Vector(xx)*widgetToCanvas; + Vector y = Vector(yy)*widgetToCanvas; + Vector z = Vector(zz)*widgetToCanvas; + + win32Color(getXColor(compassColorName_)); + win32Width(1); + + win32Line(o,x,0); + win32Line(o,y,0); + win32Line(o,z,0); +} + +void Frame3dBase::win32Highlite() +{ + Vector vv[4]; + int rr[4]; + calcHighlite(Coord::CANVAS,vv,rr); + + win32Color(getXColor(highliteColorName_)); + win32Width(1); + + win32Line(vv[0],vv[1],rr[0]); + win32Line(vv[1],vv[2],rr[1]); + win32Line(vv[2],vv[3],rr[2]); + win32Line(vv[3],vv[0],rr[3]); +} +#endif diff --git a/tksao/frame/frame3dbase.h b/tksao/frame/frame3dbase.h new file mode 100644 index 0000000..986bbe1 --- /dev/null +++ b/tksao/frame/frame3dbase.h @@ -0,0 +1,228 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __frame3dbase_h__ +#define __frame3dbase_h__ + +#include "base.h" +#include "raytrace.h" + +class Grid3d; + +class Frame3dBase : public Base { + friend class Grid3d; + + public: + enum RenderMethod {MIP,AIP}; + enum MotionType {NONE,AZIMUTH,ELEVATION}; + + protected: + int zdepth_; + double zzoom_; + double zscale_; + Vector3d vp_; + Vector viewCursor_; + + float az_; + float el_; + RenderMethod renderMethod_; + + List cache_; + List pannerCache_; + int preservecache_; + + MotionType render_; // enable background rendering + + GC threedGC; + + int border_; + char* borderColorName_; + int compass_; + char* compassColorName_; + int highlite_; + char* highliteColorName_; + + double cropsl_; + + Matrix3d dataToImage3d; + Matrix3d imageToData3d; + + Matrix3d refToUser3d; + Matrix3d userToRef3d; + Matrix3d refToWidget3d; + Matrix3d widgetToRef3d; + Matrix3d refToCanvas3d; + Matrix3d canvasToRef3d; + Matrix3d refToWindow3d; + Matrix3d windowToRef3d; + + Matrix3d userToWidget3d; + Matrix3d widgetToUser3d; + Matrix3d userToCanvas3d; + Matrix3d canvasToUser3d; + Matrix3d userToWindow3d; + Matrix3d windowToUser3d; + + Matrix3d widgetToCanvas3d; + Matrix3d canvasToWidget3d; + Matrix3d widgetToWindow3d; + Matrix3d windowToWidget3d; + + Matrix3d canvasToWindow3d; + Matrix3d windowToCanvas3d; + + Matrix3d refToMagnifier3d; + Matrix3d magnifierToRef3d; + Matrix3d userToMagnifier3d; + Matrix3d magnifierToUser3d; + Matrix3d widgetToMagnifier3d; + Matrix3d magnifierToWidget3d; + + Matrix3d refToPanner3d; + Matrix3d pannerToRef3d; + Matrix3d userToPanner3d; + Matrix3d pannerToUser3d; + Matrix3d widgetToPanner3d; + Matrix3d pannerToWidget3d; + + private: + void calcBorder(Coord::InternalSystem, FrScale::SecMode mode, + Vector3d* vv, int* dd); + void calcHighlite(Coord::InternalSystem, Vector*, int*); + + protected: + double calcZoomPanner(); + double calcZoom3d(Vector3d, Vector); + virtual void cancelDetach() =0; + void centerImage(); + + int isAzElZero() {return !az_ && !el_;} + + Vector3d imageCenter3d(FrScale::SecMode); + Vector3d imageSize3d(FrScale::SecMode); + + void psColor(PSColorSpace, const char*); + void psLine(Vector&, Vector&, int); + void psWidth(int); + void psGraphics(PSColorSpace mode); + void psBorder(PSColorSpace mode); + void psCompass(PSColorSpace mode); + void psHighlite(PSColorSpace mode); + Matrix3d psMatrix(float scale, int width, int height); + + void setBinCursor() {} + + void updateBin(const Matrix&); + void updateBlock(const Vector&); + void updateGCs(); + void updateMagnifierMatrices(); + void updatePannerMatrices(); + void updateMatrices(); + void updatePanner(); + + void x11Line(Vector, Vector, int, GC, Pixmap); + void x11Graphics(); + void x11Border(Coord::InternalSystem, FrScale::SecMode, GC, Pixmap); + void x11Compass(); + void x11Highlite(); + void ximageToPixmapMagnifier(); + + public: + Frame3dBase(Tcl_Interp*, Tk_Canvas, Tk_Item*); + virtual ~Frame3dBase(); + + void setSlice(int,int); + + Vector mapFromRef(const Vector& vv, Coord::InternalSystem sys) + {return mapFromRef3d(vv,sys);} + Vector3d mapFromRef3d(const Vector&, Coord::InternalSystem); + Vector3d mapFromRef3d(const Vector&, Coord::InternalSystem, double); + Vector mapToRef(const Vector& vv, Coord::InternalSystem sys) + {return mapToRef3d(vv,sys);} + Vector3d mapToRef3d(const Vector&, Coord::InternalSystem); + Vector3d mapToRef3d(const Vector&, Coord::InternalSystem, double); + + // Bin Commands + void binToFitCmd(); + + // Block Commands + void blockToFitCmd(); + + // Clip Commands + void clipScopeCmd(FrScale::ClipScope) {} // scope is always GLOBAL + + // Coordinate Commands + void getCursorCmd(Coord::InternalSystem); + void getCursorCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + + // Crop Commands + void crop3dBeginCmd(const Vector&, int); + void crop3dMotionCmd(const Vector&, int); + void crop3dEndCmd(const Vector&, int); + + // Grid Commands + void gridCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, + Grid::GridType, const char*, const char*); + + // Pan Zoom Rotate Orient Commands + void panCmd(const Vector&); + void panCmd(const Vector&, const Vector&); + void panCmd(const Vector&, Coord::CoordSystem, Coord::SkyFrame); + void panToCmd(const Vector&); + void panToCmd(const Vector&, Coord::CoordSystem, Coord::SkyFrame); + void panBBoxCmd(const Vector&); + void panEndCmd(const Vector&); + void rotateBeginCmd(); + void rotateMotionCmd(double); + void rotateEndCmd(); + void zoomAboutCmd(const Vector&, const Vector&); + void zoomAboutCmd(const Vector&, const Vector&, Coord::CoordSystem, Coord::SkyFrame); + void zoomToAboutCmd(const Vector&, const Vector&); + void zoomToAboutCmd(const Vector&, const Vector&, Coord::CoordSystem, Coord::SkyFrame); + void zoomToFitCmd(double); + + // 3d Commands + void get3dBorderCmd(); + void get3dBorderColorCmd(); + void get3dCompassCmd(); + void get3dCompassColorCmd(); + void get3dHighliteCmd(); + void get3dHighliteColorCmd(); + void get3dRenderMethodCmd(); + void get3dRenderBackgroundCmd(); + void get3dScaleCmd(); + void get3dViewCmd(); + void get3dViewPointCmd(); + void set3dBorderCmd(int); + void set3dBorderColorCmd(const char*); + void set3dCompassCmd(int); + void set3dCompassColorCmd(const char*); + void set3dHighliteCmd(int); + void set3dHighliteColorCmd(const char*); + void set3dRenderMethodCmd(int); + void set3dRenderBackgroundCmd(int); + void set3dPreserveCmd(); + void set3dScaleCmd(double); + void set3dViewCmd(float, float); + void set3dViewPointCmd(const Vector3d&, const Vector&); + void view3dMotionCmd(float az, float el) {set3dViewCmd(az,el);} + void view3dEndCmd(float az, float el) {set3dViewCmd(az,el);} + +#ifdef MAC_OSX_TK + void macosxLine(Vector&, Vector&, int); + void macosxGraphics(); + void macosxBorder(); + void macosxCompass(); + void macosxHighlite(); +#endif +#ifdef __WIN32 + void win32Line(Vector&, Vector&, int); + void win32Graphics(); + void win32Border(); + void win32Compass(); + void win32Highlite(); +#endif +}; + +#endif diff --git a/tksao/frame/frame3dtruecolor16.C b/tksao/frame/frame3dtruecolor16.C new file mode 100644 index 0000000..3fd3d03 --- /dev/null +++ b/tksao/frame/frame3dtruecolor16.C @@ -0,0 +1,165 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "frame3dtruecolor16.h" +#include "colorscaletrue16.h" +#include "util.h" + +// Tk Canvas Widget Function Declarations + +int Frame3dTrueColor16CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int, Tcl_Obj *const []); + +// Frame3dTrueColor16 Specs + +static Tk_CustomOption tagsOption = { + Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL +}; + +static Tk_ConfigSpec frame3dTrueColor16Specs[] = { + + {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "frame3d", + Tk_Offset(WidgetOptions, cmdName), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1", + Tk_Offset(WidgetOptions, x), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1", + Tk_Offset(WidgetOptions, y), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512", + Tk_Offset(WidgetOptions, width), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "512", + Tk_Offset(WidgetOptions, height), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw", + Tk_Offset(WidgetOptions, anchor), 0, NULL}, + {TK_CONFIG_CUSTOM, (char*)"-tags", NULL, NULL, NULL, + 0, TK_CONFIG_NULL_OK, &tagsOption}, + + {TK_CONFIG_STRING, (char*)"-helvetica", NULL, NULL, "helvetica", + Tk_Offset(WidgetOptions, helvetica), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier", + Tk_Offset(WidgetOptions, courier), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times", + Tk_Offset(WidgetOptions, times), 0, NULL}, + + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}, +}; + +// Tk Static Structure + +static Tk_ItemType frame3dTrueColor16Type = { + (char*)"frame3dtruecolor16", // name + sizeof(WidgetOptions), // item size + Frame3dTrueColor16CreateProc, // configProc + frame3dTrueColor16Specs, // configSpecs + WidgetConfigProc, // configProc + WidgetCoordProc, // coordProc + WidgetDeleteProc, // deleteProc + WidgetDisplayProc, // displayProc + 0, // alwaysRedraw + WidgetPointProc, // pointProc + WidgetAreaProc, // areaProc + WidgetPostscriptProc, // postscriptProc + WidgetScaleProc, // scaleProc + WidgetTranslateProc, // translateProc + (Tk_ItemIndexProc*)NULL, // indexProc + WidgetICursorProc, // icursorProc + (Tk_ItemSelectionProc*)NULL, // selectionProc + (Tk_ItemInsertProc*)NULL, // insertProc + (Tk_ItemDCharsProc*)NULL, // dCharsProc + (Tk_ItemType*)NULL // nextPtr +}; + +// Non-Member Functions + +int Frame3dTrueColor16_Init(Tcl_Interp* interp) +{ + Tk_CreateItemType(&frame3dTrueColor16Type); + return TCL_OK; +} + +int Frame3dTrueColor16CreateProc(Tcl_Interp* interp, Tk_Canvas canvas, + Tk_Item* item, int argc, Tcl_Obj *const argv[]) +{ + Frame3dTrueColor16* frame = new Frame3dTrueColor16(interp, canvas, item); + + // and set default configuration + + if (frame->configure(argc, (const char**)argv, 0) != TCL_OK) { + delete frame; + Tcl_AppendResult(interp, " error occured while creating frame.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// Frame3dTrueColor16 Member Functions + +Frame3dTrueColor16::Frame3dTrueColor16(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : Frame3d(i,c,item), TrueColor16(visual) +{ + configSpecs = frame3dTrueColor16Specs; // frame configure options +} + +Frame3dTrueColor16::~Frame3dTrueColor16() +{ + // we must do this at this level, because updateColorScale is called + unloadAllFits(); +} + +void Frame3dTrueColor16::updateColorScale() +{ + // we need colors before we can construct a scale + if (!colorCells) + return; + + if (colorScale) + delete colorScale; + + switch (context->colorScaleType()) { + case FrScale::LINEARSCALE: + colorScale = + new LinearScaleTrueColor16(colorCount, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::LOGSCALE: + colorScale = + new LogScaleTrueColor16(SCALESIZE, colorCells, colorCount, + context->expo(), visual, byteorder_); + break; + case FrScale::POWSCALE: + colorScale = + new PowScaleTrueColor16(SCALESIZE, colorCells, colorCount, + context->expo(), visual, byteorder_); + break; + case FrScale::SQRTSCALE: + colorScale = + new SqrtScaleTrueColor16(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::SQUAREDSCALE: + colorScale = + new SquaredScaleTrueColor16(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::ASINHSCALE: + colorScale = + new AsinhScaleTrueColor16(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::SINHSCALE: + colorScale = + new SinhScaleTrueColor16(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::HISTEQUSCALE: + colorScale = + new HistEquScaleTrueColor16(SCALESIZE, colorCells, colorCount, + context->histequ(), HISTEQUSIZE, + visual, byteorder_); + break; + case FrScale::IISSCALE: + colorScale = + new IISScaleTrueColor16(colorCells, colorCount, visual, byteorder_); + break; + } +} diff --git a/tksao/frame/frame3dtruecolor16.h b/tksao/frame/frame3dtruecolor16.h new file mode 100644 index 0000000..396ddb7 --- /dev/null +++ b/tksao/frame/frame3dtruecolor16.h @@ -0,0 +1,24 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __frame3dtruecolor16_h__ +#define __frame3dtruecolor16_h__ + +#include "frame3d.h" +#include "truecolor16.h" + +class Frame3dTrueColor16 : public Frame3d, public TrueColor16 { +private: + void encodeTrueColor(XColor* src, char* dest) + {TrueColor16::encodeTrueColor(src,dest,baseXImage);} + void encodeTrueColor(unsigned char* src, XImage* ximage) + {TrueColor16::encodeTrueColor(src, ximage);} + void updateColorScale(); + +public: + Frame3dTrueColor16(Tcl_Interp*, Tk_Canvas, Tk_Item*); + ~Frame3dTrueColor16(); +}; + +#endif diff --git a/tksao/frame/frame3dtruecolor24.C b/tksao/frame/frame3dtruecolor24.C new file mode 100644 index 0000000..cc0ae5e --- /dev/null +++ b/tksao/frame/frame3dtruecolor24.C @@ -0,0 +1,231 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "frame3dtruecolor24.h" +#include "colorscaletrue24.h" +#include "colorscaletrue32.h" + +// Tk Canvas Widget Function Declarations + +int Frame3dTrueColor24CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int, Tcl_Obj *const []); + +// Frame3dTrueColor24 Specs + +static Tk_CustomOption tagsOption = { + Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL +}; + +static Tk_ConfigSpec frame3dTrueColor24Specs[] = { + + {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "frame3d", + Tk_Offset(WidgetOptions, cmdName), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1", + Tk_Offset(WidgetOptions, x), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1", + Tk_Offset(WidgetOptions, y), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512", + Tk_Offset(WidgetOptions, width), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "512", + Tk_Offset(WidgetOptions, height), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw", + Tk_Offset(WidgetOptions, anchor), 0, NULL}, + {TK_CONFIG_CUSTOM, (char*)"-tags", NULL, NULL, NULL, + 0, TK_CONFIG_NULL_OK, &tagsOption}, + + {TK_CONFIG_STRING, (char*)"-helvetica", NULL, NULL, "helvetica", + Tk_Offset(WidgetOptions, helvetica), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier", + Tk_Offset(WidgetOptions, courier), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times", + Tk_Offset(WidgetOptions, times), 0, NULL}, + + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}, +}; + +// Tk Static Structure + +static Tk_ItemType frame3dTrueColor24Type = { + (char*)"frame3dtruecolor24", // name + sizeof(WidgetOptions), // item size + Frame3dTrueColor24CreateProc, // configProc + frame3dTrueColor24Specs, // configSpecs + WidgetConfigProc, // configProc + WidgetCoordProc, // coordProc + WidgetDeleteProc, // deleteProc + WidgetDisplayProc, // displayProc + 0, // alwaysRedraw + WidgetPointProc, // pointProc + WidgetAreaProc, // areaProc + WidgetPostscriptProc, // postscriptProc + WidgetScaleProc, // scaleProc + WidgetTranslateProc, // translateProc + (Tk_ItemIndexProc*)NULL, // indexProc + WidgetICursorProc, // icursorProc + (Tk_ItemSelectionProc*)NULL, // selectionProc + (Tk_ItemInsertProc*)NULL, // insertProc + (Tk_ItemDCharsProc*)NULL, // dCharsProc + (Tk_ItemType*)NULL // nextPtr +}; + +// Non-Member Functions + +int Frame3dTrueColor24_Init(Tcl_Interp* interp) +{ + Tk_CreateItemType(&frame3dTrueColor24Type); + return TCL_OK; +} + +int Frame3dTrueColor24CreateProc(Tcl_Interp* interp, Tk_Canvas canvas, + Tk_Item* item, int argc, Tcl_Obj *const argv[]) +{ + Frame3dTrueColor24* frame = new Frame3dTrueColor24(interp, canvas, item); + + // and set default configuration + + if (frame->configure(argc, (const char**)argv, 0) != TCL_OK) { + delete frame; + Tcl_AppendResult(interp, " error occured while creating frame.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// Frame3dTrueColor24 Member Functions + +Frame3dTrueColor24::Frame3dTrueColor24(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : Frame3d(i,c,item), TrueColor24(visual) +{ + configSpecs = frame3dTrueColor24Specs; // frame configure options +} + +Frame3dTrueColor24::~Frame3dTrueColor24() +{ + // we must do this at this level, because updateColorScale is called + unloadAllFits(); +} + +void Frame3dTrueColor24::updateColorScale() +{ + // we need colors before we can construct a scale + if (!colorCells || !bitsperpixel_) + return; + + if (colorScale) + delete colorScale; + + // determine if we have 3 bytes or 4 bytes per pixel + switch (bitsperpixel_) { + case 24: + updateColorScale24(); + break; + case 32: + updateColorScale32(); + break; + } +} + +void Frame3dTrueColor24::updateColorScale24() +{ + switch (context->colorScaleType()) { + case FrScale::LINEARSCALE: + colorScale = + new LinearScaleTrueColor24(colorCount, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::LOGSCALE: + colorScale = + new LogScaleTrueColor24(SCALESIZE, colorCells, colorCount, + context->expo(), visual, byteorder_); + break; + case FrScale::POWSCALE: + colorScale = + new PowScaleTrueColor24(SCALESIZE, colorCells, colorCount, + context->expo(), visual, byteorder_); + break; + case FrScale::SQRTSCALE: + colorScale = + new SqrtScaleTrueColor24(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::SQUAREDSCALE: + colorScale = + new SquaredScaleTrueColor24(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::ASINHSCALE: + colorScale = + new AsinhScaleTrueColor24(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::SINHSCALE: + colorScale = + new SinhScaleTrueColor24(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::HISTEQUSCALE: + colorScale = + new HistEquScaleTrueColor24(SCALESIZE, colorCells, colorCount, + context->histequ(), HISTEQUSIZE, + visual, byteorder_); + break; + case FrScale::IISSCALE: + colorScale = + new IISScaleTrueColor24(colorCells, colorCount, visual, byteorder_); + break; + } +} + +void Frame3dTrueColor24::updateColorScale32() +{ + switch (context->colorScaleType()) { + case FrScale::LINEARSCALE: + colorScale = + new LinearScaleTrueColor32(colorCount, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::LOGSCALE: + colorScale = + new LogScaleTrueColor32(SCALESIZE, colorCells, colorCount, + context->expo(), visual, byteorder_); + break; + case FrScale::POWSCALE: + colorScale = + new PowScaleTrueColor32(SCALESIZE, colorCells, colorCount, + context->expo(), visual, byteorder_); + break; + case FrScale::SQRTSCALE: + colorScale = + new SqrtScaleTrueColor32(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::SQUAREDSCALE: + colorScale = + new SquaredScaleTrueColor32(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::ASINHSCALE: + colorScale = + new AsinhScaleTrueColor32(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::SINHSCALE: + colorScale = + new SinhScaleTrueColor32(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::HISTEQUSCALE: + colorScale = + new HistEquScaleTrueColor32(SCALESIZE, colorCells, colorCount, + context->histequ(), HISTEQUSIZE, + visual, byteorder_); + break; + case FrScale::IISSCALE: + colorScale = + new IISScaleTrueColor32(colorCells, colorCount, visual, byteorder_); + break; + } +} + + diff --git a/tksao/frame/frame3dtruecolor24.h b/tksao/frame/frame3dtruecolor24.h new file mode 100644 index 0000000..df898a8 --- /dev/null +++ b/tksao/frame/frame3dtruecolor24.h @@ -0,0 +1,26 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __frame3dtruecolor24_h__ +#define __frame3dtruecolor24_h__ + +#include "frame3d.h" +#include "truecolor24.h" + +class Frame3dTrueColor24 : public Frame3d, public TrueColor24 { +private: + void encodeTrueColor(XColor* src, char* dest) + {TrueColor24::encodeTrueColor(src,dest,baseXImage);} + void encodeTrueColor(unsigned char* src, XImage* ximage) + {TrueColor24::encodeTrueColor(src, ximage);} + void updateColorScale(); + void updateColorScale24(); + void updateColorScale32(); + +public: + Frame3dTrueColor24(Tcl_Interp*, Tk_Canvas, Tk_Item*); + ~Frame3dTrueColor24(); +}; + +#endif diff --git a/tksao/frame/frame3dtruecolor8.C b/tksao/frame/frame3dtruecolor8.C new file mode 100644 index 0000000..9997549 --- /dev/null +++ b/tksao/frame/frame3dtruecolor8.C @@ -0,0 +1,162 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "frame3dtruecolor8.h" +#include "colorscaletrue8.h" + +// Tk Canvas Widget Function Declarations + +int Frame3dTrueColor8CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int, Tcl_Obj *const []); + +// Frame3dTrueColor8 Specs + +static Tk_CustomOption tagsOption = { + Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL +}; + +static Tk_ConfigSpec frame3dTrueColor8Specs[] = { + + {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "frame3d", + Tk_Offset(WidgetOptions, cmdName), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1", + Tk_Offset(WidgetOptions, x), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1", + Tk_Offset(WidgetOptions, y), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512", + Tk_Offset(WidgetOptions, width), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "512", + Tk_Offset(WidgetOptions, height), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw", + Tk_Offset(WidgetOptions, anchor), 0, NULL}, + {TK_CONFIG_CUSTOM, (char*)"-tags", NULL, NULL, NULL, + 0, TK_CONFIG_NULL_OK, &tagsOption}, + + {TK_CONFIG_STRING, (char*)"-helvetica", NULL, NULL, "helvetica", + Tk_Offset(WidgetOptions, helvetica), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier", + Tk_Offset(WidgetOptions, courier), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times", + Tk_Offset(WidgetOptions, times), 0, NULL}, + + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}, +}; + +// Tk Static Structure + +static Tk_ItemType frame3dTrueColor8Type = { + (char*)"frame3dtruecolor8", // name + sizeof(WidgetOptions), // item size + Frame3dTrueColor8CreateProc, // configProc + frame3dTrueColor8Specs, // configSpecs + WidgetConfigProc, // configProc + WidgetCoordProc, // coordProc + WidgetDeleteProc, // deleteProc + WidgetDisplayProc, // displayProc + 0, // alwaysRedraw + WidgetPointProc, // pointProc + WidgetAreaProc, // areaProc + WidgetPostscriptProc, // postscriptProc + WidgetScaleProc, // scaleProc + WidgetTranslateProc, // translateProc + (Tk_ItemIndexProc*)NULL, // indexProc + WidgetICursorProc, // icursorProc + (Tk_ItemSelectionProc*)NULL, // selectionProc + (Tk_ItemInsertProc*)NULL, // insertProc + (Tk_ItemDCharsProc*)NULL, // dCharsProc + (Tk_ItemType*)NULL // nextPtr +}; + +// Non-Member Functions + +int Frame3dTrueColor8_Init(Tcl_Interp* interp) +{ + Tk_CreateItemType(&frame3dTrueColor8Type); + return TCL_OK; +} + +int Frame3dTrueColor8CreateProc(Tcl_Interp* interp, Tk_Canvas canvas, + Tk_Item* item, int argc, Tcl_Obj *const argv[]) +{ + Frame3dTrueColor8* frame = new Frame3dTrueColor8(interp, canvas, item); + + // and set default configuration + + if (frame->configure(argc, (const char**)argv, 0) != TCL_OK) { + delete frame; + Tcl_AppendResult(interp, " error occured while creating frame.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// Frame3dTrueColor8 Member Functions + +Frame3dTrueColor8::Frame3dTrueColor8(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : Frame3d(i,c,item), TrueColor8(visual) +{ + configSpecs = frame3dTrueColor8Specs; // frame configure options +} + +Frame3dTrueColor8::~Frame3dTrueColor8() +{ + // we must do this at this level, because updateColorScale is called + unloadAllFits(); +} + +void Frame3dTrueColor8::updateColorScale() +{ + // we need colors before we can construct a scale + if (!colorCells) + return; + + if (colorScale) + delete colorScale; + + switch (context->colorScaleType()) { + case FrScale::LINEARSCALE: + colorScale = + new LinearScaleTrueColor8(colorCount, colorCells, colorCount, visual); + break; + case FrScale::LOGSCALE: + colorScale = + new LogScaleTrueColor8(SCALESIZE, colorCells, colorCount, + context->expo(), visual); + break; + case FrScale::POWSCALE: + colorScale = + new PowScaleTrueColor8(SCALESIZE, colorCells, colorCount, + context->expo(), visual); + break; + case FrScale::SQRTSCALE: + colorScale = + new SqrtScaleTrueColor8(SCALESIZE, colorCells, colorCount, visual); + break; + case FrScale::SQUAREDSCALE: + colorScale = + new SquaredScaleTrueColor8(SCALESIZE, colorCells, colorCount, visual); + break; + case FrScale::ASINHSCALE: + colorScale = + new AsinhScaleTrueColor8(SCALESIZE, colorCells, colorCount, visual); + break; + case FrScale::SINHSCALE: + colorScale = + new SinhScaleTrueColor8(SCALESIZE, colorCells, colorCount, visual); + break; + case FrScale::HISTEQUSCALE: + colorScale = + new HistEquScaleTrueColor8(SCALESIZE, colorCells, colorCount, + context->histequ(), HISTEQUSIZE, + visual); + break; + case FrScale::IISSCALE: + colorScale = + new IISScaleTrueColor8(colorCells, colorCount, visual); + break; + } +} + + + diff --git a/tksao/frame/frame3dtruecolor8.h b/tksao/frame/frame3dtruecolor8.h new file mode 100644 index 0000000..70a554f --- /dev/null +++ b/tksao/frame/frame3dtruecolor8.h @@ -0,0 +1,25 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __frame3dtruecolor8_h__ +#define __frame3dtruecolor8_h__ + +#include "frame3d.h" +#include "truecolor8.h" + +class Frame3dTrueColor8 : public Frame3d, public TrueColor8 { + +private: + void encodeTrueColor(XColor* src, char* dest) + {TrueColor8::encodeTrueColor(src,dest,baseXImage);} + void encodeTrueColor(unsigned char* src, XImage* ximage) + {TrueColor8::encodeTrueColor(src, ximage);} + void updateColorScale(); + +public: + Frame3dTrueColor8(Tcl_Interp*, Tk_Canvas, Tk_Item*); + ~Frame3dTrueColor8(); +}; + +#endif diff --git a/tksao/frame/framebase.C b/tksao/frame/framebase.C new file mode 100644 index 0000000..acf838e --- /dev/null +++ b/tksao/frame/framebase.C @@ -0,0 +1,252 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "framebase.h" +#include "fitsimage.h" +#include "marker.h" +#include "context.h" +#include "ps.h" + +// Public + +FrameBase::FrameBase(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : Base(i, c, item) +{ + rotateSrcXM = NULL; + rotateDestXM = NULL; + rotatePM = 0; + + colormapXM = NULL; + colormapPM = 0; + colormapGCXOR = 0; +} + +FrameBase::~FrameBase() +{ + if (colormapXM) + XDestroyImage(colormapXM); + + if (colormapPM) + Tk_FreePixmap(display, colormapPM); + + if (colormapGCXOR) + XFreeGC(display, colormapGCXOR); +} + +double FrameBase::calcZoomPanner() +{ + if (!(keyContext->fits && pannerPixmap)) + return 1; + + Vector src = imageSize(keyContext->datasec() ? FrScale::DATASEC : FrScale::IMGSEC); + return calcZoom(src, Vector(pannerWidth,pannerHeight)); +} + +void FrameBase::rotateMotion() +{ + // Rotate from src to dest + Vector cc = Vector(options->width,options->height)/2; + Matrix m = (Translate(-cc) * Rotate(rotation-rotateRotation) * + Translate(cc)).invert(); + double* mm = m.mm(); + + int& width = options->width; + int& height = options->height; + char* src = rotateSrcXM->data; + + int bytesPerPixel = rotateDestXM->bits_per_pixel/8; + + for (int j=0; jdata + j*rotateDestXM->bytes_per_line; + memset(dest,0,rotateDestXM->bytes_per_line); + + for (int i=0; i= 0 && x < width && y >= 0 && y < height) { +#if MAC_OSX_TK + // I really don't understand this + char* sptr = src + ((int)y)*rotateDestXM->bytes_per_line+ + ((int)x)*bytesPerPixel; + + *(dest+0) = *(sptr+3); + *(dest+1) = *(sptr+0); + *(dest+2) = *(sptr+1); + *(dest+3) = *(sptr+2); +#else + memcpy(dest, src + ((int)y)*rotateDestXM->bytes_per_line + + ((int)x)*bytesPerPixel, bytesPerPixel); +#endif + } + else + memcpy(dest, bgTrueColor_, bytesPerPixel); + } + } + + // XImage to Pixmap + TkPutImage(NULL, 0, display, rotatePM, widgetGC, rotateDestXM, + 0, 0, 0, 0, options->width, options->height); + + // Display Pixmap + Vector dd = Vector() * widgetToWindow; + XCopyArea(display, rotatePM, Tk_WindowId(tkwin), rotateGCXOR, 0, 0, + options->width, options->height, dd[0], dd[1]); +} +void FrameBase::setBinCursor() +{ + if (context->cfits) + context->cfits->setBinCursor(cursor); +} + +void FrameBase::setSlice(int id, int ss) +{ + // IMAGE (ranges 1-n) + currentContext->updateSlice(id, ss); + + switch (currentContext->clipScope()) { + case FrScale::GLOBAL: + currentContext->updateContours(); + break; + case FrScale::LOCAL: + currentContext->clearHist(); + currentContext->updateClip(); + currentContext->updateContoursScale(); + break; + } + + updateColorScale(); + update(MATRIX); + + Base::setSlice(id,ss); +} + +void FrameBase::updateBin(const Matrix& mx) +{ + // Note: cursor is in REF coords, imageCenter() in IMAGE coords + cursor = imageCenter(FrScale::IMGSEC); + Base::updateBin(mx); +} + +void FrameBase::updatePanner() +{ + Base::updatePanner(); + + if (usePanner) { + ostringstream str; + + str << pannerName << " update " << (void*)pannerPixmap << ';'; + + // calculate bbox + Vector ll = Vector(0,0) * widgetToPanner; + Vector lr = Vector(options->width,0) * widgetToPanner; + Vector ur = Vector(options->width,options->height) * widgetToPanner; + Vector ul = Vector(0,options->height) * widgetToPanner; + + str << pannerName << " update bbox " + << ll << ' ' << lr << ' ' << ur << ' ' << ul << ';'; + + // calculate image compass vectors + Matrix mm = + FlipY() * + irafMatrix_ * + wcsOrientationMatrix * + Rotate(wcsRotation) * + orientationMatrix * + Rotate(rotation); + + Vector xx = (Vector(1,0)*mm).normalize(); + Vector yy = (Vector(0,1)*mm).normalize(); + + str << pannerName << " update image compass " + << xx << ' ' << yy << ';'; + + if (keyContext->fits && keyContext->fits->hasWCS(wcsSystem_)) { + Vector orpix = keyContext->fits->center(); + Vector orval=keyContext->fits->pix2wcs(orpix, wcsSystem_, wcsSky_); + Vector orpix2 = keyContext->fits->wcs2pix(orval, wcsSystem_,wcsSky_); + Vector delta = keyContext->fits->getWCScdelt(wcsSystem_).abs(); + + Vector npix = keyContext->fits->wcs2pix(Vector(orval[0],orval[1]+delta[1]), wcsSystem_,wcsSky_); + Vector north = ((npix-orpix2)*mm).normalize(); + Vector epix = keyContext->fits->wcs2pix(Vector(orval[0]+delta[0],orval[1]), wcsSystem_,wcsSky_); + Vector east = ((epix-orpix2)*mm).normalize(); + + // sanity check + Vector diff = (north-east).abs(); + if ((north[0]==0 && north[1]==0) || + (east[0]==0 && east[1]==0) || + (diff[0]<.01 && diff[1]<.01)) { + north = (Vector(0,1)*mm).normalize(); + east = (Vector(-1,0)*mm).normalize(); + } + + str << pannerName << " update wcs compass " + << north << ' ' << east << ends; + } + else + str << pannerName << " update wcs compass invalid" << ends; + + Tcl_Eval(interp, str.str().c_str()); + } +} + +void FrameBase::x11MagnifierCursor(const Vector& vv) +{ + // first, the inner color'd box + Vector uu = vv * canvasToUser; + + Matrix mm = Translate(-uu) * + Rotate(wcsRotation) * + Rotate(rotation) * + Scale(zoom_) * + Scale(magnifierZoom_) * + Translate(magnifierWidth/2., magnifierHeight/2.); + + Vector c[5]; + c[0] = (uu + Vector(-.5,-.5)) * mm; + c[1] = (uu + Vector( .5,-.5)) * mm; + c[2] = (uu + Vector( .5, .5)) * mm; + c[3] = (uu + Vector(-.5, .5)) * mm; + c[4] = c[0]; + + XPoint pts[5]; + for (int ii=0; ii<5; ii++) { + Vector z = c[ii].round(); + pts[ii].x = (short)z[0]; + pts[ii].y = (short)z[1]; + } + XSetForeground(display, widgetGC, getColor(magnifierColorName)); + XDrawLines(display, magnifierPixmap, widgetGC, pts, 5, CoordModeOrigin); + + // now, the outer black box + Matrix nn = + Translate(-(uu * mm)) * + Rotate(-rotation) * + Rotate(-wcsRotation); + Matrix oo = nn.invert(); + + Vector dd[5]; + for (int ii=0; ii<5; ii++) + dd[ii] = c[ii] * nn; + + dd[0]+=Vector(-1,-1); + dd[1]+=Vector( 1,-1); + dd[2]+=Vector( 1, 1); + dd[3]+=Vector(-1, 1); + dd[4]=dd[0]; + + for (int ii=0; ii<5; ii++) { + dd[ii] = dd[ii] * oo; + Vector zz = dd[ii].round(); + pts[ii].x = (int)zz[0]; + pts[ii].y = (int)zz[1]; + } + XSetForeground(display, widgetGC, getColor("black")); + XDrawLines(display, magnifierPixmap, widgetGC, pts, 5, CoordModeOrigin); +} + diff --git a/tksao/frame/framebase.h b/tksao/frame/framebase.h new file mode 100644 index 0000000..6491857 --- /dev/null +++ b/tksao/frame/framebase.h @@ -0,0 +1,114 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __framebase_h__ +#define __framebase_h__ + +#include "base.h" + +class FrameBase : public Base { +protected: + XImage* rotateSrcXM; // rotate src ximage + XImage* rotateDestXM; // rotate dest ximage + Pixmap rotatePM; // rotate pixmap + + XImage* colormapXM; // rotate dest ximage + Pixmap colormapPM; // rotate pixmap + GC colormapGCXOR; // GC for interactive rotation + + Vector iisLastCursor; // iis cursor state info + +protected: + double calcZoomPanner(); + void cancelDetach() {}; + + void rotateMotion(); + + void saveFitsResampleFits(OutFitsStream&); + void saveFitsResampleKeyword(OutFitsStream&, FitsHead&); + void setBinCursor(); + + virtual void updateBin(const Matrix&); + void updatePanner(); + + void x11MagnifierCursor(const Vector&); + +public: + FrameBase(Tcl_Interp*, Tk_Canvas, Tk_Item*); + virtual ~FrameBase(); + + void setSlice(int,int); + + Vector mapFromRef(const Vector&, Coord::InternalSystem); + Vector3d mapFromRef3d(const Vector& vv, Coord::InternalSystem sys) + {return mapFromRef(vv,sys);} + Vector mapToRef(const Vector&, Coord::InternalSystem); + Vector3d mapToRef3d(const Vector& vv, Coord::InternalSystem sys) + {return mapToRef(vv,sys);} + + // Bin Commands + void binToFitCmd(); + + // Block Commands + void blockToFitCmd(); + + // Coordinate Commands + void getCursorCmd(Coord::InternalSystem); + void getCursorCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + + // Grid Commands + void gridCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, + Grid::GridType, const char*, const char*); + + // Fits Commands + void saveFitsResample(OutFitsStream&); + void saveFitsResampleFileCmd(const char*); + void saveFitsResampleChannelCmd(const char*); + void saveFitsResampleSocketCmd(int); + + // IIS Commands + void iisCursorModeCmd(int); + void iisGetCursorCmd(); + void iisGetFileNameCmd(); + void iisGetFileNameCmd(int); + void iisGetFileNameCmd(const Vector&); + void iisMessageCmd(const char*); + void iisSetCursorCmd(const Vector&, Coord::InternalSystem); + void iisSetCursorCmd(const Vector&, Coord::CoordSystem); + void iisSetFileNameCmd(const char*); + void iisSetFileNameCmd(const char*,int); + void iisUpdateCmd() {updateNow(MATRIX);} + + // Pan Zoom Rotate Orient Commands + void panCmd(const Vector&); + void panCmd(const Vector&, const Vector&); + void panCmd(const Vector&, Coord::CoordSystem, Coord::SkyFrame); + void panToCmd(const Vector&); + void panToCmd(const Vector&, Coord::CoordSystem, Coord::SkyFrame); + void panBBoxCmd(const Vector&); + void panEndCmd(const Vector&); + void rotateBeginCmd(); + void rotateMotionCmd(double); + void rotateEndCmd(); + void zoomAboutCmd(const Vector&, const Vector&); + void zoomAboutCmd(const Vector&, const Vector&, Coord::CoordSystem, Coord::SkyFrame); + void zoomToAboutCmd(const Vector&, const Vector&); + void zoomToAboutCmd(const Vector&, const Vector&, Coord::CoordSystem, Coord::SkyFrame); + void zoomToFitCmd(double); + + // 3d + void get3dBorderCmd(); + void get3dBorderColorCmd(); + void get3dCompassCmd(); + void get3dCompassColorCmd(); + void get3dHighliteCmd(); + void get3dHighliteColorCmd(); + void get3dScaleCmd(); + void get3dViewCmd(); + void get3dViewPointCmd(); + void get3dRenderMethodCmd(); + void get3dRenderBackgroundCmd(); +}; + +#endif diff --git a/tksao/frame/framergb.C b/tksao/frame/framergb.C new file mode 100644 index 0000000..a2e2949 --- /dev/null +++ b/tksao/frame/framergb.C @@ -0,0 +1,1722 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "framergb.h" +#include "fitsimage.h" +#include "ps.h" +#include "outfile.h" +#include "outchannel.h" +#include "outsocket.h" + +#include "sigbus.h" + +// Frame Member Functions + +FrameRGB::FrameRGB(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : FrameBase(i,c,item) +{ + context = new Context[3]; + context[0].parent(this); + context[1].parent(this); + context[2].parent(this); + + channel = 0; + rgbSystem = Coord::WCS; + + for (int ii=0; ii<3; ii++) { + view[ii] = 1; + bias[ii] = .5; + contrast[ii] = 1.0; + colorScale[ii] = NULL; + } + + for (int kk=0; kk<3; kk++) + colormapData[kk] = NULL; + + colorCount = 0; + colorCells = NULL; + + currentContext = &context[channel]; + keyContext = &context[channel]; + keyContextSet =0; +} + +FrameRGB::~FrameRGB() +{ + if (context) + delete [] context; + + for (int ii=0; ii<3; ii++) { + if (colorScale[ii]) + delete colorScale[ii]; + } + + for (int kk=0; kk<3; kk++) + if (colormapData[kk]) + delete [] colormapData[kk]; + + if (colorCells) + delete [] colorCells; +} + +void FrameRGB::alignWCS() +{ + if (!wcsAlign_ || !(keyContext->fits) || !keyContext->fits->hasWCS(wcsSystem_)) { + wcsOrientation = Coord::NORMAL; + wcsOrientationMatrix.identity(); + wcsRotation = 0; + } + else + calcAlignWCS(keyContext->fits, wcsSystem_, wcsSky_, + &wcsOrientation, &wcsOrientationMatrix, &wcsRotation); + + updateRGBMatrices(); +} + +void FrameRGB::alignWCS(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + if (!wcsAlign_ || !(keyContext->fits) || !keyContext->fits->hasWCS(sys)) { + wcsOrientation = Coord::NORMAL; + wcsOrientationMatrix.identity(); + wcsRotation = 0; + } + else + calcAlignWCS(keyContext->fits, sys, sky, + &wcsOrientation, &wcsOrientationMatrix, &wcsRotation); + + updateRGBMatrices(); +} + +void FrameRGB::alignWCS(FitsImage* ptr, Coord::CoordSystem sys) +{ + if (!wcsAlign_ || !(keyContext->fits) || !ptr || + !keyContext->fits->hasWCS(wcsSystem_)) { + wcsOrientation = Coord::NORMAL; + wcsOrientationMatrix.identity(); + wcsRotation = 0; + } + else + calcAlignWCS(ptr, keyContext->fits, wcsSystem_, sys, wcsSky_, + &wcsOrientation, &wcsOrientationMatrix, &wcsRotation, &zoom_); + + updateRGBMatrices(); +} + +int FrameRGB::doRender() +{ + return ((context[0].fits&&view[0]) || + (context[1].fits&&view[1]) || + (context[2].fits&&view[2])); +} + +unsigned char* FrameRGB::fillImage(int width, int height, + Coord::InternalSystem sys) +{ + // img + unsigned char* img = new unsigned char[width*height*3]; + memset(img,0,width*height*3); + + // mk + char* mk = new char[width*height]; + memset(mk,0,width*height); + + SETSIGBUS + + // one channel at a time + for (int kk=0; kk<3; kk++) { + if (!view[kk] || !context[kk].fits) + continue; + + // basics + int length = colorScale[kk]->size() - 1; + const unsigned char* table = colorScale[kk]->psColors(); + + FitsImage* sptr = context[kk].cfits; + int mosaic = context[kk].isMosaic(); + + // variable + double* mm = sptr->matrixToData(sys).mm(); + FitsBound* params = sptr->getDataParams(context[kk].secMode()); + int srcw = sptr->width(); + + double ll = sptr->low(); + double hh = sptr->high(); + double diff = hh - ll; + + // main loop + unsigned char* dest = img; + char* mkptr = mk; + + for (long jj=0; jjmatrixToData(sys).mm(); + params = sptr->getDataParams(context[kk].secMode()); + srcw = sptr->width(); + + ll = sptr->low(); + hh = sptr->high(); + diff = hh - ll; + } + + do { + double xx = ii*mm[0] + jj*mm[3] + mm[6]; + double yy = ii*mm[1] + jj*mm[4] + mm[7]; + + if (xx>=params->xmin && xxxmax && + yy>=params->ymin && yyymax) { + double value = sptr->getValueDouble(long(yy)*srcw + long(xx)); + + if (isfinite(diff) && isfinite(value)) { + if (value <= ll) + *(dest+kk) = *table; + else if (value >= hh) + *(dest+kk) = *(table+length); + else + *(dest+kk) = *(table+((int)(((value - ll)/diff * length) +.5))); + *mkptr =2; + } + else if (*mkptr < 2) + *mkptr =1; + + break; + } + else { + if (mosaic) { + sptr = sptr->nextMosaic(); + + if (sptr) { + mm = sptr->matrixToData(sys).mm(); + params = sptr->getDataParams(context[kk].secMode()); + srcw = sptr->width(); + + ll = sptr->low(); + hh = sptr->high(); + diff = hh - ll; + } + } + } + } + while (mosaic && sptr); + } + } + } + + // now fill in bg + { + unsigned char* dest = img; + char* mkptr = mk; + for (int jj=0; jjred; + *(dest+1) = (unsigned char)nanColor->green; + *(dest+2) = (unsigned char)nanColor->blue; + } + else { // bg + *dest = (unsigned char)bgColor->red; + *(dest+1) = (unsigned char)bgColor->green; + *(dest+2) = (unsigned char)bgColor->blue; + } + } + } + CLEARSIGBUS + + // clean up + delete [] mk; + + return img; +} + +BBox FrameRGB::imageBBox(FrScale::SecMode mode) +{ + // returns imageBBox in IMAGE coords + // and extends edge to edge + + updateRGBMatrices(); + + BBox rr; + int first=1; + for (int ii=0; ii<3; ii++) { + if (context[ii].fits) { + FitsImage* ptr = context[ii].fits; + while (ptr) { + FitsBound* params = ptr->getDataParams(mode); + Matrix mm = ptr->wcsToRef() * rgb[ii] * dataToImage; + + Vector aa = Vector(params->xmin,params->ymin) * mm; + if (first) { + rr = BBox(aa,aa); + first = 0; + } + else + rr.bound(aa); + + rr.bound(Vector(params->xmax,params->ymin) * mm); + rr.bound(Vector(params->xmax,params->ymax) * mm); + rr.bound(Vector(params->xmin,params->ymax) * mm); + + ptr = ptr->nextMosaic(); + } + } + } + + return rr; +} + +void FrameRGB::loadRGBCube(MemType which, const char* fn, FitsImage* img) +{ + if (!img || !img->isValid() || !(img->isImage() || img->isPost()) || (img->depth() != 3)) + goto error; + + context[0].bfits_ = img; + + if (img->isPost()) + which = POST; + + switch (which) { + case ALLOC: + if (context[0].bfits_ && context[0].bfits_->isValid()) + context[1].bfits_ = + new FitsImageFitsNextAlloc(&context[1], interp, + fn, context[0].bfits_->fitsFile(),2); + if (context[1].bfits_ && context[1].bfits_->isValid()) + context[2].bfits_ = + new FitsImageFitsNextAlloc(&context[2], interp, + fn, context[1].bfits_->fitsFile(),3); + break; + case ALLOCGZ: + if (context[0].bfits_ && context[0].bfits_->isValid()) + context[1].bfits_ = + new FitsImageFitsNextAllocGZ(&context[1], interp, + fn, context[0].bfits_->fitsFile(),2); + if (context[1].bfits_ && context[1].bfits_->isValid()) + context[2].bfits_ = + new FitsImageFitsNextAllocGZ(&context[2], interp, + fn, context[1].bfits_->fitsFile(),3); + break; + case CHANNEL: + if (context[0].bfits_ && context[0].bfits_->isValid()) + context[1].bfits_ = + new FitsImageFitsNextChannel(&context[1], interp, + fn, context[0].bfits_->fitsFile(),2); + if (context[1].bfits_ && context[1].bfits_->isValid()) + context[2].bfits_ = + new FitsImageFitsNextChannel(&context[2], interp, + fn, context[1].bfits_->fitsFile(),3); + break; + case MMAP: + if (context[0].bfits_ && context[0].bfits_->isValid()) + context[1].bfits_ = + new FitsImageFitsNextMMap(&context[1], interp, + fn, context[0].bfits_->fitsFile(),2); + if (context[1].bfits_ && context[1].bfits_->isValid()) + context[2].bfits_ = + new FitsImageFitsNextMMap(&context[2], interp, + fn, context[1].bfits_->fitsFile(),3); + break; + case SMMAP: + if (context[0].bfits_ && context[0].bfits_->isValid()) + context[1].bfits_ = + new FitsImageFitsNextSMMap(&context[1], interp, + fn, context[0].bfits_->fitsFile(),2); + if (context[1].bfits_ && context[1].bfits_->isValid()) + context[2].bfits_ = + new FitsImageFitsNextSMMap(&context[2], interp, + fn, context[1].bfits_->fitsFile(),3); + break; + case MMAPINCR: + if (context[0].bfits_ && context[0].bfits_->isValid()) + context[1].bfits_ = + new FitsImageFitsNextMMapIncr(&context[1], interp, + fn, context[0].bfits_->fitsFile(),2); + if (context[1].bfits_ && context[1].bfits_->isValid()) + context[2].bfits_ = + new FitsImageFitsNextMMapIncr(&context[2], interp, + fn, context[1].bfits_->fitsFile(),3); + break; + case SHARE: + if (context[0].bfits_ && context[0].bfits_->isValid()) + context[1].bfits_ = + new FitsImageFitsNextShare(&context[1], interp, + fn, context[0].bfits_->fitsFile(),2); + if (context[1].bfits_ && context[1].bfits_->isValid()) + context[2].bfits_ = + new FitsImageFitsNextShare(&context[2], interp, + fn, context[1].bfits_->fitsFile(),3); + break; + case SSHARE: + if (context[0].bfits_ && context[0].bfits_->isValid()) + context[1].bfits_ = + new FitsImageFitsNextSShare(&context[1], interp, + fn, context[0].bfits_->fitsFile(),2); + if (context[1].bfits_ && context[1].bfits_->isValid()) + context[2].bfits_ = + new FitsImageFitsNextSShare(&context[2], interp, + fn, context[1].bfits_->fitsFile(),3); + break; + case SOCKET: + if (context[0].bfits_ && context[0].bfits_->isValid()) + context[1].bfits_ = + new FitsImageFitsNextSocket(&context[1], interp, + fn, context[0].bfits_->fitsFile(),2); + if (context[1].bfits_ && context[1].bfits_->isValid()) + context[2].bfits_ = + new FitsImageFitsNextSocket(&context[2], interp, + fn, context[1].bfits_->fitsFile(),3); + break; + case SOCKETGZ: + if (context[0].bfits_ && context[0].bfits_->isValid()) + context[1].bfits_ = + new FitsImageFitsNextSocketGZ(&context[1], interp, + fn, context[0].bfits_->fitsFile(),2); + if (context[1].bfits_ && context[1].bfits_->isValid()) + context[2].bfits_ = + new FitsImageFitsNextSocketGZ(&context[2], interp, + fn, context[1].bfits_->fitsFile(),3); + break; + case VAR: + if (context[0].bfits_ && context[0].bfits_->isValid()) + context[1].bfits_ = + new FitsImageFitsNextVar(&context[1], interp, + fn, context[0].bfits_->fitsFile(),2); + if (context[1].bfits_ && context[1].bfits_->isValid()) + context[2].bfits_ = + new FitsImageFitsNextVar(&context[2], interp, + fn, context[1].bfits_->fitsFile(),3); + break; + case POST: + if (context[0].bfits_ && context[0].bfits_->isValid()) + context[1].bfits_ = + new FitsImageFitsNextPost(&context[1], interp, + img, context[0].bfits_->baseFile(),2); + if (context[1].bfits_ && context[1].bfits_->isValid()) + context[2].bfits_ = + new FitsImageFitsNextPost(&context[2], interp, + img, context[1].bfits_->baseFile(),3); + break; + case PHOTO: + if (context[0].bfits_ && context[0].bfits_->isValid()) + context[1].bfits_ = + new FitsImagePhotoCubeNext(&context[1], interp, + fn, context[0].bfits_->baseFile(),2); + if (context[1].bfits_ && context[1].bfits_->isValid()) + context[2].bfits_ = + new FitsImagePhotoCubeNext(&context[2], interp, + fn, context[1].bfits_->baseFile(),3); + break; + default: + // na + break; + } + + // is everything ok? + if (context[0].bfits_ && context[0].bfits_->isValid() && + (context[0].bfits_->isImage() || context[0].bfits_->isPost()) && + context[1].bfits_ && context[1].bfits_->isValid() && + (context[1].bfits_->isImage() || context[1].bfits_->isPost()) && + context[2].bfits_ && context[2].bfits_->isValid() && + (context[2].bfits_->isImage() || context[2].bfits_->isPost())) { + + loadRGBFinish(); + return; + } + + error: + context[0].unload(); + context[1].unload(); + context[2].unload(); + + reset(); + updateColorScale(); + + Tcl_AppendResult(interp, "Unable to load rgb cube file", NULL); + result = TCL_ERROR; + return; +} + +void FrameRGB::loadRGBImage(MemType which, const char* fn, FitsImage* img) +{ + FitsImage* r = img; + FitsImage* g = NULL; + FitsImage* b = NULL; + + if (!img || !img->isValid() || !(img->isImage() || img->isPost())) + goto error; + + switch (which) { + case ALLOC: + if (r && r->isValid()) + g = new FitsImageMosaicNextAlloc(&context[1], interp, + fn, r->fitsFile(), + FitsFile::NOFLUSH,1); + if (g && g->isValid()) + b = new FitsImageMosaicNextAlloc(&context[2], interp, + fn, g->fitsFile(), + FitsFile::NOFLUSH,1); + break; + case ALLOCGZ: + if (r && r->isValid()) + g = new FitsImageMosaicNextAllocGZ(&context[1], interp, + fn, r->fitsFile(), + FitsFile::NOFLUSH,1); + if (g && g->isValid()) + b = new FitsImageMosaicNextAllocGZ(&context[2], interp, + fn, g->fitsFile(), + FitsFile::NOFLUSH,1); + break; + case CHANNEL: + if (r && r->isValid()) + g = new FitsImageMosaicNextChannel(&context[1], interp, + fn, r->fitsFile(), + FitsFile::NOFLUSH,1); + if (g && g->isValid()) + b = new FitsImageMosaicNextChannel(&context[2], interp, + fn, g->fitsFile(), + FitsFile::NOFLUSH,1); + break; + case MMAP: + if (r && r->isValid()) + g = new FitsImageMosaicNextMMap(&context[1], interp, + fn, r->fitsFile(),1); + if (g && g->isValid()) + b = new FitsImageMosaicNextMMap(&context[2], interp, + fn, g->fitsFile(),1); + break; + case MMAPINCR: + if (r && r->isValid()) + g = new FitsImageMosaicNextMMapIncr(&context[1], interp, + fn, r->fitsFile(),1); + if (g && g->isValid()) + b = new FitsImageMosaicNextMMapIncr(&context[2], interp, + fn, g->fitsFile(),1); + break; + case SHARE: + if (r && r->isValid()) + g = new FitsImageMosaicNextShare(&context[1], interp, + fn, r->fitsFile(),1); + if (g && g->isValid()) + b = new FitsImageMosaicNextShare(&context[2], interp, + fn, g->fitsFile(),1); + break; + case SOCKET: + if (r && r->isValid()) + g = new FitsImageMosaicNextSocket(&context[1], interp, + fn, r->fitsFile(), + FitsFile::FLUSH,1); + if (g && g->isValid()) + b = new FitsImageMosaicNextSocket(&context[2], interp, + fn,g->fitsFile(), + FitsFile::FLUSH,1); + break; + case SOCKETGZ: + if (r && r->isValid()) + g = new FitsImageMosaicNextSocketGZ(&context[1], interp, + fn, r->fitsFile(), + FitsFile::FLUSH,1); + if (g && g->isValid()) + b = new FitsImageMosaicNextSocketGZ(&context[2], interp, + fn, g->fitsFile(), + FitsFile::FLUSH,1); + break; + case VAR: + if (r && r->isValid()) + g = new FitsImageMosaicNextVar(&context[1], interp, + fn, r->fitsFile(),1); + if (g && g->isValid()) + b = new FitsImageMosaicNextVar(&context[2], interp, + fn, g->fitsFile(),1); + break; + default: + // na + break; + } + + // ok, figure out which is which channel + context[0].bfits_ = context[1].bfits_ = context[2].bfits_ = NULL; + + { + const char* ext = r->fitsFile()->extname(); + if (ext) { + if (!strncmp(ext,"RED",3)) + context[0].bfits_ = r; + else if (!strncmp(ext,"GREEN",3)) { + context[1].bfits_ = r; + r->setContext(&context[1]); + } + else if (!strncmp(ext,"BLUE",3)) { + context[2].bfits_ = r; + r->setContext(&context[2]); + } + else + context[0].bfits_ = r; + } + else + context[0].bfits_ = r; + } + + { + const char* ext = g->fitsFile()->extname(); + if (ext) { + if (!strncmp(ext,"RED",3)) { + context[0].bfits_ = g; + g->setContext(&context[0]); + } + else if (!strncmp(ext,"GREEN",3)) + context[1].bfits_ = g; + else if (!strncmp(ext,"BLUE",3)) { + context[2].bfits_ = g; + g->setContext(&context[3]); + } + else + context[1].bfits_ = g; + } + else + context[1].bfits_ = g; + } + + { + const char* ext = b->fitsFile()->extname(); + if (ext) { + if (!strncmp(ext,"RED",3)) { + context[0].bfits_ = b; + b->setContext(&context[0]); + } + else if (!strncmp(ext,"GREEN",3)) { + context[1].bfits_ = b; + b->setContext(&context[1]); + } + else if (!strncmp(ext,"BLUE",3)) + context[2].bfits_ = b; + else + context[2].bfits_ = b; + } + else + context[2].bfits_ = b; + } + + // is everything ok? + if (context[0].bfits_ && context[0].bfits_->isValid() && + (context[0].bfits_->isImage() || context[0].bfits_->isPost()) && + context[1].bfits_ && context[1].bfits_->isValid() && + (context[1].bfits_->isImage() || context[1].bfits_->isPost()) && + context[2].bfits_ && context[2].bfits_->isValid() && + (context[2].bfits_->isImage() || context[2].bfits_->isPost())) { + + loadRGBFinish(); + return; + } + + error: + context[0].unload(); + context[1].unload(); + context[2].unload(); + + reset(); + updateColorScale(); + + Tcl_AppendResult(interp, "Unable to load rgb image file", NULL); + result = TCL_ERROR; + return; +} + +void FrameRGB::loadRGBFinish() +{ + for (int ii=0; ii<3; ii++) { + context[ii].loadInit(1,NOMOSAIC,Coord::WCS); + context[ii].loadFinish(); + } + + channel = 0; + currentContext = &context[channel]; + keyContext = &context[channel]; + keyContextSet =1; + + alignWCS(); + if (!preservePan) { + centerImage(); + // cursor is in REF, crosshair in REF + crosshair = cursor; + } + updateColorScale(); + update(MATRIX); +} + +void FrameRGB::pushMatrices() +{ + for (int ii=0; ii<3; ii++) { + FitsImage* ptr = context[ii].fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->updateMatrices(rgb[ii], refToUser, userToWidget, + widgetToCanvas, canvasToWindow); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + } +} + +void FrameRGB::pushMagnifierMatrices() +{ + for (int ii=0; ii<3; ii++) { + FitsImage* ptr = context[ii].fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->updateMagnifierMatrices(refToMagnifier); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + } +} + +void FrameRGB::pushPannerMatrices() +{ + for (int ii=0; ii<3; ii++) { + FitsImage* ptr = context[ii].fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->updatePannerMatrices(refToPanner); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + } +} + +void FrameRGB::pushPSMatrices(float scale, int width, int height) +{ + Matrix mx = psMatrix(scale, width, height); + for (int kk=0; kk<3; kk++) + if (context[kk].fits) { + FitsImage* ptr = context[kk].cfits; + while (ptr) { + ptr->updatePS(mx); + ptr = ptr->nextMosaic(); + } + } +} + +void FrameRGB::reset() +{ + for (int ii=0; ii<3; ii++) { + bias[ii] = 0.5; + contrast[ii] = 1.0; + context[ii].resetSecMode(); + context[ii].updateClip(); + } + + Base::reset(); +} + +void FrameRGB::rgbAlignWCS(int ii) +{ + if (keyContext->fits && keyContext->fits->hasWCS(rgbSystem)) + rgb[ii] = calcAlignWCS(keyContext->fits, context[ii].fits, rgbSystem, rgbSystem, Coord::FK5); + + if (DebugRGB) + cerr << "rgbAlignWCS " << rgb[ii] << endl; +} + +void FrameRGB::setBinCursor() +{ + for (int ii=0; ii<3; ii++) + if (context[ii].fits) + context[ii].fits->setBinCursor(cursor); +} + +void FrameRGB::updateColorCells(unsigned char* cells, int cnt) +{ + if (DebugRGB) + cerr << "updateColorCells" << endl; + + colorCount = cnt; + if (colorCells) + delete [] colorCells; + colorCells = new unsigned char[cnt*3]; + if (!colorCells) { + internalError("Unable to Alloc colorCells"); + return; + } + memcpy(colorCells, cells, cnt*3); +} + +void FrameRGB::updateColorScale() +{ + // we need colors before we can construct a scale + if (!colorCells) + return; + + if (DebugRGB) + cerr << "updateColorScale" << endl; + + for (int ii=0; ii<3; ii++) { + if (colorScale[ii]) + delete colorScale[ii]; + + switch (context[ii].colorScaleType()) { + case FrScale::LINEARSCALE: + colorScale[ii] = + new LinearScaleRGB(ii, colorCount, colorCells, colorCount); + break; + case FrScale::LOGSCALE: + colorScale[ii] = + new LogScaleRGB(ii, SCALESIZE, colorCells, colorCount, + context[ii].expo()); + break; + case FrScale::POWSCALE: + colorScale[ii] = + new PowScaleRGB(ii, SCALESIZE, colorCells, colorCount, + context[ii].expo()); + break; + case FrScale::SQRTSCALE: + colorScale[ii] = + new SqrtScaleRGB(ii, SCALESIZE, colorCells, colorCount); + break; + case FrScale::SQUAREDSCALE: + colorScale[ii] = + new SquaredScaleRGB(ii, SCALESIZE, colorCells, colorCount); + break; + case FrScale::ASINHSCALE: + colorScale[ii] = + new AsinhScaleRGB(ii, SCALESIZE, colorCells, colorCount); + break; + case FrScale::SINHSCALE: + colorScale[ii] = + new SinhScaleRGB(ii, SCALESIZE, colorCells, colorCount); + break; + case FrScale::HISTEQUSCALE: + colorScale[ii] = + new HistEquScaleRGB(ii, SCALESIZE, colorCells, colorCount, + context[ii].histequ(), HISTEQUSIZE); + break; + case FrScale::IISSCALE: + // na + break; + } + } +} + + +void FrameRGB::updateRGBMatrices() +{ + // image,pysical,amplifier,detector are ok, check for wcs + if (rgbSystem >= Coord::WCS) { + for (int ii=0; ii<3; ii++) { + if (context[ii].fits && !context[ii].fits->hasWCS(rgbSystem)) { + // ok, don't have requested coordinate system + // down grade to image + rgbSystem = Coord::IMAGE; + break; + } + } + } + + // rgb align + for (int ii=0; ii<3; ii++) { + rgb[ii].identity(); + + if (context[ii].fits && keyContext->fits) { + switch (rgbSystem) { + case Coord::IMAGE: + // nothing to do here + break; + case Coord::PHYSICAL: + if (context[ii].fits != keyContext->fits) + rgb[ii] = + context[ii].fits->imageToPhysical * + keyContext->fits->physicalToImage; + break; + case Coord::AMPLIFIER: + if (context[ii].fits != keyContext->fits) + rgb[ii] = context[ii].fits->imageToAmplifier * + keyContext->fits->amplifierToImage; + break; + case Coord::DETECTOR: + if (context[ii].fits != keyContext->fits) + rgb[ii] = context[ii].fits->imageToDetector * + keyContext->fits->detectorToImage; + break; + default: + rgbAlignWCS(ii); + break; + } + } + + if (DebugRGB) + cerr << "rgb[" << ii << "] " << rgb[ii] << endl; + } +} + +void FrameRGB::unloadAllFits() +{ + if (DebugPerf) + cerr << "FrameRGB::unloadAllFits()" << endl; + + for (int ii=0; ii<3; ii++) { + rgb[ii].identity(); + context[ii].unload(); + + // always (for HISTEQU and LOG) + updateColorScale(); + } + + channel =0; + currentContext = &context[channel]; + keyContext = &context[channel]; + keyContextSet =0; + + FrameBase::unloadFits(); +} + +void FrameRGB::unloadFits() +{ + if (DebugPerf) + cerr << "FrameRGB::unloadFits()" << endl; + + rgb[channel].identity(); + context[channel].unload(); + + // always (for HISTEQU and LOG) + updateColorScale(); +} + +// Commands + +void FrameRGB::colormapCmd(float rb, float gb, float bb, + float rc, float gc, float bc, int i, + unsigned char* cells, int cnt) +{ + bias[0] = rb; + bias[1] = gb; + bias[2] = bb; + contrast[0] = rc; + contrast[1] = gc; + contrast[2] = bc; + invert = i; + + updateColorCells(cells, cnt); + updateColorScale(); + update(BASE); +} + +void FrameRGB::colormapBeginCmd() +{ + // we need a colorScale before we can render + if (!validColorScale()) + return; + + // we need some fits data + // we assume the colorScale length will not change during motion calls + if (!context[0].fits && !context[1].fits && !context[2].fits) + return; + + int width = options->width; + int height = options->height; + + // Create XImage + if (!(colormapXM = XGetImage(display, pixmap, 0, 0, + width, height, AllPlanes, ZPixmap))) { + internalError("Unable to Create Colormap XImage"); + return; + } + + // Create Pixmap + colormapPM = + Tk_GetPixmap(display, Tk_WindowId(tkwin), width, height, depth); + if (!colormapPM) { + internalError("Unable to Create Colormap Pixmap"); + return; + } + + // colormapGCXOR + colormapGCXOR = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + + // Create table index array + for (int kk=0; kk<3; kk++) { + if (colormapData[kk]) + delete [] colormapData[kk]; + colormapData[kk] = new long[width*height]; + + if (!colormapData[kk]) { + internalError("Unable to alloc tmp data array"); + return; + } + } + + SETSIGBUS + + // fill data array + for (int kk=0; kk<3; kk++) { + if (!view[kk] || !context[kk].fits) + continue; + + // basics + int length = colorScale[kk]->size() - 1; + + FitsImage* sptr = context[kk].cfits; + int mosaic = context[kk].isMosaic(); + + // variable + double* mm = sptr->matrixToData(Coord::WIDGET).mm(); + FitsBound* params = sptr->getDataParams(context[kk].secMode()); + int srcw = sptr->width(); + + double ll = sptr->low(); + double hh = sptr->high(); + double diff = hh - ll; + + // main loop + long* dest = colormapData[kk]; + + for (long jj=0; jjmatrixToData(Coord::WIDGET).mm(); + params = sptr->getDataParams(context[kk].secMode()); + srcw = sptr->width(); + + ll = sptr->low(); + hh = sptr->high(); + diff = hh - ll; + } + + do { + double xx = ii*mm[0] + jj*mm[3] + mm[6]; + double yy = ii*mm[1] + jj*mm[4] + mm[7]; + + if (xx>=params->xmin && xxxmax && + yy>=params->ymin && yyymax) { + double value = sptr->getValueDouble(long(yy)*srcw + long(xx)); + + if (isfinite(diff) && isfinite(value)) { + if (value <= ll) + *dest = 0; + else if (value >= hh) + *dest = length; + else + *dest = (int)(((value - ll)/diff * length) + .5); + } + else + *dest = -1; // nan + + break; + } + else { + if (mosaic) { + sptr = sptr->nextMosaic(); + + if (sptr) { + mm = sptr->matrixToData(Coord::WIDGET).mm(); + params = sptr->getDataParams(context[kk].secMode()); + srcw = sptr->width(); + + ll = sptr->low(); + hh = sptr->high(); + diff = hh - ll; + } + } + } + } + while (mosaic && sptr); + } + } + } + CLEARSIGBUS +} + +void FrameRGB::colormapEndCmd() +{ + if (colormapXM) { + XDestroyImage(colormapXM); + colormapXM = NULL; + } + + if (colormapPM) { + Tk_FreePixmap(display, colormapPM); + colormapPM = 0; + } + + if (colormapGCXOR) { + XFreeGC(display, colormapGCXOR); + colormapGCXOR = 0; + } + + for (int kk=0; kk<3; kk++) + if (colormapData[kk]) { + delete [] colormapData[kk]; + colormapData[kk] = NULL; + } + + update(BASE); // always update +} + +void FrameRGB::colormapMotionCmd(float rb, float gb, float bb, + float rc, float gc, float bc, int i, + unsigned char* cells, int cnt) +{ + // we need a colorScale before we can render + if (!validColorScale()) + return; + + // first check for change + if (bias[0] == rb && bias[1] == gb && bias[2] == bb && + contrast[0] == rc && contrast[1] == gc && contrast[2] == bc && + invert == i && colorCells) + return; + + // we got a change + bias[0] = rb; + bias[1] = gb; + bias[2] = bb; + contrast[0] = rc; + contrast[1] = gc; + contrast[2] = bc; + invert = i; + + updateColorCells(cells, cnt); + updateColorScale(); + + // special case + if ((!view[0] || !context[0].fits) && + (!view[1] || !context[1].fits) && + (!view[2] || !context[2].fits)) + return; + + int& width = colormapXM->width; + int& height = colormapXM->height; + + // create img + unsigned char* img = new unsigned char[width*height*3]; + memset(img, 0, width*height*3); + char* mk = new char[width*height]; + memset(mk, 0, width*height); + + for (int kk=0; kk<3; kk++) { + if (!view[kk] || !context[kk].fits) + continue; + + const unsigned char* table = colorScale[kk]->psColors(); + long* src = colormapData[kk]; + unsigned char* dest = img; + char* mptr = mk; + for (long jj=0; jj= 0) { + memcpy(dest+kk, table+(*src), 1); + *mptr = 2; + } + else if (*src == -1 && *mptr < 2) + *mptr = 1; + } + + // set remainder to bg + { + unsigned char* dest = img; + char* mptr = mk; + for (long jj=0; jjred; + *(dest+1) = (unsigned char)nanColor->green; + *(dest+2) = (unsigned char)nanColor->blue; + } + else { // bg + *(dest ) = (unsigned char)bgColor->red; + *(dest+1) = (unsigned char)bgColor->green; + *(dest+2) = (unsigned char)bgColor->blue; + } + } + + // build colormapXM + encodeTrueColor((unsigned char*)img, colormapXM); + + // clean up + if (img) + delete [] img; + if (mk) + delete [] mk; + + // XImage to Pixmap + TkPutImage(NULL, 0, display, colormapPM, widgetGC, colormapXM, + 0, 0, 0, 0, width, height); + + // Display Pixmap + Vector dd = Vector() * widgetToWindow; + XCopyArea(display, colormapPM, Tk_WindowId(tkwin), colormapGCXOR, 0, 0, + width, height, dd[0], dd[1]); + + // update panner + updatePanner(); +} + +void FrameRGB::getColorbarCmd() +{ + ostringstream str; + + str << "rgb " << fixed; + for (int ii=0; ii<3; ii++) + str << bias[ii] << ' '; + for (int ii=0; ii<3; ii++) + str << contrast[ii] << ' '; + str << invert << ' ' << ends; + + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void FrameRGB::getInfoCmd(const Vector& vv, Coord::InternalSystem ref, char* var) +{ + FrameBase::getInfoCmd(vv, ref, var); + if (!currentContext->cfits) + return; + + const char* array[3] = {"value,red","value,green","value,blue"}; + + SETSIGBUS + for (int ii=0; ii<3; ii++) { + + // make sure we have an image + FitsImage* sptr = context[ii].cfits; + if (!sptr) + continue; + + int mosaic = context[ii].isMosaic(); + FitsBound* params = sptr->getDataParams(context[ii].secMode()); + + do { + Vector3d rr = mapToRef3d(vv,ref); + Vector img = Vector(rr) * sptr->refToData; + + if (img[0]>=params->xmin && img[0]xmax && + img[1]>=params->ymin && img[1]ymax) { + + Tcl_SetVar2(interp,var,array[ii],(char*)sptr->getValue(img),0); + break; + } + else { + if (mosaic) { + sptr = sptr->nextMosaic(); + if (sptr) + params = sptr->getDataParams(context[ii].secMode()); + } + } + } + while (mosaic && sptr); + } + CLEARSIGBUS +} + +void FrameRGB::getRGBChannelCmd() +{ + switch (channel) { + case 0: + Tcl_AppendResult(interp, "red", NULL); + return; + case 1: + Tcl_AppendResult(interp, "green", NULL); + return; + case 2: + Tcl_AppendResult(interp, "blue", NULL); + return; + } +} + +void FrameRGB::getRGBSystemCmd() +{ + printCoordSystem(rgbSystem); +} + +void FrameRGB::getRGBViewCmd() +{ + for (int ii=0; ii<3; ii++) + Tcl_AppendElement(interp, view[ii] ? "1" : "0"); +} + +void FrameRGB::getTypeCmd() +{ + Tcl_AppendResult(interp, "rgb", NULL); +} + +// RGBCube FITS + +void FrameRGB::loadRGBCubeAllocCmd(const char* ch, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageFitsAlloc(&context[0], interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadRGBCube(ALLOC,fn,img); +} + +void FrameRGB::loadRGBCubeAllocGZCmd(const char* ch, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageFitsAllocGZ(&context[0], interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadRGBCube(ALLOCGZ,fn,img); +} + +void FrameRGB::loadRGBCubeChannelCmd(const char* ch, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageFitsChannel(&context[0], interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadRGBCube(CHANNEL,fn,img); +} + +void FrameRGB::loadRGBCubeMMapCmd(const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageFitsMMap(&context[0], interp, fn, 1); + loadRGBCube(MMAP,fn,img); +} + +void FrameRGB::loadRGBCubeSMMapCmd(const char* hdr, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageFitsSMMap(&context[0], interp, hdr, fn, 1); + loadRGBCube(SMMAP,fn,img); +} + +void FrameRGB::loadRGBCubeMMapIncrCmd(const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageFitsMMapIncr(&context[0], interp, fn, 1); + loadRGBCube(MMAPINCR,fn,img); +} + +void FrameRGB::loadRGBCubeShareCmd(ShmType type, int id, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageFitsShare(&context[0], interp, type, id, fn, 1); + loadRGBCube(SHARE,fn,img); +} + +void FrameRGB::loadRGBCubeSShareCmd(ShmType type, int hdr, int id, + const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageFitsSShare(&context[0], interp, + type, hdr, id, fn, 1); + loadRGBCube(SSHARE,fn,img); +} + +void FrameRGB::loadRGBCubeSocketCmd(int s, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageFitsSocket(&context[0], interp, + s, fn, FitsFile::FLUSH, 1); + loadRGBCube(SOCKET,fn,img); +} + +void FrameRGB::loadRGBCubeSocketGZCmd(int s, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageFitsSocketGZ(&context[0], interp, + s, fn, FitsFile::FLUSH, 1); + loadRGBCube(SOCKETGZ,fn,img); +} + +void FrameRGB::loadRGBCubeVarCmd(const char* ch, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageFitsVar(&context[0], interp, ch, fn, 1); + loadRGBCube(VAR,fn,img); +} + +// RGBImage FITS + +void FrameRGB::loadRGBImageAllocCmd(const char* ch, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageMosaicAlloc(&context[0], interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadRGBImage(ALLOC,fn,img); +} + +void FrameRGB::loadRGBImageAllocGZCmd(const char* ch, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageMosaicAllocGZ(&context[0], interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadRGBImage(ALLOCGZ,fn,img); +} + +void FrameRGB::loadRGBImageChannelCmd(const char* ch, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageMosaicChannel(&context[0], interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadRGBImage(CHANNEL,fn,img); +} + +void FrameRGB::loadRGBImageMMapCmd(const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageMosaicMMap(&context[0], interp, fn, 1); + loadRGBImage(MMAP,fn,img); +} + +void FrameRGB::loadRGBImageMMapIncrCmd(const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageMosaicMMapIncr(&context[0], interp, fn, 1); + loadRGBImage(MMAPINCR,fn,img); +} + +void FrameRGB::loadRGBImageShareCmd(ShmType type, int id, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageMosaicShare(&context[0], interp, + type, id, fn, 1); + loadRGBImage(SHARE,fn,img); +} + +void FrameRGB::loadRGBImageSocketCmd(int s, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageMosaicSocket(&context[0], interp, + s, fn, FitsFile::FLUSH, 1); + loadRGBImage(SOCKET,fn,img); +} + +void FrameRGB::loadRGBImageSocketGZCmd(int s, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageMosaicSocketGZ(&context[0], interp, + s, fn, FitsFile::FLUSH, 1); + loadRGBImage(SOCKETGZ,fn,img); +} + +void FrameRGB::loadRGBImageVarCmd(const char* ch, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageMosaicVar(&context[0], interp, ch, fn, 1); + loadRGBImage(VAR,fn,img); +} + +// RGBCube Array + +void FrameRGB::loadArrayRGBCubeAllocCmd(const char* ch, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageArrAlloc(&context[0], interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadRGBCube(ALLOC,fn,img); +} + +void FrameRGB::loadArrayRGBCubeAllocGZCmd(const char* ch, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageArrAllocGZ(&context[0], interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadRGBCube(ALLOCGZ,fn,img); +} + +void FrameRGB::loadArrayRGBCubeChannelCmd(const char* ch, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageArrChannel(&context[0], interp, ch, fn, + FitsFile::NOFLUSH, 1); + loadRGBCube(CHANNEL,fn,img); +} + +void FrameRGB::loadArrayRGBCubeMMapCmd(const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageArrMMap(&context[0], interp, fn, 1); + loadRGBCube(MMAP,fn,img); +} + +void FrameRGB::loadArrayRGBCubeMMapIncrCmd(const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageArrMMapIncr(&context[0], interp, fn, 1); + loadRGBCube(MMAPINCR,fn,img); +} + +void FrameRGB::loadArrayRGBCubeShareCmd(ShmType type, int id, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageArrShare(&context[0], interp, + type, id, fn, 1); + loadRGBCube(SHARE,fn,img); +} + +void FrameRGB::loadArrayRGBCubeSocketCmd(int s, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageArrSocket(&context[0], interp, + s, fn, FitsFile::FLUSH, 1); + loadRGBCube(SOCKET,fn,img); +} + +void FrameRGB::loadArrayRGBCubeSocketGZCmd(int s, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageArrSocketGZ(&context[0], interp, + s, fn, FitsFile::FLUSH, 1); + loadRGBCube(SOCKETGZ,fn,img); +} + +void FrameRGB::loadArrayRGBCubeVarCmd(const char* ch, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImageArrVar(&context[0], interp, ch, fn, 1); + loadRGBCube(VAR,fn,img); +} + +// RGBPhoto + +void FrameRGB::loadPhotoCmd(const char* ph, const char* fn) +{ + unloadAllFits(); + FitsImage* img = new FitsImagePhotoCube(&context[0], interp, ph, fn, 1); + loadRGBCube(ALLOC,fn,img); +} + +void FrameRGB::saveFitsRGBImageFileCmd(const char* fn) +{ + if (keyContext->fits) { + OutFitsFile str(fn); + saveFitsRGBImage(str); + } +} + +void FrameRGB::saveFitsRGBImageChannelCmd(const char* ch) +{ + if (keyContext->fits) { + OutFitsChannel str(interp, ch); + saveFitsRGBImage(str); + } +} + +void FrameRGB::saveFitsRGBImageSocketCmd(int ss) +{ + if (keyContext->fits) { + OutFitsSocket str(ss); + saveFitsRGBImage(str); + } +} + +void FrameRGB::saveFitsRGBCubeFileCmd(const char* fn) +{ + if (keyContext->fits) { + OutFitsFile str(fn); + saveFitsRGBCube(str); + } +} + +void FrameRGB::saveFitsRGBCubeChannelCmd(const char* ch) +{ + if (keyContext->fits) { + OutFitsChannel str(interp, ch); + saveFitsRGBCube(str); + } +} + +void FrameRGB::saveFitsRGBCubeSocketCmd(int ss) +{ + if (keyContext->fits) { + OutFitsSocket str(ss); + saveFitsRGBCube(str); + } +} + +void FrameRGB::saveArrayRGBCubeFileCmd(const char* fn, FitsFile::ArchType endian) +{ + if (keyContext->fits) { + OutFitsFile str(fn); + saveArrayRGBCube(str, endian); + } +} + +void FrameRGB::saveArrayRGBCubeChannelCmd(const char* ch, FitsFile::ArchType endian) +{ + if (keyContext->fits) { + OutFitsChannel str(interp, ch); + saveArrayRGBCube(str, endian); + } +} + +void FrameRGB::saveArrayRGBCubeSocketCmd(int ss, FitsFile::ArchType endian) +{ + if (keyContext->fits) { + OutFitsSocket str(ss); + saveArrayRGBCube(str, endian); + } +} + +void FrameRGB::savePhotoCmd(const char* ph) +{ + // need to determine size from key context + FitsImage* fits = keyContext->fits; + if (!fits) + return; + + // check size + FitsBound* params = fits->getDataParams(context->secMode()); + for (int kk=0; kk<3; kk++) { + if (!view[kk] || !context[kk].fits) + continue; + + FitsImage* ptr = context[kk].fits; + FitsBound* pptr = ptr->getDataParams(context[kk].secMode()); + if (params->xmin != pptr->xmin || params->xmax != pptr->xmax || + params->ymin != pptr->ymin || params->ymax != pptr->ymax) { + internalError("All channels need to be same size."); + return; + } + } + + // width,height + int width = params->xmax - params->xmin; + int height = params->ymax - params->ymin; + + // photo + if (*ph == '\0') { + Tcl_AppendResult(interp, "bad image name ", NULL); + return; + } + Tk_PhotoHandle photo = Tk_FindPhoto(interp, ph); + if (!photo) { + Tcl_AppendResult(interp, "bad image handle ", NULL); + return; + } + if (Tk_PhotoSetSize(interp, photo, width, height) != TCL_OK) { + Tcl_AppendResult(interp, "bad photo set size ", NULL); + return; + } + Tk_PhotoBlank(photo); + Tk_PhotoImageBlock block; + if (!Tk_PhotoGetImage(photo,&block)) { + Tcl_AppendResult(interp, "bad image block ", NULL); + return; + } + + if (block.pixelSize<4) { + Tcl_AppendResult(interp, "bad pixel size ", NULL); + return; + } + + // clear, set alpha channel + unsigned char* dest = block.pixelPtr; + for (long jj=0; jjsize() - 1; + const unsigned char* table = colorScale[kk]->psColors(); + + // variable + FitsImage* fits = context[kk].cfits; + double ll = fits->low(); + double hh = fits->high(); + double diff = hh - ll; + + unsigned char* dest = block.pixelPtr; + for (long jj=params->ymax-1; jj>=params->ymin; jj--) { + for (long ii=params->xmin; iixmax; ii++, dest+=block.pixelSize) { + double value = fits->getValueDouble(Vector(ii,jj)); + + if (isfinite(diff) && isfinite(value)) { + if (value <= ll) + *(dest+block.offset[kk]) = table[0]; + else if (value >= hh) + *(dest+block.offset[kk]) = table[length]; + else + *(dest+block.offset[kk]) = table[(int)(((value - ll)/diff * length) + .5)]; + } + } + } + } + CLEARSIGBUS + + if (Tk_PhotoPutBlock(interp, photo, &block, 0, 0, width, height, + TK_PHOTO_COMPOSITE_SET) != TCL_OK) { + Tcl_AppendResult(interp, "bad put block ", NULL); + return; + } +} + +void FrameRGB::setRGBChannelCmd(const char* c) +{ + if (!strncmp(c,"red",3)) + channel = 0; + else if (!strncmp(c,"gre",3)) + channel = 1; + else if (!strncmp(c,"blu",3)) + channel = 2; + else + channel = 0; + + currentContext = &context[channel]; + + // execute any update callbacks + updateCBMarkers(&userMarkers); + updateCBMarkers(&catalogMarkers); + // updateCBMarkers(&analysisMarkers); + + // always update + update(BASE); +} + +void FrameRGB::setRGBSystemCmd(Coord::CoordSystem sys) +{ + rgbSystem = sys; + + // save current matrix + Matrix old[3]; + for (int ii=0; ii<3; ii++) + old[ii] = rgb[ii]; + + alignWCS(); + + // fix any contours + for (int ii=0; ii<3; ii++) { + Matrix mm = old[ii].invert() * rgb[ii]; + context[ii].updateContours(mm); + } + + update(MATRIX); +} + +void FrameRGB::setRGBViewCmd(int r, int g, int b) +{ + view[0] = r ? 1 : 0; + view[1] = g ? 1 : 0; + view[2] = b ? 1 : 0; + + update(BASE); // always update +} diff --git a/tksao/frame/framergb.h b/tksao/frame/framergb.h new file mode 100644 index 0000000..b0ce1bc --- /dev/null +++ b/tksao/frame/framergb.h @@ -0,0 +1,150 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __framergb_h__ +#define __framergb_h__ + +#include "context.h" +#include "framebase.h" +#include "colorscalergb.h" + +// Frame + +class FrameRGB : public FrameBase { + protected: + int channel; // current channel + Coord::CoordSystem rgbSystem; // alignment coordinate system + Matrix rgb[3]; // rgb matrix + + long* colormapData[3]; // preextract data + + int view[3]; // visible channels + float bias[3]; // current colormap bias + float contrast[3]; // current colormap contrast + ColorScaleRGB* colorScale[3]; // current color scale + + int colorCount; // number of dynamic colors + unsigned char* colorCells; // current color values + + private: + void alignWCS(); + void alignWCS(Coord::CoordSystem, Coord::SkyFrame); + void alignWCS(FitsImage*, Coord::CoordSystem); + + int doRender(); + + BBox imageBBox(FrScale::SecMode); + + void loadRGBCube(MemType, const char*, FitsImage*); + void loadRGBImage(MemType, const char*, FitsImage*); + void loadRGBFinish(); + + void reset(); + void rgbAlignWCS(int); + + void setBinCursor(); + void setKeyFits(); + + void unloadFits(); + + void pushMatrices(); + void pushMagnifierMatrices(); + void pushPannerMatrices(); + void pushPSMatrices(float, int, int); + + void updateRGBMatrices(); + + protected: + int isFrameRGB() {return 1;} + + unsigned char* fillImage(int, int, Coord::InternalSystem); + void updateColorCells(unsigned char*, int); + void updateColorScale(); + void unloadAllFits(); + + int validColorScale() + {return colorScale[0] && colorScale[1] && colorScale[2];} + + public: + FrameRGB(Tcl_Interp*, Tk_Canvas, Tk_Item*); + virtual ~FrameRGB(); + + void getColorbarCmd(); + void getInfoCmd(const Vector&, Coord::InternalSystem, char*); + void getRGBChannelCmd(); + void getRGBSystemCmd(); + void getRGBViewCmd(); + void getTypeCmd(); + + void colormapCmd(float, float, float, float, float, float, int, + unsigned char*, int); + void colormapBeginCmd(); + void colormapEndCmd(); + void colormapMotionCmd(float, float, float, float, float, float, int, + unsigned char*, int); + + void iisCmd(int, int) {} + void iisEraseCmd() {} + void iisGetCmd(char*, int, int, int, int) {} + void iisSetCmd(const char*, int, int, int, int) {} + void iisWCSCmd(const Matrix&, const Vector&, int) {} + + void loadPhotoCmd(const char*, const char*); + void loadSlicePhotoCmd(const char*, const char*) {} + + void loadRGBCubeAllocCmd(const char*, const char*); + void loadRGBCubeAllocGZCmd(const char*, const char*); + void loadRGBCubeChannelCmd(const char*, const char*); + void loadRGBCubeMMapCmd(const char*); + void loadRGBCubeSMMapCmd(const char*, const char*); + void loadRGBCubeMMapIncrCmd(const char*); + void loadRGBCubeShareCmd(ShmType, int, const char*); + void loadRGBCubeSShareCmd(ShmType, int, int, const char*); + void loadRGBCubeSocketCmd(int, const char*); + void loadRGBCubeSocketGZCmd(int, const char*); + void loadRGBCubeVarCmd(const char*, const char*); + + void loadRGBImageAllocCmd(const char*, const char*); + void loadRGBImageAllocGZCmd(const char*, const char*); + void loadRGBImageChannelCmd(const char*, const char*); + void loadRGBImageMMapCmd(const char*); + void loadRGBImageMMapIncrCmd(const char*); + void loadRGBImageShareCmd(ShmType, int, const char*); + void loadRGBImageSocketCmd(int, const char*); + void loadRGBImageSocketGZCmd(int, const char*); + void loadRGBImageVarCmd(const char*, const char*); + + void loadArrayRGBCubeAllocCmd(const char*, const char*); + void loadArrayRGBCubeAllocGZCmd(const char*, const char*); + void loadArrayRGBCubeChannelCmd(const char*, const char*); + void loadArrayRGBCubeMMapCmd(const char*); + void loadArrayRGBCubeMMapIncrCmd(const char*); + void loadArrayRGBCubeShareCmd(ShmType, int, const char*); + void loadArrayRGBCubeSocketCmd(int, const char*); + void loadArrayRGBCubeSocketGZCmd(int, const char*); + void loadArrayRGBCubeVarCmd(const char*, const char*); + + void saveFitsRGBImage(OutFitsStream&); + void saveFitsRGBImageFileCmd(const char*); + void saveFitsRGBImageChannelCmd(const char*); + void saveFitsRGBImageSocketCmd(int); + + void saveFitsRGBCube(OutFitsStream&); + void saveFitsRGBCubeFileCmd(const char*); + void saveFitsRGBCubeChannelCmd(const char*); + void saveFitsRGBCubeSocketCmd(int); + + void saveArrayRGBCube(OutFitsStream&, FitsFile::ArchType); + void saveArrayRGBCubeFileCmd(const char*, FitsFile::ArchType); + void saveArrayRGBCubeChannelCmd(const char*, FitsFile::ArchType); + void saveArrayRGBCubeSocketCmd(int, FitsFile::ArchType); + + void savePhotoCmd(const char*); + + void setRGBChannelCmd(const char*); + void setRGBViewCmd(int, int, int); + void setRGBSystemCmd(Coord::CoordSystem); +}; + +#endif diff --git a/tksao/frame/framergbtruecolor16.C b/tksao/frame/framergbtruecolor16.C new file mode 100644 index 0000000..8aac133 --- /dev/null +++ b/tksao/frame/framergbtruecolor16.C @@ -0,0 +1,114 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "framergbtruecolor16.h" +#include "fitsimage.h" + +// Tk Canvas Widget Function Declarations + +int FrameRGBTrueColor16CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int, + Tcl_Obj *const []); + +// FrameRGBTrueColor16 Specs + +static Tk_CustomOption tagsOption = { + Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL +}; + +static Tk_ConfigSpec frameRGBTrueColor16Specs[] = { + + {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "framergb", + Tk_Offset(WidgetOptions, cmdName), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1", + Tk_Offset(WidgetOptions, x), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1", + Tk_Offset(WidgetOptions, y), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512", + Tk_Offset(WidgetOptions, width), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "512", + Tk_Offset(WidgetOptions, height), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw", + Tk_Offset(WidgetOptions, anchor), 0, NULL}, + {TK_CONFIG_CUSTOM, (char*)"-tags", NULL, NULL, NULL, + 0, TK_CONFIG_NULL_OK, &tagsOption}, + + {TK_CONFIG_STRING, (char*)"-helvetica", NULL, NULL, "helvetica", + Tk_Offset(WidgetOptions, helvetica), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier", + Tk_Offset(WidgetOptions, courier), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times", + Tk_Offset(WidgetOptions, times), 0, NULL}, + + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}, +}; + +// Tk Static Structure + +static Tk_ItemType frameRGBTrueColor16Type = { + (char*)"framergbtruecolor16", // name + sizeof(WidgetOptions), // item size + FrameRGBTrueColor16CreateProc, // configProc + frameRGBTrueColor16Specs, // configSpecs + WidgetConfigProc, // configProc + WidgetCoordProc, // coordProc + WidgetDeleteProc, // deleteProc + WidgetDisplayProc, // displayProc + 0, // alwaysRedraw + WidgetPointProc, // pointProc + WidgetAreaProc, // areaProc + WidgetPostscriptProc, // postscriptProc + WidgetScaleProc, // scaleProc + WidgetTranslateProc, // translateProc + (Tk_ItemIndexProc*)NULL, // indexProc + WidgetICursorProc, // icursorProc + (Tk_ItemSelectionProc*)NULL, // selectionProc + (Tk_ItemInsertProc*)NULL, // insertProc + (Tk_ItemDCharsProc*)NULL, // dCharsProc + (Tk_ItemType*)NULL // nextPtr +}; + +// Non-Member Functions + +int FrameRGBTrueColor16_Init(Tcl_Interp* interp) +{ + Tk_CreateItemType(&frameRGBTrueColor16Type); + return TCL_OK; +} + +int FrameRGBTrueColor16CreateProc(Tcl_Interp* interp, Tk_Canvas canvas, + Tk_Item* item, int argc, + Tcl_Obj *const argv[]) +{ + FrameRGBTrueColor16* frame = new FrameRGBTrueColor16(interp, canvas, item); + + // and set default configuration + + if (frame->configure(argc, (const char**)argv, 0) != TCL_OK) { + delete frame; + Tcl_AppendResult(interp, " error occured while creating frame.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// FrameRGBTrueColor16 Member Functions + +FrameRGBTrueColor16::FrameRGBTrueColor16(Tcl_Interp* i, Tk_Canvas c, + Tk_Item* item) + : FrameRGB(i,c,item), TrueColor16(visual) +{ + configSpecs = frameRGBTrueColor16Specs; // frame configure options +} + +FrameRGBTrueColor16::~FrameRGBTrueColor16() +{ + // we must do this at this level, because updateColorScale is called + unloadAllFits(); +} + + + + + diff --git a/tksao/frame/framergbtruecolor16.h b/tksao/frame/framergbtruecolor16.h new file mode 100644 index 0000000..685b5dc --- /dev/null +++ b/tksao/frame/framergbtruecolor16.h @@ -0,0 +1,23 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __framergbtruecolor16_h__ +#define __framergbtruecolor16_h__ + +#include "framergb.h" +#include "truecolor16.h" + +class FrameRGBTrueColor16 : public FrameRGB, public TrueColor16 { + private: + void encodeTrueColor(XColor* src, char* dest) + {TrueColor16::encodeTrueColor(src,dest,baseXImage);} + void encodeTrueColor(unsigned char* src, XImage* ximage) + {TrueColor16::encodeTrueColor(src, ximage);} + + public: + FrameRGBTrueColor16(Tcl_Interp*, Tk_Canvas, Tk_Item*); + ~FrameRGBTrueColor16(); +}; + +#endif diff --git a/tksao/frame/framergbtruecolor24.C b/tksao/frame/framergbtruecolor24.C new file mode 100644 index 0000000..929d3a5 --- /dev/null +++ b/tksao/frame/framergbtruecolor24.C @@ -0,0 +1,114 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "framergbtruecolor24.h" +#include "fitsimage.h" + +// Tk Canvas Widget Function Declarations + +int FrameRGBTrueColor24CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int, + Tcl_Obj *const []); + +// FrameRGBTrueColor24 Specs + +static Tk_CustomOption tagsOption = { + Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL +}; + +static Tk_ConfigSpec frameRGBTrueColor24Specs[] = { + + {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "framergb", + Tk_Offset(WidgetOptions, cmdName), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1", + Tk_Offset(WidgetOptions, x), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1", + Tk_Offset(WidgetOptions, y), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512", + Tk_Offset(WidgetOptions, width), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "512", + Tk_Offset(WidgetOptions, height), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw", + Tk_Offset(WidgetOptions, anchor), 0, NULL}, + {TK_CONFIG_CUSTOM, (char*)"-tags", NULL, NULL, NULL, + 0, TK_CONFIG_NULL_OK, &tagsOption}, + + {TK_CONFIG_STRING, (char*)"-helvetica", NULL, NULL, "helvetica", + Tk_Offset(WidgetOptions, helvetica), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier", + Tk_Offset(WidgetOptions, courier), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times", + Tk_Offset(WidgetOptions, times), 0, NULL}, + + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}, +}; + +// Tk Static Structure + +static Tk_ItemType frameRGBTrueColor24Type = { + (char*)"framergbtruecolor24", // name + sizeof(WidgetOptions), // item size + FrameRGBTrueColor24CreateProc, // configProc + frameRGBTrueColor24Specs, // configSpecs + WidgetConfigProc, // configProc + WidgetCoordProc, // coordProc + WidgetDeleteProc, // deleteProc + WidgetDisplayProc, // displayProc + 0, // alwaysRedraw + WidgetPointProc, // pointProc + WidgetAreaProc, // areaProc + WidgetPostscriptProc, // postscriptProc + WidgetScaleProc, // scaleProc + WidgetTranslateProc, // translateProc + (Tk_ItemIndexProc*)NULL, // indexProc + WidgetICursorProc, // icursorProc + (Tk_ItemSelectionProc*)NULL, // selectionProc + (Tk_ItemInsertProc*)NULL, // insertProc + (Tk_ItemDCharsProc*)NULL, // dCharsProc + (Tk_ItemType*)NULL // nextPtr +}; + +// Non-Member Functions + +int FrameRGBTrueColor24_Init(Tcl_Interp* interp) +{ + Tk_CreateItemType(&frameRGBTrueColor24Type); + return TCL_OK; +} + +int FrameRGBTrueColor24CreateProc(Tcl_Interp* interp, Tk_Canvas canvas, + Tk_Item* item, int argc, + Tcl_Obj *const argv[]) +{ + FrameRGBTrueColor24* frame = new FrameRGBTrueColor24(interp, canvas, item); + + // and set default configuration + + if (frame->configure(argc, (const char**)argv, 0) != TCL_OK) { + delete frame; + Tcl_AppendResult(interp, " error occured while creating frame.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// FrameRGBTrueColor24 Member Functions + +FrameRGBTrueColor24::FrameRGBTrueColor24(Tcl_Interp* i, Tk_Canvas c, + Tk_Item* item) + : FrameRGB(i, c, item), TrueColor24(visual) +{ + configSpecs = frameRGBTrueColor24Specs; // frame configure options +} + +FrameRGBTrueColor24::~FrameRGBTrueColor24() +{ + // we must do this at this level, because updateColorScale is called + unloadAllFits(); +} + + + + + diff --git a/tksao/frame/framergbtruecolor24.h b/tksao/frame/framergbtruecolor24.h new file mode 100644 index 0000000..8155ed9 --- /dev/null +++ b/tksao/frame/framergbtruecolor24.h @@ -0,0 +1,23 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __framergbtruecolor24_h__ +#define __framergbtruecolor24_h__ + +#include "framergb.h" +#include "truecolor24.h" + +class FrameRGBTrueColor24 :public FrameRGB, public TrueColor24 { + private: + void encodeTrueColor(XColor* src, char* dest) + {TrueColor24::encodeTrueColor(src,dest,baseXImage);} + void encodeTrueColor(unsigned char* src, XImage* ximage) + {TrueColor24::encodeTrueColor(src, ximage);} + + public: + FrameRGBTrueColor24(Tcl_Interp*, Tk_Canvas, Tk_Item*); + ~FrameRGBTrueColor24(); +}; + +#endif diff --git a/tksao/frame/framergbtruecolor8.C b/tksao/frame/framergbtruecolor8.C new file mode 100644 index 0000000..a8653b8 --- /dev/null +++ b/tksao/frame/framergbtruecolor8.C @@ -0,0 +1,113 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "framergbtruecolor8.h" +#include "fitsimage.h" + +// Tk Canvas Widget Function Declarations + +int FrameRGBTrueColor8CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int, + Tcl_Obj *const []); + +// FrameRGBTrueColor8 Specs + +static Tk_CustomOption tagsOption = { + Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL +}; + +static Tk_ConfigSpec frameRGBTrueColor8Specs[] = { + + {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "framergb", + Tk_Offset(WidgetOptions, cmdName), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1", + Tk_Offset(WidgetOptions, x), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1", + Tk_Offset(WidgetOptions, y), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512", + Tk_Offset(WidgetOptions, width), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "512", + Tk_Offset(WidgetOptions, height), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw", + Tk_Offset(WidgetOptions, anchor), 0, NULL}, + {TK_CONFIG_CUSTOM, (char*)"-tags", NULL, NULL, NULL, + 0, TK_CONFIG_NULL_OK, &tagsOption}, + + {TK_CONFIG_STRING, (char*)"-helvetica", NULL, NULL, "helvetica", + Tk_Offset(WidgetOptions, helvetica), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier", + Tk_Offset(WidgetOptions, courier), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times", + Tk_Offset(WidgetOptions, times), 0, NULL}, + + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}, +}; + +// Tk Static Structure + +static Tk_ItemType frameRGBTrueColor8Type = { + (char*)"framergbtruecolor8", // name + sizeof(WidgetOptions), // item size + FrameRGBTrueColor8CreateProc, // configProc + frameRGBTrueColor8Specs, // configSpecs + WidgetConfigProc, // configProc + WidgetCoordProc, // coordProc + WidgetDeleteProc, // deleteProc + WidgetDisplayProc, // displayProc + 0, // alwaysRedraw + WidgetPointProc, // pointProc + WidgetAreaProc, // areaProc + WidgetPostscriptProc, // postscriptProc + WidgetScaleProc, // scaleProc + WidgetTranslateProc, // translateProc + (Tk_ItemIndexProc*)NULL, // indexProc + WidgetICursorProc, // icursorProc + (Tk_ItemSelectionProc*)NULL, // selectionProc + (Tk_ItemInsertProc*)NULL, // insertProc + (Tk_ItemDCharsProc*)NULL, // dCharsProc + (Tk_ItemType*)NULL // nextPtr +}; + +// Non-Member Functions + +int FrameRGBTrueColor8_Init(Tcl_Interp* interp) +{ + Tk_CreateItemType(&frameRGBTrueColor8Type); + return TCL_OK; +} + +int FrameRGBTrueColor8CreateProc(Tcl_Interp* interp, Tk_Canvas canvas, + Tk_Item* item, int argc, + Tcl_Obj *const argv[]) +{ + FrameRGBTrueColor8* frame = new FrameRGBTrueColor8(interp, canvas, item); + + // and set default configuration + + if (frame->configure(argc, (const char**)argv, 0) != TCL_OK) { + delete frame; + Tcl_AppendResult(interp, " error occured while creating frame.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// FrameRGBTrueColor8 Member Functions + +FrameRGBTrueColor8::FrameRGBTrueColor8(Tcl_Interp* i, Tk_Canvas c, + Tk_Item* item) + : FrameRGB(i,c,item), TrueColor8(visual) +{ + configSpecs = frameRGBTrueColor8Specs; // frame configure options +} + +FrameRGBTrueColor8::~FrameRGBTrueColor8() +{ + // we must do this at this level, because updateColorScale is called + unloadAllFits(); +} + + + + diff --git a/tksao/frame/framergbtruecolor8.h b/tksao/frame/framergbtruecolor8.h new file mode 100644 index 0000000..df9bd88 --- /dev/null +++ b/tksao/frame/framergbtruecolor8.h @@ -0,0 +1,23 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __framergbtruecolor8_h__ +#define __framergbtruecolor8_h__ + +#include "framergb.h" +#include "truecolor8.h" + +class FrameRGBTrueColor8 : public FrameRGB, public TrueColor8 { + private: + void encodeTrueColor(XColor* src, char* dest) + {TrueColor8::encodeTrueColor(src,dest,baseXImage);} + void encodeTrueColor(unsigned char* src, XImage* ximage) + {TrueColor8::encodeTrueColor(src, ximage);} + + public: + FrameRGBTrueColor8(Tcl_Interp*, Tk_Canvas, Tk_Item*); + ~FrameRGBTrueColor8(); +}; + +#endif diff --git a/tksao/frame/frametruecolor16.C b/tksao/frame/frametruecolor16.C new file mode 100644 index 0000000..8285e16 --- /dev/null +++ b/tksao/frame/frametruecolor16.C @@ -0,0 +1,165 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "frametruecolor16.h" +#include "colorscaletrue16.h" + +// Tk Canvas Widget Function Declarations + +int FrameTrueColor16CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int, Tcl_Obj *const []); + +// FrameTrueColor16 Specs + +static Tk_CustomOption tagsOption = { + Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL +}; + +static Tk_ConfigSpec frameTrueColor16Specs[] = { + + {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "frame", + Tk_Offset(WidgetOptions, cmdName), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1", + Tk_Offset(WidgetOptions, x), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1", + Tk_Offset(WidgetOptions, y), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512", + Tk_Offset(WidgetOptions, width), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "512", + Tk_Offset(WidgetOptions, height), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw", + Tk_Offset(WidgetOptions, anchor), 0, NULL}, + {TK_CONFIG_CUSTOM, (char*)"-tags", NULL, NULL, NULL, + 0, TK_CONFIG_NULL_OK, &tagsOption}, + + {TK_CONFIG_STRING, (char*)"-helvetica", NULL, NULL, "helvetica", + Tk_Offset(WidgetOptions, helvetica), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier", + Tk_Offset(WidgetOptions, courier), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times", + Tk_Offset(WidgetOptions, times), 0, NULL}, + + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}, +}; + +// Tk Static Structure + +static Tk_ItemType frameTrueColor16Type = { + (char*)"frametruecolor16", // name + sizeof(WidgetOptions), // item size + FrameTrueColor16CreateProc, // configProc + frameTrueColor16Specs, // configSpecs + WidgetConfigProc, // configProc + WidgetCoordProc, // coordProc + WidgetDeleteProc, // deleteProc + WidgetDisplayProc, // displayProc + 0, // alwaysRedraw + WidgetPointProc, // pointProc + WidgetAreaProc, // areaProc + WidgetPostscriptProc, // postscriptProc + WidgetScaleProc, // scaleProc + WidgetTranslateProc, // translateProc + (Tk_ItemIndexProc*)NULL, // indexProc + WidgetICursorProc, // icursorProc + (Tk_ItemSelectionProc*)NULL, // selectionProc + (Tk_ItemInsertProc*)NULL, // insertProc + (Tk_ItemDCharsProc*)NULL, // dCharsProc + (Tk_ItemType*)NULL // nextPtr +}; + +// Non-Member Functions + +int FrameTrueColor16_Init(Tcl_Interp* interp) +{ + Tk_CreateItemType(&frameTrueColor16Type); + return TCL_OK; +} + +int FrameTrueColor16CreateProc(Tcl_Interp* interp, Tk_Canvas canvas, + Tk_Item* item, int argc, Tcl_Obj *const argv[]) +{ + FrameTrueColor16* frame = new FrameTrueColor16(interp, canvas, item); + + // and set default configuration + + if (frame->configure(argc, (const char**)argv, 0) != TCL_OK) { + delete frame; + Tcl_AppendResult(interp, " error occured while creating frame.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// FrameTrueColor16 Member Functions + +FrameTrueColor16::FrameTrueColor16(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : Frame(i,c,item), TrueColor16(visual) +{ + configSpecs = frameTrueColor16Specs; // frame configure options +} + +FrameTrueColor16::~FrameTrueColor16() +{ + // we must do this at this level, because updateColorScale is called + unloadAllFits(); +} + +void FrameTrueColor16::updateColorScale() +{ + // we need colors before we can construct a scale + + if (!colorCells) + return; + + if (colorScale) + delete colorScale; + + switch (context->colorScaleType()) { + case FrScale::LINEARSCALE: + colorScale = + new LinearScaleTrueColor16(colorCount, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::LOGSCALE: + colorScale = + new LogScaleTrueColor16(SCALESIZE, colorCells, colorCount, + context->expo(), visual, byteorder_); + break; + case FrScale::POWSCALE: + colorScale = + new PowScaleTrueColor16(SCALESIZE, colorCells, colorCount, + context->expo(), visual, byteorder_); + break; + case FrScale::SQRTSCALE: + colorScale = + new SqrtScaleTrueColor16(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::SQUAREDSCALE: + colorScale = + new SquaredScaleTrueColor16(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::ASINHSCALE: + colorScale = + new AsinhScaleTrueColor16(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::SINHSCALE: + colorScale = + new SinhScaleTrueColor16(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::HISTEQUSCALE: + colorScale = + new HistEquScaleTrueColor16(SCALESIZE, colorCells, colorCount, + context->histequ(), HISTEQUSIZE, + visual, byteorder_); + break; + case FrScale::IISSCALE: + colorScale = + new IISScaleTrueColor16(colorCells, colorCount, visual, byteorder_); + break; + } +} diff --git a/tksao/frame/frametruecolor16.h b/tksao/frame/frametruecolor16.h new file mode 100644 index 0000000..edb5cee --- /dev/null +++ b/tksao/frame/frametruecolor16.h @@ -0,0 +1,24 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __frametruecolor16_h__ +#define __frametruecolor16_h__ + +#include "frame.h" +#include "truecolor16.h" + +class FrameTrueColor16 : public Frame, public TrueColor16 { +private: + void encodeTrueColor(XColor* src, char* dest) + {TrueColor16::encodeTrueColor(src,dest,baseXImage);} + void encodeTrueColor(unsigned char* src, XImage* ximage) + {TrueColor16::encodeTrueColor(src, ximage);} + void updateColorScale(); + +public: + FrameTrueColor16(Tcl_Interp*, Tk_Canvas, Tk_Item*); + ~FrameTrueColor16(); +}; + +#endif diff --git a/tksao/frame/frametruecolor24.C b/tksao/frame/frametruecolor24.C new file mode 100644 index 0000000..87c0d68 --- /dev/null +++ b/tksao/frame/frametruecolor24.C @@ -0,0 +1,231 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "frametruecolor24.h" +#include "colorscaletrue24.h" +#include "colorscaletrue32.h" + +// Tk Canvas Widget Function Declarations + +int FrameTrueColor24CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int, Tcl_Obj *const []); + +// FrameTrueColor24 Specs + +static Tk_CustomOption tagsOption = { + Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL +}; + +static Tk_ConfigSpec frameTrueColor24Specs[] = { + + {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "frame", + Tk_Offset(WidgetOptions, cmdName), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1", + Tk_Offset(WidgetOptions, x), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1", + Tk_Offset(WidgetOptions, y), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512", + Tk_Offset(WidgetOptions, width), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "512", + Tk_Offset(WidgetOptions, height), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw", + Tk_Offset(WidgetOptions, anchor), 0, NULL}, + {TK_CONFIG_CUSTOM, (char*)"-tags", NULL, NULL, NULL, + 0, TK_CONFIG_NULL_OK, &tagsOption}, + + {TK_CONFIG_STRING, (char*)"-helvetica", NULL, NULL, "helvetica", + Tk_Offset(WidgetOptions, helvetica), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier", + Tk_Offset(WidgetOptions, courier), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times", + Tk_Offset(WidgetOptions, times), 0, NULL}, + + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}, +}; + +// Tk Static Structure + +static Tk_ItemType frameTrueColor24Type = { + (char*)"frametruecolor24", // name + sizeof(WidgetOptions), // item size + FrameTrueColor24CreateProc, // configProc + frameTrueColor24Specs, // configSpecs + WidgetConfigProc, // configProc + WidgetCoordProc, // coordProc + WidgetDeleteProc, // deleteProc + WidgetDisplayProc, // displayProc + 0, // alwaysRedraw + WidgetPointProc, // pointProc + WidgetAreaProc, // areaProc + WidgetPostscriptProc, // postscriptProc + WidgetScaleProc, // scaleProc + WidgetTranslateProc, // translateProc + (Tk_ItemIndexProc*)NULL, // indexProc + WidgetICursorProc, // icursorProc + (Tk_ItemSelectionProc*)NULL, // selectionProc + (Tk_ItemInsertProc*)NULL, // insertProc + (Tk_ItemDCharsProc*)NULL, // dCharsProc + (Tk_ItemType*)NULL // nextPtr +}; + +// Non-Member Functions + +int FrameTrueColor24_Init(Tcl_Interp* interp) +{ + Tk_CreateItemType(&frameTrueColor24Type); + return TCL_OK; +} + +int FrameTrueColor24CreateProc(Tcl_Interp* interp, Tk_Canvas canvas, + Tk_Item* item, int argc, Tcl_Obj *const argv[]) +{ + FrameTrueColor24* frame = new FrameTrueColor24(interp, canvas, item); + + // and set default configuration + + if (frame->configure(argc, (const char**)argv, 0) != TCL_OK) { + delete frame; + Tcl_AppendResult(interp, " error occured while creating frame.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// FrameTrueColor24 Member Functions + +FrameTrueColor24::FrameTrueColor24(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : Frame(i,c,item), TrueColor24(visual) +{ + configSpecs = frameTrueColor24Specs; // frame configure options +} + +FrameTrueColor24::~FrameTrueColor24() +{ + // we must do this at this level, because updateColorScale is called + unloadAllFits(); +} + +void FrameTrueColor24::updateColorScale() +{ + // we need colors before we can construct a scale + if (!colorCells || !bitsperpixel_) + return; + + if (colorScale) + delete colorScale; + + // determine if we have 3 bytes or 4 bytes per pixel + switch (bitsperpixel_) { + case 24: + updateColorScale24(); + break; + case 32: + updateColorScale32(); + break; + } +} + +void FrameTrueColor24::updateColorScale24() +{ + switch (context->colorScaleType()) { + case FrScale::LINEARSCALE: + colorScale = + new LinearScaleTrueColor24(colorCount, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::LOGSCALE: + colorScale = + new LogScaleTrueColor24(SCALESIZE, colorCells, colorCount, + context->expo(), visual, byteorder_); + break; + case FrScale::POWSCALE: + colorScale = + new PowScaleTrueColor24(SCALESIZE, colorCells, colorCount, + context->expo(), visual, byteorder_); + break; + case FrScale::SQRTSCALE: + colorScale = + new SqrtScaleTrueColor24(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::SQUAREDSCALE: + colorScale = + new SquaredScaleTrueColor24(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::ASINHSCALE: + colorScale = + new AsinhScaleTrueColor24(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::SINHSCALE: + colorScale = + new SinhScaleTrueColor24(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::HISTEQUSCALE: + colorScale = + new HistEquScaleTrueColor24(SCALESIZE, colorCells, colorCount, + context->histequ(), HISTEQUSIZE, + visual, byteorder_); + break; + case FrScale::IISSCALE: + colorScale = + new IISScaleTrueColor24(colorCells, colorCount, visual, byteorder_); + break; + } +} + +void FrameTrueColor24::updateColorScale32() +{ + switch (context->colorScaleType()) { + case FrScale::LINEARSCALE: + colorScale = + new LinearScaleTrueColor32(colorCount, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::LOGSCALE: + colorScale = + new LogScaleTrueColor32(SCALESIZE, colorCells, colorCount, + context->expo(), visual, byteorder_); + break; + case FrScale::POWSCALE: + colorScale = + new PowScaleTrueColor32(SCALESIZE, colorCells, colorCount, + context->expo(), visual, byteorder_); + break; + case FrScale::SQRTSCALE: + colorScale = + new SqrtScaleTrueColor32(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::SQUAREDSCALE: + colorScale = + new SquaredScaleTrueColor32(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::ASINHSCALE: + colorScale = + new AsinhScaleTrueColor32(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::SINHSCALE: + colorScale = + new SinhScaleTrueColor32(SCALESIZE, colorCells, colorCount, + visual, byteorder_); + break; + case FrScale::HISTEQUSCALE: + colorScale = + new HistEquScaleTrueColor32(SCALESIZE, colorCells, colorCount, + context->histequ(), HISTEQUSIZE, + visual, byteorder_); + break; + case FrScale::IISSCALE: + colorScale = + new IISScaleTrueColor32(colorCells, colorCount, visual, byteorder_); + break; + } +} + + diff --git a/tksao/frame/frametruecolor24.h b/tksao/frame/frametruecolor24.h new file mode 100644 index 0000000..cce7df1 --- /dev/null +++ b/tksao/frame/frametruecolor24.h @@ -0,0 +1,26 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __frametruecolor24_h__ +#define __frametruecolor24_h__ + +#include "frame.h" +#include "truecolor24.h" + +class FrameTrueColor24 : public Frame, public TrueColor24 { +private: + void encodeTrueColor(XColor* src, char* dest) + {TrueColor24::encodeTrueColor(src,dest,baseXImage);} + void encodeTrueColor(unsigned char* src, XImage* ximage) + {TrueColor24::encodeTrueColor(src, ximage);} + void updateColorScale(); + void updateColorScale24(); + void updateColorScale32(); + +public: + FrameTrueColor24(Tcl_Interp*, Tk_Canvas, Tk_Item*); + ~FrameTrueColor24(); +}; + +#endif diff --git a/tksao/frame/frametruecolor8.C b/tksao/frame/frametruecolor8.C new file mode 100644 index 0000000..a2e3d96 --- /dev/null +++ b/tksao/frame/frametruecolor8.C @@ -0,0 +1,160 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "frametruecolor8.h" +#include "colorscaletrue8.h" + +// Tk Canvas Widget Function Declarations + +int FrameTrueColor8CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int, Tcl_Obj *const []); + +// FrameTrueColor8 Specs + +static Tk_CustomOption tagsOption = { + Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL +}; + +static Tk_ConfigSpec frameTrueColor8Specs[] = { + + {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "frame", + Tk_Offset(WidgetOptions, cmdName), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1", + Tk_Offset(WidgetOptions, x), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1", + Tk_Offset(WidgetOptions, y), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512", + Tk_Offset(WidgetOptions, width), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "512", + Tk_Offset(WidgetOptions, height), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw", + Tk_Offset(WidgetOptions, anchor), 0, NULL}, + {TK_CONFIG_CUSTOM, (char*)"-tags", NULL, NULL, NULL, + 0, TK_CONFIG_NULL_OK, &tagsOption}, + + {TK_CONFIG_STRING, (char*)"-helvetica", NULL, NULL, "helvetica", + Tk_Offset(WidgetOptions, helvetica), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier", + Tk_Offset(WidgetOptions, courier), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times", + Tk_Offset(WidgetOptions, times), 0, NULL}, + + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}, +}; + +// Tk Static Structure + +static Tk_ItemType frameTrueColor8Type = { + (char*)"frametruecolor8", // name + sizeof(WidgetOptions), // item size + FrameTrueColor8CreateProc, // configProc + frameTrueColor8Specs, // configSpecs + WidgetConfigProc, // configProc + WidgetCoordProc, // coordProc + WidgetDeleteProc, // deleteProc + WidgetDisplayProc, // displayProc + 0, // alwaysRedraw + WidgetPointProc, // pointProc + WidgetAreaProc, // areaProc + WidgetPostscriptProc, // postscriptProc + WidgetScaleProc, // scaleProc + WidgetTranslateProc, // translateProc + (Tk_ItemIndexProc*)NULL, // indexProc + WidgetICursorProc, // icursorProc + (Tk_ItemSelectionProc*)NULL, // selectionProc + (Tk_ItemInsertProc*)NULL, // insertProc + (Tk_ItemDCharsProc*)NULL, // dCharsProc + (Tk_ItemType*)NULL // nextPtr +}; + +// Non-Member Functions + +int FrameTrueColor8_Init(Tcl_Interp* interp) +{ + Tk_CreateItemType(&frameTrueColor8Type); + return TCL_OK; +} + +int FrameTrueColor8CreateProc(Tcl_Interp* interp, Tk_Canvas canvas, + Tk_Item* item, int argc, Tcl_Obj *const argv[]) +{ + FrameTrueColor8* frame = new FrameTrueColor8(interp, canvas, item); + + // and set default configuration + + if (frame->configure(argc, (const char**)argv, 0) != TCL_OK) { + delete frame; + Tcl_AppendResult(interp, " error occured while creating frame.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +// FrameTrueColor8 Member Functions + +FrameTrueColor8::FrameTrueColor8(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : Frame(i,c,item), TrueColor8(visual) +{ + configSpecs = frameTrueColor8Specs; // frame configure options +} + +FrameTrueColor8::~FrameTrueColor8() +{ + // we must do this at this level, because updateColorScale is called + unloadAllFits(); +} + +void FrameTrueColor8::updateColorScale() +{ + // we need colors before we can construct a scale + + if (!colorCells) + return; + + if (colorScale) + delete colorScale; + + switch (context->colorScaleType()) { + case FrScale::LINEARSCALE: + colorScale = + new LinearScaleTrueColor8(colorCount, colorCells, colorCount, visual); + break; + case FrScale::LOGSCALE: + colorScale = + new LogScaleTrueColor8(SCALESIZE, colorCells, colorCount, + context->expo(), visual); + break; + case FrScale::POWSCALE: + colorScale = + new PowScaleTrueColor8(SCALESIZE, colorCells, colorCount, + context->expo(), visual); + break; + case FrScale::SQRTSCALE: + colorScale = + new SqrtScaleTrueColor8(SCALESIZE, colorCells, colorCount, visual); + break; + case FrScale::SQUAREDSCALE: + colorScale = + new SquaredScaleTrueColor8(SCALESIZE, colorCells, colorCount, visual); + break; + case FrScale::ASINHSCALE: + colorScale = + new AsinhScaleTrueColor8(SCALESIZE, colorCells, colorCount, visual); + break; + case FrScale::SINHSCALE: + colorScale = + new SinhScaleTrueColor8(SCALESIZE, colorCells, colorCount, visual); + break; + case FrScale::HISTEQUSCALE: + colorScale = + new HistEquScaleTrueColor8(SCALESIZE, colorCells, colorCount, + context->histequ(), HISTEQUSIZE, visual); + break; + case FrScale::IISSCALE: + colorScale = + new IISScaleTrueColor8(colorCells, colorCount, visual); + break; + } +} + diff --git a/tksao/frame/frametruecolor8.h b/tksao/frame/frametruecolor8.h new file mode 100644 index 0000000..a01e114 --- /dev/null +++ b/tksao/frame/frametruecolor8.h @@ -0,0 +1,24 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __frametruecolor8_h__ +#define __frametruecolor8_h__ + +#include "frame.h" +#include "truecolor8.h" + +class FrameTrueColor8 : public Frame, public TrueColor8 { +private: + void encodeTrueColor(XColor* src, char* dest) + {TrueColor8::encodeTrueColor(src,dest,baseXImage);} + void encodeTrueColor(unsigned char* src, XImage* ximage) + {TrueColor8::encodeTrueColor(src, ximage);} + void updateColorScale(); + +public: + FrameTrueColor8(Tcl_Interp*, Tk_Canvas, Tk_Item*); + ~FrameTrueColor8(); +}; + +#endif diff --git a/tksao/frame/frblt.C b/tksao/frame/frblt.C new file mode 100644 index 0000000..d388d27 --- /dev/null +++ b/tksao/frame/frblt.C @@ -0,0 +1,1029 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "base.h" +#include "context.h" +#include "fitsimage.h" + +#include "projection.h" +extern "C" { +#include "tkbltVector.h" +} + +#include "sigbus.h" + +void Base::markerAnalysisHistogram(Marker* pp, double** x, double** y, + const BBox& bb, int num) +{ + // does not extend across mosaic boundries + // uses currentContext + FitsImage* ptr = isInCFits(pp->getCenter(),Coord::REF,NULL); + if (!ptr) + ptr = currentContext->cfits; + + int srcw = ptr->width(); + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + + double min =DBL_MAX; + double max =-DBL_MAX; + + // take the bbox and extend to lower/upper pixel boundaries + Vector ll = (bb.ll*ptr->refToData).floor(); + Vector ur = (bb.ur*ptr->refToData).ceil(); + + int msize = int(ur[1]-ll[1])*int(ur[0]-ll[0]); + double* marr = new double[msize]; + int* mask = new int[msize]; + memset(marr,0,msize*sizeof(double)); + memset(mask,0,msize*sizeof(int)); + + // main loop + SETSIGBUS + int cnt =0; + for (int jj=ll[1]; jj=params->xmin && iixmax && + jj>=params->ymin && jjymax) { + // shift to center of pixel in DATA + Vector rr = Vector(ii,jj)+Vector(.5,.5); + Vector ss = rr*ptr->dataToRef; + + if (pp->isIn(ss,Coord::REF)) { + double val =ptr->getValueDouble(long(jj)*srcw+long(ii)); + // check for nan + if (isfinite(val)) { + marr[cnt] =val; + mask[cnt] =1; + if (valmax) + max =val; + } + } + } + } + } + CLEARSIGBUS + + // sanity check + if (num<1) + num = 1; + + // we need one extra max,0 value at the end + int nn = num+1; + *x = (double*)malloc(nn*sizeof(double)); + *y = (double*)malloc(nn*sizeof(double)); + memset(*x,0,nn*sizeof(double)); + memset(*y,0,nn*sizeof(double)); + + double diff = max-min; + int last = num-1; + double* xx = *x; + double* yy = *y; + + if (diff>0) { + for (int ii=0; ii=min && val<=max) + yy[(int)((val-min)/diff*last+.5)]++; + } + } + } + else { + for (int ii=0; iigetCenter(),Coord::REF,NULL); + if (!ptr) + ptr = currentContext->cfits; + + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + + Vector vv = p2-p1; + int num = vv.length() +1; + Vector s = vv.normalize(); + int cnt[num]; + + *x = (double*)malloc(num*sizeof(double)); + *y = (double*)malloc(num*sizeof(double)); + *xc = (double*)malloc(num*sizeof(double)); + *yc = (double*)malloc(num*sizeof(double)); + + // main loop + + SETSIGBUS + for (long ii=0; iimapFromRef(t, sys, sky); + (*xc)[ii] = tv[0]; + (*yc)[ii] = tv[1]; + + Vector z = t * ptr->refToData; + + if (z[0]>=params->xmin && z[0]xmax && + z[1]>=params->ymin && z[1]ymax) { + + // check for nan + double v = ptr->getValueDouble(z); + if (isfinite(v)) { + (*y)[ii] = v; + cnt[ii] = 1; + } + + Vector ss = Vector(-s[1],s[0]); + + for (long jj=1; jjrefToData; + + if (zz[0]>=params->xmin && zz[0]xmax && + zz[1]>=params->ymin && zz[1]ymax) { + + double vvalue = ptr->getValueDouble(zz); + // check for nan + if (isfinite(vvalue)) { + (*y)[ii] += vvalue; + cnt[ii]++; + } + } + } + } + } + + // average if needed + if (method == Marker::AVERAGE) + for (long ii=0; iigetCenter(),Coord::REF,NULL); + if (!ptr) + ptr = currentContext->fits; + + // if more than 3 axes, walk it forward + int num = currentContext->calcSlice(); + for (int ii=1; iinextSlice(); + + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + FitsZBound* zparams=currentContext->getDataParams(currentContext->secMode()); + + int srcw = ptr->width(); + int srcd = zparams->zmax - zparams->zmin; + + // slice jump vector + FitsImage* sjv[srcd]; + FitsImage* sptr = ptr; + for (int ii=0; iizmin; ii++) + sptr = sptr->nextSlice(); + + for (int ii=0; iinextSlice(); + } + + // init + *x = (double*)malloc(srcd*sizeof(double)); + *y = (double*)malloc(srcd*sizeof(double)); + memset(*x,0,srcd*sizeof(double)); + memset(*y,0,srcd*sizeof(double)); + + int* cnt = new int[srcd]; + memset(cnt,0,srcd*sizeof(int)); + + // take the bbox and extend to lower/upper pixel boundaries + Vector ll = (bb.ll*ptr->refToData).floor(); + Vector ur = (bb.ur*ptr->refToData).ceil(); + + // mask + int ss = (ur[0]-ll[0])*(ur[1]-ll[1]); + bool* msk = new bool[ss]; + long* idx = new long[ss]; + memset(msk,0,ss*sizeof(bool)); + memset(idx,0,ss*sizeof(long)); + + bool* mptr=msk; + long* iptr=idx; + if (!pp->isFixed()) { + Matrix bck = pp->bckMatrix(); + for (int jj=ll[1]; jj=params->xmin && iixmax && + jj>=params->ymin && jjymax) { + // shift to center of pixel in DATA + Vector rr = Vector(ii,jj)+Vector(.5,.5); + if (pp->isIn(rr*ptr->dataToRef,bck)) { + *mptr=1; + *iptr=long(jj)*srcw+long(ii); + } + } + } + } + } + else { + for (int jj=ll[1]; jj=params->xmin && iixmax && + jj>=params->ymin && jjymax) { + // shift to center of pixel in DATA + Vector rr = Vector(ii,jj)+Vector(.5,.5); + if (pp->isIn(rr*ptr->dataToRef,Coord::REF)) { + *mptr=1; + *iptr=long(jj)*srcw+long(ii); + } + } + } + } + } + + // main loop + SETSIGBUS + for (int kk=0; kkmapFromRef3axis(kk+.5+zparams->zmin, sys, 2); + + bool* mptr=msk; + long* iptr=idx; + for (int ll=0; llgetValueDouble(*iptr); + // check for nan + if (isfinite(val)) { + (*y)[kk] += val; + cnt[kk]++; + } + } + } + } + CLEARSIGBUS + + // average if needed + if (method == Marker::AVERAGE) + for (long kk=0; kkgetCenter(),Coord::REF,NULL); + if (!ptr) + ptr = currentContext->cfits; + + int srcw = ptr->width(); + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + + double sum[num]; + memset(sum,0,num*sizeof(double)); + int cnt[num]; + memset(cnt,0,num*sizeof(int)); + + for (int kk=0; kkrefToData).floor(); + Vector ur = (bb[kk+1].ur*ptr->refToData).ceil(); + + // main loop + SETSIGBUS + for (int jj=ll[1]; jj=params->xmin && iixmax && + jj>=params->ymin && jjymax) { + // shift to center of pixel in DATA + Vector rr = Vector(ii,jj)+Vector(.5,.5); + Vector ss = rr*ptr->dataToRef; + + if (pp->isIn(ss,Coord::REF,kk+1) && !pp->isIn(ss,Coord::REF,kk)) { + double val =ptr->getValueDouble(long(jj)*srcw+long(ii)); + // check for nan + if (isfinite(val)) { + sum[kk] += val; + cnt[kk]++; + } + } + } + } + } + CLEARSIGBUS + } + + *x = (double*)malloc(num*sizeof(double)); + *y = (double*)malloc(num*sizeof(double)); + *e = (double*)malloc(num*sizeof(double)); + + int unit; + Vector cdelt; + double xaxis =1; + if (ptr->hasWCS(sys)) + if (ptr->hasWCSCel(sys)) { + unit =1; + cdelt= ptr->getWCScdelt(sys); + xaxis = fabs(cdelt[0]*60*60); + } + else { + unit =2; + cdelt= ptr->getWCScdelt(sys); + xaxis = fabs(cdelt[0]); + } + else { + unit =0; + xaxis =1; + } + + for (int kk=0; kkgetCenter(),Coord::REF,NULL); + if (!ptr) + ptr = currentContext->cfits; + + int srcw = ptr->width(); + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + + double sum[num][aa]; + memset(sum,0,num*aa*sizeof(double)); + int cnt[num][aa]; + memset(cnt,0,num*aa*sizeof(int)); + + for (int kk=0; kkrefToData).floor(); + Vector ur = (bb[kk+1].ur*ptr->refToData).ceil(); + + // main loop + SETSIGBUS + for (int qq=0; qq=params->xmin && iixmax && + jj>=params->ymin && jjymax) { + // shift to center of pixel in DATA + Vector rr = Vector(ii,jj)+Vector(.5,.5); + Vector ss = rr*ptr->dataToRef; + + if (pp->isIn(ss,Coord::REF,kk+1,qq) && + !pp->isIn(ss,Coord::REF,kk,qq)) { + double val =ptr->getValueDouble(long(jj)*srcw+long(ii)); + // check for nan + if (isfinite(val)) { + sum[kk][qq] += val; + cnt[kk][qq]++; + } + } + } + } + } + } + CLEARSIGBUS + } + + *x = (double*)malloc(num*aa*sizeof(double)); + *y = (double*)malloc(num*aa*sizeof(double)); + *e = (double*)malloc(num*aa*sizeof(double)); + + int unit; + Vector cdelt; + double xaxis =1; + if (ptr->hasWCS(sys)) + if (ptr->hasWCSCel(sys)) { + unit =1; + cdelt= ptr->getWCScdelt(sys); + xaxis = fabs(cdelt[0]*60*60); + } + else { + unit =2; + cdelt= ptr->getWCScdelt(sys); + xaxis = fabs(cdelt[0]); + } + else { + unit =0; + xaxis =1; + } + + for (int qq=0; qqgetCenter(),Coord::REF,NULL); + if (!ptr) + ptr = currentContext->cfits; + + int srcw = ptr->width(); + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + + double sum =0; + double sum2 =0; + int cnt =0; + double min =DBL_MAX; + double max =-DBL_MAX; + + // take the bbox and extend to lower/upper pixel boundaries + Vector ll = (bb.ll*ptr->refToData).floor(); + Vector ur = (bb.ur*ptr->refToData).ceil(); + + int msize = int(ur[1]-ll[1])*int(ur[0]-ll[0]); + double* marr = new double[msize]; + memset(marr,0,msize*sizeof(double)); + + // main loop + SETSIGBUS + for (int jj=ll[1]; jj=params->xmin && iixmax && + jj>=params->ymin && jjymax) { + // shift to center of pixel in DATA + Vector rr = Vector(ii,jj)+Vector(.5,.5); + Vector ss = rr*ptr->dataToRef; + + if (pp->isIn(ss,Coord::REF)) { + double val =ptr->getValueDouble(long(jj)*srcw+long(ii)); + // check for nan + if (isfinite(val)) { + sum += val; + sum2 += val*val; + if (cntmax) + max =val; + + cnt++; + } + } + } + } + } + CLEARSIGBUS + + qsort((void*)marr,cnt,sizeof(double),dCompare); + double median = marr[int(cnt/2.)]; + if (marr) + delete [] marr; + + int unit = markerAnalysisStats1(pp,ptr,str,sys,sky); + markerAnalysisStats2(ptr,str,sys,0,cnt,sum,unit); + markerAnalysisStats3(str); + markerAnalysisStats4(str,0,cnt,sum,sum2,median,min,max); +} + +// for annulus regions +void Base::markerAnalysisStats(Marker* pp, ostream& str, + int num, BBox* bb, + Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + // does not extend across mosaic boundries + // uses currentContext + FitsImage* ptr = isInCFits(pp->getCenter(),Coord::REF,NULL); + if (!ptr) + ptr = currentContext->cfits; + + int srcw = ptr->width(); + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + + double sum[num]; + memset(sum,0,num*sizeof(double)); + double sum2[num]; + memset(sum2,0,num*sizeof(double)); + int cnt[num]; + memset(cnt,0,num*sizeof(int)); + double min[num]; + double max[num]; + for (int ii=0; iirefToData).floor(); + Vector ur = (bb[kk+1].ur*ptr->refToData).ceil(); + + int msize = int(ur[1]-ll[1])*int(ur[0]-ll[0]); + double* marr = new double[msize]; + memset(marr,0,msize*sizeof(double)); + + // main loop + SETSIGBUS + for (int jj=ll[1]; jj=params->xmin && iixmax && + jj>=params->ymin && jjymax) { + // shift to center of pixel in DATA + Vector rr = Vector(ii,jj)+Vector(.5,.5); + Vector ss = rr*ptr->dataToRef; + + if (pp->isIn(ss,Coord::REF,kk+1) && !pp->isIn(ss,Coord::REF,kk)) { + double val =ptr->getValueDouble(long(jj)*srcw+long(ii)); + // check for nan + if (isfinite(val)) { + sum[kk] += val; + sum2[kk] += val*val; + if (cnt[kk]max[kk]) + max[kk] =val; + + cnt[kk]++; + } + } + } + } + } + CLEARSIGBUS + + qsort((void*)marr,cnt[kk],sizeof(double),dCompare); + median[kk] = marr[int(cnt[kk]/2.)]; + if (marr) + delete [] marr; + } + + int unit = markerAnalysisStats1(pp,ptr,str,sys,sky); + for (int kk=0; kkgetCenter(),Coord::REF,NULL); + if (!ptr) + ptr = currentContext->cfits; + + int srcw = ptr->width(); + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + + double sum[num][aa]; + memset(sum,0,num*aa*sizeof(double)); + double sum2[num][aa]; + memset(sum2,0,num*aa*sizeof(double)); + int cnt[num][aa]; + memset(cnt,0,num*aa*sizeof(int)); + double min[num][aa]; + double max[num][aa]; + for (int ii=0; iirefToData).floor(); + Vector ur = (bb[kk+1].ur*ptr->refToData).ceil(); + + int msize = int(ur[1]-ll[1])*int(ur[0]-ll[0]); + double* marr = new double[msize]; + + // main loop + SETSIGBUS + for (int qq=0; qq=params->xmin && iixmax && + jj>=params->ymin && jjymax) { + // shift to center of pixel in DATA + Vector rr = Vector(ii,jj)+Vector(.5,.5); + Vector ss = rr*ptr->dataToRef; + + if (pp->isIn(ss,Coord::REF,kk+1,qq) && + !pp->isIn(ss,Coord::REF,kk,qq)) { + double val =ptr->getValueDouble(long(jj)*srcw+long(ii)); + // check for nan + if (isfinite(val)) { + sum[kk][qq] += val; + sum2[kk][qq] += val*val; + + if (cnt[kk][qq]max[kk][qq]) + max[kk][qq] = val; + + cnt[kk][qq]++; + } + } + } + } + } + + qsort((void*)marr,cnt[kk][qq],sizeof(double),dCompare); + median[kk][qq] = marr[int(cnt[kk][qq]/2.)]; + } + CLEARSIGBUS + + if (marr) + delete [] marr; + } + + int unit = markerAnalysisStats1(pp,ptr,str,sys,sky); + for (int kk=0; kkgetWCScdelt(sys); + if (ptr->hasWCSCel(sys)) { + str << "1 pixel = "<< fabs(cdelt[0]*60*60) << " arcsec"; + str << endl << endl; + str << "reg\t" << "sum\t" << "error\t\t" + << "area\t\t" << "surf_bri\t\t" << "surf_err" << endl + << "\t" << "\t" << "\t\t" + << "(arcsec**2)\t\t" << "(sum/arcsec**2)\t" << "(sum/arcsec**2)" << endl + << "---\t" << "---\t" << "-----\t\t" + << "-----------\t\t" << "---------------\t" << "---------------" << endl; + return 1; + } + else { + str << "1 pixel = "<< fabs(cdelt[0]); + str << endl << endl; + str << "reg\t" << "sum\t" << "error\t\t" + << "area\t\t" << "surf_bri\t\t" << "surf_err" << endl + << "\t" << "\t" << "\t\t" + << "(pix**2)\t\t" << "(sum/pix**2)\t\t" << "(sum/pix**2)" << endl + << "---\t" << "---\t" << "-----\t\t" + << "--------\t\t" << "------------\t\t" << "------------" << endl; + return 2; + } + } + break; + } +} + +void Base::markerAnalysisStats2(FitsImage* ptr, ostream& str, + Coord::CoordSystem sys, + int kk, int cnt, double sum, int unit) +{ + double area =0; + switch (unit) { + case 0: + // pixels + area = cnt; + break; + case 1: + { + // Cel WCS + Vector cdelt= ptr->getWCScdelt(sys); + area = fabs(cdelt[0]*cdelt[1]*60*60*60*60*cnt); + } + break; + case 2: + { + // Linear WCS + Vector cdelt= ptr->getWCScdelt(sys); + area = fabs(cdelt[0]*cdelt[1]*cnt); + } + break; + } + double err = sqrt(fabs(sum)); + double bri = sum/area; + double brierr = err/area; + + str << kk+1 << '\t' + << sum << '\t' + << err << "\t\t" + << area << "\t\t" + << bri << "\t\t" + << brierr << endl; +} + +void Base::markerAnalysisStats3(ostream& str) +{ + str << endl + << "reg\t" << "sum\t" << "npix\t" << "mean\t" << "median\t" + << "min\t" << "max\t" << "var\t" << "stddev\t" << "rms\t" << endl + << "---\t" << "---\t" << "----\t" << "----\t" << "------\t" + << "---\t" << "---\t" << "---\t" << "------\t" << "---\t" << endl; +} + +void Base::markerAnalysisStats4(ostream& str, int kk, + int cnt, double sum, double sum2, + double median, double min, double max) +{ + double mean =0; + double std =0; + double var =0; + double rms =0; + if (cnt) { + mean = sum/cnt; + var = fabs(sum2/cnt - (sum*sum)/(cnt*cnt)); + std = sqrt(var); + rms = sqrt(sum2/cnt); + } + + str << kk+1 << '\t' + << sum << '\t' + << cnt << '\t' + << mean << '\t' + << median << '\t' + << min << '\t' + << max << '\t' + << var << '\t' + << std << '\t' + << rms << '\t' + << endl; +} + +void Base::bltCut(char* xname, char* yname, Coord::Orientation axis, + const Vector& rr) +{ + int size; + if (axis == Coord::XX) + size = options->width; + else + size = options->height; + + long length = (size+1) * 2; + double* xx = (double*)malloc(sizeof(double)*length); + double* yy = (double*)malloc(sizeof(double)*length); + + // check for data or undefined low()/high() + if (!currentContext->cfits || !isfinite(currentContext->low())) { + for (int ii=0; ii<=size; ii++) { + xx[ii*2] = ii; + xx[ii*2+1] = ii; + yy[ii*2] = 0; + yy[ii*2+1] = 0; + } + } + else + bltCutFits(xx, yy, size, axis, rr); + + Blt_Vector* xv; + if (Blt_GetVector(interp, xname, &xv) != TCL_OK) + goto error; + + if (Blt_ResetVector(xv, xx, length, length*sizeof(double), TCL_DYNAMIC) != + TCL_OK) + goto error; + + Blt_Vector* yv; + if (Blt_GetVector(interp, yname, &yv) != TCL_OK) + goto error; + + if (Blt_ResetVector(yv, yy, length, length*sizeof(double), TCL_DYNAMIC) != + TCL_OK) + goto error; + + return; + + error: + result = TCL_ERROR; + return; +} + +void Base::bltCutFits(double* xx, double* yy, int size, Coord::Orientation axis, + const Vector& r) +{ + // Widget + Vector rr = r * refToWidget; + + // basics + FitsImage* sptr = currentContext->cfits; + int mosaic = isMosaic(); + + // variable + FitsBound* params = sptr->getDataParams(currentContext->secMode()); + double prev = currentContext->low(); + + // main loop + + SETSIGBUS + for (int ii=0; ii<=size; ii++) { + double vv = currentContext->low(); + + if (mosaic) { + sptr = currentContext->cfits; + params = sptr->getDataParams(currentContext->secMode()); + } + + do { + Vector img; + if (axis == Coord::XX) + img = Vector(1+ii,rr[1]) * sptr->widgetToData; + else + img = Vector(rr[0],1+ii) * sptr->widgetToData; + + if (img[0]>=params->xmin && img[0]xmax && + img[1]>=params->ymin && img[1]ymax) { + double value = sptr->getValueDouble(img); + + if (isfinite(value)) + vv = value; + + break; + } + else { + if (mosaic) { + sptr = sptr->nextMosaic(); + if (sptr) + params = sptr->getDataParams(currentContext->secMode()); + } + } + } + while (mosaic && sptr); + + xx[2*ii] = ii; + xx[2*ii +1] = ii; + + yy[2*ii] = prev; + yy[2*ii +1] = vv; + prev = vv; + } + CLEARSIGBUS +} + diff --git a/tksao/frame/frcommand.C b/tksao/frame/frcommand.C new file mode 100644 index 0000000..13002ba --- /dev/null +++ b/tksao/frame/frcommand.C @@ -0,0 +1,499 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include "fdstream.hpp" + +#include + +#include "framebase.h" +#include "fitsimage.h" +#include "context.h" +#include "marker.h" +#include "outfile.h" +#include "outchannel.h" +#include "outsocket.h" + +void FrameBase::binToFitCmd() +{ + if (currentContext->fits) { + double bf = 1/calcZoom(currentContext->fits->getHistDim(), + Vector(options->width,options->height)); + + // round up to next power of 2 + if (bf < 1) + currentContext->setBinToFactor(Vector(1,1)); + else { + int p=1; + while (psetBinToFactor(Vector(p,p)); + } + } + + Matrix mm = currentContext->binCursor(); + updateBin(mm); +} + +void FrameBase::blockToFitCmd() +{ + if (currentContext->fits) { + double bf = 1/calcZoom(currentContext->fits->osize(), + Vector(options->width,options->height)); + + // round up to next power of 2 + Vector vv; + if (bf < 1) + vv = currentContext->setBlockToFactor(Vector(1,1)); + else { + int p=1; + while (psetBlockToFactor(Vector(p,p)); + } + + currentContext->block(); + currentContext->analysis(); + updateBlock(vv); + } +} + +void FrameBase::get3dBorderCmd() +{ + Tcl_AppendResult(interp, "1", NULL); +} + +void FrameBase::get3dBorderColorCmd() +{ + Tcl_AppendResult(interp, "blue", NULL); +} + +void FrameBase::get3dCompassCmd() +{ + Tcl_AppendResult(interp, "1", NULL); +} + +void FrameBase::get3dCompassColorCmd() +{ + Tcl_AppendResult(interp, "green", NULL); +} + +void FrameBase::get3dHighliteCmd() +{ + Tcl_AppendResult(interp, "1", NULL); +} + +void FrameBase::get3dHighliteColorCmd() +{ + Tcl_AppendResult(interp, "cyan", NULL); +} + +void FrameBase::get3dRenderMethodCmd() +{ + Tcl_AppendResult(interp, "mip", NULL); +} + +void FrameBase::get3dScaleCmd() +{ + Tcl_AppendResult(interp, "1", NULL); +} + +void FrameBase::get3dViewCmd() +{ + Tcl_AppendResult(interp, "0 0", NULL); +} + +void FrameBase::get3dViewPointCmd() +{ + Tcl_AppendResult(interp, "0 0 0 0 0", NULL); +} + +void FrameBase::get3dRenderBackgroundCmd() +{ + Tcl_AppendResult(interp, "none", NULL); +} + +void FrameBase::getCursorCmd(Coord::InternalSystem sys) +{ + ostringstream str; + str << mapFromRef(cursor, sys) << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void FrameBase::getCursorCmd(Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + if (currentContext->cfits) + printFromRef(currentContext->cfits, cursor, sys, sky, format); + else + Tcl_AppendResult(interp, "0 0", NULL); +} + +void FrameBase::gridCmd(Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, Grid::GridType type, + const char* ops, const char* vars) +{ + if (grid) + delete grid; + grid = new Grid2d(this, sys, sky, format, type, ops, vars); + + update(PIXMAP); +} + +void FrameBase::iisCursorModeCmd(int state) +{ + if (state) { + // set iisLastCursor if first time thru + if (iisLastCursor[0] == 0 && iisLastCursor[1] == 0) + iisLastCursor = Vector(options->width,options->height)/2; + + // and move to last cursor position + Vector rr = iisLastCursor * widgetToWindow; + warpTo(rr); + } +} + +void FrameBase::iisGetCursorCmd() +{ + ostringstream str; + str << iisLastCursor << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void FrameBase::iisGetFileNameCmd() +{ + FitsImage* ptr = currentContext->fits; + while (ptr && ptr->nextMosaic()) + ptr = ptr->nextMosaic(); + + if (ptr) + Tcl_AppendResult(interp, ptr->iisGetFileName(), NULL); +} + +void FrameBase::iisGetFileNameCmd(int which) +{ + FitsImage* ptr = currentContext->fits; + for (int i=0; i<(which-1); i++) { + if (ptr) + ptr = ptr->nextMosaic(); + } + + if (ptr) + Tcl_AppendResult(interp, ptr->iisGetFileName(), NULL); +} + +void FrameBase::iisGetFileNameCmd(const Vector& vv) +{ + if (FitsImage* ptr = isInCFits(vv, Coord::CANVAS, NULL)) + Tcl_AppendResult(interp, ptr->iisGetFileName(), NULL); +} + +void FrameBase::iisMessageCmd(const char* ptr) +{ + if (!currentContext->cfits) + return; + + // do we have something? + if (!(ptr && *ptr)) + return; + + // filename + // note: the file name is the second value passed + char fn[PATH_MAX]; + string x(ptr); + istringstream str(x); + str >> fn >> fn; + currentContext->cfits->setFileName(fn); + + // object name + // first go to end + char* sptr = (char*)ptr; + while (*sptr) + sptr++; + // now work backwards to last '-' + while (sptr != ptr) { + if (*sptr == '-') + break; + sptr--; + } + // is it good? + if (sptr != ptr) { + // go forward 2 + sptr += 2; + currentContext->cfits->setObjectKeyword(sptr); + } +} + +void FrameBase::iisSetCursorCmd(const Vector& v, Coord::InternalSystem sys) +{ + // assume canvas + if (!currentContext->cfits) + return; + + iisLastCursor = v * canvasToWidget; + + Vector rr = iisLastCursor * widgetToWindow; + warpTo(rr); +} + +void FrameBase::iisSetCursorCmd(const Vector& v, Coord::CoordSystem sys) +{ + if (!currentContext->cfits) + return; + + iisLastCursor = currentContext->cfits->mapToRef(v,sys) * refToWidget; + + Vector rr = iisLastCursor * widgetToWindow; + warpTo(rr); +} + +void FrameBase::iisSetFileNameCmd(const char* fn) +{ + FitsImage* ptr = currentContext->fits; + while (ptr && ptr->nextMosaic()) + ptr = ptr->nextMosaic(); + + if (ptr) + ptr->iisSetFileName(fn); +} + +void FrameBase::iisSetFileNameCmd(const char* fn, int which) +{ + FitsImage* ptr = currentContext->fits; + for (int i=0; i<(which-1); i++) { + if (ptr) + ptr = ptr->nextMosaic(); + } + + if (ptr) + ptr->iisSetFileName(fn); +} + +void FrameBase::panCmd(const Vector& v1, const Vector& v2) +{ + Vector start = mapToRef(v1,Coord::CANVAS); + Vector stop = mapToRef(v2,Coord::CANVAS); + cursor -= stop - start; + + setBinCursor(); + update(MATRIX); +} + +void FrameBase::panCmd(const Vector& vv) +{ + Vector uu = mapFromRef(cursor,Coord::CANVAS); + uu += vv; + cursor = mapToRef(uu,Coord::CANVAS); + + setBinCursor(); + update(MATRIX); +} + +void FrameBase::panCmd(const Vector& vv, Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + if (!currentContext->cfits) + return; + + Vector uu = currentContext->cfits->mapFromRef(cursor, sys, sky); + uu += vv; + cursor = currentContext->cfits->mapToRef(uu, sys, sky); + + setBinCursor(); + update(MATRIX); +} + +void FrameBase::panToCmd(const Vector& vv) +{ + cursor = mapToRef(vv,Coord::CANVAS); + + setBinCursor(); + update(MATRIX); +} + +void FrameBase::panToCmd(const Vector& vv, Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + if (!currentContext->cfits) + return; + + cursor = currentContext->cfits->mapToRef(vv, sys, sky); + + setBinCursor(); + update(MATRIX); +} + +void FrameBase::panBBoxCmd(const Vector& vv) +{ + if (!currentContext->cfits) + return; + + // we want to round to nearest pixel center + Vector rr = vv * currentContext->cfits->pannerToData; + cursor = (rr.floor() + Vector(.5,.5)) * currentContext->cfits->dataToRef; + + setBinCursor(); + update(MATRIX); +} + +void FrameBase::panEndCmd(const Vector& vv) +{ + // vv and panCursor are in Coord::CANVAS coords + // delete tmp pixmap + if (panPM) + Tk_FreePixmap(display, panPM); + panPM = 0; + + // use matrix, not map() for 3d? + Vector start = panCursor * canvasToRef; + Vector stop = vv * canvasToRef; + cursor -= stop - start; + + setBinCursor(); + update(MATRIX); +} + +void FrameBase::rotateBeginCmd() +{ + // save the current rotation + rotateRotation = rotation; + + // Create src XImage + if (!(rotateSrcXM = XGetImage(display, pixmap, 0, 0, + options->width, options->height, + AllPlanes, ZPixmap))) { + internalError("Unable to Create Rotate XImage"); + return; + } + + // Create dest XImage + if (!(rotateDestXM = XGetImage(display, pixmap, 0, 0, + options->width, options->height, + AllPlanes, ZPixmap))) { + internalError("Unable to Create Rotate XImage"); + return; + } + + // Create dest Pixmap + rotatePM = Tk_GetPixmap(display, Tk_WindowId(tkwin), + options->width, options->height, depth); + if (!rotatePM) { + internalError("Unable to Create Rotate Motion Pixmap"); + return; + } +} + +void FrameBase::rotateMotionCmd(double angle) +{ + rotation = rotateRotation + angle; + rotateMotion(); +} + +void FrameBase::rotateEndCmd() +{ + // Clean up + if (rotateSrcXM) + XDestroyImage(rotateSrcXM); + + if (rotateDestXM) + XDestroyImage(rotateDestXM); + + if (rotatePM) + Tk_FreePixmap(display, rotatePM); + + update(MATRIX); +} + +void FrameBase::saveFitsResampleFileCmd(const char* fn) +{ + OutFitsFile str(fn); + saveFitsResample(str); +} + +void FrameBase::saveFitsResampleChannelCmd(const char* ch) +{ + OutFitsChannel str(interp, ch); + saveFitsResample(str); +} + +void FrameBase::saveFitsResampleSocketCmd(int ss) +{ + OutFitsSocket str(ss); + saveFitsResample(str); +} + +void FrameBase::zoomAboutCmd(const Vector& zz, const Vector& vv) +{ + Vector az = ((Vector&)zz).abs(); + zoom_[0] *= az[0]; + zoom_[1] *= az[1]; + + cursor = mapToRef(vv,Coord::CANVAS); + + setBinCursor(); + update(MATRIX); +} + +void FrameBase::zoomAboutCmd(const Vector& z, const Vector& vv, + Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + Vector az = ((Vector&)z).abs(); + zoom_[0] *= az[0]; + zoom_[1] *= az[1]; + + if (currentContext->cfits) { + cursor = currentContext->cfits->mapToRef(vv, sys, sky); + setBinCursor(); + } + update(MATRIX); +} + +void FrameBase::zoomToAboutCmd(const Vector& z, const Vector& vv) +{ + zoom_ = ((Vector&)z).abs(); + + cursor = mapToRef(vv,Coord::CANVAS); + + setBinCursor(); + update(MATRIX); +} + +void FrameBase::zoomToAboutCmd(const Vector& z, const Vector& vv, + Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + zoom_ = ((Vector&)z).abs(); + + if (currentContext->cfits) { + cursor = currentContext->cfits->mapToRef(vv, sys, sky); + setBinCursor(); + } + update(MATRIX); +} + +void FrameBase::zoomToFitCmd(double ss) +{ + // will center image on center of pixel + // with even number pixels, it will be shifted + + if (keyContext->fits) { + centerImage(); + + Vector tt = imageSize(keyContext->secMode()); + + // adjust image size to be odd (see above) + double dd; // dummy + if (!modf(tt[0]/2,&dd)) + tt[0] +=1; + if (!modf(tt[1]/2,&dd)) + tt[1] +=1; + + double zz = calcZoom(tt,Vector(options->width,options->height)) * ss; + zoom_ = Vector(zz,zz); + update(MATRIX); + } +} + + + + + + diff --git a/tksao/frame/frload.C b/tksao/frame/frload.C new file mode 100644 index 0000000..d653dfc --- /dev/null +++ b/tksao/frame/frload.C @@ -0,0 +1,756 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "context.h" +#include "fitsimage.h" + +#include "alloc.h" +#include "allocgz.h" +#include "channel.h" +#include "mmap.h" +#include "mmapincr.h" +#include "share.h" +#include "sshare.h" +#include "socket.h" +#include "socketgz.h" +#include "var.h" + +// *** Fits *** + +void Base::loadFitsAllocCmd(const char* ch, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageFitsAlloc(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->load(ALLOC, fn, img, ll),ll); +} + +void Base::loadFitsAllocGZCmd(const char* ch, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageFitsAllocGZ(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->load(ALLOCGZ, fn, img, ll),ll); +} + +void Base::loadFitsChannelCmd(const char* ch, const char* fn,LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageFitsChannel(currentContext, interp, + ch, fn, + FitsFile::NOFLUSH, 1); + loadDone(currentContext->load(CHANNEL, fn, img, ll),ll); +} + +void Base::loadFitsMMapCmd(const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageFitsMMap(currentContext, interp, + fn, 1); + loadDone(currentContext->load(MMAP, fn, img, ll),ll); +} + +void Base::loadFitsSMMapCmd(const char* hdr, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageFitsSMMap(currentContext, interp, + hdr, fn, 1); + loadDone(currentContext->load(SMMAP, fn, img, ll),ll); +} + +void Base::loadFitsMMapIncrCmd(const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageFitsMMapIncr(currentContext, interp, + fn, 1); + loadDone(currentContext->load(MMAPINCR, fn, img, ll),ll); +} + +void Base::loadFitsShareCmd(ShmType stype, int id, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageFitsShare(currentContext, interp, + stype, id, fn, 1); + loadDone(currentContext->load(SHARE, fn, img, ll),ll); +} + +void Base::loadFitsSShareCmd(ShmType stype, int hdr, int id, + const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageFitsSShare(currentContext, interp, + stype, hdr, id, fn, 1); + loadDone(currentContext->load(SSHARE, fn, img, ll),ll); +} + +void Base::loadFitsSocketCmd(int s, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageFitsSocket(currentContext, interp, + s, fn, FitsFile::FLUSH, 1); + loadDone(currentContext->load(SOCKET, fn, img, ll),ll); +} + +void Base::loadFitsSocketGZCmd(int s, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageFitsSocketGZ(currentContext, interp, + s, fn, FitsFile::FLUSH, 1); + loadDone(currentContext->load(SOCKETGZ, fn, img, ll),ll); +} + +void Base::loadFitsVarCmd(const char* ch, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageFitsVar(currentContext, interp, + ch, fn, 1); + loadDone(currentContext->load(VAR, fn, img, ll),ll); +} + +// *** Array *** + +void Base::loadArrAllocCmd(const char* ch, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageArrAlloc(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->load(ALLOC, fn, img, ll),ll); +} + +void Base::loadArrAllocGZCmd(const char* ch, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageArrAllocGZ(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->load(ALLOCGZ, fn, img, ll),ll); +} + +void Base::loadArrChannelCmd(const char* ch, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageArrChannel(currentContext, interp, + ch, fn, + FitsFile::NOFLUSH, 1); + loadDone(currentContext->load(CHANNEL, fn, img, ll),ll); +} + +void Base::loadArrMMapCmd(const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageArrMMap(currentContext, interp, + fn, 1); + loadDone(currentContext->load(MMAP, fn, img, ll),ll); +} + +void Base::loadArrMMapIncrCmd(const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageArrMMapIncr(currentContext, interp, + fn, 1); + loadDone(currentContext->load(MMAPINCR, fn, img, ll),ll); +} + +void Base::loadArrShareCmd(ShmType stype, int id, const char* fn, + LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageArrShare(currentContext, interp, + stype, id, fn, 1); + loadDone(currentContext->load(SHARE, fn, img, ll),ll); +} + +void Base::loadArrSocketCmd(int s, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageArrSocket(currentContext, interp, + s, fn, FitsFile::FLUSH, 1); + loadDone(currentContext->load(SOCKET, fn, img, ll),ll); +} + +void Base::loadArrSocketGZCmd(int s, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageArrSocketGZ(currentContext, interp, + s, fn, FitsFile::FLUSH, 1); + loadDone(currentContext->load(SOCKETGZ, fn, img, ll),ll); +} + +void Base::loadArrVarCmd(const char* ch, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageArrVar(currentContext, interp, + ch, fn, 1); + loadDone(currentContext->load(VAR, fn, img, ll),ll); +} + +// *** ENVI *** + +void Base::loadENVISMMapCmd(const char* hdr, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageENVISMMap(currentContext, interp, hdr, fn, 1); + loadDone(currentContext->load(SMMAP, fn, img, IMG), IMG); +} + +// *** NRRD *** + +void Base::loadNRRDAllocCmd(const char* ch, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageNRRDAlloc(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->load(ALLOC, fn, img, ll),ll); +} + +void Base::loadNRRDChannelCmd(const char* ch, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageNRRDChannel(currentContext, interp, + ch, fn, + FitsFile::NOFLUSH, 1); + loadDone(currentContext->load(CHANNEL, fn, img, ll),ll); +} + +void Base::loadNRRDMMapCmd(const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageNRRDMMap(currentContext, interp, fn, 1); + loadDone(currentContext->load(MMAP, fn, img, ll),ll); +} + +void Base::loadNRRDShareCmd(ShmType stype, int id, const char* fn, + LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageNRRDShare(currentContext, interp, + stype, id, fn, 1); + loadDone(currentContext->load(SHARE, fn, img, ll),ll); +} + +void Base::loadNRRDSocketCmd(int s, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageNRRDSocket(currentContext, interp, + s, fn, FitsFile::FLUSH, 1); + loadDone(currentContext->load(SOCKET, fn, img, ll),ll); +} + +void Base::loadNRRDVarCmd(const char* ch, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageNRRDVar(currentContext, interp, + ch, fn, 1); + loadDone(currentContext->load(VAR, fn, img, ll),ll); +} + +// *** Photo *** + +void Base::loadPhotoCmd(const char* ph, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImagePhoto(currentContext, interp, + ph, fn, 1); + loadDone(currentContext->load(PHOTO, fn, img, IMG), IMG); +} + +void Base::loadSlicePhotoCmd(const char* ph, const char* fn) +{ + FitsImage* img = new FitsImagePhoto(currentContext, interp, + ph, fn, 1); + loadDone(currentContext->loadSlice(PHOTO, fn, img), IMG); +} + +// *** Data Cube *** + +void Base::loadExtCubeAllocCmd(const char* ch, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsAlloc(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadExtCube(ALLOC, fn, img), IMG); +} + +void Base::loadExtCubeAllocGZCmd(const char* ch, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsAllocGZ(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadExtCube(ALLOCGZ, fn, img), IMG); +} + +void Base::loadExtCubeChannelCmd(const char* ch, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsChannel(currentContext, interp, + ch, fn, + FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadExtCube(CHANNEL, fn, img), IMG); +} + +void Base::loadExtCubeMMapCmd(const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsMMap(currentContext, interp, + fn, 1); + loadDone(currentContext->loadExtCube(MMAP, fn, img), IMG); +} + +void Base::loadExtCubeMMapIncrCmd(const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsMMapIncr(currentContext, interp, + fn, 1); + loadDone(currentContext->loadExtCube(MMAPINCR, fn, img), IMG); +} + +void Base::loadExtCubeShareCmd(ShmType stype, int id, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsShare(currentContext, interp, + stype, id, fn, 1); + loadDone(currentContext->loadExtCube(SHARE, fn, img), IMG); +} + +void Base::loadExtCubeSocketCmd(int s, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsSocket(currentContext, interp, + s, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadExtCube(SOCKET, fn, img), IMG); +} + +void Base::loadExtCubeSocketGZCmd(int s, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsSocketGZ(currentContext, interp, + s, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadExtCube(SOCKETGZ, fn, img), IMG); +} + +void Base::loadExtCubeVarCmd(const char* ch, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsVar(currentContext, interp, + ch, fn, 1); + loadDone(currentContext->loadExtCube(VAR, fn, img), IMG); +} + +// *** Slice *** + +void Base::loadSliceAllocCmd(const char* ch, const char* fn) +{ + FitsImage* img = new FitsImageFitsAlloc(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadSlice(ALLOC, fn, img), IMG); +} + +void Base::loadSliceAllocGZCmd(const char* ch, const char* fn) +{ + FitsImage* img = new FitsImageFitsAllocGZ(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadSlice(ALLOCGZ, fn, img), IMG); +} + +void Base::loadSliceChannelCmd(const char* ch, const char* fn) +{ + FitsImage* img = new FitsImageFitsChannel(currentContext, interp, + ch, fn, + FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadSlice(CHANNEL, fn, img), IMG); +} + +void Base::loadSliceMMapCmd(const char* fn) +{ + FitsImage* img = new FitsImageFitsMMap(currentContext, interp, + fn, 1); + loadDone(currentContext->loadSlice(MMAP, fn, img), IMG); +} + +void Base::loadSliceSMMapCmd(const char* hdr, const char* fn) +{ + FitsImage* img = new FitsImageFitsSMMap(currentContext, interp, + hdr, fn, 1); + loadDone(currentContext->loadSlice(MMAP, fn, img), IMG); +} + +void Base::loadSliceMMapIncrCmd(const char* fn) +{ + FitsImage* img = new FitsImageFitsMMapIncr(currentContext, interp, + fn, 1); + loadDone(currentContext->loadSlice(MMAPINCR, fn, img), IMG); +} + +void Base::loadSliceShareCmd(ShmType stype, int id, const char* fn) +{ + FitsImage* img = new FitsImageFitsShare(currentContext, interp, + stype, id, fn, 1); + loadDone(currentContext->loadSlice(SHARE, fn, img), IMG); +} + +void Base::loadSliceSShareCmd(ShmType stype, int hdr, int id, const char* fn) +{ + FitsImage* img = new FitsImageFitsSShare(currentContext, interp, + stype, hdr, id, fn, 1); + loadDone(currentContext->loadSlice(SSHARE, fn, img), IMG); +} + +void Base::loadSliceSocketCmd(int s, const char* fn) +{ + FitsImage* img = new FitsImageFitsSocket(currentContext, interp, + s, fn, FitsFile::FLUSH, 1); + loadDone(currentContext->loadSlice(SOCKET, fn, img), IMG); +} + +void Base::loadSliceSocketGZCmd(int s, const char* fn) +{ + FitsImage* img = new FitsImageFitsSocketGZ(currentContext, interp, + s, fn, FitsFile::FLUSH, 1); + loadDone(currentContext->loadSlice(SOCKETGZ, fn, img), IMG); +} + +void Base::loadSliceVarCmd(const char* ch, const char* fn) +{ + FitsImage* img = new FitsImageFitsVar(currentContext, interp, + ch, fn, 1); + loadDone(currentContext->loadSlice(VAR, fn, img), IMG); +} + +// *** Mosaic Image *** + +void Base::loadMosaicImageAllocCmd(MosaicType type, Coord::CoordSystem sys, + const char* ch, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageMosaicAlloc(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadMosaicImage(ALLOC, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicImageAllocGZCmd(MosaicType type, Coord::CoordSystem sys, + const char* ch, const char* fn, + LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageMosaicAllocGZ(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadMosaicImage(ALLOCGZ, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicImageChannelCmd(MosaicType type, Coord::CoordSystem sys, + const char* ch, const char* fn, + LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageMosaicChannel(currentContext, interp, + ch, fn, + FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadMosaicImage(CHANNEL, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicImageMMapCmd(MosaicType type, Coord::CoordSystem sys, + const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageMosaicMMap(currentContext, interp, + fn, 1); + loadDone(currentContext->loadMosaicImage(MMAP, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicImageMMapIncrCmd(MosaicType type, Coord::CoordSystem sys, + const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageMosaicMMapIncr(currentContext, interp, + fn, 1); + loadDone(currentContext->loadMosaicImage(MMAPINCR, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicImageShareCmd(MosaicType type, Coord::CoordSystem sys, + ShmType stype, int id, const char* fn, + LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageMosaicShare(currentContext, interp, + stype, id, fn, 1); + loadDone(currentContext->loadMosaicImage(SHARE, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicImageSocketCmd(MosaicType type, Coord::CoordSystem sys, + int s, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageMosaicSocket(currentContext, interp, + s, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadMosaicImage(SOCKET, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicImageSocketGZCmd(MosaicType type, + Coord::CoordSystem sys, + int s, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageMosaicSocketGZ(currentContext, interp, + s, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadMosaicImage(SOCKETGZ, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicImageVarCmd(MosaicType type, Coord::CoordSystem sys, + const char* ch, const char* fn, LayerType ll) +{ + if (ll == IMG) + unloadFits(); + FitsImage* img = new FitsImageMosaicVar(currentContext, interp, + ch, fn, 1); + loadDone(currentContext->loadMosaicImage(VAR, fn, img, ll,type,sys),ll); +} + +// *** Mosaic *** + +void Base::loadMosaicAllocCmd(MosaicType type, Coord::CoordSystem sys, + const char* ch, const char* fn, LayerType ll) +{ + FitsImage* img = new FitsImageFitsAlloc(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadMosaic(ALLOC, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicAllocGZCmd(MosaicType type, Coord::CoordSystem sys, + const char* ch, const char* fn, LayerType ll) +{ + FitsImage* img = new FitsImageFitsAllocGZ(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadMosaic(ALLOCGZ, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicChannelCmd(MosaicType type, Coord::CoordSystem sys, + const char* ch, const char* fn, LayerType ll) +{ + FitsImage* img = new FitsImageFitsChannel(currentContext, interp, + ch, fn, + FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadMosaic(CHANNEL, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicMMapCmd(MosaicType type, Coord::CoordSystem sys, + const char* fn, LayerType ll) +{ + FitsImage* img = new FitsImageFitsMMap(currentContext, interp, + fn, 1); + loadDone(currentContext->loadMosaic(MMAP, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicSMMapCmd(MosaicType type, Coord::CoordSystem sys, + const char* hdr, const char* fn, + LayerType ll) +{ + FitsImage* img = new FitsImageFitsSMMap(currentContext, interp, + hdr, fn, 1); + loadDone(currentContext->loadMosaic(MMAP, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicMMapIncrCmd(MosaicType type, Coord::CoordSystem sys, + const char* fn, LayerType ll) +{ + FitsImage* img = new FitsImageFitsMMapIncr(currentContext, interp, + fn, 1); + loadDone(currentContext->loadMosaic(MMAPINCR, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicShareCmd(MosaicType type, Coord::CoordSystem sys, + ShmType stype, int id, const char* fn, + LayerType ll) +{ + FitsImage* img = new FitsImageFitsShare(currentContext, interp, + stype, id, fn, 1); + loadDone(currentContext->loadMosaic(SHARE, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicSShareCmd(MosaicType type, Coord::CoordSystem sys, + ShmType stype, int hdr, int id, const char* fn, + LayerType ll) +{ + FitsImage* img = new FitsImageFitsSShare(currentContext, interp, + stype, hdr, id, fn, 1); + loadDone(currentContext->loadMosaic(SSHARE, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicSocketCmd(MosaicType type, Coord::CoordSystem sys, + int s, const char* fn, LayerType ll) +{ + FitsImage* img = new FitsImageFitsSocket(currentContext, interp, + s, fn, FitsFile::FLUSH, 1); + loadDone(currentContext->loadMosaic(SOCKET, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicSocketGZCmd(MosaicType type, Coord::CoordSystem sys, + int s, const char* fn, LayerType ll) +{ + FitsImage* img = new FitsImageFitsSocketGZ(currentContext, interp, + s, fn, FitsFile::FLUSH, 1); + loadDone(currentContext->loadMosaic(SOCKETGZ, fn, img, ll,type,sys),ll); +} + +void Base::loadMosaicVarCmd(MosaicType type, Coord::CoordSystem sys, + const char* ch, const char* fn, + LayerType ll) +{ + FitsImage* img = new FitsImageFitsVar(currentContext, interp, + ch, fn, 1); + loadDone(currentContext->loadMosaic(VAR, fn, img, ll,type,sys),ll); +} + +// *** Mosaic Image WFPC2 *** + +void Base::loadMosaicImageWFPC2AllocCmd(const char* ch, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsAlloc(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadMosaicWFPC2(ALLOC, fn, img), IMG); +} + +void Base::loadMosaicImageWFPC2AllocGZCmd(const char* ch, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsAllocGZ(currentContext, interp, + ch, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadMosaicWFPC2(ALLOCGZ, fn, img), IMG); +} + +void Base::loadMosaicImageWFPC2ChannelCmd(const char* ch, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsChannel(currentContext, interp, + ch, fn, + FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadMosaicWFPC2(CHANNEL, fn, img), IMG); +} + +void Base::loadMosaicImageWFPC2MMapCmd(const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsMMap(currentContext, interp, + fn, 1); + loadDone(currentContext->loadMosaicWFPC2(MMAP, fn, img), IMG); +} + +void Base::loadMosaicImageWFPC2MMapIncrCmd(const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsMMapIncr(currentContext, interp, + fn, 1); + loadDone(currentContext->loadMosaicWFPC2(MMAPINCR, fn, img), IMG); +} + +void Base::loadMosaicImageWFPC2ShareCmd(ShmType stype, int id, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsShare(currentContext, interp, + stype, id, fn, 1); + loadDone(currentContext->loadMosaicWFPC2(SHARE, fn, img), IMG); +} + +void Base::loadMosaicImageWFPC2SocketCmd(int s, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsSocket(currentContext, interp, + s, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadMosaicWFPC2(SOCKET, fn, img), IMG); +} + +void Base::loadMosaicImageWFPC2SocketGZCmd(int s, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsSocketGZ(currentContext, interp, + s, fn, FitsFile::NOFLUSH, 1); + loadDone(currentContext->loadMosaicWFPC2(SOCKETGZ, fn, img), IMG); +} + +void Base::loadMosaicImageWFPC2VarCmd(const char* ch, const char* fn) +{ + unloadFits(); + FitsImage* img = new FitsImageFitsVar(currentContext, interp, + ch, fn, 1); + loadDone(currentContext->loadMosaicWFPC2(VAR, fn, img), IMG); +} + +// *** + +void Base::loadDone(int rr, LayerType ll) +{ + if (rr) { + if (ll == IMG) { + if (!keyContextSet) { + keyContext = currentContext; + keyContextSet =1; + } + } + alignWCS(); + if (!preservePan) { + centerImage(); + crosshair = cursor; + } + } + else { + reset(); + Tcl_AppendResult(interp, "Unable to load file", NULL); + result = TCL_ERROR; + } + + // adjust current slice if needed + if (currentContext->fits && isCube() && + currentContext->secMode()==FrScale::CROPSEC) { + + // context->slice() IMAGE (ranges 1-n) + // params are in DATA coords, edge to edge + // setSlice() IMAGE (ranges 1-n) + double sl = currentContext->slice(2)-.5; + FitsZBound* zparams = + currentContext->getDataParams(currentContext->secMode()); + double ff = zparams->zmin+.5; + double tt = zparams->zmax-.5; + if (sltt) + setSlice(2,tt+.5); + } + + updateColorScale(); + update(MATRIX); +} + diff --git a/tksao/frame/frmap.C b/tksao/frame/frmap.C new file mode 100644 index 0000000..feb267a --- /dev/null +++ b/tksao/frame/frmap.C @@ -0,0 +1,161 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "context.h" +#include "framebase.h" +#include "fitsimage.h" + +double Base::mapAngleFromRef(double angle, Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + double rr = angle; + FitsImage* ptr = currentContext->cfits; + if (!ptr) + return 0; + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + break; + default: + switch (ptr->getWCSOrientation(sys,sky)) { + case Coord::NORMAL: + rr += ptr->getWCSRotation(sys,sky); + break; + case Coord::XX: + rr = -(angle + ptr->getWCSRotation(sys,sky) + M_PI); + break; + case Coord::YY: + case Coord::XY: + break; + } + } + + return zeroTWOPI(rr); +} + +double Base::mapAngleToRef(double angle, Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + double rr = angle; + FitsImage* ptr = currentContext->cfits; + if (!ptr) + return 0; + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + break; + default: + switch (ptr->getWCSOrientation(sys,sky)) { + case Coord::NORMAL: + rr -= ptr->getWCSRotation(sys,sky); + break; + case Coord::XX: + rr = -(angle + ptr->getWCSRotation(sys,sky) + M_PI); + break; + case Coord::YY: + case Coord::XY: + break; + } + } + + return zeroTWOPI(rr); +} + +double Base::mapDistFromRef(const Vector& v1, const Vector& v2, + Coord::InternalSystem sys) +{ + switch (sys) { + case Coord::CANVAS: + return (v2*refToCanvas - v1*refToCanvas).length(); + case Coord::PANNER: + return (v2*refToPanner - v1*refToPanner).length(); + default: + // na + return 0; + } +} + +double Base::mapLenFromRef(double d, Coord::InternalSystem sys) +{ + Vector r = mapLenFromRef(Vector(d,0),sys); + return r[0]; +} + +Vector Base::mapLenFromRef(const Vector& v, Coord::InternalSystem sys) +{ + switch (sys) { + case Coord::CANVAS: + return mapLen(v,refToCanvas); + case Coord::PANNER: + return mapLen(v,refToPanner); + default: + return Vector(); + } +} + +double Base::mapLenToRef(double d, Coord::InternalSystem sys) +{ + Vector r = mapLenToRef(Vector(d,0),sys); + return r[0]; +} + +Vector Base::mapLenToRef(const Vector& v, Coord::InternalSystem sys) +{ + switch (sys) { + case Coord::CANVAS: + return mapLen(v,canvasToRef); + case Coord::PANNER: + return mapLen(v,pannerToRef); + default: + return Vector(); + } +} + +Vector FrameBase::mapFromRef(const Vector& vv, Coord::InternalSystem sys) +{ + switch (sys) { + case Coord::REF: + return vv; + case Coord::USER: + return vv * refToUser; + case Coord::WIDGET: + return vv * refToWidget; + case Coord::CANVAS: + return vv * refToCanvas; + case Coord::WINDOW: + return vv * refToWindow; + case Coord::PANNER: + return vv * refToPanner; + case Coord::MAGNIFIER: + return vv * refToMagnifier; + default: + return Vector(); + } +} + +Vector FrameBase::mapToRef(const Vector& vv, Coord::InternalSystem sys) +{ + switch (sys) { + case Coord::REF: + return vv; + case Coord::USER: + return vv * userToRef; + case Coord::WIDGET: + return vv * widgetToRef; + case Coord::CANVAS: + return vv * canvasToRef; + case Coord::WINDOW: + return vv * windowToRef; + case Coord::PANNER: + return vv * pannerToRef; + case Coord::MAGNIFIER: + return vv * magnifierToRef; + default: + return Vector(); + } +} diff --git a/tksao/frame/frmarker.C b/tksao/frame/frmarker.C new file mode 100644 index 0000000..f9c82cb --- /dev/null +++ b/tksao/frame/frmarker.C @@ -0,0 +1,6759 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include "fdstream.hpp" + +#include "context.h" +#include "base.h" +#include "fitsimage.h" +#include "fvcontour.h" +#include "marker.h" +#include "basemarker.h" +#include "sigbus.h" + +#include "circle.h" +#include "ellipse.h" +#include "box.h" +#include "polygon.h" +#include "line.h" +#include "vect.h" +#include "projection.h" +#include "segment.h" + +#include "text.h" +#include "point.h" + +#include "ruler.h" +#include "compass.h" + +#include "annulus.h" +#include "ellipseannulus.h" +#include "boxannulus.h" + +#include "cpanda.h" +#include "epanda.h" +#include "bpanda.h" + +#include "composite.h" + +#define LISTBUFSIZE 8192 + +// NOTE: all marker traversal routines use a local ptr as opposed to the +// list current() because marker call backs may invoke another traversal +// routine or the event loop, which may process pending events + +// DS9/Funtools Marker Parser Stuff +// Parser Stuff +#undef yyFlexLexer +#define yyFlexLexer mkFlexLexer +#include + +void* mklval; +mkFlexLexer* mklexx; +extern int mkparse(Base*, mkFlexLexer*); + +int mklex(void* vval, mkFlexLexer* ll) +{ + mklval = vval; + mklexx = ll; + return ll ? ll->yylex() : 0; +} + +void mkerror(Base* fr, mkFlexLexer* ll, const char* m) +{ + fr->error(m); + const char* cmd = ll ? ll->YYText() : (const char*)NULL; + if (cmd && cmd[0] != '\n') { + fr->error(": "); + fr->error(cmd); + } +} + +// CIAO Marker Parser Stuff +#undef yyFlexLexer +#define yyFlexLexer ciaoFlexLexer +#include + +void* ciaolval; +extern int ciaoparse(Base*, ciaoFlexLexer*); + +int ciaolex(void* vval, ciaoFlexLexer* ll) +{ + ciaolval = vval; + return ll ? ll->yylex() : 0; +} + +void ciaoerror(Base* fr, ciaoFlexLexer* ll, const char* m) +{ + fr->error(m); + const char* cmd = ll ? ll->YYText() : (const char*)NULL; + if (cmd && cmd[0] != '\n') { + fr->error(": "); + fr->error(cmd); + } +} + +// PROS Marker Parser Stuff +#undef yyFlexLexer +#define yyFlexLexer prosFlexLexer +#include + +void* proslval; +prosFlexLexer* proslexx; +extern int prosparse(Base*, prosFlexLexer*); + +int proslex(void* vval, prosFlexLexer* ll) +{ + proslval = vval; + proslexx = ll; + return ll ? ll->yylex() : 0; +} + +void proserror(Base* fr, prosFlexLexer* ll, const char* m) +{ + fr->error(m); + const char* cmd = ll ? ll->YYText() : (const char*)NULL; + if (cmd && cmd[0] != '\n') { + fr->error(": "); + fr->error(cmd); + } +} + +// TNG Marker Parser Stuff +#undef yyFlexLexer +#define yyFlexLexer tngFlexLexer +#include + +void* tnglval; +tngFlexLexer* tnglexx; +extern int tngparse(Base*, tngFlexLexer*); + +int tnglex(void* vval, tngFlexLexer* ll) +{ + tnglval = vval; + tnglexx = ll; + return ll ? ll->yylex() : 0; +} + +void tngerror(Base* fr, tngFlexLexer* ll, const char* m) +{ + fr->error(m); + const char* cmd = ll ? ll->YYText() : (const char*)NULL; + if (cmd && cmd[0] != '\n') { + fr->error(": "); + fr->error(cmd); + } +} + +// SAO Marker Parser Stuff +#undef yyFlexLexer +#define yyFlexLexer saoFlexLexer +#include + +void* saolval; +saoFlexLexer* saolexx; +extern int saoparse(Base*, saoFlexLexer*); + +int saolex(void* vval, saoFlexLexer* ll) +{ + saolval = vval; + saolexx = ll; + return ll ? ll->yylex() : 0; +} + +void saoerror(Base* fr, saoFlexLexer* ll, const char* m) +{ + fr->error(m); + const char* cmd = ll ? ll->YYText() : (const char*)NULL; + if (cmd && cmd[0] != '\n') { + fr->error(": "); + fr->error(cmd); + } +} + +// XY Marker Parser Stuff +#undef yyFlexLexer +#define yyFlexLexer xyFlexLexer +#include + +void* xylval; +extern int xyparse(Base*, xyFlexLexer*); + +int xylex(void* vval, xyFlexLexer* ll) +{ + xylval = vval; + return ll ? ll->yylex() : 0; +} + +void xyerror(Base* fr, xyFlexLexer* ll, const char* m) +{ + fr->error(m); + const char* cmd = ll ? ll->YYText() : (const char*)NULL; + if (cmd && cmd[0] != '\n') { + fr->error(": "); + fr->error(cmd); + } +} + +// IME Analysis Commands + +/* +void Base::analysisMarkersInit() +{ + Vector cc; + double rr =20; + Vector ss(40,20); + double ang =0; + double mag =20; + double in =0; + double out =20; + int num =10; + Vector vin(0,0); + Vector vout(40,20); + + analysisMarkers.append(new Circle(this, cc, rr)); + analysisMarkers.append(new Box(this, cc, ss, ang)); + analysisMarkers.append(new Ellipse(this, cc, ss, ang)); + analysisMarkers.append(new Polygon(this, cc, ss)); + analysisMarkers.append(new Point(this, cc)); + analysisMarkers.append(new Vect(this, cc, mag, ang)); + analysisMarkers.append(new Annulus(this, cc, in, out, num)); + analysisMarkers.append(new EllipseAnnulus(this, cc, vin, vout, num, ang)); + analysisMarkers.append(new BoxAnnulus(this, cc, vin, vout, num, ang)); + + Marker* mm = analysisMarkers.head(); + while (mm) { + mm->setProperty(Marker::SELECT, 1); + mm->setProperty(Marker::EDIT, 1); + mm->setProperty(Marker::ROTATE, 1); + mm = mm->next(); + } +} +*/ + +void Base::analysisMarkersResetCmd() +{ + /* + if (analysisMarkers.isEmpty()) + analysisMarkersInit(); + + Marker* mm = analysisMarkers.head(); + while (mm) { + mm->setProperty(Marker::HIDDEN, 1); + mm = mm->next(); + } + */ +} + +void Base::analysisMarkersSelectCmd(const char* which, const Vector& cc) +{ + /* + // reset + analysisMarkersResetCmd(); + + Marker* mm = analysisMarkers.head(); + while (mm) { + if (!strcmp(mm->getType(),which)) { + mm->setProperty(Marker::HIDDEN, 0); + mm->moveTo(cc); + update(PIXMAP); + return; + } + mm = mm->next(); + } + */ +} + +// Basic Regions +void Base::createCircleCmd(const Vector& center, + double radius, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Circle(this, center, + radius, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createEllipseCmd(const Vector& center, + const Vector& radius, + double angle, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag,const List& cb) + +{ + createMarker(new Ellipse(this,center, + radius, + angle, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createBoxCmd(const Vector& center, + const Vector& size, + double angle, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Box(this, center, + size, + angle, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createPolygonCmd(const Vector& center, + const Vector& bb, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Polygon(this, center, + bb, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createPolygonCmd(const List& list, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Polygon(this, list, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::contourCreatePolygonCmd() +{ + // only create in the USER layer + markerLayerCmd(USER); + + contourCreatePolygon(currentContext->fvcontour().lcontourlevel()); + contourCreatePolygon(currentContext->auxcontours()); + + currentContext->contourDeleteFV(); + currentContext->contourDeleteAux(); +} + +void Base::contourCreatePolygon(List& cl) +{ + int dl[2]; + dl[0] = 8; + dl[1] = 3; + char font[] = "helvetica 10 normal roman"; + char text[] = ""; + unsigned short defaultProps = Marker::SELECT | Marker::HIGHLITE | + Marker::EDIT | Marker::MOVE | Marker::ROTATE | + Marker::DELETE | Marker::INCLUDE | Marker::SOURCE; + const List tag; + const List cb; + + // back to front for levels + if (cl.tail()) { + do { + const char* color = cl.current()->colorName(); + int width = cl.current()->lineWidth(); + unsigned short prop = defaultProps; + if (cl.current()->dash()) + prop |= Marker::DASH; + + List& cc = cl.current()->lcontour(); + cc.head(); + while (cc.current()) { + List& vv = cc.current()->lvertex(); + if (!vv.isEmpty()) + createMarker(new Polygon(this, vv, color, dl, width, font, + text, prop, NULL, tag, cb)); + cc.next(); + } + } + while (cl.previous()); + } +} + +void Base::createSegmentCmd(const Vector& center, + const Vector& bb, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Segment(this, center, + bb, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createSegmentCmd(const List& list, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Segment(this, list, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createLineCmd(const Vector& center, const Vector& p2, + int arrow1, int arrow2, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Line(this, center, p2, arrow1, arrow2, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createVectCmd(const Vector& center, const Vector& p2, + int arrow, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Vect(this, center, p2, arrow, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createVectCmd(const Vector& center, double mag, double ang, + int arrow, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Vect(this, center, mag, ang, arrow, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createTextCmd(const Vector& center, double angle, int rotate, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Text(this, center, angle, rotate, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createPointCmd(const Vector& center, + Point::PointShape shape, int size, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, + const List& cb) +{ + createMarker(new Point(this, center, shape, size, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +// Measurement Regions +void Base::createRulerCmd(const Vector& center, const Vector& p2, + Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::CoordSystem distsys, Coord::SkyDist distdist, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Ruler(this, center, p2, + sys, sky, distsys, distdist, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createCompassCmd(const Vector& center, double r, + const char* north, const char* east, + int na, int ea, + Coord::CoordSystem sys, Coord::SkyFrame sky, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, + const List& cb) +{ + createMarker(new Compass(this, center, r, north, east, na, ea, sys, sky, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createProjectionCmd(const Vector& center, + const Vector& p2, double w, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, + const List& cb) +{ + createMarker(new Projection(this, center, + p2, w, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +// Annulus Regions +void Base::createAnnulusCmd(const Vector& center, + double start, double stop, int num, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag,const List& cb) +{ + createMarker(new Annulus(this, center, + start, stop, num, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createAnnulusCmd(const Vector& center, + int num, double* radii, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag,const List& cb) +{ + createMarker(new Annulus(this, center, + num, radii, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createEllipseAnnulusCmd(const Vector& center, + const Vector& inner, + const Vector& outer, int num, + double angle, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, + const List& cb) +{ + createMarker(new EllipseAnnulus(this, center, + inner, outer, num, + angle, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createEllipseAnnulusCmd(const Vector& center, + int num, Vector* radii, + double angle, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, + const List& cb) +{ + createMarker(new EllipseAnnulus(this, center, + num, radii, + angle, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createBoxAnnulusCmd(const Vector& center, + const Vector& inner, const Vector& outer, + int num, + double angle, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, + const List& cb) +{ + createMarker(new BoxAnnulus(this, center, + inner, outer, num, + angle, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createBoxAnnulusCmd(const Vector& center, + int num, Vector* size, + double angle, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, + const List& cb) +{ + createMarker(new BoxAnnulus(this, center, + num, size, + angle, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +// Panda Regions +void Base::createCpandaCmd(const Vector& center, + double ang1, double ang2, int an, + double rad1, double rad2, int rn, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Cpanda(this, center, + ang1, ang2, an, + rad1, rad2, rn, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createCpandaCmd(const Vector& center, + int an, double* a, + int rn, double* r, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Cpanda(this, center, + an, a, + rn, r, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createEpandaCmd(const Vector& center, + double ang1, double ang2, int an, + const Vector& rad1, const Vector& rad2, int rn, + double angle, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Epanda(this, center, + ang1, ang2, an, + rad1, rad2, rn, + angle, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createEpandaCmd(const Vector& center, + int an, double* a, + int rn, Vector* r, + double angle, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Epanda(this, center, + an, a, + rn, r, + angle, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createBpandaCmd(const Vector& center, + double ang1, double ang2, int an, + const Vector& rad1, const Vector& rad2, int rn, + double angle, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Bpanda(this, center, + ang1, ang2, an, + rad1, rad2, rn, + angle, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +void Base::createBpandaCmd(const Vector& center, + int an, double* a, + int rn, Vector* r, + double angle, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, const List& cb) +{ + createMarker(new Bpanda(this, center, + an, a, + rn, r, + angle, + color, dash, width, font, text, + prop, comment, tag, cb)); +} + +// Composite Regions +void Base::createCompositeCmd(const Vector& center, double angle, + int global, + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, + const List& cb) +{ + Composite* m = new Composite(this, center, angle, global, + color, dash, width, font, text, + prop, comment, tag, cb); + createMarker(m); + compositeMarker = m; +} + +void Base::createCompositeCmd( + const char* color, int* dash, + int width, const char* font, + const char* text, unsigned short prop, + const char* comment, + const List& tag, + const List& cb) +{ + // find center + Vector cc; + int cnt=0; + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected() && strncmp(mm->getType(),"composite", 9)) { + cc += mm->getCenter(); + cnt++; + } + mm=mm->next(); + } + cc /= cnt; + + // create composite + Composite* mk = new Composite(this, cc, 0, 1, color, dash, width, font, + text, prop, comment, tag, cb); + createMarker(mk); + + // append members + mm=markers->head(); + while (mm) { + if (mm->isSelected() && strncmp(mm->getType(),"composite",9)) { + mm->unselect(); + Marker* next = markers->extractNext(mm); + mm->doCallBack(CallBack::DELETECB); + mm->deleteCBs(); + mk->append(mm); + mm = next; + } + else + mm=mm->next(); + } + + // all done + mk->updateBBox(); + mk->select(); + + update(PIXMAP); +} + +// Template Regions +void Base::createTemplateCmd(const Vector& center, const char* fn) +{ + ifstream str(fn); + if (!str) { + result = TCL_ERROR; + return; + } + createTemplate(center,str); +} + +void Base::createTemplateCmd(const Vector& v, Coord::CoordSystem sys, + Coord::SkyFrame sky, const char* fn) +{ + ifstream str(fn); + if (!str) { + result = TCL_ERROR; + return; + } + createTemplate(currentContext->cfits->mapToRef(v, sys, sky),str); +} + +void Base::createTemplateVarCmd(const Vector& center, const char* var) +{ + Tcl_Obj* obj = Tcl_GetVar2Ex(interp, (char*)var, NULL, + TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG); + if (!obj) + return; + + // just in case + Tcl_ConvertToType(interp, obj, Tcl_GetObjType("bytearray")); + + typedef struct ByteArray { + int used; /* The number of bytes used in the byte + * array. */ + int allocated; /* The amount of space actually allocated + * minus 1 byte. */ + unsigned char bytes[4]; /* The array of bytes. The actual size of + * this field depends on the 'allocated' field + * above. */ + } ByteArray; + + Tcl_IncrRefCount(obj); + + // only make command string as long as needed + // or the rest will be processed as garbage + ByteArray* ba = (ByteArray*)(obj->internalRep.otherValuePtr); + int len = ba->used+2; + char* buf = new char[len]; + memcpy(buf, (char*)ba->bytes, ba->used); + + Tcl_DecrRefCount(obj); + + // add terminator to make parser happy + buf[len-2] = '\n'; + buf[len-1] = '\0'; + + string x(buf); + istringstream istr(x); + + createTemplate(center,istr); + + delete [] buf; +} + +void Base::createTemplate(const Vector& center, istream& str) +{ + FitsImage* ptr = keyContext->fits; + while (ptr) { + ptr->initWCS0(center); + ptr = ptr->nextMosaic(); + } + + mkFlexLexer* ll = new mkFlexLexer(&str); + mkparse(this, ll); + delete ll; + + Marker* mk = compositeMarker; + resetCompositeMarker(); + + ptr = keyContext->fits; + while (ptr) { + ptr->resetWCS0(); + ptr = ptr->nextMosaic(); + } + + if (mk) { + mk->moveTo(center); + update(PIXMAP, mk->getAllBBox()); + + // and return id + printInteger(mk->getId()); + } +} + +// Support + +void Base::createMarker(Marker* m) +{ + if (maperr) { + Tcl_SetVar2(interp, "ds9", "msg", "Bad Coordinate mapping, unable to create some region(s).", TCL_GLOBAL_ONLY); + Tcl_SetVar2(interp, "ds9", "msg,level", "warning", TCL_GLOBAL_ONLY); + delete m; + return; + } + + if (compositeMarker) { + compositeMarker->append(m); + compositeMarker->updateBBox(); + update(PIXMAP, compositeMarker->getAllBBox()); + } + else { + markers->append(m); + + // now update new marker + update(PIXMAP, m->getAllBBox()); + + // can't do this for windows, threads are weird + // parser.Y and ds9parser.Y are not thread safe + // *bad* exectute any Edit CallBacks + // m->doCallBack(CallBack::EDITCB); + + // and return id + printInteger(m->getId()); + } +} + +Vector Base::centroid(const Vector& vv) +{ + FitsImage* ptr = currentContext->cfits; + while (ptr) { + Vector img = vv * ptr->refToData; + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + + if (img[0]>=params->xmin && img[0]xmax && + img[1]>=params->ymin && img[1]ymax) + break; + + ptr = ptr->nextMosaic(); + } + + if (!ptr) + return vv; + + FitsBound* params = ptr->getDataParams(currentContext->secMode()); + // int srcw = ptr->width(); + + Vector cd = vv * ptr->refToData; + float rr = centroidRadius; + float rr2 = rr*rr; + + // main loop + + SETSIGBUS + for (int kk=0; kk=params->xmin && aa[0]xmax && + aa[1]>=params->ymin && aa[1]ymax) { + + if (ii*ii+jj*jj <= rr2) { + double val = ptr->getValueDouble(aa); + + // check for nan + if (isfinite(val)) { + sum += aa*val; + weight += val; + } + } + } + } + } + + if (weight>0) + cd = sum/weight; + else + break; + } + CLEARSIGBUS + + return cd * ptr->dataToRef; +} + +void Base::getMarkerAnalysisHistogramCmd(char* xname, char* yname, int num) +{ + Marker* mm = markers->head(); + while (mm) { + if (!mm->getProperty(Marker::HIDDEN)) { + mm->analysisHistogram(xname, yname, num); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerAnalysisHistogramCmd(int id, char* xname, char* yname, + int num) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + mm->analysisHistogram(xname, yname, num); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerAnalysisPlot2dCmd(char* xname, char* yname, + char* xcname, char* ycname, + Coord::CoordSystem sys, + Coord::SkyFrame sky, + Marker::AnalysisMethod method) +{ + Marker* mm=markers->head(); + while (mm) { + if (!mm->getProperty(Marker::HIDDEN)) { + mm->analysisPlot2d(xname, yname, xcname, ycname, sys, sky, method); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerAnalysisPlot2dCmd(int id, char* xname, char* yname, + char* xcname, char* ycname, + Coord::CoordSystem sys, + Coord::SkyFrame sky, + Marker::AnalysisMethod method) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + mm->analysisPlot2d(xname, yname, xcname, ycname, sys, sky, method); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerAnalysisPlot3dCmd(char* xname, char* yname, + Coord::CoordSystem sys, + Marker::AnalysisMethod method) +{ + Marker* mm=markers->head(); + while (mm) { + if (!mm->getProperty(Marker::HIDDEN)) { + mm->analysisPlot3d(xname, yname, sys, method); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerAnalysisPlot3dCmd(int id, char* xname, char* yname, + Coord::CoordSystem sys, + Marker::AnalysisMethod method) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + mm->analysisPlot3d(xname, yname, sys, method); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerAnalysisPandaCmd(Coord::CoordSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (!mm->getProperty(Marker::HIDDEN)) { + mm->analysisPanda(sys); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerAnalysisPandaCmd(int id, Coord::CoordSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + mm->analysisPanda(sys); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerAnalysisRadialCmd(char* xname, char* yname, + char* yename, Coord::CoordSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (!mm->getProperty(Marker::HIDDEN)) { + mm->analysisRadial(xname, yname, yename, sys); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerAnalysisRadialCmd(int id, char* xname, char* yname, + char* yename, Coord::CoordSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + mm->analysisRadial(xname, yname, yename, sys); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerAnalysisStatsCmd(Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + Marker* mm=markers->head(); + while (mm) { + if (!mm->getProperty(Marker::HIDDEN)) { + mm->analysisStats(sys,sky); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerAnalysisStatsCmd(int id, Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + mm->analysisStats(sys,sky); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerAngleCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + printDouble(radToDeg(mm->getAngle())); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerAngleCmd(int id, Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + printDouble(radToDeg(mapAngleFromRef(mm->getAngle(), sys, sky))); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerAnnulusRadiusCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + int cnt = ((Annulus*)mm)->numAnnuli(); + Vector cc = mm->getCenter(); + for (int i=0; iannuli(i); + FitsImage* ptr = findFits(sys,cc); + printLenFromRef(ptr, rr[0], sys, dist); + Tcl_AppendResult(interp, "\n", NULL); + } + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerBoxAnnulusRadiusCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + int cnt = ((BoxAnnulus*)mm)->numAnnuli(); + Vector cc = mm->getCenter(); + for (int i=0; iannuli(i); + FitsImage* ptr = findFits(sys,cc); + printLenFromRef(ptr, rr, sys, dist); + Tcl_AppendResult(interp, "\n", NULL); + } + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerBoxRadiusCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Vector rr = ((Box*)mm)->annuli(0); + Vector cc = mm->getCenter(); + FitsImage* ptr = findFits(sys,cc); + printLenFromRef(ptr, rr, sys, dist); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerBpandaAnglesCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + int cnt = ((Bpanda*)mm)->numAngles(); + double first=0; + for (int ii=0; iiangles(ii)); + if (!ii) + first = ang; + else + if (ang<=first+FLT_EPSILON) + ang += 360; + + printDouble(ang); + Tcl_AppendResult(interp, "\n", NULL); + } + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerBpandaAnglesCmd(int id, Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + int cnt = ((Bpanda*)mm)->numAngles(); + double first=0; + for (int ii=0; iiangles(ii),sys,sky)); + if (!ii) + first = ang; + else + if (ang<=first+FLT_EPSILON) + ang += 360; + + printDouble(ang); + Tcl_AppendResult(interp, "\n", NULL); + } + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerBpandaRadiusCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + int cnt = ((Bpanda*)mm)->numAnnuli(); + Vector cc = mm->getCenter(); + for (int i=0; iannuli(i); + FitsImage* ptr = findFits(sys,cc); + printLenFromRef(ptr, rr, sys, dist); + Tcl_AppendResult(interp, "\n", NULL); + } + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerCenterCmd(int id, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Vector cc= mm->getCenter(); + printFromRef(findFits(sys,cc), cc, sys, sky, format); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerCircleRadiusCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Vector rr = ((Circle*)mm)->annuli(0); + Vector cc = mm->getCenter(); + FitsImage* ptr = findFits(sys,cc); + printLenFromRef(ptr, rr[0], sys, dist); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerCpandaAnglesCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + int cnt = ((Cpanda*)mm)->numAngles(); + double first=0; + for (int ii=0; iiangles(ii)); + if (!ii) + first = ang; + else + if (ang<=first+FLT_EPSILON) + ang += 360; + + printDouble(ang); + Tcl_AppendResult(interp, "\n", NULL); + } + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerCpandaAnglesCmd(int id, Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + int cnt = ((Cpanda*)mm)->numAngles(); + double first=0; + for (int ii=0; iiangles(ii),sys,sky)); + if (!ii) + first = ang; + else + if (ang<=first+FLT_EPSILON) + ang += 360; + + printDouble(ang); + Tcl_AppendResult(interp, "\n", NULL); + } + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerCpandaRadiusCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + int cnt = ((Cpanda*)mm)->numAnnuli(); + Vector cc = mm->getCenter(); + for (int i=0; iannuli(i); + FitsImage* ptr = findFits(sys,cc); + printLenFromRef(ptr, rr[0], sys, dist); + Tcl_AppendResult(interp, "\n", NULL); + } + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerColorCmd() +{ + // return first found + + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) { + Tcl_AppendResult(interp, mm->getColorName(), NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerColorCmd(const char* tag) +{ + // return first found + + Marker* mm=markers->head(); + while (mm) { + if (mm->hasTag(tag)) { + Tcl_AppendResult(interp, mm->getColorName(), NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerColorCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Tcl_AppendResult(interp, mm->getColorName(), NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerCompassArrowCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (((Compass*)mm)->getNorthArrow()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); + + if (((Compass*)mm)->getEastArrow()) + Tcl_AppendResult(interp, " 1", NULL); + else + Tcl_AppendResult(interp, " 0", NULL); + + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerCompassLabelCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Tcl_AppendElement(interp, ((Compass*)mm)->getNorthText()); + Tcl_AppendElement(interp, ((Compass*)mm)->getEastText()); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerCompassRadiusCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + double rr = ((Compass*)mm)->getRadius(); + Vector cc = mm->getCenter(); + FitsImage* ptr = findFits(sys,cc); + printLenFromRef(ptr, rr, sys, dist); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerCompassSystemCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + printCoordSystem(((Compass*)mm)->getSystem()); + Tcl_AppendResult(interp, " ", NULL); + printSkyFrame(((Compass*)mm)->getSkyFrame()); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerCompositeCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (((Composite*)mm)->getGlobal()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerEllipseRadiusCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Vector rr = ((Ellipse*)mm)->annuli(0); + Vector cc = mm->getCenter(); + FitsImage* ptr = findFits(sys,cc); + printLenFromRef(ptr, rr, sys, dist); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerEllipseAnnulusRadiusCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + int cnt = ((EllipseAnnulus*)mm)->numAnnuli(); + Vector cc = mm->getCenter(); + for (int i=0; iannuli(i); + FitsImage* ptr = findFits(sys,cc); + printLenFromRef(ptr, rr, sys, dist); + Tcl_AppendResult(interp, "\n", NULL); + } + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerEpandaAnglesCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + int cnt = ((Epanda*)mm)->numAngles(); + double first=0; + for (int ii=0; iiangles(ii)); + if (!ii) + first = ang; + else + if (ang<=first+FLT_EPSILON) + ang += 360; + + printDouble(ang); + Tcl_AppendResult(interp, "\n", NULL); + } + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerEpandaAnglesCmd(int id, Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + int cnt = ((Epanda*)mm)->numAngles(); + double first=0; + for (int ii=0; iiangles(ii),sys,sky)); + if (!ii) + first = ang; + else + if (ang<=first+FLT_EPSILON) + ang += 360; + + printDouble(ang); + Tcl_AppendResult(interp, "\n", NULL); + } + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerEpandaRadiusCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + int cnt = ((Epanda*)mm)->numAnnuli(); + Vector cc = mm->getCenter(); + for (int i=0; iannuli(i); + FitsImage* ptr = findFits(sys,cc); + printLenFromRef(ptr, rr, sys, dist); + Tcl_AppendResult(interp, "\n", NULL); + } + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerEpsilonCmd() +{ + ostringstream str; + str << markerEpsilon << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getMarkerFontCmd() +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) { + Tcl_AppendResult(interp, mm->getFont(), NULL); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerFontCmd(const char* tag) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->hasTag(tag)) { + Tcl_AppendResult(interp, mm->getFont(), NULL); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerFontCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Tcl_AppendResult(interp, mm->getFont(), NULL); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerHandleCmd(const Vector& v) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) { + int h = mm->onHandle(v); + if (h) { + ostringstream str; + str << mm->getId() << ' ' << h << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + return; + } + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "0 0", NULL); +} + +void Base::getMarkerIdCmd(const char* tag) +{ + // return first found + + Marker* mm=markers->head(); + while (mm) { + if (mm->hasTag(tag)) { + printInteger(mm->getId()); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerIdCmd(const Vector& v) +{ + // v is in canvas coords + + Marker* mm=markers->head(); + while (mm) { + if (mm->isIn(v)) { + printInteger(mm->getId()); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getMarkerIdAllCmd() +{ + Marker* mm=markers->head(); + while (mm) { + ostringstream str; + str << mm->getId() << ' ' << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + mm=mm->next(); + } +} + +void Base::getMarkerLineCmd(int id, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Vector p1 = ((Line*)mm)->getP1(); + Vector p2 = ((Line*)mm)->getP2(); + Vector cc = mm->getCenter(); + printFromRef(findFits(sys,cc), p1, sys, sky, format); + Tcl_AppendResult(interp, " ", NULL); + printFromRef(findFits(sys,cc), p2, sys, sky, format); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerLineArrowCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (((Line*)mm)->getP1Arrow()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); + + if (((Line*)mm)->getP2Arrow()) + Tcl_AppendResult(interp, " 1", NULL); + else + Tcl_AppendResult(interp, " 0", NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerLineLengthCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Vector p1 = ((Line*)mm)->getP1(); + Vector p2 = ((Line*)mm)->getP2(); + Vector cc = mm->getCenter(); + FitsImage* ptr = findFits(sys,cc); + printDistFromRef(ptr,p2,p1,sys,dist); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerLineWidthCmd() +{ + // return first found + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) { + ostringstream str; + str << mm->getLineWidth() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerLineWidthCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + ostringstream str; + str << mm->getLineWidth() << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerMapLenFromRefCmd(int id, double dd, + Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + FitsImage* ptr = findFits(sys,mm->getCenter()); + printLenFromRef(ptr, dd, sys, dist); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerPointShapeCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Tcl_AppendResult(interp, ((Point*)mm)->shape(), NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerPointSizeCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + printInteger(((Point*)mm)->size()); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerPolygonSegmentCmd(const Vector& v) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) { + int s = mm->getSegment(v); + if (s) { + ostringstream str; + str << mm->getId() << ' ' << s << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + return; + } + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "0 0", NULL); +} + +void Base::getMarkerPreserveCmd() +{ + if (preserveMarkers) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getMarkerProjectionPointsCmd(int id, Coord::CoordSystem sys, + Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Vector p1 = ((Projection*)mm)->getP1(); + Vector p2 = ((Projection*)mm)->getP2(); + Vector cc = mm->getCenter(); + printFromRef(findFits(sys,cc), p1, sys, sky, format); + Tcl_AppendResult(interp, " ", NULL); + printFromRef(findFits(sys,cc), p2, sys, sky, format); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerProjectionLengthCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Vector p1 = ((Projection*)mm)->getP1(); + Vector p2 = ((Projection*)mm)->getP2(); + Vector cc = mm->getCenter(); + FitsImage* ptr = findFits(sys,cc); + printDistFromRef(ptr,p2,p1,sys,dist); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerProjectionWidthCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + double rr = ((Projection*)mm)->getWidth(); + Vector cc = mm->getCenter(); + FitsImage* ptr = findFits(sys,cc); + printLenFromRef(ptr, rr, sys, dist); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerPropertyCmd(unsigned short which) +{ + // return first selected found + + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) { + mm->getProperty(which) ? + Tcl_AppendResult(interp, "1", NULL): + Tcl_AppendResult(interp, "0", NULL); + return; + } + mm=mm->next(); + } + + // else, return 'off' + + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getMarkerPropertyCmd(const char* tag, unsigned short which) +{ + // return first selected found + + Marker* mm=markers->head(); + while (mm) { + if (mm->hasTag(tag)) { + mm->getProperty(which) ? + Tcl_AppendResult(interp, "1", NULL): + Tcl_AppendResult(interp, "0", NULL); + return; + } + mm=mm->next(); + } + + // else, return 'off' + + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getMarkerPropertyCmd(int id, unsigned short which) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + mm->getProperty(which) ? + Tcl_AppendResult(interp, "1", NULL): + Tcl_AppendResult(interp, "0", NULL); + return; + } + mm=mm->next(); + } + + // else, return 'off' + + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getMarkerRulerLengthCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Vector p1 = ((Ruler*)mm)->getP1(); + Vector p2 = ((Ruler*)mm)->getP2(); + Vector p3 = ((Ruler*)mm)->getP3(); + Vector cc = mm->getCenter(); + FitsImage* ptr = findFits(sys,cc); + printDistFromRef(ptr,p2,p1,sys,dist); + Tcl_AppendResult(interp, " ", NULL); + printDistFromRef(ptr,p3,p1,sys,dist); + Tcl_AppendResult(interp, " ", NULL); + printDistFromRef(ptr,p3,p2,sys,dist); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerRulerPointCmd(int id, Coord::CoordSystem sys, + Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Vector p1 = ((Ruler*)mm)->getP1(); + Vector p2 = ((Ruler*)mm)->getP2(); + Vector cc = mm->getCenter(); + printFromRef(findFits(sys,cc), p1, sys, sky, format); + Tcl_AppendResult(interp, " ", NULL); + printFromRef(findFits(sys,cc), p2, sys, sky, format); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerRulerSystemCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + printCoordSystem(((Ruler*)mm)->getSystem()); + Tcl_AppendResult(interp, " ", NULL); + printSkyFrame(((Ruler*)mm)->getSkyFrame()); + Tcl_AppendResult(interp, " ", NULL); + printCoordSystem(((Ruler*)mm)->getDistSystem()); + Tcl_AppendResult(interp, " ", NULL); + printSkyDist(((Ruler*)mm)->getDistDist()); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerSegmentSegmentCmd(const Vector& v) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) { + int s = mm->getSegment(v); + if (s) { + ostringstream str; + str << mm->getId() << ' ' << s << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + return; + } + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "0 0", NULL); +} + +void Base::getMarkerSelectedCmd() +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) { + ostringstream str; + str << mm->getId() << ' ' << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + mm=mm->next(); + } +} + +void Base::getMarkerSelectedCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->isSelected()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerSelectedCmd(const Vector& v) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isIn(v) && mm->isSelected()) { + ostringstream str; + str << mm->getId() << ' ' << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getMarkerNumberCmd() +{ + int count=0; + Marker* mm=markers->head(); + while (mm) { + count++; + mm=mm->next(); + } + + printInteger(count); +} + +void Base::getMarkerSelectedNumberCmd() +{ + int count=0; + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) + count++; + mm=mm->next(); + } + + printInteger(count); +} + +void Base::getMarkerHighlitedCmd() +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isHighlited()) { + ostringstream str; + str << mm->getId() << ' ' << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + mm=mm->next(); + } +} + +void Base::getMarkerHighlitedCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->isHighlited()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerHighlitedCmd(const Vector& v) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isIn(v) && mm->isHighlited()) { + ostringstream str; + str << mm->getId() << ' ' << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getMarkerHighlitedNumberCmd() +{ + int count=0; + Marker* mm=markers->head(); + while (mm) { + if (mm->isHighlited()) + count++; + mm=mm->next(); + } + + printInteger(count); +} + +void Base::getMarkerShowCmd() +{ + if (showMarkers) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getMarkerShowTextCmd() +{ + if (showMarkersText) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getMarkerCentroidAutoCmd() +{ + if (centroidAuto) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::getMarkerCentroidRadiusCmd() +{ + ostringstream str; + str << centroidRadius << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getMarkerCentroidIterationCmd() +{ + ostringstream str; + str << centroidIteration << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +// backup compatibility +void Base::getMarkerCentroidOptionCmd() +{ + ostringstream str; + str << centroidIteration << centroidRadius << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getMarkerTagCmd(const char* tag) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->hasTag(tag)) { + ostringstream str; + str << mm->getId() << ' ' << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); + } + mm=mm->next(); + } +} + +void Base::getMarkerTagCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + const char* r = mm->getTag(); + while (r) { + Tcl_AppendElement(interp, r); + r = mm->getNextTag(); + } + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerTagCmd(int id, int num) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Tcl_AppendResult(interp, mm->getTag(num), NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerTagDefaultNameCmd() +{ + int cnt = 1; + + again: + ostringstream str; + str << "Group " << cnt << ends; + Marker* mm = markers->head(); + while (mm) { + if (mm->hasTag(str.str().c_str())) { + cnt++; + goto again; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::getMarkerTagNumberCmd(const char* tag) +{ + // return number of markers with tag + int count=0; + Marker* mm=markers->head(); + while (mm) { + if (mm->hasTag(tag)) + count++; + mm=mm->next(); + } + + printInteger(count); +} + +void Base::getMarkerTagsCmd() +{ + // return all tags + List tags; + + // loop thru all markers + Marker* mm=markers->head(); + while (mm) { + + // loop thru all tags in markers + const char* t = mm->getTag(); + while (t) { + // loop thru our current list + int found = 0; + Tag* tt = tags.head(); + while (tt) { + if (!strcmp(tt->tag(), t)) { + found =1; + break; + } + tt = tt->next(); + } + // didn't find it, add it to the list + if (!found) { + tags.append(new Tag(t)); + } + + t=mm->getNextTag(); + } + mm=mm->next(); + } + + // now sort + + // ok, dump the tags + Tag* tt = tags.head(); + while (tt) { + Tcl_AppendElement(interp, tt->tag()); + tt=tt->next(); + } +} + +void Base::getMarkerTextCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Tcl_AppendResult(interp, mm->getText(), NULL); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerTextRotateCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (((Text*)mm)->getRotate()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerTypeCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Tcl_AppendResult(interp, mm->getType(), NULL); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerVectorCmd(int id, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Vector p1 = ((Line*)mm)->getP1(); + Vector cc = mm->getCenter(); + printFromRef(findFits(sys,cc), p1, sys, sky, format); + return; + } + mm=mm->next(); + } +} + +void Base::getMarkerVectorArrowCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (((Vect*)mm)->getArrow()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::getMarkerVectorLengthCmd(int id, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + Vector p1 = ((Vect*)mm)->getP1(); + Vector p2 = ((Vect*)mm)->getP2(); + Vector cc = mm->getCenter(); + FitsImage* ptr = findFits(sys,cc); + printDistFromRef(ptr,p2,p1,sys,dist); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "", NULL); +} + +void Base::hasMarkerHighlitedCmd() +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isHighlited()) { + Tcl_AppendResult(interp, "1", NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasMarkerPasteCmd() +{ + if (!pasteMarkers->isEmpty()) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasMarkerSelectedCmd() +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) { + Tcl_AppendResult(interp, "1", NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::hasMarkerUndoCmd() +{ + if (!undoMarkers->isEmpty()) + switch (undoMarkerType) { + case MOVE: + Tcl_AppendResult(interp, "move", NULL); + return; + case EDIT: + Tcl_AppendResult(interp, "edit", NULL); + return; + case DELETE: + Tcl_AppendResult(interp, "delete", NULL); + return; + default: + Tcl_AppendResult(interp, "", NULL); + return; + } + else + Tcl_AppendResult(interp, "", NULL); +} + +void Base::markerLayerCmd(MarkerLayer layer) { + switch (layer) { + case USER: + markers = &userMarkers; + undoMarkers = &undoUserMarkers; + pasteMarkers = &pasteUserMarkers; + break; + case CATALOG: + markers = &catalogMarkers; + undoMarkers = &undoCatalogMarkers; + pasteMarkers = &pasteCatalogMarkers; + break; + /* + case ANALYSIS: + markers = &analysisMarkers; + undoMarkers = &undoAnalysisMarkers; + pasteMarkers = &pasteAnalysisMarkers; + break; + */ + default: + // na + break; + } +} + +void Base::markerAnalysisCmd(int id, Marker::AnalysisTask aa, int which) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + mm->analysis(aa,which); + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerAngleCmd(int id, double angle) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canRotate()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + mm->setAngle(angle); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerAngleCmd(int id, double angle, Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canRotate()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + mm->setAngle(mapAngleToRef(angle,sys,sky)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerAnnulusCreateRadiusCmd(int id, const Vector& vv) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + printInteger(((Annulus*)mm)->addAnnuli(mapToRef(vv,Coord::CANVAS))); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerAnnulusDeleteRadiusCmd(int id, int h) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Annulus*)mm)->deleteAnnuli(h); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } +} + +void Base::markerAnnulusRadiusCmd(int id, double inner, double outer, + int num, Coord::InternalSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + double r1 = mapLenToRef(inner,sys); + double r2 = mapLenToRef(outer,sys); + ((Annulus*)mm)->setAnnuli(Vector(r1,r1),Vector(r2,r2),num); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerAnnulusRadiusCmd(int id, double inner, double outer, + int num, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + double r1 = ptr->mapLenToRef(inner, sys, dist); + double r2 = ptr->mapLenToRef(outer, sys, dist); + ((Annulus*)mm)->setAnnuli(Vector(r1,r1),Vector(r2,r2),num); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerAnnulusRadiusCmd(int id, const char* lev, + Coord::CoordSystem sys, Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + + int cnt = 0; + Vector radii[MAXANNULI]; + string x(lev); + istringstream str(x); + while ((cnt> radii[cnt][0])) { + radii[cnt][1] = radii[cnt][0]; + ++cnt; + } + + FitsImage* ptr = findFits(sys,mm->getCenter()); + for (int i=0; imapLenToRef(radii[i], sys, dist); + + ((Annulus*)mm)->setAnnuli(radii,cnt); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerBackCmd() +{ + Marker* mm = markers->tail(); + while (mm) { + if (mm->isSelected()) { + Marker* prev = markers->extractPrev(mm); + markers->append(mm); + update(PIXMAP, mm->getAllBBox()); + mm = prev; + } + else + mm=mm->previous(); + } +} + +void Base::markerBackCmd(const char* tag) +{ + Marker* mm = markers->tail(); + while (mm) { + if (mm->hasTag(tag)) { + Marker* prev = markers->extractPrev(mm); + markers->append(mm); + update(PIXMAP, mm->getAllBBox()); + mm = prev; + } + else + mm=mm->previous(); + } +} + +void Base::markerBackCmd(int id) +{ + Marker* mm = markers->tail(); + while (mm) { + if (mm->getId() == id) { + markers->extractPrev(mm); + markers->append(mm); + update(PIXMAP, mm->getAllBBox()); + return; + } + else + mm=mm->previous(); + } +} + +void Base::markerBoxAnnulusRadiusCmd(int id, const Vector& inner, + const Vector& outer, int num, + Coord::InternalSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + Vector s1 = mapLenToRef(inner, sys); + Vector s2 = mapLenToRef(outer, sys); + ((BoxAnnulus*)(mm))->setAnnuli(s1,s2,num); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerBoxAnnulusRadiusCmd(int id, const Vector& inner, + const Vector& outer, int num, + Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + Vector s1 = ptr->mapLenToRef(inner, sys, dist); + Vector s2 = ptr->mapLenToRef(outer, sys, dist); + ((BoxAnnulus*)(mm))->setAnnuli(s1,s2,num); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerBoxAnnulusRadiusCmd(int id,const char* lev, + Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + + int cnt = 0; + Vector size[MAXANNULI]; + string x(lev); + istringstream str(x); + while ((cnt> size[cnt][0])) + str >> size[cnt++][1]; + + // verify proper ratios + for (int i=0; igetCenter()); + for (int i=0; imapLenToRef(size[i], sys, dist); + + ((BoxAnnulus*)mm)->setAnnuli(size,cnt); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerBoxAnnulusCreateRadiusCmd(int id, const Vector& vv) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + printInteger(((BoxAnnulus*)mm)->addAnnuli(mapToRef(vv,Coord::CANVAS))); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerBoxAnnulusDeleteRadiusCmd(int id, int h) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((BoxAnnulus*)mm)->deleteAnnuli(h); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } +} + +void Base::markerBoxRadiusCmd(int id, const Vector& size, + Coord::InternalSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Box*)(mm))->setAnnuli(mapLenToRef(size, sys)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerBoxRadiusCmd(int id, const Vector& size, + Coord::CoordSystem sys, Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + ((Box*)(mm))->setAnnuli(ptr->mapLenToRef(size, sys, dist)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerBpandaCreateAnglesCmd(int id, const Vector& vv) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + printInteger(((Bpanda*)mm)->addAngles(mapToRef(vv,Coord::CANVAS))); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerBpandaCreateRadiusCmd(int id, const Vector& vv) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + printInteger(((Bpanda*)mm)->addAnnuli(mapToRef(vv,Coord::CANVAS))); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerBpandaDeleteCmd(int id, int h) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Bpanda*)mm)->deleteAnglesAnnuli(h); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } +} + +void Base::markerBpandaEditCmd(int id, + double a1, double a2, int an, + const Vector& r1, const Vector& r2, int rn) + +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Bpanda*)mm)->setAnglesAnnuli(a1,a2,an,r1,r2,rn); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerBpandaEditCmd(int id, + double a1, double a2, int an, + const Vector& r1, const Vector& r2, int rn, + Coord::CoordSystem sys, Coord::SkyFrame sky) + +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Bpanda*)mm)->setAnglesAnnuli(mapAngleToRef(a1,sys,sky), + mapAngleToRef(a2,sys,sky),an,r1,r2,rn); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerBpandaEditCmd(int id, + const char* a, const char* r, + Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::CoordSystem rsys, Coord::SkyDist rdist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + + int acnt = 0; + double angles[MAXANGLES]; + { + string x(a); + istringstream astr(x); + while ((acnt> angles[acnt])) + ++acnt; + } + for (int i=0; i> radii[rcnt][0])) + rstr >> radii[rcnt++][1]; + } + // verify proper ratios + for (int i=0; igetCenter()); + for (int i=0; imapLenToRef(radii[i], rsys, rdist); + + ((Bpanda*)mm)->setAnglesAnnuli(angles,acnt,radii,rcnt); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerCallBackCmd(int id, CallBack::Type cb, const char* p, + const char* a) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + result = mm->addCallBack(cb, p, a); + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerCentroidCmd() +{ + undoMarkers->deleteAll(); + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected() && mm->canMove()) { + undoMarkers->append(mm->dup()); + undoMarkerType = MOVE; + + update(PIXMAP, mm->getAllBBox()); + mm->centroid(); + update(PIXMAP, mm->getAllBBox()); + } + mm=mm->next(); + } +} + +void Base::markerCentroidCmd(const char* tag) +{ + undoMarkers->deleteAll(); + Marker* mm=markers->head(); + while (mm) { + if (mm->canMove() && mm->hasTag(tag)) { + undoMarkers->append(mm->dup()); + undoMarkerType = MOVE; + + update(PIXMAP, mm->getAllBBox()); + mm->centroid(); + update(PIXMAP, mm->getAllBBox()); + } + mm=mm->next(); + } +} + +void Base::markerCentroidCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canMove()) { + markerUndo(mm, MOVE); + + update(PIXMAP, mm->getAllBBox()); + mm->centroid(); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } +} + +void Base::markerCentroidAutoCmd(int which) +{ + centroidAuto = which; +} + +void Base::markerCentroidRadiusCmd(float rad) +{ + centroidRadius = rad; +} + +void Base::markerCentroidIterationCmd(int iter) +{ + centroidIteration = iter; +} + +void Base::markerCircleRadiusCmd(int id, double radius, + Coord::InternalSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + double r = mapLenToRef(radius, sys); + ((Circle*)mm)->setAnnuli(Vector(r,r)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerCircleRadiusCmd(int id, double radius, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + double r = ptr->mapLenToRef(radius, sys, dist); + ((Circle*)mm)->setAnnuli(Vector(r,r)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerColorCmd(const char* clr) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) { + mm->setColor(clr); + update(PIXMAP, mm->getAllBBox()); + } + mm=mm->next(); + } +} + +void Base::markerColorCmd(const char* tag, const char* clr) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->hasTag(tag)) { + mm->setColor(clr); + update(PIXMAP, mm->getAllBBox()); + } + mm=mm->next(); + } +} + +void Base::markerColorCmd(int id, const char* clr) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + mm->setColor(clr); + update(PIXMAP, mm->getAllBBox()); + return; + } + mm=mm->next(); + } +} + +void Base::markerCommandCmd(MarkerFormat fm, const char* ccmd) +{ + // only make command string as long as needed + // or the rest will be processed as garbage + int len = strlen(ccmd)+2; + char* buf = new char[len]; + memcpy(buf, ccmd, len); + + // add terminator to make parser happy + buf[len-2] = '\n'; + buf[len-1] = '\0'; + + string x(buf); + istringstream istr(x); + parseMarker(fm, istr); + delete [] buf; +} + +void Base::markerCommandVarCmd(MarkerFormat fm, const char* var) +{ + const char* ccmd = Tcl_GetVar(interp, var, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG); + if (!ccmd) { + result = TCL_ERROR; + return; + } + + // only make command string as long as needed + // or the rest will be processed as garbage + int len = strlen(ccmd)+2; + char* buf = new char[len]; + memcpy(buf, ccmd, len); + + // add terminator to make parser happy + buf[len-2] = '\n'; + buf[len-1] = '\0'; + + string x(buf); + istringstream istr(x); + parseMarker(fm, istr); + delete [] buf; +} + +void Base::markerCompassArrowCmd(int id, int n, int e) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + ((Compass*)(mm))->setArrows(n, e); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerCompassLabelCmd(int id, const char* n, const char* e) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Compass*)(mm))->setLabels(n, e); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerCompassRadiusCmd(int id, double r, Coord::InternalSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + double rr = mapLenToRef(r, sys); + ((Compass*)mm)->setRadius(rr); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerCompassRadiusCmd(int id, double r, Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + double rr = ptr->mapLenToRef(r, sys, dist); + ((Compass*)mm)->setRadius(rr); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerCompassSystemCmd(int id, Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Compass*)(mm))->setCoordSystem(sys, sky); + update(PIXMAP, mm->getAllBBox()); + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerCompositeCmd(int id, int gl) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + ((Composite*)(mm))->setGlobal(gl); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerCompositeDeleteCmd() +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected() && !strncmp(mm->getType(),"composite",9)) { + + Marker* nn = ((Composite*)mm)->extract(); + while (nn) { + markers->append(nn); + nn = ((Composite*)mm)->extract(); + } + Marker* next = markers->extractNext(mm); + delete mm; + mm = next; + + update(PIXMAP); + } + else + mm=mm->next(); + } +} + +void Base::markerCopyCmd() +{ + undoMarkers->deleteAll(); + pasteMarkers->deleteAll(); + Marker* mm = markers->head(); + while (mm) { + if (mm->isSelected()) + pasteMarkers->append(mm->dup()); + mm=mm->next(); + } +} + +void Base::markerCopyCmd(const char* tag) +{ + undoMarkers->deleteAll(); + pasteMarkers->deleteAll(); + Marker* mm = markers->head(); + while (mm) { + if (mm->hasTag(tag)) + pasteMarkers->append(mm->dup()); + mm=mm->next(); + } +} + +void Base::markerCpandaCreateAnglesCmd(int id, const Vector& vv) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + printInteger(((Cpanda*)mm)->addAngles(mapToRef(vv,Coord::CANVAS))); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerCpandaCreateRadiusCmd(int id, const Vector& vv) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + printInteger(((Cpanda*)mm)->addAnnuli(mapToRef(vv,Coord::CANVAS))); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerCpandaDeleteCmd(int id, int h) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Cpanda*)mm)->deleteAnglesAnnuli(h); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } +} + +void Base::markerCpandaEditCmd(int id, double a1, double a2, int an, + double r1, double r2, int rn) + +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Cpanda*)mm)->setAnglesAnnuli(a1,a2,an,Vector(r1,r1),Vector(r2,r2),rn); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerCpandaEditCmd(int id, double a1, double a2, int an, + double r1, double r2, int rn, + Coord::CoordSystem sys, Coord::SkyFrame sky) + +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + + ((Cpanda*)mm)->setAnglesAnnuli(mapAngleToRef(a1,sys,sky), + mapAngleToRef(a2,sys,sky), + an, + Vector(r1,r1),Vector(r2,r2),rn); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerCpandaEditCmd(int id, const char* a, const char* r, + Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::CoordSystem rsys, Coord::SkyDist rdist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + + int acnt = 0; + double angles[MAXANGLES]; + { + string x(a); + istringstream astr(x); + while ((acnt> angles[acnt])) + ++acnt; + } + { + for (int i=0; i> radii[rcnt][0])) { + radii[rcnt][1] = radii[rcnt][0]; + ++rcnt; + } + } + { + FitsImage* ptr = findFits(sys,mm->getCenter()); + for (int i=0; imapLenToRef(radii[i], rsys, rdist); + } + + ((Cpanda*)mm)->setAnglesAnnuli(angles,acnt,radii,rcnt); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerCutCmd() +{ + undoMarkers->deleteAll(); + pasteMarkers->deleteAll(); + Marker* mm = markers->head(); + while (mm) { + if (mm->isSelected() && mm->canDelete()) { + Marker* next = markers->extractNext(mm); + update(PIXMAP); + pasteMarkers->append(mm); + mm->doCallBack(CallBack::DELETECB); + mm->disableCB(); + mm = next; + } + else + mm=mm->next(); + } +} + +void Base::markerCutCmd(const char* tag) +{ + undoMarkers->deleteAll(); + pasteMarkers->deleteAll(); + Marker* mm = markers->head(); + while (mm) { + if (mm->canDelete() && mm->hasTag(tag)) { + Marker* next = markers->extractNext(mm); + update(PIXMAP); + pasteMarkers->append(mm); + mm->doCallBack(CallBack::DELETECB); + mm->disableCB(); + mm = next; + } + else + mm=mm->next(); + } +} + +void Base::markerDeleteCallBackCmd(int id, CallBack::Type cb, + const char* p) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + result = mm->deleteCallBack(cb, p); + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerDeleteCmd() +{ + undoMarkers->deleteAll(); + Marker* mm = markers->head(); + while (mm) { + if (mm->isSelected() && mm->canDelete()) { + Marker* next = markers->extractNext(mm); + update(PIXMAP); + + mm->doCallBack(CallBack::DELETECB); + mm->deleteCBs(); + undoMarkers->append(mm); + undoMarkerType = DELETE; + + mm = next; + } + else + mm=mm->next(); + } +} + +void Base::markerDeleteCmd(const char* tag) +{ + undoMarkers->deleteAll(); + Marker* mm = markers->head(); + while (mm) { + if (mm->canDelete() && mm->hasTag(tag)) { + Marker* next = markers->extractNext(mm); + update(PIXMAP); + + mm->doCallBack(CallBack::DELETECB); + mm->deleteCBs(); + undoMarkers->append(mm); + undoMarkerType = DELETE; + + mm = next; + } + else + mm=mm->next(); + } +} + +void Base::markerDeleteCmd(int id) +{ + undoMarkers->deleteAll(); + Marker* mm = markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canDelete()) { + markers->extractNext(mm); + update(PIXMAP); + + mm->doCallBack(CallBack::DELETECB); + mm->deleteCBs(); + undoMarkers->append(mm); + undoMarkerType = DELETE; + } + return; + } + else + mm=mm->next(); + } +} + +void Base::markerDeleteAllCmd() +{ + undoMarkers->deleteAll(); + Marker* mm = markers->head(); + while (mm) { + if (mm->canDelete()) { + update(PIXMAP); + Marker* next = markers->extractNext(mm); + + mm->doCallBack(CallBack::DELETECB); + mm->deleteCBs(); + undoMarkers->append(mm); + undoMarkerType = DELETE; + + mm = next; + } + else + mm=mm->next(); + } +} + +void Base::markerDeleteLastCmd() +{ + undoMarkers->deleteAll(); + Marker* mm=markers->tail(); + if (mm && mm->canDelete()) { + markers->extractNext(mm); + update(PIXMAP); + + mm->doCallBack(CallBack::DELETECB); + mm->deleteCBs(); + undoMarkers->append(mm); + undoMarkerType = DELETE; + + return; + } +} + +void Base::markerDeleteTagCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canDelete()) + mm->deleteTags(); + return; + } + mm=mm->next(); + } +} + +void Base::markerDeleteTagCmd(int id, const char* tag) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canDelete()) + mm->deleteTag(tag); + return; + } + mm=mm->next(); + } +} + +void Base::markerDeleteTagCmd(int id, int which) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canDelete()) + mm->deleteTag(which); + return; + } + mm=mm->next(); + } +} + +void Base::markerEditBeginCmd(int id, int h) +{ + // remember which marker is being edited + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id && mm->canEdit()) { + markerUndo(mm, EDIT); + + editMarker = mm; + editMarker->editBegin(h); + return; + } + mm=mm->next(); + } + + editMarker = NULL; +} + +void Base::markerEditBeginCmd(const Vector& v, int h) +{ + // remember which marker is being edited + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected() && mm->canEdit()) { + markerUndo(mm, EDIT); + + editMarker = mm; + editMarker->editBegin(h); + return; + } + mm=mm->next(); + } + + editMarker = NULL; +} + +void Base::markerEditMotionCmd(const Vector& vv, int hh) +{ + if (editMarker) { + // erase current marker now + redraw(editMarker->getAllBBox()); + forceUpdate(); + + editMarker->edit(mapToRef(vv,Coord::CANVAS), hh); + x11MarkerXOR(editMarker); + } +} + +void Base::markerEditEndCmd() +{ + if (editMarker) + editMarker->editEnd(); + editMarker = NULL; + + update(PIXMAP); +} + +void Base::markerEllipseRadiusCmd(int id, const Vector& radius, + Coord::InternalSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + Vector r = mapLenToRef(radius, sys); + ((Ellipse*)mm)->setAnnuli(r); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerEllipseRadiusCmd(int id, const Vector& radius, + Coord::CoordSystem sys, Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + Vector r = ptr->mapLenToRef(radius, sys, dist); + ((Ellipse*)mm)->setAnnuli(r); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerEllipseAnnulusRadiusCmd(int id, const Vector& inner, + const Vector& outer, int num, + Coord::InternalSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + Vector r1 = mapLenToRef(inner, sys); + Vector r2 = mapLenToRef(outer, sys); + ((EllipseAnnulus*)(mm))->setAnnuli(r1,r2,num); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerEllipseAnnulusRadiusCmd(int id, + const Vector& inner, + const Vector& outer, int num, + Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + Vector r1 = ptr->mapLenToRef(inner, sys, dist); + Vector r2 = ptr->mapLenToRef(outer, sys, dist); + ((EllipseAnnulus*)(mm))->setAnnuli(r1,r2,num); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerEllipseAnnulusRadiusCmd(int id, + const char* lev, + Coord::CoordSystem sys, + Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + + int cnt = 0; + Vector radii[MAXANNULI]; + string x(lev); + istringstream str(x); + while ((cnt> radii[cnt][0])) + str >> radii[cnt++][1]; + + // verify proper ratios + for (int i=0; igetCenter()); + for (int i=0; imapLenToRef(radii[i], sys, dist); + + ((EllipseAnnulus*)(mm))->setAnnuli(radii,cnt); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerEllipseAnnulusCreateRadiusCmd(int id, const Vector& vv) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + printInteger(((EllipseAnnulus*)mm)->addAnnuli(mapToRef(vv,Coord::CANVAS))); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerEllipseAnnulusDeleteRadiusCmd(int id, int h) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((EllipseAnnulus*)mm)->deleteAnnuli(h); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } +} + +void Base::markerEpandaCreateAnglesCmd(int id, const Vector& vv) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + printInteger(((Epanda*)mm)->addAngles(mapToRef(vv,Coord::CANVAS))); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerEpandaCreateRadiusCmd(int id, const Vector& vv) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + printInteger(((Epanda*)mm)->addAnnuli(mapToRef(vv,Coord::CANVAS))); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerEpandaDeleteCmd(int id, int h) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Epanda*)mm)->deleteAnglesAnnuli(h); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } +} + +void Base::markerEpandaEditCmd(int id, + double a1, double a2, int an, + const Vector& r1, const Vector& r2, int rn) + +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Epanda*)mm)->setAnglesAnnuli(a1,a2,an,r1,r2,rn); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerEpandaEditCmd(int id, + double a1, double a2, int an, + const Vector& r1, const Vector& r2, int rn, + Coord::CoordSystem sys, Coord::SkyFrame sky) + +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Epanda*)mm)->setAnglesAnnuli(mapAngleToRef(a1,sys,sky), + mapAngleToRef(a2,sys,sky),an,r1,r2,rn); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerEpandaEditCmd(int id, + const char* a, const char* r, + Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::CoordSystem rsys, Coord::SkyDist rdist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + + int acnt = 0; + double angles[MAXANGLES]; + { + string x(a); + istringstream astr(x); + while ((acnt> angles[acnt])) + ++acnt; + } + for (int i=0; i> radii[rcnt][0])) + rstr >> radii[rcnt++][1]; + } + // verify proper ratios + for (int i=0; igetCenter()); + for (int i=0; imapLenToRef(radii[i], rsys, rdist); + + ((Epanda*)mm)->setAnglesAnnuli(angles,acnt,radii,rcnt); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerHighliteAllCmd() +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->canHighlite()) { + mm->highlite(); + update(PIXMAP, mm->getBBox()); + } + mm=mm->next(); + } +} + +void Base::markerHighliteCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->canHighlite() && mm->getId() == id) { + mm->highlite(); + update(PIXMAP, mm->getAllBBox()); + return; + } + mm=mm->next(); + } +} + +void Base::markerHighliteCmd(const char* tag) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->canHighlite() && mm->hasTag(tag)) { + mm->highlite(); + update(PIXMAP, mm->getBBox()); + } + mm=mm->next(); + } +} + +void Base::markerHighliteToggleCmd(const Vector& v) +{ + // toggle the highlite of the first found + Marker* mm=markers->head(); + while (mm) { + if (mm->canHighlite() && mm->isIn(v)) { + mm->toggleHighlite(); + update(PIXMAP, mm->getBBox()); + Tcl_AppendResult(interp, "1", NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::markerHighliteOnlyCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->canHighlite() && mm->getId() == id) { + if (!mm->isHighlited()) { + mm->highlite(); + update(PIXMAP, mm->getBBox()); + } + } + else { + if (mm->isHighlited()) { + mm->unhighlite(); + update(PIXMAP, mm->getBBox()); + } + } + mm=mm->next(); + } +} + +void Base::markerHighliteOnlyCmd(const char* tag) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->canHighlite() && mm->hasTag(tag)) { + if (!mm->isHighlited()) { + mm->highlite(); + update(PIXMAP, mm->getBBox()); + } + else { + if (mm->isHighlited()) { + mm->unhighlite(); + update(PIXMAP, mm->getBBox()); + } + } + } + mm=mm->next(); + } +} + +void Base::markerHighliteOnlyCmd(const Vector& v) +{ + // first, check to see if we clicked on an already highlited marker + Marker* mm=markers->head(); + while (mm) { + if (mm->canHighlite() && mm->isIn(v) && mm->isHighlited()) { + Tcl_AppendResult(interp, "1", NULL); + return; + } + mm=mm->next(); + } + + // ok, now highlite the first found, and unhighlite the rest + int found = 0; + + mm=markers->head(); + while (mm) { + if (mm->canHighlite() && mm->isIn(v) && !found) { + if (!mm->isHighlited()) { + mm->highlite(); + update(PIXMAP, mm->getBBox()); + } + found = 1; + } + else { + if (mm->isHighlited()) { + mm->unhighlite(); + update(PIXMAP, mm->getBBox()); + } + } + mm=mm->next(); + } + + if (found) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::markerFontCmd(const char* f) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) { + // things can shrink, so do before and after + update(PIXMAP, mm->getAllBBox()); + mm->setFont(f); + update(PIXMAP, mm->getAllBBox()); + } + mm=mm->next(); + } +} + +void Base::markerFontCmd(const char* tag, const char* f) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->hasTag(tag)) { + // things can shrink, so do before and after + update(PIXMAP, mm->getAllBBox()); + mm->setFont(f); + update(PIXMAP, mm->getAllBBox()); + } + mm=mm->next(); + } +} + +void Base::markerFontCmd(int id, const char* f) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + // things can shrink, so do before and after + update(PIXMAP, mm->getAllBBox()); + mm->setFont(f); + update(PIXMAP, mm->getAllBBox()); + return; + } + mm=mm->next(); + } +} + +void Base::markerFrontCmd() +{ + Marker* mm = markers->head(); + while (mm) { + if (mm->isSelected()) { + Marker* next = markers->extractNext(mm); + markers->insertHead(mm); + update(PIXMAP, mm->getAllBBox()); + mm = next; + } + else + mm=mm->next(); + } +} + +void Base::markerFrontCmd(const char* tag) +{ + Marker* mm = markers->head(); + while (mm) { + if (mm->hasTag(tag)) { + Marker* next = markers->extractNext(mm); + markers->insertHead(mm); + update(PIXMAP, mm->getAllBBox()); + mm = next; + } + else + mm=mm->next(); + } +} + +void Base::markerFrontCmd(int id) +{ + Marker* mm = markers->head(); + while (mm) { + if (mm->getId() == id) { + markers->extractNext(mm); + markers->insertHead(mm); + update(PIXMAP, mm->getAllBBox()); + return; + } + else + mm=mm->next(); + } +} + +void Base::markerKeyCmd() +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) + mm->key(); + mm=mm->next(); + } +} + +void Base::markerKeyCmd(const Vector& v) +{ + // v is in canvas coords + Marker* mm=markers->head(); + while (mm) { + if (mm->isIn(v)) + mm->key(); + mm=mm->next(); + } +} + +void Base::markerLineCmd(int id, const Vector& p1, const Vector& p2, + Coord::InternalSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Line*)(mm))->setPoints(mapToRef(p1,sys),mapToRef(p2,sys)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerLineCmd(int id, const Vector& p1, const Vector& p2, + Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + ((Line*)(mm))->setPoints(ptr->mapToRef(p1,sys,sky), + ptr->mapToRef(p2,sys,sky)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerLineArrowCmd(int id, int p1, int p2) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + ((Line*)(mm))->setArrows(p1, p2); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerLineWidthCmd(int w) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) { + mm->setLineWidth(w); + update(PIXMAP, mm->getAllBBox()); + } + mm=mm->next(); + } +} + +void Base::markerLineWidthCmd(int id, int w) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + mm->setLineWidth(w); + update(PIXMAP, mm->getAllBBox()); + return; + } + mm=mm->next(); + } +} + +void Base::markerListCmd(MarkerFormat type, + Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + int strip, int select, + unsigned short mask, unsigned short value, + List& tags) +{ + ostringstream str; + + switch (type) { + case DS9: + if (!strip) + markerListHeader(str); + str << setseparator(','); + break; + case XML: + markerListXMLHeader(str, sys, sky, format); + break; + case CIAO: + str << setseparator(','); + break; + case SAOTNG: + if (!strip) + markerListSAOtngHeader(str, sys, sky, format); + str << setseparator(','); + break; + case PROS: + str << setseparator(' '); + break; + case SAOIMAGE: + str << setseparator(','); + break; + case RAWXY: + str << setseparator(' '); + break; + } + + // check for wcs + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + break; + default: + if (!keyContext->fits->hasWCS(sys)) + goto done; + } + + { + Marker* mm = markers->head(); + Marker* first = mm; + while (mm) { + Tag* t; + + // selected + if (select) { + if (!mm->isSelected()) + goto next; + } + + // properties + if (mask) { + if (!((mm->getProperty() & mask) == value)) + goto next; + } + + // tags + if ((t=tags.head())) { + while (t) { + if (!mm->hasTag(t->tag())) + goto next; + t=t->next(); + } + } + + // ok, its passed the tests! + switch (type) { + case DS9: + // only do this once + if (mm == first) { + coord.listCoordSystem(str, sys, sky, keyContext->fits); + str << (strip ? ';' : '\n'); + } + mm->list(str, sys, sky, format, 0, strip); + break; + case XML: + mm->listXML(str, sys, sky, format); + break; + case CIAO: + mm->listCiao(str, sys, strip); + break; + case SAOTNG: + mm->listSAOtng(str, sys, sky, format, strip); + break; + case PROS: + mm->listPros(str, sys, sky, format, strip); + break; + case SAOIMAGE: + mm->listSAOimage(str, strip); + break; + case RAWXY: + mm->listXY(str, sys, sky, format, strip); + break; + } + + next: + mm=mm->next(); + } + } + + done: + switch (type) { + case DS9: + break; + case XML: + markerListXMLFooter(str); + break; + case CIAO: + break; + case SAOTNG: + break; + case PROS: + break; + case SAOIMAGE: + break; + case RAWXY: + break; + } + + str << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::markerLoadCmd(MarkerFormat fm, const char* fn) +{ + ifstream str(fn); + if (!str) { + result = TCL_ERROR; + return; + } + parseMarker(fm, str); +} + +void Base::markerLoadCmd(MarkerFormat fm, const char* fn, + Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + xySystem_ = sys; + xySky_ = sky; + markerLoadCmd(fm,fn); +} + +void Base::markerLoadCmd(MarkerFormat fm, int fd) +{ + boost::fdistream str(fd); + if (!str) { + result = TCL_ERROR; + return; + } + parseMarker(fm, str); +} + +void Base::markerLoadCmd(MarkerFormat fm, int fd, + Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + xySystem_ = sys; + xySky_ = sky; + markerLoadCmd(fm,fd); +} + +void Base::markerLoadFitsCmd(const char* fn, const char* color, + int* dash, int width, const char* font) +{ + if (!keyContext->fits) + return; + + // verify that we have an ext specified + if (fn && (fn[strlen(fn)-1] != ']')) { + result = TCL_ERROR; + return; + } + + // do we have a WCS? + FitsImage* mkfits = NULL; + { + mkfits = new FitsImageFitsMMap(currentContext, interp, fn, 1); + if (!mkfits || !mkfits->isValid() || !mkfits->isBinTable()) { + if (mkfits) + delete mkfits; + result = TCL_ERROR; + return; + } + } + + // recenter + if (keyContext->fits) { + FitsImage* ptr = keyContext->fits; + mkfits->nextBin(ptr->getHistCursor()); + } + + FitsFile* mk = mkfits->fitsFile(); + FitsHead* mkh = mk->head(); + FitsTableHDU* mkhdu = (FitsTableHDU*)mkh->hdu(); + + // determine x and y column names + // if image, hard code 'x' and 'y' + // however, if table, find out the columns used to bin + FitsColumn* x; + FitsColumn* y; + if (keyContext->fits) { + FitsImage* ptr = keyContext->fits; + if (ptr->isHist()) { + x = mkhdu->find(ptr->getHistX()); + y = mkhdu->find(ptr->getHistY()); + } + else { + x = mkhdu->find("x"); + y = mkhdu->find("y"); + } + } + else { + x = mkhdu->find("x"); + y = mkhdu->find("y"); + } + + FitsColumn* shape = mkhdu->find("shape"); + FitsColumn* r = mkhdu->find("r"); + FitsColumn* ang = mkhdu->find("rotang"); + + // manatory columns x and y + if (!x || !y) { + if (mkfits) + delete mkfits; + result = TCL_ERROR; + return; + } + + // and width should be the same + if (((FitsBinColumn*)x)->repeat() != ((FitsBinColumn*)y)->repeat()) { + if (mkfits) + delete mkfits; + result = TCL_ERROR; + return; + } + int repeat = ((FitsBinColumn*)x)->repeat(); + + char* ptr = (char*)mk->data(); + int rows = mkhdu->rows(); + int rowlen = mkhdu->width(); + + char text[] = ""; + List taglist; + List cblist; + + for (int i=0; istr(ptr)); + else { + s1 = new char[7]; + strcpy(s1,"POINT "); + } + + // look for '!', which sets include/exclude + char* s2 = s1; + unsigned short props = Marker::SELECT | Marker::HIGHLITE | Marker::EDIT | + Marker::MOVE | Marker::ROTATE | Marker::DELETE | Marker::SOURCE; + if (s2[0]=='!') + s2++; + else + props |= Marker::INCLUDE; + + Vector center(x->value(ptr,0),y->value(ptr,0)); + + if (!strncmp(s2, "CIRCLE", 6) && r) { + Vector rr(r->value(ptr),0); + createCircleCmd(keyContext->fits->mapToRef(center, Coord::PHYSICAL), + keyContext->fits->mapLenToRef(rr[0], Coord::PHYSICAL), + color, dash, width, font, text, props, NULL, taglist,cblist); + + } + else if (!strncmp(s2, "ANNULU", 6) && r) { + Vector rr0(r->value(ptr,0),0); + Vector rr1(r->value(ptr,1),0); + createAnnulusCmd(keyContext->fits->mapToRef(center ,Coord::PHYSICAL), + keyContext->fits->mapLenToRef(rr0[0], Coord::PHYSICAL), + keyContext->fits->mapLenToRef(rr1[0], Coord::PHYSICAL), + 1, + color, dash, width, font, text, props, NULL, taglist,cblist); + + } + else if (!strncmp(s2, "BOX ", 6) && r && ang) { + // with angle + Vector rr(r->value(ptr,0),r->value(ptr,1)); + createBoxCmd(keyContext->fits->mapToRef(center, Coord::PHYSICAL), + keyContext->fits->mapLenToRef(rr, Coord::PHYSICAL), + degToRad(ang->value(ptr)), + color, dash, width, font, text, props, NULL, taglist,cblist); + + } + else if (!strncmp(s2, "BOX ", 6) && r) { + // no angle + Vector rr(r->value(ptr,0),r->value(ptr,1)); + createBoxCmd(keyContext->fits->mapToRef(center, Coord::PHYSICAL), + keyContext->fits->mapLenToRef(rr, Coord::PHYSICAL), + 0, + color, dash, width, font, text, props, NULL, taglist,cblist); + + } + else if (!strncmp(s2, "ROTBOX", 6) && r && ang) { + Vector rr(r->value(ptr,0),r->value(ptr,1)); + createBoxCmd(keyContext->fits->mapToRef(center, Coord::PHYSICAL), + keyContext->fits->mapLenToRef(rr, Coord::PHYSICAL), + degToRad(ang->value(ptr)), + color, dash, width, font, text, props, NULL, taglist,cblist); + + } + else if (!strncmp(s2, "RECTAN", 6)) { + Vector v1(center); + Vector v2(x->value(ptr,1), y->value(ptr,1)); + + Vector d = v2-v1; + Vector c = d/2 + v1; + + createBoxCmd(keyContext->fits->mapToRef(c,Coord::PHYSICAL), + keyContext->fits->mapLenToRef(d,Coord::PHYSICAL), + 0, + color, dash, width, font, text, props, NULL, taglist,cblist); + } + + else if (!strncmp(s2, "ROTREC", 6) && ang) { + Vector v1(center); + Vector v2(x->value(ptr,1), y->value(ptr,1)); + + Vector d = v2-v1; + Vector c = d/2 + v1; + + createBoxCmd(keyContext->fits->mapToRef(c,Coord::PHYSICAL), + keyContext->fits->mapLenToRef(d,Coord::PHYSICAL), + degToRad(ang->value(ptr)), + color, dash, width, font, text, props, NULL, taglist,cblist); + } + + else if (!strncmp(s2, "ELLIPSE", 7) && r && ang) { + Vector rr(r->value(ptr,0),r->value(ptr,1)); + createEllipseCmd(keyContext->fits->mapToRef(center, Coord::PHYSICAL), + keyContext->fits->mapLenToRef(rr, Coord::PHYSICAL), + degToRad(ang->value(ptr)), + color, dash, width, font, text, props, NULL, taglist,cblist); + + } + else if (!strncmp(s2,"PIE",3) && r && ang) { + Vector rr0(r->value(ptr,0),0); + Vector rr1(r->value(ptr,1),0); + createCpandaCmd(keyContext->fits->mapToRef(center,Coord::PHYSICAL), + degToRad(ang->value(ptr,0)),degToRad(ang->value(ptr,1)),1, + keyContext->fits->mapLenToRef(rr0[0],Coord::PHYSICAL), + keyContext->fits->mapLenToRef(rr1[0],Coord::PHYSICAL), 1, + color, dash, width, font, text, props, NULL, taglist,cblist); + + } + else if (!strncmp(s2,"ELLIPTANN",9) && r && ang) { + Vector rr0(r->value(ptr,0),r->value(ptr,1)); + Vector rr1(r->value(ptr,2),r->value(ptr,3)); + createEpandaCmd(keyContext->fits->mapToRef(center,Coord::PHYSICAL), + degToRad(ang->value(ptr,0)),degToRad(ang->value(ptr,1)),1, + keyContext->fits->mapLenToRef(rr0,Coord::PHYSICAL), + keyContext->fits->mapLenToRef(rr1,Coord::PHYSICAL), 1, + 0, + color, dash, width, font, text, props, NULL, taglist,cblist); + + } + else if (!strncmp(s2, "POINT ", 6)) + createPointCmd(keyContext->fits->mapToRef(center,Coord::PHYSICAL), + Point::BOXCIRCLE, POINTSIZE, + color, dash, width, font, text, props, NULL, taglist,cblist); + + else if (!strncmp(s2, "POLYGO", 6)) { + List list; + for (int ii=0; iivalue(ptr,ii), y->value(ptr,ii)); + Vertex* n = new Vertex(keyContext->fits->mapToRef(vv, Coord::PHYSICAL)); + + if (ii+1 < repeat) { + // check for endpoints matching or endpoints NULL after first + if ((ii>0) && ( + (x->value(ptr,ii) == x->value(ptr,0) && + y->value(ptr,ii) == y->value(ptr,0)) || + (x->value(ptr,ii) == 0 && + y->value(ptr,ii) == 0))) { + delete n; + break; + } + list.append(n); + } + else { + // check for last point equals first point + if (x->value(ptr,ii) != x->value(ptr,0) || + y->value(ptr,ii) != y->value(ptr,0)) + list.append(n); + else + delete n; + } + } + + if (!list.isEmpty()) + createPolygonCmd(list, color, dash, width, font, text, props, NULL, + taglist,cblist); + } + + delete [] s1; + } + + if (mkfits) + delete mkfits; +} + +void Base::markerMoveCmd(const Vector& v) +{ + // use matrix, not map() + undoMarkers->deleteAll(); + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected() && mm->canMove()) { + undoMarkers->append(mm->dup()); + undoMarkerType = MOVE; + + Vector c = mm->getCenter() * refToCanvas; + update(PIXMAP, mm->getAllBBox()); + mm->moveTo((c + v) * canvasToRef); + update(PIXMAP, mm->getAllBBox()); + } + mm=mm->next(); + } +} + +void Base::markerMoveCmd(const char* tag, const Vector& v) +{ + // use matrix, not map() + undoMarkers->deleteAll(); + Marker* mm=markers->head(); + while (mm) { + if (mm->canMove() && mm->hasTag(tag)) { + undoMarkers->append(mm->dup()); + undoMarkerType = MOVE; + + Vector c = mm->getCenter() * refToCanvas; + update(PIXMAP, mm->getAllBBox()); + mm->moveTo((c + v) * canvasToRef); + update(PIXMAP, mm->getAllBBox()); + } + mm=mm->next(); + } +} + +void Base::markerMoveCmd(int id, const Vector& v) +{ + // use matrix, not map() + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canMove()) { + markerUndo(mm, MOVE); + + Vector c = mm->getCenter() * refToCanvas; + update(PIXMAP, mm->getAllBBox()); + mm->moveTo((c + v) * canvasToRef); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } +} + +void Base::markerMoveBeginCmd(const Vector& v) +{ + markerBegin = mapToRef(v,Coord::CANVAS); + + undoMarkers->deleteAll(); + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected() && mm->canMove()) { + undoMarkers->append(mm->dup()); + undoMarkerType = MOVE; + mm->moveBegin(); + } + mm=mm->next(); + } +} + +void Base::markerMoveBeginCmd(int id, const Vector& v) +{ + markerBegin = mapToRef(v,Coord::CANVAS); + + undoMarkers->deleteAll(); + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canMove()) { + undoMarkers->append(mm->dup()); + undoMarkerType = MOVE; + mm->moveBegin(); + } + return; + } + mm=mm->next(); + } +} + +void Base::markerMoveMotionCmd(const Vector& v) +{ + // first, accumulate erase markers + Marker* mm=markers->head(); + if (mm) { + while (mm) { + if (mm->isSelected() && mm->canMove()) + redraw(mm->getAllBBox()); + mm=mm->next(); + } + + // and erase now + forceUpdate(); + + // ok, now draw selected markers in new location + Vector markerEnd = mapToRef(v,Coord::CANVAS); + Vector diff = markerEnd - markerBegin; + markerBegin = markerEnd; + + mm=markers->head(); + while (mm) { + if (mm->isSelected() && mm->canMove()) { + mm->move(diff); + x11MarkerXOR(mm); + } + mm=mm->next(); + } + } +} + +void Base::markerMoveMotionCmd(int id, const Vector& v) +{ + // first, accumulate erase markers + Marker* mm=markers->head(); + if (mm) { + while (mm) { + if (mm->getId() && mm->canMove()) { + redraw(mm->getAllBBox()); + break; + } + mm=mm->next(); + } + + if (!mm) + return; // can't find it + + Marker *ptr = mm; + + // and erase now + forceUpdate(); + + // ok, now draw selected markers in new location + Vector markerEnd = mapToRef(v,Coord::CANVAS); + Vector diff = markerEnd - markerBegin; + markerBegin = markerEnd; + + ptr->move(diff); + x11MarkerXOR(ptr); + } +} + +void Base::markerMoveEndCmd() +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected() && mm->canMove()) + mm->moveEnd(); + mm=mm->next(); + } + + // update widget since we don't know where the selected markers came from + update(PIXMAP); +} + +void Base::markerMoveEndCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canMove()) + mm->moveEnd(); + return; + } + mm=mm->next(); + } + + // update widget since we don't know where the selected markers came from + update(PIXMAP); +} + +void Base::markerMoveToCmd(const Vector& v, Coord::InternalSystem sys) +{ + undoMarkers->deleteAll(); + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected() && mm->canMove()) { + undoMarkers->append(mm->dup()); + undoMarkerType = MOVE; + + update(PIXMAP, mm->getAllBBox()); + mm->moveTo(mapToRef(v,sys)); + update(PIXMAP, mm->getAllBBox()); + } + mm=mm->next(); + } +} + +void Base::markerMoveToCmd(const Vector& v, Coord::CoordSystem sys, + Coord::SkyFrame sky) +{ + undoMarkers->deleteAll(); + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected() && mm->canMove()) { + undoMarkers->append(mm->dup()); + undoMarkerType = MOVE; + + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + mm->moveTo(ptr->mapToRef(v,sys,sky)); + update(PIXMAP, mm->getAllBBox()); + } + mm=mm->next(); + } +} + +void Base::markerMoveToCmd(const char* tag, const Vector& v, + Coord::InternalSystem sys) +{ + undoMarkers->deleteAll(); + Marker* mm=markers->head(); + while (mm) { + if (mm->canMove() && mm->hasTag(tag)) { + undoMarkers->append(mm->dup()); + undoMarkerType = MOVE; + + update(PIXMAP, mm->getAllBBox()); + mm->moveTo(mapToRef(v,sys)); + update(PIXMAP, mm->getAllBBox()); + } + mm=mm->next(); + } +} + +void Base::markerMoveToCmd(const char* tag, const Vector& v, + Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + undoMarkers->deleteAll(); + Marker* mm=markers->head(); + while (mm) { + if (mm->canMove() && mm->hasTag(tag)) { + undoMarkers->append(mm->dup()); + undoMarkerType = MOVE; + + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + mm->moveTo(ptr->mapToRef(v,sys,sky)); + update(PIXMAP, mm->getAllBBox()); + } + mm=mm->next(); + } +} + +void Base::markerMoveToCmd(int id, const Vector& v, Coord::InternalSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canMove()) { + markerUndo(mm, MOVE); + + update(PIXMAP, mm->getAllBBox()); + mm->moveTo(mapToRef(v, sys)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } +} + +void Base::markerMoveToCmd(int id, const Vector& v, + Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canMove()) { + markerUndo(mm, MOVE); + + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + mm->moveTo(ptr->mapToRef(v,sys,sky)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } +} + +void Base::markerPasteCmd() +{ + // Internal copy/paste + { + Marker* mm=markers->head(); + while (mm) { + mm->unselect(); + mm=mm->next(); + } + } + + undoMarkers->deleteAll(); + Marker* mm=pasteMarkers->head(); + while (mm) { + Marker* nn = mm->dup(); + nn->newIdentity(); + markers->append(nn); + mm = mm->next(); + } + + update(PIXMAP); +} + + +void Base::markerPasteCmd(Coord::CoordSystem sys) +{ + ostringstream str; + + // MarkerFormat type = DS9; + markerListHeader(str); + coord.listCoordSystem(str, sys, Coord::FK5, keyContext->fits); + str << endl; + str << setseparator(','); + + Marker* mm = pasteMarkers->head(); + while (mm) { + mm->list(str, sys, Coord::FK5, Coord::DEGREES, 0, 0); + mm=mm->next(); + } + + str << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Base::markerPointShapeCmd(int id, Point::PointShape shape) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Point*)mm)->setShape(shape); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerPointSizeCmd(int id, int size) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Point*)mm)->setSize(size); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerPolygonCreateVertexCmd(int id, int seg, const Vector& v) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + ((Polygon*)(mm))->createVertex(seg, mapToRef(v,Coord::CANVAS)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerPolygonDeleteVertexCmd(int id, int h) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Polygon*)(mm))->deleteVertex(h); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } +} + +void Base::markerPolygonResetCmd(int id, const Vector& size, + Coord::InternalSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Polygon*)(mm))->reset(mapLenToRef(size, sys)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerPolygonResetCmd(int id, const Vector& size, + Coord::CoordSystem sys, Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + ((Polygon*)(mm))->reset(ptr->mapLenToRef(size, sys, dist)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerProjectionCmd(int id,const Vector& p1,const Vector& p2, + Coord::InternalSystem sys,double width) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Projection*)(mm))->set(mapToRef(p1,sys), mapToRef(p2,sys), + mapLenToRef(width,sys)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerProjectionCmd(int id, + const Vector& p1, const Vector& p2, + Coord::CoordSystem sys, Coord::SkyFrame sky, + double width, + Coord::CoordSystem wdsys, Coord::SkyDist wddist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + ((Projection*)(mm))->set(ptr->mapToRef(p1,sys,sky), + ptr->mapToRef(p2,sys,sky), + ptr->mapLenToRef(width, wdsys, wddist)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerPropertyCmd(unsigned short prop, int value) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) { + if (prop == Marker::DASH || + prop == Marker::FIXED || + prop == Marker::INCLUDE || + prop == Marker::SOURCE) { + // marker will change bbox, so get before and after + update(PIXMAP, mm->getAllBBox()); + mm->setProperty(prop, value); + update(PIXMAP, mm->getAllBBox()); + } + else + mm->setProperty(prop, value); + } + mm=mm->next(); + } +} + +void Base::markerPropertyCmd(const char* tag, unsigned short prop, int value) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->hasTag(tag)) { + if (prop == Marker::DASH || + prop == Marker::FIXED || + prop == Marker::INCLUDE || + prop == Marker::SOURCE) { + // marker will change bbox, so get before and after + update(PIXMAP, mm->getAllBBox()); + mm->setProperty(prop, value); + update(PIXMAP, mm->getAllBBox()); + } + else + mm->setProperty(prop, value); + } + mm=mm->next(); + } +} + +void Base::markerPropertyCmd(unsigned short prop, int value, const Vector& v) +{ + // v is in canvas coords + + Marker* mm=markers->head(); + while (mm) { + if (mm->isIn(v)) { + if (prop == Marker::DASH || + prop == Marker::FIXED || + prop == Marker::INCLUDE || + prop == Marker::SOURCE) { + // marker will change bbox, so get before and after + update(PIXMAP, mm->getAllBBox()); + mm->setProperty(prop, value); + update(PIXMAP, mm->getAllBBox()); + } + else + mm->setProperty(prop, value); + } + mm=mm->next(); + } +} + +void Base::markerPropertyCmd(int id, unsigned short prop, int value) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (prop == Marker::DASH || + prop == Marker::FIXED || + prop == Marker::INCLUDE || + prop == Marker::SOURCE) { + // marker will change bbox, so get before and after + update(PIXMAP, mm->getAllBBox()); + mm->setProperty(prop, value); + update(PIXMAP, mm->getAllBBox()); + } + else + mm->setProperty(prop, value); + + return; + } + mm=mm->next(); + } +} + +void Base::markerRotateBeginCmd(int id) +{ + // remember which marker is being edited + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canRotate()) { + markerUndo(mm, EDIT); + rotateMarker = mm; + rotateMarker->rotateBegin(); + } + return; + } + mm=mm->next(); + } + + rotateMarker = NULL; +} + +void Base::markerRotateBeginCmd(const Vector& v) +{ + // remember which marker is being edited + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected() && mm->canRotate()) { + markerUndo(mm, EDIT); + rotateMarker = mm; + rotateMarker->rotateBegin(); + return; + } + mm=mm->next(); + } + + rotateMarker = NULL; +} + +void Base::markerRotateMotionCmd(const Vector& vv, int hh) +{ + if (rotateMarker) { + // erase current marker now + redraw(rotateMarker->getAllBBox()); + forceUpdate(); + + rotateMarker->rotate(mapToRef(vv,Coord::CANVAS), hh); + x11MarkerXOR(rotateMarker); + } +} + +void Base::markerRotateEndCmd() +{ + if (rotateMarker) + rotateMarker->rotateEnd(); + rotateMarker = NULL; + update(PIXMAP); +} + +void Base::markerRulerPointCmd(int id, const Vector& p1, const Vector& p2, + Coord::InternalSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Ruler*)(mm))->setPoints(mapToRef(p1,sys),mapToRef(p2,sys)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerRulerPointCmd(int id, const Vector& p1, const Vector& p2, + Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + ((Ruler*)(mm))->setPoints(ptr->mapToRef(p1,sys,sky), + ptr->mapToRef(p2,sys,sky)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerRulerSystemCmd(int id, Coord::CoordSystem sys, + Coord::SkyFrame sky, + Coord::CoordSystem dsys, Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Ruler*)(mm))->setCoordSystem(sys, sky, dsys, dist); + update(PIXMAP, mm->getAllBBox()); + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerSaveCmd(const char* fileName, MarkerFormat type, + Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, + int strip) +{ + ofstream fn(fileName); + if (!fn) { + Tcl_AppendResult(interp, "Unable to open file ", fileName, NULL); + result = TCL_ERROR; + return; + } + + switch (type) { + case DS9: + if (!strip) + markerListHeader(fn); + fn << setseparator(','); + break; + case XML: + markerListXMLHeader(fn, sys, sky, format); + break; + case CIAO: + fn << setseparator(','); + break; + case SAOTNG: + if (!strip) + markerListSAOtngHeader(fn, sys, sky, format); + fn << setseparator(','); + break; + case SAOIMAGE: + fn << setseparator(','); + break; + case PROS: + fn << setseparator(' '); + break; + case RAWXY: + fn << setseparator(' '); + break; + } + + // check for wcs + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + break; + default: + if (!keyContext->fits->hasWCS(sys)) + goto done; + } + + { + Marker* mm = markers->head(); + Marker* first = mm; + while (mm) { + switch (type) { + case DS9: + // only do this once + if (mm == first) { + coord.listCoordSystem(fn, sys, sky, keyContext->fits); + fn << (strip ? ';' : '\n'); + } + mm->list(fn, sys, sky, format, 0, strip); + break; + case XML: + mm->listXML(fn, sys, sky, format); + break; + case CIAO: + mm->listCiao(fn, sys, strip); + break; + case SAOTNG: + mm->listSAOtng(fn, sys, sky, format, strip); + break; + case SAOIMAGE: + mm->listSAOimage(fn, strip); + break; + case PROS: + mm->listPros(fn, sys, sky, format, strip); + break; + case RAWXY: + mm->listXY(fn, sys, sky, format, strip); + break; + } + mm=mm->next(); + } + } + + done: + switch (type) { + case DS9: + break; + case XML: + markerListXMLFooter(fn); + break; + case CIAO: + break; + case SAOTNG: + break; + case SAOIMAGE: + break; + case PROS: + break; + case RAWXY: + break; + } +} + +void Base::markerSaveTemplateCmd(const char* fileName) +{ + Marker* mm=markers->head(); + if (!keyContext->fits || !mm) + return; + + ofstream fn(fileName); + if (!fn) { + Tcl_AppendResult(interp, "Unable to open file ", fileName, NULL); + result = TCL_ERROR; + } + + FitsImage* ptr = keyContext->fits; + while (ptr) { + ptr->initWCS0(mm->getCenter()); + ptr = ptr->nextMosaic(); + } + + markerListHeader(fn); + fn << "wcs0;fk5" << endl; + + while (mm) { + mm->list(fn, Coord::WCS0, Coord::FK5, Coord::DEGREES, 0, 0); + mm=mm->next(); + } + + ptr = keyContext->fits; + while (ptr) { + ptr->resetWCS0(); + ptr = ptr->nextMosaic(); + } +} + +void Base::markerSegmentCreateVertexCmd(int id, int seg, const Vector& v) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + ((Segment*)(mm))->createVertex(seg, mapToRef(v,Coord::CANVAS)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerSegmentDeleteVertexCmd(int id, int h) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Segment*)(mm))->deleteVertex(h); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } +} + +void Base::markerSegmentResetCmd(int id, const Vector& size, Coord::InternalSystem sys) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Segment*)(mm))->reset(mapLenToRef(size, sys)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerSegmentResetCmd(int id, const Vector& size, + Coord::CoordSystem sys, Coord::SkyDist dist) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + ((Segment*)(mm))->reset(ptr->mapLenToRef(size, sys, dist)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerSelectAllCmd() +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->canSelect()) { + mm->select(); + update(PIXMAP, mm->getBBox()); + } + mm=mm->next(); + } +} + +void Base::markerSelectCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->canSelect() && mm->getId() == id) { + mm->select(); + update(PIXMAP, mm->getAllBBox()); + return; + } + mm=mm->next(); + } +} + +void Base::markerSelectCmd(const char* tag) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->canSelect() && mm->hasTag(tag)) { + mm->select(); + update(PIXMAP, mm->getBBox()); + } + mm=mm->next(); + } +} + +void Base::markerSelectToggleCmd() +{ + // toggle the select of the first found + Marker* mm=markers->head(); + while (mm) { + if (mm->canSelect()) { + mm->toggleSelect(); + update(PIXMAP, mm->getBBox()); + } + mm=mm->next(); + } +} + +void Base::markerSelectToggleCmd(const Vector& v) +{ + // toggle the select of the first found + Marker* mm=markers->head(); + while (mm) { + if (mm->canSelect() && mm->isIn(v)) { + mm->toggleSelect(); + update(PIXMAP, mm->getBBox()); + Tcl_AppendResult(interp, "1", NULL); + return; + } + mm=mm->next(); + } + + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::markerSelectOnlyCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->canSelect() && mm->getId() == id) { + if (!mm->isSelected()) { + mm->select(); + update(PIXMAP, mm->getBBox()); + } + } + else { + if (mm->isSelected()) { + mm->unselect(); + update(PIXMAP, mm->getBBox()); + } + } + mm=mm->next(); + } +} + +void Base::markerSelectOnlyCmd(const char* tag) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->canSelect() && mm->hasTag(tag)) { + if (!mm->isSelected()) { + mm->select(); + update(PIXMAP, mm->getBBox()); + } + else { + if (mm->isSelected()) { + mm->unselect(); + update(PIXMAP, mm->getBBox()); + } + } + } + mm=mm->next(); + } +} + +void Base::markerSelectOnlyCmd(const Vector& v) +{ + // first, check to see if we clicked on an already selected marker + Marker* mm=markers->head(); + while (mm) { + if (mm->canSelect() && mm->isIn(v) && mm->isSelected()) { + Tcl_AppendResult(interp, "1", NULL); + return; + } + mm=mm->next(); + } + + // ok, now select the first found, and unselect the rest + int found = 0; + + mm=markers->head(); + while (mm) { + if (mm->canSelect() && mm->isIn(v) && !found) { + if (!mm->isSelected()) { + mm->select(); + update(PIXMAP, mm->getBBox()); + } + found = 1; + } + else { + if (mm->isSelected()) { + mm->unselect(); + update(PIXMAP, mm->getBBox()); + } + } + mm=mm->next(); + } + + if (found) + Tcl_AppendResult(interp, "1", NULL); + else + Tcl_AppendResult(interp, "0", NULL); +} + +void Base::markerShowCmd(int which) +{ + showMarkers = which; + update(PIXMAP); +} + +void Base::markerShowTextCmd(int which) +{ + showMarkersText = which; + update(PIXMAP); +} + +void Base::markerTagCmd(const char* tag) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->isSelected()) + mm->addTag(tag); + mm=mm->next(); + } +} + +void Base::markerTagCmd(int id, const char* tag) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + mm->addTag(tag); + return; + } + mm=mm->next(); + } +} + +void Base::markerTagEditCmd(const char* from, const char* to) +{ + Marker* mm=markers->head(); + while (mm) { + mm->editTag(from, to); + mm=mm->next(); + } +} + +void Base::markerTagDeleteCmd(const char* t) +{ + Marker* mm=markers->head(); + while (mm) { + mm->deleteTag(t); + mm=mm->next(); + } +} + +void Base::markerTagDeleteAllCmd() +{ + Marker* mm=markers->head(); + while (mm) { + mm->deleteTags(); + mm=mm->next(); + } +} + +void Base::markerTagUpdateCmd(const char* t) +{ + markerTagDeleteCmd(t); + markerTagCmd(t); +} + +void Base::markerTextCmd(int id, const char* text) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + // things can shrink, so do before and after + update(PIXMAP,mm->getAllBBox()); + mm->setText(text); + update(PIXMAP,mm->getAllBBox()); + return; + } + mm=mm->next(); + } +} + +void Base::markerTextRotateCmd(int id, int rot) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + ((Text*)(mm))->setRotate(rot); + update(PIXMAP); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerUndoCmd() +{ + Marker* nn=undoMarkers->head(); + while (nn) { + Marker* next = nn->next(); + undoMarkers->extractPrev(nn); + + switch (undoMarkerType) { + case NONE: + break; + case DELETE: + markers->append(nn); + nn->updateBBox(); + update(PIXMAP,nn->getAllBBox()); + break; + case EDIT: + case MOVE: + { + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == nn->getId()) { + nn->enableCB(); + mm->updateBBox(); + update(PIXMAP,mm->getAllBBox()); + + markers->insertNext(mm,nn); + markers->extractNext(mm); + + nn->updateBBox(); + update(PIXMAP,nn->getAllBBox()); + switch (undoMarkerType) { + case EDIT: + nn->doCallBack(CallBack::EDITCB); + break; + case MOVE: + nn->doCallBack(CallBack::MOVECB); + break; + default: + // na + break; + } + + mm->disableCB(); + delete mm; + break; + } + mm=mm->next(); + } + } + break; + } + + nn=next; + } + + undoMarkerType = NONE; +} + +void Base::markerUnhighliteAllCmd() +{ + Marker* mm=markers->head(); + while (mm) { + mm->unhighlite(); + update(PIXMAP, mm->getBBox()); + mm=mm->next(); + } +} + +void Base::markerUnhighliteCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + mm->unhighlite(); + update(PIXMAP, mm->getBBox()); + return; + } + mm=mm->next(); + } +} + +void Base::markerUnhighliteCmd(const char* tag) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->hasTag(tag)) { + mm->unhighlite(); + update(PIXMAP, mm->getBBox()); + } + mm=mm->next(); + } +} + +void Base::markerUnselectAllCmd() +{ + Marker* mm=markers->head(); + while (mm) { + mm->unselect(); + update(PIXMAP, mm->getBBox()); + mm=mm->next(); + } +} + +void Base::markerUnselectCmd(int id) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + mm->unselect(); + update(PIXMAP, mm->getBBox()); + return; + } + mm=mm->next(); + } +} + +void Base::markerUnselectCmd(const char* tag) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->hasTag(tag)) { + mm->unselect(); + update(PIXMAP, mm->getBBox()); + } + mm=mm->next(); + } +} + +void Base::markerVectorCmd(int id, const Vector& p, Coord::InternalSystem sys, + double mag, double ang) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + ((Vect*)(mm))->setPoints(mapToRef(p,sys),mapLenToRef(mag,sys),ang); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerVectorCmd(int id, const Vector& p, + Coord::CoordSystem sys, Coord::SkyFrame sky, + double mag, + Coord::CoordSystem dsys, Coord::SkyDist dist, + double ang) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + markerUndo(mm, EDIT); + + // it may shrink + update(PIXMAP, mm->getAllBBox()); + FitsImage* ptr = findFits(sys,mm->getCenter()); + ((Vect*)(mm))->setPoints(ptr->mapToRef(p,sys,sky), + ptr->mapLenToRef(mag,dsys,dist), + mapAngleToRef(ang,sys,sky)); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::markerVectorArrowCmd(int id, int p) +{ + Marker* mm=markers->head(); + while (mm) { + if (mm->getId() == id) { + if (mm->canEdit()) { + ((Vect*)(mm))->setArrow(p); + update(PIXMAP, mm->getAllBBox()); + } + return; + } + mm=mm->next(); + } + + result = TCL_ERROR; +} + +void Base::regionHighliteEndCmd() +{ + BBox bb(regionBegin, regionEnd); + + Marker* mm=markers->head(); + while (mm) { + if (bb.isIn(mm->getBBox())==4 && mm->canHighlite()) + mm->highlite(); + else + mm->unhighlite(); + mm=mm->next(); + } + + update(PIXMAP, bb.expand(2)); +} + +void Base::regionHighliteShiftEndCmd() +{ + BBox bb(regionBegin, regionEnd); + + Marker* mm=markers->head(); + while (mm) { + if (bb.isIn(mm->getBBox())==4 && mm->canHighlite()) + mm->highlite(); + mm=mm->next(); + } + + update(PIXMAP, bb.expand(2)); +} + +void Base::regionSelectBeginCmd(const Vector& vv) +{ + regionBegin = vv; + regionEnd = vv; +} + +void Base::regionSelectMotionCmd(const Vector& vv) +{ + // erase + redrawNow((BBox(regionBegin, regionEnd)).expand(2)); + + // and draw to window + regionEnd = vv; + BBox cc = BBox(regionBegin, regionEnd) * canvasToWindow; + Vector size = cc.size(); + + XDrawRectangle(display, Tk_WindowId(tkwin), selectGCXOR, + cc.ll[0], cc.ll[1], size[0], size[1]); +} + +void Base::regionSelectEndCmd() +{ + BBox bb(regionBegin, regionEnd); + + Marker* mm=markers->head(); + while (mm) { + if (bb.isIn(mm->getBBox())==4 && mm->canSelect()) + mm->select(); + else + mm->unselect(); + mm=mm->next(); + } + + update(PIXMAP, bb.expand(2)); +} + +void Base::regionSelectShiftEndCmd() +{ + BBox bb(regionBegin, regionEnd); + + Marker* mm=markers->head(); + while (mm) { + if (bb.isIn(mm->getBBox())==4 && mm->canSelect()) + mm->select(); + mm=mm->next(); + } + + update(PIXMAP, bb.expand(2)); +} + +// Marker Support + +void Base::markerListHeader(ostream& str) +{ + str << "# Region file format: DS9 version 4.1" << endl; + str << "global color=green dashlist=8 3 width=1 font=\"helvetica 10 normal roman\" select=1 highlite=1 dash=0 fixed=0 edit=1 move=1 delete=1 include=1 source=1" << endl; +} + +void Base::markerListSAOtngHeader(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format) +{ + // don't output filename anymore + // if (keyContext->fits) + // str << "# filename: " << keyContext->fits->getRootFileName() << endl; + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::AMPLIFIER: + case Coord::DETECTOR: + str << "# format: pixels (physical)" << endl; + break; + + default: + str << "# format: "; + switch (sky) { + case Coord::FK4: + case Coord::FK4_NO_E: + case Coord::FK5: + case Coord::ICRS: + case Coord::GALACTIC: + case Coord::SUPERGALACTIC: + case Coord::ECLIPTIC: + case Coord::HELIOECLIPTIC: + switch (format) { + case Coord::DEGREES: + str << "degrees ("; + break; + case Coord::SEXAGESIMAL: + str << "hms ("; + break; + } + + switch (sky) { + case Coord::FK4: + str << "fk4"; + break; + case Coord::FK4_NO_E: + str << "fk4-no-e"; + break; + case Coord::FK5: + str << "fk5"; + break; + case Coord::ICRS: + str << "icrs"; + break; + case Coord::GALACTIC: + str << "galactic"; + break; + case Coord::SUPERGALACTIC: + str << "supergalactic"; + break; + case Coord::ECLIPTIC: + str << "ecliptic"; + break; + case Coord::HELIOECLIPTIC: + str << "helioecliptic"; + break; + } + + str << ')' << endl; + break; + } + } +} + +void Base::markerUndo(Marker* m, UndoMarkerType t) +{ + undoMarkers->deleteAll(); + undoMarkers->append(m->dup()); + undoMarkerType = t; +} + +void Base::parseMarker(MarkerFormat fm, istream& str) +{ + switch (fm) { + case DS9: + { + mkFlexLexer* ll = new mkFlexLexer(&str); + mkparse(this, ll); + delete ll; + + resetCompositeMarker(); + } + break; + case XML: + xmlParse(str); + break; + case CIAO: + { + ciaoFlexLexer* ll = new ciaoFlexLexer(&str); + ciaoparse(this, ll); + delete ll; + } + break; + case PROS: + { + prosFlexLexer* ll = new prosFlexLexer(&str); + prosparse(this, ll); + delete ll; + } + break; + case SAOTNG: + { + tngFlexLexer* ll = new tngFlexLexer(&str); + tngparse(this, ll); + delete ll; + } + break; + + case SAOIMAGE: + { + saoFlexLexer* ll = new saoFlexLexer(&str); + saoparse(this, ll); + delete ll; + } + break; + + case RAWXY: + { + xyFlexLexer* ll = new xyFlexLexer(&str); + xyparse(this, ll); + delete ll; + } + break; + } +} + +void Base::psMarkers(List* ml, int mode) +{ + // render from back to front + // bbox is in canvas coords + const BBox bb = BBox(0, 0, options->width-1, options->height-1) * + widgetToCanvas; + + Marker* mm=ml->tail(); + while (mm) { + if (mm->isVisible(bb)) + mm->ps(mode, showMarkersText); + mm=mm->previous(); + } +} + +void Base::x11MagnifierMarkers(List* ml, const BBox& bb) +{ + // render from back to front + // bbox is in canvas coords + Marker* mm=ml->tail(); + while (mm) { + if (mm->isVisible(bb)) + mm->x11(magnifierPixmap, Coord::MAGNIFIER, showMarkersText, + Marker::SRC, Marker::NOHANDLES); + mm=mm->previous(); + } +} + +void Base::x11Markers(List* ml, const BBox& bb) +{ + // render from back to front + // bbox is in canvas coords + Marker* mm=ml->tail(); + while (mm) { + if (mm->isVisible(bb)) + mm->x11(pixmap, Coord::WIDGET, showMarkersText, + Marker::SRC, Marker::HANDLES); + mm=mm->previous(); + } +} + +void Base::x11MarkerXOR(Marker* ptr) +{ + if (ptr) + ptr->x11(Tk_WindowId(tkwin), Coord::WINDOW, showMarkersText, + Marker::XOR, Marker::NOHANDLES); +} + +void Base::unselectMarkers(List* ml) +{ + Marker* mm=ml->head(); + while (mm) { + mm->unselect(); + mm=mm->next(); + } +} + +void Base::unhighliteMarkers() +{ + Marker* mm=markers->head(); + while (mm) { + mm->unhighlite(); + mm=mm->next(); + } +} + +void Base::updateCBMarkers(List* ml) +{ + Marker* mm=ml->head(); + while (mm) { + mm->doCallBack(CallBack::UPDATECB); + mm=mm->next(); + } +} + +void Base::updateMarkers(List* ml) +{ + Marker* mm=ml->head(); + while (mm) { + mm->updateBBox(); + mm=mm->next(); + } +} + +void Base::updateMarkerCoords(List* ml, const Matrix& mx) +{ + Marker* mm=ml->head(); + while (mm) { + mm->updateCoords(mx); + mm=mm->next(); + } +} + +void Base::updateMarkerCBs(List* ml) +{ + Marker* mm=ml->head(); + while (mm) { + mm->doCallBack(CallBack::MOVECB); + mm->doCallBack(CallBack::EDITCB); + mm->doCallBack(CallBack::ROTATECB); + mm=mm->next(); + } +} + +#ifdef MAC_OSX_TK +void Base::macosxMarkers(List* ml) +{ + // render from back to front + // bbox is in canvas coords + const BBox bb = BBox(0, 0, options->width-1, options->height-1) * + widgetToCanvas; + + Marker* mm=ml->tail(); + while (mm) { + if (mm->isVisible(bb)) + mm->macosx(showMarkersText); + mm=mm->previous(); + } +} +#endif + +#ifdef __WIN32 +void Base::win32Markers(List* ml) +{ + // render from back to front + // bbox is in canvas coords + const BBox bb = BBox(0, 0, options->width-1, options->height-1) * + widgetToCanvas; + + Marker* mm=ml->tail(); + while (mm) { + if (mm->isVisible(bb)) + mm->win32(showMarkersText); + mm=mm->previous(); + } +} +#endif + diff --git a/tksao/frame/frmarkerxml.C b/tksao/frame/frmarkerxml.C new file mode 100644 index 0000000..e8794a2 --- /dev/null +++ b/tksao/frame/frmarkerxml.C @@ -0,0 +1,1118 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include "fdstream.hpp" +#include + +#include "context.h" +#include "framebase.h" +#include "fitsimage.h" + +static int xmlRead (void * context, char * buffer, int len) +{ + istream* str=(istream*)context; + str->read(buffer,len); + return str->gcount(); +} + +static int xmlClose (void * context) +{ + return 1; +} + +void Base::xmlParse(istream& str) +{ + xmlTextReaderPtr reader = + xmlReaderForIO(xmlRead, xmlClose, (void*)(&str), "", NULL, 0); + if (reader) { + char** cols=NULL; + int colcnt=0; + + int id[128]; + char* unit[128]; + char* ref[128]; + char* axis[128]; + char* dir[128]; + for (int ii=0; ii<128; ii++) { + id[ii]=0; + unit[ii]=NULL; + ref[ii]=NULL; + dir[ii]=NULL; + } + + int cnt=0; + int state=0; + + int ret = xmlTextReaderRead(reader); + while (ret == 1) { + int nodeType = xmlTextReaderNodeType(reader); + char* key = (char*)xmlTextReaderConstName(reader); + + if (!strncmp(key,"VOTABLE",7) && (nodeType==1)) { + } else if (!strncmp(key,"VOTABLE",7) && (nodeType==15)) { + } else if (!strncmp(key,"DEFINITIONS",11) && (nodeType==1)) { + } else if (!strncmp(key,"DEFINITIONS",11) && (nodeType==15)) { + } else if (!strncmp(key,"COOSYS",6) && (nodeType==1)) { + } else if (!strncmp(key,"COOSYS",6) && (nodeType==15)) { + } else if (!strncmp(key,"RESOURCE",8) && (nodeType==1)) { + } else if (!strncmp(key,"RESOURCE",8) && (nodeType==15)) { + } else if (!strncmp(key,"TABLE",5) && (nodeType==1)) { + } else if (!strncmp(key,"TABLE",5) && (nodeType==15)) { + } else if (!strncmp(key,"FIELD",5) && (nodeType==1)) { + xmlParseFIELD(reader,id,unit,ref,axis,dir,colcnt); + state = 2; + colcnt++; + } else if (!strncmp(key,"FIELD",5) && (nodeType==15)) { + state = 0; + } else if (!strncmp(key,"DATA",4) && (nodeType==1)) { + state = 0; + } else if (!strncmp(key,"DATA",4) && (nodeType==15)) { + } else if (!strncmp(key,"TABLEDATA",9) && (nodeType==1)) { + state = 0; + } else if (!strncmp(key,"TABLEDATA",9) && (nodeType==15)) { + } else if (!strncmp(key,"TR",2) && (nodeType==1)) { + if (cols) { + for (int ii=0; ii taglist; + + // params + char* param =NULL; + char* param2 =NULL; + char* param3 =NULL; + char* param4 =NULL; + char* param5 =NULL; + + // comment + char* comment=NULL; + + List cblist; + + // build it + for (int ii=0; iimapLenToRef(atof(r), rsys, rdist), + color, dash, width, font, text, props, comment, + taglist, cblist); + } + else if (STRCMP(shape, "ellipse", 7)) { + createEllipseCmd(xmlPoint(ptr, x, y, sys, sky, format), + ptr->mapLenToRef(Vector(atof(r),atof(r2)), + rsys, rdist), + xmlAngle(ang, angsign, angoffset, angformat, + sys, sky), + color, dash, width, font, text, props, comment, + taglist, cblist); + } + else if (STRCMP(shape, "box", 3) || STRCMP(shape, "rotbox", 6)) { + createBoxCmd(xmlPoint(ptr, x, y, sys, sky, format), + ptr->mapLenToRef(Vector(atof(r),atof(r2)), + rsys, rdist), + xmlAngle(ang, angsign, angoffset, angformat, + sys, sky), + color, dash, width, font, text, props, comment, + taglist, cblist); + } + else if (STRCMP(shape, "rectang", 6) || STRCMP(shape, "rotrec", 6)) { + Vector v1 = xmlPoint(ptr, xv, yv, vsys, vsky, vformat, 0); + Vector v2 = xmlPoint(ptr, xv, yv, vsys, vsky, vformat, 1); + Vector d = v2-v1; + Vector c = d/2 + v1; + createBoxCmd(c,d, + xmlAngle(ang, angsign, angoffset, angformat, + sys, sky), + color, dash, width, font, text, props, comment, + taglist, cblist); + } + else if (STRCMP(shape, "polygon", 7)) { + List* list = xmlVertex(ptr, xv, yv, vsys, vsky, vformat); + createPolygonCmd(*list, + color, dash, width, font, text, props, comment, + taglist, cblist); + } + else if (STRCMP(shape, "line", 4)) { + int arrow1 =1; + int arrow2 =1; + if (!param) + arrow1 = atoi(param); + if (!param2) + arrow2 = atoi(param2); + createLineCmd(xmlPoint(ptr, xv, yv, vsys, vsky, vformat, 0), + xmlPoint(ptr, xv, yv, vsys, vsky, vformat, 1), + arrow1, arrow2, + color, dash, width, font, text, props, comment, + taglist, cblist); + } + else if (STRCMP(shape, "vector", 6)) { + int arrow =1; + if (!param) + arrow = atoi(param); + createVectCmd(xmlPoint(ptr, x, y, sys, sky, format), + ptr->mapLenToRef(atof(r), rsys, rdist), + xmlAngle(ang, angsign, angoffset, angformat, + sys, sky), + arrow, + color, dash, width, font, text, props, comment, + taglist, cblist); + } + else if (STRCMP(shape, "projection", 10)) { + createProjectionCmd(xmlPoint(ptr, xv, yv, vsys, vsky, vformat, 0), + xmlPoint(ptr, xv, yv, vsys, vsky, vformat, 1), + ptr->mapLenToRef(atof(r), rsys, rdist), + color, dash, width, font, + text, props, comment, taglist, cblist); + } + else if (STRCMP(shape, "segment", 7)) { + List* list = xmlVertex(ptr, xv, yv, vsys, vsky, vformat); + createSegmentCmd(*list, + color, dash, width, font, text, props, comment, + taglist, cblist); + } + else if (STRCMP(shape, "text", 4)) { + int rotate = 1; + if (!param) + rotate = atoi(param); + createTextCmd(xmlPoint(ptr, x, y, sys, sky, format), + xmlAngle(ang, angsign, angoffset, angformat, + sys, sky), + rotate, + color, dash, width, font, text, props, comment, + taglist, cblist); + } + else if (STRCMP(shape, "point", 5)) { + const char* def = "circle"; + Point::PointShape shape = Point::CIRCLE; + if (!param) + param = (char*)def; + int size = 11; + if (param2) + size = atoi(param2); + + if (STRCMP(param, "circle", 6)) + shape = Point::CIRCLE; + else if (STRCMP(param, "box", 3)) + shape = Point::BOX; + else if (STRCMP(param, "diamond", 7)) + shape = Point::DIAMOND; + else if (STRCMP(param, "cross", 5)) + shape = Point::CROSS; + else if (STRCMP(param, "x", 1)) + shape = Point::EX; + else if (STRCMP(param, "arrow", 5)) + shape = Point::ARROW; + else if (STRCMP(param,"boxcircle",9)) + shape = Point::BOXCIRCLE; + + createPointCmd(xmlPoint(ptr, x, y, sys, sky, format), + shape, size, + color, dash, width, font, text, props, comment, + taglist, cblist); + } + + // Measurement Regions + else if (STRCMP(shape, "ruler", 5)) { + Coord::CoordSystem rsys; + Coord::SkyFrame rsky; + coord.strToCoordSystem(param, wcsSystem_, &rsys, &rsky); + Coord::CoordSystem dsys; + Coord::SkyDist ddist; + coord.strToDistSystem(param2, wcsSystem_, &dsys, &ddist); + createRulerCmd(xmlPoint(ptr, xv, yv, vsys, vsky, vformat, 0), + xmlPoint(ptr, xv, yv, vsys, vsky, vformat, 1), + rsys, rsky, dsys, ddist, + color, dash, width, font, + text, props, comment, taglist, cblist); + } + else if (STRCMP(shape, "compass", 7)) { + Coord::CoordSystem csys; + Coord::SkyFrame csky; + coord.strToCoordSystem(param, wcsSystem_, &csys, &csky); + const char* param2def = "N"; + if (!param2) + param2 = (char*)param2def; + const char* param3def = "E"; + if (!param3) + param3 = (char*)param3def; + int arrow1 =1; + if (!param4) + arrow1 = atoi(param4); + int arrow2 =1; + if (!param5) + arrow2 = atoi(param5); + + createCompassCmd(xmlPoint(ptr, x, y, sys, sky, format), + ptr->mapLenToRef(atof(r), rsys, rdist), + param2, param3, arrow1, arrow2, + csys, csky, + color, dash, width, font, text, props, comment, + taglist, cblist); + } + + // Annulus Regions + else if (STRCMP(shape, "annulus", 7)) { + int num = xmlCount(rv); + createAnnulusCmd(xmlPoint(ptr, x, y, sys, sky, format), + num, xmlDistance(ptr, rv, num, rvsys, rvdist), + color, dash, width, font, text, props, comment, + taglist, cblist); + } + else if (STRCMP(shape, "ellipseannulus", 14)) { + + int num = xmlCount(rv); + createEllipseAnnulusCmd(xmlPoint(ptr, x, y, sys, sky, format), + num, xmlDistance(ptr, rv, rv2, num, rvsys, rvdist), + xmlAngle(ang, angsign, angoffset, + angformat, sys, sky), + color, dash, width, font, text, props, comment, + taglist, cblist); + } + else if (STRCMP(shape, "boxannulus", 10)) { + + int num = xmlCount(rv); + createBoxAnnulusCmd(xmlPoint(ptr, x, y, sys, sky, format), + num, xmlDistance(ptr, rv, rv2, num, rvsys, rvdist), + xmlAngle(ang, angsign, angoffset, angformat, + sys, sky), + color, dash, width, font, text, props, comment, + taglist, cblist); + } + + // Panda Regions + else if (STRCMP(shape, "panda", 5) || STRCMP(shape, "pie", 3)) { + int anum = xmlCount(angv); + int rnum = xmlCount(rv); + createCpandaCmd(xmlPoint(ptr, x, y, sys, sky, format), + anum, xmlAngles(angv, angvsign, angvoffset, + anum, angvformat, sys, sky), + rnum, xmlDistance(ptr, rv, rnum, rvsys, rvdist), + color, dash, width, font, text, props, comment, + taglist, cblist); + } + else if (STRCMP(shape, "epanda", 6)) { + int anum = xmlCount(angv); + int rnum = xmlCount(rv); + createEpandaCmd(xmlPoint(ptr, x, y, sys, sky, format), + anum, xmlAngles(angv, angvsign, angoffset, + anum, angvformat, sys, sky), + rnum, xmlDistance(ptr, rv, rv2, rnum, rvsys, rvdist), + xmlAngle(ang, angsign, angoffset, angformat, + sys, sky), + color, dash, width, font, text, props, comment, + taglist, cblist); + } + else if (STRCMP(shape, "bpanda", 6)) { + int anum = xmlCount(angv); + int rnum = xmlCount(rv); + createBpandaCmd(xmlPoint(ptr, x, y, sys, sky, format), + anum, xmlAngles(angv, angvsign, angvoffset, + anum, angvformat, sys, sky), + rnum, xmlDistance(ptr, rv, rv2, rnum, rvsys, rvdist), + xmlAngle(ang, angsign, angoffset, angformat, + sys, sky), + color, dash, width, font, text, props, comment, + taglist, cblist); + } +} + +void Base::xmlSetProps(unsigned short* props, unsigned short prop, + char* str) +{ + if (atoi(str)) + *props |= prop; + else + *props &= ~prop; +} + +int Base::xmlCount(const char* col) +{ + int cnt=0; + + char* cc = dupstr(col); + char* tok = strtok(cc, " "); + while (tok) { + cnt++; + tok = strtok(NULL, " "); + } + delete [] cc; + + return cnt; +} + +Vector Base::xmlPoint(FitsImage* ptr, const char* xstr, const char* ystr, + Coord::CoordSystem sys, Coord::SkyFrame sky, Coord::SkyFormat format, + int which) +{ + if (!xstr || !ystr) + return Vector(); + + char* x =NULL; + char* y =NULL; + char* xcc =NULL; + char* ycc =NULL; + if (which>0) { + xcc = dupstr(xstr); + x = strtok(xcc, " "); + for (int ii=0; iimapToRef(Vector(atof(x),atof(y)), sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + rr = ptr->mapToRef(Vector(atof(x),atof(y)), sys, sky); + break; + case Coord::SEXAGESIMAL: + { + double xx=parseSEXStr(x); + double yy=parseSEXStr(y); + + switch (sky) { + case Coord::FK4: + case Coord::FK4_NO_E: + case Coord::FK5: + case Coord::ICRS: + xx = xx/24.*360.; + break; + case Coord::GALACTIC: + case Coord::SUPERGALACTIC: + case Coord::ECLIPTIC: + case Coord::HELIOECLIPTIC: + break; + } + rr = ptr->mapToRef(Vector(xx,yy), sys, sky); + } + } + } + else + rr = ptr->mapToRef(Vector(atof(x),atof(y)), sys); + } + + if (which>0) { + if (xcc) + delete [] xcc; + if (ycc) + delete [] ycc; + } + + return rr; +} + +List* Base::xmlVertex(FitsImage* ptr, + const char* x, const char* y, + Coord::CoordSystem sys, Coord::SkyFrame sky, Coord::SkyFormat format) +{ + List* list = new List; + + int cnt= xmlCount(x); + for (int ii=0; iiappend(n); + } + + return list; +} + +double* Base::xmlDistance(FitsImage* ptr, const char* r, int cnt, + Coord::CoordSystem sys, Coord::SkyDist dist) +{ + double* rr = new double[cnt]; + + char* cc = dupstr(r); + char* tok = strtok(cc, " "); + for (int ii=0; iimapLenToRef(rr[ii], sys, dist); + + return rr; +} + +Vector* Base::xmlDistance(FitsImage* ptr, const char* r, const char* r2, + int cnt, Coord::CoordSystem sys, Coord::SkyDist dist) +{ + Vector* vv = new Vector[cnt]; + + { + char* cc = dupstr(r); + char* tok = strtok(cc, " "); + for (int ii=0; iimapLenToRef(vv[ii], sys, dist); + + return vv; +} + +double Base::xmlAngle(const char* angle, int sign, double offset, + Coord::AngleFormat format, Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + switch (format) { + case Coord::DEG: + return mapAngleToRef(sign*degToRad(atof(angle))+offset, sys, sky); + case Coord::RAD: + return mapAngleToRef(sign*atof(angle)+offset, sys, sky); + } +} + +double* Base::xmlAngles(const char* angle, int sign, double offset, int cnt, + Coord::AngleFormat format, Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + double* ang = new double[cnt]; + + char* cc = dupstr(angle); + char* tok = strtok(cc, " "); + for (int ii=0; ii" << endl + << "" << endl + << "" << endl + << "" << endl + << "" << endl + << "" << endl + << "" << endl + << "" << endl + << "DS9 version 4.1" << endl; + + str << "" << endl; + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + break; + + default: + if (keyContext->fits->hasWCS(sys)) { + if (keyContext->fits->hasWCSCel(sys)) { + // determine ucd + char* xucd=NULL; + char* yucd=NULL; + switch (sky) { + case Coord::FK4: + case Coord::FK4_NO_E: + case Coord::FK5: + case Coord::ICRS: + xucd = dupstr("pos.eq.ra;meta.main"); + yucd = dupstr("pos.eq.dec;meta.main"); + break; + case Coord::GALACTIC: + case Coord::SUPERGALACTIC: + xucd = dupstr("pos.galactic.lon;meta.main"); + yucd = dupstr("pos.galactic.lat;meta.main"); + break; + case Coord::ECLIPTIC: + case Coord::HELIOECLIPTIC: + xucd = dupstr("pos.ecliptic.lon;meta.main"); + yucd = dupstr("pos.ecliptic.lat;meta.main"); + break; + } + + switch (format) { + case Coord::DEGREES: + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + break; + case Coord::SEXAGESIMAL: + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + break; + } + + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + } + else { + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + } + } + } + + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + str << "" << endl; + + str << "" << endl + << "" << endl; +} + +void Base::markerListXMLFooter(ostream& str) +{ + str << "" << endl + << "" << endl + << "
" << endl + << "
" << endl + << "
" << endl; +} + diff --git a/tksao/frame/frsave.C b/tksao/frame/frsave.C new file mode 100644 index 0000000..87a8e97 --- /dev/null +++ b/tksao/frame/frsave.C @@ -0,0 +1,571 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "context.h" +#include "framebase.h" +#include "framergb.h" +#include "fitsimage.h" +#include "outfile.h" +#include "outchannel.h" +#include "outsocket.h" +#include "sigbus.h" + +void Base::saveFits(OutFitsStream& str) +{ + FitsImage* ptr = currentContext->fits; + if (!ptr) + return; + + int dd = currentContext->naxis(2); + if (!ptr->isIIS()) { + ptr->saveFitsHeader(str,dd); + size_t cnt =0; + FitsImage* sptr = ptr; + while (sptr) { + cnt += sptr->saveFits(str); + sptr = sptr->nextSlice(); + } + ptr->saveFitsPad(str,cnt,'\0'); + } + else { + ptr->saveFitsIISHeader(str); + size_t cnt = ptr->saveFitsIIS(str); + ptr->saveFitsPad(str,cnt,'\0'); + } +} + +void Base::saveFitsTable(OutFitsStream& str) +{ + FitsImage* ptr = currentContext->fits; + if (ptr) { + if (ptr->isTable()) + ptr->saveFitsTable(str); + else { + Tcl_AppendResult(interp, " not a fits table", NULL); + result = TCL_ERROR; + } + } +} + +void Base::saveFitsSlice(OutFitsStream& str) +{ + FitsImage* ptr = currentContext->cfits; + if (!ptr) + return; + + ptr->saveFitsHeader(str,0); + size_t cnt = ptr->saveFits(str); + ptr->saveFitsPad(str,cnt,'\0'); +} + +void Base::saveFitsExtCube(OutFitsStream& str) +{ + FitsImage* ptr = currentContext->fits; + if (!ptr) + return; + + ptr->saveFitsPrimHeader(str); + while (ptr) { + ptr->saveFitsXtHeader(str, 0); + size_t cnt = ptr->saveFits(str); + ptr->saveFitsPad(str,cnt,'\0'); + ptr = ptr->nextSlice(); + } +} + +void Base::saveFitsMosaic(OutFitsStream& str, int which) +{ + FitsImage* ptr = currentContext->fits; + int dd = currentContext->naxis(2); + + // which 1 to n + which--; + while (ptr && which) { + ptr = ptr->nextMosaic(); + which--; + } + + if (!ptr) + return; + + ptr->saveFitsHeader(str,dd); + size_t cnt =0; + FitsImage* sptr = ptr; + while (sptr) { + cnt += sptr->saveFits(str); + sptr = sptr->nextSlice(); + } + ptr->saveFitsPad(str,cnt,'\0'); +} + +void Base::saveFitsMosaicImage(OutFitsStream& str) +{ + FitsImage* ptr = currentContext->fits; + if (!ptr) + return; + + int dd = currentContext->naxis(2); + ptr->saveFitsPrimHeader(str); + while (ptr) { + ptr->saveFitsXtHeader(str,dd); + size_t cnt =0; + FitsImage* sptr = ptr; + while (sptr) { + cnt += sptr->saveFits(str); + sptr = sptr->nextSlice(); + } + ptr->saveFitsPad(str,cnt,'\0'); + ptr = ptr->nextMosaic(); + } +} + +void FrameRGB::saveFitsRGBImage(OutFitsStream& str) +{ + FitsImage* ptr = keyContext->fits; + if (!ptr) + return; + + // fake primary header + ptr->saveFitsPrimHeader(str); + for (int ii=0; ii<3; ii++) { + if (context[ii].fits) { + context[ii].fits->saveFitsXtHeader(str,0); + size_t cnt = context[ii].fits->saveFits(str); + context[ii].fits->saveFitsPad(str,cnt,'\0'); + } + } +} + +void FrameRGB::saveFitsRGBCube(OutFitsStream& str) +{ + FitsImage* ptr = keyContext->fits; + if (!ptr) + return; + + int ss =0; + for (int ii=0; ii<3; ii++) + if (context[ii].fits) + ss++; + ptr->saveFitsHeader(str,ss); + + size_t cnt =0; + for (int ii=0; ii<3; ii++) + if (context[ii].fits) + cnt += context[ii].fits->saveFits(str); + + ptr->saveFitsPad(str,cnt,'\0'); +} + +void Base::saveArray(OutFitsStream& str, FitsFile::ArchType endian) +{ + FitsImage* ptr = currentContext->fits; + if (!ptr) + return; + + // set endian if needed + if (endian == FitsFile::NATIVE) { + if (lsb()) + endian = FitsFile::LITTLE; + else + endian = FitsFile::BIG; + } + + // dump each slice + while (ptr) { + ptr->saveArray(str,endian); + ptr = ptr->nextSlice(); + } +} + +void FrameRGB::saveArrayRGBCube(OutFitsStream& str, FitsFile::ArchType endian) +{ + FitsImage* ptr = keyContext->fits; + if (!ptr) + return; + + // set endian if needed + if (endian == FitsFile::NATIVE) { + if (lsb()) + endian = FitsFile::LITTLE; + else + endian = FitsFile::BIG; + } + + for (int ii=0; ii<3; ii++) + if (context[ii].fits) + context[ii].fits->saveArray(str,endian); +} + +void Base::saveNRRD(OutFitsStream& str, FitsFile::ArchType endian) +{ + FitsImage* ptr = currentContext->fits; + if (!ptr) + return; + + // set endian if needed + if (endian == FitsFile::NATIVE) { + if (lsb()) + endian = FitsFile::LITTLE; + else + endian = FitsFile::BIG; + } + + // dump header + ostringstream hstr; + hstr << "NRRD0002" << endl; + if (currentContext->naxis(2)>1) { + hstr << "dimension: 3" << endl; + hstr << "sizes: " << ptr->naxis(0) << ' ' << ptr->naxis(1) << ' ' + << currentContext->naxis(2) << endl; + } + else { + hstr << "dimension: 2" << endl; + hstr << "sizes: " << ptr->naxis(0) << ' ' << ptr->naxis(1) << endl; + } + switch (ptr->bitpix()) { + case 8: + hstr << "type: char" << endl; + break; + case 16: + hstr << "type: short" << endl; + break; + case 32: + hstr << "type: int" << endl; + break; + case 64: + hstr << "type: longlong" << endl; + break; + case -32: + hstr << "type: float" << endl; + break; + case -64: + hstr << "type: double" << endl; + break; + } + if (abs(ptr->bitpix()) > 8) { + switch (endian) { + case FitsFile::LITTLE: + hstr << "endian: little" << endl; + break; + case FitsFile::BIG: + hstr << "endian: big" << endl; + break; + default: + // na + break; + } + } + hstr << "encoding: raw" << endl; + // very important + hstr << endl << ends; + + str.write((char*)hstr.str().c_str(),hstr.str().length()); + + // now dump each slice + while (ptr) { + ptr->saveArray(str,endian); + ptr = ptr->nextSlice(); + } +} + +void Base::saveENVI(ostream& hstr, OutFitsStream& fstr, + FitsFile::ArchType endian) +{ + FitsImage* ptr = currentContext->fits; + if (!ptr) + return; + + // set endian if needed + if (endian == FitsFile::NATIVE) { + if (lsb()) + endian = FitsFile::LITTLE; + else + endian = FitsFile::BIG; + } + + // header + hstr << "ENVI" << endl; + hstr << "description = {}" << endl; + hstr << "samples = " << ptr->naxis(0) << endl; + hstr << "lines = " << ptr->naxis(1) << endl; + if (currentContext->naxis(2)>1) { + hstr << "bands = " << currentContext->naxis(2) << endl; + } + hstr << "header offset = 0" << endl; + hstr << "file type = ENVI Standard" << endl; + hstr << "data type = "; + switch (ptr->bitpix()) { + case 8: + hstr << "1" << endl; + break; + case 16: + hstr << "2" << endl; + break; + case -16: + hstr << "12" << endl; + break; + case 32: + hstr << "3" << endl; + break; + case 64: + hstr << "14" << endl; + break; + case -32: + hstr << "4" << endl; + break; + case -64: + hstr << "5" << endl; + break; + } + hstr << "interleave = bsq" << endl; + hstr << "byte order = "; + switch (endian) { + case FitsFile::LITTLE: + hstr << "0" << endl; + break; + case FitsFile::BIG: + hstr << "1" << endl; + break; + default: + // na + break; + } + + // now dump each slice + while (ptr) { + ptr->saveArray(fstr,endian); + ptr = ptr->nextSlice(); + } +} + +void FrameBase::saveFitsResample(OutFitsStream& str) +{ + int& width = options->width; + int& height = options->height; + + int bitpix_ = -32; + int datapixels_ = width*height; + int realbytes_ = datapixels_ * (abs(bitpix_)/8); + int datablocks_ = (realbytes_ + (FTY_BLOCK-1))/FTY_BLOCK; + int databytes_ = datablocks_ * FTY_BLOCK; + + // create header + FitsHead hd(width, height, 1, bitpix_); + + // write keywords + saveFitsResampleKeyword(str, hd); + + // write header + str.write(hd.cards(), hd.headbytes()); + + // write data + saveFitsResampleFits(str); + + // pad rest of block + { + int diff = databytes_ - realbytes_; + char buf[diff]; + memset(buf,'\0',diff); + str.write(buf, diff); + } +} + +void FrameBase::saveFitsResampleKeyword(OutFitsStream& str, FitsHead& dst) +{ + FitsHead* src = currentContext->fits->head(); + Vector center = Vector(options->width, options->height)/2.; + + // OBJECT + char* object = src->getString("OBJECT"); + if (object) { + dst.appendString("OBJECT", object, NULL); + delete [] object; + } + + // DATE-OBS + char* date = src->getString("DATE"); + if (date) { + dst.appendString("DATE", date, NULL); + delete [] date; + } + char* dateobs = src->getString("DATE-OBS"); + if (dateobs) { + dst.appendString("DATE-OBS", dateobs, NULL); + delete [] dateobs; + } + char* timeobs = src->getString("TIME-OBS"); + if (timeobs) { + dst.appendString("TIME-OBS", timeobs, NULL); + delete [] timeobs; + } + char* dateend = src->getString("DATE-END"); + if (dateend) { + dst.appendString("DATE-END", dateend, NULL); + delete [] dateend; + } + char* timeend = src->getString("TIME-END"); + if (timeend) { + dst.appendString("TIME-END", timeend, NULL); + delete [] timeend; + } + + // LTMV,DTMV + if (!isMosaic()) { + if (currentContext->fits->hasLTMV()) { + Matrix ltmv = currentContext->fits->physicalToRef * refToWidget * + Translate(-center) * + Translate(1,0) * + FlipY() * + Translate(center); + + dst.appendReal("LTM1_1", ltmv[0][0], 9, NULL); + dst.appendReal("LTM1_2", ltmv[0][1], 9, NULL); + dst.appendReal("LTM2_1", ltmv[1][0], 9, NULL); + dst.appendReal("LTM2_2", ltmv[1][1], 9, NULL); + dst.appendReal("LTV1", ltmv[2][0], 9, NULL); + dst.appendReal("LTV2", ltmv[2][1], 9, NULL); + } + } + else { + if (currentContext->fits->hasDTMV()) { + Matrix dtmv = currentContext->fits->detectorToRef * refToWidget * + Translate(-center) * + Translate(1,0) * + FlipY() * + Translate(center); + + dst.appendReal("DTM1_1", dtmv[0][0], 9, NULL); + dst.appendReal("DTM1_2", dtmv[0][1], 9, NULL); + dst.appendReal("DTM2_1", dtmv[1][0], 9, NULL); + dst.appendReal("DTM2_2", dtmv[1][1], 9, NULL); + dst.appendReal("DTV1", dtmv[2][0], 9, NULL); + dst.appendReal("DTV2", dtmv[2][1], 9, NULL); + } + } + + // WCS + if (currentContext->fits->hasWCS(Coord::WCS)) { + WorldCoor* wcs = currentContext->fits->getWCS(Coord::WCS); + + // abort if this is a DSS, ZPN, TNX + if (!strncmp(wcs->ptype,"DSS",3) || + !strncmp(wcs->ptype,"ZPN",3) || + !strncmp(wcs->ptype,"TNX",3)) + return; + + dst.appendString("RADESYS", wcs->radecsys, NULL); + dst.appendReal("EQUINOX", wcs->equinox, 9, NULL); + + dst.appendString("CTYPE1", wcs->ctype[0], NULL); + dst.appendString("CTYPE2", wcs->ctype[1], NULL); + dst.appendReal("CRVAL1", wcs->crval[0], 9, NULL); + dst.appendReal("CRVAL2", wcs->crval[1], 9, NULL); + + char* cunit1 = src->getString("CUNIT1"); + if (cunit1) { + dst.appendString("CUNIT1", cunit1, NULL); + delete [] cunit1; + } + + char* cunit2 = src->getString("CUNIT2"); + if (cunit2) { + dst.appendString("CUNIT2", cunit2, NULL); + delete [] cunit2; + } + + // crpix + Vector crpix = Vector(wcs->crpix[0],wcs->crpix[1]) * + currentContext->fits->imageToWidget * + Translate(-center) * + Translate(1,0) * + FlipY() * + Translate(center); + + dst.appendReal("CRPIX1", crpix[0], 9, NULL); + dst.appendReal("CRPIX2", crpix[1], 9, NULL); + + // cd matrix + Matrix cd = Matrix(wcs->cd[0],wcs->cd[1],wcs->cd[2],wcs->cd[3],0,0) * + currentContext->fits->imageToRef * refToUser * + wcsOrientationMatrix * + Rotate(wcsRotation) * + orientationMatrix * + Scale(zoom_.invert()) * + Rotate(rotation) * + Translate(center) * + Translate(-center) * + Translate(1,0) * + FlipY() * + Translate(center); + + dst.appendReal("CD1_1", cd.matrix(0,0), 9, NULL); + dst.appendReal("CD1_2", cd.matrix(0,1), 9, NULL); + dst.appendReal("CD2_1", cd.matrix(1,0), 9, NULL); + dst.appendReal("CD2_2", cd.matrix(1,1), 9, NULL); + } +} + +void FrameBase::saveFitsResampleFits(OutFitsStream& str) +{ + int& width = options->width; + int& height = options->height; + + // basics + FitsImage* sptr = currentContext->fits; + int mosaic = isMosaic(); + + // variable + double* mm = sptr->matrixToData(Coord::WIDGET).mm(); + FitsBound* params = sptr->getDataParams(currentContext->secMode()); + int srcw = sptr->width(); + + // main loop + + SETSIGBUS + for (int jj=height-1; jj>=0; jj--) { + for (int ii=0; iifits; + + mm = sptr->matrixToData(Coord::WIDGET).mm(); + params = sptr->getDataParams(currentContext->secMode()); + srcw = sptr->width(); + } + + float v = NAN; + + do { + double xx = ii*mm[0] + jj*mm[3] + mm[6]; + double yy = ii*mm[1] + jj*mm[4] + mm[7]; + + if (xx>=params->xmin && xxxmax && + yy>=params->ymin && yyymax) { + + v = sptr->getValueFloat(long(yy)*srcw + long(xx)); + + break; + } + else { + if (mosaic) { + sptr = sptr->nextMosaic(); + + if (sptr) { + mm = sptr->matrixToData(Coord::WIDGET).mm(); + params = sptr->getDataParams(currentContext->secMode()); + srcw = sptr->width(); + } + } + } + } + while (mosaic && sptr); + + if (lsb()) + str.writeSwap((char*)(&v), 4, -32); + else + str.write((char*)(&v), 4); + } + } + CLEARSIGBUS +} diff --git a/tksao/frame/frscale.C b/tksao/frame/frscale.C new file mode 100644 index 0000000..19b98d9 --- /dev/null +++ b/tksao/frame/frscale.C @@ -0,0 +1,310 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "frscale.h" +#include "fitsimage.h" + +FrScale::FrScale() +{ + colorScaleType_ = LINEARSCALE; + clipScope_ = LOCAL; + clipMode_ = MINMAX; + minmaxMode_ = SCAN; + low_ = 1; + high_ = 100; + min_ = 1; + max_ = 100; + ulow_ = 1; + uhigh_ = 100; + expo_ = 1000; + zContrast_ = .25; + zSample_ = 600; + zLine_ = 120; + minmaxSample_ = 25; + autoCutPer_ = 100; + secMode_ = IMGSEC; + + histequ_ = NULL; + histequSize_ = 0; + + histogramX_ = NULL; + histogramY_ = NULL; + histogramSize_ = 0; + + datasec_ = 1; +} + +FrScale::~FrScale() +{ + if (histequ_) + delete [] histequ_; + + if (histogramX_) + free(histogramX_); + + if (histogramY_) + free(histogramY_); +} + +FrScale::FrScale(const FrScale& a) +{ + colorScaleType_ = a.colorScaleType_; + clipScope_ = a.clipScope_; + clipMode_ = a.clipMode_; + minmaxMode_ = a.minmaxMode_; + low_ = a.low_; + high_ = a.high_; + min_ = a.min_; + max_ = a.max_; + ulow_ = a.ulow_; + uhigh_ = a.uhigh_; + expo_ = a.expo_; + zContrast_ = a.zContrast_; + zSample_ = a.zSample_; + zLine_ = a.zLine_; + minmaxSample_ = a.minmaxSample_; + autoCutPer_ = a.autoCutPer_; + secMode_ = a.secMode_; + + if (a.histequ_) { + histequ_ = new double[a.histequSize_]; + memcpy(histequ_,a.histequ_,a.histequSize_*sizeof(double)); + } + else + histequ_ = NULL; + histequSize_ = a.histequSize_; + + if (a.histogramX_) { + histogramX_ = (double*)calloc(a.histogramSize_, sizeof(double)); + memcpy(histogramX_,a.histogramX_,a.histogramSize_*sizeof(double)); + } + else + histogramX_ = NULL; + if (a.histogramY_) { + histogramY_ = (double*)calloc(a.histogramSize_, sizeof(double)); + memcpy(histogramY_,a.histogramY_,a.histogramSize_*sizeof(double)); + } + else + histogramY_ = NULL; + histogramSize_ = a.histogramSize_; +} + +FrScale& FrScale::operator=(const FrScale& a) +{ + colorScaleType_ = a.colorScaleType_; + clipScope_ = a.clipScope_; + clipMode_ = a.clipMode_; + minmaxMode_ = a.minmaxMode_; + low_ = a.low_; + high_ = a.high_; + min_ = a.min_; + max_ = a.max_; + ulow_ = a.ulow_; + uhigh_ = a.uhigh_; + expo_ = a.expo_; + zContrast_ = a.zContrast_; + zSample_ = a.zSample_; + zLine_ = a.zLine_; + minmaxSample_ = a.minmaxSample_; + autoCutPer_ = a.autoCutPer_; + secMode_ = a.secMode_; + + if (histequ_) + delete histequ_; + histequ_ = NULL; + + if (a.histequ_) { + histequ_ = new double[a.histequSize_]; + memcpy(histequ_,a.histequ_,a.histequSize_*sizeof(double)); + } + histequSize_ = a.histequSize_; + + if (histogramX_) + free(histogramX_); + histogramX_ = NULL; + if (a.histogramX_) { + histogramX_ = (double*)calloc(a.histogramSize_, sizeof(double)); + memcpy(histogramX_,a.histogramX_,a.histogramSize_*sizeof(double)); + } + + if (histogramY_) + free(histogramY_); + histogramY_ = NULL; + if (a.histogramY_) { + histogramY_ = (double*)calloc(a.histogramSize_, sizeof(double)); + memcpy(histogramY_,a.histogramY_,a.histogramSize_*sizeof(double)); + } + histogramSize_ = a.histogramSize_; + + return *this; +} + +double* FrScale::histequ(FitsImage* fits) +{ + if (DebugPerf) + cerr << "FrScale::histequ()" << endl; + + // if we don't have any data, bail + if (!fits) + return NULL; + + // if we already have it, bail + if (histequ_) + return histequ_; + + // create pdf or histogram + double* pdf = new double[HISTEQUSIZE]; + memset(pdf,0,HISTEQUSIZE*sizeof(double)); + + switch (clipScope_) { + case GLOBAL: + { + FitsImage* ptr = fits; + while (ptr) { + FitsImage* sptr = ptr; + while (sptr) { + sptr->hist(pdf, HISTEQUSIZE, low_, high_, secMode_); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + } + break; + case LOCAL: + { + FitsImage* ptr = fits; + while (ptr) { + ptr->hist(pdf, HISTEQUSIZE, low_, high_, secMode_); + ptr = ptr->nextMosaic(); + } + } + break; + } + + // find a total/average + double total, average; + { + total = 0; + for (int ii=0; ii=average && color0) { + for (int ii=0; iihist(histogramY_, nn, min_, max_, secMode_); + sptr = sptr->nextSlice(); + } + ptr = ptr->nextMosaic(); + } + } + break; + case LOCAL: + { + FitsImage* ptr = fits; + while (ptr) { + ptr->hist(histogramY_, nn, min_, max_, secMode_); + ptr = ptr->nextMosaic(); + } + } + break; + } +} + +void FrScale::clearHistogram() +{ + if (DebugPerf) + cerr << "FrScale::clearHistogram" << endl; + + if (histogramX_) + free(histogramX_); + histogramX_ = NULL; + + if (histogramY_) + free(histogramY_); + histogramY_ = NULL; + + histogramSize_ = 0; +} + +ostream& operator<<(ostream& s, FrScale& fr) +{ + s << "scope: " << fr.clipScope() << endl; + s << "mode: " << fr.clipMode() << endl; + s << "low: " << fr.low() << endl; + s << "high: " << fr.high() << endl; + s << "min: " << fr.min() << endl; + s << "max: " << fr.max() << endl; + + return s; +} + diff --git a/tksao/frame/frscale.h b/tksao/frame/frscale.h new file mode 100644 index 0000000..4c82539 --- /dev/null +++ b/tksao/frame/frscale.h @@ -0,0 +1,118 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __frscale_h__ +#define __frscale_h__ + +#include +#include + +#include +using namespace std; + +#include "vector.h" + +class FitsImage; + +class FrScale { + public: + enum ColorScaleType {LINEARSCALE, + LOGSCALE, POWSCALE, + SQRTSCALE, SQUAREDSCALE, + ASINHSCALE, SINHSCALE, + HISTEQUSCALE, IISSCALE}; + enum ClipScope {GLOBAL, LOCAL}; + enum ClipMode {MINMAX, ZSCALE, ZMAX, AUTOCUT, USERCLIP}; + enum MinMaxMode {SCAN, SAMPLE, DATAMIN, IRAFMIN}; + enum SecMode {IMGSEC, DATASEC, CROPSEC}; + + private: + ColorScaleType colorScaleType_; // color scale type + ClipScope clipScope_; // color scale clip scope + ClipMode clipMode_; // color scale clip mode + MinMaxMode minmaxMode_; // method to use for determining minmax + double low_; // low cut level for all data + double high_; // high cut level for all data + double min_; // min for all data + Vector minXY_; + double max_; // max for all data + Vector maxXY_; + double ulow_; // low cut via user for all data + double uhigh_; // high cut via user for all data + float expo_; // log scale exponent + float zContrast_; // zscale slope transfer function + int zSample_; // zscale optimal sample size + int zLine_; // zscale number of lines to sample + int minmaxSample_; // minmax sampling incr + float autoCutPer_; // autoCut percentage + SecMode secMode_; // use keyword DATASEC + + double* histequ_; // image histogram equalization xfer function + int histequSize_; + + double* histogramX_; // scale histogram + double* histogramY_; // scale histogram + int histogramSize_; + + int datasec_; + + public: + FrScale(); + ~FrScale(); + FrScale(const FrScale&); + FrScale& operator=(const FrScale&); + + ColorScaleType colorScaleType() {return colorScaleType_;} + ClipScope clipScope() {return clipScope_;} + ClipMode clipMode() {return clipMode_;} + MinMaxMode minmaxMode() {return minmaxMode_;} + double low() {return low_;} + double high() {return high_;} + double min() {return min_;} + const Vector& minXY() {return minXY_;} + double max() {return max_;} + const Vector& maxXY() {return maxXY_;} + double ulow() {return ulow_;} + double uhigh() {return uhigh_;} + float expo() {return expo_;} + float zContrast() {return zContrast_;} + int zSample() {return zSample_;} + int zLine() {return zLine_;} + int minmaxSample() {return minmaxSample_;} + float autoCutPer() {return autoCutPer_;} + SecMode secMode() {return secMode_;} + double* histogramX() {return histogramX_;} + double* histogramY() {return histogramY_;} + int datasec() {return datasec_;} + + void setColorScaleType(ColorScaleType v) {colorScaleType_ = v;} + void setClipScope(ClipScope v) {clipScope_ = v;} + void setClipMode(ClipMode v) {clipMode_ = v;} + void setMinMaxMode(MinMaxMode v) {minmaxMode_ = v;} + void setLow(double v) {low_ = v;} + void setHigh(double v) {high_ = v;} + void setMin(double mm, const Vector& vv) {min_ = mm; minXY_ = vv;} + void setMax(double mm, const Vector& vv) {max_ = mm; maxXY_ = vv;} + void setULow(double v) {ulow_ = v;} + void setUHigh(double v) {uhigh_ = v;} + void setExpo(float e) {expo_ = e>10 ? e : 10;} + void setZContrast(float v) {zContrast_ = v;} + void setZSample(int v) {zSample_ = v;} + void setZLine(int v) {zLine_ = v;} + void setMinMaxSample(int v) {minmaxSample_ = v;} + void setAutoCutPer(float v) {autoCutPer_ = v;} + + void setSecMode(SecMode v) {secMode_ = v;} + void resetSecMode() {secMode_ = datasec_ ? DATASEC : IMGSEC;} + void setDataSec(int d) {datasec_ = d;} + + double* histequ(FitsImage*); + void clearHistequ(); + void histogram(FitsImage*, int); + void clearHistogram(); +}; + +ostream& operator<<(ostream&, FrScale&); + +#endif diff --git a/tksao/frame/fvcontour.C b/tksao/frame/fvcontour.C new file mode 100644 index 0000000..8b049dc --- /dev/null +++ b/tksao/frame/fvcontour.C @@ -0,0 +1,575 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "context.h" +#include "base.h" +#include "fitsimage.h" +#include "fvcontour.h" + +#include "sigbus.h" + +#ifdef INTERP +#undef INTERP +#endif +#define INTERP (((Base*)parent_)->interp) + +static const char* methodName_[] = { + "smooth", + "block" + }; + +// It is a modified version of contour code found in Fv 2.4 +// Fv may be obtained from the HEASARC (High Energy Astrophysics Science +// Archive Research Center) FTOOLS Web site at: +// http://heasarc.gsfc.nasa.gov/ftools/fv.html + +// The original author is unknown. + +FVContour::FVContour() +{ + parent_ =NULL; + + colorName_ = dupstr("green"); + lineWidth_ =1; + dash_ =0; + dlist_[0] =8; + dlist_[1] =3; + + method_ = BLOCK; + smooth_ =4; + numLevel_ =5; + + colorScaleType_ = FrScale::LINEARSCALE; + clipMode_ = (float)FrScale::MINMAX; + expo_ =1000; + limits_ = Vector(0,100); + + level_ =NULL; + scale_ =NULL; +} + +FVContour::~FVContour() +{ + if (colorName_) + delete [] colorName_; + + if (level_) + delete [] level_; + + if (scale_) + delete scale_; +} + +void FVContour::create(Base* pp, FitsImage* fits, FrScale* fr, + const char* cc, int ww, int dd, + Method mm, int nn, int rr, + const char* ll, + FrScale::ColorScaleType sc, float exp, + float cm, Vector lim) +{ + lcontourlevel_.deleteAll(); + + parent_ = pp; + + colorName_ = dupstr(cc); + lineWidth_ = ww; + dash_ = dd; + + method_ = mm; + smooth_ = rr; + numLevel_ = nn; + + colorScaleType_ = sc; + clipMode_ = cm; + expo_ = exp; + limits_ = lim; + + level_ = dupstr(ll); + + if (level_ && strlen(level_)>0) { + int cnt = 0; + double levels[100]; + string x(level_); + istringstream str(x); + + while ((cnt<100) && (str >> levels[cnt])) + cnt++; + + scale_ = new InverseScale(cnt, levels); + } + else + buildScale(fits, fr); + + append(fits); +} + +void FVContour::buildScale(FitsImage* fits, FrScale* fr) +{ + switch (colorScaleType_) { + case FrScale::LINEARSCALE: + scale_ = new LinearInverseScale(numLevel_, limits_[0], limits_[1]); + break; + case FrScale::LOGSCALE: + scale_ = new LogInverseScale(numLevel_, limits_[0], limits_[1], expo_); + break; + case FrScale::POWSCALE: + scale_ = new PowInverseScale(numLevel_, limits_[0], limits_[1], expo_); + break; + case FrScale::SQRTSCALE: + scale_ = new SqrtInverseScale(numLevel_, limits_[0], limits_[1]); + break; + case FrScale::SQUAREDSCALE: + scale_ = new SquaredInverseScale(numLevel_, limits_[0], limits_[1]); + break; + case FrScale::ASINHSCALE: + scale_ = new AsinhInverseScale(numLevel_, limits_[0], limits_[1]); + break; + case FrScale::SINHSCALE: + scale_ = new SinhInverseScale(numLevel_, limits_[0], limits_[1]); + break; + case FrScale::HISTEQUSCALE: + scale_ = new HistEquInverseScale(numLevel_, limits_[0], limits_[1], + fr->histequ(fits), HISTEQUSIZE); + break; + case FrScale::IISSCALE: + scale_ = new IISInverseScale(numLevel_, limits_[0], limits_[1], + fits->iisz()); + break; + } +} + +void FVContour::update(FitsImage* fits) +{ + if (lcontourlevel_.isEmpty()) + return; + + lcontourlevel_.deleteAll(); + append(fits); +} + +void FVContour::update(FitsImage* fits, FrScale* fr) +{ + if (lcontourlevel_.isEmpty()) + return; + + lcontourlevel_.deleteAll(); + + if (scale_) + delete scale_; + limits_ = Vector(fr->low(),fr->high()); + expo_ = fr->expo(); + + buildScale(fits, fr); + + if (level_) + delete [] level_; + ostringstream str; + str << *scale_ << ends; + level_ = dupstr(str.str().c_str()); + + append(fits); +} + +const char* FVContour::methodName() +{ + return methodName_[method_]; +} + +void FVContour::append(FitsImage* fits) +{ + if (smooth_ == 1) + unity(fits); + else + switch (method_) { + case SMOOTH: + nobin(fits); + break; + case BLOCK: + bin(fits); + break; + } +} + +void FVContour::unity(FitsImage* fits) +{ + FitsBound* params = + fits->getDataParams(((Base*)parent_)->currentContext->secMode()); + long width = fits->width(); + long height = fits->height(); + + // blank img + long size = width*height; + double* img = new double[size]; + if (!img) { + internalError("FVContour could not allocate enough memory"); + return; + } + for (long ii=0; iiymin; jjymax; jj++) { + for(long ii=params->xmin; iixmax; ii++) { + long kk = jj*width + ii; + + double vv = fits->getValueDouble(kk); + if (isfinite(vv)) + img[kk] = vv; + } + } + CLEARSIGBUS + + // do contours + build(width, height, img, fits->dataToRef); + + // clean up + delete [] img; +} + +void FVContour::nobin(FitsImage* fits) +{ + long width = fits->width(); + long height = fits->height(); + + // blank img + long size = width*height; + double* img = new double[size]; + if (!img) { + internalError("FVContour could not allocate enough memory"); + return; + } + for (long ii=0; iidataToRef); + + // cleanup + delete kernal; + delete [] img; +} + +void FVContour::convolve(FitsImage* fits, double* kernal, double* dest, int r) +{ + FitsBound* params = + fits->getDataParams(((Base*)parent_)->currentContext->secMode()); + long width = fits->width(); + int rr = 2*r+1; + + SETSIGBUS + for (long jj=params->ymin; jjymax; jj++) { + for (long ii=params->xmin; iixmax; ii++) { + long ir = ii-r; + long irr = ii+r; + long jr = jj-r; + long jrr = jj+r; + + for (long n=jr, nn=0; n<=jrr; n++, nn++) { + if (n>=params->ymin && nymax) { + for (long m=ir, mm=0; m<=irr; m++, mm++) { + if (m>=params->xmin && mxmax) { + double vv = fits->getValueDouble(n*width+m); + if (isfinite(vv)) { + double kk = kernal[nn*rr+mm]; + double* ptr = dest+(jj*width+ii); + if (*ptr == FLT_MIN) + *ptr = vv*kk; + else + *ptr += vv*kk; + } + } + } + } + } + } + } + CLEARSIGBUS +} + +double* FVContour::tophat(int r) +{ + int rr = 2*r+1; + int ksz = rr*rr; + double* kernal = new double[ksz]; + memset(kernal, 0, ksz*sizeof(double)); + + double kt = 0; + for (int yy=-r; yy<=r; yy++) { + for (int xx=-r; xx<=r; xx++) { + if ((xx*xx + yy*yy) <= r*r) { + kernal[(yy+r)*rr+(xx+r)] = 1; + kt++; + } + } + } + + // normalize kernal + for (int aa=0; aagetDataParams(((Base*)parent_)->currentContext->secMode()); + long width = fits->width(); + long height = fits->height(); + + int rr = smooth_; + + long w2 = (long)(width/rr); + long h2 = (long)(height/rr); + + Matrix m = + Translate((Vector(-width,-height)/2).floor()) * + Scale(1./rr) * + Translate((Vector(w2,h2)/2).floor()); + Matrix n = m.invert(); + double* mm = m.mm(); + + double* img = new double[w2 * h2]; + { + for (long jj=0; jjymin; jjymax; jj++) { + for (long ii=params->xmin; iixmax; ii++) { + double xx = ii*mm[0] + jj*mm[3] + mm[6]; + double yy = ii*mm[1] + jj*mm[4] + mm[7]; + + if (xx >= 0 && xx < w2 && yy >= 0 && yy < h2) { + long kk = (long(yy)*w2 + long(xx)); + double v = fits->getValueDouble(jj*width + ii); + if (isfinite(v)) { + if (count[kk]) + img[kk] += v; + else + img[kk] = v; + + count[kk]++; + } + } + } + } + + for (long kk=0; kkdataToRef; + build(w2, h2, img, w); + + delete [] img; +} + +void FVContour::build(long xdim, long ydim, double *image, Matrix& mx) +{ + long nelem = xdim*ydim; + char* usedGrid = new char[nelem]; + double** rows = new double*[ydim]; + + for (long jj=0; jjsize(); c++) { + double cntour = scale_->level(c); + + ContourLevel* cl =new ContourLevel(parent_, cntour, colorName_, lineWidth_, + dash_, dlist_); + memset(usedGrid,0,nelem); + + // Search outer edge + long ii,jj; + + // Search top + for (jj=0, ii=0; ii=0; ii--) + if (rows[jj][ii+1]=0; jj--) + if (rows[jj+1][ii]lcontour().isEmpty()) + lcontourlevel_.append(cl); + } + + delete [] usedGrid; + delete [] rows; +} + +void FVContour::trace(long xdim, long ydim, double cntr, + long xCell, long yCell, int side, + double** rows, char* usedGrid, + Matrix& mx, ContourLevel* cl) +{ + long ii = xCell; + long jj = yCell; + int origSide = side; + + int init = 1; + int done = (ii<0 || ii>=xdim-1 || (jj<0 && jj>=ydim-1)); + + Contour* cc = new Contour(cl); + + while (!done) { + int flag = 0; + double a = rows[jj][ii]; + double b = rows[jj][ii+1]; + double c = rows[jj+1][ii+1]; + double d = rows[jj+1][ii]; + + double X, Y; + if (init) { + init = 0; + switch (side) { + case top: + X = (cntr-a) / (b-a) + ii; + Y = jj; + break; + case right: + X = ii+1; + Y = (cntr-b) / (c-b) + jj; + break; + case bottom: + X = (cntr-c) / (d-c) + ii; + Y = jj+1; + break; + case left: + X = ii; + Y = (cntr-a) / (d-a) + jj; + break; + } + + } + else { + if (side==top) + usedGrid[jj*xdim + ii] = 1; + + do { + if (++side == none) + side = top; + + switch (side) { + case top: + if (a>=cntr && cntr>b) { + flag = 1; + X = (cntr-a) / (b-a) + ii; + Y = jj; + jj--; + } + break; + case right: + if( b>=cntr && cntr>c ) { + flag = 1; + X = ii+1; + Y = (cntr-b) / (c-b) + jj; + ii++; + } + break; + case bottom: + if( c>=cntr && cntr>d ) { + flag = 1; + X = (cntr-d) / (c-d) + ii; + Y = jj+1; + jj++; + } + break; + case left: + if( d>=cntr && cntr>a ) { + flag = 1; + X = ii; + Y = (cntr-a) / (d-a) + jj; + ii--; + } + break; + } + } while (!flag); + + if (++side == none) + side = top; + if (++side == none) + side = top; + if (ii==xCell && jj==yCell && side==origSide) + done = 1; + if (ii<0 || ii>=xdim-1 || jj<0 || jj>=ydim-1) + done = 1; + } + + cc->lvertex().append(new Vertex(Vector(X+.5,Y+.5)*mx)); + } + + if (!cc->lvertex().isEmpty()) + cl->lcontour().append(cc); + else + delete cc; +} + diff --git a/tksao/frame/fvcontour.h b/tksao/frame/fvcontour.h new file mode 100644 index 0000000..c6dda5a --- /dev/null +++ b/tksao/frame/fvcontour.h @@ -0,0 +1,82 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fvcontour_h__ +#define __fvcontour_h__ + +#include "vector.h" +#include "contour.h" +#include "frscale.h" +#include "inversescale.h" + +class FVContour { + public: + enum Method {SMOOTH, BLOCK}; + + private: + enum {top, right, bottom, left, none}; + + Base* parent_; + List lcontourlevel_; + + char* colorName_; + int lineWidth_; + int dash_; + int dlist_[2]; + + Method method_; + int smooth_; + int numLevel_; + + FrScale::ColorScaleType colorScaleType_; + float expo_; + float clipMode_; + Vector limits_; + + char* level_; + InverseScale* scale_; + + void buildScale(FitsImage* fits, FrScale* fr); + void unity(FitsImage*); + void bin(FitsImage*); + void nobin(FitsImage*); + void convolve(FitsImage*, double*, double*, int); + double* tophat(int); + double* gaussian(int); + void build(long xdim, long ydim, double *image, Matrix&); + void trace(long xdim, long ydim, double cntr, + long xCell, long yCell, int side, + double** rows, char* useGrid, Matrix&, ContourLevel*); + +public: + FVContour(); + ~FVContour(); + + List& lcontourlevel() {return lcontourlevel_;} + + void create(Base*, FitsImage*, FrScale*, + const char*, int, int, Method, int, int, const char*, + FrScale::ColorScaleType, float, float, Vector); + void append(FitsImage*); + void update(FitsImage*); + void update(FitsImage*, FrScale*); + + int isEmpty() {return lcontourlevel_.isEmpty();} + + const char* methodName(); + char* level() {return level_;} + int numLevel() {return numLevel_;} + int smooth() {return smooth_;} + + int colorScaleType() {return colorScaleType_;} + float expo() {return expo_;} + float clipMode() {return clipMode_;} + Vector limits() {return limits_;} + + const char* getColorName() {return colorName_;} + int getDash() {return dash_;} + int getLineWidth() {return lineWidth_;} +}; + +#endif diff --git a/tksao/frame/grid.C b/tksao/frame/grid.C new file mode 100644 index 0000000..0e23c0d --- /dev/null +++ b/tksao/frame/grid.C @@ -0,0 +1,24 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "grid.h" +#include "context.h" +#include "fitsimage.h" + +extern "C" { + #include "ast.h" +} + +Grid::Grid(Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, GridType type, const char* v) + : type_(type), system_(sys), sky_(sky), skyFormat_(format) +{ + vars_ = dupstr(v); +} + +Grid::~Grid() +{ + if (vars_) + delete [] vars_; +} diff --git a/tksao/frame/grid.h b/tksao/frame/grid.h new file mode 100644 index 0000000..8c2c235 --- /dev/null +++ b/tksao/frame/grid.h @@ -0,0 +1,44 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __grid_h__ +#define __grid_h__ + +#include "coord.h" + +class Grid { + public: + enum GridType {ANALYSIS,PUBLICATION}; + + protected: + GridType type_; + Coord::CoordSystem system_; + Coord::SkyFrame sky_; + Coord::SkyFormat skyFormat_; + char* vars_; + + public: + Grid(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, + GridType, const char*); + virtual ~Grid(); + + virtual const char* option() =0; + + virtual void x11() =0; + virtual void ps(int) =0; +#ifdef MAC_OSX_TK + virtual void macosx() =0; +#endif +#ifdef __WIN32 + virtual void win32() =0; +#endif + + GridType type() {return type_;} + Coord::CoordSystem system() {return system_;} + Coord::SkyFrame sky() {return sky_;} + Coord::SkyFormat skyFormat() {return skyFormat_;} + const char* vars() {return vars_;} +}; + +#endif diff --git a/tksao/frame/grid25d.C b/tksao/frame/grid25d.C new file mode 100644 index 0000000..cc9da43 --- /dev/null +++ b/tksao/frame/grid25d.C @@ -0,0 +1,141 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "grid25d.h" +#include "context.h" +#include "frame3dbase.h" +#include "fitsimage.h" + +extern "C" { + #include "ast.h" +} + +extern Grid25dBase* astGrid25dPtr; + +Grid25d::Grid25d(Widget* p, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, GridType t, + const char* o, const char* v) + : Grid(sys, sky, format, t, v), Grid25dBase(p,o) +{} + +Grid25d::~Grid25d() +{} + +int Grid25d::doit(RenderMode rm) +{ + Frame3dBase* pp = (Frame3dBase*)parent_; + + matrix_ = pp->widgetToCanvas; + pixmap_ = pp->pixmap; + renderMode_ = rm; + + Context* context = pp->keyContext; + FitsImage* fits = context->fits; + + if (!fits) + return 1; + + // int width = fits->width(); + // int height = fits->height(); + + astClearStatus; // just to make sure + astBegin; // start memory management + + AstFrameSet* frameSet = NULL; + FitsBound* params = fits->getDataParams(context->secMode()); + + switch (system_) { + case Coord::IMAGE: + frameSet = (AstFrameSet*)matrixMap(fits->refToImage,"Domain=IMAGE"); + break; + case Coord::PHYSICAL: + frameSet = (AstFrameSet*)matrixMap(fits->refToPhysical,"Domain=PHYSICAL"); + break; + case Coord::AMPLIFIER: + frameSet = (AstFrameSet*)matrixMap(fits->refToAmplifier,"Domain=AMPLIFIER"); + break; + case Coord::DETECTOR: + frameSet = (AstFrameSet*)matrixMap(fits->refToDetector,"Domain=DETECTOR"); + default: + { + // imageToData frame/map + double ss[] = {-.5, -.5}; + AstShiftMap *sm = astShiftMap(2, ss, " "); + AstFrame *df = astFrame(2, "Domain=DATA"); + + // Get 2D SkyFrame + AstFrameSet* wcs = (AstFrameSet*)astCopy(fits->getAST(system_)); + if (astIsASkyFrame(astGetFrame(wcs, AST__CURRENT))) + fits->setAstSkyFrame(wcs, sky_); + // astShow(wcs); + + // Record the index of the current Frame + int isky = astGetI(wcs, "Current"); + + // Add the new DATA Frame into the FrameSet, using the ShiftMap to + // connect it to the existing IMAGE Frame. + astAddFrame(wcs, AST__BASE, sm, df); + + // The above call to astAddFrame will have changed the current Frame + // in the FrameSet to be the new DATA Frame. First record the index of + // the DATA Frame, and then re-instate the original current Frame (i.e. + // the SKY Frame). + int idata = astGetI(wcs, "Current"); + astSetI(wcs, "Current", isky); + + // make the DATA Frame the new base Frame + astSetI(wcs, "Base", idata); + + frameSet = wcs; + } + } + + if (!frameSet) + return 0; + + astSet(frameSet,"Title=%s", " "); + + // create astPlot + float gbox[4]; + double pbox[4]; + + Vector ll = Vector(params->xmin,params->ymin); + Vector ur = Vector(params->xmax,params->ymax); + // Vector gll = ll * fits->dataToWidget; + // Vector gur = ur * fits->dataToWidget; + + pbox[0] = gbox[0] = ll[0]; + pbox[1] = gbox[1] = ll[1]; + pbox[2] = gbox[2] = ur[0]; + pbox[3] = gbox[3] = ur[1]; + + // and now create astGrid + astGrid25dPtr = this; + + AstPlot* plot = astPlot(frameSet, gbox, pbox, option_); + astGrid(plot); + + astEnd; // now, clean up memory + astGrid25dPtr =NULL; + return 1; +} + +void* Grid25d::matrixMap(Matrix& mx, const char* str) +{ + double ss[] = {mx.matrix(0,0),mx.matrix(1,0), + mx.matrix(0,1),mx.matrix(1,1)}; + double tt[] = {mx.matrix(2,0),mx.matrix(2,1)}; + + AstMatrixMap* mm = astMatrixMap(2, 2, 0, ss, ""); + AstShiftMap* sm = astShiftMap(2, tt, ""); + AstCmpMap* cmap = astCmpMap(mm, sm, 1, ""); + + AstFrame* in = astFrame(2,"Domain=REF"); + AstFrame* out = astFrame(2,str); + + AstFrameSet* frameSet = astFrameSet(in,""); + astAddFrame(frameSet,AST__CURRENT,cmap,out); + + return frameSet; +} diff --git a/tksao/frame/grid25d.h b/tksao/frame/grid25d.h new file mode 100644 index 0000000..acc58fd --- /dev/null +++ b/tksao/frame/grid25d.h @@ -0,0 +1,35 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __grid25d_h__ +#define __grid25d_h__ + +#include "grid.h" +#include "grid25dbase.h" +#include "coord.h" + +class Grid25d : public Grid, public Grid25dBase { + private: + void* matrixMap(Matrix&, const char*); + int doit(RenderMode); + + public: + Grid25d(Widget*, Coord::CoordSystem, Coord::SkyFrame, + Coord::SkyFormat, GridType, + const char*, const char*); + ~Grid25d(); + + const char* option() {return GridBase::option();} + + void x11() {doit(X11);} + void ps(int mode) {mode_=mode; doit(PS);} +#ifdef MAC_OSX_TK + void macosx() {doit(MACOSX);} +#endif +#ifdef __WIN32 + void win32() {doit(GWIN32);} +#endif +}; + +#endif diff --git a/tksao/frame/grid2d.C b/tksao/frame/grid2d.C new file mode 100644 index 0000000..7549dea --- /dev/null +++ b/tksao/frame/grid2d.C @@ -0,0 +1,157 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "grid2d.h" +#include "context.h" +#include "framebase.h" +#include "fitsimage.h" + +extern "C" { + #include "ast.h" +} + +extern Grid2dBase* astGrid2dPtr; + +Grid2d::Grid2d(Widget* p, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, GridType t, + const char* o, const char* v) + : Grid(sys, sky, format, t, v), Grid2dBase(p,o) +{} + +Grid2d::~Grid2d() +{} + +int Grid2d::doit(RenderMode rm) +{ + FrameBase* pp = (FrameBase*)parent_; + + matrix_ = pp->widgetToCanvas; + pixmap_ = pp->pixmap; + renderMode_ = rm; + + Context* context = pp->keyContext; + FitsImage* fits = context->fits; + + if (!fits) + return 1; + + // int width = fits->width(); + // int height = fits->height(); + + astClearStatus; // just to make sure + astBegin; // start memory management + + AstFrameSet* frameSet = NULL; + AstPlot* plot = NULL; + + if (!(frameSet = astFrameSet(astFrame(2,"Domain=WIDGET"),""))) { + astEnd; + return 0; + } + + // map from Widget to Image + matrixMap(frameSet,fits->widgetToImage,"Domain=IMAGE"); + + switch (system_) { + case Coord::IMAGE: + break; + case Coord::PHYSICAL: + matrixMap(frameSet,fits->imageToPhysical,"Domain=PHYSICAL"); + break; + case Coord::AMPLIFIER: + matrixMap(frameSet,fits->imageToAmplifier,"Domain=AMPLIFIER"); + break; + case Coord::DETECTOR: + matrixMap(frameSet,fits->imageToDetector,"Domain=DETECTOR"); + break; + default: + { + AstFrameSet* wcsfs = (AstFrameSet*)astCopy(fits->getAST(system_)); + + // set desired skyformat + if (astIsASkyFrame(astGetFrame(wcsfs, AST__CURRENT))) + fits->setAstSkyFrame(wcsfs, sky_); + + // add wcs to frameset + // this will link frame 2 of frameset to frame 3 wcs with unitMap + // set the current of frameset to last + astInvert(wcsfs); + astAddFrame(frameSet,2,astUnitMap(2,""),wcsfs); + astSetI(frameSet,"current",astGetI(frameSet,"nframe")); + } + } + + astSet(frameSet,"Title=%s", " "); + + // create astPlot + float gbox[4]; + double pbox[4]; + + switch (type_) { + case ANALYSIS: + { + gbox[0] = pbox[0] = 0; + gbox[1] = pbox[1] = 0; + gbox[2] = pbox[2] = pp->options->width-1; + gbox[3] = pbox[3] = pp->options->height-1; + } + break; + case PUBLICATION: + { + Matrix mm = fits->imageToWidget; + BBox b = pp->imageBBox(pp->context->secMode()); + + Vector ll = b.ll * mm; + Vector lr = b.lr() * mm; + Vector ur = b.ur * mm; + Vector ul = b.ul() * mm; + + BBox bb(ll,ll); + bb.bound(lr); + bb.bound(ur); + bb.bound(ul); + + gbox[0] = pbox[0] = bb.ll[0]; + gbox[1] = pbox[1] = bb.ll[1]; + gbox[2] = pbox[2] = bb.ur[0]; + gbox[3] = pbox[3] = bb.ur[1]; + } + break; + } + + // and now create astGrid + astGrid2dPtr = this; + + plot = astPlot(frameSet, gbox, pbox, option_); + astGrid(plot); + + astEnd; // now, clean up memory + astGrid2dPtr =NULL; + return 1; +} + +int Grid2d::matrixMap(void* fs, Matrix& mx, const char* str) +{ + AstFrameSet* frameSet = (AstFrameSet*)fs; + + double ss[] = {mx.matrix(0,0),mx.matrix(1,0), + mx.matrix(0,1),mx.matrix(1,1)}; + double tt[] = {mx.matrix(2,0),mx.matrix(2,1)}; + + AstMatrixMap* mm; + if (!(mm= astMatrixMap(2, 2, 0, ss, ""))) + return 0; + + AstShiftMap* sm; + if (!(sm = astShiftMap(2, tt, ""))) + return 0; + + AstCmpMap* cmp; + if (!(cmp = astCmpMap(mm, sm, 1, ""))) + return 0; + + astAddFrame(frameSet, AST__CURRENT, cmp, astFrame(2, str)); + + return 1; +} diff --git a/tksao/frame/grid2d.h b/tksao/frame/grid2d.h new file mode 100644 index 0000000..396d498 --- /dev/null +++ b/tksao/frame/grid2d.h @@ -0,0 +1,35 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __grid2d_h__ +#define __grid2d_h__ + +#include "grid.h" +#include "grid2dbase.h" +#include "coord.h" + +class Grid2d : public Grid, public Grid2dBase { + private: + int matrixMap(void*, Matrix&, const char*); + int doit(RenderMode); + + public: + Grid2d(Widget*, Coord::CoordSystem, Coord::SkyFrame, + Coord::SkyFormat, GridType, + const char*, const char*); + ~Grid2d(); + + const char* option() {return GridBase::option();} + + void x11() {doit(X11);} + void ps(int mode) {mode_=mode; doit(PS);} +#ifdef MAC_OSX_TK + void macosx() {doit(MACOSX);} +#endif +#ifdef __WIN32 + void win32() {doit(GWIN32);} +#endif +}; + +#endif diff --git a/tksao/frame/grid3d.C b/tksao/frame/grid3d.C new file mode 100644 index 0000000..d646418 --- /dev/null +++ b/tksao/frame/grid3d.C @@ -0,0 +1,214 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "grid3d.h" +#include "context.h" +#include "frame3dbase.h" +#include "fitsimage.h" + +extern "C" { + #include "ast.h" +} + +static FitsImage* foobar; + +void bar(AstMapping* that, int npoint, int ncoord_in, const double* ptr_in[], + int forward, int ncoord_out, double* ptr_out[]) +{ + WCSx** wcsx = foobar->wcsx(); + + if (forward) { + for (int ii=0; iicrpix[2]) * + wcsx[0]->cd[2] + wcsx[0]->crval[2]; + } + else { + for (int ii=0; iicrval[2]) / + wcsx[0]->cd[2] + wcsx[0]->crpix[2] -.5; + } +} + +extern Grid3dBase* astGrid3dPtr; + +Grid3d::Grid3d(Widget* p, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, GridType t, + const char* o, const char* v) + : Grid(sys, sky, format, t, v), Grid3dBase(p,o) +{} + +Grid3d::~Grid3d() +{} + +int Grid3d::doit(RenderMode rm) +{ + Frame3dBase* pp = (Frame3dBase*)parent_; + + mx_ = pp->refToWidget3d; + rx_ = + Matrix3d(pp->wcsOrientationMatrix) * + Matrix3d(pp->orientationMatrix) * + RotateZ3d(-pp->wcsRotation) * + RotateZ3d(-pp->rotation) * + RotateY3d(pp->az_) * + RotateX3d(pp->el_); + + matrix_ = pp->widgetToCanvas; + pixmap_ = pp->pixmap; + renderMode_ = rm; + + Context* context = pp->keyContext; + FitsImage* fits = context->fits; + + foobar = fits; + + if (!fits) + return 1; + + // int width = fits->width(); + // int height = fits->height(); + + astClearStatus; // just to make sure + astBegin; // start memory management + + AstFrameSet* frameSet = NULL; + AstPlot3D* plot = NULL; + FitsBound* params = fits->getDataParams(context->secMode()); + FitsZBound* zparams = context->getDataParams(context->secMode()); + + switch (system_) { + case Coord::IMAGE: + frameSet = (AstFrameSet*)matrixMap(fits->refToImage,"Domain=IMAGE"); + break; + case Coord::PHYSICAL: + frameSet = (AstFrameSet*)matrixMap(fits->refToPhysical,"Domain=PHYSICAL"); + break; + case Coord::AMPLIFIER: + frameSet = (AstFrameSet*)matrixMap(fits->refToAmplifier,"Domain=AMPLIFIER"); + break; + case Coord::DETECTOR: + frameSet = (AstFrameSet*)matrixMap(fits->refToDetector,"Domain=DETECTOR"); + break; + default: + { + // imageToData frame/map + double ss[] = {-.5, -.5}; + AstShiftMap *sm = astShiftMap(2, ss, " "); + AstFrame *df = astFrame(2, "Domain=DATA"); + + // Get 2D SkyFrame + AstFrameSet* wcs = (AstFrameSet*)astCopy(fits->getAST(system_)); + if (astIsASkyFrame(astGetFrame(wcs, AST__CURRENT))) + fits->setAstSkyFrame(wcs, sky_); + + // Record the index of the current Frame + int isky = astGetI(wcs, "Current"); + + // Add the new DATA Frame into the FrameSet, using the ShiftMap to + // connect it to the existing IMAGE Frame. + astAddFrame(wcs, AST__BASE, sm, df); + + // The above call to astAddFrame will have changed the current Frame + // in the FrameSet to be the new DATA Frame. First record the index of + // the DATA Frame, and then re-instate the original current Frame (i.e. + // the SKY Frame). + int idata = astGetI(wcs, "Current"); + astSetI(wcs, "Current", isky); + + // make the DATA Frame the new base Frame + astSetI(wcs, "Base", idata); + + // Create two 1D Frames and a 1D Mapping describing the third axis + AstFrame* zbase = astFrame(1,""); + AstFrame* zcurr = astFrame(1,""); + AstMapping* zmap; + if (fits->hasWCSx(system_,2)) { + astIntraReg("foo",1,1,bar,0,"testing","me","you"); + if (!(zmap = (AstMapping*)astIntraMap("foo",1,1,""))) + return 0; + } + else + zmap = (AstMapping*)astUnitMap(1,""); + + // Use astGetFrame and astGetMapping to get the base and current + // Frames from the 2D FrameSet, and the base->current Mapping. + AstFrame* wcsbase = (AstFrame*)astGetFrame(wcs,AST__BASE); + AstFrame* wcscurr = (AstFrame*)astGetFrame(wcs,AST__CURRENT); + AstMapping* wcsmap = (AstMapping*)astGetMapping(wcs,AST__BASE,AST__CURRENT); + // Combine the 2D and 1D base Frames into a 3D CmpFrame + // Likewise, combine the 2D and 1D current Frames into a 3D CmpFrame + AstCmpFrame* cmpwcsbase = astCmpFrame(wcsbase,zbase,""); + AstCmpFrame* cmpwcscurr = astCmpFrame(wcscurr,zcurr,""); + + // Combine the 2D and 1D Mappings into a 3D CmpMap + AstCmpMap* cmpwcsmap = astCmpMap(wcsmap,zmap,0,""); + + // Construct the 3D FrameSet from the new 3D Frames and Mapping + frameSet = astFrameSet(cmpwcsbase,""); + astAddFrame(frameSet, AST__CURRENT, cmpwcsmap, cmpwcscurr); + } + } + + if (!frameSet) + return 0; + + astSet(frameSet,"Title=%s", " "); + + // create astPlot + float gbox[6]; + double pbox[6]; + + // params is a BBOX in DATA coords 0-n + Vector3d ll = Vector3d(params->xmin,params->ymin,zparams->zmin); + Vector3d ur = Vector3d(params->xmax,params->ymax,zparams->zmax); + + pbox[0] = gbox[0] = ll[0]; + pbox[1] = gbox[1] = ll[1]; + pbox[2] = gbox[2] = ll[2]; + pbox[3] = gbox[3] = ur[0]; + pbox[4] = gbox[4] = ur[1]; + pbox[5] = gbox[5] = ur[2]; + + // and now create astGrid + astGrid3dPtr = this; + renderMode_ = rm; + + plot = astPlot3D(frameSet, gbox, pbox, option_); + // astShow(plot); + astGrid(plot); + + astEnd; // now, clean up memory + astGrid3dPtr =NULL; + return 1; +} + +void* Grid3d::matrixMap(Matrix& mx, const char* str) +{ + double ss[] = {mx.matrix(0,0),mx.matrix(1,0), + mx.matrix(0,1),mx.matrix(1,1)}; + AstMatrixMap* mm; + if (!(mm= astMatrixMap(2,2,0,ss,""))) + return NULL; + + double tt[] = {mx.matrix(2,0),mx.matrix(2,1)}; + AstShiftMap* sm; + if (!(sm = astShiftMap(2,tt,""))) + return NULL; + + AstCmpMap* mapxy; + if (!(mapxy = astCmpMap(mm,sm,1,""))) + return NULL; + + AstFrame* in = astFrame(3,"Domain=REF"); + AstFrame* out = astFrame(3,str); + + double uu =.5; + AstShiftMap* mapz = astShiftMap(1,&uu,""); + AstCmpMap* cmap = astCmpMap(mapxy,mapz,0,""); + + AstFrameSet* frameSet = astFrameSet(in,""); + astAddFrame(frameSet,AST__CURRENT,cmap,out); + + return frameSet; +} diff --git a/tksao/frame/grid3d.h b/tksao/frame/grid3d.h new file mode 100644 index 0000000..138fbe7 --- /dev/null +++ b/tksao/frame/grid3d.h @@ -0,0 +1,35 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __grid3d_h__ +#define __grid3d_h__ + +#include "grid.h" +#include "grid3dbase.h" +#include "coord.h" + +class Grid3d : public Grid, public Grid3dBase { + private: + void* matrixMap(Matrix&, const char*); + int doit(RenderMode); + + public: + Grid3d(Widget*, Coord::CoordSystem, Coord::SkyFrame, + Coord::SkyFormat, GridType, + const char*, const char*); + ~Grid3d(); + + const char* option() {return GridBase::option();} + + void x11() {doit(X11);} + void ps(int mode) {mode_=mode; doit(PS);} +#ifdef MAC_OSX_TK + void macosx() {doit(MACOSX);} +#endif +#ifdef __WIN32 + void win32() {doit(GWIN32);} +#endif +}; + +#endif diff --git a/tksao/frame/inversescale.C b/tksao/frame/inversescale.C new file mode 100644 index 0000000..70463d2 --- /dev/null +++ b/tksao/frame/inversescale.C @@ -0,0 +1,204 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "inversescale.h" +#include "framebase.h" +#include "colorscale.h" + +InverseScale::InverseScale(int ss) : size_(ss) +{ + level_ = new double[size_]; + + for (int ii=0; iivv) + break; + jj++; + } + double aa = double(jj)/histsize; + level_[ii] = aa*dd +low; + } + } +} + +IISInverseScale::IISInverseScale(int ss, double low, double high, Vector& iisz) + : InverseScale(ss) +{ + if (size_==1) { + level_[0] = high; + return; + } + + double dd = high-low; + for (int ii=0; ii IISMAX) + level_[ii] = iisz[1]; + else + level_[ii] = ((vv-1) * (iisz[1]-iisz[0]))/(IISMAX-1) + iisz[0]; + } +} + diff --git a/tksao/frame/inversescale.h b/tksao/frame/inversescale.h new file mode 100644 index 0000000..04e518e --- /dev/null +++ b/tksao/frame/inversescale.h @@ -0,0 +1,75 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __inversescale_h__ +#define __inversescale_h__ + +#include +using namespace std; + +#include "vector.h" + +class InverseScale { + protected: + double* level_; + int size_; + + public: + InverseScale(int); + InverseScale(int, double*); + virtual ~InverseScale(); + + int size() {return size_;} + double* level() {return level_;} + double level(int ii) {return level_[ii];} + + friend ostream& operator<<(ostream&, const InverseScale&); +}; + +class LinearInverseScale : public InverseScale { +public: + LinearInverseScale(int, double, double); +}; + +class LogInverseScale : public InverseScale { +public: + LogInverseScale(int, double, double, double); +}; + +class PowInverseScale : public InverseScale { +public: + PowInverseScale(int, double, double, double); +}; + +class SqrtInverseScale : public InverseScale { +public: + SqrtInverseScale(int, double, double); +}; + +class SquaredInverseScale : public InverseScale { +public: + SquaredInverseScale(int, double, double); +}; + +class AsinhInverseScale : public InverseScale { +public: + AsinhInverseScale(int, double, double); +}; + +class SinhInverseScale : public InverseScale { +public: + SinhInverseScale(int, double, double); +}; + +class HistEquInverseScale : public InverseScale { +public: + HistEquInverseScale(int, double, double, double*, int); +}; + +class IISInverseScale : public InverseScale { +public: + IISInverseScale(int, double, double, Vector&); +}; + +#endif diff --git a/tksao/frame/lex.C b/tksao/frame/lex.C new file mode 100644 index 0000000..4bd1829 --- /dev/null +++ b/tksao/frame/lex.C @@ -0,0 +1,4373 @@ +#line 2 "frame/lex.C" + +#line 4 "frame/lex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer frFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *fralloc (yy_size_t ); +void *frrealloc (void *,yy_size_t ); +void frfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 351 +#define YY_END_OF_BUFFER 352 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[1268] = + { 0, + 0, 0, 352, 350, 349, 351, 350, 350, 350, 350, + 350, 331, 331, 331, 350, 350, 350, 350, 350, 350, + 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, + 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, + 350, 349, 348, 0, 348, 345, 0, 348, 346, 348, + 331, 333, 332, 331, 348, 335, 348, 348, 348, 271, + 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 30, 348, 348, 348, + 348, 348, 43, 348, 348, 348, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, + + 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 128, 348, 348, 348, 348, + 348, 141, 348, 348, 348, 348, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, + 188, 348, 348, 348, 348, 195, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 275, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, + 348, 348, 326, 348, 348, 348, 348, 0, 348, 347, + + 345, 346, 333, 332, 337, 336, 348, 335, 348, 348, + 348, 332, 348, 334, 348, 2, 348, 6, 7, 348, + 348, 348, 348, 348, 348, 348, 348, 18, 348, 20, + 348, 348, 348, 348, 348, 348, 348, 348, 31, 33, + 348, 348, 348, 37, 348, 348, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 78, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 92, 93, + 348, 348, 348, 348, 99, 348, 348, 348, 348, 348, + 105, 348, 348, 348, 110, 348, 114, 116, 348, 348, + + 348, 348, 348, 348, 123, 348, 348, 348, 348, 130, + 348, 348, 348, 348, 348, 348, 348, 348, 142, 348, + 348, 348, 348, 348, 348, 348, 152, 348, 348, 348, + 348, 348, 348, 348, 348, 164, 348, 348, 168, 348, + 348, 348, 348, 348, 348, 175, 348, 348, 348, 348, + 348, 348, 183, 348, 348, 186, 348, 348, 190, 348, + 348, 348, 194, 348, 348, 348, 199, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 348, 214, 348, 348, + 348, 348, 348, 348, 348, 348, 348, 229, 348, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 348, 243, + + 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 263, 348, 348, 348, + 267, 348, 348, 348, 348, 348, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 348, 287, 348, 348, + 348, 348, 294, 348, 348, 348, 325, 327, 348, 348, + 348, 347, 338, 348, 333, 348, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, + 348, 19, 348, 22, 348, 348, 25, 27, 28, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, + 348, 348, 348, 348, 51, 348, 348, 54, 79, 348, + + 60, 348, 348, 348, 348, 348, 69, 348, 348, 348, + 71, 348, 76, 348, 80, 82, 348, 348, 348, 348, + 348, 348, 348, 348, 98, 348, 348, 100, 348, 348, + 348, 348, 348, 348, 108, 348, 111, 348, 348, 117, + 348, 119, 348, 348, 348, 348, 348, 126, 127, 348, + 131, 348, 348, 135, 348, 348, 348, 140, 348, 348, + 145, 146, 348, 149, 348, 348, 348, 348, 348, 348, + 159, 161, 348, 162, 348, 348, 348, 169, 171, 348, + 348, 348, 348, 176, 178, 348, 348, 181, 182, 348, + 348, 187, 189, 191, 348, 348, 196, 348, 348, 348, + + 348, 348, 348, 204, 348, 348, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 219, 348, 348, 348, 348, + 348, 348, 348, 348, 230, 348, 348, 348, 348, 348, + 236, 348, 238, 348, 348, 348, 348, 348, 348, 348, + 348, 348, 249, 250, 251, 348, 348, 348, 348, 348, + 258, 348, 348, 348, 348, 348, 348, 348, 269, 348, + 348, 348, 348, 348, 278, 279, 280, 348, 348, 348, + 348, 285, 348, 348, 348, 348, 288, 293, 321, 295, + 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, + + 316, 317, 318, 319, 320, 348, 348, 348, 328, 330, + 348, 348, 339, 348, 348, 348, 348, 1, 5, 3, + 348, 348, 10, 348, 348, 348, 348, 15, 16, 17, + 348, 348, 24, 348, 29, 348, 348, 35, 348, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, + 348, 348, 53, 55, 348, 348, 348, 348, 348, 348, + 348, 348, 70, 348, 348, 72, 348, 348, 348, 348, + 85, 348, 348, 348, 89, 348, 348, 348, 348, 348, + 348, 348, 348, 104, 348, 107, 348, 112, 113, 348, + 118, 348, 348, 348, 348, 348, 348, 348, 348, 348, + + 348, 348, 348, 348, 143, 348, 348, 348, 348, 151, + 348, 154, 348, 156, 348, 348, 163, 348, 348, 348, + 167, 348, 348, 348, 348, 348, 348, 348, 185, 348, + 348, 348, 348, 200, 348, 348, 203, 205, 348, 207, + 348, 348, 210, 348, 348, 348, 215, 348, 348, 348, + 221, 348, 348, 348, 348, 348, 227, 348, 348, 232, + 348, 348, 348, 237, 348, 240, 348, 348, 348, 245, + 348, 247, 248, 252, 253, 348, 348, 348, 348, 348, + 261, 348, 348, 348, 266, 348, 273, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 286, 348, 348, 348, + + 348, 322, 323, 324, 348, 340, 339, 348, 348, 343, + 348, 348, 341, 348, 348, 348, 348, 12, 13, 14, + 348, 348, 348, 348, 34, 36, 348, 39, 348, 41, + 42, 348, 45, 348, 348, 48, 348, 348, 52, 348, + 348, 348, 61, 348, 348, 348, 348, 348, 348, 348, + 73, 74, 348, 77, 348, 348, 348, 348, 348, 88, + 348, 348, 348, 348, 348, 101, 348, 348, 106, 109, + 348, 348, 348, 348, 124, 348, 129, 132, 133, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 348, 155, + 160, 157, 165, 348, 170, 348, 173, 174, 348, 179, + + 180, 184, 192, 193, 197, 198, 201, 202, 348, 208, + 209, 348, 348, 348, 348, 348, 348, 348, 222, 223, + 224, 348, 348, 348, 231, 233, 348, 235, 348, 348, + 242, 348, 246, 254, 255, 257, 348, 348, 262, 348, + 265, 348, 348, 348, 276, 277, 348, 348, 281, 348, + 284, 289, 348, 291, 348, 329, 344, 342, 4, 348, + 348, 11, 21, 23, 348, 348, 348, 348, 348, 46, + 348, 348, 50, 348, 348, 348, 348, 62, 63, 348, + 348, 66, 348, 348, 348, 348, 83, 84, 87, 86, + 348, 91, 348, 348, 96, 102, 348, 348, 348, 348, + + 348, 348, 348, 348, 137, 348, 348, 144, 147, 150, + 348, 153, 348, 348, 172, 348, 348, 211, 212, 348, + 348, 348, 348, 348, 225, 348, 348, 348, 348, 241, + 348, 348, 259, 260, 348, 348, 270, 348, 348, 348, + 348, 290, 348, 348, 9, 348, 348, 348, 348, 44, + 348, 49, 56, 57, 348, 348, 348, 65, 67, 348, + 348, 81, 90, 94, 348, 348, 348, 115, 120, 121, + 122, 125, 348, 136, 348, 348, 348, 348, 348, 177, + 206, 348, 216, 348, 218, 348, 226, 348, 234, 348, + 348, 256, 348, 268, 348, 348, 348, 283, 292, 8, + + 348, 32, 348, 40, 348, 348, 348, 64, 348, 75, + 95, 348, 348, 348, 138, 348, 148, 348, 166, 348, + 348, 348, 348, 348, 348, 348, 272, 348, 348, 26, + 38, 47, 58, 59, 348, 348, 103, 348, 139, 348, + 213, 217, 348, 228, 239, 348, 348, 348, 282, 68, + 348, 348, 348, 220, 244, 348, 348, 348, 348, 158, + 348, 274, 348, 134, 264, 97, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 5, 4, 4, 4, 4, 6, 4, + 4, 4, 7, 4, 8, 9, 4, 10, 11, 12, + 13, 14, 15, 16, 16, 16, 17, 18, 4, 4, + 4, 4, 4, 4, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 4, 4, 4, 4, 4, 4, 45, 46, 47, 48, + + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 4, 72, 4, 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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[73] = + { 0, + 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2 + } ; + +static yyconst flex_int16_t yy_base[1275] = + { 0, + 0, 0, 433, 2920, 429, 2920, 0, 72, 77, 75, + 83, 92, 69, 90, 141, 201, 250, 94, 295, 345, + 146, 97, 390, 418, 96, 196, 295, 194, 300, 436, + 83, 350, 483, 534, 91, 143, 243, 136, 103, 96, + 364, 383, 0, 375, 391, 0, 371, 385, 0, 594, + 603, 662, 702, 121, 611, 619, 636, 644, 742, 676, + 141, 150, 244, 184, 253, 188, 361, 376, 237, 202, + 209, 210, 354, 298, 232, 262, 0, 381, 288, 382, + 304, 309, 0, 426, 395, 357, 438, 393, 336, 763, + 415, 438, 479, 430, 809, 446, 353, 440, 452, 489, + + 489, 531, 468, 489, 485, 533, 531, 67, 524, 525, + 532, 535, 521, 533, 675, 0, 605, 676, 723, 535, + 536, 0, 538, 619, 760, 621, 618, 358, 627, 661, + 665, 709, 758, 853, 645, 710, 681, 778, 839, 770, + 795, 665, 673, 715, 725, 748, 742, 755, 843, 763, + 797, 789, 799, 858, 849, 815, 844, 846, 885, 863, + 885, 856, 893, 901, 905, 939, 895, 902, 931, 936, + 932, 911, 922, 943, 939, 960, 947, 955, 961, 960, + 947, 992, 965, 970, 980, 988, 997, 987, 989, 993, + 1006, 1000, 0, 994, 1013, 1000, 1013, 269, 1060, 0, + + 2920, 2920, 1123, 1043, 0, 0, 1060, 0, 1070, 1084, + 723, 1096, 1111, 0, 1004, 0, 1053, 1057, 0, 1063, + 1073, 1087, 1079, 1107, 1116, 1129, 1099, 0, 1116, 0, + 1114, 1114, 1121, 324, 1125, 1132, 1116, 1133, 1138, 0, + 1129, 1143, 1143, 1148, 1134, 1146, 1152, 1143, 1175, 1174, + 1160, 1167, 1167, 1180, 1183, 1169, 1175, 1173, 1180, 1167, + 1171, 1170, 1183, 1184, 1198, 1184, 1196, 1185, 0, 1208, + 1216, 1207, 1230, 1214, 1228, 1214, 1230, 1223, 0, 0, + 1228, 1218, 1217, 1231, 0, 1232, 1230, 1236, 1245, 1228, + 0, 1228, 1230, 1248, 1231, 1246, 330, 0, 1232, 1241, + + 1244, 1266, 1279, 1264, 0, 1282, 1271, 1281, 1282, 0, + 1284, 1282, 1281, 1286, 1284, 1273, 1288, 1279, 0, 1292, + 1289, 1285, 1297, 1297, 1286, 284, 1282, 1303, 1313, 1316, + 1327, 1315, 1316, 1333, 1337, 0, 1324, 1326, 0, 1330, + 1331, 1340, 1325, 1337, 1335, 0, 1333, 1345, 1350, 1343, + 1348, 1349, 0, 1346, 1351, 0, 1337, 1354, 0, 1356, + 1370, 1368, 0, 1359, 1378, 1383, 1386, 1370, 1371, 1386, + 1373, 1375, 1390, 1376, 1383, 1376, 1382, 0, 1384, 1390, + 1415, 1394, 1389, 1400, 1402, 1400, 1435, 0, 1419, 1440, + 1437, 1427, 1435, 1440, 1434, 1442, 1433, 1439, 1448, 0, + + 1453, 1440, 1453, 1452, 1440, 1456, 1472, 1480, 1485, 1473, + 1480, 1474, 1473, 1493, 1494, 1476, 0, 1492, 1478, 1487, + 0, 1484, 1481, 1499, 1499, 1498, 1498, 1493, 1503, 1505, + 1496, 1504, 1500, 1511, 1528, 1517, 1517, 0, 1520, 1524, + 1522, 1530, 1587, 1639, 1623, 279, 0, 0, 1620, 1632, + 1645, 2920, 0, 1555, 1655, 1664, 1682, 1691, 1645, 1652, + 1664, 1685, 1670, 1691, 1685, 1684, 1690, 1695, 1676, 1679, + 1695, 0, 1703, 0, 1684, 228, 1699, 0, 0, 1693, + 1694, 1700, 1699, 1706, 1698, 1738, 1710, 1710, 1714, 1716, + 1706, 1700, 1741, 1734, 0, 1737, 1732, 0, 0, 1733, + + 0, 1739, 1752, 1753, 1740, 1752, 0, 1737, 1756, 1741, + 0, 1743, 0, 1748, 1752, 1779, 1760, 1748, 1765, 1771, + 1791, 1797, 1786, 1786, 0, 1802, 1788, 0, 1801, 1794, + 1787, 1803, 1794, 1805, 0, 1806, 1787, 1809, 1800, 0, + 1795, 0, 1796, 1816, 1801, 1820, 1814, 0, 0, 1811, + 1838, 1836, 1835, 0, 1839, 1847, 1827, 0, 1849, 1834, + 0, 0, 1849, 1844, 1857, 226, 1844, 1848, 1841, 1851, + 1863, 0, 1853, 0, 1854, 1848, 1859, 1866, 0, 1864, + 1872, 1859, 1874, 1886, 0, 1887, 1887, 0, 0, 1881, + 1885, 0, 0, 0, 1900, 1903, 0, 1892, 1894, 1908, + + 1905, 1906, 1907, 0, 1898, 1905, 1903, 123, 1896, 1910, + 1899, 1914, 1900, 1918, 1919, 0, 1916, 1901, 1926, 1933, + 1953, 1942, 1936, 1945, 0, 1938, 1941, 1948, 1948, 1948, + 0, 1958, 0, 1950, 1960, 1961, 1964, 1961, 1964, 1965, + 1951, 1968, 0, 0, 0, 1970, 1960, 1957, 1973, 1976, + 0, 1981, 1982, 1987, 1989, 2004, 2005, 1999, 0, 2001, + 2012, 2002, 2014, 1997, 0, 0, 0, 2010, 2017, 2007, + 2000, 0, 2016, 2007, 2014, 2019, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 202, 2019, 174, 0, 0, + 2017, 2066, 2075, 2083, 2092, 2100, 2147, 0, 0, 2023, + 2094, 2082, 0, 2081, 2099, 2090, 2102, 0, 0, 0, + 2099, 2087, 0, 2090, 0, 2105, 2086, 0, 2103, 2108, + 2105, 2106, 2124, 2134, 2152, 2135, 2140, 2136, 2139, 2143, + 2154, 2155, 0, 2174, 2148, 2149, 2145, 2146, 2163, 2148, + 2169, 2162, 0, 2171, 2168, 2166, 2157, 2168, 2195, 2200, + 0, 2194, 2202, 2203, 0, 2189, 2196, 2191, 2192, 2195, + 2214, 2201, 2202, 0, 2200, 0, 2202, 0, 0, 2206, + 0, 2213, 2203, 2215, 2213, 2217, 2222, 2210, 2209, 2234, + + 2236, 2239, 2250, 2243, 0, 2255, 2255, 2252, 2242, 0, + 2245, 0, 2256, 0, 2248, 2262, 0, 2244, 2263, 2252, + 0, 2265, 2269, 2250, 2261, 2273, 2263, 2273, 0, 2261, + 2260, 2267, 2271, 0, 2279, 2290, 0, 0, 2306, 0, + 2306, 2307, 2307, 2298, 2311, 2297, 0, 2313, 2300, 2316, + 0, 2308, 2302, 2308, 2321, 2309, 0, 2305, 2322, 0, + 2323, 2328, 2323, 0, 2311, 0, 2318, 2313, 2338, 0, + 2345, 0, 0, 0, 0, 2352, 2341, 2357, 2358, 2359, + 0, 2346, 2359, 2354, 0, 2367, 0, 2366, 2363, 2367, + 2353, 2358, 2368, 2373, 2373, 2374, 0, 2362, 2366, 2358, + + 2380, 0, 0, 0, 2379, 2120, 2419, 2427, 2435, 0, + 2443, 2471, 0, 2419, 2438, 2439, 2430, 0, 0, 0, + 2445, 2443, 2437, 2444, 0, 0, 2434, 0, 2453, 0, + 0, 2454, 0, 2451, 2441, 0, 2451, 2449, 0, 2488, + 2490, 2489, 0, 2489, 2475, 2486, 2477, 2479, 2479, 2485, + 0, 0, 2499, 0, 2482, 2488, 2500, 2484, 2487, 0, + 2492, 2504, 2500, 2501, 2506, 0, 2498, 2495, 0, 0, + 156, 2499, 2532, 2541, 0, 2540, 0, 0, 0, 2541, + 2525, 2525, 2529, 2534, 2544, 2532, 2537, 2543, 2549, 0, + 0, 2549, 0, 2546, 0, 2551, 0, 0, 2554, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 2557, 0, + 0, 2541, 2546, 2543, 2540, 2543, 2544, 2564, 0, 0, + 0, 2561, 2581, 2574, 0, 0, 2588, 0, 2587, 2577, + 0, 2579, 0, 0, 2592, 0, 2596, 2597, 0, 2601, + 0, 2583, 2585, 2590, 0, 0, 2605, 2595, 0, 2605, + 0, 0, 2595, 0, 2609, 0, 0, 0, 0, 2606, + 2593, 0, 0, 0, 2592, 2613, 2603, 2604, 2606, 0, + 2609, 2641, 0, 2628, 2631, 2647, 2648, 0, 0, 2630, + 2632, 0, 2632, 2652, 2645, 2635, 0, 0, 0, 0, + 2638, 0, 2654, 2643, 2658, 0, 2651, 2656, 2648, 2660, + + 2650, 2646, 2654, 2662, 0, 2667, 2649, 0, 0, 0, + 2655, 0, 2683, 2693, 0, 2681, 2688, 0, 0, 2692, + 2697, 2694, 2679, 2685, 0, 2701, 2698, 2703, 2703, 0, + 2701, 2685, 0, 0, 2700, 2708, 0, 2702, 2697, 2707, + 2697, 0, 2706, 2701, 0, 2706, 2707, 2701, 2744, 0, + 2749, 0, 0, 0, 2739, 2749, 2748, 0, 0, 2734, + 2737, 0, 0, 0, 2742, 2743, 2757, 0, 0, 0, + 0, 0, 2750, 0, 2747, 2760, 2748, 2759, 2746, 0, + 0, 2749, 0, 2751, 0, 2758, 0, 2753, 0, 2760, + 2757, 0, 2770, 0, 2768, 2768, 2754, 0, 0, 0, + + 2797, 0, 2783, 0, 2791, 2799, 2800, 0, 2801, 0, + 0, 2793, 2796, 2793, 0, 2798, 0, 2802, 0, 2792, + 2799, 2799, 2801, 2813, 2816, 2815, 0, 2805, 2815, 0, + 0, 0, 0, 0, 2802, 2801, 0, 2803, 0, 2823, + 0, 0, 2811, 0, 0, 2814, 2833, 2851, 0, 0, + 2843, 2847, 2843, 0, 0, 2849, 2834, 2839, 2858, 0, + 2859, 0, 2844, 0, 0, 0, 2920, 74, 2907, 2909, + 2911, 2913, 2915, 2917 + } ; + +static yyconst flex_int16_t yy_def[1275] = + { 0, + 1267, 1, 1267, 1267, 1267, 1267, 1268, 1269, 1270, 1268, + 1268, 1268, 12, 12, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1271, 1267, 1268, 1272, 1269, 1268, 1273, 1270, 1268, 1268, + 12, 1268, 1268, 12, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1274, 1271, 1268, + + 1267, 1267, 1268, 203, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 59, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1267, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1267, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, + 1268, 1268, 1268, 1268, 1268, 1268, 0, 1267, 1267, 1267, + 1267, 1267, 1267, 1267 + } ; + +static yyconst flex_int16_t yy_nxt[2993] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, + 13, 13, 14, 13, 13, 13, 13, 7, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 7, 44, 44, 44, 43, 46, 47, 47, 47, + 297, 298, 49, 50, 51, 51, 51, 51, 51, 51, + 51, 51, 52, 52, 52, 52, 52, 52, 52, 52, + + 53, 54, 54, 54, 54, 54, 54, 54, 54, 55, + 43, 60, 94, 56, 57, 117, 95, 58, 129, 118, + 96, 157, 182, 119, 183, 194, 195, 184, 196, 120, + 97, 43, 197, 59, 841, 842, 43, 60, 94, 56, + 57, 117, 95, 58, 129, 118, 96, 157, 182, 119, + 183, 194, 195, 184, 196, 120, 97, 43, 197, 59, + 61, 185, 43, 1098, 112, 186, 192, 62, 113, 187, + 63, 64, 65, 215, 66, 114, 67, 68, 193, 69, + 70, 115, 71, 216, 72, 904, 61, 185, 43, 116, + 112, 186, 192, 62, 113, 187, 63, 64, 65, 215, + + 66, 114, 67, 68, 193, 69, 70, 115, 71, 216, + 72, 73, 139, 902, 130, 116, 140, 220, 131, 74, + 75, 224, 132, 76, 231, 77, 141, 78, 133, 142, + 79, 232, 143, 80, 81, 810, 233, 733, 139, 82, + 130, 83, 140, 220, 131, 74, 75, 224, 132, 76, + 231, 77, 141, 78, 133, 142, 79, 232, 143, 80, + 81, 188, 233, 189, 237, 82, 190, 83, 84, 191, + 217, 221, 85, 218, 229, 86, 87, 222, 230, 88, + 89, 219, 90, 91, 223, 92, 238, 188, 93, 189, + 237, 708, 190, 566, 84, 191, 217, 221, 85, 218, + + 229, 86, 87, 222, 230, 88, 89, 219, 90, 91, + 223, 92, 238, 134, 93, 98, 99, 135, 235, 144, + 242, 136, 245, 145, 100, 137, 101, 138, 102, 103, + 104, 146, 246, 147, 236, 148, 105, 539, 476, 134, + 452, 98, 99, 135, 235, 144, 242, 136, 245, 145, + 100, 137, 101, 138, 102, 103, 104, 146, 246, 147, + 236, 148, 105, 106, 198, 198, 198, 326, 158, 280, + 234, 107, 159, 108, 160, 252, 202, 109, 257, 201, + 110, 225, 161, 111, 42, 47, 47, 47, 162, 106, + 49, 44, 44, 44, 158, 46, 226, 107, 159, 108, + + 160, 252, 227, 109, 257, 239, 110, 225, 161, 111, + 121, 122, 240, 228, 162, 255, 123, 243, 241, 256, + 124, 125, 226, 244, 250, 126, 251, 127, 227, 128, + 42, 239, 1267, 264, 1267, 200, 121, 122, 240, 228, + 1267, 255, 123, 243, 241, 256, 124, 125, 1267, 244, + 250, 126, 251, 127, 149, 247, 253, 248, 150, 264, + 265, 151, 152, 249, 278, 153, 270, 271, 154, 281, + 266, 155, 1267, 254, 156, 1267, 279, 1267, 282, 1267, + 149, 247, 253, 248, 150, 1267, 265, 151, 152, 249, + 278, 153, 270, 271, 154, 281, 266, 155, 267, 254, + + 156, 163, 279, 164, 282, 165, 289, 290, 166, 167, + 285, 283, 168, 169, 268, 170, 269, 171, 284, 172, + 173, 174, 291, 1267, 267, 175, 1267, 163, 286, 164, + 1267, 165, 289, 290, 166, 167, 285, 283, 168, 169, + 268, 170, 269, 171, 284, 172, 173, 174, 291, 287, + 1267, 175, 176, 292, 286, 299, 177, 300, 305, 178, + 294, 301, 293, 302, 303, 306, 179, 288, 295, 180, + 317, 318, 296, 304, 319, 287, 181, 1267, 176, 292, + 1267, 299, 177, 300, 305, 178, 294, 301, 293, 302, + 303, 306, 179, 288, 295, 180, 317, 318, 296, 304, + + 319, 1267, 181, 203, 203, 203, 203, 203, 203, 203, + 203, 204, 51, 51, 51, 51, 51, 51, 51, 51, + 209, 209, 209, 209, 209, 209, 209, 209, 210, 210, + 210, 210, 210, 210, 210, 210, 309, 320, 205, 324, + 325, 310, 211, 211, 43, 212, 212, 212, 212, 212, + 212, 212, 212, 213, 213, 213, 213, 213, 213, 213, + 213, 1267, 309, 320, 205, 324, 325, 310, 1267, 327, + 43, 52, 52, 52, 52, 52, 52, 52, 52, 1267, + 328, 343, 344, 206, 207, 210, 210, 210, 210, 210, + 210, 210, 210, 307, 311, 327, 329, 1267, 1267, 347, + + 360, 308, 312, 361, 330, 313, 328, 343, 344, 206, + 207, 52, 52, 52, 52, 52, 52, 52, 52, 307, + 311, 1267, 329, 208, 57, 347, 360, 308, 312, 361, + 330, 313, 212, 212, 212, 212, 212, 212, 212, 212, + 331, 345, 362, 346, 314, 332, 333, 315, 363, 208, + 57, 214, 214, 214, 214, 214, 214, 214, 214, 316, + 214, 214, 214, 214, 214, 214, 331, 345, 362, 346, + 314, 332, 333, 315, 363, 1267, 334, 364, 335, 365, + 321, 366, 336, 322, 1267, 316, 214, 214, 214, 214, + 214, 214, 258, 259, 260, 261, 262, 323, 370, 348, + + 1267, 263, 334, 364, 335, 365, 321, 366, 336, 322, + 356, 357, 1267, 1267, 349, 350, 1267, 351, 258, 259, + 260, 261, 262, 323, 370, 348, 358, 263, 272, 371, + 373, 374, 273, 274, 382, 359, 356, 357, 275, 372, + 349, 350, 276, 351, 1267, 1267, 277, 1267, 1267, 1267, + 1267, 1267, 358, 1267, 272, 371, 373, 374, 273, 274, + 382, 359, 1267, 1267, 275, 372, 383, 384, 276, 352, + 353, 379, 277, 337, 367, 380, 354, 338, 368, 369, + 355, 381, 388, 1267, 375, 391, 339, 376, 340, 341, + 342, 1267, 383, 384, 377, 352, 353, 379, 378, 337, + + 367, 380, 354, 338, 368, 369, 355, 381, 388, 385, + 375, 391, 339, 376, 340, 341, 342, 389, 386, 395, + 377, 387, 390, 392, 378, 393, 406, 396, 408, 398, + 1267, 1267, 394, 397, 399, 385, 415, 1267, 407, 1267, + 416, 1267, 400, 389, 386, 395, 401, 387, 390, 392, + 1267, 393, 406, 396, 408, 398, 411, 402, 394, 397, + 399, 409, 415, 410, 407, 403, 416, 413, 400, 404, + 414, 405, 401, 417, 412, 419, 418, 422, 428, 420, + 430, 424, 411, 402, 421, 426, 435, 409, 423, 410, + 425, 403, 436, 413, 427, 404, 414, 405, 429, 417, + + 412, 419, 418, 422, 428, 420, 430, 424, 439, 437, + 421, 426, 435, 431, 423, 438, 425, 432, 436, 441, + 427, 433, 442, 440, 429, 443, 444, 445, 434, 447, + 448, 449, 450, 451, 439, 437, 1267, 446, 1267, 431, + 1267, 438, 459, 432, 1267, 441, 1267, 433, 442, 440, + 1267, 443, 444, 445, 434, 447, 448, 449, 450, 451, + 198, 198, 198, 446, 208, 57, 454, 454, 459, 455, + 455, 455, 455, 455, 455, 455, 455, 460, 205, 209, + 209, 209, 209, 209, 209, 209, 209, 456, 1267, 461, + 208, 57, 462, 210, 210, 210, 210, 210, 210, 210, + + 210, 1267, 463, 460, 205, 212, 212, 212, 212, 212, + 212, 212, 212, 1267, 457, 461, 464, 465, 462, 1267, + 213, 213, 213, 213, 213, 213, 213, 213, 463, 466, + 471, 200, 203, 203, 203, 203, 203, 203, 203, 203, + 457, 458, 464, 465, 206, 207, 467, 469, 472, 473, + 474, 475, 468, 477, 478, 466, 471, 479, 453, 480, + 481, 470, 482, 483, 484, 487, 485, 458, 486, 488, + 206, 207, 467, 469, 472, 473, 474, 475, 468, 477, + 478, 489, 490, 479, 453, 480, 481, 470, 482, 483, + 484, 487, 485, 491, 486, 488, 492, 493, 494, 495, + + 496, 497, 498, 499, 505, 500, 506, 489, 490, 501, + 503, 502, 507, 504, 508, 509, 510, 511, 513, 491, + 512, 514, 492, 493, 494, 495, 496, 497, 498, 499, + 505, 500, 506, 515, 516, 501, 503, 502, 507, 504, + 508, 509, 510, 511, 513, 517, 512, 514, 518, 519, + 520, 521, 522, 523, 524, 525, 526, 527, 528, 515, + 516, 529, 530, 531, 532, 533, 534, 537, 538, 540, + 535, 517, 541, 542, 518, 519, 520, 521, 522, 523, + 524, 525, 526, 527, 528, 536, 543, 529, 530, 531, + 532, 533, 534, 537, 538, 540, 535, 544, 541, 542, + + 545, 546, 549, 550, 547, 551, 552, 553, 554, 555, + 556, 536, 543, 548, 557, 558, 559, 562, 560, 563, + 564, 565, 567, 544, 561, 568, 545, 546, 549, 550, + 547, 551, 552, 553, 554, 555, 556, 569, 570, 548, + 557, 558, 559, 562, 560, 563, 564, 565, 567, 571, + 561, 568, 572, 573, 574, 575, 576, 577, 578, 579, + 580, 581, 582, 569, 570, 583, 584, 585, 586, 587, + 588, 589, 590, 591, 592, 571, 593, 594, 572, 573, + 574, 575, 576, 577, 578, 579, 580, 581, 582, 595, + 596, 583, 584, 585, 586, 587, 588, 589, 590, 591, + + 592, 597, 593, 594, 598, 599, 602, 600, 603, 604, + 605, 606, 607, 608, 609, 595, 596, 601, 610, 611, + 612, 613, 1267, 617, 618, 1267, 619, 597, 620, 621, + 598, 599, 602, 600, 603, 604, 605, 606, 607, 608, + 609, 1267, 614, 601, 610, 611, 612, 613, 615, 617, + 618, 616, 619, 622, 620, 621, 625, 623, 626, 627, + 628, 629, 631, 632, 634, 633, 635, 624, 614, 636, + 637, 638, 630, 639, 615, 640, 641, 616, 642, 622, + 643, 644, 625, 623, 626, 627, 628, 629, 631, 632, + 634, 633, 635, 624, 645, 636, 637, 638, 630, 639, + + 646, 640, 641, 647, 642, 648, 643, 644, 649, 650, + 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, + 645, 661, 662, 663, 664, 665, 646, 666, 667, 647, + 668, 648, 669, 670, 649, 650, 651, 652, 653, 654, + 655, 656, 657, 658, 659, 660, 671, 661, 662, 663, + 664, 665, 672, 666, 667, 673, 668, 674, 669, 670, + 675, 676, 677, 678, 455, 455, 455, 455, 455, 455, + 455, 455, 671, 1267, 1267, 1267, 1267, 1267, 672, 1267, + 1267, 673, 1267, 674, 1267, 1267, 675, 676, 677, 678, + 43, 43, 43, 43, 43, 43, 679, 43, 43, 43, + + 43, 43, 43, 43, 43, 680, 681, 682, 683, 684, + 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, + 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, + 705, 680, 681, 682, 683, 684, 685, 686, 687, 688, + 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, + 699, 700, 701, 702, 703, 704, 705, 43, 43, 706, + 707, 709, 710, 711, 455, 455, 455, 455, 455, 455, + 455, 455, 712, 713, 713, 713, 713, 713, 713, 713, + 713, 1267, 718, 719, 720, 706, 707, 709, 710, 711, + 714, 715, 715, 715, 715, 715, 715, 715, 715, 716, + + 717, 717, 717, 717, 717, 717, 717, 717, 718, 719, + 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, + 730, 731, 732, 734, 735, 736, 737, 738, 739, 740, + 1267, 743, 744, 745, 746, 747, 748, 721, 722, 723, + 724, 725, 726, 727, 728, 729, 730, 731, 732, 734, + 735, 736, 737, 738, 739, 740, 741, 743, 744, 745, + 746, 747, 748, 749, 742, 751, 752, 753, 754, 755, + 756, 757, 760, 762, 763, 761, 750, 764, 765, 766, + 767, 768, 741, 1267, 771, 758, 772, 773, 759, 749, + 742, 751, 752, 753, 754, 755, 756, 757, 760, 762, + + 763, 761, 750, 764, 765, 766, 767, 768, 774, 769, + 771, 758, 772, 773, 759, 770, 775, 776, 777, 778, + 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, + 789, 790, 791, 792, 774, 769, 793, 794, 795, 796, + 797, 770, 775, 776, 777, 778, 779, 780, 781, 782, + 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, + 798, 799, 793, 794, 795, 796, 797, 800, 801, 802, + 804, 805, 806, 807, 808, 809, 811, 812, 813, 803, + 814, 815, 816, 817, 818, 819, 798, 799, 820, 821, + 822, 823, 824, 800, 801, 802, 804, 805, 806, 807, + + 808, 809, 811, 812, 813, 803, 814, 815, 816, 817, + 818, 819, 825, 826, 820, 821, 822, 823, 824, 827, + 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, + 838, 839, 840, 843, 844, 845, 846, 847, 825, 826, + 848, 849, 850, 851, 852, 827, 828, 829, 830, 831, + 832, 833, 834, 835, 836, 837, 838, 839, 840, 843, + 844, 845, 846, 847, 853, 854, 848, 849, 850, 851, + 852, 855, 856, 857, 858, 859, 860, 861, 862, 863, + 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, + 853, 854, 874, 875, 876, 877, 878, 855, 856, 857, + + 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, + 868, 869, 870, 871, 872, 873, 879, 880, 874, 875, + 876, 877, 878, 881, 883, 882, 884, 885, 886, 887, + 888, 890, 891, 892, 893, 894, 895, 896, 897, 898, + 899, 900, 879, 880, 903, 901, 905, 914, 889, 881, + 883, 882, 884, 885, 886, 887, 888, 890, 891, 892, + 893, 894, 895, 896, 897, 898, 899, 900, 1267, 1267, + 903, 901, 905, 914, 889, 906, 906, 906, 906, 906, + 906, 906, 906, 907, 713, 713, 713, 713, 713, 713, + 713, 713, 908, 908, 908, 908, 908, 908, 908, 908, + + 909, 715, 715, 715, 715, 715, 715, 715, 715, 911, + 911, 911, 911, 911, 911, 911, 911, 915, 916, 917, + 918, 919, 920, 921, 922, 923, 924, 925, 910, 906, + 906, 906, 906, 906, 906, 906, 906, 1267, 926, 927, + 928, 929, 930, 915, 916, 917, 918, 919, 920, 921, + 922, 923, 924, 925, 910, 912, 717, 717, 717, 717, + 717, 717, 717, 717, 926, 927, 928, 929, 930, 931, + 932, 933, 934, 935, 936, 937, 938, 939, 1267, 943, + 944, 945, 946, 913, 1267, 947, 948, 949, 950, 951, + 952, 953, 954, 940, 955, 931, 932, 933, 934, 935, + + 936, 937, 938, 939, 941, 943, 944, 945, 946, 913, + 942, 947, 948, 949, 950, 951, 952, 953, 954, 940, + 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, + 941, 965, 966, 967, 968, 969, 942, 970, 971, 972, + 973, 974, 975, 976, 977, 978, 979, 956, 957, 958, + 959, 960, 961, 962, 963, 964, 980, 965, 966, 967, + 968, 969, 981, 970, 971, 972, 973, 974, 975, 976, + 977, 978, 979, 982, 983, 984, 985, 986, 987, 988, + 989, 990, 980, 991, 992, 993, 994, 995, 981, 996, + 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 982, + + 983, 984, 985, 986, 987, 988, 989, 990, 1006, 991, + 992, 993, 994, 995, 1007, 996, 997, 998, 999, 1000, + 1001, 1002, 1003, 1004, 1005, 1008, 1009, 1010, 1011, 1012, + 1013, 1014, 1015, 1016, 1006, 1017, 1018, 1019, 1020, 1021, + 1007, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, + 1031, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, + 1032, 1017, 1018, 1019, 1020, 1021, 1033, 1022, 1023, 1024, + 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1034, 1035, 1036, + 1037, 1038, 1039, 1040, 1041, 1042, 1032, 1043, 1044, 1045, + 1046, 1047, 1033, 1048, 1049, 1050, 1051, 1052, 1053, 1054, + + 1055, 1056, 1267, 1034, 1035, 1036, 1037, 1038, 1039, 1040, + 1041, 1042, 1267, 1043, 1044, 1045, 1046, 1047, 1267, 1048, + 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 906, 906, + 906, 906, 906, 906, 906, 906, 908, 908, 908, 908, + 908, 908, 908, 908, 908, 908, 908, 908, 908, 908, + 908, 908, 911, 911, 911, 911, 911, 911, 911, 911, + 1267, 1267, 1059, 1057, 1060, 1061, 1062, 1063, 1064, 1065, + 1066, 910, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1058, + 911, 911, 911, 911, 911, 911, 911, 911, 1059, 1057, + 1060, 1061, 1062, 1063, 1064, 1065, 1066, 910, 1067, 1068, + + 1069, 1070, 1071, 1072, 1073, 1058, 1074, 913, 1075, 1076, + 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, + 1088, 1089, 1077, 1090, 1091, 1092, 1093, 1094, 1095, 1096, + 1097, 1099, 1074, 913, 1075, 1076, 1078, 1079, 1080, 1081, + 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1077, 1090, + 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1099, 1100, 1101, + 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, + 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, + 1122, 1123, 1124, 1125, 1100, 1101, 1102, 1103, 1104, 1105, + 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, + + 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, + 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, + 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, + 1146, 1147, 1148, 1149, 1150, 1151, 1126, 1127, 1128, 1129, + 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, + 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, + 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, + 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, + 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1152, 1153, + 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, + + 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, + 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, + 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, + 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, + 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, + 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, + 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, + 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, + 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, + 1228, 1229, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, + + 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, + 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, + 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, + 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, + 1252, 1253, 1254, 1255, 1230, 1231, 1232, 1233, 1234, 1235, + 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, + 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, + 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, + 1266, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267, 1267, 1267, 1267, 1267, 1256, 1257, 1258, 1259, + + 1260, 1261, 1262, 1263, 1264, 1265, 1266, 45, 45, 48, + 48, 199, 199, 44, 44, 47, 47, 198, 198, 3, + 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267 + + } ; + +static yyconst flex_int16_t yy_chk[2993] = + { 0, + 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, 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, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 8, 8, 8, 1268, 8, 9, 9, 9, + 108, 108, 9, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, + + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 13, 14, 18, 12, 12, 22, 18, 12, 25, 22, + 18, 31, 35, 22, 35, 39, 40, 35, 40, 22, + 18, 14, 40, 12, 608, 608, 13, 14, 18, 12, + 12, 22, 18, 12, 25, 22, 18, 31, 35, 22, + 35, 39, 40, 35, 40, 22, 18, 14, 40, 12, + 15, 36, 54, 971, 21, 36, 38, 15, 21, 36, + 15, 15, 15, 61, 15, 21, 15, 15, 38, 15, + 15, 21, 15, 62, 15, 708, 15, 36, 54, 21, + 21, 36, 38, 15, 21, 36, 15, 15, 15, 61, + + 15, 21, 15, 15, 38, 15, 15, 21, 15, 62, + 15, 16, 28, 706, 26, 21, 28, 64, 26, 16, + 16, 66, 26, 16, 70, 16, 28, 16, 26, 28, + 16, 71, 28, 16, 16, 566, 72, 476, 28, 16, + 26, 16, 28, 64, 26, 16, 16, 66, 26, 16, + 70, 16, 28, 16, 26, 28, 16, 71, 28, 16, + 16, 37, 72, 37, 75, 16, 37, 16, 17, 37, + 63, 65, 17, 63, 69, 17, 17, 65, 69, 17, + 17, 63, 17, 17, 65, 17, 76, 37, 17, 37, + 75, 446, 37, 326, 17, 37, 63, 65, 17, 63, + + 69, 17, 17, 65, 69, 17, 17, 63, 17, 17, + 65, 17, 76, 27, 17, 19, 19, 27, 74, 29, + 79, 27, 81, 29, 19, 27, 19, 27, 19, 19, + 19, 29, 82, 29, 74, 29, 19, 297, 234, 27, + 198, 19, 19, 27, 74, 29, 79, 27, 81, 29, + 19, 27, 19, 27, 19, 19, 19, 29, 82, 29, + 74, 29, 19, 20, 41, 41, 41, 128, 32, 97, + 73, 20, 32, 20, 32, 86, 47, 20, 89, 44, + 20, 67, 32, 20, 42, 48, 48, 48, 32, 20, + 48, 45, 45, 45, 32, 45, 67, 20, 32, 20, + + 32, 86, 68, 20, 89, 78, 20, 67, 32, 20, + 23, 23, 78, 68, 32, 88, 23, 80, 78, 88, + 23, 23, 67, 80, 85, 23, 85, 23, 68, 24, + 5, 78, 3, 91, 0, 41, 23, 23, 78, 68, + 0, 88, 23, 80, 78, 88, 23, 23, 0, 80, + 85, 23, 85, 23, 30, 84, 87, 84, 30, 91, + 92, 30, 30, 84, 96, 30, 94, 94, 30, 98, + 92, 30, 0, 87, 30, 0, 96, 0, 99, 0, + 30, 84, 87, 84, 30, 0, 92, 30, 30, 84, + 96, 30, 94, 94, 30, 98, 92, 30, 93, 87, + + 30, 33, 96, 33, 99, 33, 103, 104, 33, 33, + 101, 100, 33, 33, 93, 33, 93, 33, 100, 33, + 33, 33, 105, 0, 93, 33, 0, 33, 101, 33, + 0, 33, 103, 104, 33, 33, 101, 100, 33, 33, + 93, 33, 93, 33, 100, 33, 33, 33, 105, 102, + 0, 33, 34, 106, 101, 109, 34, 110, 113, 34, + 107, 111, 106, 111, 112, 114, 34, 102, 107, 34, + 120, 121, 107, 112, 123, 102, 34, 0, 34, 106, + 0, 109, 34, 110, 113, 34, 107, 111, 106, 111, + 112, 114, 34, 102, 107, 34, 120, 121, 107, 112, + + 123, 0, 34, 50, 50, 50, 50, 50, 50, 50, + 50, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 55, 55, 55, 55, 55, 55, 55, 55, 56, 56, + 56, 56, 56, 56, 56, 56, 117, 124, 51, 126, + 127, 117, 57, 57, 51, 57, 57, 57, 57, 57, + 57, 57, 57, 58, 58, 58, 58, 58, 58, 58, + 58, 0, 117, 124, 51, 126, 127, 117, 0, 129, + 51, 52, 52, 52, 52, 52, 52, 52, 52, 0, + 130, 135, 135, 52, 52, 60, 60, 60, 60, 60, + 60, 60, 60, 115, 118, 129, 131, 0, 0, 137, + + 142, 115, 118, 143, 131, 118, 130, 135, 135, 52, + 52, 53, 53, 53, 53, 53, 53, 53, 53, 115, + 118, 0, 131, 53, 53, 137, 142, 115, 118, 143, + 131, 118, 211, 211, 211, 211, 211, 211, 211, 211, + 132, 136, 144, 136, 119, 132, 132, 119, 145, 53, + 53, 59, 59, 59, 59, 59, 59, 59, 59, 119, + 59, 59, 59, 59, 59, 59, 132, 136, 144, 136, + 119, 132, 132, 119, 145, 0, 133, 146, 133, 147, + 125, 148, 133, 125, 0, 119, 59, 59, 59, 59, + 59, 59, 90, 90, 90, 90, 90, 125, 150, 138, + + 0, 90, 133, 146, 133, 147, 125, 148, 133, 125, + 140, 140, 0, 0, 138, 138, 0, 138, 90, 90, + 90, 90, 90, 125, 150, 138, 141, 90, 95, 151, + 152, 153, 95, 95, 156, 141, 140, 140, 95, 151, + 138, 138, 95, 138, 0, 0, 95, 0, 0, 0, + 0, 0, 141, 0, 95, 151, 152, 153, 95, 95, + 156, 141, 0, 0, 95, 151, 157, 158, 95, 139, + 139, 155, 95, 134, 149, 155, 139, 134, 149, 149, + 139, 155, 160, 0, 154, 162, 134, 154, 134, 134, + 134, 0, 157, 158, 154, 139, 139, 155, 154, 134, + + 149, 155, 139, 134, 149, 149, 139, 155, 160, 159, + 154, 162, 134, 154, 134, 134, 134, 161, 159, 164, + 154, 159, 161, 163, 154, 163, 167, 164, 168, 165, + 0, 0, 163, 164, 165, 159, 172, 0, 167, 0, + 173, 0, 165, 161, 159, 164, 165, 159, 161, 163, + 0, 163, 167, 164, 168, 165, 170, 166, 163, 164, + 165, 169, 172, 169, 167, 166, 173, 171, 165, 166, + 171, 166, 165, 174, 170, 175, 174, 177, 180, 176, + 181, 178, 170, 166, 176, 179, 183, 169, 177, 169, + 178, 166, 184, 171, 179, 166, 171, 166, 180, 174, + + 170, 175, 174, 177, 180, 176, 181, 178, 186, 185, + 176, 179, 183, 182, 177, 185, 178, 182, 184, 187, + 179, 182, 188, 186, 180, 189, 190, 191, 182, 192, + 194, 195, 196, 197, 186, 185, 0, 191, 0, 182, + 0, 185, 215, 182, 0, 187, 0, 182, 188, 186, + 0, 189, 190, 191, 182, 192, 194, 195, 196, 197, + 199, 199, 199, 191, 204, 204, 207, 207, 215, 207, + 207, 207, 207, 207, 207, 207, 207, 217, 204, 209, + 209, 209, 209, 209, 209, 209, 209, 209, 0, 218, + 204, 204, 220, 210, 210, 210, 210, 210, 210, 210, + + 210, 0, 221, 217, 204, 212, 212, 212, 212, 212, + 212, 212, 212, 0, 210, 218, 222, 223, 220, 0, + 213, 213, 213, 213, 213, 213, 213, 213, 221, 224, + 227, 199, 203, 203, 203, 203, 203, 203, 203, 203, + 210, 213, 222, 223, 203, 203, 225, 226, 229, 231, + 232, 233, 225, 235, 236, 224, 227, 237, 203, 238, + 239, 226, 241, 242, 243, 245, 244, 213, 244, 246, + 203, 203, 225, 226, 229, 231, 232, 233, 225, 235, + 236, 247, 248, 237, 203, 238, 239, 226, 241, 242, + 243, 245, 244, 249, 244, 246, 250, 251, 252, 253, + + 254, 255, 256, 257, 260, 258, 261, 247, 248, 258, + 259, 258, 262, 259, 263, 264, 265, 266, 267, 249, + 266, 268, 250, 251, 252, 253, 254, 255, 256, 257, + 260, 258, 261, 270, 271, 258, 259, 258, 262, 259, + 263, 264, 265, 266, 267, 272, 266, 268, 273, 274, + 275, 276, 277, 278, 281, 282, 283, 284, 286, 270, + 271, 287, 288, 289, 290, 292, 293, 295, 296, 299, + 294, 272, 300, 301, 273, 274, 275, 276, 277, 278, + 281, 282, 283, 284, 286, 294, 302, 287, 288, 289, + 290, 292, 293, 295, 296, 299, 294, 303, 300, 301, + + 304, 306, 308, 309, 307, 311, 312, 313, 314, 315, + 316, 294, 302, 307, 317, 318, 320, 322, 321, 323, + 324, 325, 327, 303, 321, 328, 304, 306, 308, 309, + 307, 311, 312, 313, 314, 315, 316, 329, 330, 307, + 317, 318, 320, 322, 321, 323, 324, 325, 327, 331, + 321, 328, 332, 333, 334, 335, 337, 338, 340, 341, + 342, 343, 344, 329, 330, 345, 347, 348, 349, 350, + 351, 352, 354, 355, 357, 331, 358, 360, 332, 333, + 334, 335, 337, 338, 340, 341, 342, 343, 344, 361, + 362, 345, 347, 348, 349, 350, 351, 352, 354, 355, + + 357, 364, 358, 360, 365, 366, 368, 367, 369, 370, + 371, 372, 373, 374, 375, 361, 362, 367, 376, 377, + 379, 380, 0, 382, 383, 0, 384, 364, 385, 386, + 365, 366, 368, 367, 369, 370, 371, 372, 373, 374, + 375, 0, 381, 367, 376, 377, 379, 380, 381, 382, + 383, 381, 384, 387, 385, 386, 389, 387, 390, 391, + 392, 393, 394, 395, 396, 395, 397, 387, 381, 398, + 399, 401, 393, 402, 381, 402, 403, 381, 404, 387, + 405, 406, 389, 387, 390, 391, 392, 393, 394, 395, + 396, 395, 397, 387, 407, 398, 399, 401, 393, 402, + + 408, 402, 403, 409, 404, 410, 405, 406, 411, 412, + 413, 414, 415, 416, 418, 419, 420, 422, 423, 424, + 407, 425, 426, 427, 428, 429, 408, 430, 431, 409, + 432, 410, 433, 434, 411, 412, 413, 414, 415, 416, + 418, 419, 420, 422, 423, 424, 435, 425, 426, 427, + 428, 429, 436, 430, 431, 437, 432, 439, 433, 434, + 440, 440, 441, 442, 454, 454, 454, 454, 454, 454, + 454, 454, 435, 0, 0, 0, 0, 0, 436, 0, + 0, 437, 0, 439, 0, 0, 440, 440, 441, 442, + 443, 443, 443, 443, 443, 443, 443, 443, 443, 443, + + 443, 443, 443, 443, 443, 443, 443, 443, 443, 443, + 443, 443, 443, 443, 443, 443, 443, 443, 443, 443, + 443, 443, 443, 443, 443, 443, 443, 443, 443, 443, + 443, 443, 443, 443, 443, 443, 443, 443, 443, 443, + 443, 443, 443, 443, 443, 443, 443, 443, 443, 443, + 443, 443, 443, 443, 443, 443, 443, 443, 443, 444, + 445, 449, 450, 451, 455, 455, 455, 455, 455, 455, + 455, 455, 456, 456, 456, 456, 456, 456, 456, 456, + 456, 0, 459, 460, 461, 444, 445, 449, 450, 451, + 457, 457, 457, 457, 457, 457, 457, 457, 457, 458, + + 458, 458, 458, 458, 458, 458, 458, 458, 459, 460, + 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, + 471, 473, 475, 477, 480, 481, 482, 483, 484, 485, + 0, 487, 488, 489, 490, 491, 492, 462, 463, 464, + 465, 466, 467, 468, 469, 470, 471, 473, 475, 477, + 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, + 490, 491, 492, 493, 486, 494, 496, 497, 500, 502, + 503, 504, 505, 506, 508, 505, 493, 509, 510, 512, + 514, 515, 486, 0, 517, 504, 518, 519, 504, 493, + 486, 494, 496, 497, 500, 502, 503, 504, 505, 506, + + 508, 505, 493, 509, 510, 512, 514, 515, 520, 516, + 517, 504, 518, 519, 504, 516, 521, 522, 523, 524, + 526, 527, 529, 530, 531, 532, 533, 534, 536, 537, + 538, 539, 541, 543, 520, 516, 544, 545, 546, 547, + 550, 516, 521, 522, 523, 524, 526, 527, 529, 530, + 531, 532, 533, 534, 536, 537, 538, 539, 541, 543, + 551, 552, 544, 545, 546, 547, 550, 553, 555, 556, + 557, 559, 560, 563, 564, 565, 567, 568, 569, 556, + 570, 571, 573, 575, 576, 577, 551, 552, 578, 580, + 581, 582, 583, 553, 555, 556, 557, 559, 560, 563, + + 564, 565, 567, 568, 569, 556, 570, 571, 573, 575, + 576, 577, 584, 586, 578, 580, 581, 582, 583, 587, + 590, 591, 595, 596, 598, 599, 600, 601, 602, 603, + 605, 606, 607, 609, 610, 611, 612, 613, 584, 586, + 614, 615, 617, 618, 619, 587, 590, 591, 595, 596, + 598, 599, 600, 601, 602, 603, 605, 606, 607, 609, + 610, 611, 612, 613, 619, 620, 614, 615, 617, 618, + 619, 621, 622, 623, 624, 626, 627, 628, 629, 630, + 632, 634, 635, 636, 637, 638, 639, 640, 641, 642, + 619, 620, 646, 647, 648, 649, 650, 621, 622, 623, + + 624, 626, 627, 628, 629, 630, 632, 634, 635, 636, + 637, 638, 639, 640, 641, 642, 652, 653, 646, 647, + 648, 649, 650, 654, 655, 654, 656, 657, 658, 660, + 661, 662, 663, 664, 668, 669, 670, 671, 673, 674, + 675, 676, 652, 653, 707, 676, 711, 720, 661, 654, + 655, 654, 656, 657, 658, 660, 661, 662, 663, 664, + 668, 669, 670, 671, 673, 674, 675, 676, 0, 0, + 707, 676, 711, 720, 661, 712, 712, 712, 712, 712, + 712, 712, 712, 713, 713, 713, 713, 713, 713, 713, + 713, 713, 714, 714, 714, 714, 714, 714, 714, 714, + + 715, 715, 715, 715, 715, 715, 715, 715, 715, 716, + 716, 716, 716, 716, 716, 716, 716, 721, 722, 724, + 725, 726, 727, 731, 732, 734, 736, 737, 715, 906, + 906, 906, 906, 906, 906, 906, 906, 0, 739, 740, + 741, 742, 743, 721, 722, 724, 725, 726, 727, 731, + 732, 734, 736, 737, 715, 717, 717, 717, 717, 717, + 717, 717, 717, 717, 739, 740, 741, 742, 743, 744, + 745, 746, 747, 748, 749, 750, 751, 752, 0, 755, + 756, 757, 758, 717, 0, 759, 760, 761, 762, 764, + 765, 766, 767, 754, 768, 744, 745, 746, 747, 748, + + 749, 750, 751, 752, 754, 755, 756, 757, 758, 717, + 754, 759, 760, 761, 762, 764, 765, 766, 767, 754, + 768, 769, 770, 772, 773, 774, 776, 777, 778, 779, + 754, 780, 781, 782, 783, 785, 754, 787, 790, 792, + 793, 794, 795, 796, 797, 798, 799, 769, 770, 772, + 773, 774, 776, 777, 778, 779, 800, 780, 781, 782, + 783, 785, 801, 787, 790, 792, 793, 794, 795, 796, + 797, 798, 799, 802, 803, 804, 806, 807, 808, 809, + 811, 813, 800, 815, 816, 818, 819, 820, 801, 822, + 823, 824, 825, 826, 827, 828, 830, 831, 832, 802, + + 803, 804, 806, 807, 808, 809, 811, 813, 833, 815, + 816, 818, 819, 820, 835, 822, 823, 824, 825, 826, + 827, 828, 830, 831, 832, 836, 839, 841, 842, 843, + 844, 845, 846, 848, 833, 849, 850, 852, 853, 854, + 835, 855, 856, 858, 859, 861, 862, 863, 865, 867, + 868, 836, 839, 841, 842, 843, 844, 845, 846, 848, + 869, 849, 850, 852, 853, 854, 871, 855, 856, 858, + 859, 861, 862, 863, 865, 867, 868, 876, 877, 878, + 879, 880, 882, 883, 884, 886, 869, 888, 889, 890, + 891, 892, 871, 893, 894, 895, 896, 898, 899, 900, + + 901, 905, 0, 876, 877, 878, 879, 880, 882, 883, + 884, 886, 0, 888, 889, 890, 891, 892, 0, 893, + 894, 895, 896, 898, 899, 900, 901, 905, 907, 907, + 907, 907, 907, 907, 907, 907, 908, 908, 908, 908, + 908, 908, 908, 908, 909, 909, 909, 909, 909, 909, + 909, 909, 911, 911, 911, 911, 911, 911, 911, 911, + 0, 0, 914, 908, 915, 916, 917, 921, 922, 923, + 924, 909, 927, 929, 932, 934, 935, 937, 938, 911, + 912, 912, 912, 912, 912, 912, 912, 912, 914, 908, + 915, 916, 917, 921, 922, 923, 924, 909, 927, 929, + + 932, 934, 935, 937, 938, 911, 940, 912, 941, 942, + 944, 945, 946, 947, 948, 949, 950, 953, 955, 956, + 957, 958, 942, 959, 961, 962, 963, 964, 965, 967, + 968, 972, 940, 912, 941, 942, 944, 945, 946, 947, + 948, 949, 950, 953, 955, 956, 957, 958, 942, 959, + 961, 962, 963, 964, 965, 967, 968, 972, 973, 974, + 976, 980, 981, 982, 983, 984, 985, 986, 987, 988, + 989, 992, 994, 996, 999, 1009, 1012, 1013, 1014, 1015, + 1016, 1017, 1018, 1022, 973, 974, 976, 980, 981, 982, + 983, 984, 985, 986, 987, 988, 989, 992, 994, 996, + + 999, 1009, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1022, + 1023, 1024, 1027, 1029, 1030, 1032, 1035, 1037, 1038, 1040, + 1042, 1043, 1044, 1047, 1048, 1050, 1053, 1055, 1060, 1061, + 1065, 1066, 1067, 1068, 1069, 1071, 1023, 1024, 1027, 1029, + 1030, 1032, 1035, 1037, 1038, 1040, 1042, 1043, 1044, 1047, + 1048, 1050, 1053, 1055, 1060, 1061, 1065, 1066, 1067, 1068, + 1069, 1071, 1072, 1074, 1075, 1076, 1077, 1080, 1081, 1083, + 1084, 1085, 1086, 1091, 1093, 1094, 1095, 1097, 1098, 1099, + 1100, 1101, 1102, 1103, 1104, 1106, 1107, 1111, 1072, 1074, + 1075, 1076, 1077, 1080, 1081, 1083, 1084, 1085, 1086, 1091, + + 1093, 1094, 1095, 1097, 1098, 1099, 1100, 1101, 1102, 1103, + 1104, 1106, 1107, 1111, 1113, 1114, 1116, 1117, 1120, 1121, + 1122, 1123, 1124, 1126, 1127, 1128, 1129, 1131, 1132, 1135, + 1136, 1138, 1139, 1140, 1141, 1143, 1144, 1146, 1147, 1148, + 1113, 1114, 1116, 1117, 1120, 1121, 1122, 1123, 1124, 1126, + 1127, 1128, 1129, 1131, 1132, 1135, 1136, 1138, 1139, 1140, + 1141, 1143, 1144, 1146, 1147, 1148, 1149, 1151, 1155, 1156, + 1157, 1160, 1161, 1165, 1166, 1167, 1173, 1175, 1176, 1177, + 1178, 1179, 1182, 1184, 1186, 1188, 1190, 1191, 1193, 1195, + 1196, 1197, 1149, 1151, 1155, 1156, 1157, 1160, 1161, 1165, + + 1166, 1167, 1173, 1175, 1176, 1177, 1178, 1179, 1182, 1184, + 1186, 1188, 1190, 1191, 1193, 1195, 1196, 1197, 1201, 1203, + 1205, 1206, 1207, 1209, 1212, 1213, 1214, 1216, 1218, 1220, + 1221, 1222, 1223, 1224, 1225, 1226, 1228, 1229, 1235, 1236, + 1238, 1240, 1243, 1246, 1201, 1203, 1205, 1206, 1207, 1209, + 1212, 1213, 1214, 1216, 1218, 1220, 1221, 1222, 1223, 1224, + 1225, 1226, 1228, 1229, 1235, 1236, 1238, 1240, 1243, 1246, + 1247, 1248, 1251, 1252, 1253, 1256, 1257, 1258, 1259, 1261, + 1263, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1247, 1248, 1251, 1252, + + 1253, 1256, 1257, 1258, 1259, 1261, 1263, 1269, 1269, 1270, + 1270, 1271, 1271, 1272, 1272, 1273, 1273, 1274, 1274, 1267, + 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, + 1267, 1267 + + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "frame/lex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 12 "frame/lex.L" + #include + #include + #include + #include + + #include "util.h" + #include "parser.H" + + extern YYSTYPE* frlval; +/* rules */ +#line 1503 "frame/lex.C" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 28 "frame/lex.L" + + +#line 1606 "frame/lex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 1268 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 1267 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 30 "frame/lex.L" +{return ABOUT_;} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 31 "frame/lex.L" +{return AIP_;} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 32 "frame/lex.L" +{return ALLOC_;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 33 "frame/lex.L" +{return ALLOCGZ_;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 34 "frame/lex.L" +{return ALIGN_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 35 "frame/lex.L" +{return ALL_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 36 "frame/lex.L" +{return ALT_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 37 "frame/lex.L" +{return AMPLIFIER_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 38 "frame/lex.L" +{return ANALYSIS_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 39 "frame/lex.L" +{return ANGLE_;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 40 "frame/lex.L" +{return ANNULUS_;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 41 "frame/lex.L" +{return APPEND_;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 42 "frame/lex.L" +{return ARCMIN_;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 43 "frame/lex.L" +{return ARCSEC_;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 44 "frame/lex.L" +{return ARRAY_;} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 45 "frame/lex.L" +{return ARROW_;} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 46 "frame/lex.L" +{return ASINH_;} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 47 "frame/lex.L" +{return AST_;} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 48 "frame/lex.L" +{return AUTO_;} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 49 "frame/lex.L" +{return AUX_;} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 50 "frame/lex.L" +{return AVERAGE_;} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 51 "frame/lex.L" +{return AXES_;} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 52 "frame/lex.L" +{return AZIMUTH_;} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 53 "frame/lex.L" +{return B1950_;} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 54 "frame/lex.L" +{return BACK_;} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 55 "frame/lex.L" +{return BACKGROUND_;} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 56 "frame/lex.L" +{return BASE_;} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 57 "frame/lex.L" +{return BBOX_;} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 58 "frame/lex.L" +{return BEGIN_;} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 59 "frame/lex.L" +{return BG_;} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 60 "frame/lex.L" +{return BIGENDIAN_;} + YY_BREAK +case 32: +YY_RULE_SETUP +#line 61 "frame/lex.L" +{return BIGENDIAN_;} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 62 "frame/lex.L" +{return BIN_;} + YY_BREAK +case 34: +YY_RULE_SETUP +#line 63 "frame/lex.L" +{return BITPIX_;} + YY_BREAK +case 35: +YY_RULE_SETUP +#line 64 "frame/lex.L" +{return BLOCK_;} + YY_BREAK +case 36: +YY_RULE_SETUP +#line 65 "frame/lex.L" +{return BORDER_;} + YY_BREAK +case 37: +YY_RULE_SETUP +#line 66 "frame/lex.L" +{return BOX_;} + YY_BREAK +case 38: +YY_RULE_SETUP +#line 67 "frame/lex.L" +{return BOXANNULUS_;} + YY_BREAK +case 39: +YY_RULE_SETUP +#line 68 "frame/lex.L" +{return BOXCAR_;} + YY_BREAK +case 40: +YY_RULE_SETUP +#line 69 "frame/lex.L" +{return BOXCIRCLE_;} + YY_BREAK +case 41: +YY_RULE_SETUP +#line 70 "frame/lex.L" +{return BPANDA_;} + YY_BREAK +case 42: +YY_RULE_SETUP +#line 71 "frame/lex.L" +{return BUFFER_;} + YY_BREAK +case 43: +YY_RULE_SETUP +#line 72 "frame/lex.L" +{return BW_;} + YY_BREAK +case 44: +YY_RULE_SETUP +#line 73 "frame/lex.L" +{return CALLBACK_;} + YY_BREAK +case 45: +YY_RULE_SETUP +#line 74 "frame/lex.L" +{return CANVAS_;} + YY_BREAK +case 46: +YY_RULE_SETUP +#line 75 "frame/lex.L" +{return CATALOG_;} + YY_BREAK +case 47: +YY_RULE_SETUP +#line 76 "frame/lex.L" +{return CELESTRIAL_;} + YY_BREAK +case 48: +YY_RULE_SETUP +#line 77 "frame/lex.L" +{return CENTER_;} + YY_BREAK +case 49: +YY_RULE_SETUP +#line 78 "frame/lex.L" +{return CENTROID_;} + YY_BREAK +case 50: +YY_RULE_SETUP +#line 79 "frame/lex.L" +{return CHANNEL_;} + YY_BREAK +case 51: +YY_RULE_SETUP +#line 80 "frame/lex.L" +{return CIAO_;} + YY_BREAK +case 52: +YY_RULE_SETUP +#line 81 "frame/lex.L" +{return CIRCLE_;} + YY_BREAK +case 53: +YY_RULE_SETUP +#line 82 "frame/lex.L" +{return CLEAR_;} + YY_BREAK +case 54: +YY_RULE_SETUP +#line 83 "frame/lex.L" +{return CLIP_;} + YY_BREAK +case 55: +YY_RULE_SETUP +#line 84 "frame/lex.L" +{return COLOR_;} + YY_BREAK +case 56: +YY_RULE_SETUP +#line 85 "frame/lex.L" +{return COLORBAR_;} + YY_BREAK +case 57: +YY_RULE_SETUP +#line 86 "frame/lex.L" +{return COLORMAP_;} + YY_BREAK +case 58: +YY_RULE_SETUP +#line 87 "frame/lex.L" +{return COLORSCALE_;} + YY_BREAK +case 59: +YY_RULE_SETUP +#line 88 "frame/lex.L" +{return COLORSPACE_;} + YY_BREAK +case 60: +YY_RULE_SETUP +#line 89 "frame/lex.L" +{return COLS_;} + YY_BREAK +case 61: +YY_RULE_SETUP +#line 90 "frame/lex.L" +{return COLUMN_;} + YY_BREAK +case 62: +YY_RULE_SETUP +#line 91 "frame/lex.L" +{return COMMAND_;} + YY_BREAK +case 63: +YY_RULE_SETUP +#line 92 "frame/lex.L" +{return COMPASS_;} + YY_BREAK +case 64: +YY_RULE_SETUP +#line 93 "frame/lex.L" +{return COMPOSITE_;} + YY_BREAK +case 65: +YY_RULE_SETUP +#line 94 "frame/lex.L" +{return COMPRESS_;} + YY_BREAK +case 66: +YY_RULE_SETUP +#line 95 "frame/lex.L" +{return CONTOUR_;} + YY_BREAK +case 67: +YY_RULE_SETUP +#line 96 "frame/lex.L" +{return CONTRAST_;} + YY_BREAK +case 68: +YY_RULE_SETUP +#line 97 "frame/lex.L" +{return COORDINATES_;} + YY_BREAK +case 69: +YY_RULE_SETUP +#line 98 "frame/lex.L" +{return COPY_;} + YY_BREAK +case 70: +YY_RULE_SETUP +#line 99 "frame/lex.L" +{return COUNT_;} + YY_BREAK +case 71: +YY_RULE_SETUP +#line 100 "frame/lex.L" +{return CROP_;} + YY_BREAK +case 72: +YY_RULE_SETUP +#line 101 "frame/lex.L" +{return CROSS_;} + YY_BREAK +case 73: +YY_RULE_SETUP +#line 102 "frame/lex.L" +{return CPANDA_;} + YY_BREAK +case 74: +YY_RULE_SETUP +#line 103 "frame/lex.L" +{return CREATE_;} + YY_BREAK +case 75: +YY_RULE_SETUP +#line 104 "frame/lex.L" +{return CROSSHAIR_;} + YY_BREAK +case 76: +YY_RULE_SETUP +#line 105 "frame/lex.L" +{return CUBE_;} + YY_BREAK +case 77: +YY_RULE_SETUP +#line 106 "frame/lex.L" +{return CURSOR_;} + YY_BREAK +case 78: +YY_RULE_SETUP +#line 107 "frame/lex.L" +{return CUT_;} + YY_BREAK +case 79: +YY_RULE_SETUP +#line 108 "frame/lex.L" +{return CMYK_;} + YY_BREAK +case 80: +YY_RULE_SETUP +#line 109 "frame/lex.L" +{return DASH_;} + YY_BREAK +case 81: +YY_RULE_SETUP +#line 110 "frame/lex.L" +{return DASHLIST_;} + YY_BREAK +case 82: +YY_RULE_SETUP +#line 111 "frame/lex.L" +{return DATA_;} + YY_BREAK +case 83: +YY_RULE_SETUP +#line 112 "frame/lex.L" +{return DATAMIN_;} + YY_BREAK +case 84: +YY_RULE_SETUP +#line 113 "frame/lex.L" +{return DATASEC_;} + YY_BREAK +case 85: +YY_RULE_SETUP +#line 114 "frame/lex.L" +{return DEBUG_;} + YY_BREAK +case 86: +YY_RULE_SETUP +#line 115 "frame/lex.L" +{return DEGREES_;} + YY_BREAK +case 87: +YY_RULE_SETUP +#line 116 "frame/lex.L" +{return DEFAULT_;} + YY_BREAK +case 88: +YY_RULE_SETUP +#line 117 "frame/lex.L" +{return DELETE_;} + YY_BREAK +case 89: +YY_RULE_SETUP +#line 118 "frame/lex.L" +{return DEPTH_;} + YY_BREAK +case 90: +YY_RULE_SETUP +#line 119 "frame/lex.L" +{return DETECTOR_;} + YY_BREAK +case 91: +YY_RULE_SETUP +#line 120 "frame/lex.L" +{return DIAMOND_;} + YY_BREAK +case 92: +YY_RULE_SETUP +#line 121 "frame/lex.L" +{return DIM_;} + YY_BREAK +case 93: +YY_RULE_SETUP +#line 122 "frame/lex.L" +{return DS9_;} + YY_BREAK +case 94: +YY_RULE_SETUP +#line 123 "frame/lex.L" +{return ECLIPTIC_;} + YY_BREAK +case 95: +YY_RULE_SETUP +#line 124 "frame/lex.L" +{return ELEVATION_;} + YY_BREAK +case 96: +YY_RULE_SETUP +#line 125 "frame/lex.L" +{return ELLIPSE_;} + YY_BREAK +case 97: +YY_RULE_SETUP +#line 126 "frame/lex.L" +{return ELLIPSEANNULUS_;} + YY_BREAK +case 98: +YY_RULE_SETUP +#line 127 "frame/lex.L" +{return EDIT_;} + YY_BREAK +case 99: +YY_RULE_SETUP +#line 128 "frame/lex.L" +{return END_;} + YY_BREAK +case 100: +YY_RULE_SETUP +#line 129 "frame/lex.L" +{return ENVI_;} + YY_BREAK +case 101: +YY_RULE_SETUP +#line 130 "frame/lex.L" +{return EPANDA_;} + YY_BREAK +case 102: +YY_RULE_SETUP +#line 131 "frame/lex.L" +{return EPSILON_;} + YY_BREAK +case 103: +YY_RULE_SETUP +#line 132 "frame/lex.L" +{return EQUATORIAL_;} + YY_BREAK +case 104: +YY_RULE_SETUP +#line 133 "frame/lex.L" +{return ERASE_;} + YY_BREAK +case 105: +YY_RULE_SETUP +#line 134 "frame/lex.L" +{return EXT_;} + YY_BREAK +case 106: +YY_RULE_SETUP +#line 135 "frame/lex.L" +{return FACTOR_;} + YY_BREAK +case 107: +YY_RULE_SETUP +#line 136 "frame/lex.L" +{return FALSE_;} + YY_BREAK +case 108: +YY_RULE_SETUP +#line 137 "frame/lex.L" +{return FILE_;} + YY_BREAK +case 109: +YY_RULE_SETUP +#line 138 "frame/lex.L" +{return FILTER_;} + YY_BREAK +case 110: +YY_RULE_SETUP +#line 139 "frame/lex.L" +{return FIT_;} + YY_BREAK +case 111: +YY_RULE_SETUP +#line 140 "frame/lex.L" +{return FITS_;} + YY_BREAK +case 112: +YY_RULE_SETUP +#line 141 "frame/lex.L" +{return FITSY_;} + YY_BREAK +case 113: +YY_RULE_SETUP +#line 142 "frame/lex.L" +{return FIXED_;} + YY_BREAK +case 114: +YY_RULE_SETUP +#line 143 "frame/lex.L" +{return FK4_;} + YY_BREAK +case 115: +YY_RULE_SETUP +#line 144 "frame/lex.L" +{return FK4_NO_E_;} + YY_BREAK +case 116: +YY_RULE_SETUP +#line 145 "frame/lex.L" +{return FK5_;} + YY_BREAK +case 117: +YY_RULE_SETUP +#line 146 "frame/lex.L" +{return FONT_;} + YY_BREAK +case 118: +YY_RULE_SETUP +#line 147 "frame/lex.L" +{return FRONT_;} + YY_BREAK +case 119: +YY_RULE_SETUP +#line 148 "frame/lex.L" +{return FULL_;} + YY_BREAK +case 120: +YY_RULE_SETUP +#line 149 "frame/lex.L" +{return FUNCTION_;} + YY_BREAK +case 121: +YY_RULE_SETUP +#line 150 "frame/lex.L" +{return GALACTIC_;} + YY_BREAK +case 122: +YY_RULE_SETUP +#line 151 "frame/lex.L" +{return GAUSSIAN_;} + YY_BREAK +case 123: +YY_RULE_SETUP +#line 152 "frame/lex.L" +{return GET_;} + YY_BREAK +case 124: +YY_RULE_SETUP +#line 153 "frame/lex.L" +{return GLOBAL_;} + YY_BREAK +case 125: +YY_RULE_SETUP +#line 154 "frame/lex.L" +{return GRAPHICS_;} + YY_BREAK +case 126: +YY_RULE_SETUP +#line 155 "frame/lex.L" +{return GRAY_;} + YY_BREAK +case 127: +YY_RULE_SETUP +#line 156 "frame/lex.L" +{return GRID_;} + YY_BREAK +case 128: +YY_RULE_SETUP +#line 157 "frame/lex.L" +{return GZ_;} + YY_BREAK +case 129: +YY_RULE_SETUP +#line 158 "frame/lex.L" +{return HANDLE_;} + YY_BREAK +case 130: +YY_RULE_SETUP +#line 159 "frame/lex.L" +{return HAS_;} + YY_BREAK +case 131: +YY_RULE_SETUP +#line 160 "frame/lex.L" +{return HEAD_;} + YY_BREAK +case 132: +YY_RULE_SETUP +#line 161 "frame/lex.L" +{return HEADER_;} + YY_BREAK +case 133: +YY_RULE_SETUP +#line 162 "frame/lex.L" +{return HEIGHT_;} + YY_BREAK +case 134: +YY_RULE_SETUP +#line 163 "frame/lex.L" +{return HELIOECLIPTIC_;} + YY_BREAK +case 135: +YY_RULE_SETUP +#line 164 "frame/lex.L" +{return HIDE_;} + YY_BREAK +case 136: +YY_RULE_SETUP +#line 165 "frame/lex.L" +{return HIGHLITE_;} + YY_BREAK +case 137: +YY_RULE_SETUP +#line 166 "frame/lex.L" +{return HISTEQU_;} + YY_BREAK +case 138: +YY_RULE_SETUP +#line 167 "frame/lex.L" +{return HISTOGRAM_;} + YY_BREAK +case 139: +YY_RULE_SETUP +#line 168 "frame/lex.L" +{return HORIZONTAL_;} + YY_BREAK +case 140: +YY_RULE_SETUP +#line 169 "frame/lex.L" +{return ICRS_;} + YY_BREAK +case 141: +YY_RULE_SETUP +#line 170 "frame/lex.L" +{return ID_;} + YY_BREAK +case 142: +YY_RULE_SETUP +#line 171 "frame/lex.L" +{return IIS_;} + YY_BREAK +case 143: +YY_RULE_SETUP +#line 172 "frame/lex.L" +{return IMAGE_;} + YY_BREAK +case 144: +YY_RULE_SETUP +#line 173 "frame/lex.L" +{return INCLUDE_;} + YY_BREAK +case 145: +YY_RULE_SETUP +#line 174 "frame/lex.L" +{return INCR_;} + YY_BREAK +case 146: +YY_RULE_SETUP +#line 175 "frame/lex.L" +{return INFO_;} + YY_BREAK +case 147: +YY_RULE_SETUP +#line 176 "frame/lex.L" +{return INTEGER_;} + YY_BREAK +case 148: +YY_RULE_SETUP +#line 177 "frame/lex.L" +{return ITERATION_;} + YY_BREAK +case 149: +YY_RULE_SETUP +#line 178 "frame/lex.L" +{return IRAF_;} + YY_BREAK +case 150: +YY_RULE_SETUP +#line 179 "frame/lex.L" +{return IRAFMIN_;} + YY_BREAK +case 151: +YY_RULE_SETUP +#line 180 "frame/lex.L" +{return J2000_;} + YY_BREAK +case 152: +YY_RULE_SETUP +#line 181 "frame/lex.L" +{return KEY_;} + YY_BREAK +case 153: +YY_RULE_SETUP +#line 182 "frame/lex.L" +{return KEYWORD_;} + YY_BREAK +case 154: +YY_RULE_SETUP +#line 183 "frame/lex.L" +{return LABEL_;} + YY_BREAK +case 155: +YY_RULE_SETUP +#line 184 "frame/lex.L" +{return LENGTH_;} + YY_BREAK +case 156: +YY_RULE_SETUP +#line 185 "frame/lex.L" +{return LEVEL_;} + YY_BREAK +case 157: +YY_RULE_SETUP +#line 186 "frame/lex.L" +{return LITTLEENDIAN_;} + YY_BREAK +case 158: +YY_RULE_SETUP +#line 187 "frame/lex.L" +{return LITTLEENDIAN_;} + YY_BREAK +case 159: +YY_RULE_SETUP +#line 188 "frame/lex.L" +{return LINE_;} + YY_BREAK +case 160: +YY_RULE_SETUP +#line 189 "frame/lex.L" +{return LINEAR_;} + YY_BREAK +case 161: +YY_RULE_SETUP +#line 190 "frame/lex.L" +{return LIST_;} + YY_BREAK +case 162: +YY_RULE_SETUP +#line 191 "frame/lex.L" +{return LOAD_;} + YY_BREAK +case 163: +YY_RULE_SETUP +#line 192 "frame/lex.L" +{return LOCAL_;} + YY_BREAK +case 164: +YY_RULE_SETUP +#line 193 "frame/lex.L" +{return LOG_;} + YY_BREAK +case 165: +YY_RULE_SETUP +#line 194 "frame/lex.L" +{return MACOSX_;} + YY_BREAK +case 166: +YY_RULE_SETUP +#line 195 "frame/lex.L" +{return MAGNIFIER_;} + YY_BREAK +case 167: +YY_RULE_SETUP +#line 196 "frame/lex.L" +{return MATCH_;} + YY_BREAK +case 168: +YY_RULE_SETUP +#line 197 "frame/lex.L" +{return MAP_;} + YY_BREAK +case 169: +YY_RULE_SETUP +#line 198 "frame/lex.L" +{return MARK_;} + YY_BREAK +case 170: +YY_RULE_SETUP +#line 199 "frame/lex.L" +{return MARKER_;} + YY_BREAK +case 171: +YY_RULE_SETUP +#line 200 "frame/lex.L" +{return MASK_;} + YY_BREAK +case 172: +YY_RULE_SETUP +#line 201 "frame/lex.L" +{return MESSAGE_;} + YY_BREAK +case 173: +YY_RULE_SETUP +#line 202 "frame/lex.L" +{return METHOD_;} + YY_BREAK +case 174: +YY_RULE_SETUP +#line 203 "frame/lex.L" +{return MINMAX_;} + YY_BREAK +case 175: +YY_RULE_SETUP +#line 204 "frame/lex.L" +{return MIP_;} + YY_BREAK +case 176: +YY_RULE_SETUP +#line 205 "frame/lex.L" +{return MMAP_;} + YY_BREAK +case 177: +YY_RULE_SETUP +#line 206 "frame/lex.L" +{return MMAPINCR_;} + YY_BREAK +case 178: +YY_RULE_SETUP +#line 207 "frame/lex.L" +{return MODE_;} + YY_BREAK +case 179: +YY_RULE_SETUP +#line 208 "frame/lex.L" +{return MOSAIC_;} + YY_BREAK +case 180: +YY_RULE_SETUP +#line 209 "frame/lex.L" +{return MOTION_;} + YY_BREAK +case 181: +YY_RULE_SETUP +#line 210 "frame/lex.L" +{return MOVE_;} + YY_BREAK +case 182: +YY_RULE_SETUP +#line 211 "frame/lex.L" +{return NAME_;} + YY_BREAK +case 183: +YY_RULE_SETUP +#line 212 "frame/lex.L" +{return NAN_;} + YY_BREAK +case 184: +YY_RULE_SETUP +#line 213 "frame/lex.L" +{return NATIVE_;} + YY_BREAK +case 185: +YY_RULE_SETUP +#line 214 "frame/lex.L" +{return NAXES_;} + YY_BREAK +case 186: +YY_RULE_SETUP +#line 215 "frame/lex.L" +{return NEW_;} + YY_BREAK +case 187: +YY_RULE_SETUP +#line 216 "frame/lex.L" +{return NEXT_;} + YY_BREAK +case 188: +YY_RULE_SETUP +#line 217 "frame/lex.L" +{return NO_;} + YY_BREAK +case 189: +YY_RULE_SETUP +#line 218 "frame/lex.L" +{return NONE_;} + YY_BREAK +case 190: +YY_RULE_SETUP +#line 219 "frame/lex.L" +{return NOW_;} + YY_BREAK +case 191: +YY_RULE_SETUP +#line 220 "frame/lex.L" +{return NRRD_;} + YY_BREAK +case 192: +YY_RULE_SETUP +#line 221 "frame/lex.L" +{return NUMBER_;} + YY_BREAK +case 193: +YY_RULE_SETUP +#line 222 "frame/lex.L" +{return OBJECT_;} + YY_BREAK +case 194: +YY_RULE_SETUP +#line 223 "frame/lex.L" +{return OFF_;} + YY_BREAK +case 195: +YY_RULE_SETUP +#line 224 "frame/lex.L" +{return ON_;} + YY_BREAK +case 196: +YY_RULE_SETUP +#line 225 "frame/lex.L" +{return ONLY_;} + YY_BREAK +case 197: +YY_RULE_SETUP +#line 226 "frame/lex.L" +{return OPTION_;} + YY_BREAK +case 198: +YY_RULE_SETUP +#line 227 "frame/lex.L" +{return ORIENT_;} + YY_BREAK +case 199: +YY_RULE_SETUP +#line 228 "frame/lex.L" +{return PAN_;} + YY_BREAK +case 200: +YY_RULE_SETUP +#line 229 "frame/lex.L" +{return CPANDA_;} + YY_BREAK +case 201: +YY_RULE_SETUP +#line 230 "frame/lex.L" +{return PANNER_;} + YY_BREAK +case 202: +YY_RULE_SETUP +#line 231 "frame/lex.L" +{return PARSER_;} + YY_BREAK +case 203: +YY_RULE_SETUP +#line 232 "frame/lex.L" +{return PASTE_;} + YY_BREAK +case 204: +YY_RULE_SETUP +#line 233 "frame/lex.L" +{return PERF_;} + YY_BREAK +case 205: +YY_RULE_SETUP +#line 234 "frame/lex.L" +{return PHOTO_;} + YY_BREAK +case 206: +YY_RULE_SETUP +#line 235 "frame/lex.L" +{return PHYSICAL_;} + YY_BREAK +case 207: +YY_RULE_SETUP +#line 236 "frame/lex.L" +{return PIXEL_;} + YY_BREAK +case 208: +YY_RULE_SETUP +#line 237 "frame/lex.L" +{return PLOT2D_;} + YY_BREAK +case 209: +YY_RULE_SETUP +#line 238 "frame/lex.L" +{return PLOT3D_;} + YY_BREAK +case 210: +YY_RULE_SETUP +#line 239 "frame/lex.L" +{return POINT_;} + YY_BREAK +case 211: +YY_RULE_SETUP +#line 240 "frame/lex.L" +{return POINTER_;} + YY_BREAK +case 212: +YY_RULE_SETUP +#line 241 "frame/lex.L" +{return POLYGON_;} + YY_BREAK +case 213: +YY_RULE_SETUP +#line 242 "frame/lex.L" +{return POSTSCRIPT_;} + YY_BREAK +case 214: +YY_RULE_SETUP +#line 243 "frame/lex.L" +{return POW_;} + YY_BREAK +case 215: +YY_RULE_SETUP +#line 244 "frame/lex.L" +{return PRINT_;} + YY_BREAK +case 216: +YY_RULE_SETUP +#line 245 "frame/lex.L" +{return PRESERVE_;} + YY_BREAK +case 217: +YY_RULE_SETUP +#line 246 "frame/lex.L" +{return PROJECTION_;} + YY_BREAK +case 218: +YY_RULE_SETUP +#line 247 "frame/lex.L" +{return PROPERTY_;} + YY_BREAK +case 219: +YY_RULE_SETUP +#line 248 "frame/lex.L" +{return PROS_;} + YY_BREAK +case 220: +YY_RULE_SETUP +#line 249 "frame/lex.L" +{return PUBLICATION_;} + YY_BREAK +case 221: +YY_RULE_SETUP +#line 250 "frame/lex.L" +{return QUERY_;} + YY_BREAK +case 222: +YY_RULE_SETUP +#line 251 "frame/lex.L" +{return RADIAL_;} + YY_BREAK +case 223: +YY_RULE_SETUP +#line 252 "frame/lex.L" +{return RADIUS_;} + YY_BREAK +case 224: +YY_RULE_SETUP +#line 253 "frame/lex.L" +{return REGION_;} + YY_BREAK +case 225: +YY_RULE_SETUP +#line 254 "frame/lex.L" +{return REPLACE_;} + YY_BREAK +case 226: +YY_RULE_SETUP +#line 255 "frame/lex.L" +{return RESAMPLE_;} + YY_BREAK +case 227: +YY_RULE_SETUP +#line 256 "frame/lex.L" +{return RESET_;} + YY_BREAK +case 228: +YY_RULE_SETUP +#line 257 "frame/lex.L" +{return RESOLUTION_;} + YY_BREAK +case 229: +YY_RULE_SETUP +#line 258 "frame/lex.L" +{return RGB_;} + YY_BREAK +case 230: +YY_RULE_SETUP +#line 259 "frame/lex.L" +{return ROOT_;} + YY_BREAK +case 231: +YY_RULE_SETUP +#line 260 "frame/lex.L" +{return ROTATE_;} + YY_BREAK +case 232: +YY_RULE_SETUP +#line 261 "frame/lex.L" +{return RULER_;} + YY_BREAK +case 233: +YY_RULE_SETUP +#line 262 "frame/lex.L" +{return SAMPLE_;} + YY_BREAK +case 234: +YY_RULE_SETUP +#line 263 "frame/lex.L" +{return SAOIMAGE_;} + YY_BREAK +case 235: +YY_RULE_SETUP +#line 264 "frame/lex.L" +{return SAOTNG_;} + YY_BREAK +case 236: +YY_RULE_SETUP +#line 265 "frame/lex.L" +{return SAVE_;} + YY_BREAK +case 237: +YY_RULE_SETUP +#line 266 "frame/lex.L" +{return SCALE_;} + YY_BREAK +case 238: +YY_RULE_SETUP +#line 267 "frame/lex.L" +{return SCAN_;} + YY_BREAK +case 239: +YY_RULE_SETUP +#line 268 "frame/lex.L" +{return SCIENTIFIC_;} + YY_BREAK +case 240: +YY_RULE_SETUP +#line 269 "frame/lex.L" +{return SCOPE_;} + YY_BREAK +case 241: +YY_RULE_SETUP +#line 270 "frame/lex.L" +{return SEGMENT_;} + YY_BREAK +case 242: +YY_RULE_SETUP +#line 271 "frame/lex.L" +{return SELECT_;} + YY_BREAK +case 243: +YY_RULE_SETUP +#line 272 "frame/lex.L" +{return SET_;} + YY_BREAK +case 244: +YY_RULE_SETUP +#line 273 "frame/lex.L" +{return SEXAGESIMAL_;} + YY_BREAK +case 245: +YY_RULE_SETUP +#line 274 "frame/lex.L" +{return SHAPE_;} + YY_BREAK +case 246: +YY_RULE_SETUP +#line 275 "frame/lex.L" +{return SHARED_;} + YY_BREAK +case 247: +YY_RULE_SETUP +#line 276 "frame/lex.L" +{return SHIFT_;} + YY_BREAK +case 248: +YY_RULE_SETUP +#line 277 "frame/lex.L" +{return SHMID_;} + YY_BREAK +case 249: +YY_RULE_SETUP +#line 278 "frame/lex.L" +{return SHOW_;} + YY_BREAK +case 250: +YY_RULE_SETUP +#line 279 "frame/lex.L" +{return SINH_;} + YY_BREAK +case 251: +YY_RULE_SETUP +#line 280 "frame/lex.L" +{return SIZE_;} + YY_BREAK +case 252: +YY_RULE_SETUP +#line 281 "frame/lex.L" +{return SLICE_;} + YY_BREAK +case 253: +YY_RULE_SETUP +#line 282 "frame/lex.L" +{return SMMAP_;} + YY_BREAK +case 254: +YY_RULE_SETUP +#line 283 "frame/lex.L" +{return SMOOTH_;} + YY_BREAK +case 255: +YY_RULE_SETUP +#line 284 "frame/lex.L" +{return SOCKET_;} + YY_BREAK +case 256: +YY_RULE_SETUP +#line 285 "frame/lex.L" +{return SOCKETGZ_;} + YY_BREAK +case 257: +YY_RULE_SETUP +#line 286 "frame/lex.L" +{return SOURCE_;} + YY_BREAK +case 258: +YY_RULE_SETUP +#line 287 "frame/lex.L" +{return SQRT_;} + YY_BREAK +case 259: +YY_RULE_SETUP +#line 288 "frame/lex.L" +{return SQUARED_;} + YY_BREAK +case 260: +YY_RULE_SETUP +#line 289 "frame/lex.L" +{return SSHARED_;} + YY_BREAK +case 261: +YY_RULE_SETUP +#line 290 "frame/lex.L" +{return STATS_;} + YY_BREAK +case 262: +YY_RULE_SETUP +#line 291 "frame/lex.L" +{return STATUS_;} + YY_BREAK +case 263: +YY_RULE_SETUP +#line 292 "frame/lex.L" +{return SUM_;} + YY_BREAK +case 264: +YY_RULE_SETUP +#line 293 "frame/lex.L" +{return SUPERGALACTIC_;} + YY_BREAK +case 265: +YY_RULE_SETUP +#line 294 "frame/lex.L" +{return SYSTEM_;} + YY_BREAK +case 266: +YY_RULE_SETUP +#line 295 "frame/lex.L" +{return TABLE_;} + YY_BREAK +case 267: +YY_RULE_SETUP +#line 296 "frame/lex.L" +{return TAG_;} + YY_BREAK +case 268: +YY_RULE_SETUP +#line 297 "frame/lex.L" +{return TEMPLATE_;} + YY_BREAK +case 269: +YY_RULE_SETUP +#line 298 "frame/lex.L" +{return TEXT_;} + YY_BREAK +case 270: +YY_RULE_SETUP +#line 299 "frame/lex.L" +{return THREADS_;} + YY_BREAK +case 271: +YY_RULE_SETUP +#line 300 "frame/lex.L" +{return THREED_;} + YY_BREAK +case 272: +YY_RULE_SETUP +#line 301 "frame/lex.L" +{return THRESHOLD_;} + YY_BREAK +case 273: +YY_RULE_SETUP +#line 302 "frame/lex.L" +{return THICK_;} + YY_BREAK +case 274: +YY_RULE_SETUP +#line 303 "frame/lex.L" +{return TRANSPARENCY_;} + YY_BREAK +case 275: +YY_RULE_SETUP +#line 304 "frame/lex.L" +{return TO_;} + YY_BREAK +case 276: +YY_RULE_SETUP +#line 305 "frame/lex.L" +{return TOGGLE_;} + YY_BREAK +case 277: +YY_RULE_SETUP +#line 306 "frame/lex.L" +{return TOPHAT_;} + YY_BREAK +case 278: +YY_RULE_SETUP +#line 307 "frame/lex.L" +{return TRUE_;} + YY_BREAK +case 279: +YY_RULE_SETUP +#line 308 "frame/lex.L" +{return TYPE_;} + YY_BREAK +case 280: +YY_RULE_SETUP +#line 309 "frame/lex.L" +{return UNDO_;} + YY_BREAK +case 281: +YY_RULE_SETUP +#line 310 "frame/lex.L" +{return UNLOAD_;} + YY_BREAK +case 282: +YY_RULE_SETUP +#line 311 "frame/lex.L" +{return UNHIGHLITE_;} + YY_BREAK +case 283: +YY_RULE_SETUP +#line 312 "frame/lex.L" +{return UNSELECT_;} + YY_BREAK +case 284: +YY_RULE_SETUP +#line 313 "frame/lex.L" +{return UPDATE_;} + YY_BREAK +case 285: +YY_RULE_SETUP +#line 314 "frame/lex.L" +{return USER_;} + YY_BREAK +case 286: +YY_RULE_SETUP +#line 315 "frame/lex.L" +{return VALUE_;} + YY_BREAK +case 287: +YY_RULE_SETUP +#line 316 "frame/lex.L" +{return VAR_;} + YY_BREAK +case 288: +YY_RULE_SETUP +#line 317 "frame/lex.L" +{return VIEW_;} + YY_BREAK +case 289: +YY_RULE_SETUP +#line 318 "frame/lex.L" +{return VECTOR_;} + YY_BREAK +case 290: +YY_RULE_SETUP +#line 319 "frame/lex.L" +{return VERSION_;} + YY_BREAK +case 291: +YY_RULE_SETUP +#line 320 "frame/lex.L" +{return VERTEX_;} + YY_BREAK +case 292: +YY_RULE_SETUP +#line 321 "frame/lex.L" +{return VERTICAL_;} + YY_BREAK +case 293: +YY_RULE_SETUP +#line 322 "frame/lex.L" +{return WARP_;} + YY_BREAK +case 294: +YY_RULE_SETUP +#line 323 "frame/lex.L" +{return WCS_;} + YY_BREAK +case 295: +YY_RULE_SETUP +#line 324 "frame/lex.L" +{return WCSA_;} + YY_BREAK +case 296: +YY_RULE_SETUP +#line 325 "frame/lex.L" +{return WCSB_;} + YY_BREAK +case 297: +YY_RULE_SETUP +#line 326 "frame/lex.L" +{return WCSC_;} + YY_BREAK +case 298: +YY_RULE_SETUP +#line 327 "frame/lex.L" +{return WCSD_;} + YY_BREAK +case 299: +YY_RULE_SETUP +#line 328 "frame/lex.L" +{return WCSE_;} + YY_BREAK +case 300: +YY_RULE_SETUP +#line 329 "frame/lex.L" +{return WCSF_;} + YY_BREAK +case 301: +YY_RULE_SETUP +#line 330 "frame/lex.L" +{return WCSG_;} + YY_BREAK +case 302: +YY_RULE_SETUP +#line 331 "frame/lex.L" +{return WCSH_;} + YY_BREAK +case 303: +YY_RULE_SETUP +#line 332 "frame/lex.L" +{return WCSI_;} + YY_BREAK +case 304: +YY_RULE_SETUP +#line 333 "frame/lex.L" +{return WCSJ_;} + YY_BREAK +case 305: +YY_RULE_SETUP +#line 334 "frame/lex.L" +{return WCSK_;} + YY_BREAK +case 306: +YY_RULE_SETUP +#line 335 "frame/lex.L" +{return WCSL_;} + YY_BREAK +case 307: +YY_RULE_SETUP +#line 336 "frame/lex.L" +{return WCSM_;} + YY_BREAK +case 308: +YY_RULE_SETUP +#line 337 "frame/lex.L" +{return WCSN_;} + YY_BREAK +case 309: +YY_RULE_SETUP +#line 338 "frame/lex.L" +{return WCSO_;} + YY_BREAK +case 310: +YY_RULE_SETUP +#line 339 "frame/lex.L" +{return WCSP_;} + YY_BREAK +case 311: +YY_RULE_SETUP +#line 340 "frame/lex.L" +{return WCSQ_;} + YY_BREAK +case 312: +YY_RULE_SETUP +#line 341 "frame/lex.L" +{return WCSR_;} + YY_BREAK +case 313: +YY_RULE_SETUP +#line 342 "frame/lex.L" +{return WCSS_;} + YY_BREAK +case 314: +YY_RULE_SETUP +#line 343 "frame/lex.L" +{return WCST_;} + YY_BREAK +case 315: +YY_RULE_SETUP +#line 344 "frame/lex.L" +{return WCSU_;} + YY_BREAK +case 316: +YY_RULE_SETUP +#line 345 "frame/lex.L" +{return WCSV_;} + YY_BREAK +case 317: +YY_RULE_SETUP +#line 346 "frame/lex.L" +{return WCSW_;} + YY_BREAK +case 318: +YY_RULE_SETUP +#line 347 "frame/lex.L" +{return WCSX_;} + YY_BREAK +case 319: +YY_RULE_SETUP +#line 348 "frame/lex.L" +{return WCSY_;} + YY_BREAK +case 320: +YY_RULE_SETUP +#line 349 "frame/lex.L" +{return WCSZ_;} + YY_BREAK +case 321: +YY_RULE_SETUP +#line 350 "frame/lex.L" +{return WCS0_;} + YY_BREAK +case 322: +YY_RULE_SETUP +#line 351 "frame/lex.L" +{return WFPC2_;} + YY_BREAK +case 323: +YY_RULE_SETUP +#line 352 "frame/lex.L" +{return WIDTH_;} + YY_BREAK +case 324: +YY_RULE_SETUP +#line 353 "frame/lex.L" +{return WIN32_;} + YY_BREAK +case 325: +YY_RULE_SETUP +#line 354 "frame/lex.L" +{return XML_;} + YY_BREAK +case 326: +YY_RULE_SETUP +#line 355 "frame/lex.L" +{return XY_;} + YY_BREAK +case 327: +YY_RULE_SETUP +#line 356 "frame/lex.L" +{return YES_;} + YY_BREAK +case 328: +YY_RULE_SETUP +#line 357 "frame/lex.L" +{return ZMAX_;} + YY_BREAK +case 329: +YY_RULE_SETUP +#line 358 "frame/lex.L" +{return ZSCALE_;} + YY_BREAK +case 330: +YY_RULE_SETUP +#line 359 "frame/lex.L" +{return ZOOM_;} + YY_BREAK +case 331: +YY_RULE_SETUP +#line 361 "frame/lex.L" +{ // Integer + frlval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 332: +#line 367 "frame/lex.L" +case 333: +YY_RULE_SETUP +#line 367 "frame/lex.L" +{ // Real Number + frlval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 334: +YY_RULE_SETUP +#line 372 "frame/lex.L" +{ // Pointer + frlval->ptr = (void*)strtoul(yytext,NULL,16); + return POINTER; + } + YY_BREAK +case 335: +#line 378 "frame/lex.L" +case 336: +YY_RULE_SETUP +#line 378 "frame/lex.L" +{ // degrees + yytext[yyleng-1] = '\0'; + frlval->real = atof(yytext); + return ANGDEGREE; + } + YY_BREAK +case 337: +#line 385 "frame/lex.L" +case 338: +YY_RULE_SETUP +#line 385 "frame/lex.L" +{ // radians + yytext[yyleng-1] = '\0'; + frlval->real = atof(yytext); + return ANGRADIAN; + } + YY_BREAK +case 339: +#line 392 "frame/lex.L" +case 340: +YY_RULE_SETUP +#line 392 "frame/lex.L" +{ // sexagesimal + int ll = yyleng <(FRBUFSIZE-1) ? yyleng:(FRBUFSIZE-1); + strncpy(frlval->str,yytext,ll); + frlval->str[ll] = '\0'; + return SEXSTR; + } + YY_BREAK +case 341: +#line 400 "frame/lex.L" +case 342: +YY_RULE_SETUP +#line 400 "frame/lex.L" +{ // HMS + int ll = yyleng <(FRBUFSIZE-1) ? yyleng:(FRBUFSIZE-1); + strncpy(frlval->str,yytext,ll); + frlval->str[ll] = '\0'; + return HMSSTR; + } + YY_BREAK +case 343: +#line 408 "frame/lex.L" +case 344: +YY_RULE_SETUP +#line 408 "frame/lex.L" +{ // DMS + int ll = yyleng <(FRBUFSIZE-1) ? yyleng:(FRBUFSIZE-1); + strncpy(frlval->str,yytext,ll); + frlval->str[ll] = '\0'; + return DMSSTR; + } + YY_BREAK +case 345: +/* rule 345 can match eol */ +#line 416 "frame/lex.L" +case 346: +/* rule 346 can match eol */ +YY_RULE_SETUP +#line 416 "frame/lex.L" +{ // Quoted String + int ll = (yyleng-2)<(FRBUFSIZE-1) ? (yyleng-2):(FRBUFSIZE-1); + strncpy(frlval->str,yytext+1,ll); // skip the " " + frlval->str[ll] = '\0'; // Remove the '"' + return STRING; + } + YY_BREAK +case 347: +/* rule 347 can match eol */ +YY_RULE_SETUP +#line 423 "frame/lex.L" +{ // Quoted String + int ll = (yyleng-2)<(FRBUFSIZE-1) ? (yyleng-2):(FRBUFSIZE-1); + strncpy(frlval->str,yytext+1,ll); // skip the '{' + frlval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + YY_BREAK +case 348: +YY_RULE_SETUP +#line 430 "frame/lex.L" +{ // General String-- at least 2 printable chars + int ll = yyleng <(FRBUFSIZE-1) ? yyleng:(FRBUFSIZE-1); + strncpy(frlval->str,yytext,ll); + frlval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 349: +YY_RULE_SETUP +#line 437 "frame/lex.L" +{ // White Spaces + } + YY_BREAK +case 350: +YY_RULE_SETUP +#line 440 "frame/lex.L" +{ // Else, return the char + return toupper(yytext[0]); + } + YY_BREAK +case 351: +YY_RULE_SETUP +#line 444 "frame/lex.L" +ECHO; + YY_BREAK +#line 3472 "frame/lex.C" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + frfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + frfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + frrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) frrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 1268 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 1268 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 1267); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) fralloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) fralloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + frfree((void *) b->yy_ch_buf ); + + frfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)fralloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)frrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) fralloc(new_size ); + + else + (yy_start_stack) = (int *) frrealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *fralloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *frrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void frfree (void * ptr ) +{ + free( (char *) ptr ); /* see frrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 444 "frame/lex.L" + + + diff --git a/tksao/frame/lex.L b/tksao/frame/lex.L new file mode 100644 index 0000000..8bc1960 --- /dev/null +++ b/tksao/frame/lex.L @@ -0,0 +1,444 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ + +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + #include + + #include "util.h" + #include "parser.H" + + extern YYSTYPE* frlval; +%} + +D [0-9] +E [Ee][+-]?{D}+ + +/* rules */ + +%% + +about {return ABOUT_;} +aip {return AIP_;} +alloc {return ALLOC_;} +allocgz {return ALLOCGZ_;} +align {return ALIGN_;} +all {return ALL_;} +alt {return ALT_;} +amplifier {return AMPLIFIER_;} +analysis {return ANALYSIS_;} +angle {return ANGLE_;} +annulus {return ANNULUS_;} +append {return APPEND_;} +arcmin {return ARCMIN_;} +arcsec {return ARCSEC_;} +array {return ARRAY_;} +arrow {return ARROW_;} +asinh {return ASINH_;} +ast {return AST_;} +auto {return AUTO_;} +aux {return AUX_;} +average {return AVERAGE_;} +axes {return AXES_;} +azimuth {return AZIMUTH_;} +b1950 {return B1950_;} +back {return BACK_;} +background {return BACKGROUND_;} +base {return BASE_;} +bbox {return BBOX_;} +begin {return BEGIN_;} +bg {return BG_;} +big {return BIGENDIAN_;} +bigendian {return BIGENDIAN_;} +bin {return BIN_;} +bitpix {return BITPIX_;} +block {return BLOCK_;} +border {return BORDER_;} +box {return BOX_;} +boxannulus {return BOXANNULUS_;} +boxcar {return BOXCAR_;} +boxcircle {return BOXCIRCLE_;} +bpanda {return BPANDA_;} +buffer {return BUFFER_;} +bw {return BW_;} +callback {return CALLBACK_;} +canvas {return CANVAS_;} +catalog {return CATALOG_;} +celestrial {return CELESTRIAL_;} +center {return CENTER_;} +centroid {return CENTROID_;} +channel {return CHANNEL_;} +ciao {return CIAO_;} +circle {return CIRCLE_;} +clear {return CLEAR_;} +clip {return CLIP_;} +color {return COLOR_;} +colorbar {return COLORBAR_;} +colormap {return COLORMAP_;} +colorscale {return COLORSCALE_;} +colorspace {return COLORSPACE_;} +cols {return COLS_;} +column {return COLUMN_;} +command {return COMMAND_;} +compass {return COMPASS_;} +composite {return COMPOSITE_;} +compress {return COMPRESS_;} +contour {return CONTOUR_;} +contrast {return CONTRAST_;} +coordinates {return COORDINATES_;} +copy {return COPY_;} +count {return COUNT_;} +crop {return CROP_;} +cross {return CROSS_;} +cpanda {return CPANDA_;} +create {return CREATE_;} +crosshair {return CROSSHAIR_;} +cube {return CUBE_;} +cursor {return CURSOR_;} +cut {return CUT_;} +cmyk {return CMYK_;} +dash {return DASH_;} +dashlist {return DASHLIST_;} +data {return DATA_;} +datamin {return DATAMIN_;} +datasec {return DATASEC_;} +debug {return DEBUG_;} +degrees {return DEGREES_;} +default {return DEFAULT_;} +delete {return DELETE_;} +depth {return DEPTH_;} +detector {return DETECTOR_;} +diamond {return DIAMOND_;} +dim {return DIM_;} +ds9 {return DS9_;} +ecliptic {return ECLIPTIC_;} +elevation {return ELEVATION_;} +ellipse {return ELLIPSE_;} +ellipseannulus {return ELLIPSEANNULUS_;} +edit {return EDIT_;} +end {return END_;} +envi {return ENVI_;} +epanda {return EPANDA_;} +epsilon {return EPSILON_;} +equatorial {return EQUATORIAL_;} +erase {return ERASE_;} +ext {return EXT_;} +factor {return FACTOR_;} +false {return FALSE_;} +file {return FILE_;} +filter {return FILTER_;} +fit {return FIT_;} +fits {return FITS_;} +fitsy {return FITSY_;} +fixed {return FIXED_;} +fk4 {return FK4_;} +fk4-no-e {return FK4_NO_E_;} +fk5 {return FK5_;} +font {return FONT_;} +front {return FRONT_;} +full {return FULL_;} +function {return FUNCTION_;} +galactic {return GALACTIC_;} +gaussian {return GAUSSIAN_;} +get {return GET_;} +global {return GLOBAL_;} +graphics {return GRAPHICS_;} +gray {return GRAY_;} +grid {return GRID_;} +gz {return GZ_;} +handle {return HANDLE_;} +has {return HAS_;} +head {return HEAD_;} +header {return HEADER_;} +height {return HEIGHT_;} +helioecliptic {return HELIOECLIPTIC_;} +hide {return HIDE_;} +highlite {return HIGHLITE_;} +histequ {return HISTEQU_;} +histogram {return HISTOGRAM_;} +horizontal {return HORIZONTAL_;} +icrs {return ICRS_;} +id {return ID_;} +iis {return IIS_;} +image {return IMAGE_;} +include {return INCLUDE_;} +incr {return INCR_;} +info {return INFO_;} +integer {return INTEGER_;} +iteration {return ITERATION_;} +iraf {return IRAF_;} +irafmin {return IRAFMIN_;} +j2000 {return J2000_;} +key {return KEY_;} +keyword {return KEYWORD_;} +label {return LABEL_;} +length {return LENGTH_;} +level {return LEVEL_;} +little {return LITTLEENDIAN_;} +littleendian {return LITTLEENDIAN_;} +line {return LINE_;} +linear {return LINEAR_;} +list {return LIST_;} +load {return LOAD_;} +local {return LOCAL_;} +log {return LOG_;} +macosx {return MACOSX_;} +magnifier {return MAGNIFIER_;} +match {return MATCH_;} +map {return MAP_;} +mark {return MARK_;} +marker {return MARKER_;} +mask {return MASK_;} +message {return MESSAGE_;} +method {return METHOD_;} +minmax {return MINMAX_;} +mip {return MIP_;} +mmap {return MMAP_;} +mmapincr {return MMAPINCR_;} +mode {return MODE_;} +mosaic {return MOSAIC_;} +motion {return MOTION_;} +move {return MOVE_;} +name {return NAME_;} +nan {return NAN_;} +native {return NATIVE_;} +naxes {return NAXES_;} +new {return NEW_;} +next {return NEXT_;} +no {return NO_;} +none {return NONE_;} +now {return NOW_;} +nrrd {return NRRD_;} +number {return NUMBER_;} +object {return OBJECT_;} +off {return OFF_;} +on {return ON_;} +only {return ONLY_;} +option {return OPTION_;} +orient {return ORIENT_;} +pan {return PAN_;} +panda {return CPANDA_;} +panner {return PANNER_;} +parser {return PARSER_;} +paste {return PASTE_;} +perf {return PERF_;} +photo {return PHOTO_;} +physical {return PHYSICAL_;} +pixel {return PIXEL_;} +plot2d {return PLOT2D_;} +plot3d {return PLOT3D_;} +point {return POINT_;} +pointer {return POINTER_;} +polygon {return POLYGON_;} +postscript {return POSTSCRIPT_;} +pow {return POW_;} +print {return PRINT_;} +preserve {return PRESERVE_;} +projection {return PROJECTION_;} +property {return PROPERTY_;} +pros {return PROS_;} +publication {return PUBLICATION_;} +query {return QUERY_;} +radial {return RADIAL_;} +radius {return RADIUS_;} +region {return REGION_;} +replace {return REPLACE_;} +resample {return RESAMPLE_;} +reset {return RESET_;} +resolution {return RESOLUTION_;} +rgb {return RGB_;} +root {return ROOT_;} +rotate {return ROTATE_;} +ruler {return RULER_;} +sample {return SAMPLE_;} +saoimage {return SAOIMAGE_;} +saotng {return SAOTNG_;} +save {return SAVE_;} +scale {return SCALE_;} +scan {return SCAN_;} +scientific {return SCIENTIFIC_;} +scope {return SCOPE_;} +segment {return SEGMENT_;} +select {return SELECT_;} +set {return SET_;} +sexagesimal {return SEXAGESIMAL_;} +shape {return SHAPE_;} +shared {return SHARED_;} +shift {return SHIFT_;} +shmid {return SHMID_;} +show {return SHOW_;} +sinh {return SINH_;} +size {return SIZE_;} +slice {return SLICE_;} +smmap {return SMMAP_;} +smooth {return SMOOTH_;} +socket {return SOCKET_;} +socketgz {return SOCKETGZ_;} +source {return SOURCE_;} +sqrt {return SQRT_;} +squared {return SQUARED_;} +sshared {return SSHARED_;} +stats {return STATS_;} +status {return STATUS_;} +sum {return SUM_;} +supergalactic {return SUPERGALACTIC_;} +system {return SYSTEM_;} +table {return TABLE_;} +tag {return TAG_;} +template {return TEMPLATE_;} +text {return TEXT_;} +threads {return THREADS_;} +3d {return THREED_;} +threshold {return THRESHOLD_;} +thick {return THICK_;} +transparency {return TRANSPARENCY_;} +to {return TO_;} +toggle {return TOGGLE_;} +tophat {return TOPHAT_;} +true {return TRUE_;} +type {return TYPE_;} +undo {return UNDO_;} +unload {return UNLOAD_;} +unhighlite {return UNHIGHLITE_;} +unselect {return UNSELECT_;} +update {return UPDATE_;} +user {return USER_;} +value {return VALUE_;} +var {return VAR_;} +view {return VIEW_;} +vector {return VECTOR_;} +version {return VERSION_;} +vertex {return VERTEX_;} +vertical {return VERTICAL_;} +warp {return WARP_;} +wcs {return WCS_;} +wcsa {return WCSA_;} +wcsb {return WCSB_;} +wcsc {return WCSC_;} +wcsd {return WCSD_;} +wcse {return WCSE_;} +wcsf {return WCSF_;} +wcsg {return WCSG_;} +wcsh {return WCSH_;} +wcsi {return WCSI_;} +wcsj {return WCSJ_;} +wcsk {return WCSK_;} +wcsl {return WCSL_;} +wcsm {return WCSM_;} +wcsn {return WCSN_;} +wcso {return WCSO_;} +wcsp {return WCSP_;} +wcsq {return WCSQ_;} +wcsr {return WCSR_;} +wcss {return WCSS_;} +wcst {return WCST_;} +wcsu {return WCSU_;} +wcsv {return WCSV_;} +wcsw {return WCSW_;} +wcsx {return WCSX_;} +wcsy {return WCSY_;} +wcsz {return WCSZ_;} +wcs0 {return WCS0_;} +wfpc2 {return WFPC2_;} +width {return WIDTH_;} +win32 {return WIN32_;} +xml {return XML_;} +xy {return XY_;} +yes {return YES_;} +zmax {return ZMAX_;} +zscale {return ZSCALE_;} +zoom {return ZOOM_;} + +[+-]?{D}+ { // Integer + frlval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + frlval->real = atof(yytext); + return REAL; + } + +0[xX][0-9a-fA-F]+ { // Pointer + frlval->ptr = (void*)strtoul(yytext,NULL,16); + return POINTER; + } + +[+-]?{D}+"."?d | +[+-]?{D}*"."{D}+d { // degrees + yytext[yyleng-1] = '\0'; + frlval->real = atof(yytext); + return ANGDEGREE; + } + +[+-]{D}+"."?r | +[+-]{D}*"."{D}+r { // radians + yytext[yyleng-1] = '\0'; + frlval->real = atof(yytext); + return ANGRADIAN; + } + +[+-]?{D}+:{D}+:{D}+"."? | +[+-]?{D}+:{D}+:{D}*"."{D}+ { // sexagesimal + int ll = yyleng <(FRBUFSIZE-1) ? yyleng:(FRBUFSIZE-1); + strncpy(frlval->str,yytext,ll); + frlval->str[ll] = '\0'; + return SEXSTR; + } + +[+-]?{D}+h{D}+m{D}+"."?s | +[+-]?{D}+h{D}+m{D}*"."{D}+s { // HMS + int ll = yyleng <(FRBUFSIZE-1) ? yyleng:(FRBUFSIZE-1); + strncpy(frlval->str,yytext,ll); + frlval->str[ll] = '\0'; + return HMSSTR; + } + +[+-]?{D}+d{D}+m{D}+"."?s | +[+-]?{D}+d{D}+m{D}*"."{D}+s { // DMS + int ll = yyleng <(FRBUFSIZE-1) ? yyleng:(FRBUFSIZE-1); + strncpy(frlval->str,yytext,ll); + frlval->str[ll] = '\0'; + return DMSSTR; + } + +\"[^\"]*\" | +\'[^\']*\' { // Quoted String + int ll = (yyleng-2)<(FRBUFSIZE-1) ? (yyleng-2):(FRBUFSIZE-1); + strncpy(frlval->str,yytext+1,ll); // skip the " " + frlval->str[ll] = '\0'; // Remove the '"' + return STRING; + } + +\{[^\}]*\} { // Quoted String + int ll = (yyleng-2)<(FRBUFSIZE-1) ? (yyleng-2):(FRBUFSIZE-1); + strncpy(frlval->str,yytext+1,ll); // skip the '{' + frlval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + +[!-~][!-~]+ { // General String-- at least 2 printable chars + int ll = yyleng <(FRBUFSIZE-1) ? yyleng:(FRBUFSIZE-1); + strncpy(frlval->str,yytext,ll); + frlval->str[ll] = '\0'; + return STRING; + } + +[ \t]+ { // White Spaces + } + +. { // Else, return the char + return toupper(yytext[0]); + } + +%% diff --git a/tksao/frame/line.C b/tksao/frame/line.C new file mode 100644 index 0000000..70b005d --- /dev/null +++ b/tksao/frame/line.C @@ -0,0 +1,318 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "line.h" +#include "fitsimage.h" + +Line::Line(Base* p, const Vector& ptr1, const Vector& ptr2) + : BaseLine(p, ptr1, ptr2) +{ + p1Arrow = 0; + p2Arrow = 0; + + strcpy(type_,"line"); + handle = new Vector[2]; + numHandle = 2; + + updateBBox(); +} + +Line::Line(Base* p, const Vector& ptr1, const Vector& ptr2, + int a1, int a2, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BaseLine(p, ptr1, ptr2, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + p1Arrow = a1; + p2Arrow = a2; + + strcpy(type_,"line"); + handle = new Vector[2]; + numHandle = 2; + + updateBBox(); +} + +Line::Line(const Line& a) : BaseLine(a) +{ + p1Arrow = a.p1Arrow; + p2Arrow = a.p2Arrow; +} + +void Line::renderX(Drawable drawable, Coord::InternalSystem sys, RenderMode mode) +{ + GC lgc = renderXGC(mode); + + Vector aa = parent->mapFromRef(p1,sys); + Vector bb = parent->mapFromRef(p2,sys); + + if (p1Arrow) { + aa = modifyArrow(p2,p1,sys); + renderXArrow(drawable,p2,p1,sys,lgc); + } + + if (p2Arrow) { + bb = modifyArrow(p1,p2,sys); + renderXArrow(drawable,p1,p2,sys,lgc); + } + + XDrawLine(display, drawable, lgc, aa[0], aa[1], bb[0], bb[1]); +} + +void Line::renderPS(int mode) +{ + renderPSGC(mode); + + Vector aa = parent->mapFromRef(p1,Coord::CANVAS); + Vector bb = parent->mapFromRef(p2,Coord::CANVAS); + + if (p1Arrow) { + aa = modifyArrow(p2,p1,Coord::CANVAS); + renderPSArrow(p2,p1,Coord::CANVAS); + } + + if (p2Arrow) { + bb = modifyArrow(p1,p2,Coord::CANVAS); + renderPSArrow(p1,p2,Coord::CANVAS); + } + + ostringstream str; + str << "newpath " + << aa.TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << bb.TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +#ifdef MAC_OSX_TK +void Line::renderMACOSX() +{ + renderMACOSXGC(); + + Vector aa = parent->mapFromRef(p1,Coord::CANVAS); + Vector bb = parent->mapFromRef(p2,Coord::CANVAS); + + if (p1Arrow) { + aa = modifyArrow(p2,p1,Coord::CANVAS); + renderMACOSXArrow(p2,p1,Coord::CANVAS); + } + + if (p2Arrow) { + bb = modifyArrow(p1,p2,Coord::CANVAS); + renderMACOSXArrow(p1,p2,Coord::CANVAS); + } + + macosxDrawLine(aa,bb); +} +#endif + +#ifdef __WIN32 +void Line::renderWIN32() +{ + renderWIN32GC(); + + Vector aa = parent->mapFromRef(p1,Coord::CANVAS); + Vector bb = parent->mapFromRef(p2,Coord::CANVAS); + + if (p1Arrow) { + aa = modifyArrow(p2,p1,Coord::CANVAS); + renderWIN32Arrow(p2,p1,Coord::CANVAS); + } + + if (p2Arrow) { + bb = modifyArrow(p1,p2,Coord::CANVAS); + renderWIN32Arrow(p1,p2,Coord::CANVAS); + } + + win32DrawLine(aa,bb); +} +#endif + +// Support + +void Line::updateHandles() +{ + center = (p2-p1)/2 + p1; + angle = (p2-p1).angle(); + + // generate handles in Coord::CANVAS coords + handle[0] = parent->mapFromRef(p1,Coord::CANVAS); + handle[1] = parent->mapFromRef(p2,Coord::CANVAS); +} + +void Line::setArrows(int w1, int w2) +{ + p1Arrow = w1 ? 1 : 0; + p2Arrow = w2 ? 1 : 0; + updateBBox(); +} + +void Line::analysis(AnalysisTask mm, int which) +{ + switch (mm) { + case PLOT2D: + if (!analysisPlot2d_ && which) { + addCallBack(CallBack::MOVECB, analysisPlot2dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisPlot2dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisPlot2dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisPlot2dCB_[1], + parent->options->cmdName); + } + if (analysisPlot2d_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisPlot2dCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisPlot2dCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisPlot2dCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisPlot2dCB_[1]); + } + + analysisPlot2d_ = which; + break; + default: + // na + break; + } +} + +void Line::analysisPlot2d(char* xname, char* yname, + char* xcname, char* ycname, + Coord::CoordSystem sys, Coord::SkyFrame sky, + Marker::AnalysisMethod method) +{ + double* x; + double* y; + double* xc; + double* yc; + + int num = parent->markerAnalysisPlot2d(this, &x, &y, &xc, &yc, p1, p2, 0, + sys, sky, method); + analysisXYEEResult(xname, yname, xcname, ycname, x, y, xc, yc, num); +} + +// list + +void Line::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 0); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listNonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector v1 = ptr->mapFromRef(p1,sys,sky); + Vector v2 = ptr->mapFromRef(p2,sys,sky); + str << type_ << '(' << setprecision(10) << v1 << ',' << v2 << ')'; + } + break; + case Coord::SEXAGESIMAL: + str << type_ << '('; + listRADEC(ptr,p1,sys,sky,format); + str << ra << ',' << dec << ','; + listRADEC(ptr,p2,sys,sky,format); + str << ra << ',' << dec << ')'; + break; + } + } + else + listNonCel(ptr, str, sys); + } + + listPost(str, conj, strip); +} + +void Line::listPost(ostream& str, int conj, int strip) +{ + // no props for semicolons + if (!strip) { + if (conj) + str << " ||"; + + str << " # line=" << p1Arrow << ' ' << p2Arrow; + + listProperties(str, 0); + } + else { + if (conj) + str << "||"; + else + str << ';'; + } +} + +void Line::listXML(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + FitsImage* ptr = parent->findFits(sys,center); + Vector vv[2]; + vv[0] = p1; + vv[1] = p2; + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowPoint(ptr,sys,sky,format,vv,2); + XMLRow(XMLPARAM,p1Arrow); + XMLRow(XMLPARAM2,p2Arrow); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} + +void Line::listSAOtng(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int strip) +{ + FitsImage* ptr = parent->findFits(); + listSAOtngPre(str, strip); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + Vector v1 = ptr->mapFromRef(p1,Coord::IMAGE); + Vector v2 = ptr->mapFromRef(p2,Coord::IMAGE); + str << type_ << '(' << setprecision(8) << v1 << ',' << v2 << ')'; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector v1 = ptr->mapFromRef(p1,sys,sky); + Vector v2 = ptr->mapFromRef(p2,sys,sky); + str << type_ << '(' << setprecision(10) << v1 << ',' << v2 << ')'; + } + break; + case Coord::SEXAGESIMAL: + str << type_ << '('; + listRADEC(ptr,p1,sys,sky,format); + str << ra << ',' << dec << ','; + listRADEC(ptr,p2,sys,sky,format); + str << ra << ',' << dec << ')'; + break; + } + } + } + + listSAOtngPost(str, strip); +} diff --git a/tksao/frame/line.h b/tksao/frame/line.h new file mode 100644 index 0000000..68d20b8 --- /dev/null +++ b/tksao/frame/line.h @@ -0,0 +1,55 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __line_h__ +#define __line_h__ + +#include "baseline.h" + +class Line : public BaseLine { +protected: + int p1Arrow; + int p2Arrow; + +protected: + void renderX(Drawable, Coord::InternalSystem, RenderMode); + void renderPS(int); +#ifdef MAC_OSX_TK + void renderMACOSX(); +#endif +#ifdef __WIN32 + void renderWIN32(); +#endif + + void updateHandles(); + +public: + Line(Base* p, const Vector& ptr1, const Vector& ptr2); + Line(Base* p, const Vector& ptr1, + const Vector& ptr2, + int a1, int a2, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + Line(const Line&); + + virtual Marker* dup() {return new Line(*this);} + + void setArrows(int,int); + int getP1Arrow() {return p1Arrow;} + int getP2Arrow() {return p2Arrow;} + + void analysis(AnalysisTask, int); + void analysisPlot2d(char*, char*, char*, char*, + Coord::CoordSystem, Coord::SkyFrame, + Marker::AnalysisMethod); + + virtual void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + virtual void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + virtual void listPost(ostream&, int, int); + void listSAOtng(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); +}; + +#endif diff --git a/tksao/frame/marker.C b/tksao/frame/marker.C new file mode 100644 index 0000000..3ca7da0 --- /dev/null +++ b/tksao/frame/marker.C @@ -0,0 +1,2157 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "marker.h" +#include "fitsimage.h" + +extern "C" { +#include "tkbltVector.h" +} + +static int markerSeqID = 1; + +// hard coded +const char* Marker::analysisHistogramCB_[] = { + "MarkerAnalysisHistogramCB", + "MarkerAnalysisHistogramDeleteCB" +}; + +const char* Marker::analysisPlot2dCB_[] = { + "MarkerAnalysisPlot2dCB", + "MarkerAnalysisPlot2dDeleteCB" +}; + +const char* Marker::analysisPlot3dCB_[] = { + "MarkerAnalysisPlot3dCB", + "MarkerAnalysisPlot3dDeleteCB" +}; + +const char* Marker::analysisPandaCB_[] = { + "MarkerAnalysisPandaCB", + "MarkerAnalysisPandaDeleteCB" +}; + +const char* Marker::analysisRadialCB_[] = { + "MarkerAnalysisRadialCB", + "MarkerAnalysisRadialDeleteCB" +}; + +const char* Marker::analysisStatsCB_[] = { + "MarkerAnalysisStatsCB", + "MarkerAnalysisStatsDeleteCB" +}; + +// Marker Members Public + +Marker::Marker(Base* p, const Vector& ctr, double ang) +{ + id = markerSeqID++; + type_[0] = '\0'; + parent = p; + + center = ctr; + + angle = ang; + + handle = NULL; + numHandle = 0; + + colorName = dupstr("green"); + color = parent->getColor(colorName); + lineWidth = 1; + properties = INCLUDE|SOURCE; + selected = 0; + highlited = 0; + + dlist[0] = 8; + dlist[1] = 3; + + text = dupstr(""); + tkfont_ =NULL; + psfont_ =NULL; + initFonts("helvetica 10 normal roman"); + + comment = dupstr(""); + + display = parent->display; + gc = parent->markerGC; + gcxor = parent->markerGCXOR; + + for (int ii=0; ii& tg, const List& cb) +{ + id = markerSeqID++; + type_[0] = '\0'; + parent = p; + + center = ctr; + + angle = ang; + + handle = NULL; + numHandle = 0; + + colorName = dupstr(clr); + color = parent->getColor(colorName); + lineWidth = w; + properties = prop; + selected = 0; + highlited = 0; + + dlist[0] = dsh[0]; + dlist[1] = dsh[1]; + + text = dupstr(t); + tkfont_ =NULL; + psfont_ =NULL; + initFonts(f); + + comment = dupstr(c); + + display = parent->display; + gc = parent->markerGC; + gcxor = parent->markerGCXOR; + + for (int ii=0; iiinterp, parent->tkwin, Tk_NameOfFont(a.tkfont_)) : NULL; + psfont_ = a.psfont_ ? Tk_GetFont(parent->interp, parent->tkwin, Tk_NameOfFont(a.psfont_)) : NULL; + comment = dupstr(a.comment); + + display = a.display; + gc = a.gc; + gcxor = a.gcxor; + + for (int ii=0; iicanvasToWidget).round(); + Vector ur = (handle[2]*parent->canvasToWidget).round(); + + if (mode==SRC) + XSetForeground(display, gc, parent->getColor("red")); + + XDrawLine(display, drawable, lgc, ll[0], ll[1], ur[0], ur[1]); + } +} + +void Marker::renderXText(Drawable drawable, Coord::InternalSystem sys, RenderMode mode) +{ + if (text && *text && tkfont_) { + GC lgc; + switch (mode) { + case SRC: + lgc = gc; + XSetForeground(display, gc, color); + break; + case XOR: + lgc = gcxor; + break; + } + + XSetFont(display, lgc, Tk_FontId(tkfont_)); + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(tkfont_, &metrics); + int width = Tk_TextWidth(tkfont_, text, strlen(text)); + + Matrix mm; + Matrix nn; + setMatrices(sys,&mm,&nn); + + Vector ll0 = bbox.ll*parent->canvasToRef; + Vector ll = ll0*mm; + Vector ur0 = bbox.ur*parent->canvasToRef; + Vector ur = ur0*mm; + BBox bb(ll,ur); + + Vector bbc = bb.center(); + Vector tt = Vector(bbc[0], bb.ll[1]) * + Translate(-width/2., -metrics.descent); + + Tk_DrawChars(display, drawable, lgc, tkfont_, text, strlen(text), + tt[0], tt[1]); + } +} + +void Marker::renderXArrow(Drawable drawable, const Vector& p1, + const Vector& p2, Coord::InternalSystem sys, GC lgc) +{ + Vector* vv = arrow(p1,p2,sys); + XPoint dd[6]; + for (int ii=0; ii<6; ii++) { + dd[ii].x = (short)vv[ii][0]; + dd[ii].y = (short)vv[ii][1]; + } + + XFillPolygon(display, drawable, lgc, dd, 6, Nonconvex, CoordModeOrigin); + delete [] vv; +} + +void Marker::renderXHandles(Drawable drawable) +{ + // handles are of length 5 + if (selected && canSelect()) { + XSetForeground(display, gc, color); + + for (int ii=0; iicanvasToWidget - Vector(2,2)).round(); + XFillRectangle(display, drawable, gc, vv[0], vv[1], 5, 5); + } + } +} + +GC Marker::renderXGC(RenderMode mode) +{ + // set width, color, dash + switch (mode) { + case SRC: + XSetForeground(display, gc, color); + if ((properties & SOURCE) && !(properties & DASH)) + renderXLineNoDash(gc); + else + renderXLineDash(gc); + return gc; + + case XOR: + renderXLineDash(gcxor); + return gcxor; + } +} + +void Marker::renderXLineDash(GC lgc) +{ + char dl[2]; + dl[0] = dlist[0]; + dl[1] = dlist[1]; + + int ww = (highlited && canHighlite()) ? lineWidth*2 : lineWidth; + XSetDashes(display, lgc, 0, dl, 2); + XSetLineAttributes(display, lgc, ww, LineOnOffDash, CapButt, JoinMiter); +} + +void Marker::renderXLineNoDash(GC lgc) +{ + int ww = (highlited && canHighlite()) ? lineWidth*2 : lineWidth; + XSetLineAttributes(display, lgc, ww, LineSolid, CapButt, JoinMiter); +} + +void Marker::ps(int mode, int tt) +{ + if (properties & HIDDEN) + return; + + if (tt) + renderPSText(mode); + + renderPS(mode); + renderPSInclude(mode); +} + +void Marker::renderPSInclude(int mode) +{ + if (!(properties & INCLUDE)) { + renderPSColor(mode, parent->getXColor("red")); + + Vector ll = handle[0]; + Vector ur = handle[2]; + + ostringstream str; + str << "newpath " + << ll.TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << ur.TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } +} + +void Marker::renderPSText(int mode) +{ + if (text && *text && psfont_) { + renderPSColor(mode, parent->getXColor(colorName)); + + ostringstream str; + + const char* ff = Tk_NameOfFont(psfont_); + str << '/' << psFontName(ff) + << " findfont " << int(psFontSize(ff)*parent->getDisplayRatio()) + << " scalefont setfont" << endl; + + Vector bbc = bbox.center(); + Vector tt = Vector(bbc[0], bbox.ll[1]).TkCanvasPs(parent->canvas); + str << "gsave" << endl + << "newpath " << endl + << tt << " moveto" << endl + << '(' << psQuote(text) << ')' << endl + << "dup true charpath pathbbox " << endl + << "closepath " << endl + << "3 -1 roll sub 2.5 div " << endl + << "3 1 roll sub 2 div exch " << endl + << tt << " moveto rmoveto show " << endl + << "grestore" << endl; + + str << ends; + Tcl_AppendResult(parent->interp, (char*)str.str().c_str(), NULL); + } +} + +void Marker::renderPSArrow(const Vector& p1, const Vector& p2, + Coord::InternalSystem sys) +{ + Vector* vv = arrow(p1,p2,sys); + ostringstream str; + str << "newpath " << endl + << vv[0].TkCanvasPs(parent->canvas) << " moveto" << endl; + for (int ii=1; ii<6; ii++) + str << vv[ii].TkCanvasPs(parent->canvas) << " lineto" << endl; + str << "closepath fill" << endl << ends; + Tcl_AppendResult(parent->interp, (char*)str.str().c_str(), NULL); + delete [] vv; +} + +void Marker::renderPSGC(int mode) +{ + // set width, color, dash + renderPSColor(mode, parent->getXColor(colorName)); + if ((properties & SOURCE) && !(properties & DASH)) + renderPSLineNoDash(); + else + renderPSLineDash(); +} + +void Marker::renderPSLineDash() +{ + ostringstream str; + str << lineWidth << " setlinewidth" << endl + << '[' << dlist[0] << ' ' << dlist[1] << "] 0 setdash" << endl + << ends; + Tcl_AppendResult(parent->interp, (char*)str.str().c_str(), NULL); +} + +void Marker::renderPSLineNoDash() +{ + ostringstream str; + str << lineWidth << " setlinewidth" << endl + << "[] 0 setdash" << endl + << ends; + Tcl_AppendResult(parent->interp, (char*)str.str().c_str(), NULL); +} + +void Marker::renderPSColor(int mode, XColor* clr) +{ + ostringstream str; + + switch ((Widget::PSColorSpace)mode) { + case Widget::BW: + case Widget::GRAY: + psColorGray(clr, str); + str << " setgray"; + break; + case Widget::RGB: + psColorRGB(clr, str); + str << " setrgbcolor"; + break; + case Widget::CMYK: + psColorCMYK(clr, str); + str << " setcmykcolor"; + break; + } + str << endl << ends; + + Tcl_AppendResult(parent->interp, (char*)str.str().c_str(), NULL); +} + +#ifdef MAC_OSX_TK +void Marker::macosx(int tt) +{ + if (properties & HIDDEN) + return; + + if (tt) + renderMACOSXText(); + + renderMACOSX(); + renderMACOSXInclude(); +} +void Marker::renderMACOSXInclude() +{ + if (!(properties & INCLUDE)) { + macosxColor(parent->getXColor("red")); + + Vector ll = handle[0]; + Vector ur = handle[2]; + macosxDrawLine(ll,ur); + } +} + +void Marker::renderMACOSXText() +{ + if (text && *text && psfont_) { + macosxColor(parent->getXColor(colorName)); + + Tcl_DString psdstr; + Tcl_DStringInit(&psdstr); + int psSize = Tk_PostscriptFontName(psfont_, &psdstr); + macosxFont(Tcl_DStringValue(&psdstr), psSize); + Tcl_DStringFree(&psdstr); + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(psfont_, &metrics); + int width = Tk_TextWidth(psfont_, text, strlen(text)); + + Vector bbc = bbox.center(); + Vector tt = Vector(bbc[0], bbox.ll[1]) * + Translate(-width/2., -metrics.descent); + + macosxDrawText(tt, 0, text); + } +} + +void Marker::renderMACOSXArrow(const Vector& p1, const Vector& p2, + Coord::InternalSystem sys) +{ + Vector* vv = arrow(p1,p2,sys); + Vector dd[6]; + for (int ii=0; ii<6; ii++) + dd[ii] = vv[ii]; + + macosxFillPolygon(dd,6); + delete [] vv; +} + +void Marker::renderMACOSXGC() +{ + // set width, color, dash + macosxColor(parent->getXColor(colorName)); + + if ((properties & SOURCE) && !(properties & DASH)) + renderMACOSXLineNoDash(); + else + renderMACOSXLineDash(); +} + +void Marker::renderMACOSXLineDash() +{ + macosxWidth(lineWidth); + macosxDash(dlist,2); +} + +void Marker::renderMACOSXLineNoDash() +{ + macosxWidth(lineWidth); + macosxDash(NULL,0); +} +#endif + +#ifdef __WIN32 +void Marker::win32(int tt) +{ + if (properties & HIDDEN) + return; + + if (tt) + renderWIN32Text(); + + renderWIN32(); + renderWIN32Include(); +} +void Marker::renderWIN32Include() +{ + if (!(properties & INCLUDE)) { + win32Color(parent->getXColor("red")); + + Vector ll = handle[0]; + Vector ur = handle[2]; + win32DrawLine(ll,ur); + } +} + +void Marker::renderWIN32Text() +{ + if (text && *text && tkfont_) { + win32Color(parent->getXColor(colorName)); + + win32Font(tkfont_); + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(tkfont_, &metrics); + int width = Tk_TextWidth(tkfont_, text, strlen(text)); + + BBox bb = bbox; + Vector bbc = bb.center(); + Vector tt = Vector(bbc[0], bbox.ll[1]) * + Translate(-width/2., -metrics.descent); + + win32DrawText(tt, 0, text); + } +} + +void Marker::renderWIN32Arrow(const Vector& p1, const Vector& p2, + Coord::InternalSystem sys) +{ + Vector* vv = arrow(p1,p2,sys); + Vector dd[6]; + for (int ii=0; ii<6; ii++) + dd[ii] = vv[ii]; + + win32FillPolygon(dd,6); + delete [] vv; +} + +void Marker::renderWIN32GC() +{ + // set width, color, dash + win32Color(parent->getXColor(colorName)); + + if ((properties & SOURCE) && !(properties & DASH)) + renderWIN32LineNoDash(); + else + renderWIN32LineDash(); +} + +void Marker::renderWIN32LineDash() +{ + win32Width(lineWidth); + win32Dash(dlist,2); +} + +void Marker::renderWIN32LineNoDash() +{ + win32Width(lineWidth); + win32Dash(NULL,0); +} +#endif + +// Support + +void Marker::updateBBox() +{ + // generate handles + updateHandles(); + + // bound handles + bbox = BBox(handle[0]); + for (int ii=1; iicentroid(center); + updateBBox(); + doCallBack(CallBack::MOVECB); +} + +void Marker::moveTo(const Vector& v) +{ + center=v; + updateBBox(); + doCallBack(CallBack::MOVECB); +} + +void Marker::moveBegin() +{ + doCallBack(CallBack::MOVEBEGINCB); +} + +void Marker::move(const Vector& v) +{ + center+=v; + updateBBox(); + doCallBack(CallBack::MOVECB); +} + +void Marker::moveEnd() +{ + doCallBack(CallBack::MOVEENDCB); +} + +void Marker::editBegin(int) +{ + doCallBack(CallBack::EDITBEGINCB); +} + +void Marker::edit(const Vector& v, int h) +{ + doCallBack(CallBack::EDITCB); +} + +void Marker::editEnd() +{ + doCallBack(CallBack::EDITENDCB); +} + +void Marker::rotateBegin() +{ + doCallBack(CallBack::ROTATEBEGINCB); +} + +void Marker::rotate(const Vector& v, int h) +{ + // v is in ref coords + // handles are in canvas coords + + double a = (v * Translate(-center) * FlipY()).angle(); + double b = ((parent->mapToRef(handle[h-1],Coord::CANVAS) * Translate(-center) * FlipY())).angle(); + angle -= a-b; + + updateBBox(); + doCallBack(CallBack::ROTATECB); +} + +void Marker::rotateEnd() +{ + doCallBack(CallBack::ROTATEENDCB); +} + +void Marker::select() { + // only call the CB if not already selected + if (!selected) + doCallBack(CallBack::SELECTCB); + selected = 1; +} + +void Marker::unselect() { + // only call the CB if already selected + if (selected) + doCallBack(CallBack::UNSELECTCB); + selected = 0; +} + +void Marker::toggleSelect() { + selected = !selected; + if (selected) + doCallBack(CallBack::SELECTCB); + else + doCallBack(CallBack::UNSELECTCB); +} + +void Marker::highlite() { + // only call the CB if not already highlited + if (!highlited) + doCallBack(CallBack::HIGHLITECB); + highlited = 1; +} + +void Marker::unhighlite() { + // only call the CB if already highlited + if (highlited) + doCallBack(CallBack::UNHIGHLITECB); + highlited = 0; +} + +void Marker::toggleHighlite() { + highlited = !highlited; + if (highlited) + doCallBack(CallBack::HIGHLITECB); + else + doCallBack(CallBack::UNHIGHLITECB); +} + +void Marker::key() { + doCallBack(CallBack::KEYCB); +} + +Vector Marker::getHandle(int h) +{ + if (hgetColor(colorName); + + doCallBack(CallBack::COLORCB); +} + +void Marker::setLineWidth(int w) +{ + lineWidth = w; + + doCallBack(CallBack::LINEWIDTHCB); +} + +void Marker::setFont(const char* f) +{ + initFonts(f); + updateBBox(); + doCallBack(CallBack::FONTCB); +} + +void Marker::initFonts(const char* ff) +{ + if (tkfont_) + Tk_FreeFont(tkfont_); + tkfont_ = NULL; + if (psfont_) + Tk_FreeFont(psfont_); + psfont_ = NULL; + + const char* dd = "helvetica 9 roman normal"; + if (!ff) + ff = dd; + + psfont_ = Tk_GetFont(parent->interp, parent->tkwin, ff); + + // determine tkfont from psfont + string x(ff); + istringstream str(x); + char family[16] = ""; + int size = 0; + char weight[16] = ""; + char slant[16] = ""; + + str >> family >> size >> weight >> slant; + + // old regions files will not have a slant + if (strncmp(slant,"roma",4) && strncmp(slant,"ital",4)) + strcpy(slant,"roman"); + +#ifdef MAC_OSX_TK + size *= parent->getDisplayRatio(); +#endif + + char* ptr =NULL; + if (!strncmp(family,"helvetica",4)) + ptr = parent->options->helvetica; + else if (!strncmp(family,"times",4)) + ptr = parent->options->times; + else if (!strncmp(family,"courier",4)) + ptr = parent->options->courier; + else + ptr = parent->options->helvetica; + + ostringstream fstr; + fstr << '{' << ptr << '}' << ' ' + << size << ' ' << weight << ' ' << slant << ends; + + tkfont_ = Tk_GetFont(parent->getInterp(), parent->getTkwin(), + fstr.str().c_str()); +} + +const char* Marker::getFont() +{ + if (psfont_) + return Tk_NameOfFont(psfont_); + else + return NULL; +} + +void Marker::addTag(const char* tg) +{ + Tag* t = new Tag(tg); + tags.append(t); +} + +void Marker::editTag(const char* from, const char* to) +{ + // change any tags + { + Tag* t = tags.head(); + while (t) { + if (!strcmp(t->tag(),from)) { + t->set(to); + } + t=t->next(); + } + } + + // now, remove duplicates + { + Tag* t = tags.head(); + while (t) { + Tag* tt=t->next(); + while (tt) { + if (!strcmp(t->tag(),tt->tag())) { + Tag* ntt = tags.extractNext(tt); + delete tt; + tt = ntt; + } + else + tt=tt->next(); + } + t=t->next(); + } + } +} + +void Marker::deleteTags() +{ + tags.deleteAll(); +} + +void Marker::deleteTag(const char* tg) +{ + Tag* t = tags.head(); + while (t) { + if (!strcmp(t->tag(),tg)) { + tags.extractNext(t); + delete t; + return; + } + t = t->next(); + } +} + +void Marker::deleteTag(int w) +{ + Tag* t = tags.head(); + for (int i=0; inext(); + else + break; + + if (t) { + tags.extractNext(t); + delete t; + } +} + +const char* Marker::getTag() +{ + Tag* t = tags.head(); + if (t) + return t->tag(); + else + return NULL; +} + +const char* Marker::getNextTag() +{ + Tag* t = tags.next(); + if (t) + return t->tag(); + else + return NULL; +} + +const char* Marker::getTag(int w) +{ + Tag* t = tags.head(); + for (int i=0; inext(); + else + break; + + if (t) + return t->tag(); + else + return NULL; +} + +int Marker::hasTag(const char* tg) +{ + Tag* t = tags.head(); + while (t) { + if (!strcmp(t->tag(),tg)) + return 1; + t = t->next(); + } + return 0; +} + +int Marker::onHandle(const Vector& v) +{ + // return handle number + // work last to first for annuli + for (int ii=numHandle-1; ii>=0; ii--) { + BBox bb(handle[ii]); + bb.expand(parent->markerEpsilon); + if (bb.isIn(v)) + return ii+1; + } + return 0; +} + +int Marker::getProperty(unsigned short which) +{ + return (properties & which) ? 1 : 0; +} + +void Marker::setText(const char* str) +{ + if (text) + delete [] text; + text = dupstr(str); + + updateBBox(); + doCallBack(CallBack::TEXTCB); +} + +void Marker::setProperty(unsigned short prop, int value) +{ + if (value) + properties |= prop; + else + properties &= ~prop; + + if (prop == FIXED) // bbox will change + updateBBox(); + + doCallBack(CallBack::PROPERTYCB); +} + +int Marker::addCallBack(CallBack::Type t, const char* proc, const char* arg) +{ + CallBack* cb = new CallBack(parent->interp, t, proc, arg); + if (cb) { + callbacks.append(cb); + return TCL_OK; + } + + return TCL_ERROR; +} + +void Marker::deleteCallBack(CallBack::Type t) +{ + CallBack* cb = callbacks.head(); + while (cb) { + if (cb->type() == t) { + CallBack* next = callbacks.extractNext(cb); + delete cb; + cb = next; + } + else + cb = cb->next(); + } +} + +int Marker::deleteCallBack(CallBack::Type t, const char* proc) +{ + CallBack* cb = callbacks.head(); + while (cb) { + if (cb->type() == t && (!strcmp(cb->proc(), proc))) { + callbacks.extractNext(cb); + delete cb; + return TCL_OK; + } + else + cb = cb->next(); + } + + return TCL_ERROR; +} + +int Marker::isIn(const Vector& vv, Coord::InternalSystem sys) +{ + Vector rr = parent->mapToRef(vv,sys); + Vector ss = parent->mapFromRef(rr,Coord::CANVAS); + return bbox.isIn(ss); +} + +// assume Coord::REF +int Marker::isIn(const Vector& vv, const Matrix& bck) +{ + Vector ss = parent->mapFromRef(vv,Coord::CANVAS); + return bbox.isIn(ss); +} + +int Marker::isVisible(const BBox& b) +{ + // assume visible, prove otherwise + // all coords are in canvas coords + + BBox bb(b); + return + !((allBBox.ur[0] < bb.ll[0]) || + (allBBox.ll[0] > bb.ur[0]) || + (allBBox.ur[1] < bb.ll[1]) || + (allBBox.ll[1] > bb.ur[1])); +} + +void Marker::doCallBack(CallBack::Type t) +{ + if (!doCB) + return; + + ostringstream str; + + str << id << ends; + + CallBack* cb=callbacks.head(); + while (cb) { + if (cb->type() == t) + if (cb->eval(str.str().c_str())) { + ostringstream estr; + estr << "Unable to eval Marker CallBack " + << cb->proc() << " : " << Tcl_GetStringResult(parent->interp) << ends; + internalError(estr.str().c_str()); + } + cb=cb->next(); + } +} + +double Marker::calcAngle() +{ + switch (parent->getOrientation()) { + case Coord::NORMAL: + case Coord::XY: + return angle + parent->getRotation(); + case Coord::XX: + case Coord::YY: + return -angle + parent->getRotation(); + } +} + +Vector Marker::modifyArrow(const Vector& p1, const Vector& p2, + Coord::InternalSystem sys) +{ + const int tip = 6; // length from end of line to tip of arrow + + Vector aa = parent->mapFromRef(p1,sys); + Vector bb = parent->mapFromRef(p2,sys); + + Vector nn = (bb-aa).normalize(); + double ll = (bb-aa).length(); + return nn * Scale(ll-tip) * Translate(aa); +} + +Vector* Marker::arrow(const Vector& p1, const Vector& p2, Coord::InternalSystem sys) +{ + Vector p3; + if (((p2-p1)[0]) == 0) + p3 = p1+Vector(1,0); + else + p3 = p1+Vector(0,1); + + Vector3d aa = parent->mapFromRef3d(p1,sys); + Vector3d bb = parent->mapFromRef3d(p2,sys); + Vector3d cc = parent->mapFromRef3d(p3,sys); + + const int tip = 6; // length from end of line to tip of arrow + const int tail = 2; // length from end of line to tails of arrow + const int wc = 2; // width of arrow at end of line + const int wt = 3; // width of arrow at tails + + // build in Y-Z plane, align on z axis + Vector3d vv[6]; + vv[0] = Vector3d(0,0,tip); + vv[1] = Vector3d(0,-wc,0); + vv[2] = Vector3d(0,-wt,-tail); + vv[3] = Vector3d(0,0,0); + vv[4] = Vector3d(0,wt,-tail); + vv[5] = Vector3d(0,wc,0); + + Vector3d l1 = (aa-bb).normalize(); + Vector3d l2 = (aa-cc).normalize(); + Vector3d rz = -l1; + Vector3d rx = (cross(l1,l2)).normalize(); + Vector3d ry = cross(rz,rx); + Matrix3d rr(rx,ry,rz); + Matrix3d mm = + Translate3d(0,0,-tip) * + Scale3d(1.5) * + rr.invert() * + Translate3d(bb); + + Vector* ww = new Vector[6]; + for (int ii=0; ii<6; ii++) + ww[ii] = vv[ii]*mm; + + return ww; +} + +void Marker::analysisXYEEResult(char* xname, char* yname, + char* xcname, char* ycname, + double* x, double* y, + double* xc, double* yc, int num) +{ + Blt_Vector* xx; + Blt_GetVector(parent->getInterp(), xname, &xx); + Blt_ResetVector(xx, x, num, num*sizeof(double), TCL_DYNAMIC); + + Blt_Vector* yy; + Blt_GetVector(parent->getInterp(), yname, &yy); + Blt_ResetVector(yy, y, num, num*sizeof(double), TCL_DYNAMIC); + + Blt_Vector* xxc; + Blt_GetVector(parent->getInterp(), xcname, &xxc); + Blt_ResetVector(xxc, xc, num, num*sizeof(double), TCL_DYNAMIC); + + Blt_Vector* yyc; + Blt_GetVector(parent->getInterp(), ycname, &yyc); + Blt_ResetVector(yyc, yc, num, num*sizeof(double), TCL_DYNAMIC); +} + +void Marker::analysisXYResult(char* xname, char* yname, double* x, double* y, + int num) +{ + Blt_Vector* xx; + Blt_GetVector(parent->getInterp(), xname, &xx); + Blt_ResetVector(xx, x, num, num*sizeof(double), TCL_DYNAMIC); + + Blt_Vector* yy; + Blt_GetVector(parent->getInterp(), yname, &yy); + Blt_ResetVector(yy, y, num, num*sizeof(double), TCL_DYNAMIC); +} + +void Marker::analysisXYEResult(char* xname, char* yname, char* ename, + double* x, double* y, double* e, int num) +{ + Blt_Vector* xx; + Blt_GetVector(parent->getInterp(), xname, &xx); + Blt_ResetVector(xx, x, num, num*sizeof(double), TCL_DYNAMIC); + + Blt_Vector* yy; + Blt_GetVector(parent->getInterp(), yname, &yy); + Blt_ResetVector(yy, y, num, num*sizeof(double), TCL_DYNAMIC); + + Blt_Vector* ee; + Blt_GetVector(parent->getInterp(), ename, &ee); + Blt_ResetVector(ee, e, num, num*sizeof(double), TCL_DYNAMIC); +} + +void Marker::analysisXYEResult(double* x, double* y, double* e, int num) +{ + for (int ii=0; iiinterp, str.str().c_str(), NULL); + } +} + +Matrix Marker::fwdMatrix() +{ + return Rotate(angle) * FlipY() * Translate(center); +} + +Matrix Marker::bckMatrix() +{ + return Translate(-center) * FlipY() * Rotate(-angle); +} + +Vector Marker::fwdMap(const Vector& vv, Coord::InternalSystem sys) +{ + return + parent->mapFromRef(vv * Rotate(angle) * FlipY() * Translate(center),sys); +} + +Vector Marker::bckMap(const Vector& vv, Coord::InternalSystem sys) +{ + return + parent->mapToRef(vv,sys) * Translate(-center) * FlipY() * Rotate(-angle); +} + +void Marker::setMatrices(Coord::InternalSystem sys, Matrix* fwd, Matrix* bck) +{ + switch (sys) { + case Coord::WIDGET: + *fwd = parent->refToWidget; + *bck = parent->widgetToRef; + break; + case Coord::CANVAS: + *fwd = parent->refToCanvas; + *bck = parent->canvasToRef; + break; + case Coord::WINDOW: + *fwd = parent->refToWindow; + *bck = parent->windowToRef; + break; + case Coord::MAGNIFIER: + *fwd = parent->refToMagnifier; + *bck = parent->magnifierToRef; + break; + default: + // na + break; + } +} + +// list + +void Marker::listRADEC(FitsImage* ptr, + const Vector& vv, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format) +{ + char buf[64]; + ptr->mapFromRef(vv,sys,sky,format,buf); + string x(buf); + istringstream wcs(x); + wcs >> ra >> dec; +} + +void Marker::listRADECPros(FitsImage* ptr, + const Vector& vv, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format) +{ + char buf[64]; + char decc[32]; + ptr->mapFromRef(vv,sys,sky,format,buf); + string x(buf); + istringstream wcs(x); + wcs >> ra >> decc; + if (decc[0]=='+') + strncpy(dec,decc+1,32); + else + strncpy(dec,decc,32); +} + +void Marker::listPre(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + FitsImage* ptr, int strip, int hash) +{ + // no props for semicolons + if (!strip) { + FitsImage* fits = parent->findFits(); + if (fits && fits->nextMosaic()) { + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + str << "# tile " << parent->findFits(ptr) << endl; + + break; + default: + if (!parent->findFits()->hasWCSCel(sys)) + str << "# tile " << parent->findFits(ptr) << endl; + } + } + + if (hash) + str << "# "; + } + + if (!(properties&INCLUDE)) + str << '-'; +} + +void Marker::listPost(ostream& str, int conj, int strip) +{ + // no props for semicolons + if (!strip) { + if (conj) + str << " ||"; + + listProperties(str,1); + } + else { + if (conj) + str << "||"; + else + str << ';'; + } +} + +void Marker::listProperties(ostream& str, int hash) +{ + if (strncmp("green",colorName,5) || + dlist[0] != 8 || + dlist[1] != 3 || + (lineWidth != 1) || + strncmp("helvetica 10 normal roman",getFont(),25) || + (text && *text) || + !(properties&SELECT) || + !(properties&HIGHLITE) || + (properties&DASH) || + (properties&FIXED) || + !(properties&EDIT) || + !(properties&MOVE) || + !(properties&ROTATE) || + !(properties&DELETE) || + !(properties&SOURCE) || + (tags.count() > 0) || + (comment && *comment)) { + + if (hash) + str << " #"; + listProps(str); + } + + str << endl; +} + +void Marker::listProps(ostream& str) +{ + if (strncmp("green",colorName,5)) + str << " color=" << colorName; + + if (dlist[0] != 8 || dlist[1] != 3) + str << " dashlist=" << dlist[0] << ' ' << dlist[1]; + + if (lineWidth != 1) + str << " width=" << lineWidth; + + if (strncmp("helvetica 10 normal roman", getFont(), 25)) + str << " font=\"" << getFont() << '"'; + + if (text && *text) // only list text if there is something to list + str << " text={" << text << '}'; + + if (!(properties&SELECT)) + str << " select=0"; + + if (!(properties&HIGHLITE)) + str << " highlite=0"; + + if (properties&DASH) + str << " dash=1"; + + if (properties&FIXED) + str << " fixed=1"; + + if (!(properties&EDIT)) + str << " edit=0"; + + if (!(properties&MOVE)) + str << " move=0"; + + if (!(properties&ROTATE)) + str << " rotate=0"; + + if (!(properties&DELETE)) + str << " delete=0"; + + if (!(properties&SOURCE)) + str << " background"; + + // tags + Tag* t = tags.head(); + while (t) { + str << " tag={" << t->tag() << '}'; + t = t->next(); + } + + if (comment && *comment) + str << ' ' << comment; +} + +void Marker::listCiaoPre(ostream& str) +{ + if (!(properties&INCLUDE)) + str << '-'; +} + +void Marker::listCiaoPost(ostream& str, int strip) + +{ + str << (strip ? ';' : '\n'); +} + +void Marker::listProsPost(ostream& str, int strip) +{ + str << (strip ? ';' : '\n'); +} + +void Marker::listSAOtngPre(ostream& str, int strip) +{ + if (!strip && text && *text) + str << '#' << text << endl; + + if (properties&INCLUDE) + str << '+'; + else + str << '-'; +} + +void Marker::listSAOtngPost(ostream& str, int strip) +{ + if (!strip) { + str << " # "; + if (comment && *comment) + str << comment; + else if (!(properties&SOURCE)) + str << "background"; + else + str << colorName; + } + + str << (strip ? ';' : '\n'); +} + +void Marker::listSAOimagePre(ostream& str) +{ + if (!(properties&INCLUDE)) + str << '-'; +} + +void Marker::listSAOimagePost(ostream& str, int strip) +{ + str << (strip ? ';' : '\n'); +} + +void Marker::listXY(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int strip) +{ + FitsImage* ptr = parent->findFits(); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + str << setprecision(8) << ptr->mapFromRef(center,sys); + break; + default: + if (ptr->hasWCS(sys)) { + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + str << setprecision(10) << ptr->mapFromRef(center,sys,sky); + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << ra << ' ' << dec; + break; + } + } + else { + str << setprecision(8) << ptr->mapFromRef(center,sys); + } + } + break; + } + + str << (strip ? ';' : '\n'); +} + +void Marker::XMLRowInit() +{ + for (int ii=0; iifindFits(); + if (fits && fits->nextMosaic()) { + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + str << parent->findFits(ptr) << ends; + break; + default: + if (!parent->findFits()->hasWCSCel(sys)) + str << parent->findFits(ptr) << ends; + break; + } + } + if (XMLCol[col]) + delete [] XMLCol[col]; + XMLCol[col] = dupstr(str.str().c_str()); + } + + // color + { + XMLColName col = XMLCOLOR; + if (XMLCol[col]) + delete [] XMLCol[col]; + XMLCol[col] = dupstr(colorName); + } + + // width + { + ostringstream str; + str << lineWidth << ends; + XMLColName col = XMLWIDTH; + if (XMLCol[col]) + delete [] XMLCol[col]; + XMLCol[col] = dupstr(str.str().c_str()); + } + + // text + if (text && *text) { + XMLColName col = XMLTEXT; + if (XMLCol[col]) + delete [] XMLCol[col]; + XMLCol[col] = dupstr(text); + } + + // font + { + XMLColName col = XMLFONT; + if (XMLCol[col]) + delete [] XMLCol[col]; + XMLCol[col] = dupstr(getFont()); + } + + XMLRowProp(XMLSELECT,SELECT); + XMLRowProp(XMLHIGHLITE,HIGHLITE); + XMLRowProp(XMLEDIT,EDIT); + XMLRowProp(XMLMOVE,MOVE); + XMLRowProp(XMLROTATE,ROTATE); + XMLRowProp(XMLDELETE,DELETE); + XMLRowProp(XMLFIXED,FIXED); + XMLRowProp(XMLINCLUDE,INCLUDE); + XMLRowProp(XMLSOURCE,SOURCE); + XMLRowProp(XMLDASH,DASH); + + // dashlist + { + ostringstream str; + str << dlist[0] << ',' << dlist[1] << ends; + XMLColName col = XMLDASHLIST; + if (XMLCol[col]) + delete [] XMLCol[col]; + XMLCol[col] = dupstr(str.str().c_str()); + } + + // tags + { + ostringstream str; + Tag* start = tags.head(); + Tag* ptr = start; + while (ptr) { + if (ptr != start) + str << ' '; + char* tag = (char*)ptr->tag(); + while (*tag) { + if (*tag == ' ') + str << " "; + else + str << *tag; + tag++; + } + ptr = ptr->next(); + } + str << ends; + + XMLColName col = XMLTAG; + if (XMLCol[col]) + delete [] XMLCol[col]; + XMLCol[col] = dupstr(str.str().c_str()); + } + + // comment + if (comment && *comment) { + XMLColName col = XMLCOMMENT; + if (XMLCol[col]) + delete [] XMLCol[col]; + XMLCol[col] = dupstr(comment); + } +} + +void Marker::XMLRowEnd(ostream& str) +{ + str << ""; + for (int ii=0; ii"; + if (XMLCol[ii]) { + char* ss = XMLQuote(XMLCol[ii]); + str << ss; + delete [] XMLCol[ii]; + delete [] ss; + XMLCol[ii] = NULL; + } + str << ""; + } + str << "" << endl; +} + +void Marker::XMLRowProp(XMLColName col, Property prop) +{ + if (properties & prop) + XMLCol[col] = dupstr("1"); + else + XMLCol[col] = dupstr("0"); +} + +void Marker::XMLRowPoint(FitsImage* ptr, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + Vector vv) +{ + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + Vector v = ptr->mapFromRef(vv,sys); + XMLRow(XMLX,v[0],8); + XMLRow(XMLY,v[1],8); + } + break; + default: + if (ptr->hasWCS(sys)) { + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector v = ptr->mapFromRef(vv,sys,sky); + XMLRow(XMLX,v[0],10); + XMLRow(XMLY,v[1],10); + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,vv,sys,sky,format); + XMLRow(XMLX,ra); + XMLRow(XMLY,dec); + break; + } + } + else { + Vector v = ptr->mapFromRef(vv,sys); + XMLRow(XMLX,v[0],8); + XMLRow(XMLY,v[1],8); + } + } + } +} + +void Marker::XMLRowPoint(FitsImage* ptr, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + Vector* vv, int cnt) +{ + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + double xx[cnt]; + double yy[cnt]; + for (int ii=0; iimapFromRef(vv[ii],sys); + xx[ii] = v[0]; + yy[ii] = v[1]; + } + XMLRow(XMLXV,xx,cnt,8); + XMLRow(XMLYV,yy,cnt,8); + } + break; + default: + if (ptr->hasWCS(sys)) { + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + double xx[cnt]; + double yy[cnt]; + for (int ii=0; iimapFromRef(vv[ii],sys,sky); + xx[ii] = v[0]; + yy[ii] = v[1]; + } + XMLRow(XMLXV,xx,cnt,10); + XMLRow(XMLYV,yy,cnt,10); + } + break; + case Coord::SEXAGESIMAL: + { + char* xx[cnt]; + char* yy[cnt]; + for (int ii=0; iimapFromRef(vv[ii],sys); + xx[ii] = v[0]; + yy[ii] = v[1]; + } + XMLRow(XMLXV,xx,cnt,8); + XMLRow(XMLYV,yy,cnt,8); + } + } + } +} + +void Marker::XMLRowRadiusX(FitsImage* ptr, Coord::CoordSystem sys, Vector vv) +{ + double rr = ptr->mapLenFromRef(vv[0],sys,Coord::ARCSEC); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + XMLRow(XMLR,rr,8); + break; + default: + if (ptr->hasWCS(sys)) { + if (ptr->hasWCSCel(sys)) + XMLRowARCSEC(XMLR,rr); + else + XMLRow(XMLR,rr,8); + } + break; + } +} + +void Marker::XMLRowRadiusX(FitsImage* ptr, Coord::CoordSystem sys, + Vector* vv, int cnt) +{ + double rr[cnt]; + for (int ii=0; iimapLenFromRef(vv[ii][0],sys,Coord::ARCSEC); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + XMLRow(XMLRV,rr,cnt,8); + break; + default: + if (ptr->hasWCS(sys)) { + if (ptr->hasWCSCel(sys)) + XMLRowARCSEC(XMLRV,rr,cnt); + else + XMLRow(XMLRV,rr,cnt,8); + } + break; + } +} + +void Marker::XMLRowRadius(FitsImage* ptr, Coord::CoordSystem sys, Vector vv) +{ + Vector v = ptr->mapLenFromRef(vv,sys,Coord::ARCSEC); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + XMLRow(XMLR,v[0],8); + XMLRow(XMLR2,v[1],8); + break; + default: + if (ptr->hasWCS(sys)) { + if (ptr->hasWCSCel(sys)) { + XMLRowARCSEC(XMLR,v[0]); + XMLRowARCSEC(XMLR2,v[1]); + } + else { + XMLRow(XMLR,v[0],8); + XMLRow(XMLR2,v[1],8); + } + } + break; + } +} + +void Marker::XMLRowRadius(FitsImage* ptr, Coord::CoordSystem sys, + Vector* vv, int cnt) +{ + double rr[cnt]; + double rr2[cnt]; + for (int ii=0; iimapLenFromRef(vv[ii],sys,Coord::ARCSEC); + rr[ii] = v[0]; + rr2[ii] = v[1]; + } + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + XMLRow(XMLRV,rr,cnt,8); + XMLRow(XMLRV2,rr2,cnt,8); + break; + default: + if (ptr->hasWCS(sys)) { + if (ptr->hasWCSCel(sys)) { + XMLRowARCSEC(XMLRV,rr,cnt); + XMLRowARCSEC(XMLRV2,rr2,cnt); + } + else { + XMLRow(XMLRV,rr,cnt,8); + XMLRow(XMLRV2,rr2,cnt,8); + } + } + break; + } +} + +void Marker::XMLRowAng(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + XMLRow(XMLANG, radToDeg(parent->mapAngleFromRef(angle,sys,sky)),8); +} + +void Marker::XMLRowAng(Coord::CoordSystem sys, Coord::SkyFrame sky, + double* ang, int cnt) +{ + double aa[cnt]; + for (int ii=0; iimapAngleFromRef(ang[ii],sys,sky)); + + XMLRow(XMLANGV,aa,cnt,8); +} + +char* Marker::XMLQuote(char* src) +{ + char* dest = new char[strlen(src)*7+1]; + char* sptr = src; + char* dptr = dest; + while (sptr && *sptr) { + if (*sptr == '&') { + // special case, char entities + if (*(sptr+1) == '#') { + *dptr++ = *sptr; + } + else { + memcpy(dptr,"&",5); + dptr += 5; + } + } + else if (*sptr == '<') { + memcpy(dptr,"<",4); + dptr += 4; + } + else if (*sptr == '>') { + memcpy(dptr,">",4); + dptr += 4; + } + else if (*sptr == '\'') { + memcpy(dptr,"'",6); + dptr += 6; + } + else if (*sptr == '"') { + memcpy(dptr,""",6); + dptr += 6; + } + else + *dptr++ = *sptr; + + sptr++; + } + *dptr = '\0'; + + return dest; +} + +// special composite funtionallity + +void Marker::setComposite(const Matrix& mx, double aa) +{ + center *= mx; + angle += aa; + updateBBox(); +} + +void Marker::setComposite(const char* clr, int w, int h) +{ + lineWidth = w; + if (colorName) + delete [] colorName; + + colorName = dupstr(clr); + color = parent->getColor(colorName); + highlited = h; +} + diff --git a/tksao/frame/marker.h b/tksao/frame/marker.h new file mode 100644 index 0000000..ba2d0e7 --- /dev/null +++ b/tksao/frame/marker.h @@ -0,0 +1,366 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __marker_h__ +#define __marker_h__ + +#include + +#include "vector.h" +#include "vector3d.h" +#include "callback.h" +#include "list.h" +#include "tag.h" +#include "coord.h" +#include "xml.h" + +#define POINTSIZE 11 + +class Base; +class FitsImage; +class Vector; + +class Marker { +public: + // Select-- user may select the marker + // Highlite-- user may highlite the marker + // Edit-- user may edit the marker + // Move-- user may move the marker + // Rotate-- user may rotate the marker + // Delete-- user may delete the marker + // Fixed-- marker is fixed in size (not scaled based on zoom) + // Include-- marker is 'included' or 'excluded' ie '+' or '-' + // Source-- marker is a 'source' or 'background' marker + // Dash-- render with dashed line + // Hide-- hidden marker + enum Property {NONE=0, SELECT=1, HIGHLITE=2, EDIT=4, MOVE=8, ROTATE=16, + DELETE=32, FIXED=64, INCLUDE=128, SOURCE=256, DASH=512, + HIDDEN=1024}; + enum RenderMode {SRC,XOR}; + enum HandleMode {HANDLES,NOHANDLES}; + + enum AnalysisTask {STATS,PLOT2D,PLOT3D,RADIAL,PANDA,HISTOGRAM}; + enum AnalysisMethod {SUM,AVERAGE}; + +protected: + int id; + char type_[64]; + Base* parent; + + Vector center; // ref coordinates + BBox bbox; // canvas coordinates + BBox allBBox; // canvas coordinates + + double angle; // radians + + Vector* handle; // canvas coordinates + int numHandle; + + char* colorName; + unsigned long color; + int lineWidth; + unsigned short properties; + int selected; + int highlited; + + float dlist[2]; + + char* text; + Tk_Font tkfont_; + Tk_Font psfont_; + char* comment; + + Display* display; + GC gc; + GC gcxor; + + int doCB; + + List tags; + List callbacks; + + Marker* previous_; + Marker* next_; + + Vector* arrow(const Vector&, const Vector&, Coord::InternalSystem); + + char* XMLCol[XMLNUMCOL]; + + int analysisHistogram_; + static const char* analysisHistogramCB_[]; + int analysisPlot2d_; + static const char* analysisPlot2dCB_[]; + int analysisPlot3d_; + static const char* analysisPlot3dCB_[]; + int analysisPanda_; + static const char* analysisPandaCB_[]; + int analysisRadial_; + static const char* analysisRadialCB_[]; + int analysisStats_; + static const char* analysisStatsCB_[]; + + char ra[32]; // tmp storage + char dec[32]; // tmp storage + + protected: + virtual void renderX(Drawable, Coord::InternalSystem, RenderMode) =0; + virtual void renderXInclude(Drawable drawable, Coord::InternalSystem, RenderMode mode); + virtual void renderXText(Drawable, Coord::InternalSystem, RenderMode); + void renderXArrow(Drawable, const Vector&, const Vector&, Coord::InternalSystem, GC); + void renderXHandles(Drawable); + virtual GC renderXGC(RenderMode); + virtual void renderXLineDash(GC); + void renderXLineNoDash(GC); + + virtual void renderPS(int mode) =0; + virtual void renderPSInclude(int); + virtual void renderPSText(int); + void renderPSArrow(const Vector&, const Vector&, Coord::InternalSystem); + virtual void renderPSGC(int); + virtual void renderPSLineDash(); + void renderPSLineNoDash(); + void renderPSColor(int, XColor*); + +#ifdef MAC_OSX_TK + virtual void renderMACOSX() =0; + virtual void renderMACOSXInclude(); + virtual void renderMACOSXText(); + void renderMACOSXArrow(const Vector&, const Vector&, Coord::InternalSystem); + virtual void renderMACOSXGC(); + virtual void renderMACOSXLineDash(); + void renderMACOSXLineNoDash(); +#endif + +#ifdef __WIN32 + virtual void renderWIN32() =0; + virtual void renderWIN32Include(); + virtual void renderWIN32Text(); + void renderWIN32Arrow(const Vector&, const Vector&, Coord::InternalSystem); + virtual void renderWIN32GC(); + virtual void renderWIN32LineDash(); + void renderWIN32LineNoDash(); +#endif + + void analysisXYResult(char*, char*, double*, double*, int); + void analysisXYEResult(char*, char*, char*, double*, double*, double*, int); + void analysisXYEResult(double*, double*, double*, int); + void analysisXYEEResult(char*, char*, char*, char*, + double*, double*, double*, double*, int); + + void setMatrices(Coord::InternalSystem, Matrix*, Matrix*); + double calcAngle(); + Vector modifyArrow(const Vector&, const Vector&, Coord::InternalSystem); + virtual void updateHandles() =0; + virtual void calcAllBBox(); + + void initFonts(const char*); + + void listRADEC(FitsImage*, const Vector&, Coord::CoordSystem, + Coord::SkyFrame, Coord::SkyFormat); + void listRADECPros(FitsImage*, const Vector&, Coord::CoordSystem, + Coord::SkyFrame, Coord::SkyFormat); + void listPre(ostream&, Coord::CoordSystem, Coord::SkyFrame, + FitsImage*, int, int); + virtual void listPost(ostream&, int, int); + + void listCiaoPre(ostream&); + void listCiaoPost(ostream&, int); + + void listProsPost(ostream&, int); + + void listSAOtngPre(ostream&, int); + void listSAOtngPost(ostream&, int); + + void listSAOimagePre(ostream&); + void listSAOimagePost(ostream&, int); + + void listProps(ostream&); + void listProperties(ostream&, int); + + void XMLRowInit(); + void XMLRow(XMLColName,int); + void XMLRow(XMLColName,int*,int); + void XMLRow(XMLColName,double, int); + void XMLRow(XMLColName,double*,int, int); + void XMLRow(XMLColName,char*); + void XMLRow(XMLColName,char**, int); + void XMLRowARCSEC(XMLColName,double); + void XMLRowARCSEC(XMLColName,double*,int); + void XMLRowProps(FitsImage*, Coord::CoordSystem); + void XMLRowEnd(ostream&); + void XMLRowProp(XMLColName, Property); + void XMLRowCenter(FitsImage* fits, Coord::CoordSystem sys, Coord::SkyFrame sky, Coord::SkyFormat format) {XMLRowPoint(fits, sys, sky, format, center);} + void XMLRowPoint(FitsImage*, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, Vector); + void XMLRowPoint(FitsImage*, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, Vector*, int); + void XMLRowRadiusX(FitsImage*, Coord::CoordSystem, Vector); + void XMLRowRadiusX(FitsImage*, Coord::CoordSystem, Vector*, int); + void XMLRowRadius(FitsImage*, Coord::CoordSystem, Vector); + void XMLRowRadius(FitsImage*, Coord::CoordSystem, Vector*, int); + void XMLRowAng(Coord::CoordSystem, Coord::SkyFrame); + void XMLRowAng(Coord::CoordSystem, Coord::SkyFrame, double*, int); + char* XMLQuote(char*); + + public: + Marker(Base* p, const Vector& v, double ang); + Marker(Base* p, const Vector& v, double ang, + const char* clr, int* dsh, + int w, const char* f, const char* t, + unsigned short prop, const char* c, + const List& tag, const List& cb); + Marker(const Marker&); + virtual ~Marker(); + + virtual Matrix fwdMatrix(); + virtual Matrix bckMatrix(); + virtual Vector fwdMap(const Vector&, Coord::InternalSystem); + virtual Vector bckMap(const Vector&, Coord::InternalSystem); + + virtual void x11(Drawable, Coord::InternalSystem, int, RenderMode,HandleMode); + virtual void ps(int,int); +#ifdef MAC_OSX_TK + virtual void macosx(int); +#endif +#ifdef __WIN32 + virtual void win32(int); +#endif + + virtual Marker* dup() =0; + void newIdentity(); + + virtual void updateBBox(); + virtual void updateCoords(const Matrix&); + + virtual void moveTo(const Vector& v); + + virtual void moveBegin(); + virtual void move(const Vector& v); + virtual void moveEnd(); + + virtual void centroid(); + + virtual void editBegin(int); + virtual void edit(const Vector& v, int h); + virtual void editEnd(); + + virtual void rotateBegin(); + virtual void rotate(const Vector& v, int h); + virtual void rotateEnd(); + + // assume Coord::CANVAS + virtual int isIn(const Vector& vv) {return bbox.isIn(vv);} + + virtual int isIn(const Vector& vv, Coord::InternalSystem sys); + virtual int isIn(const Vector& vv, Coord::InternalSystem sys, int nn) + {return isIn(vv,sys);} + virtual int isIn(const Vector& vv, Coord::InternalSystem sys, int nn, int aa) + {return isIn(vv,sys);} + + // assume Coord::REF + virtual int isIn(const Vector& vv, const Matrix& bck); + virtual int isIn(const Vector& vv, const Matrix& bck, int nn) + {return isIn(vv,bck);} + virtual int isIn(const Vector& vv, const Matrix& bck, int nn, int aa) + {return isIn(vv,bck);} + + void setAngle(double); + double getAngle() {return angle;} + + int getNumHandle() {return numHandle;} + Vector getHandle(int); + + virtual int getSegment(const Vector&) {return 0;} + + virtual void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int) =0; + virtual void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat) {} + virtual void listCiao(ostream&, Coord::CoordSystem, int) {} + virtual void listSAOtng(ostream&,Coord::CoordSystem,Coord::SkyFrame,Coord::SkyFormat, int) {} + virtual void listPros(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int) {} + virtual void listSAOimage(ostream&, int) {} + virtual void listXY(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + + const BBox& getBBox() {return bbox;} + const BBox& getAllBBox() {return allBBox;} + int isVisible(const BBox&); + + void select(); + void unselect(); + void toggleSelect(); + int isSelected() {return selected;} + + void highlite(); + void unhighlite(); + void toggleHighlite(); + int isHighlited() {return highlited;} + + void key(); + + void setColor(const char*); + const char* getColorName() {return colorName;} + + void setLineWidth(int); + int getLineWidth() {return lineWidth;} + + void setText(const char*); + const char* getText() {return text;} + void setFont(const char*); + const char* getFont(); + + void addTag(const char*); + void editTag(const char*, const char*); + void deleteTags(); + void deleteTag(int); + void deleteTag(const char*); + const char* getTag(); + const char* getNextTag(); + const char* getTag(int); + int hasTag(const char*); + + int onHandle(const Vector& v); + + int getId() {return id;} + const char* getType() {return type_;} + Vector getCenter() {return center;} + + int canSelect() {return (properties & SELECT) ? 1:0;} + int canHighlite() {return (properties & HIGHLITE) ? 1:0;} + int canEdit() {return (properties & EDIT) ? 1:0;} + int canMove() {return (properties & MOVE) ? 1:0;} + int canRotate() {return (properties & ROTATE) ? 1:0;} + int canDelete() {return (properties & DELETE) ? 1:0;} + int isFixed() {return (properties & FIXED) ? 1:0;} + void setProperty(unsigned short, int); + int getProperty(unsigned short); + unsigned short getProperty() {return properties;} + + int addCallBack(CallBack::Type, const char*, const char*); + int deleteCallBack(CallBack::Type, const char*); + void deleteCallBack(CallBack::Type); + void doCallBack(CallBack::Type); + + Marker* previous() {return previous_;} + void setPrevious(Marker* m) {previous_ = m;} + Marker* next() {return next_;} + void setNext(Marker* m) {next_ = m;} + + void enableCB() {doCB = 1;} + void disableCB() {doCB = 0;} + void deleteCBs(); + + virtual void analysis(AnalysisTask, int) {} + virtual void analysisHistogram(char*, char*, int) {} + virtual void analysisRadial(char*, char*, char*, Coord::CoordSystem) {} + virtual void analysisStats(Coord::CoordSystem, Coord::SkyFrame) {} + virtual void analysisPanda(Coord::CoordSystem) {} + virtual void analysisPlot2d(char*, char*, char*, char*, + Coord::CoordSystem, Coord::SkyFrame, + Marker::AnalysisMethod) {} + virtual void analysisPlot3d(char*, char*, Coord::CoordSystem, + Marker::AnalysisMethod) {} + + // special composite funtionality + virtual void setComposite(const Matrix&, double); + void setComposite(const char*, int, int); +}; + +#endif diff --git a/tksao/frame/parser.C b/tksao/frame/parser.C new file mode 100644 index 0000000..360aff3 --- /dev/null +++ b/tksao/frame/parser.C @@ -0,0 +1,11193 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse frparse +#define yylex frlex +#define yyerror frerror +#define yylval frlval +#define yychar frchar +#define yydebug frdebug +#define yynerrs frnerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + REAL = 258, + INT = 259, + STRING = 260, + POINTER = 261, + ANGDEGREE = 262, + ANGRADIAN = 263, + SEXSTR = 264, + HMSSTR = 265, + DMSSTR = 266, + ABOUT_ = 267, + AIP_ = 268, + ALLOC_ = 269, + ALLOCGZ_ = 270, + ALIGN_ = 271, + ALL_ = 272, + ALT_ = 273, + AMPLIFIER_ = 274, + ANALYSIS_ = 275, + ANGLE_ = 276, + ANNULUS_ = 277, + APPEND_ = 278, + ARCMIN_ = 279, + ARCSEC_ = 280, + ARRAY_ = 281, + ARROW_ = 282, + ASINH_ = 283, + AST_ = 284, + AUTO_ = 285, + AUX_ = 286, + AVERAGE_ = 287, + AXES_ = 288, + AZIMUTH_ = 289, + B1950_ = 290, + BACK_ = 291, + BACKGROUND_ = 292, + BASE_ = 293, + BBOX_ = 294, + BEGIN_ = 295, + BG_ = 296, + BIG_ = 297, + BIGENDIAN_ = 298, + BIN_ = 299, + BITPIX_ = 300, + BLOCK_ = 301, + BORDER_ = 302, + BOX_ = 303, + BOXANNULUS_ = 304, + BOXCAR_ = 305, + BOXCIRCLE_ = 306, + BPANDA_ = 307, + BUFFER_ = 308, + BW_ = 309, + CALLBACK_ = 310, + CANVAS_ = 311, + CATALOG_ = 312, + CELESTRIAL_ = 313, + CENTER_ = 314, + CENTROID_ = 315, + CHANNEL_ = 316, + CIRCLE_ = 317, + CIAO_ = 318, + CLEAR_ = 319, + CLIP_ = 320, + COLOR_ = 321, + COLORBAR_ = 322, + COLORMAP_ = 323, + COLORSCALE_ = 324, + COLORSPACE_ = 325, + COLS_ = 326, + COLUMN_ = 327, + COMMAND_ = 328, + COMPASS_ = 329, + COMPOSITE_ = 330, + COMPRESS_ = 331, + CONTOUR_ = 332, + CONTRAST_ = 333, + COORDINATES_ = 334, + COPY_ = 335, + COUNT_ = 336, + CPANDA_ = 337, + CREATE_ = 338, + CROP_ = 339, + CROSS_ = 340, + CROSSHAIR_ = 341, + CUBE_ = 342, + CURSOR_ = 343, + CUT_ = 344, + CMYK_ = 345, + DASH_ = 346, + DASHLIST_ = 347, + DATA_ = 348, + DATAMIN_ = 349, + DATASEC_ = 350, + DEBUG_ = 351, + DEGREES_ = 352, + DEFAULT_ = 353, + DELETE_ = 354, + DEPTH_ = 355, + DETECTOR_ = 356, + DIAMOND_ = 357, + DIM_ = 358, + DS9_ = 359, + EDIT_ = 360, + ECLIPTIC_ = 361, + ELEVATION_ = 362, + ELLIPSE_ = 363, + ELLIPSEANNULUS_ = 364, + END_ = 365, + ENVI_ = 366, + EPANDA_ = 367, + EPSILON_ = 368, + EQUATORIAL_ = 369, + ERASE_ = 370, + EXT_ = 371, + FACTOR_ = 372, + FALSE_ = 373, + FILE_ = 374, + FILTER_ = 375, + FIT_ = 376, + FITS_ = 377, + FITSY_ = 378, + FIXED_ = 379, + FK4_ = 380, + FK4_NO_E_ = 381, + FK5_ = 382, + FONT_ = 383, + FRONT_ = 384, + FULL_ = 385, + FUNCTION_ = 386, + GALACTIC_ = 387, + GAUSSIAN_ = 388, + GET_ = 389, + GLOBAL_ = 390, + GRAPHICS_ = 391, + GRAY_ = 392, + GRID_ = 393, + GZ_ = 394, + HANDLE_ = 395, + HAS_ = 396, + HEAD_ = 397, + HEADER_ = 398, + HEIGHT_ = 399, + HELIOECLIPTIC_ = 400, + HIDE_ = 401, + HIGHLITE_ = 402, + HISTEQU_ = 403, + HISTOGRAM_ = 404, + HORIZONTAL_ = 405, + ICRS_ = 406, + ID_ = 407, + IIS_ = 408, + IMAGE_ = 409, + INCLUDE_ = 410, + INCR_ = 411, + INFO_ = 412, + INTEGER_ = 413, + ITERATION_ = 414, + IRAF_ = 415, + IRAFMIN_ = 416, + J2000_ = 417, + KEY_ = 418, + KEYWORD_ = 419, + LABEL_ = 420, + LENGTH_ = 421, + LEVEL_ = 422, + LITTLE_ = 423, + LITTLEENDIAN_ = 424, + LINE_ = 425, + LINEAR_ = 426, + LIST_ = 427, + LOAD_ = 428, + LOCAL_ = 429, + LOG_ = 430, + MACOSX_ = 431, + MAGNIFIER_ = 432, + MATCH_ = 433, + MAP_ = 434, + MARK_ = 435, + MARKER_ = 436, + MASK_ = 437, + MESSAGE_ = 438, + METHOD_ = 439, + MINMAX_ = 440, + MIP_ = 441, + MMAP_ = 442, + MMAPINCR_ = 443, + MOSAIC_ = 444, + MODE_ = 445, + MOTION_ = 446, + MOVE_ = 447, + NAME_ = 448, + NAN_ = 449, + NATIVE_ = 450, + NAXES_ = 451, + NEW_ = 452, + NEXT_ = 453, + NO_ = 454, + NONE_ = 455, + NOW_ = 456, + NRRD_ = 457, + NUMBER_ = 458, + OBJECT_ = 459, + OFF_ = 460, + ON_ = 461, + ONLY_ = 462, + OPTION_ = 463, + ORIENT_ = 464, + PAN_ = 465, + PANNER_ = 466, + PARSER_ = 467, + PASTE_ = 468, + PERF_ = 469, + PHOTO_ = 470, + PHYSICAL_ = 471, + PIXEL_ = 472, + PLOT2D_ = 473, + PLOT3D_ = 474, + POINT_ = 475, + POINTER_ = 476, + POLYGON_ = 477, + POSTSCRIPT_ = 478, + POW_ = 479, + PRINT_ = 480, + PRESERVE_ = 481, + PROJECTION_ = 482, + PROPERTY_ = 483, + PUBLICATION_ = 484, + PROS_ = 485, + QUERY_ = 486, + RADIAL_ = 487, + RADIUS_ = 488, + REGION_ = 489, + REPLACE_ = 490, + RESAMPLE_ = 491, + RESET_ = 492, + RESOLUTION_ = 493, + RGB_ = 494, + ROOT_ = 495, + ROTATE_ = 496, + RULER_ = 497, + SAMPLE_ = 498, + SAOIMAGE_ = 499, + SAOTNG_ = 500, + SAVE_ = 501, + SCALE_ = 502, + SCAN_ = 503, + SCIENTIFIC_ = 504, + SCOPE_ = 505, + SEGMENT_ = 506, + SELECT_ = 507, + SET_ = 508, + SEXAGESIMAL_ = 509, + SHAPE_ = 510, + SHARED_ = 511, + SHIFT_ = 512, + SHMID_ = 513, + SHOW_ = 514, + SINH_ = 515, + SIZE_ = 516, + SLICE_ = 517, + SMMAP_ = 518, + SMOOTH_ = 519, + SOCKET_ = 520, + SOCKETGZ_ = 521, + SOURCE_ = 522, + SQRT_ = 523, + SQUARED_ = 524, + SSHARED_ = 525, + STATS_ = 526, + STATUS_ = 527, + SUPERGALACTIC_ = 528, + SUM_ = 529, + SYSTEM_ = 530, + TABLE_ = 531, + TAG_ = 532, + TEMPLATE_ = 533, + TEXT_ = 534, + THREADS_ = 535, + THREED_ = 536, + THRESHOLD_ = 537, + THICK_ = 538, + TRANSPARENCY_ = 539, + TO_ = 540, + TOGGLE_ = 541, + TOPHAT_ = 542, + TRUE_ = 543, + TYPE_ = 544, + UNDO_ = 545, + UNHIGHLITE_ = 546, + UNLOAD_ = 547, + UNSELECT_ = 548, + UPDATE_ = 549, + USER_ = 550, + VALUE_ = 551, + VAR_ = 552, + VIEW_ = 553, + VECTOR_ = 554, + VERSION_ = 555, + VERTEX_ = 556, + VERTICAL_ = 557, + WARP_ = 558, + WCS_ = 559, + WCSA_ = 560, + WCSB_ = 561, + WCSC_ = 562, + WCSD_ = 563, + WCSE_ = 564, + WCSF_ = 565, + WCSG_ = 566, + WCSH_ = 567, + WCSI_ = 568, + WCSJ_ = 569, + WCSK_ = 570, + WCSL_ = 571, + WCSM_ = 572, + WCSN_ = 573, + WCSO_ = 574, + WCSP_ = 575, + WCSQ_ = 576, + WCSR_ = 577, + WCSS_ = 578, + WCST_ = 579, + WCSU_ = 580, + WCSV_ = 581, + WCSW_ = 582, + WCSX_ = 583, + WCSY_ = 584, + WCSZ_ = 585, + WCS0_ = 586, + WFPC2_ = 587, + WIDTH_ = 588, + WIN32_ = 589, + XML_ = 590, + XY_ = 591, + YES_ = 592, + ZMAX_ = 593, + ZSCALE_ = 594, + ZOOM_ = 595 + }; +#endif +/* Tokens. */ +#define REAL 258 +#define INT 259 +#define STRING 260 +#define POINTER 261 +#define ANGDEGREE 262 +#define ANGRADIAN 263 +#define SEXSTR 264 +#define HMSSTR 265 +#define DMSSTR 266 +#define ABOUT_ 267 +#define AIP_ 268 +#define ALLOC_ 269 +#define ALLOCGZ_ 270 +#define ALIGN_ 271 +#define ALL_ 272 +#define ALT_ 273 +#define AMPLIFIER_ 274 +#define ANALYSIS_ 275 +#define ANGLE_ 276 +#define ANNULUS_ 277 +#define APPEND_ 278 +#define ARCMIN_ 279 +#define ARCSEC_ 280 +#define ARRAY_ 281 +#define ARROW_ 282 +#define ASINH_ 283 +#define AST_ 284 +#define AUTO_ 285 +#define AUX_ 286 +#define AVERAGE_ 287 +#define AXES_ 288 +#define AZIMUTH_ 289 +#define B1950_ 290 +#define BACK_ 291 +#define BACKGROUND_ 292 +#define BASE_ 293 +#define BBOX_ 294 +#define BEGIN_ 295 +#define BG_ 296 +#define BIG_ 297 +#define BIGENDIAN_ 298 +#define BIN_ 299 +#define BITPIX_ 300 +#define BLOCK_ 301 +#define BORDER_ 302 +#define BOX_ 303 +#define BOXANNULUS_ 304 +#define BOXCAR_ 305 +#define BOXCIRCLE_ 306 +#define BPANDA_ 307 +#define BUFFER_ 308 +#define BW_ 309 +#define CALLBACK_ 310 +#define CANVAS_ 311 +#define CATALOG_ 312 +#define CELESTRIAL_ 313 +#define CENTER_ 314 +#define CENTROID_ 315 +#define CHANNEL_ 316 +#define CIRCLE_ 317 +#define CIAO_ 318 +#define CLEAR_ 319 +#define CLIP_ 320 +#define COLOR_ 321 +#define COLORBAR_ 322 +#define COLORMAP_ 323 +#define COLORSCALE_ 324 +#define COLORSPACE_ 325 +#define COLS_ 326 +#define COLUMN_ 327 +#define COMMAND_ 328 +#define COMPASS_ 329 +#define COMPOSITE_ 330 +#define COMPRESS_ 331 +#define CONTOUR_ 332 +#define CONTRAST_ 333 +#define COORDINATES_ 334 +#define COPY_ 335 +#define COUNT_ 336 +#define CPANDA_ 337 +#define CREATE_ 338 +#define CROP_ 339 +#define CROSS_ 340 +#define CROSSHAIR_ 341 +#define CUBE_ 342 +#define CURSOR_ 343 +#define CUT_ 344 +#define CMYK_ 345 +#define DASH_ 346 +#define DASHLIST_ 347 +#define DATA_ 348 +#define DATAMIN_ 349 +#define DATASEC_ 350 +#define DEBUG_ 351 +#define DEGREES_ 352 +#define DEFAULT_ 353 +#define DELETE_ 354 +#define DEPTH_ 355 +#define DETECTOR_ 356 +#define DIAMOND_ 357 +#define DIM_ 358 +#define DS9_ 359 +#define EDIT_ 360 +#define ECLIPTIC_ 361 +#define ELEVATION_ 362 +#define ELLIPSE_ 363 +#define ELLIPSEANNULUS_ 364 +#define END_ 365 +#define ENVI_ 366 +#define EPANDA_ 367 +#define EPSILON_ 368 +#define EQUATORIAL_ 369 +#define ERASE_ 370 +#define EXT_ 371 +#define FACTOR_ 372 +#define FALSE_ 373 +#define FILE_ 374 +#define FILTER_ 375 +#define FIT_ 376 +#define FITS_ 377 +#define FITSY_ 378 +#define FIXED_ 379 +#define FK4_ 380 +#define FK4_NO_E_ 381 +#define FK5_ 382 +#define FONT_ 383 +#define FRONT_ 384 +#define FULL_ 385 +#define FUNCTION_ 386 +#define GALACTIC_ 387 +#define GAUSSIAN_ 388 +#define GET_ 389 +#define GLOBAL_ 390 +#define GRAPHICS_ 391 +#define GRAY_ 392 +#define GRID_ 393 +#define GZ_ 394 +#define HANDLE_ 395 +#define HAS_ 396 +#define HEAD_ 397 +#define HEADER_ 398 +#define HEIGHT_ 399 +#define HELIOECLIPTIC_ 400 +#define HIDE_ 401 +#define HIGHLITE_ 402 +#define HISTEQU_ 403 +#define HISTOGRAM_ 404 +#define HORIZONTAL_ 405 +#define ICRS_ 406 +#define ID_ 407 +#define IIS_ 408 +#define IMAGE_ 409 +#define INCLUDE_ 410 +#define INCR_ 411 +#define INFO_ 412 +#define INTEGER_ 413 +#define ITERATION_ 414 +#define IRAF_ 415 +#define IRAFMIN_ 416 +#define J2000_ 417 +#define KEY_ 418 +#define KEYWORD_ 419 +#define LABEL_ 420 +#define LENGTH_ 421 +#define LEVEL_ 422 +#define LITTLE_ 423 +#define LITTLEENDIAN_ 424 +#define LINE_ 425 +#define LINEAR_ 426 +#define LIST_ 427 +#define LOAD_ 428 +#define LOCAL_ 429 +#define LOG_ 430 +#define MACOSX_ 431 +#define MAGNIFIER_ 432 +#define MATCH_ 433 +#define MAP_ 434 +#define MARK_ 435 +#define MARKER_ 436 +#define MASK_ 437 +#define MESSAGE_ 438 +#define METHOD_ 439 +#define MINMAX_ 440 +#define MIP_ 441 +#define MMAP_ 442 +#define MMAPINCR_ 443 +#define MOSAIC_ 444 +#define MODE_ 445 +#define MOTION_ 446 +#define MOVE_ 447 +#define NAME_ 448 +#define NAN_ 449 +#define NATIVE_ 450 +#define NAXES_ 451 +#define NEW_ 452 +#define NEXT_ 453 +#define NO_ 454 +#define NONE_ 455 +#define NOW_ 456 +#define NRRD_ 457 +#define NUMBER_ 458 +#define OBJECT_ 459 +#define OFF_ 460 +#define ON_ 461 +#define ONLY_ 462 +#define OPTION_ 463 +#define ORIENT_ 464 +#define PAN_ 465 +#define PANNER_ 466 +#define PARSER_ 467 +#define PASTE_ 468 +#define PERF_ 469 +#define PHOTO_ 470 +#define PHYSICAL_ 471 +#define PIXEL_ 472 +#define PLOT2D_ 473 +#define PLOT3D_ 474 +#define POINT_ 475 +#define POINTER_ 476 +#define POLYGON_ 477 +#define POSTSCRIPT_ 478 +#define POW_ 479 +#define PRINT_ 480 +#define PRESERVE_ 481 +#define PROJECTION_ 482 +#define PROPERTY_ 483 +#define PUBLICATION_ 484 +#define PROS_ 485 +#define QUERY_ 486 +#define RADIAL_ 487 +#define RADIUS_ 488 +#define REGION_ 489 +#define REPLACE_ 490 +#define RESAMPLE_ 491 +#define RESET_ 492 +#define RESOLUTION_ 493 +#define RGB_ 494 +#define ROOT_ 495 +#define ROTATE_ 496 +#define RULER_ 497 +#define SAMPLE_ 498 +#define SAOIMAGE_ 499 +#define SAOTNG_ 500 +#define SAVE_ 501 +#define SCALE_ 502 +#define SCAN_ 503 +#define SCIENTIFIC_ 504 +#define SCOPE_ 505 +#define SEGMENT_ 506 +#define SELECT_ 507 +#define SET_ 508 +#define SEXAGESIMAL_ 509 +#define SHAPE_ 510 +#define SHARED_ 511 +#define SHIFT_ 512 +#define SHMID_ 513 +#define SHOW_ 514 +#define SINH_ 515 +#define SIZE_ 516 +#define SLICE_ 517 +#define SMMAP_ 518 +#define SMOOTH_ 519 +#define SOCKET_ 520 +#define SOCKETGZ_ 521 +#define SOURCE_ 522 +#define SQRT_ 523 +#define SQUARED_ 524 +#define SSHARED_ 525 +#define STATS_ 526 +#define STATUS_ 527 +#define SUPERGALACTIC_ 528 +#define SUM_ 529 +#define SYSTEM_ 530 +#define TABLE_ 531 +#define TAG_ 532 +#define TEMPLATE_ 533 +#define TEXT_ 534 +#define THREADS_ 535 +#define THREED_ 536 +#define THRESHOLD_ 537 +#define THICK_ 538 +#define TRANSPARENCY_ 539 +#define TO_ 540 +#define TOGGLE_ 541 +#define TOPHAT_ 542 +#define TRUE_ 543 +#define TYPE_ 544 +#define UNDO_ 545 +#define UNHIGHLITE_ 546 +#define UNLOAD_ 547 +#define UNSELECT_ 548 +#define UPDATE_ 549 +#define USER_ 550 +#define VALUE_ 551 +#define VAR_ 552 +#define VIEW_ 553 +#define VECTOR_ 554 +#define VERSION_ 555 +#define VERTEX_ 556 +#define VERTICAL_ 557 +#define WARP_ 558 +#define WCS_ 559 +#define WCSA_ 560 +#define WCSB_ 561 +#define WCSC_ 562 +#define WCSD_ 563 +#define WCSE_ 564 +#define WCSF_ 565 +#define WCSG_ 566 +#define WCSH_ 567 +#define WCSI_ 568 +#define WCSJ_ 569 +#define WCSK_ 570 +#define WCSL_ 571 +#define WCSM_ 572 +#define WCSN_ 573 +#define WCSO_ 574 +#define WCSP_ 575 +#define WCSQ_ 576 +#define WCSR_ 577 +#define WCSS_ 578 +#define WCST_ 579 +#define WCSU_ 580 +#define WCSV_ 581 +#define WCSW_ 582 +#define WCSX_ 583 +#define WCSY_ 584 +#define WCSZ_ 585 +#define WCS0_ 586 +#define WFPC2_ 587 +#define WIDTH_ 588 +#define WIN32_ 589 +#define XML_ 590 +#define XY_ 591 +#define YES_ 592 +#define ZMAX_ 593 +#define ZSCALE_ 594 +#define ZOOM_ 595 + + + + +/* Copy the first part of user declarations. */ +#line 10 "frame/parser.Y" + +#define YYDEBUG 1 + +#include +#include +#include + +#include "base.h" +#include "frame3d.h" +#include "fitsimage.h" +#include "marker.h" + +#undef yyFlexLexer +#define yyFlexLexer frFlexLexer +#include + +extern int frlex(void*, frFlexLexer*); +extern void frerror(Base*, frFlexLexer*, const char*); + +static Coord::CoordSystem currentCoord = Coord::IMAGE; +static Coord::SkyFrame currentSky = Coord::FK5; + +static unsigned short defaultProps = Marker::SELECT | Marker::HIGHLITE | + Marker::EDIT | Marker::MOVE | Marker::ROTATE | + Marker::DELETE | Marker::INCLUDE | Marker::SOURCE; +static unsigned short currentProps; +static char currentColor[16]; +static int currentWidth; +static int currentDash[2]; +static char currentFont[32]; +static char currentText[80]; + +static List taglist; +static List cblist; + +static unsigned short propQMask; +static unsigned short propQValue; + +static void setProps(unsigned short* props, unsigned short prop, int value); + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 51 "frame/parser.Y" +{ +#define FRBUFSIZE 4096 + char chr; + char str[FRBUFSIZE]; + void* ptr; + int integer; + double real; + double vector[3]; + int dash[2]; +} +/* Line 193 of yacc.c. */ +#line 836 "frame/parser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 849 "frame/parser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 354 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 5976 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 345 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 216 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 1263 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 2793 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 595 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint16 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 344, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 342, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 343, 341, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, + 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, + 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, + 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, + 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, + 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, + 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, + 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, + 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, + 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, + 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, + 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, + 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 6, 9, 12, 16, 19, 21, 23, + 26, 30, 33, 36, 39, 42, 45, 48, 51, 54, + 57, 60, 63, 65, 68, 71, 75, 78, 81, 84, + 87, 91, 94, 98, 101, 104, 107, 110, 113, 115, + 119, 122, 125, 128, 130, 133, 136, 139, 141, 144, + 146, 149, 152, 155, 158, 160, 162, 164, 166, 169, + 172, 175, 178, 181, 184, 187, 190, 193, 196, 199, + 201, 203, 205, 207, 209, 211, 213, 215, 217, 218, + 221, 224, 226, 228, 229, 231, 233, 235, 237, 239, + 241, 243, 246, 249, 252, 255, 257, 259, 261, 263, + 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, + 285, 287, 289, 291, 293, 295, 297, 299, 301, 303, + 305, 307, 309, 311, 313, 315, 317, 319, 321, 323, + 325, 327, 329, 331, 333, 335, 337, 339, 341, 343, + 345, 347, 349, 351, 352, 354, 356, 358, 360, 362, + 364, 366, 368, 370, 372, 373, 375, 377, 378, 380, + 382, 384, 386, 388, 390, 392, 394, 395, 397, 399, + 400, 402, 404, 405, 407, 409, 410, 412, 414, 416, + 418, 420, 422, 424, 425, 427, 429, 431, 433, 435, + 437, 439, 440, 442, 444, 445, 447, 449, 451, 453, + 455, 458, 461, 464, 467, 470, 473, 476, 478, 481, + 483, 486, 488, 491, 493, 496, 499, 506, 510, 514, + 518, 520, 523, 527, 531, 535, 539, 543, 547, 551, + 555, 559, 562, 567, 570, 573, 576, 580, 583, 586, + 588, 591, 593, 596, 601, 607, 610, 614, 620, 627, + 629, 631, 633, 641, 653, 662, 675, 677, 680, 683, + 685, 687, 690, 693, 696, 699, 703, 706, 709, 711, + 713, 715, 717, 719, 721, 723, 726, 729, 732, 736, + 739, 742, 745, 752, 763, 765, 768, 770, 777, 788, + 790, 793, 796, 799, 802, 805, 808, 821, 823, 824, + 826, 828, 833, 840, 842, 844, 846, 851, 855, 860, + 861, 868, 877, 880, 884, 888, 892, 893, 897, 902, + 907, 912, 916, 920, 922, 926, 932, 937, 942, 946, + 949, 953, 956, 959, 962, 965, 968, 971, 974, 977, + 980, 983, 986, 989, 992, 995, 997, 1000, 1003, 1008, + 1016, 1019, 1022, 1025, 1027, 1031, 1034, 1037, 1039, 1042, + 1051, 1054, 1056, 1059, 1061, 1064, 1066, 1071, 1079, 1082, + 1084, 1086, 1088, 1090, 1093, 1095, 1097, 1100, 1102, 1103, + 1106, 1109, 1111, 1113, 1115, 1117, 1120, 1123, 1126, 1128, + 1129, 1131, 1133, 1135, 1137, 1139, 1141, 1143, 1145, 1147, + 1149, 1150, 1152, 1155, 1157, 1162, 1168, 1169, 1172, 1174, + 1180, 1183, 1186, 1188, 1190, 1192, 1195, 1197, 1200, 1202, + 1204, 1205, 1207, 1208, 1210, 1216, 1223, 1228, 1232, 1239, + 1242, 1244, 1248, 1250, 1252, 1254, 1258, 1265, 1273, 1279, + 1281, 1283, 1288, 1294, 1296, 1300, 1301, 1303, 1306, 1308, + 1313, 1315, 1318, 1320, 1323, 1327, 1330, 1332, 1335, 1337, + 1342, 1345, 1347, 1349, 1353, 1355, 1358, 1362, 1365, 1366, + 1368, 1370, 1375, 1378, 1379, 1381, 1383, 1386, 1387, 1389, + 1391, 1393, 1395, 1397, 1399, 1401, 1403, 1405, 1407, 1409, + 1412, 1415, 1418, 1421, 1423, 1425, 1427, 1428, 1430, 1431, + 1433, 1434, 1436, 1437, 1439, 1440, 1443, 1446, 1447, 1449, + 1452, 1454, 1461, 1467, 1469, 1471, 1473, 1476, 1479, 1481, + 1483, 1485, 1487, 1490, 1492, 1494, 1496, 1499, 1501, 1503, + 1506, 1509, 1512, 1513, 1515, 1516, 1518, 1520, 1522, 1524, + 1526, 1528, 1530, 1532, 1535, 1538, 1540, 1543, 1547, 1549, + 1552, 1555, 1560, 1567, 1569, 1580, 1582, 1585, 1589, 1593, + 1596, 1599, 1602, 1605, 1608, 1611, 1614, 1619, 1624, 1629, + 1633, 1637, 1643, 1648, 1653, 1658, 1662, 1666, 1670, 1674, + 1677, 1680, 1685, 1689, 1693, 1697, 1701, 1706, 1711, 1716, + 1721, 1727, 1732, 1739, 1747, 1752, 1757, 1763, 1766, 1770, + 1774, 1778, 1781, 1785, 1789, 1793, 1797, 1802, 1806, 1812, + 1819, 1823, 1827, 1832, 1836, 1840, 1844, 1848, 1852, 1858, + 1862, 1866, 1871, 1875, 1878, 1881, 1883, 1887, 1892, 1897, + 1902, 1907, 1912, 1919, 1924, 1929, 1935, 1940, 1945, 1950, + 1955, 1961, 1966, 1973, 1981, 1986, 1991, 1997, 2003, 2009, + 2015, 2021, 2027, 2035, 2041, 2047, 2054, 2060, 2066, 2072, + 2078, 2085, 2091, 2099, 2108, 2114, 2120, 2127, 2131, 2135, + 2139, 2143, 2147, 2153, 2157, 2161, 2166, 2170, 2174, 2178, + 2182, 2187, 2191, 2197, 2204, 2208, 2212, 2217, 2221, 2225, + 2229, 2233, 2237, 2243, 2247, 2251, 2256, 2261, 2266, 2270, + 2276, 2281, 2286, 2289, 2293, 2300, 2307, 2309, 2311, 2313, + 2316, 2319, 2322, 2326, 2330, 2333, 2346, 2349, 2352, 2354, + 2358, 2363, 2366, 2367, 2371, 2373, 2375, 2378, 2381, 2384, + 2387, 2390, 2395, 2400, 2405, 2409, 2414, 2420, 2428, 2437, + 2444, 2453, 2463, 2470, 2477, 2485, 2496, 2508, 2521, 2531, + 2537, 2543, 2550, 2554, 2560, 2566, 2572, 2579, 2585, 2590, + 2600, 2611, 2623, 2633, 2640, 2647, 2654, 2661, 2668, 2675, + 2682, 2689, 2696, 2704, 2712, 2715, 2720, 2725, 2730, 2735, + 2741, 2746, 2751, 2757, 2763, 2767, 2772, 2777, 2782, 2789, + 2797, 2806, 2816, 2823, 2834, 2846, 2859, 2869, 2873, 2876, + 2880, 2886, 2893, 2901, 2906, 2910, 2914, 2921, 2928, 2935, + 2943, 2950, 2958, 2963, 2968, 2975, 2985, 2990, 2994, 3001, + 3009, 3017, 3020, 3024, 3028, 3032, 3037, 3040, 3043, 3048, + 3056, 3067, 3071, 3073, 3077, 3080, 3083, 3086, 3089, 3093, + 3099, 3104, 3110, 3113, 3121, 3125, 3128, 3131, 3135, 3138, + 3141, 3144, 3148, 3151, 3155, 3160, 3164, 3168, 3174, 3181, + 3186, 3189, 3193, 3196, 3199, 3204, 3208, 3212, 3215, 3219, + 3221, 3224, 3226, 3229, 3232, 3235, 3237, 3239, 3241, 3243, + 3246, 3248, 3251, 3254, 3256, 3259, 3262, 3264, 3267, 3269, + 3271, 3273, 3275, 3277, 3279, 3281, 3283, 3284, 3286, 3289, + 3292, 3295, 3299, 3305, 3313, 3321, 3328, 3335, 3342, 3349, + 3355, 3362, 3369, 3376, 3383, 3390, 3397, 3404, 3415, 3423, + 3431, 3439, 3449, 3459, 3470, 3483, 3496, 3499, 3502, 3506, + 3511, 3516, 3521, 3524, 3529, 3534, 3536, 3538, 3540, 3542, + 3544, 3546, 3548, 3550, 3553, 3555, 3557, 3559, 3563, 3567, + 3572, 3579, 3590, 3598, 3606, 3612, 3617, 3624, 3635, 3643, + 3651, 3657, 3660, 3663, 3667, 3672, 3678, 3684, 3690, 3694, + 3699, 3705, 3711, 3717, 3723, 3726, 3730, 3734, 3740, 3744, + 3748, 3752, 3757, 3763, 3769, 3775, 3781, 3785, 3790, 3796, + 3802, 3805, 3808, 3812, 3818, 3825, 3832, 3836, 3840, 3847, + 3853, 3859, 3862, 3866, 3872, 3879, 3883, 3886, 3889, 3893, + 3896, 3900, 3903, 3907, 3913, 3920, 3923, 3926, 3929, 3931, + 3936, 3941, 3943, 3946, 3949, 3952, 3955, 3958, 3961, 3964, + 3968, 3971, 3975, 3978, 3982, 3984, 3986, 3988, 3990, 3992, + 3993, 3996, 3997, 4000, 4001, 4003, 4004, 4005, 4007, 4009, + 4011, 4013, 4015, 4023, 4032, 4035, 4040, 4043, 4048, 4055, + 4058, 4060, 4062, 4066, 4070, 4072, 4076, 4081, 4084, 4086, + 4090, 4094, 4099, 4103, 4107, 4111, 4113, 4115, 4117, 4119, + 4121, 4123, 4125, 4127, 4129, 4131, 4133, 4135, 4137, 4139, + 4142, 4143, 4144, 4147, 4149, 4153, 4155, 4159, 4161, 4164, + 4167, 4169, 4173, 4174, 4175, 4178, 4181, 4183, 4187, 4193, + 4195, 4198, 4201, 4204, 4206, 4208, 4210, 4212, 4217, 4220, + 4224, 4228, 4231, 4235, 4238, 4241, 4244, 4248, 4252, 4256, + 4259, 4263, 4265, 4269, 4273, 4275, 4278, 4281, 4284, 4287, + 4289, 4291, 4293, 4295, 4298, 4301, 4305, 4309, 4311, 4314, + 4318, 4322, 4324, 4327, 4329, 4331, 4333, 4335, 4337, 4340, + 4343, 4348, 4350, 4353, 4356, 4359, 4363, 4365, 4367, 4369, + 4372, 4375, 4378, 4381, 4384, 4388, 4392, 4396, 4400, 4404, + 4408, 4412, 4414, 4417, 4420, 4423, 4427, 4430, 4434, 4438, + 4441, 4444, 4447, 4450, 4453, 4456, 4459, 4462, 4465, 4468, + 4471, 4474, 4477, 4480, 4484, 4488, 4492, 4495, 4498, 4501, + 4504, 4507, 4510, 4513, 4516, 4519, 4522, 4525, 4528, 4532, + 4536, 4540, 4545, 4548, 4550, 4552, 4554, 4556, 4557, 4563, + 4565, 4572, 4576, 4578, 4581, 4584, 4588, 4591, 4595, 4599, + 4602, 4605, 4608, 4611, 4614, 4617, 4621, 4624, 4627, 4631, + 4633, 4637, 4642, 4644, 4647, 4653, 4660, 4667, 4670, 4672, + 4675, 4678, 4684, 4691 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int16 yyrhs[] = +{ + 346, 0, -1, 96, 348, -1, 20, 379, -1, 44, + 381, -1, 41, 66, 5, -1, 46, 386, -1, 59, + -1, 64, -1, 65, 388, -1, 67, 277, 5, -1, + 68, 393, -1, 69, 395, -1, 77, 396, -1, 84, + 403, -1, 86, 405, -1, 87, 406, -1, 95, 349, + -1, 123, 407, -1, 134, 408, -1, 138, 451, -1, + 141, 454, -1, 146, -1, 147, 349, -1, 153, 460, + -1, 160, 16, 4, -1, 173, 463, -1, 176, 481, + -1, 177, 482, -1, 178, 483, -1, 181, 499, 484, + -1, 182, 518, -1, 194, 66, 5, -1, 209, 519, + -1, 210, 520, -1, 211, 523, -1, 231, 88, -1, + 223, 524, -1, 237, -1, 234, 499, 526, -1, 239, + 531, -1, 241, 532, -1, 246, 534, -1, 259, -1, + 264, 549, -1, 280, 4, -1, 281, 374, -1, 292, + -1, 294, 551, -1, 300, -1, 303, 553, -1, 304, + 554, -1, 334, 558, -1, 340, 559, -1, 3, -1, + 4, -1, 206, -1, 205, -1, 29, 349, -1, 189, + 349, -1, 212, 349, -1, 214, 349, -1, 304, 349, + -1, 44, 349, -1, 46, 349, -1, 76, 349, -1, + 84, 349, -1, 139, 349, -1, 239, 349, -1, 4, + -1, 337, -1, 341, -1, 206, -1, 288, -1, 199, + -1, 342, -1, 205, -1, 118, -1, -1, 240, 38, + -1, 130, 38, -1, 240, -1, 130, -1, -1, 352, + -1, 347, -1, 7, -1, 8, -1, 9, -1, 10, + -1, 11, -1, 353, 353, -1, 354, 355, -1, 355, + 355, -1, 347, 347, -1, 154, -1, 216, -1, 101, + -1, 19, -1, 358, -1, 304, -1, 305, -1, 306, + -1, 307, -1, 308, -1, 309, -1, 310, -1, 311, + -1, 312, -1, 313, -1, 314, -1, 315, -1, 316, + -1, 317, -1, 318, -1, 319, -1, 320, -1, 321, + -1, 322, -1, 323, -1, 324, -1, 325, -1, 326, + -1, 327, -1, 328, -1, 329, -1, 330, -1, 331, + -1, 56, -1, 211, -1, 171, -1, 175, -1, 224, + -1, 268, -1, 269, -1, 28, -1, 260, -1, 148, + -1, 30, -1, 248, -1, 243, -1, 94, -1, 161, + -1, -1, 125, -1, 126, -1, 35, -1, 127, -1, + 162, -1, 151, -1, 132, -1, 273, -1, 106, -1, + 145, -1, -1, 97, -1, 254, -1, -1, 97, -1, + 24, -1, 25, -1, 347, -1, 185, -1, 339, -1, + 338, -1, 295, -1, -1, 258, -1, 163, -1, -1, + 17, -1, 156, -1, -1, 154, -1, 182, -1, -1, + 62, -1, 48, -1, 102, -1, 85, -1, 343, -1, + 27, -1, 51, -1, -1, 4, -1, 82, -1, 149, + -1, 218, -1, 219, -1, 232, -1, 271, -1, -1, + 32, -1, 274, -1, -1, 195, -1, 42, -1, 43, + -1, 168, -1, 169, -1, 298, 378, -1, 47, 375, + -1, 74, 376, -1, 147, 377, -1, 184, 529, -1, + 37, 530, -1, 247, 347, -1, 226, -1, 282, 347, + -1, 349, -1, 66, 5, -1, 349, -1, 66, 5, + -1, 349, -1, 66, 5, -1, 347, 347, -1, 220, + 347, 347, 347, 347, 347, -1, 40, 347, 347, -1, + 191, 347, 347, -1, 110, 347, 347, -1, 237, -1, + 255, 380, -1, 62, 347, 347, -1, 108, 347, 347, + -1, 48, 347, 347, -1, 222, 347, 347, -1, 220, + 347, 347, -1, 299, 347, 347, -1, 22, 347, 347, + -1, 109, 347, 347, -1, 49, 347, 347, -1, 12, + 382, -1, 71, 5, 5, 5, -1, 100, 4, -1, + 117, 383, -1, 131, 384, -1, 53, 261, 4, -1, + 285, 385, -1, 120, 5, -1, 59, -1, 347, 347, + -1, 347, -1, 347, 347, -1, 347, 12, 347, 347, + -1, 347, 347, 12, 347, 347, -1, 285, 347, -1, + 285, 347, 347, -1, 285, 347, 12, 347, 347, -1, + 285, 347, 347, 12, 347, 347, -1, 32, -1, 274, + -1, 121, -1, 347, 347, 12, 59, 5, 5, 5, + -1, 347, 347, 4, 347, 347, 12, 59, 5, 5, + 5, 5, -1, 347, 347, 12, 347, 347, 5, 5, + 5, -1, 347, 347, 4, 347, 347, 12, 347, 347, + 5, 5, 5, 5, -1, 347, -1, 347, 347, -1, + 285, 387, -1, 121, -1, 347, -1, 347, 347, -1, + 250, 389, -1, 190, 390, -1, 185, 391, -1, 295, + 347, 347, -1, 339, 392, -1, 226, 349, -1, 135, + -1, 174, -1, 347, -1, 185, -1, 339, -1, 338, + -1, 295, -1, 4, 361, -1, 190, 361, -1, 243, + 4, -1, 347, 4, 4, -1, 78, 347, -1, 243, + 4, -1, 170, 4, -1, 4, 347, 347, 4, 6, + 4, -1, 239, 347, 347, 347, 347, 347, 347, 4, + 6, 4, -1, 40, -1, 191, 394, -1, 110, -1, + 4, 347, 347, 4, 6, 4, -1, 239, 347, 347, + 347, 347, 347, 347, 4, 6, 4, -1, 360, -1, + 175, 347, -1, 83, 397, -1, 99, 398, -1, 173, + 399, -1, 213, 401, -1, 246, 402, -1, 5, 4, + 4, 400, 4, 4, 360, 347, 365, 347, 347, 5, + -1, 222, -1, -1, 31, -1, 5, -1, 5, 5, + 4, 349, -1, 5, 4, 349, 5, 357, 362, -1, + 264, -1, 46, -1, 5, -1, 5, 5, 4, 349, + -1, 5, 357, 362, -1, 31, 5, 357, 362, -1, + -1, 347, 347, 347, 347, 357, 362, -1, 59, 356, + 357, 362, 347, 347, 357, 364, -1, 281, 404, -1, + 40, 347, 347, -1, 191, 347, 347, -1, 110, 347, + 347, -1, -1, 347, 347, 357, -1, 40, 347, 347, + 4, -1, 191, 347, 347, 4, -1, 110, 347, 347, + 4, -1, 359, 347, 347, -1, 357, 362, 356, -1, + 349, -1, 303, 347, 347, -1, 40, 191, 359, 347, + 347, -1, 191, 359, 347, 347, -1, 40, 191, 357, + 356, -1, 191, 357, 356, -1, 33, 4, -1, 141, + 116, 5, -1, 41, 66, -1, 44, 409, -1, 46, + 411, -1, 65, 412, -1, 68, 417, -1, 67, 416, + -1, 69, 419, -1, 77, 421, -1, 79, 424, -1, + 84, 425, -1, 86, 426, -1, 88, 428, -1, 87, + 427, -1, 93, 429, -1, 95, -1, 122, 433, -1, + 138, 439, -1, 149, 5, 5, 4, -1, 150, 89, + 5, 5, 347, 347, 359, -1, 153, 431, -1, 157, + 430, -1, 160, 16, -1, 185, -1, 181, 499, 493, + -1, 182, 440, -1, 194, 66, -1, 209, -1, 210, + 441, -1, 217, 276, 359, 347, 347, 4, 4, 5, + -1, 239, 442, -1, 241, -1, 264, 443, -1, 280, + -1, 281, 444, -1, 289, -1, 296, 359, 347, 347, + -1, 302, 89, 5, 5, 347, 347, 359, -1, 304, + 449, -1, 340, -1, 100, -1, 117, -1, 131, -1, + 53, 261, -1, 88, -1, 120, -1, 71, 410, -1, + 172, -1, -1, 185, 5, -1, 103, 5, -1, 117, + -1, 413, -1, 250, -1, 190, -1, 185, 414, -1, + 295, 167, -1, 339, 415, -1, 226, -1, -1, 347, + -1, 185, -1, 339, -1, 338, -1, 295, -1, 190, + -1, 243, -1, 78, -1, 243, -1, 170, -1, -1, + 277, -1, 167, 418, -1, 4, -1, 4, 359, 347, + 347, -1, 4, 347, 347, 360, 347, -1, -1, 167, + 420, -1, 175, -1, 4, 347, 347, 360, 347, -1, + 357, 362, -1, 65, 422, -1, 66, -1, 91, -1, + 167, -1, 203, 167, -1, 184, -1, 69, 423, -1, + 264, -1, 333, -1, -1, 190, -1, -1, 175, -1, + 347, 347, 357, 362, 363, -1, 359, 347, 347, 357, + 362, 363, -1, 347, 357, 357, 4, -1, 357, 362, + 363, -1, 59, 357, 362, 363, 357, 364, -1, 281, + 357, -1, 359, -1, 357, 362, 363, -1, 272, -1, + 33, -1, 359, -1, 357, 362, 363, -1, 357, 362, + 356, 347, 347, 5, -1, 4, 357, 362, 356, 347, + 347, 5, -1, 359, 347, 347, 4, 4, -1, 5, + -1, 65, -1, 359, 347, 347, 5, -1, 6, 4, + 4, 4, 4, -1, 88, -1, 119, 193, 432, -1, + -1, 4, -1, 347, 347, -1, 196, -1, 59, 357, + 362, 363, -1, 81, -1, 100, 436, -1, 45, -1, + 116, 434, -1, 119, 193, 437, -1, 143, 435, -1, + 144, -1, 204, 193, -1, 261, -1, 261, 357, 362, + 364, -1, 262, 438, -1, 333, -1, 4, -1, 359, + 347, 347, -1, 4, -1, 164, 5, -1, 4, 164, + 5, -1, 304, 4, -1, -1, 4, -1, 350, -1, + 350, 359, 347, 347, -1, 350, 4, -1, -1, 4, + -1, 357, -1, 4, 357, -1, -1, 208, -1, 297, + -1, 66, -1, 180, -1, 284, -1, 226, -1, 61, + -1, 275, -1, 298, -1, 131, -1, 233, -1, 298, + 448, -1, 47, 445, -1, 74, 446, -1, 147, 447, + -1, 184, -1, 37, -1, 247, -1, -1, 66, -1, + -1, 66, -1, -1, 66, -1, -1, 220, -1, -1, + 16, 450, -1, 193, 358, -1, -1, 221, -1, 83, + 452, -1, 99, -1, 357, 362, 363, 453, 5, 5, + -1, 357, 362, 363, 453, 5, -1, 20, -1, 229, + -1, 19, -1, 44, 455, -1, 77, 456, -1, 84, + -1, 94, -1, 95, -1, 101, -1, 122, 457, -1, + 138, -1, 153, -1, 161, -1, 181, 458, -1, 216, + -1, 264, -1, 275, 357, -1, 304, 459, -1, 72, + 5, -1, -1, 31, -1, -1, 44, -1, 87, -1, + 189, -1, 147, -1, 252, -1, 213, -1, 290, -1, + 357, -1, 114, 357, -1, 58, 357, -1, 18, -1, + 281, 357, -1, 197, 4, 4, -1, 115, -1, 183, + 5, -1, 88, 462, -1, 253, 119, 193, 461, -1, + 253, 6, 4, 4, 4, 4, -1, 294, -1, 304, + 347, 347, 347, 347, 347, 347, 347, 347, 4, -1, + 5, -1, 5, 4, -1, 4, 4, 56, -1, 4, + 4, 357, -1, 190, 349, -1, 26, 464, -1, 111, + 466, -1, 122, 467, -1, 156, 480, -1, 202, 478, + -1, 215, 479, -1, 5, 14, 5, 368, -1, 5, + 15, 5, 368, -1, 5, 61, 5, 368, -1, 5, + 187, 368, -1, 5, 188, 368, -1, 5, 256, 366, + 4, 368, -1, 5, 265, 4, 368, -1, 5, 266, + 4, 368, -1, 5, 297, 5, 368, -1, 239, 87, + 465, -1, 5, 14, 5, -1, 5, 15, 5, -1, + 5, 61, 5, -1, 5, 187, -1, 5, 188, -1, + 5, 256, 366, 4, -1, 5, 265, 4, -1, 5, + 266, 4, -1, 5, 297, 5, -1, 5, 5, 263, + -1, 5, 14, 5, 368, -1, 5, 15, 5, 368, + -1, 5, 61, 5, 368, -1, 5, 187, 367, 368, + -1, 5, 5, 263, 367, 368, -1, 5, 188, 367, + 368, -1, 5, 256, 366, 4, 367, 368, -1, 5, + 270, 366, 4, 4, 367, 368, -1, 5, 265, 4, + 368, -1, 5, 266, 4, 368, -1, 5, 297, 5, + 367, 368, -1, 262, 468, -1, 116, 87, 469, -1, + 239, 154, 477, -1, 239, 87, 476, -1, 189, 470, + -1, 5, 14, 5, -1, 5, 15, 5, -1, 5, + 61, 5, -1, 5, 187, 367, -1, 5, 5, 263, + 367, -1, 5, 188, 367, -1, 5, 256, 366, 4, + 367, -1, 5, 270, 366, 4, 4, 367, -1, 5, + 265, 4, -1, 5, 266, 4, -1, 5, 297, 5, + 367, -1, 5, 14, 5, -1, 5, 15, 5, -1, + 5, 61, 5, -1, 5, 187, 367, -1, 5, 188, + 367, -1, 5, 256, 366, 4, 367, -1, 5, 265, + 4, -1, 5, 266, 4, -1, 5, 297, 5, 367, + -1, 154, 160, 471, -1, 160, 472, -1, 154, 473, + -1, 474, -1, 154, 332, 475, -1, 5, 14, 5, + 368, -1, 5, 15, 5, 368, -1, 5, 61, 5, + 368, -1, 5, 187, 367, 368, -1, 5, 188, 367, + 368, -1, 5, 256, 366, 4, 367, 368, -1, 5, + 265, 4, 368, -1, 5, 266, 4, 368, -1, 5, + 297, 5, 367, 368, -1, 5, 14, 5, 368, -1, + 5, 15, 5, 368, -1, 5, 61, 5, 368, -1, + 5, 187, 367, 368, -1, 5, 5, 263, 367, 368, + -1, 5, 188, 367, 368, -1, 5, 256, 366, 4, + 367, 368, -1, 5, 270, 366, 4, 4, 367, 368, + -1, 5, 265, 4, 368, -1, 5, 266, 4, 368, + -1, 5, 297, 5, 367, 368, -1, 358, 5, 14, + 5, 368, -1, 358, 5, 15, 5, 368, -1, 358, + 5, 61, 5, 368, -1, 358, 5, 187, 367, 368, + -1, 358, 5, 188, 367, 368, -1, 358, 5, 256, + 366, 4, 367, 368, -1, 358, 5, 265, 4, 368, + -1, 358, 5, 266, 4, 368, -1, 358, 5, 297, + 5, 367, 368, -1, 358, 5, 14, 5, 368, -1, + 358, 5, 15, 5, 368, -1, 358, 5, 61, 5, + 368, -1, 358, 5, 187, 367, 368, -1, 358, 5, + 5, 263, 367, 368, -1, 358, 5, 188, 367, 368, + -1, 358, 5, 256, 366, 4, 367, 368, -1, 358, + 5, 270, 366, 4, 4, 367, 368, -1, 358, 5, + 265, 4, 368, -1, 358, 5, 266, 4, 368, -1, + 358, 5, 297, 5, 367, 368, -1, 5, 14, 5, + -1, 5, 15, 5, -1, 5, 61, 5, -1, 5, + 187, 367, -1, 5, 188, 367, -1, 5, 256, 366, + 4, 367, -1, 5, 265, 4, -1, 5, 266, 4, + -1, 5, 297, 5, 367, -1, 5, 14, 5, -1, + 5, 15, 5, -1, 5, 61, 5, -1, 5, 187, + 367, -1, 5, 5, 263, 367, -1, 5, 188, 367, + -1, 5, 256, 366, 4, 367, -1, 5, 270, 366, + 4, 4, 367, -1, 5, 265, 4, -1, 5, 266, + 4, -1, 5, 297, 5, 367, -1, 5, 14, 5, + -1, 5, 15, 5, -1, 5, 61, 5, -1, 5, + 187, 367, -1, 5, 188, 367, -1, 5, 256, 366, + 4, 367, -1, 5, 265, 4, -1, 5, 266, 4, + -1, 5, 297, 5, 367, -1, 5, 14, 5, 368, + -1, 5, 61, 5, 368, -1, 5, 187, 368, -1, + 5, 256, 366, 4, 368, -1, 5, 265, 4, 368, + -1, 5, 297, 5, 368, -1, 5, 5, -1, 262, + 5, 5, -1, 93, 4, 4, 4, 4, 4, -1, + 185, 4, 4, 4, 4, 4, -1, 110, -1, 225, + -1, 349, -1, 136, 349, -1, 88, 349, -1, 66, + 5, -1, 5, 4, 4, -1, 294, 347, 347, -1, + 340, 347, -1, 5, 5, 358, 362, 5, 5, 358, + 362, 347, 358, 364, 5, -1, 60, 487, -1, 66, + 5, -1, 80, -1, 73, 492, 5, -1, 73, 492, + 297, 5, -1, 75, 99, -1, -1, 83, 485, 488, + -1, 89, -1, 99, -1, 99, 17, -1, 105, 491, + -1, 113, 4, -1, 128, 5, -1, 147, 17, -1, + 147, 207, 347, 347, -1, 147, 286, 347, 347, -1, + 4, 20, 371, 349, -1, 4, 21, 352, -1, 4, + 21, 352, 359, -1, 4, 21, 352, 357, 362, -1, + 4, 22, 233, 347, 347, 4, 359, -1, 4, 22, + 233, 347, 347, 4, 357, 364, -1, 4, 22, 233, + 5, 357, 364, -1, 4, 49, 233, 347, 347, 347, + 4, 359, -1, 4, 49, 233, 347, 347, 347, 4, + 357, 364, -1, 4, 49, 233, 5, 357, 364, -1, + 4, 48, 233, 347, 347, 359, -1, 4, 48, 233, + 347, 347, 357, 364, -1, 4, 52, 105, 352, 352, + 4, 347, 347, 347, 4, -1, 4, 52, 105, 352, + 352, 4, 347, 347, 347, 4, 359, -1, 4, 52, + 105, 352, 352, 4, 347, 347, 347, 4, 357, 362, + -1, 4, 52, 105, 5, 5, 357, 362, 357, 364, + -1, 4, 55, 486, 5, 5, -1, 4, 62, 233, + 347, 359, -1, 4, 62, 233, 347, 357, 364, -1, + 4, 66, 5, -1, 4, 74, 27, 349, 349, -1, + 4, 74, 165, 5, 5, -1, 4, 74, 233, 347, + 359, -1, 4, 74, 233, 347, 357, 364, -1, 4, + 74, 275, 357, 362, -1, 4, 75, 135, 349, -1, + 4, 82, 105, 352, 352, 4, 347, 347, 4, -1, + 4, 82, 105, 352, 352, 4, 347, 347, 4, 359, + -1, 4, 82, 105, 352, 352, 4, 347, 347, 4, + 357, 362, -1, 4, 82, 105, 5, 5, 357, 362, + 357, 364, -1, 4, 83, 22, 233, 347, 347, -1, + 4, 83, 49, 233, 347, 347, -1, 4, 83, 52, + 21, 347, 347, -1, 4, 83, 52, 233, 347, 347, + -1, 4, 83, 109, 233, 347, 347, -1, 4, 83, + 112, 21, 347, 347, -1, 4, 83, 112, 233, 347, + 347, -1, 4, 83, 82, 21, 347, 347, -1, 4, + 83, 82, 233, 347, 347, -1, 4, 83, 222, 301, + 4, 347, 347, -1, 4, 83, 251, 301, 4, 347, + 347, -1, 4, 99, -1, 4, 99, 22, 4, -1, + 4, 99, 49, 4, -1, 4, 99, 52, 4, -1, + 4, 99, 109, 4, -1, 4, 99, 55, 486, 5, + -1, 4, 99, 112, 4, -1, 4, 99, 82, 4, + -1, 4, 99, 222, 301, 4, -1, 4, 99, 251, + 301, 4, -1, 4, 99, 277, -1, 4, 99, 277, + 5, -1, 4, 99, 277, 4, -1, 4, 105, 40, + 4, -1, 4, 108, 233, 347, 347, 359, -1, 4, + 108, 233, 347, 347, 357, 364, -1, 4, 109, 233, + 347, 347, 347, 4, 359, -1, 4, 109, 233, 347, + 347, 347, 4, 357, 364, -1, 4, 109, 233, 5, + 357, 364, -1, 4, 112, 105, 352, 352, 4, 347, + 347, 347, 4, -1, 4, 112, 105, 352, 352, 4, + 347, 347, 347, 4, 359, -1, 4, 112, 105, 352, + 352, 4, 347, 347, 347, 4, 357, 362, -1, 4, + 112, 105, 5, 5, 357, 362, 357, 364, -1, 4, + 128, 5, -1, 4, 147, -1, 4, 147, 207, -1, + 4, 170, 27, 349, 349, -1, 4, 170, 220, 359, + 356, 356, -1, 4, 170, 220, 357, 362, 356, 356, + -1, 4, 192, 347, 347, -1, 4, 192, 129, -1, + 4, 192, 36, -1, 4, 192, 285, 359, 347, 347, + -1, 4, 192, 285, 357, 362, 356, -1, 4, 222, + 237, 347, 347, 359, -1, 4, 222, 237, 347, 347, + 357, 364, -1, 4, 251, 237, 347, 347, 359, -1, + 4, 251, 237, 347, 347, 357, 364, -1, 4, 220, + 255, 369, -1, 4, 220, 261, 4, -1, 4, 227, + 359, 356, 356, 347, -1, 4, 227, 357, 362, 356, + 356, 347, 357, 364, -1, 4, 228, 505, 349, -1, + 4, 241, 40, -1, 4, 242, 220, 359, 356, 356, + -1, 4, 242, 220, 357, 362, 356, 356, -1, 4, + 242, 275, 357, 362, 357, 364, -1, 4, 252, -1, + 4, 252, 207, -1, 4, 277, 5, -1, 4, 279, + 5, -1, 4, 279, 241, 349, -1, 4, 291, -1, + 4, 293, -1, 4, 299, 27, 349, -1, 4, 299, + 220, 359, 356, 347, 352, -1, 4, 299, 220, 357, + 362, 356, 357, 364, 347, 352, -1, 4, 333, 4, + -1, 163, -1, 163, 347, 347, -1, 172, 500, -1, + 173, 501, -1, 192, 502, -1, 226, 349, -1, 228, + 505, 349, -1, 228, 505, 349, 347, 347, -1, 241, + 40, 347, 347, -1, 241, 191, 347, 347, 4, -1, + 241, 110, -1, 246, 5, 492, 357, 362, 363, 349, + -1, 246, 278, 5, -1, 252, 509, -1, 259, 510, + -1, 5, 66, 5, -1, 5, 80, -1, 5, 99, + -1, 5, 89, -1, 5, 128, 5, -1, 5, 147, + -1, 5, 147, 207, -1, 5, 192, 347, 347, -1, + 5, 192, 129, -1, 5, 192, 36, -1, 5, 192, + 285, 359, 356, -1, 5, 192, 285, 357, 362, 356, + -1, 5, 228, 505, 349, -1, 5, 252, -1, 5, + 252, 207, -1, 5, 291, -1, 5, 293, -1, 277, + 105, 5, 5, -1, 277, 99, 5, -1, 277, 99, + 17, -1, 277, 5, -1, 277, 294, 5, -1, 213, + -1, 213, 357, -1, 290, -1, 291, 17, -1, 293, + 17, -1, 333, 4, -1, 252, -1, 293, -1, 147, + -1, 291, -1, 40, 192, -1, 192, -1, 110, 192, + -1, 40, 105, -1, 105, -1, 110, 105, -1, 40, + 241, -1, 241, -1, 110, 241, -1, 99, -1, 279, + -1, 66, -1, 333, -1, 228, -1, 128, -1, 163, + -1, 294, -1, -1, 4, -1, 30, 349, -1, 233, + 347, -1, 159, 4, -1, 208, 4, 347, -1, 62, + 347, 347, 347, 506, -1, 108, 347, 347, 347, 347, + 351, 506, -1, 48, 347, 347, 347, 347, 351, 506, + -1, 222, 347, 347, 347, 347, 506, -1, 251, 347, + 347, 347, 347, 506, -1, 170, 347, 347, 347, 347, + 506, -1, 299, 347, 347, 347, 347, 506, -1, 279, + 347, 347, 351, 506, -1, 62, 220, 347, 347, 370, + 506, -1, 48, 220, 347, 347, 370, 506, -1, 102, + 220, 347, 347, 370, 506, -1, 85, 220, 347, 347, + 370, 506, -1, 343, 220, 347, 347, 370, 506, -1, + 27, 220, 347, 347, 370, 506, -1, 51, 220, 347, + 347, 370, 506, -1, 242, 347, 347, 347, 347, 357, + 362, 357, 364, 506, -1, 74, 347, 347, 347, 357, + 362, 506, -1, 227, 347, 347, 347, 347, 347, 506, + -1, 22, 347, 347, 347, 347, 4, 506, -1, 109, + 347, 347, 347, 347, 347, 4, 351, 506, -1, 49, + 347, 347, 347, 347, 347, 4, 351, 506, -1, 82, + 347, 347, 352, 352, 4, 347, 347, 4, 506, -1, + 112, 347, 347, 352, 352, 4, 347, 347, 347, 4, + 351, 506, -1, 52, 347, 347, 352, 352, 4, 347, + 347, 347, 4, 351, 506, -1, 75, 506, -1, 278, + 489, -1, 5, 347, 347, -1, 297, 5, 347, 347, + -1, 347, 347, 297, 5, -1, 5, 357, 362, 356, + -1, 4, 4, -1, 40, 347, 347, 4, -1, 191, + 347, 347, 4, -1, 110, -1, 104, -1, 335, -1, + 63, -1, 245, -1, 244, -1, 230, -1, 336, -1, + 60, 494, -1, 66, -1, 128, -1, 113, -1, 140, + 347, 347, -1, 152, 347, 347, -1, 146, 20, 82, + 357, -1, 146, 20, 149, 5, 5, 4, -1, 146, + 20, 218, 5, 5, 5, 5, 357, 362, 372, -1, + 146, 20, 219, 5, 5, 357, 372, -1, 146, 20, + 232, 5, 5, 5, 357, -1, 146, 20, 271, 357, + 362, -1, 4, 20, 82, 357, -1, 4, 20, 149, + 5, 5, 4, -1, 4, 20, 218, 5, 5, 5, + 5, 357, 362, 372, -1, 4, 20, 219, 5, 5, + 357, 372, -1, 4, 20, 232, 5, 5, 5, 357, + -1, 4, 20, 271, 357, 362, -1, 152, 17, -1, + 4, 21, -1, 4, 21, 359, -1, 4, 21, 357, + 362, -1, 4, 22, 233, 357, 364, -1, 4, 49, + 233, 357, 364, -1, 4, 48, 233, 357, 364, -1, + 4, 52, 21, -1, 4, 52, 21, 359, -1, 4, + 52, 21, 357, 362, -1, 4, 52, 233, 357, 364, + -1, 4, 59, 357, 362, 363, -1, 4, 62, 233, + 357, 364, -1, 4, 66, -1, 4, 74, 27, -1, + 4, 74, 165, -1, 4, 74, 233, 357, 364, -1, + 4, 74, 275, -1, 4, 75, 135, -1, 4, 82, + 21, -1, 4, 82, 21, 359, -1, 4, 82, 21, + 357, 362, -1, 4, 82, 233, 357, 364, -1, 4, + 108, 233, 357, 364, -1, 4, 109, 233, 357, 364, + -1, 4, 112, 21, -1, 4, 112, 21, 359, -1, + 4, 112, 21, 357, 362, -1, 4, 112, 233, 357, + 364, -1, 4, 128, -1, 4, 147, -1, 4, 170, + 27, -1, 4, 170, 166, 357, 364, -1, 4, 170, + 220, 357, 362, 363, -1, 4, 179, 166, 347, 357, + 364, -1, 4, 220, 255, -1, 4, 220, 261, -1, + 4, 227, 220, 357, 362, 363, -1, 4, 227, 166, + 357, 364, -1, 4, 227, 283, 357, 364, -1, 4, + 228, -1, 4, 228, 505, -1, 4, 242, 166, 357, + 364, -1, 4, 242, 220, 357, 362, 363, -1, 4, + 242, 275, -1, 4, 252, -1, 4, 277, -1, 4, + 277, 4, -1, 4, 279, -1, 4, 279, 241, -1, + 4, 289, -1, 4, 299, 27, -1, 4, 299, 166, + 357, 364, -1, 4, 299, 220, 357, 362, 363, -1, + 4, 333, -1, 147, 495, -1, 147, 203, -1, 203, + -1, 222, 251, 347, 347, -1, 251, 251, 347, 347, + -1, 226, -1, 228, 505, -1, 252, 496, -1, 252, + 203, -1, 259, 497, -1, 5, 66, -1, 5, 128, + -1, 5, 152, -1, 5, 228, 505, -1, 5, 277, + -1, 5, 277, 203, -1, 277, 17, -1, 277, 98, + 193, -1, 333, -1, 30, -1, 233, -1, 159, -1, + 208, -1, -1, 347, 347, -1, -1, 347, 347, -1, + -1, 279, -1, -1, -1, 221, -1, 234, -1, 295, + -1, 57, -1, 20, -1, 492, 357, 362, 363, 349, + 507, 513, -1, 252, 492, 357, 362, 363, 349, 507, + 513, -1, 492, 5, -1, 492, 5, 357, 362, -1, + 492, 4, -1, 492, 4, 357, 362, -1, 122, 5, + 5, 490, 4, 5, -1, 347, 347, -1, 129, -1, + 36, -1, 40, 347, 347, -1, 191, 347, 347, -1, + 110, -1, 285, 359, 356, -1, 285, 357, 362, 356, + -1, 503, 504, -1, 504, -1, 505, 344, 349, -1, + 66, 344, 5, -1, 92, 344, 4, 4, -1, 333, + 344, 4, -1, 128, 344, 5, -1, 279, 344, 5, + -1, 516, -1, 517, -1, 200, -1, 252, -1, 147, + -1, 91, -1, 124, -1, 105, -1, 192, -1, 241, + -1, 99, -1, 155, -1, 267, -1, 498, -1, 498, + 503, -1, -1, -1, 508, 511, -1, 17, -1, 207, + 347, 347, -1, 286, -1, 286, 347, 347, -1, 349, + -1, 279, 349, -1, 511, 512, -1, 512, -1, 505, + 344, 349, -1, -1, -1, 514, 515, -1, 515, 516, + -1, 516, -1, 277, 344, 5, -1, 55, 344, 486, + 5, 5, -1, 64, -1, 66, 5, -1, 180, 4, + -1, 284, 347, -1, 343, -1, 341, -1, 336, -1, + 200, -1, 347, 347, 347, 347, -1, 347, 347, -1, + 359, 347, 347, -1, 357, 362, 356, -1, 285, 521, + -1, 39, 347, 347, -1, 191, 522, -1, 226, 349, + -1, 347, 347, -1, 359, 347, 347, -1, 357, 362, + 356, -1, 40, 347, 347, -1, 347, 347, -1, 110, + 347, 347, -1, 349, -1, 304, 358, 362, -1, 5, + 4, 4, -1, 294, -1, 70, 525, -1, 167, 4, + -1, 238, 4, -1, 247, 347, -1, 54, -1, 137, + -1, 239, -1, 90, -1, 147, 527, -1, 252, 528, + -1, 40, 347, 347, -1, 191, 347, 347, -1, 110, + -1, 257, 110, -1, 40, 347, 347, -1, 191, 347, + 347, -1, 110, -1, 257, 110, -1, 186, -1, 13, + -1, 200, -1, 34, -1, 107, -1, 61, 5, -1, + 275, 357, -1, 298, 4, 4, 4, -1, 347, -1, + 347, 97, -1, 191, 533, -1, 285, 347, -1, 285, + 347, 97, -1, 40, -1, 347, -1, 110, -1, 26, + 535, -1, 122, 537, -1, 202, 547, -1, 111, 548, + -1, 215, 5, -1, 119, 5, 373, -1, 61, 5, + 373, -1, 265, 4, 373, -1, 239, 87, 536, -1, + 119, 5, 373, -1, 61, 5, 373, -1, 265, 4, + 373, -1, 538, -1, 154, 538, -1, 276, 539, -1, + 262, 540, -1, 116, 87, 541, -1, 189, 542, -1, + 239, 154, 544, -1, 239, 87, 545, -1, 236, 546, + -1, 119, 5, -1, 61, 5, -1, 265, 4, -1, + 119, 5, -1, 61, 5, -1, 265, 4, -1, 119, + 5, -1, 61, 5, -1, 265, 4, -1, 119, 5, + -1, 61, 5, -1, 265, 4, -1, 154, 543, -1, + 119, 5, 4, -1, 61, 5, 4, -1, 265, 4, + 4, -1, 119, 5, -1, 61, 5, -1, 265, 4, + -1, 119, 5, -1, 61, 5, -1, 265, 4, -1, + 119, 5, -1, 61, 5, -1, 265, 4, -1, 119, + 5, -1, 61, 5, -1, 265, 4, -1, 119, 5, + 373, -1, 61, 5, 373, -1, 265, 4, 373, -1, + 119, 5, 5, 373, -1, 550, 4, -1, 99, -1, + 50, -1, 133, -1, 287, -1, -1, 4, 347, 347, + 347, 347, -1, 201, -1, 201, 4, 347, 347, 347, + 347, -1, 122, 262, 552, -1, 4, -1, 347, 357, + -1, 4, 4, -1, 4, 347, 357, -1, 347, 347, + -1, 285, 347, 347, -1, 358, 362, 363, -1, 16, + 557, -1, 237, 4, -1, 235, 556, -1, 23, 555, + -1, 4, 4, -1, 4, 5, -1, 279, 4, 5, + -1, 4, 4, -1, 4, 5, -1, 279, 4, 5, + -1, 4, -1, 4, 358, 362, -1, 4, 6, 358, + 362, -1, 225, -1, 347, 347, -1, 347, 347, 12, + 347, 347, -1, 347, 347, 12, 359, 347, 347, -1, + 347, 347, 12, 357, 362, 356, -1, 285, 560, -1, + 121, -1, 121, 347, -1, 347, 347, -1, 347, 347, + 12, 347, 347, -1, 347, 347, 12, 359, 347, 347, + -1, 347, 347, 12, 357, 362, 356, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 445, 445, 446, 447, 448, 449, 450, 451, 452, + 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, + 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, + 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, + 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, + 493, 494, 495, 496, 499, 500, 503, 504, 505, 506, + 507, 508, 509, 510, 511, 512, 513, 514, 515, 518, + 520, 521, 522, 523, 525, 526, 527, 528, 531, 532, + 533, 534, 535, 538, 539, 542, 543, 544, 547, 550, + 553, 556, 568, 575, 582, 590, 591, 592, 593, 594, + 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, + 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, + 617, 618, 619, 620, 621, 622, 623, 624, 627, 628, + 631, 632, 633, 634, 635, 636, 637, 638, 641, 642, + 643, 644, 645, 648, 649, 650, 651, 652, 653, 654, + 655, 656, 657, 658, 661, 662, 663, 666, 667, 668, + 669, 672, 673, 674, 675, 676, 679, 680, 681, 684, + 685, 686, 689, 690, 691, 694, 695, 696, 697, 698, + 699, 700, 701, 704, 705, 708, 709, 710, 711, 712, + 713, 716, 717, 718, 721, 722, 723, 724, 725, 726, + 729, 730, 731, 732, 733, 734, 735, 736, 737, 741, + 742, 745, 746, 749, 750, 753, 754, 756, 757, 758, + 761, 762, 765, 767, 769, 771, 773, 775, 777, 779, + 781, 785, 786, 787, 788, 789, 790, 791, 792, 795, + 796, 799, 800, 801, 803, 805, 806, 807, 809, 813, + 814, 817, 818, 820, 823, 825, 831, 832, 833, 836, + 837, 838, 841, 842, 843, 844, 845, 846, 852, 853, + 856, 857, 858, 859, 860, 863, 864, 865, 868, 869, + 874, 879, 886, 888, 890, 891, 892, 895, 897, 900, + 901, 904, 905, 906, 907, 908, 911, 913, 916, 917, + 920, 921, 922, 929, 930, 933, 934, 937, 939, 943, + 944, 947, 949, 950, 951, 952, 955, 956, 957, 958, + 959, 962, 964, 966, 967, 969, 971, 973, 975, 979, + 982, 985, 986, 987, 988, 989, 990, 991, 992, 993, + 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, + 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, + 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1024, 1026, 1027, + 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1040, 1041, + 1042, 1045, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1061, + 1062, 1063, 1064, 1065, 1066, 1069, 1070, 1073, 1074, 1075, + 1078, 1079, 1082, 1085, 1086, 1088, 1092, 1093, 1094, 1097, + 1101, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, + 1114, 1115, 1118, 1119, 1122, 1124, 1130, 1134, 1136, 1138, + 1141, 1142, 1144, 1147, 1150, 1151, 1155, 1157, 1160, 1165, + 1166, 1167, 1171, 1172, 1173, 1176, 1177, 1178, 1181, 1182, + 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, + 1195, 1196, 1199, 1200, 1203, 1204, 1205, 1206, 1209, 1210, + 1213, 1215, 1218, 1222, 1223, 1224, 1225, 1228, 1229, 1230, + 1233, 1234, 1235, 1238, 1241, 1242, 1243, 1246, 1247, 1250, + 1251, 1252, 1253, 1254, 1255, 1256, 1259, 1260, 1263, 1264, + 1267, 1268, 1271, 1272, 1275, 1276, 1277, 1280, 1281, 1284, + 1285, 1288, 1291, 1299, 1300, 1303, 1304, 1305, 1306, 1307, + 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, + 1318, 1321, 1324, 1325, 1328, 1329, 1330, 1331, 1334, 1335, + 1336, 1337, 1340, 1341, 1342, 1343, 1344, 1347, 1348, 1349, + 1350, 1351, 1352, 1354, 1355, 1360, 1361, 1364, 1366, 1368, + 1371, 1372, 1373, 1374, 1375, 1376, 1379, 1381, 1383, 1385, + 1386, 1388, 1390, 1392, 1394, 1396, 1399, 1400, 1401, 1402, + 1403, 1404, 1406, 1407, 1408, 1411, 1414, 1416, 1418, 1420, + 1422, 1424, 1426, 1428, 1431, 1433, 1435, 1437, 1438, 1439, + 1440, 1441, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1452, + 1454, 1455, 1456, 1459, 1460, 1461, 1462, 1463, 1464, 1466, + 1467, 1468, 1471, 1472, 1473, 1474, 1475, 1478, 1481, 1484, + 1487, 1490, 1493, 1496, 1499, 1502, 1507, 1510, 1513, 1516, + 1519, 1522, 1525, 1528, 1531, 1534, 1537, 1542, 1545, 1548, + 1551, 1554, 1557, 1560, 1563, 1566, 1571, 1574, 1577, 1580, + 1583, 1586, 1589, 1592, 1595, 1598, 1601, 1606, 1608, 1609, + 1610, 1611, 1612, 1614, 1615, 1616, 1618, 1619, 1620, 1621, + 1622, 1623, 1624, 1626, 1628, 1629, 1630, 1633, 1634, 1635, + 1636, 1637, 1638, 1640, 1641, 1642, 1645, 1647, 1649, 1650, + 1652, 1654, 1658, 1659, 1662, 1663, 1664, 1667, 1674, 1675, + 1676, 1677, 1678, 1679, 1680, 1683, 1691, 1692, 1693, 1694, + 1696, 1698, 1699, 1699, 1700, 1701, 1702, 1703, 1704, 1705, + 1707, 1708, 1710, 1713, 1716, 1717, 1718, 1721, 1723, 1726, + 1729, 1732, 1736, 1739, 1741, 1744, 1747, 1751, 1756, 1761, + 1763, 1765, 1767, 1768, 1770, 1772, 1774, 1776, 1778, 1779, + 1781, 1783, 1787, 1792, 1794, 1796, 1798, 1800, 1802, 1804, + 1806, 1808, 1810, 1812, 1815, 1816, 1818, 1820, 1821, 1823, + 1825, 1826, 1827, 1829, 1831, 1832, 1833, 1835, 1836, 1838, + 1841, 1845, 1849, 1852, 1855, 1859, 1864, 1870, 1871, 1872, + 1874, 1875, 1877, 1881, 1883, 1884, 1885, 1887, 1890, 1892, + 1895, 1897, 1900, 1902, 1904, 1907, 1912, 1915, 1916, 1919, + 1922, 1926, 1927, 1929, 1930, 1931, 1933, 1934, 1936, 1937, + 1939, 1944, 1946, 1947, 1949, 1950, 1951, 1952, 1953, 1954, + 1956, 1958, 1960, 1961, 1963, 1964, 1966, 1968, 1969, 1970, + 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1980, 1982, + 1984, 1985, 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1995, + 1996, 1997, 1998, 1999, 2000, 2003, 2004, 2005, 2006, 2007, + 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, + 2018, 2019, 2020, 2021, 2022, 2023, 2026, 2027, 2028, 2029, + 2030, 2031, 2039, 2046, 2055, 2064, 2071, 2078, 2086, 2094, + 2101, 2106, 2111, 2116, 2121, 2126, 2131, 2137, 2146, 2156, + 2166, 2173, 2183, 2193, 2202, 2214, 2227, 2232, 2235, 2237, + 2239, 2244, 2248, 2251, 2253, 2255, 2258, 2259, 2260, 2261, + 2262, 2263, 2264, 2267, 2268, 2269, 2270, 2271, 2272, 2274, + 2276, 2278, 2280, 2282, 2284, 2287, 2289, 2291, 2293, 2295, + 2297, 2300, 2301, 2302, 2303, 2305, 2308, 2310, 2312, 2313, + 2314, 2316, 2319, 2322, 2324, 2325, 2326, 2327, 2329, 2330, + 2331, 2332, 2333, 2335, 2337, 2339, 2342, 2343, 2344, 2346, + 2348, 2349, 2350, 2351, 2353, 2356, 2360, 2361, 2362, 2365, + 2368, 2370, 2371, 2372, 2374, 2377, 2378, 2380, 2381, 2382, + 2383, 2384, 2386, 2387, 2389, 2392, 2393, 2394, 2395, 2396, + 2398, 2400, 2401, 2402, 2403, 2405, 2407, 2408, 2409, 2410, + 2411, 2412, 2414, 2415, 2417, 2420, 2421, 2422, 2423, 2426, + 2427, 2430, 2431, 2434, 2435, 2438, 2451, 2452, 2456, 2457, + 2461, 2462, 2465, 2470, 2477, 2479, 2482, 2484, 2487, 2491, + 2492, 2493, 2494, 2495, 2496, 2497, 2499, 2503, 2504, 2507, + 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2517, 2518, 2519, + 2520, 2521, 2522, 2523, 2524, 2525, 2526, 2527, 2530, 2531, + 2534, 2535, 2535, 2538, 2539, 2540, 2541, 2544, 2545, 2548, + 2549, 2552, 2556, 2557, 2557, 2560, 2561, 2564, 2567, 2571, + 2572, 2573, 2574, 2577, 2578, 2579, 2580, 2583, 2585, 2586, + 2591, 2593, 2594, 2595, 2596, 2599, 2600, 2605, 2609, 2610, + 2611, 2614, 2615, 2620, 2621, 2624, 2626, 2627, 2628, 2633, + 2634, 2635, 2636, 2639, 2640, 2643, 2645, 2647, 2648, 2651, + 2653, 2654, 2655, 2658, 2659, 2662, 2663, 2664, 2667, 2668, + 2669, 2672, 2673, 2674, 2675, 2676, 2679, 2680, 2681, 2684, + 2685, 2686, 2687, 2688, 2691, 2693, 2695, 2697, 2700, 2702, + 2704, 2707, 2708, 2709, 2710, 2711, 2712, 2713, 2714, 2715, + 2718, 2719, 2720, 2723, 2724, 2725, 2728, 2729, 2730, 2733, + 2734, 2735, 2738, 2739, 2740, 2741, 2744, 2745, 2746, 2749, + 2750, 2751, 2754, 2755, 2756, 2759, 2760, 2761, 2764, 2766, + 2768, 2772, 2776, 2777, 2780, 2781, 2782, 2785, 2786, 2788, + 2789, 2791, 2794, 2795, 2796, 2797, 2800, 2801, 2804, 2806, + 2807, 2808, 2809, 2812, 2813, 2814, 2817, 2818, 2819, 2822, + 2823, 2828, 2832, 2839, 2840, 2842, 2847, 2849, 2852, 2853, + 2854, 2855, 2857, 2862 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "REAL", "INT", "STRING", "POINTER", + "ANGDEGREE", "ANGRADIAN", "SEXSTR", "HMSSTR", "DMSSTR", "ABOUT_", "AIP_", + "ALLOC_", "ALLOCGZ_", "ALIGN_", "ALL_", "ALT_", "AMPLIFIER_", + "ANALYSIS_", "ANGLE_", "ANNULUS_", "APPEND_", "ARCMIN_", "ARCSEC_", + "ARRAY_", "ARROW_", "ASINH_", "AST_", "AUTO_", "AUX_", "AVERAGE_", + "AXES_", "AZIMUTH_", "B1950_", "BACK_", "BACKGROUND_", "BASE_", "BBOX_", + "BEGIN_", "BG_", "BIG_", "BIGENDIAN_", "BIN_", "BITPIX_", "BLOCK_", + "BORDER_", "BOX_", "BOXANNULUS_", "BOXCAR_", "BOXCIRCLE_", "BPANDA_", + "BUFFER_", "BW_", "CALLBACK_", "CANVAS_", "CATALOG_", "CELESTRIAL_", + "CENTER_", "CENTROID_", "CHANNEL_", "CIRCLE_", "CIAO_", "CLEAR_", + "CLIP_", "COLOR_", "COLORBAR_", "COLORMAP_", "COLORSCALE_", + "COLORSPACE_", "COLS_", "COLUMN_", "COMMAND_", "COMPASS_", "COMPOSITE_", + "COMPRESS_", "CONTOUR_", "CONTRAST_", "COORDINATES_", "COPY_", "COUNT_", + "CPANDA_", "CREATE_", "CROP_", "CROSS_", "CROSSHAIR_", "CUBE_", + "CURSOR_", "CUT_", "CMYK_", "DASH_", "DASHLIST_", "DATA_", "DATAMIN_", + "DATASEC_", "DEBUG_", "DEGREES_", "DEFAULT_", "DELETE_", "DEPTH_", + "DETECTOR_", "DIAMOND_", "DIM_", "DS9_", "EDIT_", "ECLIPTIC_", + "ELEVATION_", "ELLIPSE_", "ELLIPSEANNULUS_", "END_", "ENVI_", "EPANDA_", + "EPSILON_", "EQUATORIAL_", "ERASE_", "EXT_", "FACTOR_", "FALSE_", + "FILE_", "FILTER_", "FIT_", "FITS_", "FITSY_", "FIXED_", "FK4_", + "FK4_NO_E_", "FK5_", "FONT_", "FRONT_", "FULL_", "FUNCTION_", + "GALACTIC_", "GAUSSIAN_", "GET_", "GLOBAL_", "GRAPHICS_", "GRAY_", + "GRID_", "GZ_", "HANDLE_", "HAS_", "HEAD_", "HEADER_", "HEIGHT_", + "HELIOECLIPTIC_", "HIDE_", "HIGHLITE_", "HISTEQU_", "HISTOGRAM_", + "HORIZONTAL_", "ICRS_", "ID_", "IIS_", "IMAGE_", "INCLUDE_", "INCR_", + "INFO_", "INTEGER_", "ITERATION_", "IRAF_", "IRAFMIN_", "J2000_", "KEY_", + "KEYWORD_", "LABEL_", "LENGTH_", "LEVEL_", "LITTLE_", "LITTLEENDIAN_", + "LINE_", "LINEAR_", "LIST_", "LOAD_", "LOCAL_", "LOG_", "MACOSX_", + "MAGNIFIER_", "MATCH_", "MAP_", "MARK_", "MARKER_", "MASK_", "MESSAGE_", + "METHOD_", "MINMAX_", "MIP_", "MMAP_", "MMAPINCR_", "MOSAIC_", "MODE_", + "MOTION_", "MOVE_", "NAME_", "NAN_", "NATIVE_", "NAXES_", "NEW_", + "NEXT_", "NO_", "NONE_", "NOW_", "NRRD_", "NUMBER_", "OBJECT_", "OFF_", + "ON_", "ONLY_", "OPTION_", "ORIENT_", "PAN_", "PANNER_", "PARSER_", + "PASTE_", "PERF_", "PHOTO_", "PHYSICAL_", "PIXEL_", "PLOT2D_", "PLOT3D_", + "POINT_", "POINTER_", "POLYGON_", "POSTSCRIPT_", "POW_", "PRINT_", + "PRESERVE_", "PROJECTION_", "PROPERTY_", "PUBLICATION_", "PROS_", + "QUERY_", "RADIAL_", "RADIUS_", "REGION_", "REPLACE_", "RESAMPLE_", + "RESET_", "RESOLUTION_", "RGB_", "ROOT_", "ROTATE_", "RULER_", "SAMPLE_", + "SAOIMAGE_", "SAOTNG_", "SAVE_", "SCALE_", "SCAN_", "SCIENTIFIC_", + "SCOPE_", "SEGMENT_", "SELECT_", "SET_", "SEXAGESIMAL_", "SHAPE_", + "SHARED_", "SHIFT_", "SHMID_", "SHOW_", "SINH_", "SIZE_", "SLICE_", + "SMMAP_", "SMOOTH_", "SOCKET_", "SOCKETGZ_", "SOURCE_", "SQRT_", + "SQUARED_", "SSHARED_", "STATS_", "STATUS_", "SUPERGALACTIC_", "SUM_", + "SYSTEM_", "TABLE_", "TAG_", "TEMPLATE_", "TEXT_", "THREADS_", "THREED_", + "THRESHOLD_", "THICK_", "TRANSPARENCY_", "TO_", "TOGGLE_", "TOPHAT_", + "TRUE_", "TYPE_", "UNDO_", "UNHIGHLITE_", "UNLOAD_", "UNSELECT_", + "UPDATE_", "USER_", "VALUE_", "VAR_", "VIEW_", "VECTOR_", "VERSION_", + "VERTEX_", "VERTICAL_", "WARP_", "WCS_", "WCSA_", "WCSB_", "WCSC_", + "WCSD_", "WCSE_", "WCSF_", "WCSG_", "WCSH_", "WCSI_", "WCSJ_", "WCSK_", + "WCSL_", "WCSM_", "WCSN_", "WCSO_", "WCSP_", "WCSQ_", "WCSR_", "WCSS_", + "WCST_", "WCSU_", "WCSV_", "WCSW_", "WCSX_", "WCSY_", "WCSZ_", "WCS0_", + "WFPC2_", "WIDTH_", "WIN32_", "XML_", "XY_", "YES_", "ZMAX_", "ZSCALE_", + "ZOOM_", "'Y'", "'N'", "'X'", "'='", "$accept", "command", "numeric", + "debug", "yesno", "fileNameType", "optangle", "angle", "sexagesimal", + "hms", "dms", "coord", "coordSystem", "wcsSystem", "internalSystem", + "scaleType", "minmaxMode", "skyFrame", "skyFormat", "skyDist", + "contourClipMode", "shmType", "incrLoad", "layerType", "pointShape", + "pointSize", "analysisMethod", "analysisParam", "endian", "threed", + "threedBorder", "threedCompass", "threedHighlite", "threedView", + "analysis", "analysisShape", "bin", "binAbout", "binFactor", + "binFunction", "binTo", "block", "blockTo", "clip", "clipScope", + "clipMode", "clipMinMax", "clipZScale", "colormap", "colormapMotion", + "colorscale", "contour", "contourCreate", "contourDelete", "contourLoad", + "contourMethod", "contourPaste", "contourSave", "crop", "crop3d", + "crosshair", "cube", "fitsy", "get", "getBin", "getBinCols", "getBlock", + "getClip", "getClipLimits", "getClipMinMax", "getClipZScale", + "getColorbar", "getColorMap", "getColorMapLevel", "getColorScale", + "getColorScaleLevel", "getContour", "getContourClip", + "getContourColorScale", "getCoord", "getCrop", "getCrosshair", "getCube", + "getCursor", "getData", "getInfo", "getiis", "getIISFileName", "getFits", + "getFitsExt", "getFitsHeader", "getFitsDepth", "getFitsFileName", + "getFitsSlice", "getGrid", "getMask", "getPan", "getRGB", "getSmooth", + "getThreed", "getThreedBorder", "getThreedCompass", "getThreedHighlite", + "getThreedView", "getWCS", "getWCSAlign", "grid", "gridCreate", + "gridType", "has", "hasBin", "hasContour", "hasFits", "hasMarker", + "hasWCS", "iis", "iisSetFileName", "iiscursor", "load", "loadArr", + "loadArrayRGBCube", "loadENVI", "loadFits", "loadFitsSlice", + "loadFitsExtCube", "loadFitsMosaic", "loadFitsMosaicImageIRAF", + "loadFitsMosaicIRAF", "loadFitsMosaicImageWCS", "loadFitsMosaicWCS", + "loadFitsMosaicImageWFPC2", "loadFitsRGBCube", "loadFitsRGBImage", + "loadNRRD", "loadPhoto", "loadIncr", "macosx", "magnifier", "match", + "marker", "@1", "markerCallBack", "markerCentroid", "markerCreate", + "markerCreateTemplate", "markerDash", "markerEdit", "markerFormat", + "markerGet", "markerGetCentroid", "markerGetHighlite", "markerGetSelect", + "markerGetShow", "markerInitProp", "markerLayer", "markerList", + "markerLoad", "markerMoveSelected", "markerProps", "markerProp", + "markerProperty", "markerProperties", "markerQuery", "@2", + "markerSelect", "markerShow", "queries", "query", "markerTags", "@3", + "tags", "tag", "callback", "mask", "orient", "pan", "panTo", "panMotion", + "panner", "postscript", "pscolorspace", "region", "regionHighlite", + "regionSelect", "renderMethod", "renderBackground", "rgb", "rotate", + "rotateMotion", "save", "saveArray", "saveArrayRGBCube", "saveFits", + "saveFitsImage", "saveFitsTable", "saveFitsSlice", "saveFitsExtCube", + "saveFitsMosaic", "saveFitsMosaicImage", "saveFitsRGBImage", + "saveFitsRGBCube", "saveFitsResample", "saveNRRD", "saveENVI", "smooth", + "smoothFunction", "update", "updateFitsSlice", "warp", "wcs", + "wcsAppend", "wcsReplace", "wcsAlign", "win32", "zoom", "zoomTo", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, + 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, + 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, + 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, + 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, + 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, + 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, + 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, + 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, + 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, + 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, + 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, + 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, + 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, + 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, + 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, + 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, + 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, + 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, + 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, + 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, + 595, 89, 78, 88, 61 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint16 yyr1[] = +{ + 0, 345, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 347, 347, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 348, 348, 348, 349, + 349, 349, 349, 349, 349, 349, 349, 349, 350, 350, + 350, 350, 350, 351, 351, 352, 352, 352, 353, 354, + 355, 356, 356, 356, 356, 357, 357, 357, 357, 357, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 359, 359, + 360, 360, 360, 360, 360, 360, 360, 360, 361, 361, + 361, 361, 361, 362, 362, 362, 362, 362, 362, 362, + 362, 362, 362, 362, 363, 363, 363, 364, 364, 364, + 364, 365, 365, 365, 365, 365, 366, 366, 366, 367, + 367, 367, 368, 368, 368, 369, 369, 369, 369, 369, + 369, 369, 369, 370, 370, 371, 371, 371, 371, 371, + 371, 372, 372, 372, 373, 373, 373, 373, 373, 373, + 374, 374, 374, 374, 374, 374, 374, 374, 374, 375, + 375, 376, 376, 377, 377, 378, 378, 378, 378, 378, + 379, 379, 380, 380, 380, 380, 380, 380, 380, 380, + 380, 381, 381, 381, 381, 381, 381, 381, 381, 382, + 382, 383, 383, 383, 383, 383, 383, 383, 383, 384, + 384, 385, 385, 385, 385, 385, 386, 386, 386, 387, + 387, 387, 388, 388, 388, 388, 388, 388, 389, 389, + 390, 390, 390, 390, 390, 391, 391, 391, 392, 392, + 392, 392, 393, 393, 393, 393, 393, 394, 394, 395, + 395, 396, 396, 396, 396, 396, 397, 397, 398, 398, + 399, 399, 399, 400, 400, 401, 401, 402, 402, 403, + 403, 403, 403, 403, 403, 403, 404, 404, 404, 404, + 404, 405, 405, 405, 405, 405, 405, 405, 405, 406, + 407, 408, 408, 408, 408, 408, 408, 408, 408, 408, + 408, 408, 408, 408, 408, 408, 408, 408, 408, 408, + 408, 408, 408, 408, 408, 408, 408, 408, 408, 408, + 408, 408, 408, 408, 408, 408, 408, 408, 408, 408, + 409, 409, 409, 409, 409, 409, 409, 409, 410, 410, + 410, 411, 412, 412, 412, 412, 412, 412, 412, 413, + 413, 413, 413, 413, 413, 414, 414, 415, 415, 415, + 416, 416, 417, 418, 418, 418, 419, 419, 419, 420, + 421, 421, 421, 421, 421, 421, 421, 421, 421, 421, + 422, 422, 423, 423, 424, 424, 424, 425, 425, 425, + 426, 426, 426, 427, 428, 428, 429, 429, 429, 430, + 430, 430, 431, 431, 431, 432, 432, 432, 433, 433, + 433, 433, 433, 433, 433, 433, 433, 433, 433, 433, + 433, 433, 434, 434, 435, 435, 435, 435, 436, 436, + 437, 437, 437, 438, 438, 438, 438, 439, 439, 439, + 440, 440, 440, 441, 442, 442, 442, 443, 443, 444, + 444, 444, 444, 444, 444, 444, 445, 445, 446, 446, + 447, 447, 448, 448, 449, 449, 449, 450, 450, 451, + 451, 452, 452, 453, 453, 454, 454, 454, 454, 454, + 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, + 454, 455, 456, 456, 457, 457, 457, 457, 458, 458, + 458, 458, 459, 459, 459, 459, 459, 460, 460, 460, + 460, 460, 460, 460, 460, 461, 461, 462, 462, 462, + 463, 463, 463, 463, 463, 463, 464, 464, 464, 464, + 464, 464, 464, 464, 464, 464, 465, 465, 465, 465, + 465, 465, 465, 465, 465, 466, 467, 467, 467, 467, + 467, 467, 467, 467, 467, 467, 467, 467, 467, 467, + 467, 467, 468, 468, 468, 468, 468, 468, 468, 468, + 468, 468, 468, 469, 469, 469, 469, 469, 469, 469, + 469, 469, 470, 470, 470, 470, 470, 471, 471, 471, + 471, 471, 471, 471, 471, 471, 472, 472, 472, 472, + 472, 472, 472, 472, 472, 472, 472, 473, 473, 473, + 473, 473, 473, 473, 473, 473, 474, 474, 474, 474, + 474, 474, 474, 474, 474, 474, 474, 475, 475, 475, + 475, 475, 475, 475, 475, 475, 476, 476, 476, 476, + 476, 476, 476, 476, 476, 476, 476, 477, 477, 477, + 477, 477, 477, 477, 477, 477, 478, 478, 478, 478, + 478, 478, 479, 479, 480, 480, 480, 481, 482, 482, + 482, 482, 482, 482, 482, 483, 484, 484, 484, 484, + 484, 484, 485, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 484, 484, 484, 484, 484, + 484, 484, 484, 484, 484, 486, 486, 486, 486, 486, + 486, 486, 486, 486, 486, 486, 486, 486, 486, 486, + 486, 486, 486, 486, 486, 486, 487, 487, 487, 487, + 487, 487, 488, 488, 488, 488, 488, 488, 488, 488, + 488, 488, 488, 488, 488, 488, 488, 488, 488, 488, + 488, 488, 488, 488, 488, 488, 488, 488, 489, 489, + 489, 489, 490, 491, 491, 491, 492, 492, 492, 492, + 492, 492, 492, 493, 493, 493, 493, 493, 493, 493, + 493, 493, 493, 493, 493, 493, 493, 493, 493, 493, + 493, 493, 493, 493, 493, 493, 493, 493, 493, 493, + 493, 493, 493, 493, 493, 493, 493, 493, 493, 493, + 493, 493, 493, 493, 493, 493, 493, 493, 493, 493, + 493, 493, 493, 493, 493, 493, 493, 493, 493, 493, + 493, 493, 493, 493, 493, 493, 493, 493, 493, 493, + 493, 493, 493, 493, 493, 493, 493, 493, 493, 493, + 493, 493, 493, 493, 493, 493, 493, 493, 493, 493, + 493, 493, 493, 493, 493, 494, 494, 494, 494, 495, + 495, 496, 496, 497, 497, 498, 499, 499, 499, 499, + 499, 499, 500, 500, 501, 501, 501, 501, 501, 502, + 502, 502, 502, 502, 502, 502, 502, 503, 503, 504, + 504, 504, 504, 504, 504, 504, 504, 505, 505, 505, + 505, 505, 505, 505, 505, 505, 505, 505, 506, 506, + 507, 508, 507, 509, 509, 509, 509, 510, 510, 511, + 511, 512, 513, 514, 513, 515, 515, 516, 517, 518, + 518, 518, 518, 519, 519, 519, 519, 520, 520, 520, + 520, 520, 520, 520, 520, 521, 521, 521, 522, 522, + 522, 523, 523, 523, 523, 524, 524, 524, 524, 525, + 525, 525, 525, 526, 526, 527, 527, 527, 527, 528, + 528, 528, 528, 529, 529, 530, 530, 530, 531, 531, + 531, 532, 532, 532, 532, 532, 533, 533, 533, 534, + 534, 534, 534, 534, 535, 535, 535, 535, 536, 536, + 536, 537, 537, 537, 537, 537, 537, 537, 537, 537, + 538, 538, 538, 539, 539, 539, 540, 540, 540, 541, + 541, 541, 542, 542, 542, 542, 543, 543, 543, 544, + 544, 544, 545, 545, 545, 546, 546, 546, 547, 547, + 547, 548, 549, 549, 550, 550, 550, 551, 551, 551, + 551, 551, 552, 552, 552, 552, 553, 553, 554, 554, + 554, 554, 554, 555, 555, 555, 556, 556, 556, 557, + 557, 557, 558, 559, 559, 559, 559, 559, 560, 560, + 560, 560, 560, 560 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 2, 2, 2, 3, 2, 1, 1, 2, + 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 1, 2, 2, 3, 2, 2, 2, 2, + 3, 2, 3, 2, 2, 2, 2, 2, 1, 3, + 2, 2, 2, 1, 2, 2, 2, 1, 2, 1, + 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, + 2, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 2, 2, 2, 2, 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, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, + 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, + 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, + 2, 1, 2, 1, 2, 2, 6, 3, 3, 3, + 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 2, 4, 2, 2, 2, 3, 2, 2, 1, + 2, 1, 2, 4, 5, 2, 3, 5, 6, 1, + 1, 1, 7, 11, 8, 12, 1, 2, 2, 1, + 1, 2, 2, 2, 2, 3, 2, 2, 1, 1, + 1, 1, 1, 1, 1, 2, 2, 2, 3, 2, + 2, 2, 6, 10, 1, 2, 1, 6, 10, 1, + 2, 2, 2, 2, 2, 2, 12, 1, 0, 1, + 1, 4, 6, 1, 1, 1, 4, 3, 4, 0, + 6, 8, 2, 3, 3, 3, 0, 3, 4, 4, + 4, 3, 3, 1, 3, 5, 4, 4, 3, 2, + 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 2, 2, 4, 7, + 2, 2, 2, 1, 3, 2, 2, 1, 2, 8, + 2, 1, 2, 1, 2, 1, 4, 7, 2, 1, + 1, 1, 1, 2, 1, 1, 2, 1, 0, 2, + 2, 1, 1, 1, 1, 2, 2, 2, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 2, 1, 4, 5, 0, 2, 1, 5, + 2, 2, 1, 1, 1, 2, 1, 2, 1, 1, + 0, 1, 0, 1, 5, 6, 4, 3, 6, 2, + 1, 3, 1, 1, 1, 3, 6, 7, 5, 1, + 1, 4, 5, 1, 3, 0, 1, 2, 1, 4, + 1, 2, 1, 2, 3, 2, 1, 2, 1, 4, + 2, 1, 1, 3, 1, 2, 3, 2, 0, 1, + 1, 4, 2, 0, 1, 1, 2, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 2, 2, 2, 1, 1, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 2, 2, 0, 1, 2, + 1, 6, 5, 1, 1, 1, 2, 2, 1, 1, + 1, 1, 2, 1, 1, 1, 2, 1, 1, 2, + 2, 2, 0, 1, 0, 1, 1, 1, 1, 1, + 1, 1, 1, 2, 2, 1, 2, 3, 1, 2, + 2, 4, 6, 1, 10, 1, 2, 3, 3, 2, + 2, 2, 2, 2, 2, 2, 4, 4, 4, 3, + 3, 5, 4, 4, 4, 3, 3, 3, 3, 2, + 2, 4, 3, 3, 3, 3, 4, 4, 4, 4, + 5, 4, 6, 7, 4, 4, 5, 2, 3, 3, + 3, 2, 3, 3, 3, 3, 4, 3, 5, 6, + 3, 3, 4, 3, 3, 3, 3, 3, 5, 3, + 3, 4, 3, 2, 2, 1, 3, 4, 4, 4, + 4, 4, 6, 4, 4, 5, 4, 4, 4, 4, + 5, 4, 6, 7, 4, 4, 5, 5, 5, 5, + 5, 5, 7, 5, 5, 6, 5, 5, 5, 5, + 6, 5, 7, 8, 5, 5, 6, 3, 3, 3, + 3, 3, 5, 3, 3, 4, 3, 3, 3, 3, + 4, 3, 5, 6, 3, 3, 4, 3, 3, 3, + 3, 3, 5, 3, 3, 4, 4, 4, 3, 5, + 4, 4, 2, 3, 6, 6, 1, 1, 1, 2, + 2, 2, 3, 3, 2, 12, 2, 2, 1, 3, + 4, 2, 0, 3, 1, 1, 2, 2, 2, 2, + 2, 4, 4, 4, 3, 4, 5, 7, 8, 6, + 8, 9, 6, 6, 7, 10, 11, 12, 9, 5, + 5, 6, 3, 5, 5, 5, 6, 5, 4, 9, + 10, 11, 9, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 7, 7, 2, 4, 4, 4, 4, 5, + 4, 4, 5, 5, 3, 4, 4, 4, 6, 7, + 8, 9, 6, 10, 11, 12, 9, 3, 2, 3, + 5, 6, 7, 4, 3, 3, 6, 6, 6, 7, + 6, 7, 4, 4, 6, 9, 4, 3, 6, 7, + 7, 2, 3, 3, 3, 4, 2, 2, 4, 7, + 10, 3, 1, 3, 2, 2, 2, 2, 3, 5, + 4, 5, 2, 7, 3, 2, 2, 3, 2, 2, + 2, 3, 2, 3, 4, 3, 3, 5, 6, 4, + 2, 3, 2, 2, 4, 3, 3, 2, 3, 1, + 2, 1, 2, 2, 2, 1, 1, 1, 1, 2, + 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 1, 2, 2, + 2, 3, 5, 7, 7, 6, 6, 6, 6, 5, + 6, 6, 6, 6, 6, 6, 6, 10, 7, 7, + 7, 9, 9, 10, 12, 12, 2, 2, 3, 4, + 4, 4, 2, 4, 4, 1, 1, 1, 1, 1, + 1, 1, 1, 2, 1, 1, 1, 3, 3, 4, + 6, 10, 7, 7, 5, 4, 6, 10, 7, 7, + 5, 2, 2, 3, 4, 5, 5, 5, 3, 4, + 5, 5, 5, 5, 2, 3, 3, 5, 3, 3, + 3, 4, 5, 5, 5, 5, 3, 4, 5, 5, + 2, 2, 3, 5, 6, 6, 3, 3, 6, 5, + 5, 2, 3, 5, 6, 3, 2, 2, 3, 2, + 3, 2, 3, 5, 6, 2, 2, 2, 1, 4, + 4, 1, 2, 2, 2, 2, 2, 2, 2, 3, + 2, 3, 2, 3, 1, 1, 1, 1, 1, 0, + 2, 0, 2, 0, 1, 0, 0, 1, 1, 1, + 1, 1, 7, 8, 2, 4, 2, 4, 6, 2, + 1, 1, 3, 3, 1, 3, 4, 2, 1, 3, + 3, 4, 3, 3, 3, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 0, 0, 2, 1, 3, 1, 3, 1, 2, 2, + 1, 3, 0, 0, 2, 2, 1, 3, 5, 1, + 2, 2, 2, 1, 1, 1, 1, 4, 2, 3, + 3, 2, 3, 2, 2, 2, 3, 3, 3, 2, + 3, 1, 3, 3, 1, 2, 2, 2, 2, 1, + 1, 1, 1, 2, 2, 3, 3, 1, 2, 3, + 3, 1, 2, 1, 1, 1, 1, 1, 2, 2, + 4, 1, 2, 2, 2, 3, 1, 1, 1, 2, + 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, + 3, 1, 2, 2, 2, 3, 2, 3, 3, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, + 3, 4, 2, 1, 1, 1, 1, 0, 5, 1, + 6, 3, 1, 2, 2, 3, 2, 3, 3, 2, + 2, 2, 2, 2, 2, 3, 2, 2, 3, 1, + 3, 4, 1, 2, 5, 6, 6, 2, 1, 2, + 2, 5, 6, 6 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint16 yydefact[] = +{ + 0, 0, 0, 0, 0, 7, 8, 0, 0, 0, + 0, 0, 309, 0, 0, 0, 0, 0, 0, 0, + 0, 22, 0, 0, 0, 0, 0, 0, 0, 1046, + 0, 0, 0, 0, 0, 0, 0, 1046, 38, 0, + 0, 0, 43, 0, 0, 0, 47, 1227, 49, 0, + 0, 0, 0, 0, 220, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 4, 54, 55, 0, + 256, 6, 0, 0, 0, 0, 0, 0, 9, 0, + 0, 284, 286, 0, 0, 11, 135, 137, 130, 131, + 132, 136, 133, 134, 289, 12, 0, 298, 0, 0, + 0, 13, 0, 0, 0, 0, 316, 0, 14, 69, + 98, 0, 128, 97, 77, 95, 0, 74, 76, 72, + 129, 96, 73, 0, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, + 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, + 126, 127, 70, 71, 75, 323, 143, 99, 0, 15, + 0, 16, 17, 0, 0, 0, 0, 0, 0, 0, + 57, 56, 0, 0, 0, 0, 2, 0, 18, 0, + 0, 0, 389, 400, 0, 406, 0, 0, 0, 0, + 0, 0, 0, 345, 0, 477, 0, 0, 0, 0, + 0, 1046, 0, 353, 0, 357, 0, 0, 0, 361, + 0, 363, 0, 365, 0, 0, 504, 369, 19, 0, + 510, 20, 515, 0, 532, 518, 519, 520, 521, 534, + 523, 524, 525, 0, 527, 528, 0, 0, 21, 23, + 0, 548, 0, 0, 0, 553, 0, 24, 0, 0, + 0, 0, 0, 0, 0, 26, 707, 27, 0, 0, + 0, 0, 0, 0, 708, 28, 0, 29, 1051, 1050, + 1047, 1048, 1049, 0, 1109, 0, 0, 0, 31, 0, + 1116, 1115, 1114, 1113, 33, 0, 0, 0, 0, 0, + 143, 0, 34, 0, 1134, 0, 1131, 35, 0, 0, + 0, 0, 37, 36, 0, 0, 0, 0, 40, 0, + 0, 1161, 41, 0, 0, 0, 0, 0, 42, 1224, + 1223, 1225, 1226, 44, 0, 45, 0, 0, 0, 0, + 0, 207, 0, 0, 0, 46, 0, 0, 1229, 48, + 0, 0, 50, 0, 0, 0, 0, 143, 51, 1252, + 52, 0, 0, 53, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 221, 5, 239, 0, 231, 0, + 0, 233, 0, 241, 234, 238, 249, 250, 235, 251, + 0, 237, 259, 260, 258, 257, 0, 0, 0, 264, + 271, 274, 273, 272, 270, 263, 267, 268, 269, 262, + 0, 0, 0, 0, 0, 266, 10, 0, 0, 0, + 285, 0, 290, 0, 297, 291, 299, 292, 300, 293, + 305, 294, 0, 0, 295, 0, 88, 89, 90, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 312, 0, 0, 0, 0, 0, 146, 152, 144, 145, + 147, 150, 153, 149, 148, 151, 0, 0, 329, 58, + 63, 64, 65, 66, 67, 59, 60, 61, 68, 62, + 0, 331, 0, 378, 374, 370, 371, 375, 372, 377, + 332, 381, 333, 391, 384, 388, 383, 394, 393, 392, + 390, 334, 382, 401, 336, 0, 335, 0, 408, 337, + 420, 412, 422, 413, 414, 416, 0, 418, 419, 143, + 338, 0, 0, 339, 0, 0, 143, 340, 432, 143, + 430, 341, 433, 343, 143, 434, 342, 0, 143, 0, + 344, 452, 0, 450, 468, 0, 0, 0, 456, 448, + 0, 458, 473, 461, 346, 478, 479, 347, 0, 0, + 0, 443, 0, 350, 439, 440, 0, 351, 352, 0, + 480, 481, 482, 355, 356, 483, 358, 0, 484, 485, + 486, 360, 487, 488, 362, 494, 496, 498, 500, 493, + 495, 502, 364, 0, 0, 507, 0, 368, 143, 509, + 0, 516, 533, 517, 535, 536, 537, 522, 538, 540, + 539, 541, 526, 529, 545, 0, 0, 0, 542, 530, + 0, 0, 550, 549, 0, 0, 0, 0, 25, 0, + 0, 560, 0, 561, 0, 0, 0, 0, 0, 562, + 0, 706, 0, 563, 0, 564, 0, 0, 565, 0, + 711, 710, 709, 0, 714, 0, 0, 0, 896, 0, + 0, 0, 718, 722, 724, 725, 0, 0, 0, 0, + 832, 0, 0, 0, 869, 0, 0, 0, 0, 0, + 0, 0, 871, 0, 0, 0, 30, 1110, 1111, 1112, + 32, 0, 0, 0, 0, 1123, 1124, 0, 143, 0, + 1121, 1118, 0, 0, 0, 143, 1139, 1142, 1140, 1141, + 1135, 1136, 1137, 1138, 0, 0, 39, 1158, 1159, 0, + 1166, 1168, 1167, 1163, 1164, 1162, 0, 0, 0, 0, + 1169, 0, 1172, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1170, 1181, 0, 0, 0, 1171, 1173, + 1222, 1156, 1157, 1155, 205, 0, 209, 201, 0, 211, + 202, 0, 213, 203, 1154, 1153, 204, 206, 208, 0, + 0, 0, 0, 0, 200, 0, 0, 0, 0, 1236, + 1249, 1239, 0, 0, 1242, 0, 0, 1241, 1240, 154, + 1258, 0, 1257, 1253, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 240, 236, 0, 245, 0, 242, 0, + 261, 138, 141, 142, 140, 139, 275, 276, 277, 265, + 279, 281, 280, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 143, 0, 313, 94, 91, 92, 93, 143, + 315, 314, 0, 0, 0, 0, 0, 0, 0, 328, + 0, 324, 322, 321, 330, 373, 0, 0, 376, 395, + 396, 385, 386, 397, 399, 398, 387, 403, 402, 0, + 407, 421, 411, 423, 417, 415, 410, 0, 0, 0, + 143, 429, 154, 154, 154, 143, 0, 0, 143, 469, + 451, 462, 0, 453, 78, 464, 0, 0, 455, 457, + 143, 474, 475, 460, 0, 0, 0, 445, 0, 0, + 0, 0, 944, 946, 945, 0, 0, 1039, 0, 1018, + 0, 1021, 0, 0, 1041, 1043, 0, 1034, 354, 0, + 497, 490, 499, 491, 501, 492, 503, 489, 0, 0, + 508, 505, 506, 154, 531, 544, 543, 546, 0, 559, + 547, 0, 0, 0, 0, 0, 0, 172, 172, 166, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 169, + 169, 166, 0, 0, 166, 0, 0, 0, 0, 0, + 601, 625, 0, 0, 0, 597, 0, 0, 0, 0, + 172, 166, 0, 0, 702, 0, 712, 713, 143, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 774, 0, 0, 0, 0, 0, 798, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 821, 0, + 0, 826, 827, 0, 0, 0, 848, 850, 849, 0, + 852, 0, 0, 860, 862, 863, 897, 0, 0, 0, + 0, 716, 717, 938, 936, 941, 940, 939, 937, 942, + 0, 721, 0, 726, 0, 935, 0, 727, 728, 729, + 730, 0, 0, 0, 0, 0, 834, 0, 0, 835, + 1061, 0, 1064, 1060, 0, 0, 0, 836, 870, 837, + 1080, 1085, 1082, 1081, 1079, 1086, 1083, 1077, 1084, 1078, + 1087, 0, 0, 842, 0, 0, 0, 1093, 0, 1095, + 845, 0, 1097, 846, 867, 0, 0, 0, 872, 873, + 874, 1122, 0, 0, 1129, 1125, 0, 0, 0, 1120, + 1119, 1133, 1132, 0, 1147, 0, 0, 1143, 0, 1151, + 0, 0, 1144, 0, 1165, 194, 194, 0, 194, 0, + 1191, 0, 1190, 1182, 0, 0, 0, 0, 1186, 0, + 0, 0, 1189, 0, 0, 0, 0, 0, 1184, 1192, + 0, 0, 0, 1183, 194, 194, 194, 210, 212, 214, + 0, 0, 0, 0, 215, 0, 55, 0, 1231, 0, + 1237, 0, 143, 1243, 1244, 0, 1246, 1247, 0, 155, + 156, 1238, 1259, 1260, 0, 228, 224, 230, 222, 223, + 229, 226, 225, 227, 232, 0, 246, 0, 0, 0, + 0, 278, 0, 0, 0, 0, 0, 0, 0, 0, + 307, 143, 0, 0, 0, 0, 317, 0, 327, 0, + 326, 380, 379, 0, 0, 0, 143, 0, 0, 154, + 427, 431, 435, 0, 0, 0, 154, 0, 82, 81, + 470, 454, 0, 465, 467, 157, 476, 348, 0, 0, + 55, 0, 444, 0, 0, 962, 0, 0, 0, 0, + 0, 0, 974, 0, 0, 0, 0, 0, 0, 990, + 991, 0, 0, 0, 0, 1001, 0, 1006, 1007, 1009, + 1011, 0, 1015, 1026, 1027, 1028, 0, 1030, 1035, 1037, + 1038, 1036, 943, 0, 0, 1017, 0, 1016, 961, 0, + 0, 1022, 0, 1024, 0, 1023, 1044, 1025, 1032, 0, + 0, 366, 0, 0, 557, 558, 0, 555, 551, 0, + 172, 172, 172, 173, 174, 569, 570, 168, 167, 0, + 172, 172, 172, 0, 575, 585, 169, 172, 172, 172, + 170, 171, 172, 172, 0, 172, 172, 0, 169, 0, + 598, 0, 0, 0, 624, 0, 623, 0, 0, 600, + 0, 599, 0, 0, 0, 0, 169, 169, 166, 0, + 0, 166, 0, 0, 0, 172, 172, 698, 0, 172, + 172, 703, 0, 185, 186, 187, 188, 189, 190, 0, + 86, 87, 85, 734, 0, 0, 0, 0, 0, 890, + 888, 883, 0, 893, 877, 894, 880, 892, 886, 875, + 889, 878, 876, 895, 891, 0, 0, 752, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 784, 0, 0, 0, 0, 797, 799, 0, 0, + 805, 804, 0, 0, 175, 0, 0, 143, 0, 0, + 817, 0, 0, 0, 822, 823, 824, 0, 0, 0, + 831, 847, 851, 853, 856, 855, 0, 0, 0, 861, + 898, 900, 0, 899, 719, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1045, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 723, 0, 0, 0, 0, 833, 0, 143, 0, 1056, + 1054, 0, 0, 143, 0, 1059, 838, 0, 0, 0, + 844, 0, 0, 1098, 865, 866, 0, 868, 1128, 1130, + 1127, 1126, 1117, 0, 0, 1148, 0, 0, 1152, 1160, + 196, 197, 198, 199, 195, 1175, 1174, 0, 0, 0, + 1177, 1176, 194, 0, 0, 0, 1185, 0, 0, 0, + 0, 0, 1202, 0, 1216, 1215, 1217, 0, 0, 0, + 1188, 0, 0, 0, 1187, 1197, 1196, 1198, 1194, 1193, + 1195, 1219, 1218, 1220, 217, 219, 218, 0, 0, 55, + 0, 1233, 0, 143, 1250, 1245, 1248, 0, 0, 143, + 0, 0, 0, 243, 0, 0, 0, 0, 0, 0, + 0, 0, 304, 303, 0, 0, 301, 306, 308, 0, + 318, 320, 319, 143, 325, 0, 0, 0, 154, 426, + 143, 0, 0, 0, 0, 449, 463, 80, 79, 472, + 0, 466, 159, 160, 158, 459, 0, 0, 447, 441, + 0, 0, 0, 0, 0, 0, 143, 963, 0, 0, + 0, 968, 0, 143, 0, 975, 976, 0, 978, 979, + 980, 0, 0, 0, 986, 0, 992, 0, 0, 0, + 996, 997, 0, 0, 0, 1002, 0, 0, 1005, 1008, + 1010, 1012, 0, 0, 1029, 1031, 947, 0, 0, 0, + 0, 0, 0, 1040, 948, 0, 0, 1042, 1033, 0, + 0, 513, 514, 0, 0, 556, 0, 566, 567, 568, + 172, 572, 573, 574, 0, 0, 0, 579, 580, 166, + 0, 0, 0, 172, 586, 587, 588, 589, 591, 169, + 594, 595, 0, 172, 0, 0, 0, 169, 169, 166, + 0, 0, 0, 0, 622, 0, 626, 0, 0, 0, + 0, 0, 169, 169, 166, 0, 0, 166, 0, 0, + 0, 0, 0, 169, 169, 166, 0, 0, 166, 0, + 0, 0, 0, 0, 169, 169, 166, 0, 0, 166, + 0, 0, 0, 0, 169, 169, 166, 0, 0, 0, + 169, 602, 603, 604, 605, 607, 0, 610, 611, 0, + 169, 0, 0, 696, 697, 172, 700, 701, 0, 733, + 143, 735, 0, 0, 0, 0, 0, 0, 0, 882, + 879, 885, 884, 881, 887, 0, 0, 0, 0, 0, + 143, 758, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 775, 776, 777, 0, 781, + 778, 780, 0, 0, 786, 785, 787, 0, 0, 0, + 0, 0, 0, 143, 0, 143, 0, 803, 181, 177, + 182, 176, 179, 178, 180, 812, 813, 0, 0, 0, + 816, 143, 0, 143, 0, 825, 828, 143, 0, 143, + 0, 854, 859, 901, 720, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1088, 926, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 927, 0, 0, 0, 0, 0, 731, 732, 143, + 154, 0, 143, 143, 1062, 1063, 0, 1065, 0, 840, + 0, 143, 1094, 1096, 864, 1145, 1146, 1149, 1150, 194, + 194, 194, 1221, 1200, 1199, 1201, 1204, 1203, 1207, 1206, + 1208, 1205, 1213, 1212, 1214, 1210, 1209, 1211, 0, 1228, + 1235, 0, 1251, 0, 143, 0, 1254, 0, 0, 247, + 0, 244, 0, 0, 0, 282, 0, 0, 0, 0, + 143, 0, 310, 131, 0, 404, 0, 424, 154, 157, + 0, 0, 438, 0, 0, 442, 955, 0, 0, 0, + 0, 143, 964, 157, 157, 157, 143, 969, 157, 154, + 157, 157, 143, 981, 157, 157, 157, 143, 987, 157, + 157, 143, 0, 157, 143, 157, 157, 143, 157, 143, + 949, 0, 0, 0, 0, 143, 1019, 1020, 0, 0, + 512, 552, 0, 571, 576, 577, 578, 0, 582, 583, + 584, 590, 172, 169, 596, 613, 614, 615, 616, 617, + 0, 619, 620, 169, 0, 0, 0, 169, 169, 166, + 0, 0, 0, 0, 0, 0, 169, 169, 166, 0, + 0, 0, 0, 0, 0, 169, 169, 166, 0, 0, + 0, 169, 172, 172, 172, 172, 172, 0, 172, 172, + 0, 169, 169, 172, 172, 172, 172, 172, 0, 172, + 172, 0, 169, 169, 676, 677, 678, 679, 681, 0, + 684, 685, 0, 169, 687, 688, 689, 690, 691, 0, + 693, 694, 169, 606, 169, 0, 612, 0, 0, 699, + 0, 736, 157, 0, 0, 157, 0, 0, 0, 749, + 157, 750, 753, 754, 157, 755, 757, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 779, 782, 783, 0, 157, 0, 0, 0, 800, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 857, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1089, 1068, 0, 1075, 1076, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 143, 0, + 0, 83, 0, 0, 933, 934, 154, 0, 0, 0, + 1057, 1055, 1066, 839, 841, 154, 1179, 1178, 1180, 0, + 1230, 1261, 0, 0, 1256, 1255, 248, 0, 0, 0, + 287, 0, 0, 0, 302, 157, 405, 409, 425, 428, + 0, 436, 471, 349, 0, 0, 0, 0, 960, 965, + 967, 966, 970, 971, 972, 973, 977, 982, 983, 984, + 985, 988, 989, 993, 154, 157, 999, 154, 1000, 1003, + 154, 1013, 154, 0, 0, 0, 0, 954, 0, 367, + 511, 0, 581, 592, 172, 169, 621, 172, 172, 172, + 172, 172, 0, 172, 172, 169, 667, 668, 669, 670, + 671, 0, 673, 674, 169, 172, 172, 172, 172, 172, + 0, 172, 172, 169, 172, 636, 637, 638, 639, 641, + 169, 644, 645, 0, 172, 172, 656, 657, 658, 659, + 661, 169, 664, 665, 0, 172, 680, 169, 0, 686, + 169, 695, 608, 169, 704, 705, 143, 739, 0, 157, + 743, 742, 0, 143, 0, 751, 756, 143, 0, 763, + 764, 765, 766, 770, 771, 767, 768, 769, 0, 0, + 157, 788, 792, 0, 143, 0, 0, 801, 807, 806, + 157, 808, 0, 814, 0, 818, 157, 157, 810, 0, + 0, 858, 0, 183, 183, 0, 0, 183, 0, 183, + 1045, 0, 0, 0, 0, 0, 0, 0, 0, 1067, + 0, 0, 183, 183, 0, 0, 0, 0, 0, 0, + 0, 0, 928, 0, 0, 0, 1045, 84, 0, 183, + 0, 1091, 932, 0, 0, 216, 1263, 1262, 0, 0, + 252, 0, 0, 0, 0, 311, 437, 956, 0, 191, + 0, 994, 995, 998, 1004, 1014, 950, 0, 191, 0, + 359, 0, 593, 618, 627, 628, 629, 630, 631, 169, + 633, 634, 172, 169, 675, 647, 648, 649, 650, 651, + 169, 653, 654, 172, 640, 172, 169, 646, 660, 172, + 169, 666, 682, 169, 692, 609, 0, 157, 737, 744, + 0, 0, 0, 0, 0, 772, 773, 789, 0, 0, + 0, 802, 809, 0, 819, 820, 811, 157, 829, 0, + 184, 1045, 1045, 83, 0, 1045, 0, 1045, 902, 143, + 0, 1070, 0, 1073, 1107, 1074, 1072, 1069, 0, 1045, + 1045, 83, 0, 0, 1045, 1045, 0, 0, 1045, 931, + 929, 930, 909, 1045, 1045, 1091, 1102, 0, 1058, 843, + 0, 0, 254, 0, 0, 0, 0, 192, 193, 958, + 959, 0, 952, 953, 0, 172, 635, 672, 172, 655, + 642, 172, 662, 172, 683, 0, 738, 157, 740, 157, + 0, 157, 0, 157, 790, 157, 0, 157, 0, 1045, + 915, 911, 1045, 0, 916, 0, 910, 1045, 0, 1071, + 0, 913, 912, 1045, 0, 0, 907, 905, 1045, 143, + 906, 908, 914, 1102, 1052, 0, 0, 1092, 1100, 0, + 0, 0, 283, 162, 165, 164, 163, 161, 0, 143, + 143, 554, 632, 652, 643, 663, 157, 741, 748, 0, + 762, 759, 791, 796, 0, 815, 0, 920, 904, 83, + 0, 918, 1108, 0, 903, 83, 0, 919, 0, 1053, + 1104, 1106, 0, 1099, 0, 0, 288, 0, 191, 191, + 0, 745, 143, 760, 793, 830, 1045, 0, 0, 1045, + 0, 157, 1105, 1101, 253, 0, 0, 957, 951, 715, + 143, 746, 761, 143, 794, 922, 0, 1045, 921, 0, + 1045, 255, 296, 747, 795, 83, 923, 83, 917, 1045, + 1045, 925, 924 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 53, 429, 176, 155, 1250, 2496, 2497, 430, 431, + 432, 433, 156, 157, 158, 94, 806, 456, 1191, 1665, + 2708, 1339, 1352, 1335, 1905, 2591, 1399, 2639, 1565, 335, + 747, 750, 753, 764, 56, 364, 66, 368, 374, 378, + 381, 71, 384, 78, 399, 395, 389, 405, 85, 410, + 95, 101, 415, 417, 419, 1634, 421, 424, 108, 440, + 159, 161, 178, 218, 480, 848, 482, 491, 492, 851, + 856, 494, 496, 858, 499, 860, 510, 862, 864, 513, + 517, 521, 523, 526, 530, 557, 553, 1262, 544, 883, + 888, 880, 1251, 893, 547, 563, 566, 571, 574, 582, + 921, 923, 925, 927, 587, 931, 221, 589, 1733, 238, + 591, 593, 597, 602, 609, 247, 1328, 612, 255, 621, + 1344, 623, 629, 975, 1360, 970, 1774, 1366, 1364, 971, + 1776, 1369, 1371, 635, 638, 633, 257, 265, 267, 676, + 1052, 1425, 1041, 1520, 1951, 2279, 1057, 1050, 918, 1302, + 1307, 1315, 1317, 1935, 273, 1066, 1069, 1077, 2251, 2252, + 2253, 1936, 2626, 2627, 1100, 1103, 2697, 2698, 2694, 2695, + 2740, 2254, 2255, 278, 284, 292, 690, 685, 297, 302, + 700, 706, 1127, 1132, 756, 744, 308, 312, 713, 318, + 720, 1570, 733, 734, 1163, 1158, 1576, 1148, 1582, 1594, + 1590, 1152, 738, 722, 323, 324, 339, 1178, 342, 348, + 774, 777, 771, 350, 353, 782 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -2562 +static const yytype_int16 yypact[] = +{ + 4516, -71, 69, 444, 80, -2562, -2562, 932, -85, 563, + 1115, 397, 236, 3453, 163, 330, 1947, 58, 5636, 405, + 1609, -2562, 330, 728, 201, 41, -22, 105, 244, 190, + 49, 209, 881, 3122, 185, 836, 118, 190, -2562, -24, + 75, 748, -2562, -10, 276, 355, -2562, 487, -2562, 90, + 2084, 267, 124, 494, -2562, 498, -2562, 500, 171, 262, + 525, 559, 133, 590, -7, 88, -2562, -2562, -2562, 539, + 837, -2562, 145, 47, 330, 399, 837, 84, -2562, 592, + 837, -2562, -2562, 53, 837, -2562, -2562, -2562, -2562, 837, + -2562, -2562, -2562, -2562, -2562, -2562, 28, 581, 612, 633, + 155, -2562, 837, 1553, 837, 837, 979, 837, -2562, -2562, + -2562, 463, -2562, -2562, -2562, -2562, 5014, -2562, -2562, -2562, + -2562, -2562, -2562, 837, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, 1397, -2562, 837, -2562, + 682, -2562, -2562, 330, 330, 330, 330, 330, 330, 330, + -2562, -2562, 330, 330, 330, 330, -2562, 584, -2562, 624, + 1273, 586, 43, 434, 565, 517, 4582, 322, 5069, 4986, + 697, 5014, 4019, -2562, 61, -75, 746, 689, 701, 91, + 778, 190, -13, -2562, 743, -2562, 596, 557, 97, -2562, + 443, -2562, 421, -2562, 0, 761, 125, -2562, -2562, 5258, + -2562, -2562, -2562, 780, 829, -2562, -2562, -2562, -2562, 564, + -2562, -2562, -2562, 858, -2562, -2562, 5258, 4637, -2562, -2562, + 45, -2562, 859, 879, 492, -2562, 837, -2562, 887, 25, + 880, 396, 406, 895, 27, -2562, -2562, -2562, 898, 900, + 330, 330, 837, 837, -2562, -2562, 902, -2562, -2562, -2562, + -2562, -2562, -2562, 2903, -2562, 904, 910, 837, -2562, 935, + -2562, -2562, -2562, -2562, -2562, 837, 1275, 330, 3782, 837, + 1397, 837, -2562, 931, -2562, 4124, -2562, -2562, 526, 938, + 947, 837, -2562, -2562, 10, 955, 5258, 961, -2562, 1347, + 837, 877, -2562, 495, 875, 1224, 429, 1007, -2562, -2562, + -2562, -2562, -2562, -2562, 1029, -2562, 52, 8, 73, 360, + 461, -2562, 837, 837, 479, -2562, 837, 776, 1039, -2562, + 837, 837, -2562, 1047, 15, 20, 1059, 1397, -2562, -2562, + -2562, 617, 837, -2562, -2562, 837, 837, 837, 837, 837, + 837, 837, 837, 837, -2562, -2562, -2562, 837, -2562, 1073, + 1077, -2562, 837, 740, -2562, -2562, -2562, -2562, -2562, -2562, + 837, -2562, -2562, 837, -2562, -2562, 488, 488, 1092, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + 837, 837, 1099, 1107, 1119, -2562, -2562, 837, 837, 837, + -2562, 837, -2562, 1121, -2562, -2562, -2562, -2562, 883, -2562, + 1125, -2562, 5258, 1129, -2562, 837, -2562, -2562, -2562, 837, + 1127, 1133, 1133, 5258, 837, 837, 837, 837, 837, 837, + -2562, 837, 5014, 1553, 837, 837, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, 1553, 837, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + 1140, -2562, 886, 2, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -35, -2562, -2562, -2562, 982, -2562, 379, + -2562, -2562, -2562, -2562, -2562, 1159, -2562, 1160, -2562, -2562, + 986, -2562, 1002, -2562, -2562, -2562, 1011, -2562, -2562, 1397, + -2562, 3963, 837, -2562, 5258, 5258, 1397, -2562, -2562, 1397, + -2562, -2562, -2562, -2562, 1397, -2562, -2562, 5258, 1397, 837, + -2562, -2562, 5258, -2562, 1175, 419, 988, 12, -2562, -2562, + 991, 5258, 4197, -2562, -2562, -2562, -2562, -2562, 1180, 1183, + 1190, -2562, 1003, -2562, -2562, -2562, 837, -2562, -2562, 595, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, 0, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, 1134, 1136, 1141, -2562, + -2562, 989, -2562, 837, 1211, 974, 4124, -2562, 1397, -2562, + 1216, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, 5258, 5258, 5258, -2562, -2562, + 1222, 330, -2562, -2562, 1228, 1229, 1035, 837, -2562, 440, + 1147, -2562, 1230, -2562, 540, 1150, 4553, 64, 1239, -2562, + 1242, -2562, 1244, -2562, 187, -2562, 1245, 1248, -2562, 1251, + -2562, -2562, -2562, 837, -2562, 4124, 4949, 945, 483, 1253, + 618, 1157, -2562, -2562, -2562, 1232, 441, 1258, 1261, 14, + 837, 465, 468, 35, 5258, 330, 1482, 466, 39, 114, + 304, 13, -2562, 1250, 1252, 1268, -2562, -2562, -2562, -2562, + -2562, 837, 837, 837, 837, -2562, -2562, 837, 1397, 837, + -2562, 837, 1553, 837, 1277, 1397, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, 110, 513, -2562, -2562, -2562, 1279, + -2562, -2562, -2562, -2562, 1192, -2562, 1282, 1289, 1197, 1292, + -2562, 1295, -2562, 1296, 1220, 1304, 543, 510, 614, 82, + 621, 1307, 707, -2562, -2562, 1312, 1315, 1308, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, 1316, -2562, -2562, 1319, -2562, + -2562, 1323, -2562, -2562, -2562, -2562, -2562, -2562, -2562, 837, + 837, 837, 837, 837, -2562, 837, 933, 837, 837, -2562, + 1490, -2562, 964, 1326, -2562, 997, 1332, -2562, -2562, -42, + 837, 837, -2562, 1325, 837, 837, 837, 837, 837, 837, + 837, 837, 837, -2562, -2562, 1343, 981, 837, 1341, 574, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, 1350, 1363, 837, 837, 837, 1365, 330, + 1366, 1367, 1397, 5258, -2562, -2562, -2562, -2562, -2562, 1397, + -2562, -2562, 837, 837, 837, 5258, 837, 1553, 837, -2562, + 837, -2562, -2562, -2562, -2562, -2562, 1369, 1371, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, 322, -2562, 837, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, 5258, 5258, 837, + 1397, -2562, -42, -42, -42, 1397, 1553, 837, 1397, -2562, + -2562, -2562, 837, -2562, -9, 1208, 1372, 1375, -2562, -2562, + 1397, 5258, -2562, -2562, 1376, 1381, 1377, 1045, 837, 4954, + 522, 812, -2562, -2562, -2562, 837, 1374, 140, 975, -2562, + 1138, -2562, 1482, 1144, 416, 1118, 121, -2562, -2562, 837, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, 837, 1394, + -2562, -2562, -2562, -42, -2562, -2562, -2562, -2562, 5345, -2562, + -2562, 1401, 1405, 837, 1407, 1409, 1410, -14, -14, -64, + 1415, 1416, 1419, 1420, 1158, 1165, 1426, 1428, 1430, 42, + 42, -64, 1432, 1433, -64, 1436, 1437, 5109, 1441, 1447, + -2562, -2562, 1448, 1449, 710, -2562, 1434, 1454, 1456, 1461, + -14, -64, 1463, 1465, -2562, 1467, -2562, -2562, 1397, 725, + 1338, 1241, 1246, 1249, 1379, 785, 1254, 1480, 175, 1355, + 1386, 817, 909, 1453, 1288, 1293, 1425, 1520, 1324, 119, + 24, 616, 1298, 5014, 1482, 1500, 257, 1306, 1337, 1540, + 29, -2562, -2562, 411, 1542, 1546, -2562, -2562, -2562, 1555, + 1340, 59, 1482, 1358, -2562, -2562, -2562, 330, 1562, 1565, + 837, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + 18, -2562, 1053, -2562, 837, -2562, 837, -2562, -2562, -2562, + -2562, 837, 837, 837, 618, 5258, -2562, 1567, 1049, -2562, + -2562, 837, -2562, -2562, 837, 5014, 837, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, 330, 837, -2562, 837, 618, 1569, -2562, 837, 837, + -2562, 330, -2562, -2562, -2562, 709, 1571, 1572, -2562, -2562, + -2562, -2562, 837, 837, -2562, -2562, 1553, 837, 837, -2562, + -2562, -2562, -2562, 837, -2562, 837, 1469, -2562, 837, -2562, + 837, 1470, -2562, 1580, -2562, 1108, 1108, 708, 1108, 1584, + -2562, 730, -2562, -2562, 1590, 1591, 763, 1593, -2562, 1594, + 1595, 1597, -2562, 770, 777, 1600, 1602, 1598, -2562, -2562, + 1604, 1605, 1607, -2562, 1108, 1108, 1108, -2562, -2562, -2562, + 837, 837, 837, 837, -2562, 837, 916, 5258, -2562, 837, + -2562, 4124, 1397, -2562, -2562, 1610, -2562, -2562, 1614, -2562, + -2562, -2562, -2562, 1586, 3782, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, 837, 1612, 837, 837, 837, + 864, -2562, 1606, 1618, 837, 837, -11, 1620, 330, 330, + -2562, 1397, 837, 1626, 1627, 1628, -2562, 5258, -2562, 837, + -2562, -2562, -2562, 837, 837, 837, 1397, 1629, 5258, -42, + -2562, -2562, -2562, 1553, 837, 1630, -42, 837, 1601, 1603, + 482, -2562, 1631, -2562, -2562, 721, -2562, -2562, 837, 1634, + 1643, 837, -2562, 1639, 798, 5014, 1412, 1413, 1414, 108, + 5258, 1417, -2562, 218, 1516, 179, 1421, 1422, 195, -2562, + -2562, 432, 1486, 620, -98, 1482, -50, -2562, 1653, 1423, + -2562, 449, -2562, -2562, -2562, -2562, 1482, 1455, -2562, -2562, + -2562, -2562, -2562, 837, 980, -2562, 837, -2562, -2562, 837, + 837, -2562, 837, -2562, 837, -2562, -2562, -2562, -2562, 1468, + 837, -2562, 837, 32, -2562, -2562, 1656, 1659, -2562, 837, + -14, -14, -14, -2562, -2562, -2562, -2562, -2562, -2562, 1661, + -14, -14, -14, 579, -2562, -2562, 42, -14, -14, -14, + -2562, -2562, -14, -14, 1662, -14, -14, 1663, 42, 758, + -2562, 1666, 1667, 1670, -2562, 734, -2562, 1178, 1403, -2562, + 800, -2562, 1424, 1671, 1672, 1673, 42, 42, -64, 1675, + 1676, -64, 1678, 1680, 1681, -14, -14, -2562, 1684, -14, + -14, -2562, 1685, -2562, -2562, -2562, -2562, -2562, -2562, 330, + -2562, -2562, -2562, 5014, 1005, 837, 1081, 1149, 3, -2562, + -2562, -2562, 395, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, 1686, 837, -2562, 330, 1687, + 837, 5258, 330, 1352, 1464, 1466, 203, 206, 1472, 234, + 1393, 1400, 1694, 1698, 1702, 785, 1703, 1704, 1705, 1411, + 1418, 1056, 1707, 837, 1095, 1473, -2562, -2562, 330, 5014, + -2562, -2562, 5014, 837, 63, 1709, 837, 1397, 1553, 330, + -2562, 5014, 5258, 837, -2562, -2562, -2562, 330, 330, 5014, + -2562, -2562, -2562, -2562, -2562, -2562, 5014, 837, 330, -2562, + -2562, -2562, 837, -2562, -2562, 1710, 837, 1494, 169, 837, + 1497, 837, 178, 837, -2562, 837, 1498, 1504, 837, 837, + 837, 837, 837, 837, 837, 837, 17, 837, 837, 1507, + -2562, 837, 837, 837, 837, -2562, 5258, 1397, 1715, 5258, + 5258, 837, 837, 1397, 1553, -2562, 837, 837, 837, 5258, + -2562, 837, 837, -2562, -2562, -2562, 1723, -2562, -2562, -2562, + -2562, -2562, -2562, 837, 837, -2562, 837, 837, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, 1725, 1728, 1731, + -2562, -2562, 1108, 1732, 1733, 1735, -2562, 1736, 1737, 1738, + 1739, 1741, -2562, 1742, -2562, -2562, -2562, 1743, 1745, 1747, + -2562, 1748, 1749, 1752, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, 837, 837, 1757, + 5258, -2562, 837, 1397, -2562, -2562, -2562, 3782, 837, 1397, + 837, 837, 837, -2562, 837, 837, 1753, 837, 1755, 1730, + 837, 837, -2562, -2562, 1756, 5258, -2562, -2562, -2562, 837, + -2562, -2562, -2562, 1397, -2562, 1187, 837, 1187, -42, -2562, + 1397, 5258, 837, 837, 1759, -2562, -2562, -2562, -2562, -2562, + 837, -2562, -2562, -2562, -2562, -2562, 837, 1760, -2562, -2562, + 5258, 1762, 1763, 1764, 1766, 5258, 1397, -2562, 5258, 5258, + 5258, 5014, 5258, 1397, 5258, -2562, -2562, 5258, -2562, -2562, + 5014, 5258, 5258, 5258, 5014, 5258, -2562, 5258, 5258, 837, + -2562, -2562, 5258, 5258, 5258, -2562, 5258, 5258, -2562, -2562, + -2562, -2562, 5258, 5258, -2562, -2562, -2562, 5258, 1767, 1768, + 1771, 1772, 5258, -2562, -2562, 837, 837, -2562, -2562, 1761, + 837, -2562, -2562, 1773, 1775, -2562, 837, -2562, -2562, -2562, + -14, -2562, -2562, -2562, 1776, 1777, 1778, -2562, -2562, -64, + 1780, 1782, 1783, -14, -2562, -2562, -2562, -2562, -2562, 42, + -2562, -2562, 1787, -14, 1817, 1818, 1819, 42, 42, -64, + 1788, 1822, 1823, 1026, -2562, 1032, -2562, 1126, 1479, 1824, + 1825, 1826, 42, 42, -64, 1828, 1830, -64, 1831, 1489, + 1832, 1833, 1836, 42, 42, -64, 1839, 1841, -64, 1842, + 1524, 1843, 1845, 1846, 42, 42, -64, 1848, 1849, -64, + 1850, 1851, 1852, 1853, 42, 42, -64, 1865, 1866, 1867, + 42, -2562, -2562, -2562, -2562, -2562, 1870, -2562, -2562, 1871, + 42, 1872, 1874, -2562, -2562, -14, -2562, -2562, 1875, -2562, + 1397, -2562, 5258, 837, 837, 5258, 837, 1876, 1338, -2562, + -2562, -2562, -2562, -2562, -2562, 1877, 5014, 330, 1881, 5014, + 1397, -2562, 1883, 1338, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 1885, 1886, -2562, -2562, -2562, 1891, -2562, + -2562, -2562, 1887, 1893, -2562, -2562, -2562, 837, 5258, 837, + 1894, 1338, 330, 1397, 1553, 1397, 837, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, 837, 1553, 1553, + -2562, 1397, 1553, 1397, 837, -2562, -2562, 1397, 1553, 1397, + 1553, -2562, -2562, -2562, -2562, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 2906, -2562, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 3963, 1897, + 837, -2562, 837, 837, 837, 1901, 1903, -2562, -2562, 1397, + -42, 1904, 1397, 1397, -2562, -2562, 1553, -2562, 837, -2562, + 1905, 1397, -2562, -2562, -2562, -2562, -2562, -2562, -2562, 1108, + 1108, 1108, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, 837, -2562, + -2562, 837, -2562, 837, 1397, 837, -2562, 1553, 837, -2562, + 837, -2562, 1815, 1906, 1907, -2562, 1910, 837, 837, 1911, + 1397, 5258, -2562, -2562, 837, -2562, 837, -2562, -42, 721, + 837, 1912, -2562, 837, 0, -2562, -2562, 1913, 1914, 1915, + 1926, 1397, -2562, 721, 721, 721, 1397, -2562, 721, -42, + 721, 721, 1397, -2562, 721, 721, 721, 1397, -2562, 721, + 721, 1397, 5258, 721, 1397, 721, 721, 1397, 721, 1397, + -2562, 1927, 1940, 1942, 1946, 1397, -2562, -2562, 1948, 0, + 1949, -2562, 837, -2562, -2562, -2562, -2562, 1952, -2562, -2562, + -2562, -2562, -14, 42, -2562, -2562, -2562, -2562, -2562, -2562, + 1953, -2562, -2562, 42, 1954, 1956, 1957, 42, 42, -64, + 1959, 1961, 1962, 1963, 1964, 1965, 42, 42, -64, 1967, + 1968, 1969, 1972, 1973, 1974, 42, 42, -64, 1976, 1977, + 1978, 42, -14, -14, -14, -14, -14, 1980, -14, -14, + 1981, 42, 42, -14, -14, -14, -14, -14, 1982, -14, + -14, 1983, 42, 42, -2562, -2562, -2562, -2562, -2562, 1984, + -2562, -2562, 1985, 42, -2562, -2562, -2562, -2562, -2562, 1986, + -2562, -2562, 42, -2562, 42, 1988, -2562, 1991, 1992, -2562, + 4124, -2562, 721, 1994, 5014, 721, 837, 5258, 1996, -2562, + 721, -2562, -2562, -2562, 721, -2562, -2562, 5258, 1998, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + -2562, -2562, -2562, 5014, 721, 837, 5258, 1999, -2562, 1553, + 1553, 1553, 837, 5014, 1553, 837, 1553, 1553, 5258, 5014, + 1553, 837, 1553, -2562, 837, 837, 837, 837, 837, 837, + 1338, 837, 837, 837, 1491, 1502, 1505, 1510, 1527, 1535, + 1638, 2906, -2562, 1664, -2562, -2562, 1338, 837, 837, 837, + 837, 1338, 837, 837, 837, 837, 837, 837, 1397, 837, + 1619, 1338, 837, 837, -2562, -2562, -42, 330, 2001, 2003, + -2562, -2562, -2562, -2562, -2562, -42, -2562, -2562, -2562, 837, + -2562, -2562, 1553, 837, -2562, -2562, -2562, 930, 2004, 2005, + -2562, 837, 2007, 1187, -2562, 721, -2562, -2562, -2562, -2562, + 2010, -2562, -2562, -2562, 2008, 2011, 5258, 2012, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -42, 721, -2562, -42, -2562, -2562, + -42, -2562, -42, 2014, 2016, 5258, 2019, -2562, 2020, -2562, + -2562, 837, -2562, -2562, -14, 42, -2562, -14, -14, -14, + -14, -14, 2015, -14, -14, 42, -2562, -2562, -2562, -2562, + -2562, 2023, -2562, -2562, 42, -14, -14, -14, -14, -14, + 2024, -14, -14, 42, -14, -2562, -2562, -2562, -2562, -2562, + 42, -2562, -2562, 2030, -14, -14, -2562, -2562, -2562, -2562, + -2562, 42, -2562, -2562, 2033, -14, -2562, 42, 2034, -2562, + 42, -2562, -2562, 42, -2562, -2562, 1397, -2562, 5014, 721, + -2562, -2562, 2035, 1397, 837, -2562, -2562, 1397, 837, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, 837, 837, + 721, -2562, -2562, 2036, 1397, 837, 1553, -2562, -2562, -2562, + 721, -2562, 837, -2562, 1553, -2562, 721, 721, -2562, 5258, + 1338, -2562, 837, 2037, 2037, 837, 837, 2037, 1338, 2037, + -2562, 5258, 785, 2038, 2040, 2041, 2042, 2043, 2045, -2562, + 330, 1338, 2037, 2037, 837, 837, 1338, 837, 837, 837, + 837, 837, -2562, 1553, 837, 2046, -2562, -2562, 837, 2037, + 330, 6, -2562, 2047, 330, -2562, -2562, -2562, 2048, 837, + -2562, 2049, 2051, 2044, 837, -2562, -2562, -2562, 2052, -6, + 5258, -2562, -2562, -2562, -2562, -2562, -2562, 2053, -6, 5258, + -2562, 837, -2562, -2562, -2562, -2562, -2562, -2562, -2562, 42, + -2562, -2562, -14, 42, -2562, -2562, -2562, -2562, -2562, -2562, + 42, -2562, -2562, -14, -2562, -14, 42, -2562, -2562, -14, + 42, -2562, -2562, 42, -2562, -2562, 837, 721, -2562, -2562, + 5014, 5258, 837, 5258, 837, -2562, -2562, -2562, 5014, 5258, + 837, -2562, -2562, 5258, -2562, -2562, -2562, 721, -2562, 2055, + -2562, -2562, -2562, 1338, 837, -2562, 2056, -2562, -2562, 1397, + 2057, -2562, 2060, -2562, -2562, -2562, -2562, -2562, 2061, -2562, + -2562, 1338, 837, 2062, -2562, -2562, 837, 5258, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, 6, 1484, 1482, -2562, -2562, + 2063, 2064, -2562, 2050, 2066, 78, 5258, -2562, -2562, -2562, + -2562, 5258, -2562, -2562, 2067, -14, -2562, -2562, -14, -2562, + -2562, -14, -2562, -14, -2562, 4124, -2562, 721, -2562, 721, + 837, 721, 2068, 721, -2562, 721, 837, 721, 837, -2562, + -2562, -2562, -2562, 2069, -2562, 837, -2562, -2562, 2071, -2562, + 837, -2562, -2562, -2562, 2070, 837, -2562, -2562, -2562, 1397, + -2562, -2562, -2562, 1484, -2562, 1696, 1717, 1482, -2562, 2072, + 2074, 2078, -2562, -2562, -2562, -2562, -2562, -2562, 837, 1397, + 1397, -2562, -2562, -2562, -2562, -2562, 721, -2562, -2562, 2079, + -2562, 5014, -2562, -2562, 2080, -2562, 1338, -2562, -2562, 1338, + 837, -2562, -2562, 837, -2562, 1338, 837, -2562, 5258, -2562, + 1696, -2562, 330, -2562, 2083, 2085, -2562, 837, -6, -6, + 2086, 5014, 1397, -2562, 5014, -2562, -2562, 837, 2081, -2562, + 837, 721, -2562, -2562, -2562, 2087, 2088, -2562, -2562, -2562, + 1397, -2562, -2562, 1397, -2562, -2562, 2090, -2562, -2562, 2091, + -2562, -2562, -2562, -2562, -2562, 1338, -2562, 1338, -2562, -2562, + -2562, -2562, -2562 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -2562, -2562, -4, -2562, 297, -2562, -1596, -893, 1523, -2562, + 675, -326, 1844, -49, 99, -1638, 1655, 1951, -869, 570, + -2562, -857, 729, 1581, -2562, -928, -2562, -2511, -1123, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -1443, -2562, -2562, -2562, -2562, -2562, -651, -2562, -2562, + -2562, -2562, -2562, -2562, 33, -2562, -2562, -2562, -2562, -184, + -652, -1350, -536, -2562, -2562, -2562, -2562, -601, -596, -2562, + -2562, -2561, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, 1373, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, -2562, + -2562, -2562, -2562, -2562, -2562, -2562 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1235 +static const yytype_int16 yytable[] = +{ + 70, 347, 1878, 1240, 1241, 1242, -1090, 2024, 107, 2026, + 1065, 1068, 109, 1566, 1091, 1571, 885, 2642, 1104, 772, + 67, 68, 1948, 1494, 775, 376, 2637, 67, 68, 289, + 619, 1060, 636, 413, 1476, 1632, 311, 305, 67, 68, + 319, 1601, 1602, 1603, 1095, 341, 67, 68, 352, 610, + 67, 68, 1731, 560, 367, 1189, 112, 408, 373, 1350, + 1460, 380, 67, 68, 1323, 383, 385, 249, 1702, 394, + 304, 1070, 400, 404, 745, 1071, 407, 109, 67, 68, + 411, 67, 68, 67, 68, 412, 741, 67, 68, 320, + 1898, 67, 68, 67, 68, 1484, 554, 1403, 425, 1337, + 434, 435, 439, 441, 1354, 846, 531, 1357, 1849, 109, + 258, 1899, 1105, 274, 1900, 275, 1706, 839, 1106, 445, + 532, 1248, 1703, 321, 1388, 1901, 114, 67, 68, 1681, + 842, 1097, 291, 545, 2741, 57, 67, 68, 1318, 748, + 1333, 585, 533, 67, 68, 1072, 1458, 112, 1902, 386, + 1123, 972, 250, 1461, 457, 849, 555, 704, 568, 742, + 422, 534, 401, 251, 1073, 1903, 54, 561, 1334, 1153, + 1707, 259, 67, 68, 67, 68, 886, 535, 490, 2762, + 536, 67, 68, 511, 55, 1704, 423, 847, 1485, 109, + 293, 114, 79, 260, 1338, 1850, 160, 252, 1351, 177, + 1690, 978, 1428, 256, 537, 538, 303, 117, 850, 379, + 268, 120, 1190, 118, 119, 444, 1694, 248, 973, 1319, + 1124, 1061, 546, 114, 1866, 1708, 1074, 1868, 483, 276, + 366, 1249, 390, 484, 559, 611, 1154, 2767, 2768, 67, + 68, 261, 617, 253, 1851, 1685, 695, 269, 979, 266, + 414, 306, 743, 1633, 402, 1871, 254, 539, 643, 644, + 1311, 1732, 705, 2703, 620, 540, 309, 377, 2638, 485, + 1477, 562, 117, 679, 307, 279, 102, 322, 118, 119, + 325, 681, 684, -1090, 687, 691, 512, 693, 520, 637, + 525, 529, 409, 486, 773, 103, 122, 703, 556, 776, + 1062, 1125, 120, 114, 117, 712, 714, 1107, 109, 1462, + 118, 119, 162, 583, 1949, 1495, 887, 1096, 586, 239, + 1075, 1098, 541, 542, 264, 67, 68, 403, 757, 758, + 763, 296, 765, 277, 109, 387, 768, 769, 487, 1459, + 1429, 1682, 391, 1305, 1486, 152, 104, 781, 783, 153, + 154, 784, 785, 786, 787, 788, 789, 790, 791, 792, + 310, 122, 1469, 793, 109, 69, 1119, 1126, 796, 798, + 1651, 396, 569, 2704, 980, 340, 799, 1655, 112, 800, + 1488, 488, 489, 1686, 117, 392, 393, 689, 388, 1927, + 118, 119, 326, 122, 543, 570, 809, 810, 1932, 262, + 1099, 624, 327, 814, 815, 816, 1904, 817, 1430, 351, + 152, 270, 1691, 1526, 153, 154, 2705, 2706, 372, 67, + 68, 824, 114, 881, 271, 825, 751, 105, 1695, 328, + 830, 831, 832, 833, 834, 835, 1867, 836, 1478, 1869, + 840, 841, 152, 981, 1539, 263, 153, 154, 114, 1982, + 1431, 1687, 982, 843, 944, 945, 58, 853, 575, 1696, + 459, 460, 461, 462, 463, 464, 465, 1872, 576, 466, + 467, 468, 469, 122, 754, 112, 1711, 1471, 114, 294, + 96, 1054, 67, 68, 983, 272, 1659, 1036, 219, 295, + 735, 336, 349, 1688, 354, 577, 97, 59, 615, 630, + 1852, 946, 329, 117, 220, 365, 1092, 867, 869, 118, + 119, 1228, 625, 1037, 1848, 60, 631, 106, 801, 759, + 355, 1826, 152, 369, 1829, 877, 153, 154, 1043, 117, + 370, 1043, 1472, 120, 397, 118, 119, 932, 112, 330, + 1863, 838, 67, 68, 61, 955, 356, 357, 736, 854, + 1244, 1055, 898, 1128, 956, 957, 716, 641, 642, 117, + 358, 62, 1891, 371, 63, 118, 119, 80, 578, 1044, + 98, 1144, 1044, 398, 572, 64, 1093, 969, 1209, 928, + 696, 331, 802, 1101, 686, 626, 1210, 1853, 1293, 760, + 1067, 632, 122, 1744, 1745, 375, 988, 406, 1697, 899, + 900, 958, 332, 81, 723, 579, 359, 360, 594, 337, + 99, 616, 416, 943, 717, 1712, 697, 418, 122, 1313, + 67, 68, 855, 1129, 746, 749, 752, 947, 948, 1145, + 120, 1479, 1056, 1705, 882, 627, 1854, 333, 420, 987, + 1746, 152, 1038, 100, 1714, 153, 154, 755, 122, 803, + 1294, 595, 1698, 334, 442, 901, 1063, 1094, 628, 1076, + 382, 902, 725, 698, 1146, 2514, 919, 152, 580, 1713, + 761, 153, 154, 82, 1295, 1149, 573, 1111, 1112, 1113, + 1114, 1043, 1155, 1115, 497, 1117, 458, 1118, 338, 1120, + 471, 1039, 498, 120, 737, 1045, 949, 152, 1045, 762, + 470, 153, 154, 481, 1130, 950, 951, 550, 903, 1046, + 1047, 493, 1046, 1047, 1544, 1372, 1040, 1064, 361, 581, + 362, 1182, 1044, 904, 1373, 1374, 1545, 959, 960, 65, + 522, 804, 495, 1150, 718, 905, 805, 952, 780, 1778, + 1156, 906, 907, 67, 68, 1662, 1663, 908, 1779, 1780, + 1296, 548, 797, 596, 83, 1170, 1171, 1172, 1173, 1174, + 719, 1175, 1177, 1179, 1180, 699, 1747, 1748, 1160, 1567, + 1131, 1375, 1764, 1765, 313, 1147, 1192, 1193, 549, 2027, + 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 551, + 1550, 1573, 1206, 1207, 558, 1781, 961, 363, 909, 1297, + 1048, 1049, 84, 1048, 1049, 962, 963, 1393, 731, 564, + 964, 1213, 1214, 1215, 1811, 1812, 240, 910, 1664, 1766, + 552, 911, 565, 912, 1579, 1408, 1161, 1568, 1223, 1224, + 1225, 1587, 1227, 567, 1229, 1749, 1230, 965, 1591, 1434, + 67, 68, 1298, 241, 1750, 1751, 913, 914, 1045, 1574, + 584, 1409, 590, 1233, 915, 1235, 2286, 2287, 2288, 314, + 592, 1813, 1046, 1047, 613, 1238, 1435, 67, 68, 1436, + 315, 1464, 916, 1245, 1394, 1700, 1752, 1465, 1247, 1151, + 1670, 1701, 1580, 614, 1410, 622, 1157, 819, 820, 1588, + 1411, 618, 2087, 1261, 1263, 1412, 1592, 1376, 1377, 1437, + 634, 1303, 639, 1306, 1309, 640, 298, 645, 939, 677, + 1314, 242, 2100, 1413, 678, 1320, -1232, 1652, 1363, 67, + 1609, 1782, 1783, 1626, 1321, 243, 1438, 2137, 917, 1439, + 2140, 1442, 1414, 67, 68, 694, 67, 1176, 2148, 1329, + 680, 2151, 701, 1395, 1396, 1767, 1768, 1671, 1415, 2159, + 316, 702, 2162, 1048, 1049, 2188, 1234, 1397, 1443, 2169, + 707, 1444, 1079, 317, 1445, 709, 1378, 1102, 1183, 1184, + 2198, 1299, 1162, 1569, 715, 1379, 1380, 1416, 67, 68, + 1381, 244, 67, 68, 67, 68, 1402, 1814, 1815, 2508, + 1784, 1446, 1308, 1205, 721, 1575, 1398, 2672, 2217, 1785, + 1786, 1186, 1187, 299, 1787, 598, 1463, 1382, 67, 68, + 1842, 1025, 739, 1417, 1769, 2683, 1672, 1673, 1447, 436, + 1300, 1448, 245, 1770, 1771, 1026, 1418, 1487, 1581, 2600, + 1674, 1788, 246, 740, 1027, 1589, 1493, 1419, 766, 1440, + 2104, 2105, 1593, 767, 1028, 1301, 2113, 2114, 67, 1260, + 1521, 770, 1522, 1529, 1530, 1772, 1816, 1523, 1524, 1525, + 1884, 1885, 1717, 778, 1420, 1817, 1818, 1531, 1441, 1675, + 1532, 599, 1535, 1029, 300, 1496, 1421, 794, 1422, 1423, + 1497, 280, 795, 301, 67, 68, 1845, 2106, 1537, 437, + 1538, 2277, 1030, 2115, 1541, 1542, 808, 1819, 67, 68, + 1888, 1498, 1499, 811, 1500, 1501, 827, 828, 1548, 1549, + 600, 812, 1468, 1551, 1552, 1502, 1217, 72, 1424, 1553, + 2598, 1554, 73, 813, 1556, 818, 1557, 1503, 1504, 1718, + 821, 1449, 1613, 2756, 823, 1505, 426, 1031, 1506, 2759, + 2122, 2123, 1909, 86, 428, 844, 2622, 845, 601, 852, + 1560, 1561, 67, 68, 1847, 1507, 1400, 1401, 74, 2308, + 1450, 1508, 1509, 857, 859, 1510, 1604, 1605, 1606, 1607, + 438, 1608, 1610, 1032, 1534, 1612, 861, 863, 865, 879, + 2324, 884, 75, 1789, 889, 894, 1451, 2124, 895, 2789, + 1618, 2790, 1790, 1791, 896, 930, 897, 1033, 1719, 1720, + 920, 1621, 922, 1623, 1624, 1625, 1627, 924, 1967, 926, + 1630, 1631, 1721, 2107, 2108, 86, 929, 281, 1639, 2116, + 2117, 934, 282, 1511, 283, 1644, 938, 76, 942, 1645, + 1646, 1647, 940, 941, 953, 954, 1034, 966, 1035, 1792, + 1653, 2670, 2671, 1656, 974, 2674, 976, 2676, 977, 1053, + 984, 1722, 2362, 985, 1666, 986, 1051, 1668, 1042, 2681, + 2682, 2371, 1058, 87, 2686, 2687, 1059, 1108, 2690, 1109, + 2380, 77, 1110, 2691, 2692, 1512, 1562, 1563, 67, 68, + 1513, 1121, 2109, 1133, 1137, 723, 88, 1135, 2118, 1134, + 89, 2110, 2111, 1620, 1136, 1514, 1138, 2119, 2120, 1716, + 1139, 1140, 1723, 1564, 1515, 1724, 1725, 1141, 1726, 1142, + 1727, 1159, 1166, 2125, 2126, 682, 1729, 1164, 1730, 2727, + 1165, 1167, 2728, 2112, 1168, 1736, 472, 2731, 1169, 2121, + 1185, 1516, 1517, 2734, 1490, 87, 1188, 1194, 2737, 90, + 724, 67, 68, 725, 473, 1400, 1401, 2468, 1204, 1660, + 67, 68, 1518, 1208, 1211, 67, 68, 1862, 88, 1400, + 1401, 474, 2023, 2481, 1677, 1793, 1794, 1212, 2486, 1216, + 1218, 1219, 1252, 475, 1231, 91, 1232, 1253, 726, 1254, + 1257, 1259, 2127, 92, 93, 683, 1258, 710, 1536, 1310, + 476, 2128, 2129, 477, 1304, 1312, 1519, 1316, 1543, 1322, + 1843, 1844, 1846, 1402, 478, 1326, 2775, 2500, 1800, 2778, + 1327, 90, 1330, 727, 1331, 1332, 2504, 1801, 1802, 1340, + 1341, 1345, 1856, 2130, 1342, 1343, 1859, 2786, 1346, 1402, + 2788, 1347, 446, 1348, 1795, 1349, 1355, 1356, 1383, 2791, + 2792, 1358, 1359, 1796, 1797, 479, 1365, 91, 1798, 1887, + 1889, 1402, 1367, 1368, 1370, 92, 93, 711, 1384, 1897, + 728, 1385, 1907, 729, 1803, 2521, 1386, 1389, 2523, 1914, + 1390, 2524, 1391, 2525, 1404, 1799, 67, 68, 1890, 1405, + 1400, 1401, 1406, 1921, 1407, 1427, 730, 1426, 1923, 731, + 1432, 1433, 1925, 1452, 1928, 1929, 1181, 1931, 1933, 1934, + 732, 1937, 1841, 447, 1940, 1941, 1942, 1943, 1944, 1945, + 1946, 1947, 1950, 1952, 1953, 1636, 1637, 1955, 1956, 1957, + 1958, 1453, 448, 449, 450, 1456, 1454, 1964, 1965, 451, + 1455, 1457, 1968, 1969, 1970, 1466, 2592, 1972, 1973, 2595, + 1470, 2597, 452, 1473, 1474, 1475, 1480, 1483, 453, 1975, + 1976, 1481, 1977, 1978, 2609, 2610, 67, 68, 1894, 454, + 1482, 1896, 426, 427, 428, 1489, 1491, 2588, 2220, 1492, + 1912, 2624, 1528, 1080, 1540, 2596, 1546, 1547, 1918, 1555, + 1558, 1081, 2224, 2225, 1559, 1920, 2227, 1082, 2608, 1572, + 1804, 1805, 2231, 2613, 2233, 1577, 1578, 1583, 1617, 1584, + 1585, 1586, 1597, 1998, 1999, 1595, 1083, 1596, 2001, 1598, + 1599, 1600, 1628, 2003, 2006, 1615, 2008, 2009, 2010, 1616, + 2011, 2012, 1629, 2014, 1622, 1635, 2017, 2018, 222, 1084, + 1640, 1641, 1642, 1649, 1654, 2021, 1661, 1085, 1667, 1657, + 2282, 1658, 2025, -446, 1669, 1678, 1679, 1680, 2030, 2031, + 1684, 1689, 1699, 223, 1692, 1693, 2033, 1709, 1715, 1806, + 1734, 1728, 2034, 1735, 1710, 1740, 1759, 1762, 1807, 1808, + 455, 1773, 1775, 1809, 1086, 1777, 1821, 1822, 1823, 1827, + 1828, 2294, 1087, 1830, 1831, 1832, 224, 1820, 1835, 1353, + 1838, 1855, 1858, 225, 1873, 2062, 1839, 1864, 1875, 1865, + 1810, 1874, 1876, 226, 227, 1870, 1877, 1879, 1880, 1881, + 228, 1886, 1882, 1906, 1926, 1924, 2005, 1930, 1938, 1883, + 1961, 2076, 2077, 1088, 1939, 1857, 2079, 1954, 1974, 1861, + 1979, 229, 2082, 1980, 1089, 1981, 2016, 1983, 1984, 1985, + 1986, 1987, 2131, 1988, 1989, 1990, 1991, 230, 1992, 1090, + 1993, 1994, 2142, 1995, 1996, 1892, 1997, -1234, 2013, 2015, + 2019, -1103, 231, 2032, 2035, 2078, 1910, 2037, 2038, 2039, + 232, 2040, 2071, 2072, 1915, 1916, 2073, 2074, 2080, 2081, + 2047, 2084, 2085, 2086, 2088, 1922, 2089, 2153, 2090, 2053, + 233, 2093, 2101, 2058, 124, 125, 126, 127, 128, 129, + 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, + 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, + 150, 151, 2095, 2096, 2097, 234, 2102, 2297, 2103, 2132, + 2133, 2134, 2138, 2755, 2139, 2472, 2141, 2143, 2144, 2183, + 2184, 2145, 2186, 2149, 1402, 2150, 2473, 2152, 2154, 2474, + 2155, 2156, 2160, 2161, 2475, 2163, 2164, 2165, 2166, 1402, + 2199, 2200, 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2170, + 2171, 2476, 2172, 235, 2174, 2175, 2177, 290, 2178, 2477, + 2180, 2187, 2189, 2213, 236, 2215, 2193, 1402, 2197, 2208, + 2209, 2211, 2222, 2446, 2447, 2448, 2210, 2212, 2452, 2216, + 2454, 2455, 2269, 2223, 2459, 2274, 2461, 2275, 2278, 2284, + 2229, 2298, 2299, 237, 2300, 2303, 2495, 2311, 2314, 2315, + 2316, 2234, 2235, 2236, 2237, 2238, 2239, 2240, 2241, 2242, + 2243, 2317, 2343, 2256, 2257, 2258, 2259, 2260, 2261, 2262, + 2263, 2264, 2265, 2266, 2267, 2344, 2270, 2345, 2271, 2272, + 2273, 2346, 2348, 826, 2350, 2191, 2352, 2355, 2195, 2357, + 443, 2358, 2359, 2363, 2283, 2364, 2506, 2365, 2366, 2367, + 2368, 2372, 2373, 2248, 2374, 2696, 163, 2375, 2376, 2377, + 2381, 2382, 2478, 2383, 2390, 2393, 2401, 2404, 2407, 2408, + 2410, 164, 2413, 165, 2289, 2414, 2415, 2290, 2418, 2291, + 2424, 2293, 2428, 2445, 2295, 2502, 2296, 2503, 2480, 2510, + 2511, 2513, 2517, 2301, 2302, 2516, 2518, 2520, 2526, 2539, + 2306, 2527, 2307, 166, 2529, 2530, 2310, 2543, 2550, 2312, + 509, 167, 516, 519, 2556, 524, 528, 2560, 2563, 2570, + 2578, 2590, 807, 2601, 2602, 2696, 2603, 2604, 2605, 2606, + 2634, 2621, 2628, 2630, 2632, 2633, 2701, 2636, 2641, 2669, + 2675, 2742, 2678, 588, 2679, 2680, 2685, 2479, 2699, 2700, + 2702, 2711, 2721, 2729, 2735, 1753, 2732, 2744, 2351, 2745, + 603, 608, 2746, 2751, 2754, 2777, 168, 1763, 2764, 2693, + 2765, 2769, 2781, 2782, 2785, 2787, 2743, 2739, 0, 1143, + 343, 0, 0, 0, 0, 1824, 1825, 344, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2581, 0, 0, 0, 0, 0, 0, 0, 2584, 0, + 0, 2416, 688, 2313, 0, 0, 169, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 708, 0, 170, 171, 2192, 0, 0, 0, 0, 172, + 0, 173, 0, 0, 0, 0, 0, 2619, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 2349, 0, + 0, 0, 2422, 0, 0, 0, 174, 0, 0, 2218, + 0, 0, 0, 0, 0, 2429, 2430, 2431, 2432, 2433, + 2434, 2435, 2436, 2437, 2438, 2439, 0, 0, 0, 0, + 0, 2443, 0, 0, 0, 0, 0, 0, 2449, 0, + 0, 2453, 0, 0, 0, 0, 0, 2460, 0, 0, + 2462, 2463, 2464, 2465, 2466, 2467, 1402, 2469, 2470, 2471, + 0, 692, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 175, 1402, 2482, 2483, 2484, 2485, 1402, 2487, 2488, + 2489, 2490, 2491, 2492, 0, 2494, 822, 1402, 2498, 2499, + 0, 0, 0, 0, 0, 0, 0, 829, 0, 0, + 0, 0, 0, 2420, 0, 2505, 837, 0, 0, 2507, + 0, 0, 0, 2509, 0, 0, 0, 2512, 779, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2441, 0, 0, 0, 0, 0, 0, 345, + 0, 346, 2451, 0, 0, 0, 0, 0, 2458, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2531, 0, 0, + 0, 0, 0, 0, 0, 868, 0, 0, 870, 871, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 875, 0, 0, 0, 0, 878, 0, 0, 0, + 0, 0, 0, 0, 0, 890, 892, 0, 124, 125, + 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, + 146, 147, 148, 149, 150, 151, 0, 0, 0, 0, + 2572, 0, 0, 0, 2574, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2575, 2576, 0, 0, 0, 0, + 0, 2580, 0, 0, 0, 0, 0, 0, 2583, 935, + 936, 937, 0, 0, 0, 0, 1402, 0, 2589, 0, + 866, 2593, 2594, 0, 1402, 0, 0, 872, 0, 0, + 873, 0, 0, 0, 0, 874, 0, 1402, 0, 876, + 2611, 2612, 1402, 2614, 2615, 2616, 2617, 2618, 2092, 0, + 2620, 0, 0, 0, 2623, 0, 2098, 2099, 0, 0, + 0, 0, 0, 0, 0, 2631, 0, 0, 1078, 0, + 2635, 2135, 2136, 0, 0, 0, 0, 2568, 0, 0, + 0, 0, 2146, 2147, 0, 0, 0, 2644, 0, 1336, + 0, 0, 0, 2157, 2158, 0, 0, 0, 0, 933, + 0, 0, 0, 2167, 2168, 0, 0, 0, 0, 2173, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2176, + 0, 1387, 2655, 0, 0, 0, 0, 0, 2660, 0, + 2662, 0, 0, 0, 2501, 0, 2666, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1402, + 2673, 0, 0, 0, 0, 0, 0, 0, 0, 2309, + 0, 0, 0, 0, 0, 0, 2716, 1402, 2684, 0, + 0, 0, 2688, 2319, 2320, 2321, 0, 0, 2323, 0, + 2325, 2326, 0, 0, 2328, 2329, 2330, 0, 0, 2332, + 2333, 2707, 0, 2336, 0, 2338, 2339, 0, 2341, 1116, + 0, 0, 0, 0, 0, 0, 1122, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2719, 0, 0, 0, + 0, 0, 2724, 0, 2726, 0, 0, 1221, 0, 2658, + 0, 2730, 0, 0, 0, 0, 2733, 2664, 0, 1226, + 0, 2736, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2747, 0, 0, 0, 0, 0, + 0, 1236, 1237, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1402, 0, 0, 1402, 2757, 0, 0, 2758, + 0, 1402, 2760, 0, 0, 1256, 0, 0, 0, 0, + 0, 0, 0, 2766, 0, 0, 0, 0, 0, 0, + 0, 0, 2417, 2776, 0, 2421, 2779, 0, 0, 0, + 2425, 0, 0, 0, 2426, 0, 0, 0, 0, 0, + 0, 0, 0, 1220, 0, 0, 0, 2607, 0, 0, + 1222, 1402, 1325, 1402, 2442, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2625, 0, 0, + 0, 2629, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2753, 1239, 2354, 0, 0, 0, 1243, 0, 0, 1246, + 0, 0, 2356, 0, 0, 0, 2360, 2361, 0, 0, + 0, 1255, 0, 0, 0, 2369, 2370, 0, 0, 0, + 2771, 0, 0, 2774, 2378, 2379, 0, 1467, 0, 0, + 2384, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2394, 2395, 0, 0, 0, 2515, 0, 0, 0, 0, + 0, 2405, 2406, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2409, 0, 0, 0, 0, 0, 0, 0, + 0, 2411, 0, 2412, 0, 2522, 0, 646, 647, 1527, + 0, 1737, 1738, 1739, 0, 0, 0, 0, 0, 1533, + 0, 1741, 1742, 1743, 0, 0, 0, 0, 1754, 1755, + 1756, 0, 0, 1757, 1758, 0, 1760, 1761, 0, 1392, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2244, 0, 648, 0, 0, 1833, 1834, 0, 649, + 1836, 1837, 2245, 0, 0, 0, 650, 0, 651, 0, + 0, 0, 0, 652, 0, 0, 653, 0, 0, 2569, + 0, 0, 654, 0, 0, 0, 0, 1080, 2246, 0, + 0, 0, 655, 0, 0, 1081, 0, 0, 656, 0, + 2577, 1082, 0, 0, 0, 0, 657, 0, 0, 0, + 2582, 1611, 0, 0, 0, 0, 2585, 2586, 0, 0, + 1083, 658, 0, 0, 2247, 0, 0, 0, 1619, 2763, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 659, 0, 0, 1084, 0, 0, 0, 0, 0, 0, + 0, 1085, 0, 0, 0, 0, 660, 0, 0, 0, + 0, 1643, 0, 0, 0, 661, 662, 0, 0, 0, + 0, 0, 1650, 0, 2533, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2542, 663, 0, 0, 1086, 0, + 0, 0, 0, 2544, 0, 0, 1087, 0, 0, 1676, + 0, 0, 2553, 0, 1683, 0, 664, 0, 0, 2555, + 0, 0, 0, 0, 0, 67, 68, 0, 0, 665, + 2559, 666, 0, 1614, 0, 0, 2562, 2656, 0, 2564, + 0, 110, 2565, 0, 667, 0, 0, 1088, 0, 668, + 0, 0, 0, 0, 0, 669, 0, 2668, 1089, 0, + 0, 285, 670, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1638, 1090, 0, 0, 0, 0, 112, 0, + 671, 0, 0, 2248, 0, 2249, 0, 1648, 0, 0, + 0, 0, 0, 672, 673, 0, 674, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 113, 0, 0, 0, 2717, 0, 2718, + 0, 2720, 0, 2722, 0, 2723, 675, 2725, 0, 2250, + 0, 0, 0, 0, 0, 0, 0, 1840, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 2645, 0, + 0, 0, 2647, 0, 0, 1860, 115, 0, 0, 2648, + 0, 0, 0, 0, 0, 2651, 2750, 0, 0, 2653, + 0, 0, 2654, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1893, 0, 0, 1895, 0, 0, 0, + 0, 0, 0, 286, 0, 1911, 1913, 0, 0, 0, + 0, 2083, 0, 1917, 0, 0, 0, 0, 0, 0, + 1919, 2780, 0, 120, 2091, 0, 0, 0, 121, 0, + 0, 0, 0, 0, 2094, 0, 0, 0, 287, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1959, 0, 0, 1962, 1963, 0, 0, 0, 0, 0, + 0, 0, 0, 1971, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 288, 0, 0, + 0, 0, 0, 0, 0, 0, 2179, 0, 1908, 0, + 0, 0, 0, 0, 0, 0, 124, 125, 126, 127, + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, + 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, + 148, 149, 150, 151, 2000, 0, 0, 109, 0, 0, + 0, 2004, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 110, 0, 0, 0, 0, 0, 1960, 2020, + 0, 0, 0, 0, 1966, 0, 0, 0, 0, 0, + 0, 0, 0, 111, 0, 2029, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, + 0, 0, 0, 0, 2036, 0, 0, 0, 0, 2041, + 0, 0, 2043, 2044, 2045, 2046, 2048, 0, 2050, 0, + 0, 2051, 0, 0, 2052, 2054, 2055, 2056, 2057, 2059, + 0, 2060, 2061, 0, 0, 0, 2063, 2064, 2065, 0, + 2066, 2067, 0, 0, 113, 0, 2068, 2069, 0, 0, + 0, 2070, 0, 0, 2002, 0, 2075, 0, 0, 0, + 2007, 114, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2022, 0, 0, 0, 0, 0, + 0, 2028, 0, 0, 0, 0, 0, 115, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2042, 0, 0, + 0, 0, 0, 0, 2049, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 116, 0, 0, 0, 0, 0, + 0, 0, 117, 0, 0, 0, 0, 0, 118, 119, + 0, 0, 0, 0, 120, 0, 0, 0, 0, 121, + 0, 0, 0, 2353, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2182, 0, 0, 2185, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2190, 0, 0, 2194, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2385, 2386, 2387, 2388, 2389, 0, 2391, + 2392, 0, 0, 0, 2396, 2397, 2398, 2399, 2400, 0, + 2402, 2403, 2214, 0, 0, 0, 0, 0, 0, 0, + 0, 122, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 123, 124, 125, 126, + 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, + 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, + 147, 148, 149, 150, 151, 67, 68, 0, 0, 0, + 152, 2181, 2268, 0, 153, 154, 0, 0, 0, 0, + 0, 110, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2196, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 112, 0, + 0, 0, 0, 0, 2219, 0, 2221, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2226, 0, 2228, 2305, 0, 0, 2230, 0, + 2232, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2335, 0, 0, 0, + 2276, 0, 0, 2280, 2281, 0, 0, 0, 0, 0, + 0, 0, 2285, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2532, 115, 0, 2534, 2535, + 2536, 2537, 2538, 0, 2540, 2541, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2292, 2545, 2546, 2547, 2548, + 2549, 0, 2551, 2552, 0, 2554, 67, 68, 0, 0, + 0, 2304, 0, 0, 0, 2557, 2558, 0, 0, 0, + 0, 0, 110, 0, 0, 0, 2561, 0, 0, 0, + 0, 0, 2318, 120, 0, 0, 0, 2322, 121, 0, + 0, 0, 0, 2327, 0, 0, 0, 0, 2331, 0, + 0, 0, 2334, 0, 0, 2337, 0, 0, 2340, 0, + 2342, 0, 0, 527, 0, 0, 2347, 0, 2419, 0, + 0, 2423, 0, 0, 0, 0, 0, 0, 110, 0, + 0, 2427, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2440, 0, 0, + 2444, 0, 0, 0, 113, 0, 0, 2450, 0, 0, + 0, 0, 2456, 2457, 0, 112, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 124, 125, 126, 127, + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, + 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, + 148, 149, 150, 151, 0, 0, 0, 115, 0, 0, + 113, 0, 0, 2646, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2649, 0, 2650, 0, 0, 0, + 2652, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2519, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 115, 0, 0, 0, 0, 0, 121, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2528, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 891, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 110, 0, 0, 2493, + 0, 0, 0, 0, 0, 0, 2712, 0, 0, 2713, + 120, 0, 2714, 0, 2715, 121, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2567, 0, 0, 0, 0, 124, 125, 126, + 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, + 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, + 147, 148, 149, 150, 151, 0, 0, 0, 113, 0, + 0, 0, 0, 2587, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2599, 0, 0, 0, 0, + 0, 0, 0, 124, 125, 126, 127, 128, 129, 130, + 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, + 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, + 151, 115, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2640, 0, 0, 2566, 0, 0, + 0, 0, 0, 2643, 2571, 0, 0, 0, 2573, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2579, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 121, 2657, 2659, 0, 2661, 0, 0, + 0, 0, 2663, 2665, 0, 0, 0, 2667, 124, 125, + 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, + 146, 147, 148, 149, 150, 151, 0, 0, 0, 0, + 0, 2689, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2709, 0, 0, 0, 0, 2710, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 124, 125, 126, 127, 128, 129, 130, 131, 132, + 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2677, 0, 0, 0, 0, 0, 0, 2, 0, 0, + 3, 0, 4, 0, 0, 2752, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, + 6, 7, 2761, 8, 9, 10, 0, 0, 0, 0, + 0, 0, 0, 11, 0, 2770, 0, 0, 2773, 0, + 12, 110, 13, 14, 0, 0, 0, 0, 0, 0, + 0, 15, 16, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, + 2738, 0, 0, 0, 0, 0, 0, 500, 501, 0, + 18, 502, 0, 0, 19, 604, 110, 20, 0, 0, + 2748, 2749, 21, 22, 0, 0, 0, 0, 0, 23, + 0, 0, 0, 503, 0, 0, 24, 0, 0, 0, + 0, 0, 0, 113, 0, 0, 0, 0, 0, 25, + 0, 0, 26, 27, 28, 605, 0, 29, 30, 0, + 0, 0, 0, 2772, 0, 0, 0, 967, 0, 0, + 31, 0, 0, 968, 0, 0, 0, 0, 0, 0, + 0, 2783, 0, 0, 2784, 32, 33, 34, 0, 0, + 0, 0, 0, 0, 0, 0, 115, 0, 113, 35, + 0, 0, 0, 0, 0, 0, 0, 36, 0, 504, + 37, 606, 0, 38, 0, 39, 0, 40, 0, 0, + 0, 0, 41, 0, 0, 0, 505, 0, 0, 0, + 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, + 43, 0, 0, 0, 0, 506, 0, 0, 0, 0, + 0, 115, 0, 0, 0, 0, 44, 45, 121, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 46, 0, + 47, 0, 0, 0, 0, 0, 48, 0, 0, 49, + 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 507, 0, 0, 0, + 51, 0, 0, 121, 0, 0, 52, 124, 125, 126, + 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, + 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, + 147, 148, 149, 150, 151, 0, 124, 125, 126, 127, + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, + 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, + 148, 149, 150, 151, 0, 508, 0, 0, 607, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 124, 125, 126, 127, 128, 129, 130, 131, 132, + 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 989, + 990, 991, 0, 0, 1264, 1265, 1266, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 992, 993, 0, + 0, 994, 1267, 1268, 995, 110, 1269, 0, 0, 0, + 0, 996, 0, 1270, 0, 997, 1271, 0, 0, 0, + 1272, 0, 0, 998, 999, 0, 0, 0, 1273, 1274, + 0, 1000, 1001, 110, 0, 0, 1275, 0, 0, 0, + 0, 0, 112, 0, 0, 0, 0, 0, 1002, 0, + 0, 0, 0, 0, 1003, 0, 0, 1004, 1005, 0, + 0, 1006, 1276, 1277, 0, 0, 1278, 0, 0, 0, + 112, 0, 0, 0, 0, 0, 0, 1007, 0, 0, + 0, 0, 1279, 0, 0, 0, 0, 113, 110, 0, + 0, 0, 0, 0, 0, 0, 1008, 0, 0, 0, + 0, 1280, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 113, 0, 0, 0, 1009, + 0, 0, 0, 0, 1281, 0, 0, 0, 514, 0, + 0, 0, 0, 1282, 0, 0, 0, 0, 0, 0, + 115, 1010, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 115, 1011, + 113, 1012, 0, 0, 1283, 0, 1013, 1014, 0, 0, + 0, 1284, 1285, 0, 0, 0, 0, 0, 0, 0, + 1015, 1016, 0, 0, 0, 0, 1286, 120, 0, 0, + 1017, 1018, 121, 0, 0, 0, 1287, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 115, 0, 120, 1019, 0, 1020, 0, + 121, 1288, 0, 1289, 0, 0, 0, 0, 0, 0, + 1021, 0, 1022, 1290, 0, 0, 0, 0, 1023, 0, + 0, 0, 0, 1291, 0, 0, 0, 0, 518, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1361, + 0, 0, 0, 0, 0, 0, 0, 110, 0, 0, + 0, 0, 1024, 0, 0, 121, 0, 1292, 0, 0, + 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, + 144, 145, 146, 147, 148, 149, 150, 151, 124, 125, + 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, + 146, 147, 148, 149, 150, 151, 0, 0, 0, 0, + 515, 0, 0, 0, 0, 0, 0, 0, 0, 113, + 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, + 0, 0, 0, 124, 125, 126, 127, 128, 129, 130, + 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, + 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, + 151, 1324, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 115, 124, 125, 126, 127, 128, 129, 130, + 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, + 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, + 151, 1362, 0, 0, 0, 0, 113, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 121, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 121, 124, 125, 126, 127, 128, 129, 130, 131, + 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, + 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, + 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, + 145, 146, 147, 148, 149, 150, 151, 179, 0, 0, + 180, 0, 181, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 182, 0, 183, 184, 185, 0, 0, 0, 0, + 0, 0, 0, 186, 0, 187, 0, 0, 0, 0, + 188, 0, 189, 190, 191, 0, 0, 0, 0, 192, + 0, 193, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 194, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 195, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 196, 197, 0, 0, 198, + 0, 0, 0, 199, 0, 0, 200, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 201, 202, 0, + 0, 203, 0, 0, 0, 0, 0, 0, 0, 0, + 204, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 205, 206, 0, 0, 0, + 0, 0, 0, 207, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 208, 0, 209, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 210, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 211, 212, 0, 0, + 0, 0, 0, 0, 0, 213, 0, 0, 0, 0, + 0, 0, 214, 0, 0, 0, 0, 0, 215, 0, + 216, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 217 +}; + +static const yytype_int16 yycheck[] = +{ + 4, 50, 1445, 872, 873, 874, 0, 1645, 12, 1647, + 661, 662, 4, 1136, 666, 1138, 4, 2528, 5, 4, + 3, 4, 5, 5, 4, 32, 32, 3, 4, 33, + 5, 17, 5, 5, 5, 46, 40, 61, 3, 4, + 50, 1164, 1165, 1166, 5, 49, 3, 4, 52, 4, + 3, 4, 20, 66, 58, 97, 56, 4, 62, 17, + 36, 65, 3, 4, 933, 69, 70, 26, 166, 73, + 37, 36, 76, 77, 66, 40, 80, 4, 3, 4, + 84, 3, 4, 3, 4, 89, 34, 3, 4, 99, + 27, 3, 4, 3, 4, 36, 5, 990, 102, 163, + 104, 105, 106, 107, 961, 103, 45, 964, 105, 4, + 5, 48, 99, 64, 51, 66, 166, 443, 105, 123, + 59, 130, 220, 133, 981, 62, 118, 3, 4, 21, + 456, 17, 33, 208, 2695, 66, 3, 4, 17, 66, + 154, 16, 81, 3, 4, 110, 27, 56, 85, 4, + 40, 87, 111, 129, 158, 190, 65, 147, 61, 107, + 5, 100, 78, 122, 129, 102, 237, 180, 182, 87, + 220, 66, 3, 4, 3, 4, 164, 116, 182, 2740, + 119, 3, 4, 187, 255, 283, 31, 185, 129, 4, + 5, 118, 277, 88, 258, 192, 33, 156, 156, 141, + 21, 14, 27, 225, 143, 144, 88, 199, 243, 121, + 20, 211, 254, 205, 206, 116, 21, 16, 154, 98, + 110, 207, 297, 118, 21, 275, 191, 21, 185, 180, + 59, 240, 185, 190, 201, 190, 154, 2748, 2749, 3, + 4, 136, 246, 202, 241, 27, 295, 57, 61, 5, + 222, 275, 200, 264, 170, 21, 215, 196, 262, 263, + 912, 229, 252, 185, 239, 204, 191, 274, 274, 226, + 241, 284, 199, 277, 298, 66, 40, 287, 205, 206, + 4, 285, 286, 277, 288, 289, 187, 291, 189, 262, + 191, 192, 239, 250, 279, 59, 288, 301, 199, 279, + 286, 191, 211, 118, 199, 309, 310, 294, 4, 285, + 205, 206, 15, 214, 297, 297, 304, 278, 193, 22, + 285, 207, 261, 262, 27, 3, 4, 243, 332, 333, + 334, 34, 336, 284, 4, 190, 340, 341, 295, 220, + 165, 233, 295, 203, 285, 337, 110, 351, 352, 341, + 342, 355, 356, 357, 358, 359, 360, 361, 362, 363, + 285, 288, 1014, 367, 4, 285, 692, 257, 372, 373, + 1239, 74, 275, 295, 187, 285, 380, 1246, 56, 383, + 1032, 338, 339, 165, 199, 338, 339, 288, 243, 220, + 205, 206, 37, 288, 333, 298, 400, 401, 220, 294, + 286, 5, 47, 407, 408, 409, 343, 411, 233, 285, + 337, 221, 233, 1064, 341, 342, 338, 339, 285, 3, + 4, 425, 118, 4, 234, 429, 66, 191, 233, 74, + 434, 435, 436, 437, 438, 439, 233, 441, 27, 233, + 444, 445, 337, 256, 1095, 340, 341, 342, 118, 1572, + 275, 233, 265, 457, 14, 15, 12, 78, 37, 27, + 163, 164, 165, 166, 167, 168, 169, 233, 47, 172, + 173, 174, 175, 288, 13, 56, 27, 220, 118, 294, + 83, 40, 3, 4, 297, 295, 4, 4, 83, 304, + 61, 4, 225, 275, 0, 74, 99, 53, 6, 93, + 105, 61, 147, 199, 99, 5, 40, 511, 512, 205, + 206, 837, 116, 30, 1407, 71, 110, 281, 30, 40, + 22, 1378, 337, 261, 1381, 529, 341, 342, 63, 199, + 5, 63, 275, 211, 135, 205, 206, 586, 56, 184, + 1433, 442, 3, 4, 100, 5, 48, 49, 119, 170, + 876, 110, 556, 40, 14, 15, 61, 260, 261, 199, + 62, 117, 1455, 4, 120, 205, 206, 4, 147, 104, + 173, 61, 104, 174, 131, 131, 110, 626, 4, 583, + 54, 226, 94, 279, 287, 189, 12, 192, 66, 110, + 122, 185, 288, 14, 15, 5, 645, 5, 166, 4, + 5, 61, 247, 40, 61, 184, 108, 109, 44, 122, + 213, 119, 31, 617, 119, 166, 90, 5, 288, 203, + 3, 4, 243, 110, 327, 328, 329, 187, 188, 119, + 211, 220, 191, 1285, 535, 239, 241, 282, 5, 643, + 61, 337, 159, 246, 1296, 341, 342, 186, 288, 161, + 128, 87, 220, 298, 191, 60, 660, 191, 262, 663, + 121, 66, 119, 137, 154, 2303, 567, 337, 247, 220, + 191, 341, 342, 110, 152, 61, 233, 681, 682, 683, + 684, 63, 61, 687, 167, 689, 4, 691, 201, 693, + 66, 208, 175, 211, 265, 230, 256, 337, 230, 220, + 116, 341, 342, 117, 191, 265, 266, 6, 113, 244, + 245, 277, 244, 245, 5, 5, 233, 252, 220, 298, + 222, 770, 104, 128, 14, 15, 17, 187, 188, 285, + 33, 243, 167, 119, 239, 140, 248, 297, 121, 5, + 119, 146, 147, 3, 4, 24, 25, 152, 14, 15, + 228, 5, 12, 189, 191, 759, 760, 761, 762, 763, + 265, 765, 766, 767, 768, 239, 187, 188, 61, 61, + 257, 61, 14, 15, 26, 265, 780, 781, 89, 1648, + 784, 785, 786, 787, 788, 789, 790, 791, 792, 88, + 1116, 61, 796, 797, 16, 61, 256, 299, 203, 277, + 335, 336, 239, 335, 336, 265, 266, 82, 265, 66, + 270, 815, 816, 817, 14, 15, 88, 222, 97, 61, + 119, 226, 226, 228, 61, 40, 119, 119, 832, 833, + 834, 61, 836, 276, 838, 256, 840, 297, 61, 22, + 3, 4, 30, 115, 265, 266, 251, 252, 230, 119, + 89, 66, 72, 857, 259, 859, 1979, 1980, 1981, 111, + 31, 61, 244, 245, 5, 869, 49, 3, 4, 52, + 122, 255, 277, 877, 149, 255, 297, 261, 882, 265, + 82, 261, 119, 4, 99, 5, 265, 4, 5, 119, + 105, 4, 1749, 897, 898, 110, 119, 187, 188, 82, + 5, 905, 4, 907, 908, 5, 70, 5, 611, 5, + 914, 183, 1769, 128, 4, 919, 0, 1243, 967, 3, + 4, 187, 188, 59, 928, 197, 109, 1784, 333, 112, + 1787, 22, 147, 3, 4, 4, 3, 4, 1795, 943, + 5, 1798, 4, 218, 219, 187, 188, 149, 163, 1806, + 202, 4, 1809, 335, 336, 1848, 857, 232, 49, 1816, + 5, 52, 665, 215, 55, 4, 256, 670, 4, 5, + 1863, 159, 265, 265, 97, 265, 266, 192, 3, 4, + 270, 253, 3, 4, 3, 4, 990, 187, 188, 59, + 256, 82, 17, 12, 119, 265, 271, 2593, 1891, 265, + 266, 4, 5, 167, 270, 147, 1010, 297, 3, 4, + 5, 66, 5, 228, 256, 2611, 218, 219, 109, 40, + 208, 112, 294, 265, 266, 80, 241, 1031, 265, 2472, + 232, 297, 304, 4, 89, 265, 1040, 252, 262, 222, + 14, 15, 265, 4, 99, 233, 14, 15, 3, 4, + 1054, 4, 1056, 4, 5, 297, 256, 1061, 1062, 1063, + 4, 5, 82, 4, 279, 265, 266, 1071, 251, 271, + 1074, 213, 1076, 128, 238, 22, 291, 4, 293, 294, + 27, 200, 5, 247, 3, 4, 5, 61, 1092, 110, + 1094, 1960, 147, 61, 1098, 1099, 4, 297, 3, 4, + 5, 48, 49, 4, 51, 52, 431, 432, 1112, 1113, + 252, 4, 1013, 1117, 1118, 62, 819, 185, 333, 1123, + 2470, 1125, 190, 4, 1128, 4, 1130, 74, 75, 149, + 5, 222, 1181, 2729, 5, 82, 9, 192, 85, 2735, + 14, 15, 1468, 28, 11, 5, 2496, 261, 290, 167, + 42, 43, 3, 4, 5, 102, 7, 8, 226, 2028, + 251, 108, 109, 4, 4, 112, 1170, 1171, 1172, 1173, + 191, 1175, 1176, 228, 1075, 1179, 190, 175, 167, 4, + 2049, 193, 250, 5, 193, 5, 277, 61, 5, 2785, + 1194, 2787, 14, 15, 4, 221, 193, 252, 218, 219, + 66, 1205, 66, 1207, 1208, 1209, 1210, 66, 1534, 220, + 1214, 1215, 232, 187, 188, 28, 5, 336, 1222, 187, + 188, 5, 341, 170, 343, 1229, 4, 295, 193, 1233, + 1234, 1235, 4, 4, 87, 5, 291, 87, 293, 61, + 1244, 2591, 2592, 1247, 5, 2595, 4, 2597, 4, 17, + 5, 271, 2109, 5, 1258, 4, 99, 1261, 5, 2609, + 2610, 2118, 4, 148, 2614, 2615, 5, 17, 2618, 17, + 2127, 339, 4, 2623, 2624, 222, 168, 169, 3, 4, + 227, 4, 256, 4, 87, 61, 171, 5, 256, 97, + 175, 265, 266, 1194, 5, 242, 4, 265, 266, 1303, + 5, 5, 1306, 195, 251, 1309, 1310, 87, 1312, 5, + 1314, 4, 4, 187, 188, 40, 1320, 5, 1322, 2669, + 5, 5, 2672, 297, 5, 1329, 53, 2677, 5, 297, + 4, 278, 279, 2683, 1037, 148, 4, 12, 2688, 224, + 116, 3, 4, 119, 71, 7, 8, 2240, 5, 1250, + 3, 4, 299, 12, 4, 3, 4, 5, 171, 7, + 8, 88, 175, 2256, 1265, 187, 188, 4, 2261, 4, + 4, 4, 164, 100, 5, 260, 5, 5, 154, 4, + 4, 4, 256, 268, 269, 110, 5, 40, 1091, 251, + 117, 265, 266, 120, 20, 251, 343, 279, 1101, 5, + 1404, 1405, 1406, 1407, 131, 4, 2756, 2276, 5, 2759, + 5, 224, 5, 189, 5, 5, 2285, 14, 15, 4, + 4, 263, 1426, 297, 5, 5, 1430, 2777, 263, 1433, + 2780, 5, 35, 5, 256, 5, 4, 4, 4, 2789, + 2790, 5, 5, 265, 266, 172, 5, 260, 270, 1453, + 1454, 1455, 5, 5, 5, 268, 269, 110, 4, 1463, + 236, 5, 1466, 239, 61, 2334, 5, 4, 2337, 1473, + 5, 2340, 5, 2342, 233, 297, 3, 4, 5, 233, + 7, 8, 233, 1487, 105, 5, 262, 233, 1492, 265, + 135, 105, 1496, 40, 1498, 1499, 6, 1501, 1502, 1503, + 276, 1505, 1403, 106, 1508, 1509, 1510, 1511, 1512, 1513, + 1514, 1515, 1516, 1517, 1518, 1218, 1219, 1521, 1522, 1523, + 1524, 233, 125, 126, 127, 5, 233, 1531, 1532, 132, + 105, 207, 1536, 1537, 1538, 237, 2464, 1541, 1542, 2467, + 40, 2469, 145, 237, 207, 5, 4, 207, 151, 1553, + 1554, 5, 1556, 1557, 2482, 2483, 3, 4, 1459, 162, + 5, 1462, 9, 10, 11, 207, 4, 2460, 1894, 4, + 1471, 2499, 5, 91, 5, 2468, 5, 5, 1479, 110, + 110, 99, 1908, 1909, 4, 1486, 1912, 105, 2481, 5, + 187, 188, 1918, 2486, 1920, 5, 5, 4, 12, 5, + 5, 4, 4, 1607, 1608, 5, 124, 5, 1612, 5, + 5, 4, 6, 1617, 1618, 5, 1620, 1621, 1622, 5, + 1624, 1625, 4, 1627, 12, 5, 1630, 1631, 19, 147, + 4, 4, 4, 4, 4, 1639, 5, 155, 4, 38, + 1966, 38, 1646, 0, 5, 233, 233, 233, 1652, 1653, + 233, 135, 166, 44, 233, 233, 1660, 4, 203, 256, + 4, 193, 1666, 4, 241, 4, 4, 4, 265, 266, + 273, 5, 5, 270, 192, 5, 5, 5, 5, 4, + 4, 2007, 200, 5, 4, 4, 77, 263, 4, 960, + 5, 5, 5, 84, 301, 1699, 1399, 233, 4, 233, + 297, 301, 4, 94, 95, 233, 4, 4, 4, 4, + 101, 4, 301, 4, 220, 5, 1617, 220, 220, 301, + 5, 1725, 1726, 241, 220, 1428, 1730, 220, 5, 1432, + 5, 122, 1736, 5, 252, 4, 6, 5, 5, 4, + 4, 4, 263, 5, 5, 4, 4, 138, 5, 267, + 5, 4, 263, 5, 5, 1458, 4, 0, 5, 4, + 4, 277, 153, 4, 4, 4, 1469, 5, 5, 5, + 161, 5, 5, 5, 1477, 1478, 5, 5, 5, 4, + 1681, 5, 5, 5, 4, 1488, 4, 263, 5, 1690, + 181, 4, 4, 1694, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, + 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, + 330, 331, 5, 5, 5, 216, 4, 12, 5, 5, + 5, 5, 4, 2726, 4, 344, 5, 5, 5, 1843, + 1844, 5, 1846, 4, 1848, 4, 344, 5, 5, 344, + 5, 5, 4, 4, 344, 5, 5, 5, 5, 1863, + 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 4, + 4, 344, 5, 264, 4, 4, 4, 33, 4, 344, + 5, 5, 5, 1887, 275, 1889, 5, 1891, 5, 4, + 4, 4, 1896, 2219, 2220, 2221, 5, 4, 2224, 5, + 2226, 2227, 5, 1907, 2230, 4, 2232, 4, 4, 4, + 1914, 5, 5, 304, 4, 4, 297, 5, 5, 5, + 5, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, + 1934, 5, 5, 1937, 1938, 1939, 1940, 1941, 1942, 1943, + 1944, 1945, 1946, 1947, 1948, 5, 1950, 5, 1952, 1953, + 1954, 5, 4, 430, 5, 1856, 4, 4, 1859, 5, + 116, 5, 5, 4, 1968, 4, 2292, 5, 5, 5, + 5, 4, 4, 277, 5, 2627, 29, 5, 5, 5, + 4, 4, 344, 5, 4, 4, 4, 4, 4, 4, + 4, 44, 4, 46, 1998, 4, 4, 2001, 4, 2003, + 4, 2005, 4, 4, 2008, 4, 2010, 4, 344, 5, + 5, 4, 4, 2017, 2018, 5, 5, 5, 4, 4, + 2024, 5, 2026, 76, 5, 5, 2030, 4, 4, 2033, + 186, 84, 188, 189, 4, 191, 192, 4, 4, 4, + 4, 4, 387, 5, 4, 2697, 5, 5, 5, 4, + 6, 5, 5, 5, 5, 4, 6, 5, 5, 4, + 4, 344, 5, 219, 4, 4, 4, 2251, 5, 5, + 4, 4, 4, 4, 4, 1346, 5, 5, 2082, 5, + 236, 237, 4, 4, 4, 4, 139, 1358, 5, 2625, + 5, 5, 5, 5, 4, 4, 2697, 2693, -1, 726, + 16, -1, -1, -1, -1, 1376, 1377, 23, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2446, -1, -1, -1, -1, -1, -1, -1, 2454, -1, + -1, 2180, 288, 2034, -1, -1, 189, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 306, -1, 205, 206, 1857, -1, -1, -1, -1, 212, + -1, 214, -1, -1, -1, -1, -1, 2493, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 2079, -1, + -1, -1, 2186, -1, -1, -1, 239, -1, -1, 1892, + -1, -1, -1, -1, -1, 2199, 2200, 2201, 2202, 2203, + 2204, 2205, 2206, 2207, 2208, 2209, -1, -1, -1, -1, + -1, 2215, -1, -1, -1, -1, -1, -1, 2222, -1, + -1, 2225, -1, -1, -1, -1, -1, 2231, -1, -1, + 2234, 2235, 2236, 2237, 2238, 2239, 2240, 2241, 2242, 2243, + -1, 290, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 304, 2256, 2257, 2258, 2259, 2260, 2261, 2262, 2263, + 2264, 2265, 2266, 2267, -1, 2269, 422, 2271, 2272, 2273, + -1, -1, -1, -1, -1, -1, -1, 433, -1, -1, + -1, -1, -1, 2184, -1, 2289, 442, -1, -1, 2293, + -1, -1, -1, 2297, -1, -1, -1, 2301, 347, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 2213, -1, -1, -1, -1, -1, -1, 235, + -1, 237, 2223, -1, -1, -1, -1, -1, 2229, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 2351, -1, -1, + -1, -1, -1, -1, -1, 511, -1, -1, 514, 515, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 527, -1, -1, -1, -1, 532, -1, -1, -1, + -1, -1, -1, -1, -1, 541, 542, -1, 304, 305, + 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, + 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, + 326, 327, 328, 329, 330, 331, -1, -1, -1, -1, + 2424, -1, -1, -1, 2428, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 2438, 2439, -1, -1, -1, -1, + -1, 2445, -1, -1, -1, -1, -1, -1, 2452, 605, + 606, 607, -1, -1, -1, -1, 2460, -1, 2462, -1, + 509, 2465, 2466, -1, 2468, -1, -1, 516, -1, -1, + 519, -1, -1, -1, -1, 524, -1, 2481, -1, 528, + 2484, 2485, 2486, 2487, 2488, 2489, 2490, 2491, 1759, -1, + 2494, -1, -1, -1, 2498, -1, 1767, 1768, -1, -1, + -1, -1, -1, -1, -1, 2509, -1, -1, 664, -1, + 2514, 1782, 1783, -1, -1, -1, -1, 2418, -1, -1, + -1, -1, 1793, 1794, -1, -1, -1, 2531, -1, 948, + -1, -1, -1, 1804, 1805, -1, -1, -1, -1, 588, + -1, -1, -1, 1814, 1815, -1, -1, -1, -1, 1820, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 1830, + -1, 980, 2566, -1, -1, -1, -1, -1, 2572, -1, + 2574, -1, -1, -1, 2277, -1, 2580, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 2593, + 2594, -1, -1, -1, -1, -1, -1, -1, -1, 2029, + -1, -1, -1, -1, -1, -1, 2655, 2611, 2612, -1, + -1, -1, 2616, 2043, 2044, 2045, -1, -1, 2048, -1, + 2050, 2051, -1, -1, 2054, 2055, 2056, -1, -1, 2059, + 2060, 2635, -1, 2063, -1, 2065, 2066, -1, 2068, 688, + -1, -1, -1, -1, -1, -1, 695, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 2660, -1, -1, -1, + -1, -1, 2666, -1, 2668, -1, -1, 823, -1, 2570, + -1, 2675, -1, -1, -1, -1, 2680, 2578, -1, 835, + -1, 2685, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 2708, -1, -1, -1, -1, -1, + -1, 867, 868, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 2726, -1, -1, 2729, 2730, -1, -1, 2733, + -1, 2735, 2736, -1, -1, 891, -1, -1, -1, -1, + -1, -1, -1, 2747, -1, -1, -1, -1, -1, -1, + -1, -1, 2182, 2757, -1, 2185, 2760, -1, -1, -1, + 2190, -1, -1, -1, 2194, -1, -1, -1, -1, -1, + -1, -1, -1, 822, -1, -1, -1, 2480, -1, -1, + 829, 2785, 938, 2787, 2214, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 2500, -1, -1, + -1, 2504, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2721, 870, 2093, -1, -1, -1, 875, -1, -1, 878, + -1, -1, 2103, -1, -1, -1, 2107, 2108, -1, -1, + -1, 890, -1, -1, -1, 2116, 2117, -1, -1, -1, + 2751, -1, -1, 2754, 2125, 2126, -1, 1013, -1, -1, + 2131, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2141, 2142, -1, -1, -1, 2305, -1, -1, -1, -1, + -1, 2152, 2153, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 2163, -1, -1, -1, -1, -1, -1, -1, + -1, 2172, -1, 2174, -1, 2335, -1, 4, 5, 1065, + -1, 1330, 1331, 1332, -1, -1, -1, -1, -1, 1075, + -1, 1340, 1341, 1342, -1, -1, -1, -1, 1347, 1348, + 1349, -1, -1, 1352, 1353, -1, 1355, 1356, -1, 988, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 55, -1, 60, -1, -1, 1385, 1386, -1, 66, + 1389, 1390, 66, -1, -1, -1, 73, -1, 75, -1, + -1, -1, -1, 80, -1, -1, 83, -1, -1, 2419, + -1, -1, 89, -1, -1, -1, -1, 91, 92, -1, + -1, -1, 99, -1, -1, 99, -1, -1, 105, -1, + 2440, 105, -1, -1, -1, -1, 113, -1, -1, -1, + 2450, 1177, -1, -1, -1, -1, 2456, 2457, -1, -1, + 124, 128, -1, -1, 128, -1, -1, -1, 1194, 2742, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 147, -1, -1, 147, -1, -1, -1, -1, -1, -1, + -1, 155, -1, -1, -1, -1, 163, -1, -1, -1, + -1, 1227, -1, -1, -1, 172, 173, -1, -1, -1, + -1, -1, 1238, -1, 2355, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 2365, 192, -1, -1, 192, -1, + -1, -1, -1, 2374, -1, -1, 200, -1, -1, 1265, + -1, -1, 2383, -1, 1270, -1, 213, -1, -1, 2390, + -1, -1, -1, -1, -1, 3, 4, -1, -1, 226, + 2401, 228, -1, 1182, -1, -1, 2407, 2567, -1, 2410, + -1, 19, 2413, -1, 241, -1, -1, 241, -1, 246, + -1, -1, -1, -1, -1, 252, -1, 2587, 252, -1, + -1, 39, 259, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 1221, 267, -1, -1, -1, -1, 56, -1, + 277, -1, -1, 277, -1, 279, -1, 1236, -1, -1, + -1, -1, -1, 290, 291, -1, 293, -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, 101, -1, -1, -1, 2657, -1, 2659, + -1, 2661, -1, 2663, -1, 2665, 333, 2667, -1, 333, + -1, -1, -1, -1, -1, -1, -1, 1403, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 2539, -1, + -1, -1, 2543, -1, -1, 1431, 154, -1, -1, 2550, + -1, -1, -1, -1, -1, 2556, 2716, -1, -1, 2560, + -1, -1, 2563, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 1459, -1, -1, 1462, -1, -1, -1, + -1, -1, -1, 191, -1, 1471, 1472, -1, -1, -1, + -1, 1740, -1, 1479, -1, -1, -1, -1, -1, -1, + 1486, 2761, -1, 211, 1753, -1, -1, -1, 216, -1, + -1, -1, -1, -1, 1763, -1, -1, -1, 226, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1526, -1, -1, 1529, 1530, -1, -1, -1, -1, -1, + -1, -1, -1, 1539, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 285, -1, -1, + -1, -1, -1, -1, -1, -1, 1835, -1, 1467, -1, + -1, -1, -1, -1, -1, -1, 304, 305, 306, 307, + 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, + 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, + 328, 329, 330, 331, 1610, -1, -1, 4, -1, -1, + -1, 1617, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 19, -1, -1, -1, -1, -1, 1527, 1635, + -1, -1, -1, -1, 1533, -1, -1, -1, -1, -1, + -1, -1, -1, 40, -1, 1651, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 56, + -1, -1, -1, -1, 1670, -1, -1, -1, -1, 1675, + -1, -1, 1678, 1679, 1680, 1681, 1682, -1, 1684, -1, + -1, 1687, -1, -1, 1690, 1691, 1692, 1693, 1694, 1695, + -1, 1697, 1698, -1, -1, -1, 1702, 1703, 1704, -1, + 1706, 1707, -1, -1, 101, -1, 1712, 1713, -1, -1, + -1, 1717, -1, -1, 1613, -1, 1722, -1, -1, -1, + 1619, 118, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 1643, -1, -1, -1, -1, -1, + -1, 1650, -1, -1, -1, -1, -1, 154, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 1676, -1, -1, + -1, -1, -1, -1, 1683, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 191, -1, -1, -1, -1, -1, + -1, -1, 199, -1, -1, -1, -1, -1, 205, 206, + -1, -1, -1, -1, 211, -1, -1, -1, -1, 216, + -1, -1, -1, 2092, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 1842, -1, -1, 1845, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1856, -1, -1, 1859, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 2132, 2133, 2134, 2135, 2136, -1, 2138, + 2139, -1, -1, -1, 2143, 2144, 2145, 2146, 2147, -1, + 2149, 2150, 1888, -1, -1, -1, -1, -1, -1, -1, + -1, 288, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, + 327, 328, 329, 330, 331, 3, 4, -1, -1, -1, + 337, 1840, 1948, -1, 341, 342, -1, -1, -1, -1, + -1, 19, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 1860, -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, 56, -1, + -1, -1, -1, -1, 1893, -1, 1895, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 1911, -1, 1913, 2021, -1, -1, 1917, -1, + 1919, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 101, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 2062, -1, -1, -1, + 1959, -1, -1, 1962, 1963, -1, -1, -1, -1, -1, + -1, -1, 1971, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 2354, 154, -1, 2357, 2358, + 2359, 2360, 2361, -1, 2363, 2364, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 2004, 2375, 2376, 2377, 2378, + 2379, -1, 2381, 2382, -1, 2384, 3, 4, -1, -1, + -1, 2020, -1, -1, -1, 2394, 2395, -1, -1, -1, + -1, -1, 19, -1, -1, -1, 2405, -1, -1, -1, + -1, -1, 2041, 211, -1, -1, -1, 2046, 216, -1, + -1, -1, -1, 2052, -1, -1, -1, -1, 2057, -1, + -1, -1, 2061, -1, -1, 2064, -1, -1, 2067, -1, + 2069, -1, -1, 4, -1, -1, 2075, -1, 2184, -1, + -1, 2187, -1, -1, -1, -1, -1, -1, 19, -1, + -1, 2197, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 2213, -1, -1, + 2216, -1, -1, -1, 101, -1, -1, 2223, -1, -1, + -1, -1, 2228, 2229, -1, 56, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 304, 305, 306, 307, + 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, + 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, + 328, 329, 330, 331, -1, -1, -1, 154, -1, -1, + 101, -1, -1, 2542, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 2553, -1, 2555, -1, -1, -1, + 2559, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2316, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 154, -1, -1, -1, -1, -1, 216, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 2345, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 4, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 19, -1, -1, 2268, + -1, -1, -1, -1, -1, -1, 2645, -1, -1, 2648, + 211, -1, 2651, -1, 2653, 216, -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, 2418, -1, -1, -1, -1, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, + 327, 328, 329, 330, 331, -1, -1, -1, 101, -1, + -1, -1, -1, 2459, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 2471, -1, -1, -1, -1, + -1, -1, -1, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, + 331, 154, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 2520, -1, -1, 2416, -1, -1, + -1, -1, -1, 2529, 2423, -1, -1, -1, 2427, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 2444, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 216, 2570, 2571, -1, 2573, -1, -1, + -1, -1, 2578, 2579, -1, -1, -1, 2583, 304, 305, + 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, + 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, + 326, 327, 328, 329, 330, 331, -1, -1, -1, -1, + -1, 2617, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2636, -1, -1, -1, -1, 2641, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 324, 325, 326, 327, 328, 329, 330, 331, -1, + -1, -1, -1, -1, -1, -1, 20, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2599, -1, -1, -1, -1, -1, -1, 41, -1, -1, + 44, -1, 46, -1, -1, 2721, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 59, -1, -1, -1, -1, + 64, 65, 2738, 67, 68, 69, -1, -1, -1, -1, + -1, -1, -1, 77, -1, 2751, -1, -1, 2754, -1, + 84, 19, 86, 87, -1, -1, -1, -1, -1, -1, + -1, 95, 96, -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, 123, + 2689, -1, -1, -1, -1, -1, -1, 65, 66, -1, + 134, 69, -1, -1, 138, 18, 19, 141, -1, -1, + 2709, 2710, 146, 147, -1, -1, -1, -1, -1, 153, + -1, -1, -1, 91, -1, -1, 160, -1, -1, -1, + -1, -1, -1, 101, -1, -1, -1, -1, -1, 173, + -1, -1, 176, 177, 178, 58, -1, 181, 182, -1, + -1, -1, -1, 2752, -1, -1, -1, 154, -1, -1, + 194, -1, -1, 160, -1, -1, -1, -1, -1, -1, + -1, 2770, -1, -1, 2773, 209, 210, 211, -1, -1, + -1, -1, -1, -1, -1, -1, 154, -1, 101, 223, + -1, -1, -1, -1, -1, -1, -1, 231, -1, 167, + 234, 114, -1, 237, -1, 239, -1, 241, -1, -1, + -1, -1, 246, -1, -1, -1, 184, -1, -1, -1, + -1, -1, -1, -1, -1, 259, -1, -1, -1, -1, + 264, -1, -1, -1, -1, 203, -1, -1, -1, -1, + -1, 154, -1, -1, -1, -1, 280, 281, 216, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 292, -1, + 294, -1, -1, -1, -1, -1, 300, -1, -1, 303, + 304, -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, 264, -1, -1, -1, + 334, -1, -1, 216, -1, -1, 340, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, + 327, 328, 329, 330, 331, -1, 304, 305, 306, 307, + 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, + 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, + 328, 329, 330, 331, -1, 333, -1, -1, 281, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 324, 325, 326, 327, 328, 329, 330, 331, 20, + 21, 22, -1, -1, 20, 21, 22, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 48, 49, -1, + -1, 52, 48, 49, 55, 19, 52, -1, -1, -1, + -1, 62, -1, 59, -1, 66, 62, -1, -1, -1, + 66, -1, -1, 74, 75, -1, -1, -1, 74, 75, + -1, 82, 83, 19, -1, -1, 82, -1, -1, -1, + -1, -1, 56, -1, -1, -1, -1, -1, 99, -1, + -1, -1, -1, -1, 105, -1, -1, 108, 109, -1, + -1, 112, 108, 109, -1, -1, 112, -1, -1, -1, + 56, -1, -1, -1, -1, -1, -1, 128, -1, -1, + -1, -1, 128, -1, -1, -1, -1, 101, 19, -1, + -1, -1, -1, -1, -1, -1, 147, -1, -1, -1, + -1, 147, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 101, -1, -1, -1, 170, + -1, -1, -1, -1, 170, -1, -1, -1, 59, -1, + -1, -1, -1, 179, -1, -1, -1, -1, -1, -1, + 154, 192, -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, 154, 220, + 101, 222, -1, -1, 220, -1, 227, 228, -1, -1, + -1, 227, 228, -1, -1, -1, -1, -1, -1, -1, + 241, 242, -1, -1, -1, -1, 242, 211, -1, -1, + 251, 252, 216, -1, -1, -1, 252, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 154, -1, 211, 277, -1, 279, -1, + 216, 277, -1, 279, -1, -1, -1, -1, -1, -1, + 291, -1, 293, 289, -1, -1, -1, -1, 299, -1, + -1, -1, -1, 299, -1, -1, -1, -1, 272, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 160, + -1, -1, -1, -1, -1, -1, -1, 19, -1, -1, + -1, -1, 333, -1, -1, 216, -1, 333, -1, -1, + 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, + 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, + 324, 325, 326, 327, 328, 329, 330, 331, 304, 305, + 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, + 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, + 326, 327, 328, 329, 330, 331, -1, -1, -1, -1, + 281, -1, -1, -1, -1, -1, -1, -1, -1, 101, + -1, -1, -1, -1, 19, -1, -1, -1, -1, -1, + -1, -1, -1, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, + 331, 56, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 154, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, + 331, 332, -1, -1, -1, -1, 101, -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, 216, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, + -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, -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, -1, -1, + -1, 216, 304, 305, 306, 307, 308, 309, 310, 311, + 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, + 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, + -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, -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, -1, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 41, -1, -1, + 44, -1, 46, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 65, -1, 67, 68, 69, -1, -1, -1, -1, + -1, -1, -1, 77, -1, 79, -1, -1, -1, -1, + 84, -1, 86, 87, 88, -1, -1, -1, -1, 93, + -1, 95, -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, 122, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 138, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 149, 150, -1, -1, 153, + -1, -1, -1, 157, -1, -1, 160, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 181, 182, -1, + -1, 185, -1, -1, -1, -1, -1, -1, -1, -1, + 194, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 209, 210, -1, -1, -1, + -1, -1, -1, 217, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 239, -1, 241, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 264, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 280, 281, -1, -1, + -1, -1, -1, -1, -1, 289, -1, -1, -1, -1, + -1, -1, 296, -1, -1, -1, -1, -1, 302, -1, + 304, -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, + -1, -1, -1, -1, -1, -1, 340 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint16 yystos[] = +{ + 0, 20, 41, 44, 46, 59, 64, 65, 67, 68, + 69, 77, 84, 86, 87, 95, 96, 123, 134, 138, + 141, 146, 147, 153, 160, 173, 176, 177, 178, 181, + 182, 194, 209, 210, 211, 223, 231, 234, 237, 239, + 241, 246, 259, 264, 280, 281, 292, 294, 300, 303, + 304, 334, 340, 346, 237, 255, 379, 66, 12, 53, + 71, 100, 117, 120, 131, 285, 381, 3, 4, 285, + 347, 386, 185, 190, 226, 250, 295, 339, 388, 277, + 4, 40, 110, 191, 239, 393, 28, 148, 171, 175, + 224, 260, 268, 269, 360, 395, 83, 99, 173, 213, + 246, 396, 40, 59, 110, 191, 281, 347, 403, 4, + 19, 40, 56, 101, 118, 154, 191, 199, 205, 206, + 211, 216, 288, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, + 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, + 330, 331, 337, 341, 342, 349, 357, 358, 359, 405, + 33, 406, 349, 29, 44, 46, 76, 84, 139, 189, + 205, 206, 212, 214, 239, 304, 348, 141, 407, 41, + 44, 46, 65, 67, 68, 69, 77, 79, 84, 86, + 87, 88, 93, 95, 122, 138, 149, 150, 153, 157, + 160, 181, 182, 185, 194, 209, 210, 217, 239, 241, + 264, 280, 281, 289, 296, 302, 304, 340, 408, 83, + 99, 451, 19, 44, 77, 84, 94, 95, 101, 122, + 138, 153, 161, 181, 216, 264, 275, 304, 454, 349, + 88, 115, 183, 197, 253, 294, 304, 460, 16, 26, + 111, 122, 156, 202, 215, 463, 225, 481, 5, 66, + 88, 136, 294, 340, 349, 482, 5, 483, 20, 57, + 221, 234, 295, 499, 64, 66, 180, 284, 518, 66, + 200, 336, 341, 343, 519, 39, 191, 226, 285, 347, + 357, 359, 520, 5, 294, 304, 349, 523, 70, 167, + 238, 247, 524, 88, 499, 61, 275, 298, 531, 191, + 285, 347, 532, 26, 111, 122, 202, 215, 534, 50, + 99, 133, 287, 549, 550, 4, 37, 47, 74, 147, + 184, 226, 247, 282, 298, 374, 4, 122, 201, 551, + 285, 347, 553, 16, 23, 235, 237, 358, 554, 225, + 558, 285, 347, 559, 0, 22, 48, 49, 62, 108, + 109, 220, 222, 299, 380, 5, 59, 347, 382, 261, + 5, 4, 285, 347, 383, 5, 32, 274, 384, 121, + 347, 385, 121, 347, 387, 347, 4, 190, 243, 391, + 185, 295, 338, 339, 347, 390, 349, 135, 174, 389, + 347, 78, 170, 243, 347, 392, 5, 347, 4, 239, + 394, 347, 347, 5, 222, 397, 31, 398, 5, 399, + 5, 401, 5, 31, 402, 347, 9, 10, 11, 347, + 353, 354, 355, 356, 347, 347, 40, 110, 191, 347, + 404, 347, 191, 357, 359, 347, 35, 106, 125, 126, + 127, 132, 145, 151, 162, 273, 362, 347, 4, 349, + 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, + 116, 66, 53, 71, 88, 100, 117, 120, 131, 172, + 409, 117, 411, 185, 190, 226, 250, 295, 338, 339, + 347, 412, 413, 277, 416, 167, 417, 167, 175, 419, + 65, 66, 69, 91, 167, 184, 203, 264, 333, 357, + 421, 347, 359, 424, 59, 281, 357, 425, 272, 357, + 359, 426, 33, 427, 357, 359, 428, 4, 357, 359, + 429, 45, 59, 81, 100, 116, 119, 143, 144, 196, + 204, 261, 262, 333, 433, 208, 297, 439, 5, 89, + 6, 88, 119, 431, 5, 65, 359, 430, 16, 499, + 66, 180, 284, 440, 66, 226, 441, 276, 61, 275, + 298, 442, 131, 233, 443, 37, 47, 74, 147, 184, + 247, 298, 444, 359, 89, 16, 193, 449, 357, 452, + 72, 455, 31, 456, 44, 87, 189, 457, 147, 213, + 252, 290, 458, 357, 18, 58, 114, 281, 357, 459, + 4, 190, 462, 5, 4, 6, 119, 347, 4, 5, + 239, 464, 5, 466, 5, 116, 189, 239, 262, 467, + 93, 110, 185, 480, 5, 478, 5, 262, 479, 4, + 5, 349, 349, 347, 347, 5, 4, 5, 60, 66, + 73, 75, 80, 83, 89, 99, 105, 113, 128, 147, + 163, 172, 173, 192, 213, 226, 228, 241, 246, 252, + 259, 277, 290, 291, 293, 333, 484, 5, 4, 347, + 5, 347, 40, 110, 347, 522, 349, 347, 357, 359, + 521, 347, 362, 347, 4, 358, 54, 90, 137, 239, + 525, 4, 4, 347, 147, 252, 526, 5, 357, 4, + 40, 110, 347, 533, 347, 97, 61, 119, 239, 265, + 535, 119, 548, 61, 116, 119, 154, 189, 236, 239, + 262, 265, 276, 537, 538, 61, 119, 265, 547, 5, + 4, 34, 107, 200, 530, 66, 349, 375, 66, 349, + 376, 66, 349, 377, 13, 186, 529, 347, 347, 40, + 110, 191, 220, 347, 378, 347, 262, 4, 347, 347, + 4, 557, 4, 279, 555, 4, 279, 556, 4, 362, + 121, 347, 560, 347, 347, 347, 347, 347, 347, 347, + 347, 347, 347, 347, 4, 5, 347, 12, 347, 347, + 347, 30, 94, 161, 243, 248, 361, 361, 4, 347, + 347, 4, 4, 4, 347, 347, 347, 347, 4, 4, + 5, 5, 357, 5, 347, 347, 353, 355, 355, 357, + 347, 347, 347, 347, 347, 347, 347, 357, 359, 356, + 347, 347, 356, 347, 5, 261, 103, 185, 410, 190, + 243, 414, 167, 78, 170, 243, 415, 4, 418, 4, + 420, 190, 422, 175, 423, 167, 362, 347, 357, 347, + 357, 357, 362, 362, 362, 357, 362, 347, 357, 4, + 436, 4, 359, 434, 193, 4, 164, 304, 435, 193, + 357, 4, 357, 438, 5, 5, 4, 193, 347, 4, + 5, 60, 66, 113, 128, 140, 146, 147, 152, 203, + 222, 226, 228, 251, 252, 259, 277, 333, 493, 359, + 66, 445, 66, 446, 66, 447, 220, 448, 347, 5, + 221, 450, 358, 362, 5, 357, 357, 357, 4, 349, + 4, 4, 193, 347, 14, 15, 61, 187, 188, 256, + 265, 266, 297, 87, 5, 5, 14, 15, 61, 187, + 188, 256, 265, 266, 270, 297, 87, 154, 160, 358, + 470, 474, 87, 154, 5, 468, 4, 4, 14, 61, + 187, 256, 265, 297, 5, 5, 4, 347, 358, 20, + 21, 22, 48, 49, 52, 55, 62, 66, 74, 75, + 82, 83, 99, 105, 108, 109, 112, 128, 147, 170, + 192, 220, 222, 227, 228, 241, 242, 251, 252, 277, + 279, 291, 293, 299, 333, 66, 80, 89, 99, 128, + 147, 192, 228, 252, 291, 293, 4, 30, 159, 208, + 233, 487, 5, 63, 104, 230, 244, 245, 335, 336, + 492, 99, 485, 17, 40, 110, 191, 491, 4, 5, + 17, 207, 286, 347, 252, 492, 500, 122, 492, 501, + 36, 40, 110, 129, 191, 285, 347, 502, 357, 349, + 91, 99, 105, 124, 147, 155, 192, 200, 241, 252, + 267, 505, 40, 110, 191, 5, 278, 17, 207, 286, + 509, 279, 349, 510, 5, 99, 105, 294, 17, 17, + 4, 347, 347, 347, 347, 347, 362, 347, 347, 356, + 347, 4, 362, 40, 110, 191, 257, 527, 40, 110, + 191, 257, 528, 4, 97, 5, 5, 87, 4, 5, + 5, 87, 5, 538, 61, 119, 154, 265, 542, 61, + 119, 265, 546, 87, 154, 61, 119, 265, 540, 4, + 61, 119, 265, 539, 5, 5, 4, 5, 5, 5, + 347, 347, 347, 347, 347, 347, 4, 347, 552, 347, + 347, 6, 358, 4, 5, 4, 4, 5, 4, 97, + 254, 363, 347, 347, 12, 347, 347, 347, 347, 347, + 347, 347, 347, 347, 5, 12, 347, 347, 12, 4, + 12, 4, 4, 347, 347, 347, 4, 349, 4, 4, + 362, 357, 362, 347, 347, 347, 357, 347, 356, 347, + 347, 5, 5, 347, 359, 347, 357, 357, 347, 362, + 363, 363, 363, 362, 356, 347, 362, 347, 130, 240, + 350, 437, 164, 5, 4, 362, 357, 4, 5, 4, + 4, 347, 432, 347, 20, 21, 22, 48, 49, 52, + 59, 62, 66, 74, 75, 82, 108, 109, 112, 128, + 147, 170, 179, 220, 227, 228, 242, 252, 277, 279, + 289, 299, 333, 66, 128, 152, 228, 277, 30, 159, + 208, 233, 494, 347, 20, 203, 347, 495, 17, 347, + 251, 505, 251, 203, 347, 496, 279, 497, 17, 98, + 347, 347, 5, 363, 56, 357, 4, 5, 461, 347, + 5, 5, 5, 154, 182, 368, 368, 163, 258, 366, + 4, 4, 5, 5, 465, 263, 263, 5, 5, 5, + 17, 156, 367, 367, 366, 4, 4, 366, 5, 5, + 469, 160, 332, 358, 473, 5, 472, 5, 5, 476, + 5, 477, 5, 14, 15, 61, 187, 188, 256, 265, + 266, 270, 297, 4, 4, 5, 5, 368, 366, 4, + 5, 5, 362, 82, 149, 218, 219, 232, 271, 371, + 7, 8, 347, 352, 233, 233, 233, 105, 40, 66, + 99, 105, 110, 128, 147, 163, 192, 228, 241, 252, + 279, 291, 293, 294, 333, 486, 233, 5, 27, 165, + 233, 275, 135, 105, 22, 49, 52, 82, 109, 112, + 222, 251, 22, 49, 52, 55, 82, 109, 112, 222, + 251, 277, 40, 233, 233, 105, 5, 207, 27, 220, + 36, 129, 285, 347, 255, 261, 237, 357, 359, 505, + 40, 220, 275, 237, 207, 5, 5, 241, 27, 220, + 4, 5, 5, 207, 36, 129, 285, 347, 505, 207, + 349, 4, 4, 347, 5, 297, 22, 27, 48, 49, + 51, 52, 62, 74, 75, 82, 85, 102, 108, 109, + 112, 170, 222, 227, 242, 251, 278, 279, 299, 343, + 488, 347, 347, 347, 347, 347, 492, 357, 5, 4, + 5, 347, 347, 357, 359, 347, 349, 347, 347, 492, + 5, 347, 347, 349, 5, 17, 5, 5, 347, 347, + 356, 347, 347, 347, 347, 110, 347, 347, 110, 4, + 42, 43, 168, 169, 195, 373, 373, 61, 119, 265, + 536, 373, 5, 61, 119, 265, 541, 5, 5, 61, + 119, 265, 543, 4, 5, 5, 4, 61, 119, 265, + 545, 61, 119, 265, 544, 5, 5, 4, 5, 5, + 4, 373, 373, 373, 347, 347, 347, 347, 347, 4, + 347, 357, 347, 358, 362, 5, 5, 12, 347, 357, + 359, 347, 12, 347, 347, 347, 59, 347, 6, 4, + 347, 347, 46, 264, 400, 5, 349, 349, 362, 347, + 4, 4, 4, 357, 347, 347, 347, 347, 362, 4, + 357, 363, 356, 347, 4, 363, 347, 38, 38, 4, + 359, 5, 24, 25, 97, 364, 347, 4, 347, 5, + 82, 149, 218, 219, 232, 271, 357, 359, 233, 233, + 233, 21, 233, 357, 233, 27, 165, 233, 275, 135, + 21, 233, 233, 233, 21, 233, 27, 166, 220, 166, + 255, 261, 166, 220, 283, 505, 166, 220, 275, 4, + 241, 27, 166, 220, 505, 203, 347, 82, 149, 218, + 219, 232, 271, 347, 347, 347, 347, 347, 193, 347, + 347, 20, 229, 453, 4, 4, 347, 368, 368, 368, + 4, 368, 368, 368, 14, 15, 61, 187, 188, 256, + 265, 266, 297, 367, 368, 368, 368, 368, 368, 4, + 368, 368, 4, 367, 14, 15, 61, 187, 188, 256, + 265, 266, 297, 5, 471, 5, 475, 5, 5, 14, + 15, 61, 187, 188, 256, 265, 266, 270, 297, 5, + 14, 15, 61, 187, 188, 256, 265, 266, 270, 297, + 5, 14, 15, 61, 187, 188, 256, 265, 266, 270, + 297, 14, 15, 61, 187, 188, 256, 265, 266, 297, + 263, 5, 5, 5, 367, 367, 366, 4, 4, 366, + 5, 4, 4, 368, 368, 4, 368, 368, 5, 349, + 357, 359, 5, 347, 347, 5, 347, 5, 352, 105, + 192, 241, 105, 192, 241, 5, 347, 349, 5, 347, + 357, 349, 5, 352, 233, 233, 21, 233, 21, 233, + 233, 21, 233, 301, 301, 4, 4, 4, 486, 4, + 4, 4, 301, 301, 4, 5, 4, 347, 5, 347, + 5, 352, 349, 357, 359, 357, 359, 347, 27, 48, + 51, 62, 85, 102, 343, 369, 4, 347, 362, 356, + 349, 357, 359, 357, 347, 349, 349, 357, 359, 357, + 359, 347, 349, 347, 5, 347, 220, 220, 347, 347, + 220, 347, 220, 347, 347, 498, 506, 347, 220, 220, + 347, 347, 347, 347, 347, 347, 347, 347, 5, 297, + 347, 489, 347, 347, 220, 347, 347, 347, 347, 357, + 362, 5, 357, 357, 347, 347, 362, 356, 347, 347, + 347, 357, 347, 347, 5, 347, 347, 347, 347, 5, + 5, 4, 373, 5, 5, 4, 4, 4, 5, 5, + 4, 4, 5, 5, 4, 5, 5, 4, 347, 347, + 357, 347, 362, 347, 357, 359, 347, 362, 347, 347, + 347, 347, 347, 5, 347, 4, 6, 347, 347, 4, + 357, 347, 362, 175, 360, 347, 360, 363, 362, 357, + 347, 347, 4, 347, 347, 4, 357, 5, 5, 5, + 5, 357, 362, 357, 357, 357, 357, 359, 357, 362, + 357, 357, 357, 359, 357, 357, 357, 357, 359, 357, + 357, 357, 347, 357, 357, 357, 357, 357, 357, 357, + 357, 5, 5, 5, 5, 357, 347, 347, 4, 347, + 5, 4, 347, 368, 5, 5, 5, 366, 4, 4, + 5, 368, 367, 4, 368, 5, 5, 5, 367, 367, + 366, 4, 4, 5, 14, 15, 61, 187, 188, 256, + 265, 266, 297, 14, 15, 61, 187, 188, 256, 265, + 266, 297, 14, 15, 61, 187, 188, 256, 265, 266, + 297, 263, 5, 5, 5, 367, 367, 366, 4, 4, + 366, 5, 263, 5, 5, 5, 367, 367, 366, 4, + 4, 366, 5, 263, 5, 5, 5, 367, 367, 366, + 4, 4, 366, 5, 5, 5, 5, 367, 367, 366, + 4, 4, 5, 367, 4, 4, 367, 4, 4, 368, + 5, 362, 357, 347, 347, 357, 347, 5, 352, 5, + 357, 359, 349, 5, 357, 359, 362, 5, 352, 347, + 347, 347, 347, 347, 347, 347, 347, 347, 4, 4, + 5, 4, 4, 347, 357, 347, 5, 352, 349, 362, + 356, 362, 347, 347, 356, 356, 362, 356, 362, 347, + 362, 356, 362, 356, 347, 347, 347, 347, 347, 347, + 347, 347, 347, 347, 55, 66, 92, 128, 277, 279, + 333, 503, 504, 505, 516, 517, 347, 347, 347, 347, + 347, 347, 347, 347, 347, 347, 347, 347, 357, 5, + 347, 347, 347, 347, 4, 4, 362, 363, 4, 490, + 362, 362, 356, 347, 4, 362, 373, 373, 373, 347, + 347, 347, 362, 347, 356, 347, 347, 12, 5, 5, + 4, 347, 347, 4, 362, 357, 347, 347, 363, 364, + 347, 5, 347, 359, 5, 5, 5, 5, 362, 364, + 364, 364, 362, 364, 363, 364, 364, 362, 364, 364, + 364, 362, 364, 364, 362, 357, 364, 362, 364, 364, + 362, 364, 362, 5, 5, 5, 5, 362, 4, 359, + 5, 347, 4, 368, 367, 4, 367, 5, 5, 5, + 367, 367, 366, 4, 4, 5, 5, 5, 5, 367, + 367, 366, 4, 4, 5, 5, 5, 5, 367, 367, + 366, 4, 4, 5, 367, 368, 368, 368, 368, 368, + 4, 368, 368, 4, 367, 367, 368, 368, 368, 368, + 368, 4, 368, 368, 4, 367, 367, 4, 4, 367, + 4, 367, 367, 4, 4, 4, 358, 364, 4, 357, + 359, 364, 347, 357, 4, 364, 364, 357, 4, 347, + 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + 357, 359, 364, 347, 357, 4, 356, 356, 356, 347, + 357, 359, 356, 347, 356, 356, 357, 357, 359, 356, + 347, 356, 347, 347, 347, 347, 347, 347, 352, 347, + 347, 347, 344, 344, 344, 344, 344, 344, 344, 504, + 344, 352, 347, 347, 347, 347, 352, 347, 347, 347, + 347, 347, 347, 362, 347, 297, 351, 352, 347, 347, + 363, 349, 4, 4, 363, 347, 356, 347, 59, 347, + 5, 5, 347, 4, 360, 364, 5, 4, 5, 357, + 5, 363, 364, 363, 363, 363, 4, 5, 357, 5, + 5, 347, 368, 367, 368, 368, 368, 368, 368, 4, + 368, 368, 367, 4, 367, 368, 368, 368, 368, 368, + 4, 368, 368, 367, 368, 367, 4, 368, 368, 367, + 4, 368, 367, 4, 367, 367, 362, 357, 359, 364, + 4, 362, 347, 362, 347, 347, 347, 364, 4, 362, + 347, 356, 364, 347, 356, 364, 364, 357, 352, 347, + 4, 370, 370, 347, 347, 370, 352, 370, 506, 357, + 486, 5, 4, 5, 5, 5, 4, 349, 352, 370, + 370, 347, 347, 352, 347, 347, 347, 347, 347, 356, + 347, 5, 506, 347, 370, 349, 507, 508, 5, 349, + 5, 347, 5, 4, 6, 347, 5, 32, 274, 372, + 357, 5, 372, 357, 347, 367, 368, 367, 367, 368, + 368, 367, 368, 367, 367, 347, 364, 357, 359, 357, + 347, 357, 347, 357, 359, 357, 347, 357, 364, 4, + 506, 506, 351, 347, 506, 4, 506, 362, 5, 4, + 4, 506, 506, 351, 347, 4, 506, 506, 347, 357, + 506, 506, 506, 507, 513, 514, 505, 511, 512, 5, + 5, 6, 4, 185, 295, 338, 339, 347, 365, 357, + 357, 4, 368, 368, 368, 368, 358, 364, 364, 347, + 364, 4, 364, 364, 347, 364, 347, 506, 506, 4, + 347, 506, 5, 347, 506, 4, 347, 506, 362, 513, + 515, 516, 344, 512, 5, 5, 4, 347, 362, 362, + 364, 4, 357, 359, 4, 352, 351, 347, 347, 351, + 347, 357, 516, 349, 5, 5, 347, 372, 372, 5, + 357, 359, 362, 357, 359, 506, 347, 4, 506, 347, + 364, 5, 5, 362, 362, 4, 506, 4, 506, 351, + 351, 506, 506 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (fr, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, fr, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, frFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + frFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (fr); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, frFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + frFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Base* fr, frFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, fr, ll) + YYSTYPE *yyvsp; + int yyrule; + Base* fr; + frFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , fr, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, fr, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Base* fr, frFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, fr, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + Base* fr; + frFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (fr); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (Base* fr, frFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (Base* fr, frFlexLexer* ll) +#else +int +yyparse (fr, ll) + Base* fr; + frFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 5: +#line 448 "frame/parser.Y" + {fr->bgColorCmd((yyvsp[(3) - (3)].str));;} + break; + + case 7: +#line 450 "frame/parser.Y" + {fr->centerCmd();;} + break; + + case 8: +#line 451 "frame/parser.Y" + {fr->clearCmd();;} + break; + + case 10: +#line 453 "frame/parser.Y" + {fr->colorbarTagCmd((yyvsp[(3) - (3)].str));;} + break; + + case 17: +#line 460 "frame/parser.Y" + {fr->DATASECCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 22: +#line 465 "frame/parser.Y" + {fr->hideCmd();;} + break; + + case 23: +#line 466 "frame/parser.Y" + {fr->highliteCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 25: +#line 468 "frame/parser.Y" + {fr->irafAlignCmd((yyvsp[(3) - (3)].integer));;} + break; + + case 32: +#line 475 "frame/parser.Y" + {fr->nanColorCmd((yyvsp[(3) - (3)].str));;} + break; + + case 36: +#line 479 "frame/parser.Y" + {fr->queryCursorCmd();;} + break; + + case 38: +#line 481 "frame/parser.Y" + {fr->resetCmd();;} + break; + + case 43: +#line 486 "frame/parser.Y" + {fr->showCmd();;} + break; + + case 45: +#line 488 "frame/parser.Y" + {fr->threadsCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 47: +#line 490 "frame/parser.Y" + {fr->unloadFitsCmd();;} + break; + + case 49: +#line 492 "frame/parser.Y" + {fr->msg("Frame 1.0");;} + break; + + case 54: +#line 499 "frame/parser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 55: +#line 500 "frame/parser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].integer);;} + break; + + case 56: +#line 503 "frame/parser.Y" + {yydebug=1;;} + break; + + case 57: +#line 504 "frame/parser.Y" + {yydebug=0;;} + break; + + case 58: +#line 505 "frame/parser.Y" + {DebugAST=(yyvsp[(2) - (2)].integer);;} + break; + + case 59: +#line 506 "frame/parser.Y" + {DebugMosaic=(yyvsp[(2) - (2)].integer);;} + break; + + case 60: +#line 507 "frame/parser.Y" + {yydebug=(yyvsp[(2) - (2)].integer);;} + break; + + case 61: +#line 508 "frame/parser.Y" + {DebugPerf=(yyvsp[(2) - (2)].integer);;} + break; + + case 62: +#line 509 "frame/parser.Y" + {DebugWCS=(yyvsp[(2) - (2)].integer);;} + break; + + case 63: +#line 510 "frame/parser.Y" + {DebugBin=(yyvsp[(2) - (2)].integer);;} + break; + + case 64: +#line 511 "frame/parser.Y" + {DebugBlock=(yyvsp[(2) - (2)].integer);;} + break; + + case 65: +#line 512 "frame/parser.Y" + {DebugCompress=(yyvsp[(2) - (2)].integer);;} + break; + + case 66: +#line 513 "frame/parser.Y" + {DebugCrop=(yyvsp[(2) - (2)].integer);;} + break; + + case 67: +#line 514 "frame/parser.Y" + {DebugGZ=(yyvsp[(2) - (2)].integer);;} + break; + + case 68: +#line 515 "frame/parser.Y" + {DebugRGB=(yyvsp[(2) - (2)].integer);;} + break; + + case 69: +#line 518 "frame/parser.Y" + {(yyval.integer)=((yyvsp[(1) - (1)].integer) ? 1 : 0);;} + break; + + case 70: +#line 520 "frame/parser.Y" + {(yyval.integer)=1;;} + break; + + case 71: +#line 521 "frame/parser.Y" + {(yyval.integer)=1;;} + break; + + case 72: +#line 522 "frame/parser.Y" + {(yyval.integer)=1;;} + break; + + case 73: +#line 523 "frame/parser.Y" + {(yyval.integer)=1;;} + break; + + case 74: +#line 525 "frame/parser.Y" + {(yyval.integer)=0;;} + break; + + case 75: +#line 526 "frame/parser.Y" + {(yyval.integer)=0;;} + break; + + case 76: +#line 527 "frame/parser.Y" + {(yyval.integer)=0;;} + break; + + case 77: +#line 528 "frame/parser.Y" + {(yyval.integer)=0;;} + break; + + case 78: +#line 531 "frame/parser.Y" + {(yyval.integer) = Base::ROOTBASE;;} + break; + + case 79: +#line 532 "frame/parser.Y" + {(yyval.integer) = Base::ROOTBASE;;} + break; + + case 80: +#line 533 "frame/parser.Y" + {(yyval.integer) = Base::FULLBASE;;} + break; + + case 81: +#line 534 "frame/parser.Y" + {(yyval.integer) = Base::ROOT;;} + break; + + case 82: +#line 535 "frame/parser.Y" + {(yyval.integer) = Base::FULL;;} + break; + + case 83: +#line 538 "frame/parser.Y" + {(yyval.real) = 0;;} + break; + + case 84: +#line 539 "frame/parser.Y" + {(yyval.real) = (yyvsp[(1) - (1)].real);;} + break; + + case 85: +#line 542 "frame/parser.Y" + {(yyval.real) = degToRad((yyvsp[(1) - (1)].real));;} + break; + + case 86: +#line 543 "frame/parser.Y" + {(yyval.real) = degToRad((yyvsp[(1) - (1)].real));;} + break; + + case 87: +#line 544 "frame/parser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 88: +#line 547 "frame/parser.Y" + {(yyval.real) = parseSEXStr((yyvsp[(1) - (1)].str));;} + break; + + case 89: +#line 550 "frame/parser.Y" + {(yyval.real) = parseHMSStr((yyvsp[(1) - (1)].str));;} + break; + + case 90: +#line 553 "frame/parser.Y" + {(yyval.real) = parseDMSStr((yyvsp[(1) - (1)].str));;} + break; + + case 91: +#line 557 "frame/parser.Y" + { + Vector r; + if (currentSky == Coord::GALACTIC || currentSky == Coord::ECLIPTIC) + r = Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)); + else + r = Vector((yyvsp[(1) - (2)].real)*360./24.,(yyvsp[(2) - (2)].real)); + + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 92: +#line 569 "frame/parser.Y" + { + Vector r = Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 93: +#line 576 "frame/parser.Y" + { + Vector r = Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 94: +#line 583 "frame/parser.Y" + { + (yyval.vector)[0] = (yyvsp[(1) - (2)].real); + (yyval.vector)[1] = (yyvsp[(2) - (2)].real); + (yyval.vector)[2] = 1; + ;} + break; + + case 95: +#line 590 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::IMAGE;;} + break; + + case 96: +#line 591 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::PHYSICAL;;} + break; + + case 97: +#line 592 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::DETECTOR;;} + break; + + case 98: +#line 593 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::AMPLIFIER;;} + break; + + case 99: +#line 594 "frame/parser.Y" + {(yyval.integer) = (Coord::CoordSystem)(yyvsp[(1) - (1)].integer);;} + break; + + case 100: +#line 597 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCS;;} + break; + + case 101: +#line 598 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSA;;} + break; + + case 102: +#line 599 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSB;;} + break; + + case 103: +#line 600 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSC;;} + break; + + case 104: +#line 601 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSD;;} + break; + + case 105: +#line 602 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSE;;} + break; + + case 106: +#line 603 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSF;;} + break; + + case 107: +#line 604 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSG;;} + break; + + case 108: +#line 605 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSH;;} + break; + + case 109: +#line 606 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSI;;} + break; + + case 110: +#line 607 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSJ;;} + break; + + case 111: +#line 608 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSK;;} + break; + + case 112: +#line 609 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSL;;} + break; + + case 113: +#line 610 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSM;;} + break; + + case 114: +#line 611 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSN;;} + break; + + case 115: +#line 612 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSO;;} + break; + + case 116: +#line 613 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSP;;} + break; + + case 117: +#line 614 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSQ;;} + break; + + case 118: +#line 615 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSR;;} + break; + + case 119: +#line 616 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSS;;} + break; + + case 120: +#line 617 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCST;;} + break; + + case 121: +#line 618 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSU;;} + break; + + case 122: +#line 619 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSV;;} + break; + + case 123: +#line 620 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSW;;} + break; + + case 124: +#line 621 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSX;;} + break; + + case 125: +#line 622 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSY;;} + break; + + case 126: +#line 623 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCSZ;;} + break; + + case 127: +#line 624 "frame/parser.Y" + {(yyval.integer) = currentCoord = Coord::WCS0;;} + break; + + case 128: +#line 627 "frame/parser.Y" + {(yyval.integer) = Coord::CANVAS;;} + break; + + case 129: +#line 628 "frame/parser.Y" + {(yyval.integer) = Coord::PANNER;;} + break; + + case 130: +#line 631 "frame/parser.Y" + {(yyval.integer) = FrScale::LINEARSCALE;;} + break; + + case 131: +#line 632 "frame/parser.Y" + {(yyval.integer) = FrScale::LOGSCALE;;} + break; + + case 132: +#line 633 "frame/parser.Y" + {(yyval.integer) = FrScale::POWSCALE;;} + break; + + case 133: +#line 634 "frame/parser.Y" + {(yyval.integer) = FrScale::SQRTSCALE;;} + break; + + case 134: +#line 635 "frame/parser.Y" + {(yyval.integer) = FrScale::SQUAREDSCALE;;} + break; + + case 135: +#line 636 "frame/parser.Y" + {(yyval.integer) = FrScale::ASINHSCALE;;} + break; + + case 136: +#line 637 "frame/parser.Y" + {(yyval.integer) = FrScale::SINHSCALE;;} + break; + + case 137: +#line 638 "frame/parser.Y" + {(yyval.integer) = FrScale::HISTEQUSCALE;;} + break; + + case 138: +#line 641 "frame/parser.Y" + {(yyval.integer)=FrScale::SCAN;;} + break; + + case 139: +#line 642 "frame/parser.Y" + {(yyval.integer)=FrScale::SCAN;;} + break; + + case 140: +#line 643 "frame/parser.Y" + {(yyval.integer)=FrScale::SAMPLE;;} + break; + + case 141: +#line 644 "frame/parser.Y" + {(yyval.integer)=FrScale::DATAMIN;;} + break; + + case 142: +#line 645 "frame/parser.Y" + {(yyval.integer)=FrScale::IRAFMIN;;} + break; + + case 143: +#line 648 "frame/parser.Y" + {(yyval.integer) = currentSky = Coord::FK5;;} + break; + + case 144: +#line 649 "frame/parser.Y" + {(yyval.integer) = currentSky = Coord::FK4;;} + break; + + case 145: +#line 650 "frame/parser.Y" + {(yyval.integer) = currentSky = Coord::FK4_NO_E;;} + break; + + case 146: +#line 651 "frame/parser.Y" + {(yyval.integer) = currentSky = Coord::FK4;;} + break; + + case 147: +#line 652 "frame/parser.Y" + {(yyval.integer) = currentSky = Coord::FK5;;} + break; + + case 148: +#line 653 "frame/parser.Y" + {(yyval.integer) = currentSky = Coord::FK5;;} + break; + + case 149: +#line 654 "frame/parser.Y" + {(yyval.integer) = currentSky = Coord::ICRS;;} + break; + + case 150: +#line 655 "frame/parser.Y" + {(yyval.integer) = currentSky = Coord::GALACTIC;;} + break; + + case 151: +#line 656 "frame/parser.Y" + {(yyval.integer) = currentSky = Coord::SUPERGALACTIC;;} + break; + + case 152: +#line 657 "frame/parser.Y" + {(yyval.integer) = currentSky = Coord::ECLIPTIC;;} + break; + + case 153: +#line 658 "frame/parser.Y" + {(yyval.integer) = currentSky = Coord::HELIOECLIPTIC;;} + break; + + case 154: +#line 661 "frame/parser.Y" + {(yyval.integer)=Coord::DEGREES;;} + break; + + case 155: +#line 662 "frame/parser.Y" + {(yyval.integer)=Coord::DEGREES;;} + break; + + case 156: +#line 663 "frame/parser.Y" + {(yyval.integer)=Coord::SEXAGESIMAL;;} + break; + + case 157: +#line 666 "frame/parser.Y" + {(yyval.integer)=Coord::DEGREE;;} + break; + + case 158: +#line 667 "frame/parser.Y" + {(yyval.integer)=Coord::DEGREE;;} + break; + + case 159: +#line 668 "frame/parser.Y" + {(yyval.integer)=Coord::ARCMIN;;} + break; + + case 160: +#line 669 "frame/parser.Y" + {(yyval.integer)=Coord::ARCSEC;;} + break; + + case 161: +#line 672 "frame/parser.Y" + {(yyval.real) = (yyvsp[(1) - (1)].real);;} + break; + + case 162: +#line 673 "frame/parser.Y" + {(yyval.real) = FrScale::MINMAX;;} + break; + + case 163: +#line 674 "frame/parser.Y" + {(yyval.real) = FrScale::ZSCALE;;} + break; + + case 164: +#line 675 "frame/parser.Y" + {(yyval.real) = FrScale::ZMAX;;} + break; + + case 165: +#line 676 "frame/parser.Y" + {(yyval.real) = FrScale::USERCLIP;;} + break; + + case 166: +#line 679 "frame/parser.Y" + {(yyval.integer) = Base::SHMID;;} + break; + + case 167: +#line 680 "frame/parser.Y" + {(yyval.integer) = Base::SHMID;;} + break; + + case 168: +#line 681 "frame/parser.Y" + {(yyval.integer) = Base::KEY;;} + break; + + case 169: +#line 684 "frame/parser.Y" + {;} + break; + + case 170: +#line 685 "frame/parser.Y" + {;} + break; + + case 171: +#line 686 "frame/parser.Y" + {;} + break; + + case 172: +#line 689 "frame/parser.Y" + {(yyval.integer) = Base::IMG;;} + break; + + case 173: +#line 690 "frame/parser.Y" + {(yyval.integer) = Base::IMG;;} + break; + + case 174: +#line 691 "frame/parser.Y" + {(yyval.integer) = Base::MASK;;} + break; + + case 175: +#line 694 "frame/parser.Y" + {(yyval.integer) = Point::CIRCLE;;} + break; + + case 176: +#line 695 "frame/parser.Y" + {(yyval.integer) = Point::CIRCLE;;} + break; + + case 177: +#line 696 "frame/parser.Y" + {(yyval.integer) = Point::BOX;;} + break; + + case 178: +#line 697 "frame/parser.Y" + {(yyval.integer) = Point::DIAMOND;;} + break; + + case 179: +#line 698 "frame/parser.Y" + {(yyval.integer) = Point::CROSS;;} + break; + + case 180: +#line 699 "frame/parser.Y" + {(yyval.integer) = Point::EX;;} + break; + + case 181: +#line 700 "frame/parser.Y" + {(yyval.integer) = Point::ARROW;;} + break; + + case 182: +#line 701 "frame/parser.Y" + {(yyval.integer) = Point::BOXCIRCLE;;} + break; + + case 183: +#line 704 "frame/parser.Y" + {(yyval.integer) = POINTSIZE;;} + break; + + case 184: +#line 705 "frame/parser.Y" + {(yyval.integer) = (yyvsp[(1) - (1)].integer);;} + break; + + case 185: +#line 708 "frame/parser.Y" + {(yyval.integer) = Marker::PANDA;;} + break; + + case 186: +#line 709 "frame/parser.Y" + {(yyval.integer) = Marker::HISTOGRAM;;} + break; + + case 187: +#line 710 "frame/parser.Y" + {(yyval.integer) = Marker::PLOT2D;;} + break; + + case 188: +#line 711 "frame/parser.Y" + {(yyval.integer) = Marker::PLOT3D;;} + break; + + case 189: +#line 712 "frame/parser.Y" + {(yyval.integer) = Marker::RADIAL;;} + break; + + case 190: +#line 713 "frame/parser.Y" + {(yyval.integer) = Marker::STATS;;} + break; + + case 191: +#line 716 "frame/parser.Y" + {(yyval.integer) = Marker::AVERAGE;;} + break; + + case 192: +#line 717 "frame/parser.Y" + {(yyval.integer) = Marker::AVERAGE;;} + break; + + case 193: +#line 718 "frame/parser.Y" + {(yyval.integer) = Marker::SUM;;} + break; + + case 194: +#line 721 "frame/parser.Y" + {(yyval.integer) = FitsFile::NATIVE;;} + break; + + case 195: +#line 722 "frame/parser.Y" + {(yyval.integer) = FitsFile::NATIVE;;} + break; + + case 196: +#line 723 "frame/parser.Y" + {(yyval.integer) = FitsFile::BIG;;} + break; + + case 197: +#line 724 "frame/parser.Y" + {(yyval.integer) = FitsFile::BIG;;} + break; + + case 198: +#line 725 "frame/parser.Y" + {(yyval.integer) = FitsFile::LITTLE;;} + break; + + case 199: +#line 726 "frame/parser.Y" + {(yyval.integer) = FitsFile::LITTLE;;} + break; + + case 204: +#line 733 "frame/parser.Y" + {fr->set3dRenderMethodCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 205: +#line 734 "frame/parser.Y" + {fr->set3dRenderBackgroundCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 206: +#line 735 "frame/parser.Y" + {fr->set3dScaleCmd((yyvsp[(2) - (2)].real));;} + break; + + case 207: +#line 736 "frame/parser.Y" + {fr->set3dPreserveCmd();;} + break; + + case 208: +#line 738 "frame/parser.Y" + {/* needed for compatibility with old version of backup */;} + break; + + case 209: +#line 741 "frame/parser.Y" + {fr->set3dBorderCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 210: +#line 742 "frame/parser.Y" + {fr->set3dBorderColorCmd((yyvsp[(2) - (2)].str));;} + break; + + case 211: +#line 745 "frame/parser.Y" + {fr->set3dCompassCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 212: +#line 746 "frame/parser.Y" + {fr->set3dCompassColorCmd((yyvsp[(2) - (2)].str));;} + break; + + case 213: +#line 749 "frame/parser.Y" + {fr->set3dHighliteCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 214: +#line 750 "frame/parser.Y" + {fr->set3dHighliteColorCmd((yyvsp[(2) - (2)].str));;} + break; + + case 215: +#line 753 "frame/parser.Y" + {fr->set3dViewCmd((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real));;} + break; + + case 216: +#line 755 "frame/parser.Y" + {fr->set3dViewPointCmd(Vector3d((yyvsp[(2) - (6)].real),(yyvsp[(3) - (6)].real),(yyvsp[(4) - (6)].real)),Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real)));;} + break; + + case 217: +#line 756 "frame/parser.Y" + {fr->view3dBeginCmd((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real));;} + break; + + case 218: +#line 757 "frame/parser.Y" + {fr->view3dMotionCmd((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real));;} + break; + + case 219: +#line 758 "frame/parser.Y" + {fr->view3dEndCmd((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real));;} + break; + + case 220: +#line 761 "frame/parser.Y" + {fr->analysisMarkersResetCmd();;} + break; + + case 222: +#line 766 "frame/parser.Y" + {fr->analysisMarkersSelectCmd("circle", fr->mapToRef(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::CANVAS));;} + break; + + case 223: +#line 768 "frame/parser.Y" + {fr->analysisMarkersSelectCmd("ellipse", fr->mapToRef(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::CANVAS));;} + break; + + case 224: +#line 770 "frame/parser.Y" + {fr->analysisMarkersSelectCmd("box", fr->mapToRef(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::CANVAS));;} + break; + + case 225: +#line 772 "frame/parser.Y" + {fr->analysisMarkersSelectCmd("polygon", fr->mapToRef(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::CANVAS));;} + break; + + case 226: +#line 774 "frame/parser.Y" + {fr->analysisMarkersSelectCmd("point", fr->mapToRef(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::CANVAS));;} + break; + + case 227: +#line 776 "frame/parser.Y" + {fr->analysisMarkersSelectCmd("vector", fr->mapToRef(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::CANVAS));;} + break; + + case 228: +#line 778 "frame/parser.Y" + {fr->analysisMarkersSelectCmd("annulus", fr->mapToRef(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::CANVAS));;} + break; + + case 229: +#line 780 "frame/parser.Y" + {fr->analysisMarkersSelectCmd("ellipseannulus", fr->mapToRef(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::CANVAS));;} + break; + + case 230: +#line 782 "frame/parser.Y" + {fr->analysisMarkersSelectCmd("boxannulus", fr->mapToRef(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::CANVAS));;} + break; + + case 232: +#line 786 "frame/parser.Y" + {fr->binColsCmd((yyvsp[(2) - (4)].str),(yyvsp[(3) - (4)].str),(yyvsp[(4) - (4)].str));;} + break; + + case 233: +#line 787 "frame/parser.Y" + {fr->binDepthCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 236: +#line 790 "frame/parser.Y" + {fr->binBufferSizeCmd((yyvsp[(3) - (3)].integer));;} + break; + + case 238: +#line 792 "frame/parser.Y" + {fr->binFilterCmd((yyvsp[(2) - (2)].str));;} + break; + + case 239: +#line 795 "frame/parser.Y" + {fr->binAboutCmd();;} + break; + + case 240: +#line 796 "frame/parser.Y" + {fr->binAboutCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 241: +#line 799 "frame/parser.Y" + {fr->binFactorCmd(Vector((yyvsp[(1) - (1)].real),(yyvsp[(1) - (1)].real)));;} + break; + + case 242: +#line 800 "frame/parser.Y" + {fr->binFactorCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 243: +#line 802 "frame/parser.Y" + {fr->binFactorAboutCmd(Vector((yyvsp[(1) - (4)].real),(yyvsp[(1) - (4)].real)), Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)));;} + break; + + case 244: +#line 804 "frame/parser.Y" + {fr->binFactorAboutCmd(Vector((yyvsp[(1) - (5)].real),(yyvsp[(2) - (5)].real)), Vector((yyvsp[(4) - (5)].real),(yyvsp[(5) - (5)].real)));;} + break; + + case 245: +#line 805 "frame/parser.Y" + {fr->binFactorToCmd(Vector((yyvsp[(2) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 246: +#line 806 "frame/parser.Y" + {fr->binFactorToCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 247: +#line 808 "frame/parser.Y" + {fr->binFactorToAboutCmd(Vector((yyvsp[(2) - (5)].real),(yyvsp[(2) - (5)].real)), Vector((yyvsp[(4) - (5)].real),(yyvsp[(5) - (5)].real)));;} + break; + + case 248: +#line 810 "frame/parser.Y" + {fr->binFactorToAboutCmd(Vector((yyvsp[(2) - (6)].real),(yyvsp[(3) - (6)].real)), Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real)));;} + break; + + case 249: +#line 813 "frame/parser.Y" + {fr->binFunctionCmd(FitsHist::AVERAGE);;} + break; + + case 250: +#line 814 "frame/parser.Y" + {fr->binFunctionCmd(FitsHist::SUM);;} + break; + + case 251: +#line 817 "frame/parser.Y" + {fr->binToFitCmd();;} + break; + + case 252: +#line 819 "frame/parser.Y" + {fr->binCmd(Vector((yyvsp[(1) - (7)].real),(yyvsp[(2) - (7)].real)), (yyvsp[(5) - (7)].str), (yyvsp[(6) - (7)].str), (yyvsp[(7) - (7)].str));;} + break; + + case 253: +#line 822 "frame/parser.Y" + {fr->binCmd(Vector((yyvsp[(1) - (11)].real),(yyvsp[(2) - (11)].real)), (yyvsp[(3) - (11)].integer), Vector((yyvsp[(4) - (11)].real),(yyvsp[(5) - (11)].real)), (yyvsp[(8) - (11)].str), (yyvsp[(9) - (11)].str), (yyvsp[(10) - (11)].str), (yyvsp[(11) - (11)].str));;} + break; + + case 254: +#line 824 "frame/parser.Y" + {fr->binCmd(Vector((yyvsp[(1) - (8)].real),(yyvsp[(2) - (8)].real)), Vector((yyvsp[(4) - (8)].real),(yyvsp[(5) - (8)].real)), (yyvsp[(6) - (8)].str), (yyvsp[(7) - (8)].str), (yyvsp[(8) - (8)].str));;} + break; + + case 255: +#line 827 "frame/parser.Y" + {fr->binCmd(Vector((yyvsp[(1) - (12)].real),(yyvsp[(2) - (12)].real)), (yyvsp[(3) - (12)].integer), Vector((yyvsp[(4) - (12)].real),(yyvsp[(5) - (12)].real)), Vector((yyvsp[(7) - (12)].real),(yyvsp[(8) - (12)].real)), + (yyvsp[(9) - (12)].str), (yyvsp[(10) - (12)].str), (yyvsp[(11) - (12)].str), (yyvsp[(12) - (12)].str));;} + break; + + case 256: +#line 831 "frame/parser.Y" + {fr->blockCmd(Vector((yyvsp[(1) - (1)].real),(yyvsp[(1) - (1)].real)));;} + break; + + case 257: +#line 832 "frame/parser.Y" + {fr->blockCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 259: +#line 836 "frame/parser.Y" + {fr->blockToFitCmd();;} + break; + + case 260: +#line 837 "frame/parser.Y" + {fr->blockToCmd(Vector((yyvsp[(1) - (1)].real),(yyvsp[(1) - (1)].real)));;} + break; + + case 261: +#line 838 "frame/parser.Y" + {fr->blockToCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 265: +#line 844 "frame/parser.Y" + {fr->clipUserCmd((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real));;} + break; + + case 267: +#line 847 "frame/parser.Y" + { + // backward compatibility with backup + ;} + break; + + case 268: +#line 852 "frame/parser.Y" + {fr->clipScopeCmd(FrScale::GLOBAL);;} + break; + + case 269: +#line 853 "frame/parser.Y" + {fr->clipScopeCmd(FrScale::LOCAL);;} + break; + + case 270: +#line 856 "frame/parser.Y" + {fr->clipModeCmd((yyvsp[(1) - (1)].real));;} + break; + + case 271: +#line 857 "frame/parser.Y" + {fr->clipModeCmd(FrScale::MINMAX);;} + break; + + case 272: +#line 858 "frame/parser.Y" + {fr->clipModeCmd(FrScale::ZSCALE);;} + break; + + case 273: +#line 859 "frame/parser.Y" + {fr->clipModeCmd(FrScale::ZMAX);;} + break; + + case 274: +#line 860 "frame/parser.Y" + {fr->clipModeCmd(FrScale::USERCLIP);;} + break; + + case 275: +#line 863 "frame/parser.Y" + {fr->clipMinMaxCmd((FrScale::MinMaxMode)(yyvsp[(2) - (2)].integer),(yyvsp[(1) - (2)].integer));;} + break; + + case 276: +#line 864 "frame/parser.Y" + {fr->clipMinMaxModeCmd((FrScale::MinMaxMode)(yyvsp[(2) - (2)].integer));;} + break; + + case 277: +#line 865 "frame/parser.Y" + {fr->clipMinMaxSampleCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 278: +#line 868 "frame/parser.Y" + {fr->clipZScaleCmd((yyvsp[(1) - (3)].real),(yyvsp[(2) - (3)].integer),(yyvsp[(3) - (3)].integer));;} + break; + + case 279: +#line 870 "frame/parser.Y" + { + // backward compatibility with backup + fr->clipZScaleContrastCmd((yyvsp[(2) - (2)].real)); + ;} + break; + + case 280: +#line 875 "frame/parser.Y" + { + // backward compatibility with backup + fr->clipZScaleSampleCmd((yyvsp[(2) - (2)].integer)); + ;} + break; + + case 281: +#line 880 "frame/parser.Y" + { + // backward compatibility with backup + fr->clipZScaleLineCmd((yyvsp[(2) - (2)].integer)); + ;} + break; + + case 282: +#line 887 "frame/parser.Y" + {fr->colormapCmd((yyvsp[(1) - (6)].integer), (yyvsp[(2) - (6)].real), (yyvsp[(3) - (6)].real), (yyvsp[(4) - (6)].integer), (unsigned char*)(yyvsp[(5) - (6)].ptr), (yyvsp[(6) - (6)].integer));;} + break; + + case 283: +#line 889 "frame/parser.Y" + {fr->colormapCmd((yyvsp[(2) - (10)].real),(yyvsp[(3) - (10)].real),(yyvsp[(4) - (10)].real),(yyvsp[(5) - (10)].real),(yyvsp[(6) - (10)].real),(yyvsp[(7) - (10)].real),(yyvsp[(8) - (10)].integer),(unsigned char*)(yyvsp[(9) - (10)].ptr),(yyvsp[(10) - (10)].integer));;} + break; + + case 284: +#line 890 "frame/parser.Y" + {fr->colormapBeginCmd();;} + break; + + case 286: +#line 892 "frame/parser.Y" + {fr->colormapEndCmd();;} + break; + + case 287: +#line 896 "frame/parser.Y" + {fr->colormapMotionCmd((yyvsp[(1) - (6)].integer), (yyvsp[(2) - (6)].real), (yyvsp[(3) - (6)].real), (yyvsp[(4) - (6)].integer), (unsigned char*)(yyvsp[(5) - (6)].ptr), (yyvsp[(6) - (6)].integer));;} + break; + + case 288: +#line 898 "frame/parser.Y" + {fr->colormapMotionCmd((yyvsp[(2) - (10)].real),(yyvsp[(3) - (10)].real),(yyvsp[(4) - (10)].real),(yyvsp[(5) - (10)].real),(yyvsp[(6) - (10)].real),(yyvsp[(7) - (10)].real),(yyvsp[(8) - (10)].integer),(unsigned char*)(yyvsp[(9) - (10)].ptr),(yyvsp[(10) - (10)].integer));;} + break; + + case 289: +#line 900 "frame/parser.Y" + {fr->colorScaleCmd((FrScale::ColorScaleType)(yyvsp[(1) - (1)].integer));;} + break; + + case 290: +#line 901 "frame/parser.Y" + {fr->colorScaleLogCmd((yyvsp[(2) - (2)].real));;} + break; + + case 296: +#line 912 "frame/parser.Y" + {fr->contourCreateCmd((yyvsp[(1) - (12)].str),(yyvsp[(2) - (12)].integer),(yyvsp[(3) - (12)].integer),(FVContour::Method)(yyvsp[(4) - (12)].integer),(yyvsp[(5) - (12)].integer),(yyvsp[(6) - (12)].integer),(FrScale::ColorScaleType)(yyvsp[(7) - (12)].integer),(yyvsp[(8) - (12)].real),(yyvsp[(9) - (12)].real),Vector((yyvsp[(10) - (12)].real),(yyvsp[(11) - (12)].real)),(yyvsp[(12) - (12)].str));;} + break; + + case 297: +#line 913 "frame/parser.Y" + {fr->contourCreatePolygonCmd();;} + break; + + case 298: +#line 916 "frame/parser.Y" + {fr->contourDeleteCmd();;} + break; + + case 299: +#line 917 "frame/parser.Y" + {fr->contourDeleteAuxCmd();;} + break; + + case 300: +#line 920 "frame/parser.Y" + {fr->contourLoadCmd((yyvsp[(1) - (1)].str));;} + break; + + case 301: +#line 921 "frame/parser.Y" + {fr->contourLoadCmd((yyvsp[(1) - (4)].str),(yyvsp[(2) - (4)].str),(yyvsp[(3) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 302: +#line 923 "frame/parser.Y" + { + // backward compatibility with backup + fr->contourLoadCmd((yyvsp[(4) - (6)].str),(Coord::CoordSystem)(yyvsp[(5) - (6)].integer),(Coord::SkyFrame)(yyvsp[(6) - (6)].integer),(yyvsp[(1) - (6)].str),(yyvsp[(2) - (6)].integer),(yyvsp[(3) - (6)].integer)); + ;} + break; + + case 303: +#line 929 "frame/parser.Y" + {(yyval.integer) = FVContour::SMOOTH;;} + break; + + case 304: +#line 930 "frame/parser.Y" + {(yyval.integer) = FVContour::BLOCK;;} + break; + + case 305: +#line 933 "frame/parser.Y" + {fr->contourPasteCmd((yyvsp[(1) - (1)].str));;} + break; + + case 306: +#line 934 "frame/parser.Y" + {fr->contourPasteCmd((yyvsp[(1) - (4)].str),(yyvsp[(2) - (4)].str),(yyvsp[(3) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 307: +#line 938 "frame/parser.Y" + {fr->contourSaveCmd((yyvsp[(1) - (3)].str), (Coord::CoordSystem)(yyvsp[(2) - (3)].integer), (Coord::SkyFrame)(yyvsp[(3) - (3)].integer));;} + break; + + case 308: +#line 940 "frame/parser.Y" + {fr->contourSaveAuxCmd((yyvsp[(2) - (4)].str),(Coord::CoordSystem)(yyvsp[(3) - (4)].integer),(Coord::SkyFrame)(yyvsp[(4) - (4)].integer));;} + break; + + case 309: +#line 943 "frame/parser.Y" + {fr->cropCmd();;} + break; + + case 310: +#line 945 "frame/parser.Y" + {fr->cropCmd(Vector((yyvsp[(1) - (6)].real),(yyvsp[(2) - (6)].real)), Vector((yyvsp[(3) - (6)].real),(yyvsp[(4) - (6)].real)), + (Coord::CoordSystem)(yyvsp[(5) - (6)].integer), (Coord::SkyFrame)(yyvsp[(6) - (6)].integer));;} + break; + + case 311: +#line 948 "frame/parser.Y" + {fr->cropCenterCmd(Vector((yyvsp[(2) - (8)].vector)), (Coord::CoordSystem)(yyvsp[(3) - (8)].integer), (Coord::SkyFrame)(yyvsp[(4) - (8)].integer), Vector((yyvsp[(5) - (8)].real),(yyvsp[(6) - (8)].real)), (Coord::CoordSystem)(yyvsp[(7) - (8)].integer), (Coord::SkyDist)(yyvsp[(8) - (8)].integer));;} + break; + + case 313: +#line 950 "frame/parser.Y" + {fr->cropBeginCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 314: +#line 951 "frame/parser.Y" + {fr->cropMotionCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 315: +#line 952 "frame/parser.Y" + {fr->cropEndCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 316: +#line 955 "frame/parser.Y" + {fr->crop3dCmd();;} + break; + + case 317: +#line 956 "frame/parser.Y" + {fr->crop3dCmd((yyvsp[(1) - (3)].real), (yyvsp[(2) - (3)].real), (Coord::CoordSystem)(yyvsp[(3) - (3)].integer));;} + break; + + case 318: +#line 957 "frame/parser.Y" + {fr->crop3dBeginCmd(Vector((yyvsp[(2) - (4)].real),(yyvsp[(3) - (4)].real)),(yyvsp[(4) - (4)].integer));;} + break; + + case 319: +#line 958 "frame/parser.Y" + {fr->crop3dMotionCmd(Vector((yyvsp[(2) - (4)].real),(yyvsp[(3) - (4)].real)),(yyvsp[(4) - (4)].integer));;} + break; + + case 320: +#line 959 "frame/parser.Y" + {fr->crop3dEndCmd(Vector((yyvsp[(2) - (4)].real),(yyvsp[(3) - (4)].real)),(yyvsp[(4) - (4)].integer));;} + break; + + case 321: +#line 963 "frame/parser.Y" + {fr->crosshairCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)), (Coord::InternalSystem)(yyvsp[(1) - (3)].integer));;} + break; + + case 322: +#line 965 "frame/parser.Y" + {fr->crosshairCmd(Vector((yyvsp[(3) - (3)].vector)), (Coord::CoordSystem)(yyvsp[(1) - (3)].integer), (Coord::SkyFrame)(yyvsp[(2) - (3)].integer));;} + break; + + case 323: +#line 966 "frame/parser.Y" + {fr->crosshairCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 324: +#line 967 "frame/parser.Y" + {fr->crosshairWarpCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 325: +#line 970 "frame/parser.Y" + {fr->crosshairCmd(Vector((yyvsp[(4) - (5)].real),(yyvsp[(5) - (5)].real)), (Coord::InternalSystem)(yyvsp[(3) - (5)].integer));;} + break; + + case 326: +#line 972 "frame/parser.Y" + {fr->crosshairCmd(Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)), (Coord::InternalSystem)(yyvsp[(2) - (4)].integer));;} + break; + + case 327: +#line 974 "frame/parser.Y" + {fr->crosshairCmd(Vector((yyvsp[(4) - (4)].vector)), (Coord::CoordSystem)(yyvsp[(3) - (4)].integer));;} + break; + + case 328: +#line 976 "frame/parser.Y" + {fr->crosshairCmd(Vector((yyvsp[(3) - (3)].vector)), (Coord::CoordSystem)(yyvsp[(2) - (3)].integer));;} + break; + + case 329: +#line 979 "frame/parser.Y" + {fr->axesOrderCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 330: +#line 982 "frame/parser.Y" + {fr->fitsyHasExtCmd((yyvsp[(3) - (3)].str));;} + break; + + case 331: +#line 985 "frame/parser.Y" + {fr->getBgColorCmd();;} + break; + + case 345: +#line 999 "frame/parser.Y" + {fr->getDATASECCmd();;} + break; + + case 348: +#line 1002 "frame/parser.Y" + {fr->getHistogramCmd((yyvsp[(2) - (4)].str),(yyvsp[(3) - (4)].str),(yyvsp[(4) - (4)].integer));;} + break; + + case 349: +#line 1004 "frame/parser.Y" + {fr->getHorzCutCmd((yyvsp[(3) - (7)].str),(yyvsp[(4) - (7)].str),Vector((yyvsp[(5) - (7)].real),(yyvsp[(6) - (7)].real)),(Coord::InternalSystem)(yyvsp[(7) - (7)].integer));;} + break; + + case 352: +#line 1007 "frame/parser.Y" + {fr->getIRAFAlignCmd();;} + break; + + case 353: +#line 1008 "frame/parser.Y" + {fr->getMinMaxCmd();;} + break; + + case 356: +#line 1011 "frame/parser.Y" + {fr->getNANColorCmd();;} + break; + + case 357: +#line 1012 "frame/parser.Y" + {fr->getOrientCmd();;} + break; + + case 359: +#line 1015 "frame/parser.Y" + {fr->getPixelTableCmd(Vector((yyvsp[(4) - (8)].real),(yyvsp[(5) - (8)].real)), (Coord::InternalSystem)(yyvsp[(3) - (8)].integer), (yyvsp[(6) - (8)].integer), (yyvsp[(7) - (8)].integer), (yyvsp[(8) - (8)].str));;} + break; + + case 361: +#line 1017 "frame/parser.Y" + {fr->getRotateCmd();;} + break; + + case 363: +#line 1019 "frame/parser.Y" + {fr->getThreadsCmd();;} + break; + + case 365: +#line 1021 "frame/parser.Y" + {fr->getTypeCmd();;} + break; + + case 366: +#line 1023 "frame/parser.Y" + {fr->getValueCmd(Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)),(Coord::InternalSystem)(yyvsp[(2) - (4)].integer));;} + break; + + case 367: +#line 1025 "frame/parser.Y" + {fr->getVertCutCmd((yyvsp[(3) - (7)].str),(yyvsp[(4) - (7)].str),Vector((yyvsp[(5) - (7)].real),(yyvsp[(6) - (7)].real)),(Coord::InternalSystem)(yyvsp[(7) - (7)].integer));;} + break; + + case 369: +#line 1027 "frame/parser.Y" + {fr->getZoomCmd();;} + break; + + case 370: +#line 1030 "frame/parser.Y" + {fr->getBinDepthCmd();;} + break; + + case 371: +#line 1031 "frame/parser.Y" + {fr->getBinFactorCmd();;} + break; + + case 372: +#line 1032 "frame/parser.Y" + {fr->getBinFunctionCmd();;} + break; + + case 373: +#line 1033 "frame/parser.Y" + {fr->getBinBufferSizeCmd();;} + break; + + case 374: +#line 1034 "frame/parser.Y" + {fr->getBinCursorCmd();;} + break; + + case 375: +#line 1035 "frame/parser.Y" + {fr->getBinFilterCmd();;} + break; + + case 377: +#line 1037 "frame/parser.Y" + {fr->getBinListCmd();;} + break; + + case 378: +#line 1040 "frame/parser.Y" + {fr->getBinColsCmd();;} + break; + + case 379: +#line 1041 "frame/parser.Y" + {fr->getBinColsMinMaxCmd((yyvsp[(2) - (2)].str));;} + break; + + case 380: +#line 1042 "frame/parser.Y" + {fr->getBinColsDimCmd((yyvsp[(2) - (2)].str));;} + break; + + case 381: +#line 1045 "frame/parser.Y" + {fr->getBlockCmd();;} + break; + + case 383: +#line 1049 "frame/parser.Y" + {fr->getClipScopeCmd();;} + break; + + case 384: +#line 1050 "frame/parser.Y" + {fr->getClipModeCmd();;} + break; + + case 386: +#line 1052 "frame/parser.Y" + {fr->getClipUserCmd();;} + break; + + case 388: +#line 1055 "frame/parser.Y" + { + // backward compatibility with backup + fr->getClipPreserveCmd(); + ;} + break; + + case 389: +#line 1061 "frame/parser.Y" + {fr->getClipCmd();;} + break; + + case 390: +#line 1062 "frame/parser.Y" + {fr->getClipCmd((yyvsp[(1) - (1)].real));;} + break; + + case 391: +#line 1063 "frame/parser.Y" + {fr->getClipCmd(FrScale::MINMAX);;} + break; + + case 392: +#line 1064 "frame/parser.Y" + {fr->getClipCmd(FrScale::ZSCALE);;} + break; + + case 393: +#line 1065 "frame/parser.Y" + {fr->getClipCmd(FrScale::ZMAX);;} + break; + + case 394: +#line 1066 "frame/parser.Y" + {fr->getClipCmd(FrScale::USERCLIP);;} + break; + + case 395: +#line 1069 "frame/parser.Y" + {fr->getClipMinMaxModeCmd();;} + break; + + case 396: +#line 1070 "frame/parser.Y" + {fr->getClipMinMaxSampleCmd();;} + break; + + case 397: +#line 1073 "frame/parser.Y" + {fr->getClipZScaleContrastCmd();;} + break; + + case 398: +#line 1074 "frame/parser.Y" + {fr->getClipZScaleSampleCmd();;} + break; + + case 399: +#line 1075 "frame/parser.Y" + {fr->getClipZScaleLineCmd();;} + break; + + case 400: +#line 1078 "frame/parser.Y" + {fr->getColorbarCmd();;} + break; + + case 401: +#line 1079 "frame/parser.Y" + {fr->getColorbarTagCmd();;} + break; + + case 403: +#line 1085 "frame/parser.Y" + {fr->getColorMapLevelCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 404: +#line 1087 "frame/parser.Y" + {fr->getColorMapLevelCmd((yyvsp[(1) - (4)].integer),Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)),(Coord::InternalSystem)(yyvsp[(2) - (4)].integer));;} + break; + + case 405: +#line 1089 "frame/parser.Y" + {fr->getColorMapLevelCmd((yyvsp[(1) - (5)].integer),(yyvsp[(2) - (5)].real),(yyvsp[(3) - (5)].real),(FrScale::ColorScaleType)(yyvsp[(4) - (5)].integer),(yyvsp[(5) - (5)].real));;} + break; + + case 406: +#line 1092 "frame/parser.Y" + {fr->getColorScaleCmd();;} + break; + + case 408: +#line 1094 "frame/parser.Y" + {fr->getColorScaleLogCmd();;} + break; + + case 409: +#line 1098 "frame/parser.Y" + {fr->getColorScaleLevelCmd((yyvsp[(1) - (5)].integer),(yyvsp[(2) - (5)].real),(yyvsp[(3) - (5)].real),(FrScale::ColorScaleType)(yyvsp[(4) - (5)].integer),(yyvsp[(5) - (5)].real));;} + break; + + case 410: +#line 1102 "frame/parser.Y" + {fr->getContourCmd((Coord::CoordSystem)(yyvsp[(1) - (2)].integer),(Coord::SkyFrame)(yyvsp[(2) - (2)].integer));;} + break; + + case 412: +#line 1104 "frame/parser.Y" + {fr->getContourColorNameCmd();;} + break; + + case 413: +#line 1105 "frame/parser.Y" + {fr->getContourDashCmd();;} + break; + + case 414: +#line 1106 "frame/parser.Y" + {fr->getContourLevelCmd();;} + break; + + case 415: +#line 1107 "frame/parser.Y" + {fr->getContourNumLevelCmd();;} + break; + + case 416: +#line 1108 "frame/parser.Y" + {fr->getContourMethodCmd();;} + break; + + case 418: +#line 1110 "frame/parser.Y" + {fr->getContourSmoothCmd();;} + break; + + case 419: +#line 1111 "frame/parser.Y" + {fr->getContourLineWidthCmd();;} + break; + + case 420: +#line 1114 "frame/parser.Y" + {fr->getContourClipCmd();;} + break; + + case 421: +#line 1115 "frame/parser.Y" + {fr->getContourClipModeCmd();;} + break; + + case 422: +#line 1118 "frame/parser.Y" + {fr->getContourScaleCmd();;} + break; + + case 423: +#line 1119 "frame/parser.Y" + {fr->getContourScaleLogCmd();;} + break; + + case 424: +#line 1123 "frame/parser.Y" + {fr->getCoordCmd(Vector((yyvsp[(1) - (5)].real),(yyvsp[(2) - (5)].real)), (Coord::CoordSystem)(yyvsp[(3) - (5)].integer), (Coord::SkyFrame)(yyvsp[(4) - (5)].integer), (Coord::SkyFormat)(yyvsp[(5) - (5)].integer));;} + break; + + case 425: +#line 1125 "frame/parser.Y" + { + // backward compatibility + fr->getCoordCmd(Vector((yyvsp[(2) - (6)].real),(yyvsp[(3) - (6)].real)), (Coord::CoordSystem)(yyvsp[(4) - (6)].integer), (Coord::SkyFrame)(yyvsp[(5) - (6)].integer), + (Coord::SkyFormat)(yyvsp[(6) - (6)].integer)); + ;} + break; + + case 426: +#line 1131 "frame/parser.Y" + {fr->getCoord3axisCmd((yyvsp[(1) - (4)].real), (Coord::CoordSystem)(yyvsp[(2) - (4)].integer), (Coord::CoordSystem)(yyvsp[(3) - (4)].integer), (yyvsp[(4) - (4)].integer));;} + break; + + case 427: +#line 1135 "frame/parser.Y" + {fr->getCropCmd((Coord::CoordSystem)(yyvsp[(1) - (3)].integer), (Coord::SkyFrame)(yyvsp[(2) - (3)].integer), (Coord::SkyFormat)(yyvsp[(3) - (3)].integer));;} + break; + + case 428: +#line 1137 "frame/parser.Y" + {fr->getCropCenterCmd((Coord::CoordSystem)(yyvsp[(2) - (6)].integer), (Coord::SkyFrame)(yyvsp[(3) - (6)].integer), (Coord::SkyFormat)(yyvsp[(4) - (6)].integer), (Coord::CoordSystem)(yyvsp[(5) - (6)].integer), (Coord::SkyDist)(yyvsp[(6) - (6)].integer));;} + break; + + case 429: +#line 1138 "frame/parser.Y" + {fr->getCrop3dCmd((Coord::CoordSystem)(yyvsp[(2) - (2)].integer));;} + break; + + case 430: +#line 1141 "frame/parser.Y" + {fr->getCrosshairCmd((Coord::InternalSystem)(yyvsp[(1) - (1)].integer));;} + break; + + case 431: +#line 1143 "frame/parser.Y" + {fr->getCrosshairCmd((Coord::CoordSystem)(yyvsp[(1) - (3)].integer), (Coord::SkyFrame)(yyvsp[(2) - (3)].integer), (Coord::SkyFormat)(yyvsp[(3) - (3)].integer));;} + break; + + case 432: +#line 1144 "frame/parser.Y" + {fr->getCrosshairStatusCmd();;} + break; + + case 433: +#line 1147 "frame/parser.Y" + {fr->getAxesOrderCmd();;} + break; + + case 434: +#line 1150 "frame/parser.Y" + {fr->getCursorCmd((Coord::InternalSystem)(yyvsp[(1) - (1)].integer));;} + break; + + case 435: +#line 1152 "frame/parser.Y" + {fr->getCursorCmd((Coord::CoordSystem)(yyvsp[(1) - (3)].integer), (Coord::SkyFrame)(yyvsp[(2) - (3)].integer), (Coord::SkyFormat)(yyvsp[(3) - (3)].integer));;} + break; + + case 436: +#line 1156 "frame/parser.Y" + {fr->getDataValuesCmd(1, Vector((yyvsp[(3) - (6)].vector)), (Coord::CoordSystem)(yyvsp[(1) - (6)].integer), (Coord::SkyFrame)(yyvsp[(2) - (6)].integer), Vector((yyvsp[(4) - (6)].real),(yyvsp[(5) - (6)].real)), (yyvsp[(6) - (6)].str));;} + break; + + case 437: +#line 1158 "frame/parser.Y" + {fr->getDataValuesCmd((yyvsp[(1) - (7)].integer), Vector((yyvsp[(4) - (7)].vector)), + (Coord::CoordSystem)(yyvsp[(2) - (7)].integer), (Coord::SkyFrame)(yyvsp[(3) - (7)].integer), Vector((yyvsp[(5) - (7)].real),(yyvsp[(6) - (7)].real)), (yyvsp[(7) - (7)].str));;} + break; + + case 438: +#line 1161 "frame/parser.Y" + {fr->getDataValuesCmd(Vector((yyvsp[(2) - (5)].real),(yyvsp[(3) - (5)].real)),(Coord::InternalSystem)(yyvsp[(1) - (5)].integer), + Vector((yyvsp[(4) - (5)].integer),(yyvsp[(5) - (5)].integer)));;} + break; + + case 439: +#line 1165 "frame/parser.Y" + {fr->getInfoCmd((yyvsp[(1) - (1)].str));;} + break; + + case 440: +#line 1166 "frame/parser.Y" + {fr->getInfoClipCmd();;} + break; + + case 441: +#line 1168 "frame/parser.Y" + {fr->getInfoCmd(Vector((yyvsp[(2) - (4)].real),(yyvsp[(3) - (4)].real)), (Coord::InternalSystem)(yyvsp[(1) - (4)].integer), (yyvsp[(4) - (4)].str));;} + break; + + case 442: +#line 1171 "frame/parser.Y" + {fr->iisGetCmd((char*)(yyvsp[(1) - (5)].ptr),(yyvsp[(2) - (5)].integer),(yyvsp[(3) - (5)].integer),(yyvsp[(4) - (5)].integer),(yyvsp[(5) - (5)].integer));;} + break; + + case 443: +#line 1172 "frame/parser.Y" + {fr->iisGetCursorCmd();;} + break; + + case 445: +#line 1176 "frame/parser.Y" + {fr->iisGetFileNameCmd();;} + break; + + case 446: +#line 1177 "frame/parser.Y" + {fr->iisGetFileNameCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 447: +#line 1178 "frame/parser.Y" + {fr->iisGetFileNameCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 448: +#line 1181 "frame/parser.Y" + {fr->getFitsNAxesCmd();;} + break; + + case 449: +#line 1183 "frame/parser.Y" + {fr->getFitsCenterCmd((Coord::CoordSystem)(yyvsp[(2) - (4)].integer),(Coord::SkyFrame)(yyvsp[(3) - (4)].integer),(Coord::SkyFormat)(yyvsp[(4) - (4)].integer));;} + break; + + case 450: +#line 1184 "frame/parser.Y" + {fr->getFitsCountCmd();;} + break; + + case 452: +#line 1186 "frame/parser.Y" + {fr->getBitpixCmd();;} + break; + + case 456: +#line 1190 "frame/parser.Y" + {fr->getFitsHeightCmd();;} + break; + + case 457: +#line 1191 "frame/parser.Y" + {fr->getFitsObjectNameCmd();;} + break; + + case 458: +#line 1192 "frame/parser.Y" + {fr->getFitsSizeCmd();;} + break; + + case 459: +#line 1194 "frame/parser.Y" + {fr->getFitsSizeCmd((Coord::CoordSystem)(yyvsp[(2) - (4)].integer),(Coord::SkyFrame)(yyvsp[(3) - (4)].integer),(Coord::SkyDist)(yyvsp[(4) - (4)].integer));;} + break; + + case 461: +#line 1196 "frame/parser.Y" + {fr->getFitsWidthCmd();;} + break; + + case 462: +#line 1199 "frame/parser.Y" + {fr->getFitsExtCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 463: +#line 1201 "frame/parser.Y" + {fr->getFitsExtCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)),(Coord::InternalSystem)(yyvsp[(1) - (3)].integer));;} + break; + + case 464: +#line 1203 "frame/parser.Y" + {fr->getFitsHeaderCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 465: +#line 1204 "frame/parser.Y" + {fr->getFitsHeaderKeywordCmd(1,(yyvsp[(2) - (2)].str));;} + break; + + case 466: +#line 1205 "frame/parser.Y" + {fr->getFitsHeaderKeywordCmd((yyvsp[(1) - (3)].integer),(yyvsp[(3) - (3)].str));;} + break; + + case 467: +#line 1206 "frame/parser.Y" + {fr->getFitsHeaderWCSCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 468: +#line 1209 "frame/parser.Y" + {fr->getFitsDepthCmd(2);;} + break; + + case 469: +#line 1210 "frame/parser.Y" + {fr->getFitsDepthCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 470: +#line 1214 "frame/parser.Y" + {fr->getFitsFileNameCmd((Base::FileNameType)(yyvsp[(1) - (1)].integer));;} + break; + + case 471: +#line 1216 "frame/parser.Y" + {fr->getFitsFileNameCmd(Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)), (Coord::InternalSystem)(yyvsp[(2) - (4)].integer), + (Base::FileNameType)(yyvsp[(1) - (4)].integer));;} + break; + + case 472: +#line 1219 "frame/parser.Y" + {fr->getFitsFileNameCmd((yyvsp[(2) - (2)].integer), (Base::FileNameType)(yyvsp[(1) - (2)].integer));;} + break; + + case 473: +#line 1222 "frame/parser.Y" + {fr->getFitsSliceCmd(2);;} + break; + + case 474: +#line 1223 "frame/parser.Y" + {fr->getFitsSliceCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 475: +#line 1224 "frame/parser.Y" + {fr->getFitsSliceCmd(2, (Coord::CoordSystem)(yyvsp[(1) - (1)].integer));;} + break; + + case 476: +#line 1225 "frame/parser.Y" + {fr->getFitsSliceCmd((yyvsp[(1) - (2)].integer), (Coord::CoordSystem)(yyvsp[(2) - (2)].integer));;} + break; + + case 477: +#line 1228 "frame/parser.Y" + {fr->getGridCmd();;} + break; + + case 478: +#line 1229 "frame/parser.Y" + {fr->getGridOptionCmd();;} + break; + + case 479: +#line 1230 "frame/parser.Y" + {fr->getGridVarsCmd();;} + break; + + case 480: +#line 1233 "frame/parser.Y" + {fr->getMaskColorCmd();;} + break; + + case 481: +#line 1234 "frame/parser.Y" + {fr->getMaskMarkCmd();;} + break; + + case 482: +#line 1235 "frame/parser.Y" + {fr->getMaskTransparencyCmd();;} + break; + + case 483: +#line 1238 "frame/parser.Y" + {fr->getPanPreserveCmd();;} + break; + + case 484: +#line 1241 "frame/parser.Y" + {fr->getRGBChannelCmd();;} + break; + + case 485: +#line 1242 "frame/parser.Y" + {fr->getRGBSystemCmd();;} + break; + + case 486: +#line 1243 "frame/parser.Y" + {fr->getRGBViewCmd();;} + break; + + case 487: +#line 1246 "frame/parser.Y" + {fr->getSmoothFunctionCmd();;} + break; + + case 488: +#line 1247 "frame/parser.Y" + {fr->getSmoothRadiusCmd();;} + break; + + case 493: +#line 1254 "frame/parser.Y" + {fr->get3dRenderMethodCmd();;} + break; + + case 494: +#line 1255 "frame/parser.Y" + {fr->get3dRenderBackgroundCmd();;} + break; + + case 495: +#line 1256 "frame/parser.Y" + {fr->get3dScaleCmd();;} + break; + + case 496: +#line 1259 "frame/parser.Y" + {fr->get3dBorderCmd();;} + break; + + case 497: +#line 1260 "frame/parser.Y" + {fr->get3dBorderColorCmd();;} + break; + + case 498: +#line 1263 "frame/parser.Y" + {fr->get3dCompassCmd();;} + break; + + case 499: +#line 1264 "frame/parser.Y" + {fr->get3dCompassColorCmd();;} + break; + + case 500: +#line 1267 "frame/parser.Y" + {fr->get3dHighliteCmd();;} + break; + + case 501: +#line 1268 "frame/parser.Y" + {fr->get3dHighliteColorCmd();;} + break; + + case 502: +#line 1271 "frame/parser.Y" + {fr->get3dViewCmd();;} + break; + + case 503: +#line 1272 "frame/parser.Y" + {fr->get3dViewPointCmd();;} + break; + + case 504: +#line 1275 "frame/parser.Y" + {fr->getWCSCmd();;} + break; + + case 506: +#line 1277 "frame/parser.Y" + {fr->getWCSNameCmd((Coord::CoordSystem)(yyvsp[(2) - (2)].integer));;} + break; + + case 507: +#line 1280 "frame/parser.Y" + {fr->getWCSAlignCmd();;} + break; + + case 508: +#line 1281 "frame/parser.Y" + {fr->getWCSAlignPointerCmd();;} + break; + + case 510: +#line 1285 "frame/parser.Y" + {fr->gridDeleteCmd();;} + break; + + case 511: +#line 1289 "frame/parser.Y" + {fr->gridCmd((Coord::CoordSystem)(yyvsp[(1) - (6)].integer), (Coord::SkyFrame)(yyvsp[(2) - (6)].integer), + (Coord::SkyFormat)(yyvsp[(3) - (6)].integer), (Grid2d::GridType)(yyvsp[(4) - (6)].integer), (yyvsp[(5) - (6)].str), (yyvsp[(6) - (6)].str));;} + break; + + case 512: +#line 1292 "frame/parser.Y" + { + // backward compatibility with backup + fr->gridCmd((Coord::CoordSystem)(yyvsp[(1) - (5)].integer), (Coord::SkyFrame)(yyvsp[(2) - (5)].integer), + (Coord::SkyFormat)(yyvsp[(3) - (5)].integer), (Grid2d::GridType)(yyvsp[(4) - (5)].integer), (yyvsp[(5) - (5)].str), ""); + ;} + break; + + case 513: +#line 1299 "frame/parser.Y" + {(yyval.integer)=Grid2d::ANALYSIS;;} + break; + + case 514: +#line 1300 "frame/parser.Y" + {(yyval.integer)=Grid2d::PUBLICATION;;} + break; + + case 515: +#line 1303 "frame/parser.Y" + {fr->hasAmplifierCmd();;} + break; + + case 518: +#line 1306 "frame/parser.Y" + {fr->hasCropCmd();;} + break; + + case 519: +#line 1307 "frame/parser.Y" + {fr->hasDATAMINCmd();;} + break; + + case 520: +#line 1308 "frame/parser.Y" + {fr->hasDATASECCmd();;} + break; + + case 521: +#line 1309 "frame/parser.Y" + {fr->hasDetectorCmd();;} + break; + + case 523: +#line 1311 "frame/parser.Y" + {fr->hasGridCmd();;} + break; + + case 524: +#line 1312 "frame/parser.Y" + {fr->hasIISCmd();;} + break; + + case 525: +#line 1313 "frame/parser.Y" + {fr->hasIRAFMINCmd();;} + break; + + case 527: +#line 1315 "frame/parser.Y" + {fr->hasPhysicalCmd();;} + break; + + case 528: +#line 1316 "frame/parser.Y" + {fr->hasSmoothCmd();;} + break; + + case 529: +#line 1317 "frame/parser.Y" + {fr->hasSystemCmd((Coord::CoordSystem)(yyvsp[(2) - (2)].integer));;} + break; + + case 531: +#line 1321 "frame/parser.Y" + {fr->hasBinColCmd((yyvsp[(2) - (2)].str));;} + break; + + case 532: +#line 1324 "frame/parser.Y" + {fr->hasContourCmd();;} + break; + + case 533: +#line 1325 "frame/parser.Y" + {fr->hasContourAuxCmd();;} + break; + + case 534: +#line 1328 "frame/parser.Y" + {fr->hasFitsCmd();;} + break; + + case 535: +#line 1329 "frame/parser.Y" + {fr->hasFitsBinCmd();;} + break; + + case 536: +#line 1330 "frame/parser.Y" + {fr->hasFitsCubeCmd();;} + break; + + case 537: +#line 1331 "frame/parser.Y" + {fr->hasFitsMosaicCmd();;} + break; + + case 538: +#line 1334 "frame/parser.Y" + {fr->hasMarkerHighlitedCmd();;} + break; + + case 539: +#line 1335 "frame/parser.Y" + {fr->hasMarkerSelectedCmd();;} + break; + + case 540: +#line 1336 "frame/parser.Y" + {fr->hasMarkerPasteCmd();;} + break; + + case 541: +#line 1337 "frame/parser.Y" + {fr->hasMarkerUndoCmd();;} + break; + + case 542: +#line 1340 "frame/parser.Y" + {fr->hasWCSCmd((Coord::CoordSystem)(yyvsp[(1) - (1)].integer));;} + break; + + case 543: +#line 1341 "frame/parser.Y" + {fr->hasWCSEquCmd((Coord::CoordSystem)(yyvsp[(2) - (2)].integer));;} + break; + + case 544: +#line 1342 "frame/parser.Y" + {fr->hasWCSCelCmd((Coord::CoordSystem)(yyvsp[(2) - (2)].integer));;} + break; + + case 545: +#line 1343 "frame/parser.Y" + {fr->hasWCSAltCmd();;} + break; + + case 546: +#line 1344 "frame/parser.Y" + {fr->hasWCSxCmd((Coord::CoordSystem)(yyvsp[(2) - (2)].integer));;} + break; + + case 547: +#line 1347 "frame/parser.Y" + {fr->iisCmd((yyvsp[(2) - (3)].integer),(yyvsp[(3) - (3)].integer));;} + break; + + case 548: +#line 1348 "frame/parser.Y" + {fr->iisEraseCmd();;} + break; + + case 549: +#line 1349 "frame/parser.Y" + {fr->iisMessageCmd((yyvsp[(2) - (2)].str));;} + break; + + case 552: +#line 1353 "frame/parser.Y" + {fr->iisSetCmd((const char*)(yyvsp[(2) - (6)].ptr),(yyvsp[(3) - (6)].integer),(yyvsp[(4) - (6)].integer),(yyvsp[(5) - (6)].integer),(yyvsp[(6) - (6)].integer));;} + break; + + case 553: +#line 1354 "frame/parser.Y" + {fr->iisUpdateCmd();;} + break; + + case 554: +#line 1357 "frame/parser.Y" + {fr->iisWCSCmd(Matrix((yyvsp[(2) - (10)].real),(yyvsp[(3) - (10)].real),(yyvsp[(4) - (10)].real),(yyvsp[(5) - (10)].real),(yyvsp[(6) - (10)].real),(yyvsp[(7) - (10)].real)),Vector((yyvsp[(8) - (10)].real),(yyvsp[(9) - (10)].real)),(yyvsp[(10) - (10)].integer));;} + break; + + case 555: +#line 1360 "frame/parser.Y" + {fr->iisSetFileNameCmd((yyvsp[(1) - (1)].str));;} + break; + + case 556: +#line 1361 "frame/parser.Y" + {fr->iisSetFileNameCmd((yyvsp[(1) - (2)].str),(yyvsp[(2) - (2)].integer));;} + break; + + case 557: +#line 1365 "frame/parser.Y" + {fr->iisSetCursorCmd(Vector((yyvsp[(1) - (3)].integer),(yyvsp[(2) - (3)].integer)),Coord::CANVAS);;} + break; + + case 558: +#line 1367 "frame/parser.Y" + {fr->iisSetCursorCmd(Vector((yyvsp[(1) - (3)].integer),(yyvsp[(2) - (3)].integer)),(Coord::CoordSystem)(yyvsp[(3) - (3)].integer));;} + break; + + case 559: +#line 1368 "frame/parser.Y" + {fr->iisCursorModeCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 566: +#line 1380 "frame/parser.Y" + {fr->loadArrAllocCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 567: +#line 1382 "frame/parser.Y" + {fr->loadArrAllocGZCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 568: +#line 1384 "frame/parser.Y" + {fr->loadArrChannelCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 569: +#line 1385 "frame/parser.Y" + {fr->loadArrMMapCmd((yyvsp[(1) - (3)].str), (Base::LayerType)(yyvsp[(3) - (3)].integer));;} + break; + + case 570: +#line 1387 "frame/parser.Y" + {fr->loadArrMMapIncrCmd((yyvsp[(1) - (3)].str), (Base::LayerType)(yyvsp[(3) - (3)].integer));;} + break; + + case 571: +#line 1389 "frame/parser.Y" + {fr->loadArrShareCmd((Base::ShmType)(yyvsp[(3) - (5)].integer), (yyvsp[(4) - (5)].integer), (yyvsp[(1) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 572: +#line 1391 "frame/parser.Y" + {fr->loadArrSocketCmd((yyvsp[(3) - (4)].integer), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 573: +#line 1393 "frame/parser.Y" + {fr->loadArrSocketGZCmd((yyvsp[(3) - (4)].integer), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 574: +#line 1395 "frame/parser.Y" + {fr->loadArrVarCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 576: +#line 1399 "frame/parser.Y" + {fr->loadArrayRGBCubeAllocCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 577: +#line 1400 "frame/parser.Y" + {fr->loadArrayRGBCubeAllocGZCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 578: +#line 1401 "frame/parser.Y" + {fr->loadArrayRGBCubeChannelCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 579: +#line 1402 "frame/parser.Y" + {fr->loadArrayRGBCubeMMapCmd((yyvsp[(1) - (2)].str));;} + break; + + case 580: +#line 1403 "frame/parser.Y" + {fr->loadArrayRGBCubeMMapIncrCmd((yyvsp[(1) - (2)].str));;} + break; + + case 581: +#line 1405 "frame/parser.Y" + {fr->loadArrayRGBCubeShareCmd((Base::ShmType)(yyvsp[(3) - (4)].integer), (yyvsp[(4) - (4)].integer), (yyvsp[(1) - (4)].str));;} + break; + + case 582: +#line 1406 "frame/parser.Y" + {fr->loadArrayRGBCubeSocketCmd((yyvsp[(3) - (3)].integer), (yyvsp[(1) - (3)].str));;} + break; + + case 583: +#line 1407 "frame/parser.Y" + {fr->loadArrayRGBCubeSocketGZCmd((yyvsp[(3) - (3)].integer), (yyvsp[(1) - (3)].str));;} + break; + + case 584: +#line 1408 "frame/parser.Y" + {fr->loadArrayRGBCubeVarCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 585: +#line 1411 "frame/parser.Y" + {fr->loadENVISMMapCmd((yyvsp[(1) - (3)].str),(yyvsp[(2) - (3)].str));;} + break; + + case 586: +#line 1415 "frame/parser.Y" + {fr->loadFitsAllocCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 587: +#line 1417 "frame/parser.Y" + {fr->loadFitsAllocGZCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 588: +#line 1419 "frame/parser.Y" + {fr->loadFitsChannelCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 589: +#line 1421 "frame/parser.Y" + {fr->loadFitsMMapCmd((yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 590: +#line 1423 "frame/parser.Y" + {fr->loadFitsSMMapCmd((yyvsp[(1) - (5)].str), (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 591: +#line 1425 "frame/parser.Y" + {fr->loadFitsMMapIncrCmd((yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 592: +#line 1427 "frame/parser.Y" + {fr->loadFitsShareCmd((Base::ShmType)(yyvsp[(3) - (6)].integer), (yyvsp[(4) - (6)].integer), (yyvsp[(1) - (6)].str), (Base::LayerType)(yyvsp[(6) - (6)].integer));;} + break; + + case 593: +#line 1429 "frame/parser.Y" + {fr->loadFitsSShareCmd((Base::ShmType)(yyvsp[(3) - (7)].integer), (yyvsp[(4) - (7)].integer), (yyvsp[(5) - (7)].integer), (yyvsp[(1) - (7)].str), + (Base::LayerType)(yyvsp[(7) - (7)].integer));;} + break; + + case 594: +#line 1432 "frame/parser.Y" + {fr->loadFitsSocketCmd((yyvsp[(3) - (4)].integer), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 595: +#line 1434 "frame/parser.Y" + {fr->loadFitsSocketGZCmd((yyvsp[(3) - (4)].integer), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 596: +#line 1436 "frame/parser.Y" + {fr->loadFitsVarCmd((yyvsp[(3) - (5)].str), (yyvsp[(1) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 602: +#line 1444 "frame/parser.Y" + {fr->loadSliceAllocCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 603: +#line 1445 "frame/parser.Y" + {fr->loadSliceAllocGZCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 604: +#line 1446 "frame/parser.Y" + {fr->loadSliceChannelCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 605: +#line 1447 "frame/parser.Y" + {fr->loadSliceMMapCmd((yyvsp[(1) - (3)].str));;} + break; + + case 606: +#line 1448 "frame/parser.Y" + {fr->loadSliceSMMapCmd((yyvsp[(1) - (4)].str), (yyvsp[(2) - (4)].str));;} + break; + + case 607: +#line 1449 "frame/parser.Y" + {fr->loadSliceMMapIncrCmd((yyvsp[(1) - (3)].str));;} + break; + + case 608: +#line 1451 "frame/parser.Y" + {fr->loadSliceShareCmd((Base::ShmType)(yyvsp[(3) - (5)].integer), (yyvsp[(4) - (5)].integer), (yyvsp[(1) - (5)].str));;} + break; + + case 609: +#line 1453 "frame/parser.Y" + {fr->loadSliceSShareCmd((Base::ShmType)(yyvsp[(3) - (6)].integer), (yyvsp[(4) - (6)].integer), (yyvsp[(5) - (6)].integer), (yyvsp[(1) - (6)].str));;} + break; + + case 610: +#line 1454 "frame/parser.Y" + {fr->loadSliceSocketCmd((yyvsp[(3) - (3)].integer), (yyvsp[(1) - (3)].str));;} + break; + + case 611: +#line 1455 "frame/parser.Y" + {fr->loadSliceSocketGZCmd((yyvsp[(3) - (3)].integer), (yyvsp[(1) - (3)].str));;} + break; + + case 612: +#line 1456 "frame/parser.Y" + {fr->loadSliceVarCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str));;} + break; + + case 613: +#line 1459 "frame/parser.Y" + {fr->loadExtCubeAllocCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 614: +#line 1460 "frame/parser.Y" + {fr->loadExtCubeAllocGZCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 615: +#line 1461 "frame/parser.Y" + {fr->loadExtCubeChannelCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 616: +#line 1462 "frame/parser.Y" + {fr->loadExtCubeMMapCmd((yyvsp[(1) - (3)].str));;} + break; + + case 617: +#line 1463 "frame/parser.Y" + {fr->loadExtCubeMMapIncrCmd((yyvsp[(1) - (3)].str));;} + break; + + case 618: +#line 1465 "frame/parser.Y" + {fr->loadExtCubeShareCmd((Base::ShmType)(yyvsp[(3) - (5)].integer), (yyvsp[(4) - (5)].integer), (yyvsp[(1) - (5)].str));;} + break; + + case 619: +#line 1466 "frame/parser.Y" + {fr->loadExtCubeSocketCmd((yyvsp[(3) - (3)].integer), (yyvsp[(1) - (3)].str));;} + break; + + case 620: +#line 1467 "frame/parser.Y" + {fr->loadExtCubeSocketGZCmd((yyvsp[(3) - (3)].integer), (yyvsp[(1) - (3)].str));;} + break; + + case 621: +#line 1468 "frame/parser.Y" + {fr->loadExtCubeVarCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str));;} + break; + + case 627: +#line 1479 "frame/parser.Y" + {fr->loadMosaicImageAllocCmd(Base::IRAF, Coord::WCS, + (yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 628: +#line 1482 "frame/parser.Y" + {fr->loadMosaicImageAllocGZCmd(Base::IRAF, Coord::WCS, + (yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str),(Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 629: +#line 1485 "frame/parser.Y" + {fr->loadMosaicImageChannelCmd(Base::IRAF, Coord::WCS, + (yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str),(Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 630: +#line 1488 "frame/parser.Y" + {fr->loadMosaicImageMMapCmd(Base::IRAF, Coord::WCS, + (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 631: +#line 1491 "frame/parser.Y" + {fr->loadMosaicImageMMapIncrCmd(Base::IRAF, Coord::WCS, + (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 632: +#line 1494 "frame/parser.Y" + {fr->loadMosaicImageShareCmd(Base::IRAF, Coord::WCS, + (Base::ShmType)(yyvsp[(3) - (6)].integer), (yyvsp[(4) - (6)].integer), (yyvsp[(1) - (6)].str), (Base::LayerType)(yyvsp[(6) - (6)].integer));;} + break; + + case 633: +#line 1497 "frame/parser.Y" + {fr->loadMosaicImageSocketCmd(Base::IRAF, Coord::WCS, + (yyvsp[(3) - (4)].integer), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 634: +#line 1500 "frame/parser.Y" + {fr->loadMosaicImageSocketGZCmd(Base::IRAF, Coord::WCS, + (yyvsp[(3) - (4)].integer), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 635: +#line 1503 "frame/parser.Y" + {fr->loadMosaicImageVarCmd(Base::IRAF, Coord::WCS, + (yyvsp[(3) - (5)].str), (yyvsp[(1) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 636: +#line 1508 "frame/parser.Y" + {fr->loadMosaicAllocCmd(Base::IRAF, Coord::WCS, + (yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 637: +#line 1511 "frame/parser.Y" + {fr->loadMosaicAllocGZCmd(Base::IRAF, Coord::WCS, + (yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 638: +#line 1514 "frame/parser.Y" + {fr->loadMosaicChannelCmd(Base::IRAF, Coord::WCS, + (yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 639: +#line 1517 "frame/parser.Y" + {fr->loadMosaicMMapCmd(Base::IRAF, Coord::WCS, + (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 640: +#line 1520 "frame/parser.Y" + {fr->loadMosaicSMMapCmd(Base::IRAF, Coord::WCS, + (yyvsp[(1) - (5)].str), (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 641: +#line 1523 "frame/parser.Y" + {fr->loadMosaicMMapIncrCmd(Base::IRAF, Coord::WCS, + (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 642: +#line 1526 "frame/parser.Y" + {fr->loadMosaicShareCmd(Base::IRAF, Coord::WCS, + (Base::ShmType)(yyvsp[(3) - (6)].integer), (yyvsp[(4) - (6)].integer), (yyvsp[(1) - (6)].str), (Base::LayerType)(yyvsp[(6) - (6)].integer));;} + break; + + case 643: +#line 1529 "frame/parser.Y" + {fr->loadMosaicSShareCmd(Base::IRAF, Coord::WCS, + (Base::ShmType)(yyvsp[(3) - (7)].integer), (yyvsp[(4) - (7)].integer), (yyvsp[(5) - (7)].integer), (yyvsp[(1) - (7)].str), (Base::LayerType)(yyvsp[(7) - (7)].integer));;} + break; + + case 644: +#line 1532 "frame/parser.Y" + {fr->loadMosaicSocketCmd(Base::IRAF, Coord::WCS, + (yyvsp[(3) - (4)].integer), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 645: +#line 1535 "frame/parser.Y" + {fr->loadMosaicSocketGZCmd(Base::IRAF, Coord::WCS, + (yyvsp[(3) - (4)].integer), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 646: +#line 1538 "frame/parser.Y" + {fr->loadMosaicVarCmd(Base::IRAF, Coord::WCS, + (yyvsp[(3) - (5)].str), (yyvsp[(1) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 647: +#line 1543 "frame/parser.Y" + {fr->loadMosaicImageAllocCmd(Base::WCSMOSAIC, (Coord::CoordSystem)(yyvsp[(1) - (5)].integer), + (yyvsp[(4) - (5)].str), (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 648: +#line 1546 "frame/parser.Y" + {fr->loadMosaicImageAllocGZCmd(Base::WCSMOSAIC, + (Coord::CoordSystem)(yyvsp[(1) - (5)].integer), (yyvsp[(4) - (5)].str), (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 649: +#line 1549 "frame/parser.Y" + {fr->loadMosaicImageChannelCmd(Base::WCSMOSAIC, + (Coord::CoordSystem)(yyvsp[(1) - (5)].integer), (yyvsp[(4) - (5)].str), (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 650: +#line 1552 "frame/parser.Y" + {fr->loadMosaicImageMMapCmd(Base::WCSMOSAIC, (Coord::CoordSystem)(yyvsp[(1) - (5)].integer), + (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 651: +#line 1555 "frame/parser.Y" + {fr->loadMosaicImageMMapIncrCmd(Base::WCSMOSAIC, + (Coord::CoordSystem)(yyvsp[(1) - (5)].integer), (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 652: +#line 1558 "frame/parser.Y" + {fr->loadMosaicImageShareCmd(Base::WCSMOSAIC, (Coord::CoordSystem)(yyvsp[(1) - (7)].integer), + (Base::ShmType)(yyvsp[(4) - (7)].integer), (yyvsp[(5) - (7)].integer), (yyvsp[(2) - (7)].str), (Base::LayerType)(yyvsp[(7) - (7)].integer));;} + break; + + case 653: +#line 1561 "frame/parser.Y" + {fr->loadMosaicImageSocketCmd(Base::WCSMOSAIC, (Coord::CoordSystem)(yyvsp[(1) - (5)].integer), + (yyvsp[(4) - (5)].integer), (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 654: +#line 1564 "frame/parser.Y" + {fr->loadMosaicImageSocketGZCmd(Base::WCSMOSAIC, + (Coord::CoordSystem)(yyvsp[(1) - (5)].integer), (yyvsp[(4) - (5)].integer), (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 655: +#line 1567 "frame/parser.Y" + {fr->loadMosaicImageVarCmd(Base::WCSMOSAIC, (Coord::CoordSystem)(yyvsp[(1) - (6)].integer), + (yyvsp[(4) - (6)].str), (yyvsp[(2) - (6)].str), (Base::LayerType)(yyvsp[(6) - (6)].integer));;} + break; + + case 656: +#line 1572 "frame/parser.Y" + {fr->loadMosaicAllocCmd((Base::WCSMOSAIC), (Coord::CoordSystem)(yyvsp[(1) - (5)].integer), + (yyvsp[(4) - (5)].str), (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 657: +#line 1575 "frame/parser.Y" + {fr->loadMosaicAllocGZCmd((Base::WCSMOSAIC), (Coord::CoordSystem)(yyvsp[(1) - (5)].integer), + (yyvsp[(4) - (5)].str), (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 658: +#line 1578 "frame/parser.Y" + {fr->loadMosaicChannelCmd((Base::WCSMOSAIC), (Coord::CoordSystem)(yyvsp[(1) - (5)].integer), + (yyvsp[(4) - (5)].str), (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 659: +#line 1581 "frame/parser.Y" + {fr->loadMosaicMMapCmd((Base::WCSMOSAIC), (Coord::CoordSystem)(yyvsp[(1) - (5)].integer), + (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 660: +#line 1584 "frame/parser.Y" + {fr->loadMosaicSMMapCmd((Base::WCSMOSAIC), (Coord::CoordSystem)(yyvsp[(1) - (6)].integer), + (yyvsp[(2) - (6)].str), (yyvsp[(3) - (6)].str), (Base::LayerType)(yyvsp[(6) - (6)].integer));;} + break; + + case 661: +#line 1587 "frame/parser.Y" + {fr->loadMosaicMMapIncrCmd((Base::WCSMOSAIC), (Coord::CoordSystem)(yyvsp[(1) - (5)].integer), + (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 662: +#line 1590 "frame/parser.Y" + {fr->loadMosaicShareCmd((Base::WCSMOSAIC), (Coord::CoordSystem)(yyvsp[(1) - (7)].integer), + (Base::ShmType)(yyvsp[(4) - (7)].integer), (yyvsp[(5) - (7)].integer), (yyvsp[(2) - (7)].str), (Base::LayerType)(yyvsp[(7) - (7)].integer));;} + break; + + case 663: +#line 1593 "frame/parser.Y" + {fr->loadMosaicSShareCmd((Base::WCSMOSAIC), (Coord::CoordSystem)(yyvsp[(1) - (8)].integer), + (Base::ShmType)(yyvsp[(4) - (8)].integer), (yyvsp[(5) - (8)].integer), (yyvsp[(6) - (8)].integer), (yyvsp[(2) - (8)].str), (Base::LayerType)(yyvsp[(8) - (8)].integer));;} + break; + + case 664: +#line 1596 "frame/parser.Y" + {fr->loadMosaicSocketCmd((Base::WCSMOSAIC), (Coord::CoordSystem)(yyvsp[(1) - (5)].integer), + (yyvsp[(4) - (5)].integer), (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 665: +#line 1599 "frame/parser.Y" + {fr->loadMosaicSocketGZCmd((Base::WCSMOSAIC), (Coord::CoordSystem)(yyvsp[(1) - (5)].integer), + (yyvsp[(4) - (5)].integer), (yyvsp[(2) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 666: +#line 1602 "frame/parser.Y" + {fr->loadMosaicVarCmd((Base::WCSMOSAIC), (Coord::CoordSystem)(yyvsp[(1) - (6)].integer), + (yyvsp[(4) - (6)].str), (yyvsp[(2) - (6)].str), (Base::LayerType)(yyvsp[(6) - (6)].integer));;} + break; + + case 667: +#line 1607 "frame/parser.Y" + {fr->loadMosaicImageWFPC2AllocCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 668: +#line 1608 "frame/parser.Y" + {fr->loadMosaicImageWFPC2AllocGZCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 669: +#line 1609 "frame/parser.Y" + {fr->loadMosaicImageWFPC2ChannelCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 670: +#line 1610 "frame/parser.Y" + {fr->loadMosaicImageWFPC2MMapCmd((yyvsp[(1) - (3)].str));;} + break; + + case 671: +#line 1611 "frame/parser.Y" + {fr->loadMosaicImageWFPC2MMapIncrCmd((yyvsp[(1) - (3)].str));;} + break; + + case 672: +#line 1613 "frame/parser.Y" + {fr->loadMosaicImageWFPC2ShareCmd((Base::ShmType)(yyvsp[(3) - (5)].integer), (yyvsp[(4) - (5)].integer), (yyvsp[(1) - (5)].str));;} + break; + + case 673: +#line 1614 "frame/parser.Y" + {fr->loadMosaicImageWFPC2SocketCmd((yyvsp[(3) - (3)].integer), (yyvsp[(1) - (3)].str));;} + break; + + case 674: +#line 1615 "frame/parser.Y" + {fr->loadMosaicImageWFPC2SocketGZCmd((yyvsp[(3) - (3)].integer), (yyvsp[(1) - (3)].str));;} + break; + + case 675: +#line 1616 "frame/parser.Y" + {fr->loadMosaicImageWFPC2VarCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str));;} + break; + + case 676: +#line 1618 "frame/parser.Y" + {fr->loadRGBCubeAllocCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 677: +#line 1619 "frame/parser.Y" + {fr->loadRGBCubeAllocGZCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 678: +#line 1620 "frame/parser.Y" + {fr->loadRGBCubeChannelCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 679: +#line 1621 "frame/parser.Y" + {fr->loadRGBCubeMMapCmd((yyvsp[(1) - (3)].str));;} + break; + + case 680: +#line 1622 "frame/parser.Y" + {fr->loadRGBCubeSMMapCmd((yyvsp[(1) - (4)].str), (yyvsp[(2) - (4)].str));;} + break; + + case 681: +#line 1623 "frame/parser.Y" + {fr->loadRGBCubeMMapIncrCmd((yyvsp[(1) - (3)].str));;} + break; + + case 682: +#line 1625 "frame/parser.Y" + {fr->loadRGBCubeShareCmd((Base::ShmType)(yyvsp[(3) - (5)].integer), (yyvsp[(4) - (5)].integer), (yyvsp[(1) - (5)].str));;} + break; + + case 683: +#line 1627 "frame/parser.Y" + {fr->loadRGBCubeSShareCmd((Base::ShmType)(yyvsp[(3) - (6)].integer), (yyvsp[(4) - (6)].integer), (yyvsp[(5) - (6)].integer), (yyvsp[(1) - (6)].str));;} + break; + + case 684: +#line 1628 "frame/parser.Y" + {fr->loadRGBCubeSocketCmd((yyvsp[(3) - (3)].integer), (yyvsp[(1) - (3)].str));;} + break; + + case 685: +#line 1629 "frame/parser.Y" + {fr->loadRGBCubeSocketGZCmd((yyvsp[(3) - (3)].integer), (yyvsp[(1) - (3)].str));;} + break; + + case 686: +#line 1630 "frame/parser.Y" + {fr->loadRGBCubeVarCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str));;} + break; + + case 687: +#line 1633 "frame/parser.Y" + {fr->loadRGBImageAllocCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 688: +#line 1634 "frame/parser.Y" + {fr->loadRGBImageAllocGZCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 689: +#line 1635 "frame/parser.Y" + {fr->loadRGBImageChannelCmd((yyvsp[(3) - (3)].str), (yyvsp[(1) - (3)].str));;} + break; + + case 690: +#line 1636 "frame/parser.Y" + {fr->loadRGBImageMMapCmd((yyvsp[(1) - (3)].str));;} + break; + + case 691: +#line 1637 "frame/parser.Y" + {fr->loadRGBImageMMapIncrCmd((yyvsp[(1) - (3)].str));;} + break; + + case 692: +#line 1639 "frame/parser.Y" + {fr->loadRGBImageShareCmd((Base::ShmType)(yyvsp[(3) - (5)].integer), (yyvsp[(4) - (5)].integer), (yyvsp[(1) - (5)].str));;} + break; + + case 693: +#line 1640 "frame/parser.Y" + {fr->loadRGBImageSocketCmd((yyvsp[(3) - (3)].integer), (yyvsp[(1) - (3)].str));;} + break; + + case 694: +#line 1641 "frame/parser.Y" + {fr->loadRGBImageSocketGZCmd((yyvsp[(3) - (3)].integer), (yyvsp[(1) - (3)].str));;} + break; + + case 695: +#line 1642 "frame/parser.Y" + {fr->loadRGBImageVarCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str));;} + break; + + case 696: +#line 1646 "frame/parser.Y" + {fr->loadNRRDAllocCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 697: +#line 1648 "frame/parser.Y" + {fr->loadNRRDChannelCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 698: +#line 1649 "frame/parser.Y" + {fr->loadNRRDMMapCmd((yyvsp[(1) - (3)].str), (Base::LayerType)(yyvsp[(3) - (3)].integer));;} + break; + + case 699: +#line 1651 "frame/parser.Y" + {fr->loadNRRDShareCmd((Base::ShmType)(yyvsp[(3) - (5)].integer), (yyvsp[(4) - (5)].integer), (yyvsp[(1) - (5)].str), (Base::LayerType)(yyvsp[(5) - (5)].integer));;} + break; + + case 700: +#line 1653 "frame/parser.Y" + {fr->loadNRRDSocketCmd((yyvsp[(3) - (4)].integer), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 701: +#line 1655 "frame/parser.Y" + {fr->loadNRRDVarCmd((yyvsp[(3) - (4)].str), (yyvsp[(1) - (4)].str), (Base::LayerType)(yyvsp[(4) - (4)].integer));;} + break; + + case 702: +#line 1658 "frame/parser.Y" + {fr->loadPhotoCmd((yyvsp[(1) - (2)].str),(yyvsp[(2) - (2)].str));;} + break; + + case 703: +#line 1659 "frame/parser.Y" + {fr->loadSlicePhotoCmd((yyvsp[(2) - (3)].str),(yyvsp[(3) - (3)].str));;} + break; + + case 704: +#line 1662 "frame/parser.Y" + {fr->loadIncrDataCmd((yyvsp[(2) - (6)].integer),(yyvsp[(3) - (6)].integer),(yyvsp[(4) - (6)].integer),(yyvsp[(5) - (6)].integer),(yyvsp[(6) - (6)].integer));;} + break; + + case 705: +#line 1663 "frame/parser.Y" + {fr->loadIncrMinMaxCmd((yyvsp[(2) - (6)].integer),(yyvsp[(3) - (6)].integer),(yyvsp[(4) - (6)].integer),(yyvsp[(5) - (6)].integer),(yyvsp[(6) - (6)].integer));;} + break; + + case 706: +#line 1664 "frame/parser.Y" + {fr->loadIncrEndCmd();;} + break; + + case 707: +#line 1667 "frame/parser.Y" + { +#ifdef MAC_OSX_TK + fr->macosxPrintCmd(); +#endif + ;} + break; + + case 708: +#line 1674 "frame/parser.Y" + {fr->magnifierCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 709: +#line 1675 "frame/parser.Y" + {fr->magnifierGraphicsCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 710: +#line 1676 "frame/parser.Y" + {fr->magnifierCursorCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 711: +#line 1677 "frame/parser.Y" + {fr->magnifierColorCmd((yyvsp[(2) - (2)].str));;} + break; + + case 712: +#line 1678 "frame/parser.Y" + {fr->magnifierCmd((yyvsp[(1) - (3)].str), (yyvsp[(2) - (3)].integer), (yyvsp[(3) - (3)].integer));;} + break; + + case 713: +#line 1679 "frame/parser.Y" + {fr->updateMagnifierCmd(Vector((yyvsp[(2) - (3)].real), (yyvsp[(3) - (3)].real)));;} + break; + + case 714: +#line 1680 "frame/parser.Y" + {fr->magnifierZoomCmd((yyvsp[(2) - (2)].real));;} + break; + + case 715: +#line 1684 "frame/parser.Y" + { + fr->matchCmd((yyvsp[(1) - (12)].str),(yyvsp[(2) - (12)].str),(Coord::CoordSystem)(yyvsp[(3) - (12)].integer),(Coord::SkyFrame)(yyvsp[(4) - (12)].integer), + (yyvsp[(5) - (12)].str),(yyvsp[(6) - (12)].str),(Coord::CoordSystem)(yyvsp[(7) - (12)].integer),(Coord::SkyFrame)(yyvsp[(8) - (12)].integer), + (yyvsp[(9) - (12)].real),(Coord::CoordSystem)(yyvsp[(10) - (12)].integer),(Coord::SkyDist)(yyvsp[(11) - (12)].integer), + (yyvsp[(12) - (12)].str)); + ;} + break; + + case 717: +#line 1692 "frame/parser.Y" + {fr->markerColorCmd((yyvsp[(2) - (2)].str));;} + break; + + case 718: +#line 1693 "frame/parser.Y" + {fr->markerCopyCmd();;} + break; + + case 719: +#line 1695 "frame/parser.Y" + {fr->markerCommandCmd((Base::MarkerFormat)(yyvsp[(2) - (3)].integer),(yyvsp[(3) - (3)].str));;} + break; + + case 720: +#line 1697 "frame/parser.Y" + {fr->markerCommandVarCmd((Base::MarkerFormat)(yyvsp[(2) - (4)].integer),(yyvsp[(4) - (4)].str));;} + break; + + case 721: +#line 1698 "frame/parser.Y" + {fr->markerCompositeDeleteCmd();;} + break; + + case 722: +#line 1699 "frame/parser.Y" + {maperr =0;;} + break; + + case 724: +#line 1700 "frame/parser.Y" + {fr->markerCutCmd();;} + break; + + case 725: +#line 1701 "frame/parser.Y" + {fr->markerDeleteCmd();;} + break; + + case 726: +#line 1702 "frame/parser.Y" + {fr->markerDeleteAllCmd();;} + break; + + case 728: +#line 1704 "frame/parser.Y" + {fr->markerEpsilonCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 729: +#line 1705 "frame/parser.Y" + {fr->markerFontCmd((yyvsp[(2) - (2)].str));;} + break; + + case 730: +#line 1707 "frame/parser.Y" + {fr->markerHighliteAllCmd();;} + break; + + case 731: +#line 1709 "frame/parser.Y" + {fr->markerHighliteOnlyCmd(Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)));;} + break; + + case 732: +#line 1711 "frame/parser.Y" + {fr->markerHighliteToggleCmd(Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)));;} + break; + + case 733: +#line 1714 "frame/parser.Y" + {fr->markerAnalysisCmd((yyvsp[(1) - (4)].integer), (Marker::AnalysisTask)(yyvsp[(3) - (4)].integer), (yyvsp[(4) - (4)].integer));;} + break; + + case 734: +#line 1716 "frame/parser.Y" + {fr->markerAngleCmd((yyvsp[(1) - (3)].integer),(yyvsp[(3) - (3)].real));;} + break; + + case 735: +#line 1717 "frame/parser.Y" + {fr->markerAngleCmd((yyvsp[(1) - (4)].integer),(yyvsp[(3) - (4)].real));;} + break; + + case 736: +#line 1719 "frame/parser.Y" + {fr->markerAngleCmd((yyvsp[(1) - (5)].integer),(yyvsp[(3) - (5)].real),(Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyFrame)(yyvsp[(5) - (5)].integer));;} + break; + + case 737: +#line 1722 "frame/parser.Y" + {fr->markerAnnulusRadiusCmd((yyvsp[(1) - (7)].integer), (yyvsp[(4) - (7)].real), (yyvsp[(5) - (7)].real), (yyvsp[(6) - (7)].integer), (Coord::InternalSystem)(yyvsp[(7) - (7)].integer));;} + break; + + case 738: +#line 1724 "frame/parser.Y" + {fr->markerAnnulusRadiusCmd((yyvsp[(1) - (8)].integer), (yyvsp[(4) - (8)].real), (yyvsp[(5) - (8)].real), (yyvsp[(6) - (8)].integer), + (Coord::CoordSystem)(yyvsp[(7) - (8)].integer), (Coord::SkyDist)(yyvsp[(8) - (8)].integer));;} + break; + + case 739: +#line 1727 "frame/parser.Y" + {fr->markerAnnulusRadiusCmd((yyvsp[(1) - (6)].integer), (yyvsp[(4) - (6)].str),(Coord::CoordSystem)(yyvsp[(5) - (6)].integer),(Coord::SkyDist)(yyvsp[(6) - (6)].integer));;} + break; + + case 740: +#line 1730 "frame/parser.Y" + {fr->markerBoxAnnulusRadiusCmd((yyvsp[(1) - (8)].integer), Vector((yyvsp[(4) - (8)].real), (yyvsp[(5) - (8)].real)), + Vector((yyvsp[(6) - (8)].real), (yyvsp[(6) - (8)].real)*(yyvsp[(5) - (8)].real)/(yyvsp[(4) - (8)].real)), (yyvsp[(7) - (8)].integer), (Coord::InternalSystem)(yyvsp[(8) - (8)].integer));;} + break; + + case 741: +#line 1734 "frame/parser.Y" + {fr->markerBoxAnnulusRadiusCmd((yyvsp[(1) - (9)].integer), Vector((yyvsp[(4) - (9)].real), (yyvsp[(5) - (9)].real)), + Vector((yyvsp[(6) - (9)].real), (yyvsp[(6) - (9)].real)*(yyvsp[(5) - (9)].real)/(yyvsp[(4) - (9)].real)), (yyvsp[(7) - (9)].integer), (Coord::CoordSystem)(yyvsp[(8) - (9)].integer), (Coord::SkyDist)(yyvsp[(9) - (9)].integer));;} + break; + + case 742: +#line 1737 "frame/parser.Y" + {fr->markerBoxAnnulusRadiusCmd((yyvsp[(1) - (6)].integer),(yyvsp[(4) - (6)].str),(Coord::CoordSystem)(yyvsp[(5) - (6)].integer),(Coord::SkyDist)(yyvsp[(6) - (6)].integer));;} + break; + + case 743: +#line 1740 "frame/parser.Y" + {fr->markerBoxRadiusCmd((yyvsp[(1) - (6)].integer), Vector((yyvsp[(4) - (6)].real),(yyvsp[(5) - (6)].real)), (Coord::InternalSystem)(yyvsp[(6) - (6)].integer));;} + break; + + case 744: +#line 1742 "frame/parser.Y" + {fr->markerBoxRadiusCmd((yyvsp[(1) - (7)].integer), Vector((yyvsp[(4) - (7)].real),(yyvsp[(5) - (7)].real)), + (Coord::CoordSystem)(yyvsp[(6) - (7)].integer), (Coord::SkyDist)(yyvsp[(7) - (7)].integer));;} + break; + + case 745: +#line 1745 "frame/parser.Y" + {fr->markerBpandaEditCmd((yyvsp[(1) - (10)].integer), (yyvsp[(4) - (10)].real), (yyvsp[(5) - (10)].real), (yyvsp[(6) - (10)].integer), + Vector((yyvsp[(7) - (10)].real),(yyvsp[(8) - (10)].real)), Vector((yyvsp[(9) - (10)].real),(yyvsp[(9) - (10)].real)*(yyvsp[(8) - (10)].real)/(yyvsp[(7) - (10)].real)), (yyvsp[(10) - (10)].integer));;} + break; + + case 746: +#line 1749 "frame/parser.Y" + {fr->markerBpandaEditCmd((yyvsp[(1) - (11)].integer), (yyvsp[(4) - (11)].real), (yyvsp[(5) - (11)].real), (yyvsp[(6) - (11)].integer), + Vector((yyvsp[(7) - (11)].real),(yyvsp[(8) - (11)].real)), Vector((yyvsp[(9) - (11)].real),(yyvsp[(9) - (11)].real)*(yyvsp[(8) - (11)].real)/(yyvsp[(7) - (11)].real)), (yyvsp[(10) - (11)].integer));;} + break; + + case 747: +#line 1753 "frame/parser.Y" + {fr->markerBpandaEditCmd((yyvsp[(1) - (12)].integer), (yyvsp[(4) - (12)].real), (yyvsp[(5) - (12)].real), (yyvsp[(6) - (12)].integer), + Vector((yyvsp[(7) - (12)].real),(yyvsp[(8) - (12)].real)), Vector((yyvsp[(9) - (12)].real),(yyvsp[(9) - (12)].real)*(yyvsp[(8) - (12)].real)/(yyvsp[(7) - (12)].real)), (yyvsp[(10) - (12)].integer), + (Coord::CoordSystem)(yyvsp[(11) - (12)].integer), (Coord::SkyFrame)(yyvsp[(12) - (12)].integer));;} + break; + + case 748: +#line 1758 "frame/parser.Y" + {fr->markerBpandaEditCmd((yyvsp[(1) - (9)].integer), (yyvsp[(4) - (9)].str), (yyvsp[(5) - (9)].str), + (Coord::CoordSystem)(yyvsp[(6) - (9)].integer), (Coord::SkyFrame)(yyvsp[(7) - (9)].integer), (Coord::CoordSystem)(yyvsp[(8) - (9)].integer), (Coord::SkyDist)(yyvsp[(9) - (9)].integer));;} + break; + + case 749: +#line 1762 "frame/parser.Y" + {fr->markerCallBackCmd((yyvsp[(1) - (5)].integer),(CallBack::Type)(yyvsp[(3) - (5)].integer),(yyvsp[(4) - (5)].str),(yyvsp[(5) - (5)].str));;} + break; + + case 750: +#line 1764 "frame/parser.Y" + {fr->markerCircleRadiusCmd((yyvsp[(1) - (5)].integer), (yyvsp[(4) - (5)].real), (Coord::InternalSystem)(yyvsp[(5) - (5)].integer));;} + break; + + case 751: +#line 1766 "frame/parser.Y" + {fr->markerCircleRadiusCmd((yyvsp[(1) - (6)].integer), (yyvsp[(4) - (6)].real), (Coord::CoordSystem)(yyvsp[(5) - (6)].integer), (Coord::SkyDist)(yyvsp[(6) - (6)].integer));;} + break; + + case 752: +#line 1767 "frame/parser.Y" + {fr->markerColorCmd((yyvsp[(1) - (3)].integer),(yyvsp[(3) - (3)].str));;} + break; + + case 753: +#line 1769 "frame/parser.Y" + {fr->markerCompassArrowCmd((yyvsp[(1) - (5)].integer),(yyvsp[(4) - (5)].integer),(yyvsp[(5) - (5)].integer));;} + break; + + case 754: +#line 1771 "frame/parser.Y" + {fr->markerCompassLabelCmd((yyvsp[(1) - (5)].integer),(yyvsp[(4) - (5)].str),(yyvsp[(5) - (5)].str));;} + break; + + case 755: +#line 1773 "frame/parser.Y" + {fr->markerCompassRadiusCmd((yyvsp[(1) - (5)].integer),(yyvsp[(4) - (5)].real),(Coord::InternalSystem)(yyvsp[(5) - (5)].integer));;} + break; + + case 756: +#line 1775 "frame/parser.Y" + {fr->markerCompassRadiusCmd((yyvsp[(1) - (6)].integer),(yyvsp[(4) - (6)].real),(Coord::CoordSystem)(yyvsp[(5) - (6)].integer),(Coord::SkyDist)(yyvsp[(6) - (6)].integer));;} + break; + + case 757: +#line 1777 "frame/parser.Y" + {fr->markerCompassSystemCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyFrame)(yyvsp[(5) - (5)].integer));;} + break; + + case 758: +#line 1778 "frame/parser.Y" + {fr->markerCompositeCmd((yyvsp[(1) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 759: +#line 1780 "frame/parser.Y" + {fr->markerCpandaEditCmd((yyvsp[(1) - (9)].integer), (yyvsp[(4) - (9)].real), (yyvsp[(5) - (9)].real), (yyvsp[(6) - (9)].integer), (yyvsp[(7) - (9)].real), (yyvsp[(8) - (9)].real), (yyvsp[(9) - (9)].integer));;} + break; + + case 760: +#line 1782 "frame/parser.Y" + {fr->markerCpandaEditCmd((yyvsp[(1) - (10)].integer), (yyvsp[(4) - (10)].real), (yyvsp[(5) - (10)].real), (yyvsp[(6) - (10)].integer), (yyvsp[(7) - (10)].real), (yyvsp[(8) - (10)].real), (yyvsp[(9) - (10)].integer));;} + break; + + case 761: +#line 1785 "frame/parser.Y" + {fr->markerCpandaEditCmd((yyvsp[(1) - (11)].integer), (yyvsp[(4) - (11)].real), (yyvsp[(5) - (11)].real), (yyvsp[(6) - (11)].integer), (yyvsp[(7) - (11)].real), (yyvsp[(8) - (11)].real), (yyvsp[(9) - (11)].integer), + (Coord::CoordSystem)(yyvsp[(10) - (11)].integer), (Coord::SkyFrame)(yyvsp[(11) - (11)].integer));;} + break; + + case 762: +#line 1789 "frame/parser.Y" + {fr->markerCpandaEditCmd((yyvsp[(1) - (9)].integer), (yyvsp[(4) - (9)].str), (yyvsp[(5) - (9)].str), (Coord::CoordSystem)(yyvsp[(6) - (9)].integer), (Coord::SkyFrame)(yyvsp[(7) - (9)].integer), + (Coord::CoordSystem)(yyvsp[(8) - (9)].integer), (Coord::SkyDist)(yyvsp[(9) - (9)].integer));;} + break; + + case 763: +#line 1793 "frame/parser.Y" + {fr->markerAnnulusCreateRadiusCmd((yyvsp[(1) - (6)].integer),Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real)));;} + break; + + case 764: +#line 1795 "frame/parser.Y" + {fr->markerBoxAnnulusCreateRadiusCmd((yyvsp[(1) - (6)].integer),Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real)));;} + break; + + case 765: +#line 1797 "frame/parser.Y" + {fr->markerBpandaCreateAnglesCmd((yyvsp[(1) - (6)].integer),Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real)));;} + break; + + case 766: +#line 1799 "frame/parser.Y" + {fr->markerBpandaCreateRadiusCmd((yyvsp[(1) - (6)].integer),Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real)));;} + break; + + case 767: +#line 1801 "frame/parser.Y" + {fr->markerEllipseAnnulusCreateRadiusCmd((yyvsp[(1) - (6)].integer),Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real)));;} + break; + + case 768: +#line 1803 "frame/parser.Y" + {fr->markerEpandaCreateAnglesCmd((yyvsp[(1) - (6)].integer),Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real)));;} + break; + + case 769: +#line 1805 "frame/parser.Y" + {fr->markerEpandaCreateRadiusCmd((yyvsp[(1) - (6)].integer),Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real)));;} + break; + + case 770: +#line 1807 "frame/parser.Y" + {fr->markerCpandaCreateAnglesCmd((yyvsp[(1) - (6)].integer),Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real)));;} + break; + + case 771: +#line 1809 "frame/parser.Y" + {fr->markerCpandaCreateRadiusCmd((yyvsp[(1) - (6)].integer),Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real)));;} + break; + + case 772: +#line 1811 "frame/parser.Y" + {fr->markerPolygonCreateVertexCmd((yyvsp[(1) - (7)].integer),(yyvsp[(5) - (7)].integer),Vector((yyvsp[(6) - (7)].real),(yyvsp[(7) - (7)].real)));;} + break; + + case 773: +#line 1813 "frame/parser.Y" + {fr->markerSegmentCreateVertexCmd((yyvsp[(1) - (7)].integer),(yyvsp[(5) - (7)].integer),Vector((yyvsp[(6) - (7)].real),(yyvsp[(7) - (7)].real)));;} + break; + + case 774: +#line 1815 "frame/parser.Y" + {fr->markerDeleteCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 775: +#line 1817 "frame/parser.Y" + {fr->markerAnnulusDeleteRadiusCmd((yyvsp[(1) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 776: +#line 1819 "frame/parser.Y" + {fr->markerBoxAnnulusDeleteRadiusCmd((yyvsp[(1) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 777: +#line 1820 "frame/parser.Y" + {fr->markerBpandaDeleteCmd((yyvsp[(1) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 778: +#line 1822 "frame/parser.Y" + {fr->markerEllipseAnnulusDeleteRadiusCmd((yyvsp[(1) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 779: +#line 1824 "frame/parser.Y" + {fr->markerDeleteCallBackCmd((yyvsp[(1) - (5)].integer),(CallBack::Type)(yyvsp[(4) - (5)].integer),(yyvsp[(5) - (5)].str));;} + break; + + case 780: +#line 1825 "frame/parser.Y" + {fr->markerEpandaDeleteCmd((yyvsp[(1) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 781: +#line 1826 "frame/parser.Y" + {fr->markerCpandaDeleteCmd((yyvsp[(1) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 782: +#line 1828 "frame/parser.Y" + {fr->markerPolygonDeleteVertexCmd((yyvsp[(1) - (5)].integer),(yyvsp[(5) - (5)].integer));;} + break; + + case 783: +#line 1830 "frame/parser.Y" + {fr->markerSegmentDeleteVertexCmd((yyvsp[(1) - (5)].integer),(yyvsp[(5) - (5)].integer));;} + break; + + case 784: +#line 1831 "frame/parser.Y" + {fr->markerDeleteTagCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 785: +#line 1832 "frame/parser.Y" + {fr->markerDeleteTagCmd((yyvsp[(1) - (4)].integer),(yyvsp[(4) - (4)].str));;} + break; + + case 786: +#line 1833 "frame/parser.Y" + {fr->markerDeleteTagCmd((yyvsp[(1) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 787: +#line 1835 "frame/parser.Y" + {fr->markerEditBeginCmd((yyvsp[(1) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 788: +#line 1837 "frame/parser.Y" + {fr->markerEllipseRadiusCmd((yyvsp[(1) - (6)].integer), Vector((yyvsp[(4) - (6)].real), (yyvsp[(5) - (6)].real)), (Coord::InternalSystem)(yyvsp[(6) - (6)].integer));;} + break; + + case 789: +#line 1839 "frame/parser.Y" + {fr->markerEllipseRadiusCmd((yyvsp[(1) - (7)].integer), Vector((yyvsp[(4) - (7)].real), (yyvsp[(5) - (7)].real)), + (Coord::CoordSystem)(yyvsp[(6) - (7)].integer), (Coord::SkyDist)(yyvsp[(7) - (7)].integer));;} + break; + + case 790: +#line 1843 "frame/parser.Y" + {fr->markerEllipseAnnulusRadiusCmd((yyvsp[(1) - (8)].integer), Vector((yyvsp[(4) - (8)].real),(yyvsp[(5) - (8)].real)), + Vector((yyvsp[(6) - (8)].real),(yyvsp[(6) - (8)].real)*(yyvsp[(5) - (8)].real)/(yyvsp[(4) - (8)].real)), (yyvsp[(7) - (8)].integer), (Coord::InternalSystem)(yyvsp[(8) - (8)].integer));;} + break; + + case 791: +#line 1847 "frame/parser.Y" + {fr->markerEllipseAnnulusRadiusCmd((yyvsp[(1) - (9)].integer), Vector((yyvsp[(4) - (9)].real),(yyvsp[(5) - (9)].real)), + Vector((yyvsp[(6) - (9)].real),(yyvsp[(6) - (9)].real)*(yyvsp[(5) - (9)].real)/(yyvsp[(4) - (9)].real)), (yyvsp[(7) - (9)].integer), (Coord::CoordSystem)(yyvsp[(8) - (9)].integer), (Coord::SkyDist)(yyvsp[(9) - (9)].integer));;} + break; + + case 792: +#line 1850 "frame/parser.Y" + {fr->markerEllipseAnnulusRadiusCmd((yyvsp[(1) - (6)].integer), (yyvsp[(4) - (6)].str), + (Coord::CoordSystem)(yyvsp[(5) - (6)].integer), (Coord::SkyDist)(yyvsp[(6) - (6)].integer));;} + break; + + case 793: +#line 1853 "frame/parser.Y" + {fr->markerEpandaEditCmd((yyvsp[(1) - (10)].integer), (yyvsp[(4) - (10)].real), (yyvsp[(5) - (10)].real), (yyvsp[(6) - (10)].integer), + Vector((yyvsp[(7) - (10)].real),(yyvsp[(8) - (10)].real)), Vector((yyvsp[(9) - (10)].real),(yyvsp[(9) - (10)].real)*(yyvsp[(8) - (10)].real)/(yyvsp[(7) - (10)].real)), (yyvsp[(10) - (10)].integer));;} + break; + + case 794: +#line 1857 "frame/parser.Y" + {fr->markerEpandaEditCmd((yyvsp[(1) - (11)].integer), (yyvsp[(4) - (11)].real), (yyvsp[(5) - (11)].real), (yyvsp[(6) - (11)].integer), + Vector((yyvsp[(7) - (11)].real),(yyvsp[(8) - (11)].real)), Vector((yyvsp[(9) - (11)].real),(yyvsp[(9) - (11)].real)*(yyvsp[(8) - (11)].real)/(yyvsp[(7) - (11)].real)), (yyvsp[(10) - (11)].integer));;} + break; + + case 795: +#line 1861 "frame/parser.Y" + {fr->markerEpandaEditCmd((yyvsp[(1) - (12)].integer), (yyvsp[(4) - (12)].real), (yyvsp[(5) - (12)].real), (yyvsp[(6) - (12)].integer), + Vector((yyvsp[(7) - (12)].real),(yyvsp[(8) - (12)].real)), Vector((yyvsp[(9) - (12)].real),(yyvsp[(9) - (12)].real)*(yyvsp[(8) - (12)].real)/(yyvsp[(7) - (12)].real)), (yyvsp[(10) - (12)].integer), + (Coord::CoordSystem)(yyvsp[(11) - (12)].integer), (Coord::SkyFrame)(yyvsp[(12) - (12)].integer));;} + break; + + case 796: +#line 1866 "frame/parser.Y" + {fr->markerEpandaEditCmd((yyvsp[(1) - (9)].integer), (yyvsp[(4) - (9)].str), (yyvsp[(5) - (9)].str), + (Coord::CoordSystem)(yyvsp[(6) - (9)].integer), (Coord::SkyFrame)(yyvsp[(7) - (9)].integer), + (Coord::CoordSystem)(yyvsp[(8) - (9)].integer), (Coord::SkyDist)(yyvsp[(9) - (9)].integer));;} + break; + + case 797: +#line 1870 "frame/parser.Y" + {fr->markerFontCmd((yyvsp[(1) - (3)].integer),(yyvsp[(3) - (3)].str));;} + break; + + case 798: +#line 1871 "frame/parser.Y" + {fr->markerHighliteCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 799: +#line 1872 "frame/parser.Y" + {fr->markerHighliteOnlyCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 800: +#line 1874 "frame/parser.Y" + {fr->markerLineArrowCmd((yyvsp[(1) - (5)].integer),(yyvsp[(4) - (5)].integer),(yyvsp[(5) - (5)].integer));;} + break; + + case 801: +#line 1876 "frame/parser.Y" + {fr->markerLineCmd((yyvsp[(1) - (6)].integer), Vector((yyvsp[(5) - (6)].vector)), Vector((yyvsp[(6) - (6)].vector)), (Coord::InternalSystem)(yyvsp[(4) - (6)].integer));;} + break; + + case 802: +#line 1878 "frame/parser.Y" + {fr->markerLineCmd((yyvsp[(1) - (7)].integer), Vector((yyvsp[(6) - (7)].vector)), Vector((yyvsp[(7) - (7)].vector)), + (Coord::CoordSystem)(yyvsp[(4) - (7)].integer), (Coord::SkyFrame)(yyvsp[(5) - (7)].integer));;} + break; + + case 803: +#line 1882 "frame/parser.Y" + {fr->markerMoveCmd((yyvsp[(1) - (4)].integer), Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)));;} + break; + + case 804: +#line 1883 "frame/parser.Y" + {fr->markerFrontCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 805: +#line 1884 "frame/parser.Y" + {fr->markerBackCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 806: +#line 1886 "frame/parser.Y" + {fr->markerMoveToCmd((yyvsp[(1) - (6)].integer), Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real)), (Coord::InternalSystem)(yyvsp[(4) - (6)].integer));;} + break; + + case 807: +#line 1888 "frame/parser.Y" + {fr->markerMoveToCmd((yyvsp[(1) - (6)].integer),Vector((yyvsp[(6) - (6)].vector)),(Coord::CoordSystem)(yyvsp[(4) - (6)].integer),(Coord::SkyFrame)(yyvsp[(5) - (6)].integer));;} + break; + + case 808: +#line 1891 "frame/parser.Y" + {fr->markerPolygonResetCmd((yyvsp[(1) - (6)].integer), Vector((yyvsp[(4) - (6)].real),(yyvsp[(5) - (6)].real)),(Coord::InternalSystem)(yyvsp[(6) - (6)].integer));;} + break; + + case 809: +#line 1893 "frame/parser.Y" + {fr->markerPolygonResetCmd((yyvsp[(1) - (7)].integer), Vector((yyvsp[(4) - (7)].real),(yyvsp[(5) - (7)].real)), + (Coord::CoordSystem)(yyvsp[(6) - (7)].integer), (Coord::SkyDist)(yyvsp[(7) - (7)].integer));;} + break; + + case 810: +#line 1896 "frame/parser.Y" + {fr->markerSegmentResetCmd((yyvsp[(1) - (6)].integer), Vector((yyvsp[(4) - (6)].real),(yyvsp[(5) - (6)].real)),(Coord::InternalSystem)(yyvsp[(6) - (6)].integer));;} + break; + + case 811: +#line 1898 "frame/parser.Y" + {fr->markerSegmentResetCmd((yyvsp[(1) - (7)].integer), Vector((yyvsp[(4) - (7)].real),(yyvsp[(5) - (7)].real)), + (Coord::CoordSystem)(yyvsp[(6) - (7)].integer), (Coord::SkyDist)(yyvsp[(7) - (7)].integer));;} + break; + + case 812: +#line 1901 "frame/parser.Y" + {fr->markerPointShapeCmd((yyvsp[(1) - (4)].integer),(Point::PointShape)(yyvsp[(4) - (4)].integer));;} + break; + + case 813: +#line 1902 "frame/parser.Y" + {fr->markerPointSizeCmd((yyvsp[(1) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 814: +#line 1905 "frame/parser.Y" + {fr->markerProjectionCmd((yyvsp[(1) - (6)].integer), Vector((yyvsp[(4) - (6)].vector)), Vector((yyvsp[(5) - (6)].vector)), + (Coord::InternalSystem)(yyvsp[(3) - (6)].integer), (yyvsp[(6) - (6)].real));;} + break; + + case 815: +#line 1909 "frame/parser.Y" + {fr->markerProjectionCmd((yyvsp[(1) - (9)].integer), Vector((yyvsp[(5) - (9)].vector)), Vector((yyvsp[(6) - (9)].vector)), + (Coord::CoordSystem)(yyvsp[(3) - (9)].integer), (Coord::SkyFrame)(yyvsp[(4) - (9)].integer), (yyvsp[(7) - (9)].real), + (Coord::CoordSystem)(yyvsp[(8) - (9)].integer), (Coord::SkyDist)(yyvsp[(9) - (9)].integer));;} + break; + + case 816: +#line 1913 "frame/parser.Y" + {fr->markerPropertyCmd((yyvsp[(1) - (4)].integer),(yyvsp[(3) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 817: +#line 1915 "frame/parser.Y" + {fr->markerRotateBeginCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 818: +#line 1917 "frame/parser.Y" + {fr->markerRulerPointCmd((yyvsp[(1) - (6)].integer), Vector((yyvsp[(5) - (6)].vector)), Vector((yyvsp[(6) - (6)].vector)), + (Coord::InternalSystem)(yyvsp[(4) - (6)].integer));;} + break; + + case 819: +#line 1920 "frame/parser.Y" + {fr->markerRulerPointCmd((yyvsp[(1) - (7)].integer), Vector((yyvsp[(6) - (7)].vector)), Vector((yyvsp[(7) - (7)].vector)), + (Coord::CoordSystem)(yyvsp[(4) - (7)].integer), (Coord::SkyFrame)(yyvsp[(5) - (7)].integer));;} + break; + + case 820: +#line 1923 "frame/parser.Y" + {fr->markerRulerSystemCmd((yyvsp[(1) - (7)].integer), (Coord::CoordSystem)(yyvsp[(4) - (7)].integer), (Coord::SkyFrame)(yyvsp[(5) - (7)].integer), + (Coord::CoordSystem)(yyvsp[(6) - (7)].integer), (Coord::SkyDist)(yyvsp[(7) - (7)].integer));;} + break; + + case 821: +#line 1926 "frame/parser.Y" + {fr->markerSelectCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 822: +#line 1927 "frame/parser.Y" + {fr->markerSelectOnlyCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 823: +#line 1929 "frame/parser.Y" + {fr->markerTagCmd((yyvsp[(1) - (3)].integer),(yyvsp[(3) - (3)].str));;} + break; + + case 824: +#line 1930 "frame/parser.Y" + {fr->markerTextCmd((yyvsp[(1) - (3)].integer),(yyvsp[(3) - (3)].str));;} + break; + + case 825: +#line 1931 "frame/parser.Y" + {fr->markerTextRotateCmd((yyvsp[(1) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 826: +#line 1933 "frame/parser.Y" + {fr->markerUnhighliteCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 827: +#line 1934 "frame/parser.Y" + {fr->markerUnselectCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 828: +#line 1936 "frame/parser.Y" + {fr->markerVectorArrowCmd((yyvsp[(1) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 829: +#line 1938 "frame/parser.Y" + {fr->markerVectorCmd((yyvsp[(1) - (7)].integer), Vector((yyvsp[(5) - (7)].vector)), (Coord::InternalSystem)(yyvsp[(4) - (7)].integer), (yyvsp[(6) - (7)].real), (yyvsp[(7) - (7)].real));;} + break; + + case 830: +#line 1941 "frame/parser.Y" + {fr->markerVectorCmd((yyvsp[(1) - (10)].integer), Vector((yyvsp[(6) - (10)].vector)), (Coord::CoordSystem)(yyvsp[(4) - (10)].integer), (Coord::SkyFrame)(yyvsp[(5) - (10)].integer), + (yyvsp[(9) - (10)].real), (Coord::CoordSystem)(yyvsp[(7) - (10)].integer), (Coord::SkyDist)(yyvsp[(8) - (10)].integer), (yyvsp[(10) - (10)].real));;} + break; + + case 831: +#line 1944 "frame/parser.Y" + {fr->markerLineWidthCmd((yyvsp[(1) - (3)].integer),(yyvsp[(3) - (3)].integer));;} + break; + + case 832: +#line 1946 "frame/parser.Y" + {fr->markerKeyCmd();;} + break; + + case 833: +#line 1947 "frame/parser.Y" + {fr->markerKeyCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 837: +#line 1952 "frame/parser.Y" + {fr->markerPreserveCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 838: +#line 1953 "frame/parser.Y" + {fr->markerPropertyCmd((yyvsp[(2) - (3)].integer),(yyvsp[(3) - (3)].integer));;} + break; + + case 839: +#line 1955 "frame/parser.Y" + {fr->markerPropertyCmd((yyvsp[(2) - (5)].integer),(yyvsp[(3) - (5)].integer),Vector((yyvsp[(4) - (5)].real),(yyvsp[(5) - (5)].real)));;} + break; + + case 840: +#line 1957 "frame/parser.Y" + {fr->markerRotateBeginCmd(Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)));;} + break; + + case 841: +#line 1959 "frame/parser.Y" + {fr->markerRotateMotionCmd(Vector((yyvsp[(3) - (5)].real),(yyvsp[(4) - (5)].real)),(yyvsp[(5) - (5)].integer));;} + break; + + case 842: +#line 1960 "frame/parser.Y" + {fr->markerRotateEndCmd();;} + break; + + case 843: +#line 1962 "frame/parser.Y" + {fr->markerSaveCmd((yyvsp[(2) - (7)].str), (Base::MarkerFormat)(yyvsp[(3) - (7)].integer), (Coord::CoordSystem)(yyvsp[(4) - (7)].integer), (Coord::SkyFrame)(yyvsp[(5) - (7)].integer), (Coord::SkyFormat)(yyvsp[(6) - (7)].integer), (yyvsp[(7) - (7)].integer));;} + break; + + case 844: +#line 1963 "frame/parser.Y" + {fr->markerSaveTemplateCmd((yyvsp[(3) - (3)].str));;} + break; + + case 847: +#line 1968 "frame/parser.Y" + {fr->markerColorCmd((yyvsp[(1) - (3)].str),(yyvsp[(3) - (3)].str));;} + break; + + case 848: +#line 1969 "frame/parser.Y" + {fr->markerCopyCmd((yyvsp[(1) - (2)].str));;} + break; + + case 849: +#line 1970 "frame/parser.Y" + {fr->markerDeleteCmd((yyvsp[(1) - (2)].str));;} + break; + + case 850: +#line 1971 "frame/parser.Y" + {fr->markerCutCmd((yyvsp[(1) - (2)].str));;} + break; + + case 851: +#line 1972 "frame/parser.Y" + {fr->markerFontCmd((yyvsp[(1) - (3)].str),(yyvsp[(3) - (3)].str));;} + break; + + case 852: +#line 1973 "frame/parser.Y" + {fr->markerHighliteCmd((yyvsp[(1) - (2)].str));;} + break; + + case 853: +#line 1974 "frame/parser.Y" + {fr->markerHighliteOnlyCmd((yyvsp[(1) - (3)].str));;} + break; + + case 854: +#line 1975 "frame/parser.Y" + {fr->markerMoveCmd((yyvsp[(1) - (4)].str),Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)));;} + break; + + case 855: +#line 1976 "frame/parser.Y" + {fr->markerFrontCmd((yyvsp[(1) - (3)].str));;} + break; + + case 856: +#line 1977 "frame/parser.Y" + {fr->markerBackCmd((yyvsp[(1) - (3)].str));;} + break; + + case 857: +#line 1979 "frame/parser.Y" + {fr->markerMoveToCmd((yyvsp[(1) - (5)].str),Vector((yyvsp[(5) - (5)].vector)),(Coord::InternalSystem)(yyvsp[(4) - (5)].integer));;} + break; + + case 858: +#line 1981 "frame/parser.Y" + {fr->markerMoveToCmd((yyvsp[(1) - (6)].str),Vector((yyvsp[(6) - (6)].vector)),(Coord::CoordSystem)(yyvsp[(4) - (6)].integer),(Coord::SkyFrame)(yyvsp[(5) - (6)].integer));;} + break; + + case 859: +#line 1983 "frame/parser.Y" + {fr->markerPropertyCmd((yyvsp[(1) - (4)].str),(yyvsp[(3) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 860: +#line 1984 "frame/parser.Y" + {fr->markerSelectCmd((yyvsp[(1) - (2)].str));;} + break; + + case 861: +#line 1985 "frame/parser.Y" + {fr->markerSelectOnlyCmd((yyvsp[(1) - (3)].str));;} + break; + + case 862: +#line 1986 "frame/parser.Y" + {fr->markerUnhighliteCmd((yyvsp[(1) - (2)].str));;} + break; + + case 863: +#line 1987 "frame/parser.Y" + {fr->markerUnselectCmd((yyvsp[(1) - (2)].str));;} + break; + + case 864: +#line 1989 "frame/parser.Y" + {fr->markerTagEditCmd((yyvsp[(3) - (4)].str),(yyvsp[(4) - (4)].str));;} + break; + + case 865: +#line 1990 "frame/parser.Y" + {fr->markerTagDeleteCmd((yyvsp[(3) - (3)].str));;} + break; + + case 866: +#line 1991 "frame/parser.Y" + {fr->markerTagDeleteAllCmd();;} + break; + + case 867: +#line 1992 "frame/parser.Y" + {fr->markerTagCmd((yyvsp[(2) - (2)].str));;} + break; + + case 868: +#line 1993 "frame/parser.Y" + {fr->markerTagUpdateCmd((yyvsp[(3) - (3)].str));;} + break; + + case 869: +#line 1995 "frame/parser.Y" + {fr->markerPasteCmd();;} + break; + + case 870: +#line 1996 "frame/parser.Y" + {fr->markerPasteCmd((Coord::CoordSystem)(yyvsp[(2) - (2)].integer));;} + break; + + case 871: +#line 1997 "frame/parser.Y" + {fr->markerUndoCmd();;} + break; + + case 872: +#line 1998 "frame/parser.Y" + {fr->markerUnhighliteAllCmd();;} + break; + + case 873: +#line 1999 "frame/parser.Y" + {fr->markerUnselectAllCmd();;} + break; + + case 874: +#line 2000 "frame/parser.Y" + {fr->markerLineWidthCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 875: +#line 2003 "frame/parser.Y" + {(yyval.integer) = CallBack::SELECTCB;;} + break; + + case 876: +#line 2004 "frame/parser.Y" + {(yyval.integer) = CallBack::UNSELECTCB;;} + break; + + case 877: +#line 2005 "frame/parser.Y" + {(yyval.integer) = CallBack::HIGHLITECB;;} + break; + + case 878: +#line 2006 "frame/parser.Y" + {(yyval.integer) = CallBack::UNHIGHLITECB;;} + break; + + case 879: +#line 2007 "frame/parser.Y" + {(yyval.integer) = CallBack::MOVEBEGINCB;;} + break; + + case 880: +#line 2008 "frame/parser.Y" + {(yyval.integer) = CallBack::MOVECB;;} + break; + + case 881: +#line 2009 "frame/parser.Y" + {(yyval.integer) = CallBack::MOVEENDCB;;} + break; + + case 882: +#line 2010 "frame/parser.Y" + {(yyval.integer) = CallBack::EDITBEGINCB;;} + break; + + case 883: +#line 2011 "frame/parser.Y" + {(yyval.integer) = CallBack::EDITCB;;} + break; + + case 884: +#line 2012 "frame/parser.Y" + {(yyval.integer) = CallBack::EDITENDCB;;} + break; + + case 885: +#line 2013 "frame/parser.Y" + {(yyval.integer) = CallBack::ROTATEBEGINCB;;} + break; + + case 886: +#line 2014 "frame/parser.Y" + {(yyval.integer) = CallBack::ROTATECB;;} + break; + + case 887: +#line 2015 "frame/parser.Y" + {(yyval.integer) = CallBack::ROTATEENDCB;;} + break; + + case 888: +#line 2016 "frame/parser.Y" + {(yyval.integer) = CallBack::DELETECB;;} + break; + + case 889: +#line 2017 "frame/parser.Y" + {(yyval.integer) = CallBack::TEXTCB;;} + break; + + case 890: +#line 2018 "frame/parser.Y" + {(yyval.integer) = CallBack::COLORCB;;} + break; + + case 891: +#line 2019 "frame/parser.Y" + {(yyval.integer) = CallBack::LINEWIDTHCB;;} + break; + + case 892: +#line 2020 "frame/parser.Y" + {(yyval.integer) = CallBack::PROPERTYCB;;} + break; + + case 893: +#line 2021 "frame/parser.Y" + {(yyval.integer) = CallBack::FONTCB;;} + break; + + case 894: +#line 2022 "frame/parser.Y" + {(yyval.integer) = CallBack::KEYCB;;} + break; + + case 895: +#line 2023 "frame/parser.Y" + {(yyval.integer) = CallBack::UPDATECB;;} + break; + + case 896: +#line 2026 "frame/parser.Y" + {fr->markerCentroidCmd();;} + break; + + case 897: +#line 2027 "frame/parser.Y" + {fr->markerCentroidCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 898: +#line 2028 "frame/parser.Y" + {fr->markerCentroidAutoCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 899: +#line 2029 "frame/parser.Y" + {fr->markerCentroidRadiusCmd((yyvsp[(2) - (2)].real));;} + break; + + case 900: +#line 2030 "frame/parser.Y" + {fr->markerCentroidIterationCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 901: +#line 2032 "frame/parser.Y" + { + fr->markerCentroidIterationCmd((yyvsp[(2) - (3)].integer)); + fr->markerCentroidRadiusCmd((yyvsp[(3) - (3)].real)); + ;} + break; + + case 902: +#line 2042 "frame/parser.Y" + {fr->createCircleCmd(fr->mapToRef(Vector((yyvsp[(2) - (5)].real),(yyvsp[(3) - (5)].real)),Coord::CANVAS), + (yyvsp[(4) - (5)].real), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 903: +#line 2050 "frame/parser.Y" + {fr->createEllipseCmd(fr->mapToRef(Vector((yyvsp[(2) - (7)].real),(yyvsp[(3) - (7)].real)),Coord::CANVAS), + Vector((yyvsp[(4) - (7)].real),(yyvsp[(5) - (7)].real)), + (yyvsp[(6) - (7)].real), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 904: +#line 2059 "frame/parser.Y" + {fr->createBoxCmd(fr->mapToRef(Vector((yyvsp[(2) - (7)].real),(yyvsp[(3) - (7)].real)),Coord::CANVAS), + Vector((yyvsp[(4) - (7)].real),(yyvsp[(5) - (7)].real)), + (yyvsp[(6) - (7)].real), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 905: +#line 2067 "frame/parser.Y" + {fr->createPolygonCmd(fr->mapToRef(Vector((yyvsp[(2) - (6)].real),(yyvsp[(3) - (6)].real)),Coord::CANVAS), + Vector((yyvsp[(4) - (6)].real),(yyvsp[(5) - (6)].real)), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 906: +#line 2074 "frame/parser.Y" + {fr->createSegmentCmd(fr->mapToRef(Vector((yyvsp[(2) - (6)].real),(yyvsp[(3) - (6)].real)),Coord::CANVAS), + Vector((yyvsp[(4) - (6)].real),(yyvsp[(5) - (6)].real)), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 907: +#line 2081 "frame/parser.Y" + {fr->createLineCmd(fr->mapToRef(Vector((yyvsp[(2) - (6)].real),(yyvsp[(3) - (6)].real)),Coord::CANVAS), + fr->mapToRef(Vector((yyvsp[(4) - (6)].real),(yyvsp[(5) - (6)].real)),Coord::CANVAS), + 0, 0, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 908: +#line 2089 "frame/parser.Y" + {fr->createVectCmd(fr->mapToRef(Vector((yyvsp[(2) - (6)].real),(yyvsp[(3) - (6)].real)),Coord::CANVAS), + fr->mapToRef(Vector((yyvsp[(4) - (6)].real),(yyvsp[(5) - (6)].real)),Coord::CANVAS), + 1, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 909: +#line 2097 "frame/parser.Y" + {fr->createTextCmd(fr->mapToRef(Vector((yyvsp[(2) - (5)].real),(yyvsp[(3) - (5)].real)),Coord::CANVAS), + (yyvsp[(4) - (5)].real), 1, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 910: +#line 2102 "frame/parser.Y" + {fr->createPointCmd(fr->mapToRef(Vector((yyvsp[(3) - (6)].real),(yyvsp[(4) - (6)].real)),Coord::CANVAS), + Point::CIRCLE, (yyvsp[(5) - (6)].integer), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 911: +#line 2107 "frame/parser.Y" + {fr->createPointCmd(fr->mapToRef(Vector((yyvsp[(3) - (6)].real),(yyvsp[(4) - (6)].real)),Coord::CANVAS), + Point::BOX, (yyvsp[(5) - (6)].integer), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 912: +#line 2112 "frame/parser.Y" + {fr->createPointCmd(fr->mapToRef(Vector((yyvsp[(3) - (6)].real),(yyvsp[(4) - (6)].real)),Coord::CANVAS), + Point::DIAMOND, (yyvsp[(5) - (6)].integer), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 913: +#line 2117 "frame/parser.Y" + {fr->createPointCmd(fr->mapToRef(Vector((yyvsp[(3) - (6)].real),(yyvsp[(4) - (6)].real)),Coord::CANVAS), + Point::CROSS, (yyvsp[(5) - (6)].integer), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 914: +#line 2122 "frame/parser.Y" + {fr->createPointCmd(fr->mapToRef(Vector((yyvsp[(3) - (6)].real),(yyvsp[(4) - (6)].real)),Coord::CANVAS), + Point::EX, (yyvsp[(5) - (6)].integer), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 915: +#line 2127 "frame/parser.Y" + {fr->createPointCmd(fr->mapToRef(Vector((yyvsp[(3) - (6)].real),(yyvsp[(4) - (6)].real)),Coord::CANVAS), + Point::ARROW, (yyvsp[(5) - (6)].integer), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 916: +#line 2132 "frame/parser.Y" + {fr->createPointCmd(fr->mapToRef(Vector((yyvsp[(3) - (6)].real),(yyvsp[(4) - (6)].real)),Coord::CANVAS), + Point::BOXCIRCLE, (yyvsp[(5) - (6)].integer), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 917: +#line 2141 "frame/parser.Y" + {fr->createRulerCmd(fr->mapToRef(Vector((yyvsp[(2) - (10)].real),(yyvsp[(3) - (10)].real)),Coord::CANVAS), + fr->mapToRef(Vector((yyvsp[(4) - (10)].real),(yyvsp[(5) - (10)].real)),Coord::CANVAS), + (Coord::CoordSystem)(yyvsp[(6) - (10)].integer), (Coord::SkyFrame)(yyvsp[(7) - (10)].integer), (Coord::CoordSystem)(yyvsp[(8) - (10)].integer), (Coord::SkyDist)(yyvsp[(9) - (10)].integer), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 918: +#line 2150 "frame/parser.Y" + {fr->createCompassCmd(fr->mapToRef(Vector((yyvsp[(2) - (7)].real),(yyvsp[(3) - (7)].real)),Coord::CANVAS), + (yyvsp[(4) - (7)].real), + "N", "E", 1, 1, + (Coord::CoordSystem)(yyvsp[(5) - (7)].integer), (Coord::SkyFrame)(yyvsp[(6) - (7)].integer), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 919: +#line 2160 "frame/parser.Y" + {fr->createProjectionCmd(fr->mapToRef(Vector((yyvsp[(2) - (7)].real),(yyvsp[(3) - (7)].real)),Coord::CANVAS), + fr->mapToRef(Vector((yyvsp[(4) - (7)].real),(yyvsp[(5) - (7)].real)),Coord::CANVAS), + (yyvsp[(6) - (7)].real), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 920: +#line 2169 "frame/parser.Y" + {fr->createAnnulusCmd(fr->mapToRef(Vector((yyvsp[(2) - (7)].real),(yyvsp[(3) - (7)].real)),Coord::CANVAS), + (yyvsp[(4) - (7)].real),(yyvsp[(5) - (7)].real),(yyvsp[(6) - (7)].integer), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 921: +#line 2177 "frame/parser.Y" + {fr->createEllipseAnnulusCmd(fr->mapToRef(Vector((yyvsp[(2) - (9)].real),(yyvsp[(3) - (9)].real)),Coord::CANVAS), + Vector((yyvsp[(4) - (9)].real),(yyvsp[(5) - (9)].real)), + Vector((yyvsp[(6) - (9)].real),(yyvsp[(6) - (9)].real)*(yyvsp[(4) - (9)].real)/(yyvsp[(5) - (9)].real)),(yyvsp[(7) - (9)].integer), + (yyvsp[(8) - (9)].real), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 922: +#line 2187 "frame/parser.Y" + {fr->createBoxAnnulusCmd(fr->mapToRef(Vector((yyvsp[(2) - (9)].real),(yyvsp[(3) - (9)].real)),Coord::CANVAS), + Vector((yyvsp[(4) - (9)].real),(yyvsp[(5) - (9)].real)),Vector((yyvsp[(6) - (9)].real),(yyvsp[(6) - (9)].real)*(yyvsp[(4) - (9)].real)/(yyvsp[(5) - (9)].real)),(yyvsp[(7) - (9)].integer), + (yyvsp[(8) - (9)].real), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 923: +#line 2197 "frame/parser.Y" + {fr->createCpandaCmd(fr->mapToRef(Vector((yyvsp[(2) - (10)].real),(yyvsp[(3) - (10)].real)),Coord::CANVAS), + (yyvsp[(4) - (10)].real),(yyvsp[(5) - (10)].real),(yyvsp[(6) - (10)].integer), + (yyvsp[(7) - (10)].real),(yyvsp[(8) - (10)].real),(yyvsp[(9) - (10)].integer), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 924: +#line 2207 "frame/parser.Y" + {fr->createEpandaCmd(fr->mapToRef(Vector((yyvsp[(2) - (12)].real),(yyvsp[(3) - (12)].real)),Coord::CANVAS), + (yyvsp[(4) - (12)].real),(yyvsp[(5) - (12)].real),(yyvsp[(6) - (12)].integer), + Vector((yyvsp[(7) - (12)].real),(yyvsp[(8) - (12)].real)), + Vector((yyvsp[(9) - (12)].real),(yyvsp[(9) - (12)].real)*(yyvsp[(7) - (12)].real)/(yyvsp[(8) - (12)].real)),(yyvsp[(10) - (12)].integer), + (yyvsp[(11) - (12)].real), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 925: +#line 2219 "frame/parser.Y" + {fr->createBpandaCmd(fr->mapToRef(Vector((yyvsp[(2) - (12)].real),(yyvsp[(3) - (12)].real)),Coord::CANVAS), + (yyvsp[(4) - (12)].real),(yyvsp[(5) - (12)].real),(yyvsp[(6) - (12)].integer), + Vector((yyvsp[(7) - (12)].real),(yyvsp[(8) - (12)].real)), + Vector((yyvsp[(9) - (12)].real),(yyvsp[(9) - (12)].real)*(yyvsp[(7) - (12)].real)/(yyvsp[(8) - (12)].real)),(yyvsp[(10) - (12)].integer), + (yyvsp[(11) - (12)].real), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 926: +#line 2228 "frame/parser.Y" + {fr->createCompositeCmd( + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);;} + break; + + case 928: +#line 2236 "frame/parser.Y" + {fr->createTemplateCmd(fr->mapToRef(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)),Coord::CANVAS), (yyvsp[(1) - (3)].str));;} + break; + + case 929: +#line 2238 "frame/parser.Y" + {fr->createTemplateVarCmd(fr->mapToRef(Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)),Coord::CANVAS), (yyvsp[(2) - (4)].str));;} + break; + + case 930: +#line 2240 "frame/parser.Y" + { + // backward compatibility + fr->createTemplateVarCmd(fr->mapToRef(Vector((yyvsp[(1) - (4)].real),(yyvsp[(2) - (4)].real)),Coord::CANVAS), (yyvsp[(4) - (4)].str)); + ;} + break; + + case 931: +#line 2245 "frame/parser.Y" + {fr->createTemplateCmd(Vector((yyvsp[(4) - (4)].vector)),(Coord::CoordSystem)(yyvsp[(2) - (4)].integer),(Coord::SkyFrame)(yyvsp[(3) - (4)].integer), (yyvsp[(1) - (4)].str));;} + break; + + case 932: +#line 2248 "frame/parser.Y" + {(yyval.dash)[0] = (yyvsp[(1) - (2)].integer); (yyval.dash)[1] = (yyvsp[(2) - (2)].integer);;} + break; + + case 933: +#line 2252 "frame/parser.Y" + {fr->markerEditBeginCmd(Vector((yyvsp[(2) - (4)].real),(yyvsp[(3) - (4)].real)),(yyvsp[(4) - (4)].integer));;} + break; + + case 934: +#line 2254 "frame/parser.Y" + {fr->markerEditMotionCmd(Vector((yyvsp[(2) - (4)].real),(yyvsp[(3) - (4)].real)),(yyvsp[(4) - (4)].integer));;} + break; + + case 935: +#line 2255 "frame/parser.Y" + {fr->markerEditEndCmd();;} + break; + + case 936: +#line 2258 "frame/parser.Y" + {(yyval.integer) = Base::DS9;;} + break; + + case 937: +#line 2259 "frame/parser.Y" + {(yyval.integer) = Base::XML;;} + break; + + case 938: +#line 2260 "frame/parser.Y" + {(yyval.integer) = Base::CIAO;;} + break; + + case 939: +#line 2261 "frame/parser.Y" + {(yyval.integer) = Base::SAOTNG;;} + break; + + case 940: +#line 2262 "frame/parser.Y" + {(yyval.integer) = Base::SAOIMAGE;;} + break; + + case 941: +#line 2263 "frame/parser.Y" + {(yyval.integer) = Base::PROS;;} + break; + + case 942: +#line 2264 "frame/parser.Y" + {(yyval.integer) = Base::RAWXY;;} + break; + + case 944: +#line 2268 "frame/parser.Y" + {fr->getMarkerColorCmd();;} + break; + + case 945: +#line 2269 "frame/parser.Y" + {fr->getMarkerFontCmd();;} + break; + + case 946: +#line 2270 "frame/parser.Y" + {fr->getMarkerEpsilonCmd();;} + break; + + case 947: +#line 2271 "frame/parser.Y" + {fr->getMarkerHandleCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 948: +#line 2272 "frame/parser.Y" + {fr->getMarkerIdCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 949: +#line 2275 "frame/parser.Y" + {fr->getMarkerAnalysisPandaCmd((Coord::CoordSystem)(yyvsp[(4) - (4)].integer));;} + break; + + case 950: +#line 2277 "frame/parser.Y" + {fr->getMarkerAnalysisHistogramCmd((yyvsp[(4) - (6)].str),(yyvsp[(5) - (6)].str),(yyvsp[(6) - (6)].integer));;} + break; + + case 951: +#line 2279 "frame/parser.Y" + {fr->getMarkerAnalysisPlot2dCmd((yyvsp[(4) - (10)].str),(yyvsp[(5) - (10)].str),(yyvsp[(6) - (10)].str),(yyvsp[(7) - (10)].str),(Coord::CoordSystem)(yyvsp[(8) - (10)].integer), (Coord::SkyFrame)(yyvsp[(9) - (10)].integer), (Marker::AnalysisMethod)(yyvsp[(10) - (10)].integer));;} + break; + + case 952: +#line 2281 "frame/parser.Y" + {fr->getMarkerAnalysisPlot3dCmd((yyvsp[(4) - (7)].str),(yyvsp[(5) - (7)].str),(Coord::CoordSystem)(yyvsp[(6) - (7)].integer),(Marker::AnalysisMethod)(yyvsp[(7) - (7)].integer));;} + break; + + case 953: +#line 2283 "frame/parser.Y" + {fr->getMarkerAnalysisRadialCmd((yyvsp[(4) - (7)].str),(yyvsp[(5) - (7)].str),(yyvsp[(6) - (7)].str),(Coord::CoordSystem)(yyvsp[(7) - (7)].integer));;} + break; + + case 954: +#line 2285 "frame/parser.Y" + {fr->getMarkerAnalysisStatsCmd((Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyFrame)(yyvsp[(5) - (5)].integer));;} + break; + + case 955: +#line 2288 "frame/parser.Y" + {fr->getMarkerAnalysisPandaCmd((yyvsp[(1) - (4)].integer),(Coord::CoordSystem)(yyvsp[(4) - (4)].integer));;} + break; + + case 956: +#line 2290 "frame/parser.Y" + {fr->getMarkerAnalysisHistogramCmd((yyvsp[(1) - (6)].integer),(yyvsp[(4) - (6)].str),(yyvsp[(5) - (6)].str),(yyvsp[(6) - (6)].integer));;} + break; + + case 957: +#line 2292 "frame/parser.Y" + {fr->getMarkerAnalysisPlot2dCmd((yyvsp[(1) - (10)].integer),(yyvsp[(4) - (10)].str),(yyvsp[(5) - (10)].str),(yyvsp[(6) - (10)].str),(yyvsp[(7) - (10)].str),(Coord::CoordSystem)(yyvsp[(8) - (10)].integer), (Coord::SkyFrame)(yyvsp[(9) - (10)].integer), (Marker::AnalysisMethod)(yyvsp[(10) - (10)].integer));;} + break; + + case 958: +#line 2294 "frame/parser.Y" + {fr->getMarkerAnalysisPlot3dCmd((yyvsp[(1) - (7)].integer),(yyvsp[(4) - (7)].str),(yyvsp[(5) - (7)].str),(Coord::CoordSystem)(yyvsp[(6) - (7)].integer),(Marker::AnalysisMethod)(yyvsp[(7) - (7)].integer));;} + break; + + case 959: +#line 2296 "frame/parser.Y" + {fr->getMarkerAnalysisRadialCmd((yyvsp[(1) - (7)].integer),(yyvsp[(4) - (7)].str),(yyvsp[(5) - (7)].str),(yyvsp[(6) - (7)].str),(Coord::CoordSystem)(yyvsp[(7) - (7)].integer));;} + break; + + case 960: +#line 2298 "frame/parser.Y" + {fr->getMarkerAnalysisStatsCmd((yyvsp[(1) - (5)].integer),(Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyFrame)(yyvsp[(5) - (5)].integer));;} + break; + + case 961: +#line 2300 "frame/parser.Y" + {fr->getMarkerIdAllCmd();;} + break; + + case 962: +#line 2301 "frame/parser.Y" + {fr->getMarkerAngleCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 963: +#line 2302 "frame/parser.Y" + {fr->getMarkerAngleCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 964: +#line 2304 "frame/parser.Y" + {fr->getMarkerAngleCmd((yyvsp[(1) - (4)].integer),(Coord::CoordSystem)(yyvsp[(3) - (4)].integer), (Coord::SkyFrame)(yyvsp[(4) - (4)].integer));;} + break; + + case 965: +#line 2306 "frame/parser.Y" + {fr->getMarkerAnnulusRadiusCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 966: +#line 2309 "frame/parser.Y" + {fr->getMarkerBoxAnnulusRadiusCmd((yyvsp[(1) - (5)].integer),(Coord::CoordSystem)(yyvsp[(4) - (5)].integer),(Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 967: +#line 2311 "frame/parser.Y" + {fr->getMarkerBoxRadiusCmd((yyvsp[(1) - (5)].integer),(Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 968: +#line 2312 "frame/parser.Y" + {fr->getMarkerBpandaAnglesCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 969: +#line 2313 "frame/parser.Y" + {fr->getMarkerBpandaAnglesCmd((yyvsp[(1) - (4)].integer));;} + break; + + case 970: +#line 2315 "frame/parser.Y" + {fr->getMarkerBpandaAnglesCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyFrame)(yyvsp[(5) - (5)].integer));;} + break; + + case 971: +#line 2317 "frame/parser.Y" + {fr->getMarkerBpandaRadiusCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 972: +#line 2320 "frame/parser.Y" + {fr->getMarkerCenterCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(3) - (5)].integer), (Coord::SkyFrame)(yyvsp[(4) - (5)].integer), + (Coord::SkyFormat)(yyvsp[(5) - (5)].integer));;} + break; + + case 973: +#line 2323 "frame/parser.Y" + {fr->getMarkerCircleRadiusCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 974: +#line 2324 "frame/parser.Y" + {fr->getMarkerColorCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 975: +#line 2325 "frame/parser.Y" + {fr->getMarkerCompassArrowCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 976: +#line 2326 "frame/parser.Y" + {fr->getMarkerCompassLabelCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 977: +#line 2328 "frame/parser.Y" + {fr->getMarkerCompassRadiusCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 978: +#line 2329 "frame/parser.Y" + {fr->getMarkerCompassSystemCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 979: +#line 2330 "frame/parser.Y" + {fr->getMarkerCompositeCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 980: +#line 2331 "frame/parser.Y" + {fr->getMarkerCpandaAnglesCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 981: +#line 2332 "frame/parser.Y" + {fr->getMarkerCpandaAnglesCmd((yyvsp[(1) - (4)].integer));;} + break; + + case 982: +#line 2334 "frame/parser.Y" + {fr->getMarkerCpandaAnglesCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyFrame)(yyvsp[(5) - (5)].integer));;} + break; + + case 983: +#line 2336 "frame/parser.Y" + {fr->getMarkerCpandaRadiusCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 984: +#line 2338 "frame/parser.Y" + {fr->getMarkerEllipseRadiusCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 985: +#line 2340 "frame/parser.Y" + {fr->getMarkerEllipseAnnulusRadiusCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), + (Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 986: +#line 2342 "frame/parser.Y" + {fr->getMarkerEpandaAnglesCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 987: +#line 2343 "frame/parser.Y" + {fr->getMarkerEpandaAnglesCmd((yyvsp[(1) - (4)].integer));;} + break; + + case 988: +#line 2345 "frame/parser.Y" + {fr->getMarkerEpandaAnglesCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyFrame)(yyvsp[(5) - (5)].integer));;} + break; + + case 989: +#line 2347 "frame/parser.Y" + {fr->getMarkerEpandaRadiusCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 990: +#line 2348 "frame/parser.Y" + {fr->getMarkerFontCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 991: +#line 2349 "frame/parser.Y" + {fr->getMarkerHighlitedCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 992: +#line 2350 "frame/parser.Y" + {fr->getMarkerLineArrowCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 993: +#line 2352 "frame/parser.Y" + {fr->getMarkerLineLengthCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 994: +#line 2354 "frame/parser.Y" + {fr->getMarkerLineCmd((yyvsp[(1) - (6)].integer), (Coord::CoordSystem)(yyvsp[(4) - (6)].integer), + (Coord::SkyFrame)(yyvsp[(5) - (6)].integer), (Coord::SkyFormat)(yyvsp[(6) - (6)].integer));;} + break; + + case 995: +#line 2357 "frame/parser.Y" + {fr->getMarkerMapLenFromRefCmd((yyvsp[(1) - (6)].integer), (yyvsp[(4) - (6)].real), + (Coord::CoordSystem)(yyvsp[(5) - (6)].integer),(Coord::SkyDist)(yyvsp[(6) - (6)].integer));;} + break; + + case 996: +#line 2360 "frame/parser.Y" + {fr->getMarkerPointShapeCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 997: +#line 2361 "frame/parser.Y" + {fr->getMarkerPointSizeCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 998: +#line 2363 "frame/parser.Y" + {fr->getMarkerProjectionPointsCmd((yyvsp[(1) - (6)].integer), (Coord::CoordSystem)(yyvsp[(4) - (6)].integer), + (Coord::SkyFrame)(yyvsp[(5) - (6)].integer), (Coord::SkyFormat)(yyvsp[(6) - (6)].integer));;} + break; + + case 999: +#line 2366 "frame/parser.Y" + {fr->getMarkerProjectionLengthCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), + (Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 1000: +#line 2369 "frame/parser.Y" + {fr->getMarkerProjectionWidthCmd((yyvsp[(1) - (5)].integer),(Coord::CoordSystem)(yyvsp[(4) - (5)].integer),(Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 1001: +#line 2370 "frame/parser.Y" + {fr->getMarkerPropertyCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 1002: +#line 2371 "frame/parser.Y" + {fr->getMarkerPropertyCmd((yyvsp[(1) - (3)].integer),(yyvsp[(3) - (3)].integer));;} + break; + + case 1003: +#line 2373 "frame/parser.Y" + {fr->getMarkerRulerLengthCmd((yyvsp[(1) - (5)].integer),(Coord::CoordSystem)(yyvsp[(4) - (5)].integer),(Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 1004: +#line 2375 "frame/parser.Y" + {fr->getMarkerRulerPointCmd((yyvsp[(1) - (6)].integer), (Coord::CoordSystem)(yyvsp[(4) - (6)].integer), + (Coord::SkyFrame)(yyvsp[(5) - (6)].integer), (Coord::SkyFormat)(yyvsp[(6) - (6)].integer));;} + break; + + case 1005: +#line 2377 "frame/parser.Y" + {fr->getMarkerRulerSystemCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 1006: +#line 2378 "frame/parser.Y" + {fr->getMarkerSelectedCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 1007: +#line 2380 "frame/parser.Y" + {fr->getMarkerTagCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 1008: +#line 2381 "frame/parser.Y" + {fr->getMarkerTagCmd((yyvsp[(1) - (3)].integer),(yyvsp[(3) - (3)].integer));;} + break; + + case 1009: +#line 2382 "frame/parser.Y" + {fr->getMarkerTextCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 1010: +#line 2383 "frame/parser.Y" + {fr->getMarkerTextRotateCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 1011: +#line 2384 "frame/parser.Y" + {fr->getMarkerTypeCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 1012: +#line 2386 "frame/parser.Y" + {fr->getMarkerVectorArrowCmd((yyvsp[(1) - (3)].integer));;} + break; + + case 1013: +#line 2388 "frame/parser.Y" + {fr->getMarkerVectorLengthCmd((yyvsp[(1) - (5)].integer), (Coord::CoordSystem)(yyvsp[(4) - (5)].integer), (Coord::SkyDist)(yyvsp[(5) - (5)].integer));;} + break; + + case 1014: +#line 2390 "frame/parser.Y" + {fr->getMarkerVectorCmd((yyvsp[(1) - (6)].integer), (Coord::CoordSystem)(yyvsp[(4) - (6)].integer), + (Coord::SkyFrame)(yyvsp[(5) - (6)].integer), (Coord::SkyFormat)(yyvsp[(6) - (6)].integer));;} + break; + + case 1015: +#line 2392 "frame/parser.Y" + {fr->getMarkerLineWidthCmd((yyvsp[(1) - (2)].integer));;} + break; + + case 1017: +#line 2394 "frame/parser.Y" + {fr->getMarkerHighlitedNumberCmd();;} + break; + + case 1018: +#line 2395 "frame/parser.Y" + {fr->getMarkerNumberCmd();;} + break; + + case 1019: +#line 2397 "frame/parser.Y" + {fr->getMarkerPolygonSegmentCmd(Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)));;} + break; + + case 1020: +#line 2399 "frame/parser.Y" + {fr->getMarkerSegmentSegmentCmd(Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)));;} + break; + + case 1021: +#line 2400 "frame/parser.Y" + {fr->getMarkerPreserveCmd();;} + break; + + case 1022: +#line 2401 "frame/parser.Y" + {fr->getMarkerPropertyCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1024: +#line 2403 "frame/parser.Y" + {fr->getMarkerSelectedNumberCmd();;} + break; + + case 1026: +#line 2407 "frame/parser.Y" + {fr->getMarkerColorCmd((yyvsp[(1) - (2)].str));;} + break; + + case 1027: +#line 2408 "frame/parser.Y" + {fr->getMarkerFontCmd((yyvsp[(1) - (2)].str));;} + break; + + case 1028: +#line 2409 "frame/parser.Y" + {fr->getMarkerIdCmd((yyvsp[(1) - (2)].str));;} + break; + + case 1029: +#line 2410 "frame/parser.Y" + {fr->getMarkerPropertyCmd((yyvsp[(1) - (3)].str),(yyvsp[(3) - (3)].integer));;} + break; + + case 1030: +#line 2411 "frame/parser.Y" + {fr->getMarkerTagCmd((yyvsp[(1) - (2)].str));;} + break; + + case 1031: +#line 2412 "frame/parser.Y" + {fr->getMarkerTagNumberCmd((yyvsp[(1) - (3)].str));;} + break; + + case 1032: +#line 2414 "frame/parser.Y" + {fr->getMarkerTagsCmd();;} + break; + + case 1033: +#line 2415 "frame/parser.Y" + {fr->getMarkerTagDefaultNameCmd();;} + break; + + case 1034: +#line 2417 "frame/parser.Y" + {fr->getMarkerLineWidthCmd();;} + break; + + case 1035: +#line 2420 "frame/parser.Y" + {fr->getMarkerCentroidAutoCmd();;} + break; + + case 1036: +#line 2421 "frame/parser.Y" + {fr->getMarkerCentroidRadiusCmd();;} + break; + + case 1037: +#line 2422 "frame/parser.Y" + {fr->getMarkerCentroidIterationCmd();;} + break; + + case 1038: +#line 2423 "frame/parser.Y" + {fr->getMarkerCentroidOptionCmd();;} + break; + + case 1039: +#line 2426 "frame/parser.Y" + {fr->getMarkerHighlitedCmd();;} + break; + + case 1040: +#line 2427 "frame/parser.Y" + {fr->getMarkerHighlitedCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 1041: +#line 2430 "frame/parser.Y" + {fr->getMarkerSelectedCmd();;} + break; + + case 1042: +#line 2431 "frame/parser.Y" + {fr->getMarkerSelectedCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 1043: +#line 2434 "frame/parser.Y" + {fr->getMarkerShowCmd();;} + break; + + case 1044: +#line 2435 "frame/parser.Y" + {fr->getMarkerShowTextCmd();;} + break; + + case 1045: +#line 2438 "frame/parser.Y" + { + strncpy(currentFont, "helvetica 10 normal roman", 32); + strncpy(currentColor, "green", 16); + currentDash[0] = 8; + currentDash[1] = 3; + currentWidth = 1; + strncpy(currentText, "", 80); + currentProps = defaultProps; + taglist.deleteAll(); + cblist.deleteAll(); + ;} + break; + + case 1046: +#line 2451 "frame/parser.Y" + {fr->markerLayerCmd(Base::USER);;} + break; + + case 1047: +#line 2452 "frame/parser.Y" + { + // backward compatibility + fr->markerLayerCmd(Base::USER); + ;} + break; + + case 1048: +#line 2456 "frame/parser.Y" + {fr->markerLayerCmd(Base::USER);;} + break; + + case 1049: +#line 2457 "frame/parser.Y" + { + // backward compatibility + fr->markerLayerCmd(Base::USER); + ;} + break; + + case 1050: +#line 2461 "frame/parser.Y" + {fr->markerLayerCmd(Base::CATALOG);;} + break; + + case 1051: +#line 2462 "frame/parser.Y" + {fr->markerLayerCmd(Base::ANALYSIS);;} + break; + + case 1052: +#line 2467 "frame/parser.Y" + {fr->markerListCmd((Base::MarkerFormat)(yyvsp[(1) - (7)].integer), + (Coord::CoordSystem)(yyvsp[(2) - (7)].integer), (Coord::SkyFrame)(yyvsp[(3) - (7)].integer), (Coord::SkyFormat)(yyvsp[(4) - (7)].integer), (yyvsp[(5) - (7)].integer), + 0, propQMask, propQValue, taglist);;} + break; + + case 1053: +#line 2472 "frame/parser.Y" + {fr->markerListCmd((Base::MarkerFormat)(yyvsp[(2) - (8)].integer), + (Coord::CoordSystem)(yyvsp[(3) - (8)].integer), (Coord::SkyFrame)(yyvsp[(4) - (8)].integer), (Coord::SkyFormat)(yyvsp[(5) - (8)].integer), (yyvsp[(6) - (8)].integer), + 1, propQMask, propQValue, taglist);;} + break; + + case 1054: +#line 2478 "frame/parser.Y" + {fr->markerLoadCmd((Base::MarkerFormat)(yyvsp[(1) - (2)].integer),(yyvsp[(2) - (2)].str));;} + break; + + case 1055: +#line 2480 "frame/parser.Y" + {fr->markerLoadCmd((Base::MarkerFormat)(yyvsp[(1) - (4)].integer),(yyvsp[(2) - (4)].str), + (Coord::CoordSystem)(yyvsp[(3) - (4)].integer),(Coord::SkyFrame)(yyvsp[(4) - (4)].integer));;} + break; + + case 1056: +#line 2483 "frame/parser.Y" + {fr->markerLoadCmd((Base::MarkerFormat)(yyvsp[(1) - (2)].integer),(yyvsp[(2) - (2)].integer));;} + break; + + case 1057: +#line 2485 "frame/parser.Y" + {fr->markerLoadCmd((Base::MarkerFormat)(yyvsp[(1) - (4)].integer),(yyvsp[(2) - (4)].integer), + (Coord::CoordSystem)(yyvsp[(3) - (4)].integer),(Coord::SkyFrame)(yyvsp[(4) - (4)].integer));;} + break; + + case 1058: +#line 2488 "frame/parser.Y" + {fr->markerLoadFitsCmd((yyvsp[(2) - (6)].str), (yyvsp[(3) - (6)].str), (yyvsp[(4) - (6)].dash), (yyvsp[(5) - (6)].integer), (yyvsp[(6) - (6)].str));;} + break; + + case 1059: +#line 2491 "frame/parser.Y" + {fr->markerMoveCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 1060: +#line 2492 "frame/parser.Y" + {fr->markerFrontCmd();;} + break; + + case 1061: +#line 2493 "frame/parser.Y" + {fr->markerBackCmd();;} + break; + + case 1062: +#line 2494 "frame/parser.Y" + {fr->markerMoveBeginCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 1063: +#line 2495 "frame/parser.Y" + {fr->markerMoveMotionCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 1064: +#line 2496 "frame/parser.Y" + {fr->markerMoveEndCmd();;} + break; + + case 1065: +#line 2498 "frame/parser.Y" + {fr->markerMoveToCmd(Vector((yyvsp[(3) - (3)].vector)), (Coord::InternalSystem)(yyvsp[(2) - (3)].integer));;} + break; + + case 1066: +#line 2500 "frame/parser.Y" + {fr->markerMoveToCmd(Vector((yyvsp[(4) - (4)].vector)), (Coord::CoordSystem)(yyvsp[(2) - (4)].integer), (Coord::SkyFrame)(yyvsp[(3) - (4)].integer));;} + break; + + case 1069: +#line 2507 "frame/parser.Y" + {setProps(¤tProps,(yyvsp[(1) - (3)].integer),(yyvsp[(3) - (3)].integer));;} + break; + + case 1070: +#line 2508 "frame/parser.Y" + {strncpy(currentColor,(yyvsp[(3) - (3)].str),16);;} + break; + + case 1071: +#line 2509 "frame/parser.Y" + {currentDash[0]=(yyvsp[(3) - (4)].integer);currentDash[1]=(yyvsp[(4) - (4)].integer);;} + break; + + case 1072: +#line 2510 "frame/parser.Y" + {currentWidth = (yyvsp[(3) - (3)].integer);;} + break; + + case 1073: +#line 2511 "frame/parser.Y" + {strncpy(currentFont,(yyvsp[(3) - (3)].str),32);;} + break; + + case 1074: +#line 2512 "frame/parser.Y" + {strncpy(currentText,(yyvsp[(3) - (3)].str),80);;} + break; + + case 1077: +#line 2517 "frame/parser.Y" + {(yyval.integer) = Marker::NONE;;} + break; + + case 1078: +#line 2518 "frame/parser.Y" + {(yyval.integer) = Marker::SELECT;;} + break; + + case 1079: +#line 2519 "frame/parser.Y" + {(yyval.integer) = Marker::HIGHLITE;;} + break; + + case 1080: +#line 2520 "frame/parser.Y" + {(yyval.integer) = Marker::DASH;;} + break; + + case 1081: +#line 2521 "frame/parser.Y" + {(yyval.integer) = Marker::FIXED;;} + break; + + case 1082: +#line 2522 "frame/parser.Y" + {(yyval.integer) = Marker::EDIT;;} + break; + + case 1083: +#line 2523 "frame/parser.Y" + {(yyval.integer) = Marker::MOVE;;} + break; + + case 1084: +#line 2524 "frame/parser.Y" + {(yyval.integer) = Marker::ROTATE;;} + break; + + case 1085: +#line 2525 "frame/parser.Y" + {(yyval.integer) = Marker::DELETE;;} + break; + + case 1086: +#line 2526 "frame/parser.Y" + {(yyval.integer) = Marker::INCLUDE;;} + break; + + case 1087: +#line 2527 "frame/parser.Y" + {(yyval.integer) = Marker::SOURCE;;} + break; + + case 1090: +#line 2534 "frame/parser.Y" + {propQMask=0;propQValue=0;;} + break; + + case 1091: +#line 2535 "frame/parser.Y" + {propQMask=0;propQValue=0;;} + break; + + case 1093: +#line 2538 "frame/parser.Y" + {fr->markerSelectAllCmd();;} + break; + + case 1094: +#line 2539 "frame/parser.Y" + {fr->markerSelectOnlyCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 1095: +#line 2540 "frame/parser.Y" + {fr->markerSelectToggleCmd();;} + break; + + case 1096: +#line 2541 "frame/parser.Y" + {fr->markerSelectToggleCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 1097: +#line 2544 "frame/parser.Y" + {fr->markerShowCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 1098: +#line 2545 "frame/parser.Y" + {fr->markerShowTextCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1101: +#line 2553 "frame/parser.Y" + {propQMask |= (yyvsp[(1) - (3)].integer); setProps(&propQValue,(yyvsp[(1) - (3)].integer),(yyvsp[(3) - (3)].integer));;} + break; + + case 1102: +#line 2556 "frame/parser.Y" + {taglist.deleteAll();;} + break; + + case 1103: +#line 2557 "frame/parser.Y" + {taglist.deleteAll();;} + break; + + case 1107: +#line 2564 "frame/parser.Y" + {taglist.append(new Tag((yyvsp[(3) - (3)].str)));;} + break; + + case 1108: +#line 2567 "frame/parser.Y" + {cblist.append( + new CallBack(fr->getInterp(),(CallBack::Type)(yyvsp[(3) - (5)].integer),(yyvsp[(4) - (5)].str),(yyvsp[(5) - (5)].str)));;} + break; + + case 1109: +#line 2571 "frame/parser.Y" + {fr->maskClearCmd();;} + break; + + case 1110: +#line 2572 "frame/parser.Y" + {fr->maskColorCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1111: +#line 2573 "frame/parser.Y" + {fr->maskMarkCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1112: +#line 2574 "frame/parser.Y" + {fr->maskTransparencyCmd((yyvsp[(2) - (2)].real));;} + break; + + case 1113: +#line 2577 "frame/parser.Y" + {fr->orientCmd(Coord::XX);;} + break; + + case 1114: +#line 2578 "frame/parser.Y" + {fr->orientCmd(Coord::YY);;} + break; + + case 1115: +#line 2579 "frame/parser.Y" + {fr->orientCmd(Coord::XY);;} + break; + + case 1116: +#line 2580 "frame/parser.Y" + {fr->orientCmd(Coord::NORMAL);;} + break; + + case 1117: +#line 2584 "frame/parser.Y" + {fr->panCmd(Vector((yyvsp[(1) - (4)].real),(yyvsp[(2) - (4)].real)),Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)));;} + break; + + case 1118: +#line 2585 "frame/parser.Y" + {fr->panCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 1119: +#line 2587 "frame/parser.Y" + { + // backward compatibility + fr->panCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real))); + ;} + break; + + case 1120: +#line 2592 "frame/parser.Y" + {fr->panCmd(Vector((yyvsp[(3) - (3)].vector)), (Coord::CoordSystem)(yyvsp[(1) - (3)].integer), (Coord::SkyFrame)(yyvsp[(2) - (3)].integer));;} + break; + + case 1122: +#line 2594 "frame/parser.Y" + {fr->panBBoxCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 1124: +#line 2596 "frame/parser.Y" + {fr->panPreserveCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1125: +#line 2599 "frame/parser.Y" + {fr->panToCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 1126: +#line 2601 "frame/parser.Y" + { + // backward compatibility + fr->panToCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real))); + ;} + break; + + case 1127: +#line 2606 "frame/parser.Y" + {fr->panToCmd(Vector((yyvsp[(3) - (3)].vector)), (Coord::CoordSystem)(yyvsp[(1) - (3)].integer), (Coord::SkyFrame)(yyvsp[(2) - (3)].integer));;} + break; + + case 1128: +#line 2609 "frame/parser.Y" + {fr->panBeginCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 1129: +#line 2610 "frame/parser.Y" + {fr->panMotionCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 1130: +#line 2611 "frame/parser.Y" + {fr->panEndCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 1131: +#line 2614 "frame/parser.Y" + {fr->pannerCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 1132: +#line 2616 "frame/parser.Y" + { + // backward compatibility + fr->pannerCmd((Coord::CoordSystem)(yyvsp[(2) - (3)].integer),(Coord::SkyFrame)(yyvsp[(3) - (3)].integer)); + ;} + break; + + case 1133: +#line 2620 "frame/parser.Y" + {fr->pannerCmd((yyvsp[(1) - (3)].str), (yyvsp[(2) - (3)].integer), (yyvsp[(3) - (3)].integer));;} + break; + + case 1134: +#line 2621 "frame/parser.Y" + {fr->updatePannerCmd();;} + break; + + case 1135: +#line 2625 "frame/parser.Y" + {fr->psColorSpaceCmd((Widget::PSColorSpace)(yyvsp[(2) - (2)].integer));;} + break; + + case 1136: +#line 2626 "frame/parser.Y" + {fr->psLevelCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1137: +#line 2627 "frame/parser.Y" + {fr->psResolutionCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1138: +#line 2628 "frame/parser.Y" + { + // backward compatibility with backup + ;} + break; + + case 1139: +#line 2633 "frame/parser.Y" + {(yyval.integer) = Widget::BW;;} + break; + + case 1140: +#line 2634 "frame/parser.Y" + {(yyval.integer) = Widget::GRAY;;} + break; + + case 1141: +#line 2635 "frame/parser.Y" + {(yyval.integer) = Widget::RGB;;} + break; + + case 1142: +#line 2636 "frame/parser.Y" + {(yyval.integer) = Widget::CMYK;;} + break; + + case 1145: +#line 2644 "frame/parser.Y" + {fr->regionHighliteBeginCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 1146: +#line 2646 "frame/parser.Y" + {fr->regionHighliteMotionCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 1147: +#line 2647 "frame/parser.Y" + {fr->regionHighliteEndCmd();;} + break; + + case 1148: +#line 2648 "frame/parser.Y" + {fr->regionHighliteShiftEndCmd();;} + break; + + case 1149: +#line 2652 "frame/parser.Y" + {fr->regionSelectBeginCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 1150: +#line 2653 "frame/parser.Y" + {fr->regionSelectMotionCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 1151: +#line 2654 "frame/parser.Y" + {fr->regionSelectEndCmd();;} + break; + + case 1152: +#line 2655 "frame/parser.Y" + {fr->regionSelectShiftEndCmd();;} + break; + + case 1153: +#line 2658 "frame/parser.Y" + {(yyval.integer) = Frame3dBase::MIP;;} + break; + + case 1154: +#line 2659 "frame/parser.Y" + {(yyval.integer) = Frame3dBase::AIP;;} + break; + + case 1155: +#line 2662 "frame/parser.Y" + {(yyval.integer) = Frame3dBase::NONE;;} + break; + + case 1156: +#line 2663 "frame/parser.Y" + {(yyval.integer) = Frame3dBase::AZIMUTH;;} + break; + + case 1157: +#line 2664 "frame/parser.Y" + {(yyval.integer) = Frame3dBase::ELEVATION;;} + break; + + case 1158: +#line 2667 "frame/parser.Y" + {fr->setRGBChannelCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1159: +#line 2668 "frame/parser.Y" + {fr->setRGBSystemCmd((Coord::CoordSystem)(yyvsp[(2) - (2)].integer));;} + break; + + case 1160: +#line 2669 "frame/parser.Y" + {fr->setRGBViewCmd((yyvsp[(2) - (4)].integer),(yyvsp[(3) - (4)].integer),(yyvsp[(4) - (4)].integer));;} + break; + + case 1161: +#line 2672 "frame/parser.Y" + {fr->rotateCmd(degToRad((yyvsp[(1) - (1)].real)));;} + break; + + case 1162: +#line 2673 "frame/parser.Y" + {fr->rotateCmd(degToRad((yyvsp[(1) - (2)].real)));;} + break; + + case 1164: +#line 2675 "frame/parser.Y" + {fr->rotateToCmd(degToRad((yyvsp[(2) - (2)].real)));;} + break; + + case 1165: +#line 2676 "frame/parser.Y" + {fr->rotateToCmd(degToRad((yyvsp[(2) - (3)].real)));;} + break; + + case 1166: +#line 2679 "frame/parser.Y" + {fr->rotateBeginCmd();;} + break; + + case 1167: +#line 2680 "frame/parser.Y" + {fr->rotateMotionCmd(degToRad((yyvsp[(1) - (1)].real)));;} + break; + + case 1168: +#line 2681 "frame/parser.Y" + {fr->rotateEndCmd();;} + break; + + case 1173: +#line 2688 "frame/parser.Y" + {fr->savePhotoCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1174: +#line 2692 "frame/parser.Y" + {fr->saveArrayFileCmd((yyvsp[(2) - (3)].str), (FitsFile::ArchType)(yyvsp[(3) - (3)].integer));;} + break; + + case 1175: +#line 2694 "frame/parser.Y" + {fr->saveArrayChannelCmd((yyvsp[(2) - (3)].str), (FitsFile::ArchType)(yyvsp[(3) - (3)].integer));;} + break; + + case 1176: +#line 2696 "frame/parser.Y" + {fr->saveArraySocketCmd((yyvsp[(2) - (3)].integer), (FitsFile::ArchType)(yyvsp[(3) - (3)].integer));;} + break; + + case 1178: +#line 2701 "frame/parser.Y" + {fr->saveArrayRGBCubeFileCmd((yyvsp[(2) - (3)].str), (FitsFile::ArchType)(yyvsp[(3) - (3)].integer));;} + break; + + case 1179: +#line 2703 "frame/parser.Y" + {fr->saveArrayRGBCubeChannelCmd((yyvsp[(2) - (3)].str), (FitsFile::ArchType)(yyvsp[(3) - (3)].integer));;} + break; + + case 1180: +#line 2705 "frame/parser.Y" + {fr->saveArrayRGBCubeSocketCmd((yyvsp[(2) - (3)].integer), (FitsFile::ArchType)(yyvsp[(3) - (3)].integer));;} + break; + + case 1190: +#line 2718 "frame/parser.Y" + {fr->saveFitsFileCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1191: +#line 2719 "frame/parser.Y" + {fr->saveFitsChannelCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1192: +#line 2720 "frame/parser.Y" + {fr->saveFitsSocketCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1193: +#line 2723 "frame/parser.Y" + {fr->saveFitsTableFileCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1194: +#line 2724 "frame/parser.Y" + {fr->saveFitsTableChannelCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1195: +#line 2725 "frame/parser.Y" + {fr->saveFitsTableSocketCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1196: +#line 2728 "frame/parser.Y" + {fr->saveFitsSliceFileCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1197: +#line 2729 "frame/parser.Y" + {fr->saveFitsSliceChannelCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1198: +#line 2730 "frame/parser.Y" + {fr->saveFitsSliceSocketCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1199: +#line 2733 "frame/parser.Y" + {fr->saveFitsExtCubeFileCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1200: +#line 2734 "frame/parser.Y" + {fr->saveFitsExtCubeChannelCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1201: +#line 2735 "frame/parser.Y" + {fr->saveFitsExtCubeSocketCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1203: +#line 2739 "frame/parser.Y" + {fr->saveFitsMosaicFileCmd((yyvsp[(2) - (3)].str),(yyvsp[(3) - (3)].integer));;} + break; + + case 1204: +#line 2740 "frame/parser.Y" + {fr->saveFitsMosaicChannelCmd((yyvsp[(2) - (3)].str),(yyvsp[(3) - (3)].integer));;} + break; + + case 1205: +#line 2741 "frame/parser.Y" + {fr->saveFitsMosaicSocketCmd((yyvsp[(2) - (3)].integer),(yyvsp[(3) - (3)].integer));;} + break; + + case 1206: +#line 2744 "frame/parser.Y" + {fr->saveFitsMosaicImageFileCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1207: +#line 2745 "frame/parser.Y" + {fr->saveFitsMosaicImageChannelCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1208: +#line 2746 "frame/parser.Y" + {fr->saveFitsMosaicImageSocketCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1209: +#line 2749 "frame/parser.Y" + {fr->saveFitsRGBImageFileCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1210: +#line 2750 "frame/parser.Y" + {fr->saveFitsRGBImageChannelCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1211: +#line 2751 "frame/parser.Y" + {fr->saveFitsRGBImageSocketCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1212: +#line 2754 "frame/parser.Y" + {fr->saveFitsRGBCubeFileCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1213: +#line 2755 "frame/parser.Y" + {fr->saveFitsRGBCubeChannelCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1214: +#line 2756 "frame/parser.Y" + {fr->saveFitsRGBCubeSocketCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1215: +#line 2759 "frame/parser.Y" + {fr->saveFitsResampleFileCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1216: +#line 2760 "frame/parser.Y" + {fr->saveFitsResampleChannelCmd((yyvsp[(2) - (2)].str));;} + break; + + case 1217: +#line 2761 "frame/parser.Y" + {fr->saveFitsResampleSocketCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1218: +#line 2765 "frame/parser.Y" + {fr->saveNRRDFileCmd((yyvsp[(2) - (3)].str), (FitsFile::ArchType)(yyvsp[(3) - (3)].integer));;} + break; + + case 1219: +#line 2767 "frame/parser.Y" + {fr->saveNRRDChannelCmd((yyvsp[(2) - (3)].str), (FitsFile::ArchType)(yyvsp[(3) - (3)].integer));;} + break; + + case 1220: +#line 2769 "frame/parser.Y" + {fr->saveNRRDSocketCmd((yyvsp[(2) - (3)].integer), (FitsFile::ArchType)(yyvsp[(3) - (3)].integer));;} + break; + + case 1221: +#line 2773 "frame/parser.Y" + {fr->saveENVIFileCmd((yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].str), (FitsFile::ArchType)(yyvsp[(4) - (4)].integer));;} + break; + + case 1222: +#line 2776 "frame/parser.Y" + {fr->smoothCmd((Context::SmoothFunction)(yyvsp[(1) - (2)].integer),(yyvsp[(2) - (2)].integer));;} + break; + + case 1223: +#line 2777 "frame/parser.Y" + {fr->smoothDeleteCmd();;} + break; + + case 1224: +#line 2780 "frame/parser.Y" + {(yyval.integer) = Context::BOXCAR;;} + break; + + case 1225: +#line 2781 "frame/parser.Y" + {(yyval.integer) = Context::GAUSSIAN;;} + break; + + case 1226: +#line 2782 "frame/parser.Y" + {(yyval.integer) = Context::TOPHAT;;} + break; + + case 1227: +#line 2785 "frame/parser.Y" + {fr->updateFitsCmd(0);;} + break; + + case 1228: +#line 2787 "frame/parser.Y" + {fr->updateFitsCmd((yyvsp[(1) - (5)].integer),BBox((yyvsp[(2) - (5)].real),(yyvsp[(3) - (5)].real),(yyvsp[(4) - (5)].real),(yyvsp[(5) - (5)].real)),0);;} + break; + + case 1229: +#line 2788 "frame/parser.Y" + {fr->updateFitsCmd(1);;} + break; + + case 1230: +#line 2790 "frame/parser.Y" + {fr->updateFitsCmd((yyvsp[(2) - (6)].integer),BBox((yyvsp[(3) - (6)].real),(yyvsp[(4) - (6)].real),(yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real)),1);;} + break; + + case 1232: +#line 2794 "frame/parser.Y" + {fr->sliceCmd(2, (yyvsp[(1) - (1)].integer));;} + break; + + case 1233: +#line 2795 "frame/parser.Y" + {fr->sliceCmd(2, (yyvsp[(1) - (2)].real), (Coord::CoordSystem)(yyvsp[(2) - (2)].integer));;} + break; + + case 1234: +#line 2796 "frame/parser.Y" + {fr->sliceCmd((yyvsp[(1) - (2)].integer), (yyvsp[(2) - (2)].integer));;} + break; + + case 1235: +#line 2797 "frame/parser.Y" + {fr->sliceCmd((yyvsp[(1) - (3)].integer), (yyvsp[(2) - (3)].real), (Coord::CoordSystem)(yyvsp[(3) - (3)].integer));;} + break; + + case 1236: +#line 2800 "frame/parser.Y" + {fr->warpCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 1237: +#line 2801 "frame/parser.Y" + {fr->warpToCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 1238: +#line 2805 "frame/parser.Y" + {fr->wcsCmd((Coord::CoordSystem)(yyvsp[(1) - (3)].integer), (Coord::SkyFrame)(yyvsp[(2) - (3)].integer), (Coord::SkyFormat)(yyvsp[(3) - (3)].integer));;} + break; + + case 1240: +#line 2807 "frame/parser.Y" + {fr->wcsResetCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 1243: +#line 2812 "frame/parser.Y" + {fr->wcsAppendCmd((yyvsp[(1) - (2)].integer),(yyvsp[(2) - (2)].integer));;} + break; + + case 1244: +#line 2813 "frame/parser.Y" + {fr->wcsAppendCmd((yyvsp[(1) - (2)].integer),(yyvsp[(2) - (2)].str));;} + break; + + case 1245: +#line 2814 "frame/parser.Y" + {fr->wcsAppendTxtCmd((yyvsp[(2) - (3)].integer),(yyvsp[(3) - (3)].str));;} + break; + + case 1246: +#line 2817 "frame/parser.Y" + {fr->wcsReplaceCmd((yyvsp[(1) - (2)].integer),(yyvsp[(2) - (2)].integer));;} + break; + + case 1247: +#line 2818 "frame/parser.Y" + {fr->wcsReplaceCmd((yyvsp[(1) - (2)].integer),(yyvsp[(2) - (2)].str));;} + break; + + case 1248: +#line 2819 "frame/parser.Y" + {fr->wcsReplaceTxtCmd((yyvsp[(2) - (3)].integer),(yyvsp[(3) - (3)].str));;} + break; + + case 1249: +#line 2822 "frame/parser.Y" + {fr->wcsAlignCmd((yyvsp[(1) - (1)].integer));;} + break; + + case 1250: +#line 2824 "frame/parser.Y" + { + // used by backup + fr->wcsAlignCmd((yyvsp[(1) - (3)].integer), (Coord::CoordSystem)(yyvsp[(2) - (3)].integer), (Coord::SkyFrame)(yyvsp[(3) - (3)].integer)); + ;} + break; + + case 1251: +#line 2829 "frame/parser.Y" + {fr->wcsAlignCmd((yyvsp[(1) - (4)].integer), (FitsImage*)(yyvsp[(2) - (4)].ptr), (Coord::CoordSystem)(yyvsp[(3) - (4)].integer), (Coord::SkyFrame)(yyvsp[(4) - (4)].integer));;} + break; + + case 1252: +#line 2832 "frame/parser.Y" + { +#ifdef __WIN32 + fr->win32PrintCmd(); +#endif + ;} + break; + + case 1253: +#line 2839 "frame/parser.Y" + {fr->zoomCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 1254: +#line 2841 "frame/parser.Y" + {fr->zoomAboutCmd(Vector((yyvsp[(1) - (5)].real),(yyvsp[(2) - (5)].real)),Vector((yyvsp[(4) - (5)].real),(yyvsp[(5) - (5)].real)));;} + break; + + case 1255: +#line 2843 "frame/parser.Y" + { + // backward compatibility + fr->zoomAboutCmd(Vector((yyvsp[(1) - (6)].real),(yyvsp[(2) - (6)].real)),Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real))); + ;} + break; + + case 1256: +#line 2848 "frame/parser.Y" + {fr->zoomAboutCmd(Vector((yyvsp[(1) - (6)].real),(yyvsp[(2) - (6)].real)),Vector((yyvsp[(6) - (6)].vector)), (Coord::CoordSystem)(yyvsp[(4) - (6)].integer),(Coord::SkyFrame)(yyvsp[(5) - (6)].integer));;} + break; + + case 1258: +#line 2852 "frame/parser.Y" + {fr->zoomToFitCmd(1);;} + break; + + case 1259: +#line 2853 "frame/parser.Y" + {fr->zoomToFitCmd((yyvsp[(2) - (2)].real));;} + break; + + case 1260: +#line 2854 "frame/parser.Y" + {fr->zoomToCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 1261: +#line 2856 "frame/parser.Y" + {fr->zoomToAboutCmd(Vector((yyvsp[(1) - (5)].real),(yyvsp[(2) - (5)].real)),Vector((yyvsp[(4) - (5)].real),(yyvsp[(5) - (5)].real)));;} + break; + + case 1262: +#line 2858 "frame/parser.Y" + { + // backward compatibility + fr->zoomToAboutCmd(Vector((yyvsp[(1) - (6)].real),(yyvsp[(2) - (6)].real)),Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real))); + ;} + break; + + case 1263: +#line 2863 "frame/parser.Y" + {fr->zoomToAboutCmd(Vector((yyvsp[(1) - (6)].real),(yyvsp[(2) - (6)].real)), Vector((yyvsp[(6) - (6)].vector)), + (Coord::CoordSystem)(yyvsp[(4) - (6)].integer), (Coord::SkyFrame)(yyvsp[(5) - (6)].integer));;} + break; + + +/* Line 1267 of yacc.c. */ +#line 10970 "frame/parser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (fr, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (fr, ll, yymsg); + } + else + { + yyerror (fr, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, fr, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, fr, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (fr, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, fr, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, fr, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 2867 "frame/parser.Y" + + +static void setProps(unsigned short* props, unsigned short prop, int value) +{ + if (value) + *props |= prop; + else + *props &= ~prop; +} + diff --git a/tksao/frame/parser.H b/tksao/frame/parser.H new file mode 100644 index 0000000..8f39baf --- /dev/null +++ b/tksao/frame/parser.H @@ -0,0 +1,747 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + REAL = 258, + INT = 259, + STRING = 260, + POINTER = 261, + ANGDEGREE = 262, + ANGRADIAN = 263, + SEXSTR = 264, + HMSSTR = 265, + DMSSTR = 266, + ABOUT_ = 267, + AIP_ = 268, + ALLOC_ = 269, + ALLOCGZ_ = 270, + ALIGN_ = 271, + ALL_ = 272, + ALT_ = 273, + AMPLIFIER_ = 274, + ANALYSIS_ = 275, + ANGLE_ = 276, + ANNULUS_ = 277, + APPEND_ = 278, + ARCMIN_ = 279, + ARCSEC_ = 280, + ARRAY_ = 281, + ARROW_ = 282, + ASINH_ = 283, + AST_ = 284, + AUTO_ = 285, + AUX_ = 286, + AVERAGE_ = 287, + AXES_ = 288, + AZIMUTH_ = 289, + B1950_ = 290, + BACK_ = 291, + BACKGROUND_ = 292, + BASE_ = 293, + BBOX_ = 294, + BEGIN_ = 295, + BG_ = 296, + BIG_ = 297, + BIGENDIAN_ = 298, + BIN_ = 299, + BITPIX_ = 300, + BLOCK_ = 301, + BORDER_ = 302, + BOX_ = 303, + BOXANNULUS_ = 304, + BOXCAR_ = 305, + BOXCIRCLE_ = 306, + BPANDA_ = 307, + BUFFER_ = 308, + BW_ = 309, + CALLBACK_ = 310, + CANVAS_ = 311, + CATALOG_ = 312, + CELESTRIAL_ = 313, + CENTER_ = 314, + CENTROID_ = 315, + CHANNEL_ = 316, + CIRCLE_ = 317, + CIAO_ = 318, + CLEAR_ = 319, + CLIP_ = 320, + COLOR_ = 321, + COLORBAR_ = 322, + COLORMAP_ = 323, + COLORSCALE_ = 324, + COLORSPACE_ = 325, + COLS_ = 326, + COLUMN_ = 327, + COMMAND_ = 328, + COMPASS_ = 329, + COMPOSITE_ = 330, + COMPRESS_ = 331, + CONTOUR_ = 332, + CONTRAST_ = 333, + COORDINATES_ = 334, + COPY_ = 335, + COUNT_ = 336, + CPANDA_ = 337, + CREATE_ = 338, + CROP_ = 339, + CROSS_ = 340, + CROSSHAIR_ = 341, + CUBE_ = 342, + CURSOR_ = 343, + CUT_ = 344, + CMYK_ = 345, + DASH_ = 346, + DASHLIST_ = 347, + DATA_ = 348, + DATAMIN_ = 349, + DATASEC_ = 350, + DEBUG_ = 351, + DEGREES_ = 352, + DEFAULT_ = 353, + DELETE_ = 354, + DEPTH_ = 355, + DETECTOR_ = 356, + DIAMOND_ = 357, + DIM_ = 358, + DS9_ = 359, + EDIT_ = 360, + ECLIPTIC_ = 361, + ELEVATION_ = 362, + ELLIPSE_ = 363, + ELLIPSEANNULUS_ = 364, + END_ = 365, + ENVI_ = 366, + EPANDA_ = 367, + EPSILON_ = 368, + EQUATORIAL_ = 369, + ERASE_ = 370, + EXT_ = 371, + FACTOR_ = 372, + FALSE_ = 373, + FILE_ = 374, + FILTER_ = 375, + FIT_ = 376, + FITS_ = 377, + FITSY_ = 378, + FIXED_ = 379, + FK4_ = 380, + FK4_NO_E_ = 381, + FK5_ = 382, + FONT_ = 383, + FRONT_ = 384, + FULL_ = 385, + FUNCTION_ = 386, + GALACTIC_ = 387, + GAUSSIAN_ = 388, + GET_ = 389, + GLOBAL_ = 390, + GRAPHICS_ = 391, + GRAY_ = 392, + GRID_ = 393, + GZ_ = 394, + HANDLE_ = 395, + HAS_ = 396, + HEAD_ = 397, + HEADER_ = 398, + HEIGHT_ = 399, + HELIOECLIPTIC_ = 400, + HIDE_ = 401, + HIGHLITE_ = 402, + HISTEQU_ = 403, + HISTOGRAM_ = 404, + HORIZONTAL_ = 405, + ICRS_ = 406, + ID_ = 407, + IIS_ = 408, + IMAGE_ = 409, + INCLUDE_ = 410, + INCR_ = 411, + INFO_ = 412, + INTEGER_ = 413, + ITERATION_ = 414, + IRAF_ = 415, + IRAFMIN_ = 416, + J2000_ = 417, + KEY_ = 418, + KEYWORD_ = 419, + LABEL_ = 420, + LENGTH_ = 421, + LEVEL_ = 422, + LITTLE_ = 423, + LITTLEENDIAN_ = 424, + LINE_ = 425, + LINEAR_ = 426, + LIST_ = 427, + LOAD_ = 428, + LOCAL_ = 429, + LOG_ = 430, + MACOSX_ = 431, + MAGNIFIER_ = 432, + MATCH_ = 433, + MAP_ = 434, + MARK_ = 435, + MARKER_ = 436, + MASK_ = 437, + MESSAGE_ = 438, + METHOD_ = 439, + MINMAX_ = 440, + MIP_ = 441, + MMAP_ = 442, + MMAPINCR_ = 443, + MOSAIC_ = 444, + MODE_ = 445, + MOTION_ = 446, + MOVE_ = 447, + NAME_ = 448, + NAN_ = 449, + NATIVE_ = 450, + NAXES_ = 451, + NEW_ = 452, + NEXT_ = 453, + NO_ = 454, + NONE_ = 455, + NOW_ = 456, + NRRD_ = 457, + NUMBER_ = 458, + OBJECT_ = 459, + OFF_ = 460, + ON_ = 461, + ONLY_ = 462, + OPTION_ = 463, + ORIENT_ = 464, + PAN_ = 465, + PANNER_ = 466, + PARSER_ = 467, + PASTE_ = 468, + PERF_ = 469, + PHOTO_ = 470, + PHYSICAL_ = 471, + PIXEL_ = 472, + PLOT2D_ = 473, + PLOT3D_ = 474, + POINT_ = 475, + POINTER_ = 476, + POLYGON_ = 477, + POSTSCRIPT_ = 478, + POW_ = 479, + PRINT_ = 480, + PRESERVE_ = 481, + PROJECTION_ = 482, + PROPERTY_ = 483, + PUBLICATION_ = 484, + PROS_ = 485, + QUERY_ = 486, + RADIAL_ = 487, + RADIUS_ = 488, + REGION_ = 489, + REPLACE_ = 490, + RESAMPLE_ = 491, + RESET_ = 492, + RESOLUTION_ = 493, + RGB_ = 494, + ROOT_ = 495, + ROTATE_ = 496, + RULER_ = 497, + SAMPLE_ = 498, + SAOIMAGE_ = 499, + SAOTNG_ = 500, + SAVE_ = 501, + SCALE_ = 502, + SCAN_ = 503, + SCIENTIFIC_ = 504, + SCOPE_ = 505, + SEGMENT_ = 506, + SELECT_ = 507, + SET_ = 508, + SEXAGESIMAL_ = 509, + SHAPE_ = 510, + SHARED_ = 511, + SHIFT_ = 512, + SHMID_ = 513, + SHOW_ = 514, + SINH_ = 515, + SIZE_ = 516, + SLICE_ = 517, + SMMAP_ = 518, + SMOOTH_ = 519, + SOCKET_ = 520, + SOCKETGZ_ = 521, + SOURCE_ = 522, + SQRT_ = 523, + SQUARED_ = 524, + SSHARED_ = 525, + STATS_ = 526, + STATUS_ = 527, + SUPERGALACTIC_ = 528, + SUM_ = 529, + SYSTEM_ = 530, + TABLE_ = 531, + TAG_ = 532, + TEMPLATE_ = 533, + TEXT_ = 534, + THREADS_ = 535, + THREED_ = 536, + THRESHOLD_ = 537, + THICK_ = 538, + TRANSPARENCY_ = 539, + TO_ = 540, + TOGGLE_ = 541, + TOPHAT_ = 542, + TRUE_ = 543, + TYPE_ = 544, + UNDO_ = 545, + UNHIGHLITE_ = 546, + UNLOAD_ = 547, + UNSELECT_ = 548, + UPDATE_ = 549, + USER_ = 550, + VALUE_ = 551, + VAR_ = 552, + VIEW_ = 553, + VECTOR_ = 554, + VERSION_ = 555, + VERTEX_ = 556, + VERTICAL_ = 557, + WARP_ = 558, + WCS_ = 559, + WCSA_ = 560, + WCSB_ = 561, + WCSC_ = 562, + WCSD_ = 563, + WCSE_ = 564, + WCSF_ = 565, + WCSG_ = 566, + WCSH_ = 567, + WCSI_ = 568, + WCSJ_ = 569, + WCSK_ = 570, + WCSL_ = 571, + WCSM_ = 572, + WCSN_ = 573, + WCSO_ = 574, + WCSP_ = 575, + WCSQ_ = 576, + WCSR_ = 577, + WCSS_ = 578, + WCST_ = 579, + WCSU_ = 580, + WCSV_ = 581, + WCSW_ = 582, + WCSX_ = 583, + WCSY_ = 584, + WCSZ_ = 585, + WCS0_ = 586, + WFPC2_ = 587, + WIDTH_ = 588, + WIN32_ = 589, + XML_ = 590, + XY_ = 591, + YES_ = 592, + ZMAX_ = 593, + ZSCALE_ = 594, + ZOOM_ = 595 + }; +#endif +/* Tokens. */ +#define REAL 258 +#define INT 259 +#define STRING 260 +#define POINTER 261 +#define ANGDEGREE 262 +#define ANGRADIAN 263 +#define SEXSTR 264 +#define HMSSTR 265 +#define DMSSTR 266 +#define ABOUT_ 267 +#define AIP_ 268 +#define ALLOC_ 269 +#define ALLOCGZ_ 270 +#define ALIGN_ 271 +#define ALL_ 272 +#define ALT_ 273 +#define AMPLIFIER_ 274 +#define ANALYSIS_ 275 +#define ANGLE_ 276 +#define ANNULUS_ 277 +#define APPEND_ 278 +#define ARCMIN_ 279 +#define ARCSEC_ 280 +#define ARRAY_ 281 +#define ARROW_ 282 +#define ASINH_ 283 +#define AST_ 284 +#define AUTO_ 285 +#define AUX_ 286 +#define AVERAGE_ 287 +#define AXES_ 288 +#define AZIMUTH_ 289 +#define B1950_ 290 +#define BACK_ 291 +#define BACKGROUND_ 292 +#define BASE_ 293 +#define BBOX_ 294 +#define BEGIN_ 295 +#define BG_ 296 +#define BIG_ 297 +#define BIGENDIAN_ 298 +#define BIN_ 299 +#define BITPIX_ 300 +#define BLOCK_ 301 +#define BORDER_ 302 +#define BOX_ 303 +#define BOXANNULUS_ 304 +#define BOXCAR_ 305 +#define BOXCIRCLE_ 306 +#define BPANDA_ 307 +#define BUFFER_ 308 +#define BW_ 309 +#define CALLBACK_ 310 +#define CANVAS_ 311 +#define CATALOG_ 312 +#define CELESTRIAL_ 313 +#define CENTER_ 314 +#define CENTROID_ 315 +#define CHANNEL_ 316 +#define CIRCLE_ 317 +#define CIAO_ 318 +#define CLEAR_ 319 +#define CLIP_ 320 +#define COLOR_ 321 +#define COLORBAR_ 322 +#define COLORMAP_ 323 +#define COLORSCALE_ 324 +#define COLORSPACE_ 325 +#define COLS_ 326 +#define COLUMN_ 327 +#define COMMAND_ 328 +#define COMPASS_ 329 +#define COMPOSITE_ 330 +#define COMPRESS_ 331 +#define CONTOUR_ 332 +#define CONTRAST_ 333 +#define COORDINATES_ 334 +#define COPY_ 335 +#define COUNT_ 336 +#define CPANDA_ 337 +#define CREATE_ 338 +#define CROP_ 339 +#define CROSS_ 340 +#define CROSSHAIR_ 341 +#define CUBE_ 342 +#define CURSOR_ 343 +#define CUT_ 344 +#define CMYK_ 345 +#define DASH_ 346 +#define DASHLIST_ 347 +#define DATA_ 348 +#define DATAMIN_ 349 +#define DATASEC_ 350 +#define DEBUG_ 351 +#define DEGREES_ 352 +#define DEFAULT_ 353 +#define DELETE_ 354 +#define DEPTH_ 355 +#define DETECTOR_ 356 +#define DIAMOND_ 357 +#define DIM_ 358 +#define DS9_ 359 +#define EDIT_ 360 +#define ECLIPTIC_ 361 +#define ELEVATION_ 362 +#define ELLIPSE_ 363 +#define ELLIPSEANNULUS_ 364 +#define END_ 365 +#define ENVI_ 366 +#define EPANDA_ 367 +#define EPSILON_ 368 +#define EQUATORIAL_ 369 +#define ERASE_ 370 +#define EXT_ 371 +#define FACTOR_ 372 +#define FALSE_ 373 +#define FILE_ 374 +#define FILTER_ 375 +#define FIT_ 376 +#define FITS_ 377 +#define FITSY_ 378 +#define FIXED_ 379 +#define FK4_ 380 +#define FK4_NO_E_ 381 +#define FK5_ 382 +#define FONT_ 383 +#define FRONT_ 384 +#define FULL_ 385 +#define FUNCTION_ 386 +#define GALACTIC_ 387 +#define GAUSSIAN_ 388 +#define GET_ 389 +#define GLOBAL_ 390 +#define GRAPHICS_ 391 +#define GRAY_ 392 +#define GRID_ 393 +#define GZ_ 394 +#define HANDLE_ 395 +#define HAS_ 396 +#define HEAD_ 397 +#define HEADER_ 398 +#define HEIGHT_ 399 +#define HELIOECLIPTIC_ 400 +#define HIDE_ 401 +#define HIGHLITE_ 402 +#define HISTEQU_ 403 +#define HISTOGRAM_ 404 +#define HORIZONTAL_ 405 +#define ICRS_ 406 +#define ID_ 407 +#define IIS_ 408 +#define IMAGE_ 409 +#define INCLUDE_ 410 +#define INCR_ 411 +#define INFO_ 412 +#define INTEGER_ 413 +#define ITERATION_ 414 +#define IRAF_ 415 +#define IRAFMIN_ 416 +#define J2000_ 417 +#define KEY_ 418 +#define KEYWORD_ 419 +#define LABEL_ 420 +#define LENGTH_ 421 +#define LEVEL_ 422 +#define LITTLE_ 423 +#define LITTLEENDIAN_ 424 +#define LINE_ 425 +#define LINEAR_ 426 +#define LIST_ 427 +#define LOAD_ 428 +#define LOCAL_ 429 +#define LOG_ 430 +#define MACOSX_ 431 +#define MAGNIFIER_ 432 +#define MATCH_ 433 +#define MAP_ 434 +#define MARK_ 435 +#define MARKER_ 436 +#define MASK_ 437 +#define MESSAGE_ 438 +#define METHOD_ 439 +#define MINMAX_ 440 +#define MIP_ 441 +#define MMAP_ 442 +#define MMAPINCR_ 443 +#define MOSAIC_ 444 +#define MODE_ 445 +#define MOTION_ 446 +#define MOVE_ 447 +#define NAME_ 448 +#define NAN_ 449 +#define NATIVE_ 450 +#define NAXES_ 451 +#define NEW_ 452 +#define NEXT_ 453 +#define NO_ 454 +#define NONE_ 455 +#define NOW_ 456 +#define NRRD_ 457 +#define NUMBER_ 458 +#define OBJECT_ 459 +#define OFF_ 460 +#define ON_ 461 +#define ONLY_ 462 +#define OPTION_ 463 +#define ORIENT_ 464 +#define PAN_ 465 +#define PANNER_ 466 +#define PARSER_ 467 +#define PASTE_ 468 +#define PERF_ 469 +#define PHOTO_ 470 +#define PHYSICAL_ 471 +#define PIXEL_ 472 +#define PLOT2D_ 473 +#define PLOT3D_ 474 +#define POINT_ 475 +#define POINTER_ 476 +#define POLYGON_ 477 +#define POSTSCRIPT_ 478 +#define POW_ 479 +#define PRINT_ 480 +#define PRESERVE_ 481 +#define PROJECTION_ 482 +#define PROPERTY_ 483 +#define PUBLICATION_ 484 +#define PROS_ 485 +#define QUERY_ 486 +#define RADIAL_ 487 +#define RADIUS_ 488 +#define REGION_ 489 +#define REPLACE_ 490 +#define RESAMPLE_ 491 +#define RESET_ 492 +#define RESOLUTION_ 493 +#define RGB_ 494 +#define ROOT_ 495 +#define ROTATE_ 496 +#define RULER_ 497 +#define SAMPLE_ 498 +#define SAOIMAGE_ 499 +#define SAOTNG_ 500 +#define SAVE_ 501 +#define SCALE_ 502 +#define SCAN_ 503 +#define SCIENTIFIC_ 504 +#define SCOPE_ 505 +#define SEGMENT_ 506 +#define SELECT_ 507 +#define SET_ 508 +#define SEXAGESIMAL_ 509 +#define SHAPE_ 510 +#define SHARED_ 511 +#define SHIFT_ 512 +#define SHMID_ 513 +#define SHOW_ 514 +#define SINH_ 515 +#define SIZE_ 516 +#define SLICE_ 517 +#define SMMAP_ 518 +#define SMOOTH_ 519 +#define SOCKET_ 520 +#define SOCKETGZ_ 521 +#define SOURCE_ 522 +#define SQRT_ 523 +#define SQUARED_ 524 +#define SSHARED_ 525 +#define STATS_ 526 +#define STATUS_ 527 +#define SUPERGALACTIC_ 528 +#define SUM_ 529 +#define SYSTEM_ 530 +#define TABLE_ 531 +#define TAG_ 532 +#define TEMPLATE_ 533 +#define TEXT_ 534 +#define THREADS_ 535 +#define THREED_ 536 +#define THRESHOLD_ 537 +#define THICK_ 538 +#define TRANSPARENCY_ 539 +#define TO_ 540 +#define TOGGLE_ 541 +#define TOPHAT_ 542 +#define TRUE_ 543 +#define TYPE_ 544 +#define UNDO_ 545 +#define UNHIGHLITE_ 546 +#define UNLOAD_ 547 +#define UNSELECT_ 548 +#define UPDATE_ 549 +#define USER_ 550 +#define VALUE_ 551 +#define VAR_ 552 +#define VIEW_ 553 +#define VECTOR_ 554 +#define VERSION_ 555 +#define VERTEX_ 556 +#define VERTICAL_ 557 +#define WARP_ 558 +#define WCS_ 559 +#define WCSA_ 560 +#define WCSB_ 561 +#define WCSC_ 562 +#define WCSD_ 563 +#define WCSE_ 564 +#define WCSF_ 565 +#define WCSG_ 566 +#define WCSH_ 567 +#define WCSI_ 568 +#define WCSJ_ 569 +#define WCSK_ 570 +#define WCSL_ 571 +#define WCSM_ 572 +#define WCSN_ 573 +#define WCSO_ 574 +#define WCSP_ 575 +#define WCSQ_ 576 +#define WCSR_ 577 +#define WCSS_ 578 +#define WCST_ 579 +#define WCSU_ 580 +#define WCSV_ 581 +#define WCSW_ 582 +#define WCSX_ 583 +#define WCSY_ 584 +#define WCSZ_ 585 +#define WCS0_ 586 +#define WFPC2_ 587 +#define WIDTH_ 588 +#define WIN32_ 589 +#define XML_ 590 +#define XY_ 591 +#define YES_ 592 +#define ZMAX_ 593 +#define ZSCALE_ 594 +#define ZOOM_ 595 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 51 "frame/parser.Y" +{ +#define FRBUFSIZE 4096 + char chr; + char str[FRBUFSIZE]; + void* ptr; + int integer; + double real; + double vector[3]; + int dash[2]; +} +/* Line 1529 of yacc.c. */ +#line 740 "frame/parser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/frame/parser.Y b/tksao/frame/parser.Y new file mode 100644 index 0000000..38ad54e --- /dev/null +++ b/tksao/frame/parser.Y @@ -0,0 +1,2875 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {Base* fr} +%lex-param {frFlexLexer* ll} +%parse-param {frFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#include +#include +#include + +#include "base.h" +#include "frame3d.h" +#include "fitsimage.h" +#include "marker.h" + +#undef yyFlexLexer +#define yyFlexLexer frFlexLexer +#include + +extern int frlex(void*, frFlexLexer*); +extern void frerror(Base*, frFlexLexer*, const char*); + +static Coord::CoordSystem currentCoord = Coord::IMAGE; +static Coord::SkyFrame currentSky = Coord::FK5; + +static unsigned short defaultProps = Marker::SELECT | Marker::HIGHLITE | + Marker::EDIT | Marker::MOVE | Marker::ROTATE | + Marker::DELETE | Marker::INCLUDE | Marker::SOURCE; +static unsigned short currentProps; +static char currentColor[16]; +static int currentWidth; +static int currentDash[2]; +static char currentFont[32]; +static char currentText[80]; + +static List taglist; +static List cblist; + +static unsigned short propQMask; +static unsigned short propQValue; + +static void setProps(unsigned short* props, unsigned short prop, int value); +%} + +%union { +#define FRBUFSIZE 4096 + char chr; + char str[FRBUFSIZE]; + void* ptr; + int integer; + double real; + double vector[3]; + int dash[2]; +} + +%type numeric +%type yesno + +%type angle +%type optangle +%type sexagesimal +%type hms +%type dms +%type coord +%type coordSystem +%type wcsSystem +%type internalSystem +%type skyFrame +%type skyFormat +%type skyDist + +%type markerProperty +%type markerCallBack +%type markerFormat +%type markerLayer +%type markerDash +%type pscolorspace +%type scaleType +%type minmaxMode +%type contourClipMode +%type shmType +%type contourMethod +%type layerType +%type gridType +%type fileNameType +%type smoothFunction +%type pointShape +%type pointSize +%type endian +%type renderMethod +%type renderBackground +%type analysisMethod +%type analysisParam + +%token REAL +%token INT +%token STRING +%token POINTER + +%token ANGDEGREE +%token ANGRADIAN + +%token SEXSTR +%token HMSSTR +%token DMSSTR + +%token ABOUT_ +%token AIP_ +%token ALLOC_ +%token ALLOCGZ_ +%token ALIGN_ +%token ALL_ +%token ALT_ +%token AMPLIFIER_ +%token ANALYSIS_ +%token ANGLE_ +%token ANNULUS_ +%token APPEND_ +%token ARCMIN_ +%token ARCSEC_ +%token ARRAY_ +%token ARROW_ +%token ASINH_ +%token AST_ +%token AUTO_ +%token AUX_ +%token AVERAGE_ +%token AXES_ +%token AZIMUTH_ +%token B1950_ +%token BACK_ +%token BACKGROUND_ +%token BASE_ +%token BBOX_ +%token BEGIN_ +%token BG_ +%token BIG_ +%token BIGENDIAN_ +%token BIN_ +%token BITPIX_ +%token BLOCK_ +%token BORDER_ +%token BOX_ +%token BOXANNULUS_ +%token BOXCAR_ +%token BOXCIRCLE_ +%token BPANDA_ +%token BUFFER_ +%token BW_ +%token CALLBACK_ +%token CANVAS_ +%token CATALOG_ +%token CELESTRIAL_ +%token CENTER_ +%token CENTROID_ +%token CHANNEL_ +%token CIRCLE_ +%token CIAO_ +%token CLEAR_ +%token CLIP_ +%token COLOR_ +%token COLORBAR_ +%token COLORMAP_ +%token COLORSCALE_ +%token COLORSPACE_ +%token COLS_ +%token COLUMN_ +%token COMMAND_ +%token COMPASS_ +%token COMPOSITE_ +%token COMPRESS_ +%token CONTOUR_ +%token CONTRAST_ +%token COORDINATES_ +%token COPY_ +%token COUNT_ +%token CPANDA_ +%token CREATE_ +%token CROP_ +%token CROSS_ +%token CROSSHAIR_ +%token CUBE_ +%token CURSOR_ +%token CUT_ +%token CMYK_ +%token DASH_ +%token DASHLIST_ +%token DATA_ +%token DATAMIN_ +%token DATASEC_ +%token DEBUG_ +%token DEGREES_ +%token DEFAULT_ +%token DELETE_ +%token DEPTH_ +%token DETECTOR_ +%token DIAMOND_ +%token DIM_ +%token DS9_ +%token EDIT_ +%token ECLIPTIC_ +%token ELEVATION_ +%token ELLIPSE_ +%token ELLIPSEANNULUS_ +%token END_ +%token ENVI_ +%token EPANDA_ +%token EPSILON_ +%token EQUATORIAL_ +%token ERASE_ +%token EXT_ +%token FACTOR_ +%token FALSE_ +%token FILE_ +%token FILTER_ +%token FIT_ +%token FITS_ +%token FITSY_ +%token FIXED_ +%token FK4_ +%token FK4_NO_E_ +%token FK5_ +%token FONT_ +%token FRONT_ +%token FULL_ +%token FUNCTION_ +%token GALACTIC_ +%token GAUSSIAN_ +%token GET_ +%token GLOBAL_ +%token GRAPHICS_ +%token GRAY_ +%token GRID_ +%token GZ_ +%token HANDLE_ +%token HAS_ +%token HEAD_ +%token HEADER_ +%token HEIGHT_ +%token HELIOECLIPTIC_ +%token HIDE_ +%token HIGHLITE_ +%token HISTEQU_ +%token HISTOGRAM_ +%token HORIZONTAL_ +%token ICRS_ +%token ID_ +%token IIS_ +%token IMAGE_ +%token INCLUDE_ +%token INCR_ +%token INFO_ +%token INTEGER_ +%token ITERATION_ +%token IRAF_ +%token IRAFMIN_ +%token J2000_ +%token KEY_ +%token KEYWORD_ +%token LABEL_ +%token LENGTH_ +%token LEVEL_ +%token LITTLE_ +%token LITTLEENDIAN_ +%token LINE_ +%token LINEAR_ +%token LIST_ +%token LOAD_ +%token LOCAL_ +%token LOG_ +%token MACOSX_ +%token MAGNIFIER_ +%token MATCH_ +%token MAP_ +%token MARK_ +%token MARKER_ +%token MASK_ +%token MESSAGE_ +%token METHOD_ +%token MINMAX_ +%token MIP_ +%token MMAP_ +%token MMAPINCR_ +%token MOSAIC_ +%token MODE_ +%token MOTION_ +%token MOVE_ +%token NAME_ +%token NAN_ +%token NATIVE_ +%token NAXES_ +%token NEW_ +%token NEXT_ +%token NO_ +%token NONE_ +%token NOW_ +%token NRRD_ +%token NUMBER_ +%token OBJECT_ +%token OFF_ +%token ON_ +%token ONLY_ +%token OPTION_ +%token ORIENT_ +%token PAN_ +%token PANNER_ +%token PARSER_ +%token PASTE_ +%token PERF_ +%token PHOTO_ +%token PHYSICAL_ +%token PIXEL_ +%token PLOT2D_ +%token PLOT3D_ +%token POINT_ +%token POINTER_ +%token POLYGON_ +%token POSTSCRIPT_ +%token POW_ +%token PRINT_ +%token PRESERVE_ +%token PROJECTION_ +%token PROPERTY_ +%token PUBLICATION_ +%token PROS_ +%token QUERY_ +%token RADIAL_ +%token RADIUS_ +%token REGION_ +%token REPLACE_ +%token RESAMPLE_ +%token RESET_ +%token RESOLUTION_ +%token RGB_ +%token ROOT_ +%token ROTATE_ +%token RULER_ +%token SAMPLE_ +%token SAOIMAGE_ +%token SAOTNG_ +%token SAVE_ +%token SCALE_ +%token SCAN_ +%token SCIENTIFIC_ +%token SCOPE_ +%token SEGMENT_ +%token SELECT_ +%token SET_ +%token SEXAGESIMAL_ +%token SHAPE_ +%token SHARED_ +%token SHIFT_ +%token SHMID_ +%token SHOW_ +%token SINH_ +%token SIZE_ +%token SLICE_ +%token SMMAP_ +%token SMOOTH_ +%token SOCKET_ +%token SOCKETGZ_ +%token SOURCE_ +%token SQRT_ +%token SQUARED_ +%token SSHARED_ +%token STATS_ +%token STATUS_ +%token SUPERGALACTIC_ +%token SUM_ +%token SYSTEM_ +%token TABLE_ +%token TAG_ +%token TEMPLATE_ +%token TEXT_ +%token THREADS_ +%token THREED_ +%token THRESHOLD_ +%token THICK_ +%token TRANSPARENCY_ +%token TO_ +%token TOGGLE_ +%token TOPHAT_ +%token TRUE_ +%token TYPE_ +%token UNDO_ +%token UNHIGHLITE_ +%token UNLOAD_ +%token UNSELECT_ +%token UPDATE_ +%token USER_ +%token VALUE_ +%token VAR_ +%token VIEW_ +%token VECTOR_ +%token VERSION_ +%token VERTEX_ +%token VERTICAL_ +%token WARP_ +%token WCS_ +%token WCSA_ +%token WCSB_ +%token WCSC_ +%token WCSD_ +%token WCSE_ +%token WCSF_ +%token WCSG_ +%token WCSH_ +%token WCSI_ +%token WCSJ_ +%token WCSK_ +%token WCSL_ +%token WCSM_ +%token WCSN_ +%token WCSO_ +%token WCSP_ +%token WCSQ_ +%token WCSR_ +%token WCSS_ +%token WCST_ +%token WCSU_ +%token WCSV_ +%token WCSW_ +%token WCSX_ +%token WCSY_ +%token WCSZ_ +%token WCS0_ +%token WFPC2_ +%token WIDTH_ +%token WIN32_ +%token XML_ +%token XY_ +%token YES_ +%token ZMAX_ +%token ZSCALE_ +%token ZOOM_ + +%% + +command : DEBUG_ debug + | ANALYSIS_ analysis + | BIN_ bin + | BG_ COLOR_ STRING {fr->bgColorCmd($3);} + | BLOCK_ block + | CENTER_ {fr->centerCmd();} + | CLEAR_ {fr->clearCmd();} + | CLIP_ clip + | COLORBAR_ TAG_ STRING {fr->colorbarTagCmd($3);} + | COLORMAP_ colormap + | COLORSCALE_ colorscale + | CONTOUR_ contour + | CROP_ crop + | CROSSHAIR_ crosshair + | CUBE_ cube + | DATASEC_ yesno {fr->DATASECCmd($2);} + | FITSY_ fitsy + | GET_ get + | GRID_ grid + | HAS_ has + | HIDE_ {fr->hideCmd();} + | HIGHLITE_ yesno {fr->highliteCmd($2);} + | IIS_ iis + | IRAF_ ALIGN_ INT {fr->irafAlignCmd($3);} + | LOAD_ load + | MACOSX_ macosx + | MAGNIFIER_ magnifier + | MATCH_ match + | MARKER_ markerLayer marker + | MASK_ mask + | NAN_ COLOR_ STRING {fr->nanColorCmd($3);} + | ORIENT_ orient + | PAN_ pan + | PANNER_ panner + | QUERY_ CURSOR_ {fr->queryCursorCmd();} + | POSTSCRIPT_ postscript + | RESET_ {fr->resetCmd();} + | REGION_ markerLayer region + | RGB_ rgb + | ROTATE_ rotate + | SAVE_ save + | SHOW_ {fr->showCmd();} + | SMOOTH_ smooth + | THREADS_ INT {fr->threadsCmd($2);} + | THREED_ threed + | UNLOAD_ {fr->unloadFitsCmd();} + | UPDATE_ update + | VERSION_ {fr->msg("Frame 1.0");} + | WARP_ warp + | WCS_ wcs + | WIN32_ win32 + | ZOOM_ zoom + ; + +numeric : REAL {$$=$1;} + | INT {$$=$1;} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + | AST_ yesno {DebugAST=$2;} + | MOSAIC_ yesno {DebugMosaic=$2;} + | PARSER_ yesno {yydebug=$2;} + | PERF_ yesno {DebugPerf=$2;} + | WCS_ yesno {DebugWCS=$2;} + | BIN_ yesno {DebugBin=$2;} + | BLOCK_ yesno {DebugBlock=$2;} + | COMPRESS_ yesno {DebugCompress=$2;} + | CROP_ yesno {DebugCrop=$2;} + | GZ_ yesno {DebugGZ=$2;} + | RGB_ yesno {DebugRGB=$2;} + ; + +yesno : INT {$$=($1 ? 1 : 0);} + + | YES_ {$$=1;} + | 'Y' {$$=1;} + | ON_ {$$=1;} + | TRUE_ {$$=1;} + + | NO_ {$$=0;} + | 'N' {$$=0;} + | OFF_ {$$=0;} + | FALSE_ {$$=0;} + ; + +fileNameType : /* empty */ {$$ = Base::ROOTBASE;} + | ROOT_ BASE_ {$$ = Base::ROOTBASE;} + | FULL_ BASE_ {$$ = Base::FULLBASE;} + | ROOT_ {$$ = Base::ROOT;} + | FULL_ {$$ = Base::FULL;} + ; + +optangle : /* empty */ {$$ = 0;} + | angle {$$ = $1;} + ; + +angle : numeric {$$ = degToRad($1);} /* assume degree */ + | ANGDEGREE {$$ = degToRad($1);} + | ANGRADIAN {$$=$1;} + ; + +sexagesimal: SEXSTR {$$ = parseSEXStr($1);} + ; + +hms : HMSSTR {$$ = parseHMSStr($1);} + ; + +dms : DMSSTR {$$ = parseDMSStr($1);} + ; + +coord : sexagesimal sexagesimal + { + Vector r; + if (currentSky == Coord::GALACTIC || currentSky == Coord::ECLIPTIC) + r = Vector($1,$2); + else + r = Vector($1*360./24.,$2); + + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | hms dms + { + Vector r = Vector($1,$2); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | dms dms + { + Vector r = Vector($1,$2); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | numeric numeric + { + $$[0] = $1; + $$[1] = $2; + $$[2] = 1; + } + ; + +coordSystem :IMAGE_ {$$ = currentCoord = Coord::IMAGE;} + | PHYSICAL_ {$$ = currentCoord = Coord::PHYSICAL;} + | DETECTOR_ {$$ = currentCoord = Coord::DETECTOR;} + | AMPLIFIER_ {$$ = currentCoord = Coord::AMPLIFIER;} + | wcsSystem {$$ = (Coord::CoordSystem)$1;} + ; + +wcsSystem : WCS_ {$$ = currentCoord = Coord::WCS;} + | WCSA_ {$$ = currentCoord = Coord::WCSA;} + | WCSB_ {$$ = currentCoord = Coord::WCSB;} + | WCSC_ {$$ = currentCoord = Coord::WCSC;} + | WCSD_ {$$ = currentCoord = Coord::WCSD;} + | WCSE_ {$$ = currentCoord = Coord::WCSE;} + | WCSF_ {$$ = currentCoord = Coord::WCSF;} + | WCSG_ {$$ = currentCoord = Coord::WCSG;} + | WCSH_ {$$ = currentCoord = Coord::WCSH;} + | WCSI_ {$$ = currentCoord = Coord::WCSI;} + | WCSJ_ {$$ = currentCoord = Coord::WCSJ;} + | WCSK_ {$$ = currentCoord = Coord::WCSK;} + | WCSL_ {$$ = currentCoord = Coord::WCSL;} + | WCSM_ {$$ = currentCoord = Coord::WCSM;} + | WCSN_ {$$ = currentCoord = Coord::WCSN;} + | WCSO_ {$$ = currentCoord = Coord::WCSO;} + | WCSP_ {$$ = currentCoord = Coord::WCSP;} + | WCSQ_ {$$ = currentCoord = Coord::WCSQ;} + | WCSR_ {$$ = currentCoord = Coord::WCSR;} + | WCSS_ {$$ = currentCoord = Coord::WCSS;} + | WCST_ {$$ = currentCoord = Coord::WCST;} + | WCSU_ {$$ = currentCoord = Coord::WCSU;} + | WCSV_ {$$ = currentCoord = Coord::WCSV;} + | WCSW_ {$$ = currentCoord = Coord::WCSW;} + | WCSX_ {$$ = currentCoord = Coord::WCSX;} + | WCSY_ {$$ = currentCoord = Coord::WCSY;} + | WCSZ_ {$$ = currentCoord = Coord::WCSZ;} + | WCS0_ {$$ = currentCoord = Coord::WCS0;} + ; + +internalSystem : CANVAS_ {$$ = Coord::CANVAS;} + | PANNER_ {$$ = Coord::PANNER;} + ; + +scaleType: LINEAR_ {$$ = FrScale::LINEARSCALE;} + | LOG_ {$$ = FrScale::LOGSCALE;} + | POW_ {$$ = FrScale::POWSCALE;} + | SQRT_ {$$ = FrScale::SQRTSCALE;} + | SQUARED_ {$$ = FrScale::SQUAREDSCALE;} + | ASINH_ {$$ = FrScale::ASINHSCALE;} + | SINH_ {$$ = FrScale::SINHSCALE;} + | HISTEQU_ {$$ = FrScale::HISTEQUSCALE;} + ; + +minmaxMode : AUTO_ {$$=FrScale::SCAN;} + | SCAN_ {$$=FrScale::SCAN;} + | SAMPLE_ {$$=FrScale::SAMPLE;} + | DATAMIN_ {$$=FrScale::DATAMIN;} + | IRAFMIN_ {$$=FrScale::IRAFMIN;} + ; + +skyFrame : /* empty */ {$$ = currentSky = Coord::FK5;} + | FK4_ {$$ = currentSky = Coord::FK4;} + | FK4_NO_E_ {$$ = currentSky = Coord::FK4_NO_E;} + | B1950_ {$$ = currentSky = Coord::FK4;} + | FK5_ {$$ = currentSky = Coord::FK5;} + | J2000_ {$$ = currentSky = Coord::FK5;} + | ICRS_ {$$ = currentSky = Coord::ICRS;} + | GALACTIC_ {$$ = currentSky = Coord::GALACTIC;} + | SUPERGALACTIC_ {$$ = currentSky = Coord::SUPERGALACTIC;} + | ECLIPTIC_ {$$ = currentSky = Coord::ECLIPTIC;} + | HELIOECLIPTIC_ {$$ = currentSky = Coord::HELIOECLIPTIC;} + ; + +skyFormat : /* empty */ {$$=Coord::DEGREES;} + | DEGREES_ {$$=Coord::DEGREES;} + | SEXAGESIMAL_ {$$=Coord::SEXAGESIMAL;} + ; + +skyDist : /* empty */ {$$=Coord::DEGREE;} + | DEGREES_ {$$=Coord::DEGREE;} + | ARCMIN_ {$$=Coord::ARCMIN;} + | ARCSEC_ {$$=Coord::ARCSEC;} + ; + +contourClipMode: numeric {$$ = $1;} + | MINMAX_ {$$ = FrScale::MINMAX;} + | ZSCALE_ {$$ = FrScale::ZSCALE;} + | ZMAX_ {$$ = FrScale::ZMAX;} + | USER_ {$$ = FrScale::USERCLIP;} + ; + +shmType : /* empty */ {$$ = Base::SHMID;} + | SHMID_ {$$ = Base::SHMID;} + | KEY_ {$$ = Base::KEY;} + ; + +incrLoad: /*backward compatibility*/ {} + | ALL_ {} + | INCR_ {} + ; + +layerType : /* empty */ {$$ = Base::IMG;} + | IMAGE_ {$$ = Base::IMG;} + | MASK_ {$$ = Base::MASK;} + ; + +pointShape: /* empty */ {$$ = Point::CIRCLE;} + | CIRCLE_ {$$ = Point::CIRCLE;} + | BOX_ {$$ = Point::BOX;} + | DIAMOND_ {$$ = Point::DIAMOND;} + | CROSS_ {$$ = Point::CROSS;} + | 'X' {$$ = Point::EX;} + | ARROW_ {$$ = Point::ARROW;} + | BOXCIRCLE_ {$$ = Point::BOXCIRCLE;} + ; + +pointSize: /* empty */ {$$ = POINTSIZE;} + | INT {$$ = $1;} + ; + +analysisMethod: CPANDA_ {$$ = Marker::PANDA;} + | HISTOGRAM_ {$$ = Marker::HISTOGRAM;} + | PLOT2D_ {$$ = Marker::PLOT2D;} + | PLOT3D_ {$$ = Marker::PLOT3D;} + | RADIAL_ {$$ = Marker::RADIAL;} + | STATS_ {$$ = Marker::STATS;} + ; + +analysisParam : /* emtpy */ {$$ = Marker::AVERAGE;} + | AVERAGE_ {$$ = Marker::AVERAGE;} + | SUM_ {$$ = Marker::SUM;} + ; + +endian : /* empty */ {$$ = FitsFile::NATIVE;} + | NATIVE_ {$$ = FitsFile::NATIVE;} + | BIG_ {$$ = FitsFile::BIG;} + | BIGENDIAN_ {$$ = FitsFile::BIG;} + | LITTLE_ {$$ = FitsFile::LITTLE;} + | LITTLEENDIAN_ {$$ = FitsFile::LITTLE;} + ; + +threed : VIEW_ threedView + | BORDER_ threedBorder + | COMPASS_ threedCompass + | HIGHLITE_ threedHighlite + | METHOD_ renderMethod {fr->set3dRenderMethodCmd($2);} + | BACKGROUND_ renderBackground {fr->set3dRenderBackgroundCmd($2);} + | SCALE_ numeric {fr->set3dScaleCmd($2);} + | PRESERVE_ {fr->set3dPreserveCmd();} + | THRESHOLD_ numeric + {/* needed for compatibility with old version of backup */} + ; + +threedBorder : yesno {fr->set3dBorderCmd($1);} + | COLOR_ STRING {fr->set3dBorderColorCmd($2);} + ; + +threedCompass : yesno {fr->set3dCompassCmd($1);} + | COLOR_ STRING {fr->set3dCompassColorCmd($2);} + ; + +threedHighlite : yesno {fr->set3dHighliteCmd($1);} + | COLOR_ STRING {fr->set3dHighliteColorCmd($2);} + ; + +threedView : numeric numeric {fr->set3dViewCmd($1,$2);} + | POINT_ numeric numeric numeric numeric numeric + {fr->set3dViewPointCmd(Vector3d($2,$3,$4),Vector($5,$6));} + | BEGIN_ numeric numeric {fr->view3dBeginCmd($2,$3);} + | MOTION_ numeric numeric {fr->view3dMotionCmd($2,$3);} + | END_ numeric numeric {fr->view3dEndCmd($2,$3);} + ; + +analysis : RESET_ {fr->analysisMarkersResetCmd();} + | SHAPE_ analysisShape + ; + +analysisShape : CIRCLE_ numeric numeric + {fr->analysisMarkersSelectCmd("circle", fr->mapToRef(Vector($2,$3), Coord::CANVAS));} + | ELLIPSE_ numeric numeric + {fr->analysisMarkersSelectCmd("ellipse", fr->mapToRef(Vector($2,$3), Coord::CANVAS));} + | BOX_ numeric numeric + {fr->analysisMarkersSelectCmd("box", fr->mapToRef(Vector($2,$3), Coord::CANVAS));} + | POLYGON_ numeric numeric + {fr->analysisMarkersSelectCmd("polygon", fr->mapToRef(Vector($2,$3), Coord::CANVAS));} + | POINT_ numeric numeric + {fr->analysisMarkersSelectCmd("point", fr->mapToRef(Vector($2,$3), Coord::CANVAS));} + | VECTOR_ numeric numeric + {fr->analysisMarkersSelectCmd("vector", fr->mapToRef(Vector($2,$3), Coord::CANVAS));} + | ANNULUS_ numeric numeric + {fr->analysisMarkersSelectCmd("annulus", fr->mapToRef(Vector($2,$3), Coord::CANVAS));} + | ELLIPSEANNULUS_ numeric numeric + {fr->analysisMarkersSelectCmd("ellipseannulus", fr->mapToRef(Vector($2,$3), Coord::CANVAS));} + | BOXANNULUS_ numeric numeric + {fr->analysisMarkersSelectCmd("boxannulus", fr->mapToRef(Vector($2,$3), Coord::CANVAS));} + ; + +bin : ABOUT_ binAbout + | COLS_ STRING STRING STRING {fr->binColsCmd($2,$3,$4);} + | DEPTH_ INT {fr->binDepthCmd($2);} + | FACTOR_ binFactor + | FUNCTION_ binFunction + | BUFFER_ SIZE_ INT {fr->binBufferSizeCmd($3);} + | TO_ binTo + | FILTER_ STRING {fr->binFilterCmd($2);} + ; + +binAbout : CENTER_ {fr->binAboutCmd();} + | numeric numeric {fr->binAboutCmd(Vector($1,$2));} + ; + +binFactor : numeric {fr->binFactorCmd(Vector($1,$1));} + | numeric numeric {fr->binFactorCmd(Vector($1,$2));} + | numeric ABOUT_ numeric numeric + {fr->binFactorAboutCmd(Vector($1,$1), Vector($3,$4));} + | numeric numeric ABOUT_ numeric numeric + {fr->binFactorAboutCmd(Vector($1,$2), Vector($4,$5));} + | TO_ numeric {fr->binFactorToCmd(Vector($2,$2));} + | TO_ numeric numeric {fr->binFactorToCmd(Vector($2,$3));} + | TO_ numeric ABOUT_ numeric numeric + {fr->binFactorToAboutCmd(Vector($2,$2), Vector($4,$5));} + | TO_ numeric numeric ABOUT_ numeric numeric + {fr->binFactorToAboutCmd(Vector($2,$3), Vector($5,$6));} + ; + +binFunction : AVERAGE_ {fr->binFunctionCmd(FitsHist::AVERAGE);} + | SUM_ {fr->binFunctionCmd(FitsHist::SUM);} + ; + +binTo : FIT_ {fr->binToFitCmd();} + | numeric numeric ABOUT_ CENTER_ STRING STRING STRING + {fr->binCmd(Vector($1,$2), $5, $6, $7);} + | numeric numeric INT numeric numeric ABOUT_ CENTER_ + STRING STRING STRING STRING + {fr->binCmd(Vector($1,$2), $3, Vector($4,$5), $8, $9, $10, $11);} + | numeric numeric ABOUT_ numeric numeric STRING STRING STRING + {fr->binCmd(Vector($1,$2), Vector($4,$5), $6, $7, $8);} + | numeric numeric INT numeric numeric ABOUT_ numeric numeric + STRING STRING STRING STRING + {fr->binCmd(Vector($1,$2), $3, Vector($4,$5), Vector($7,$8), + $9, $10, $11, $12);} + ; + +block : numeric {fr->blockCmd(Vector($1,$1));} + | numeric numeric {fr->blockCmd(Vector($1,$2));} + | TO_ blockTo + ; + +blockTo : FIT_ {fr->blockToFitCmd();} + | numeric {fr->blockToCmd(Vector($1,$1));} + | numeric numeric {fr->blockToCmd(Vector($1,$2));} + ; + +clip : SCOPE_ clipScope + | MODE_ clipMode + | MINMAX_ clipMinMax + | USER_ numeric numeric {fr->clipUserCmd($2,$3);} + | ZSCALE_ clipZScale + | PRESERVE_ yesno + { + // backward compatibility with backup + } + ; + +clipScope: GLOBAL_ {fr->clipScopeCmd(FrScale::GLOBAL);} + | LOCAL_ {fr->clipScopeCmd(FrScale::LOCAL);} + ; + +clipMode: numeric {fr->clipModeCmd($1);} + | MINMAX_ {fr->clipModeCmd(FrScale::MINMAX);} + | ZSCALE_ {fr->clipModeCmd(FrScale::ZSCALE);} + | ZMAX_ {fr->clipModeCmd(FrScale::ZMAX);} + | USER_ {fr->clipModeCmd(FrScale::USERCLIP);} + ; + +clipMinMax : INT minmaxMode {fr->clipMinMaxCmd((FrScale::MinMaxMode)$2,$1);} + | MODE_ minmaxMode {fr->clipMinMaxModeCmd((FrScale::MinMaxMode)$2);} + | SAMPLE_ INT {fr->clipMinMaxSampleCmd($2);} + ; + +clipZScale: numeric INT INT {fr->clipZScaleCmd($1,$2,$3);} + | CONTRAST_ numeric + { + // backward compatibility with backup + fr->clipZScaleContrastCmd($2); + } + | SAMPLE_ INT + { + // backward compatibility with backup + fr->clipZScaleSampleCmd($2); + } + | LINE_ INT + { + // backward compatibility with backup + fr->clipZScaleLineCmd($2); + } + ; + +colormap : INT numeric numeric INT POINTER INT + {fr->colormapCmd($1, $2, $3, $4, (unsigned char*)$5, $6);} + | RGB_ numeric numeric numeric numeric numeric numeric INT POINTER INT + {fr->colormapCmd($2,$3,$4,$5,$6,$7,$8,(unsigned char*)$9,$10);} + | BEGIN_ {fr->colormapBeginCmd();} + | MOTION_ colormapMotion + | END_ {fr->colormapEndCmd();} + ; + +colormapMotion: INT numeric numeric INT POINTER INT + {fr->colormapMotionCmd($1, $2, $3, $4, (unsigned char*)$5, $6);} + | RGB_ numeric numeric numeric numeric numeric numeric INT POINTER INT + {fr->colormapMotionCmd($2,$3,$4,$5,$6,$7,$8,(unsigned char*)$9,$10);} + +colorscale : scaleType {fr->colorScaleCmd((FrScale::ColorScaleType)$1);} + | LOG_ numeric {fr->colorScaleLogCmd($2);} + ; + +contour : CREATE_ contourCreate + | DELETE_ contourDelete + | LOAD_ contourLoad + | PASTE_ contourPaste + | SAVE_ contourSave + ; + +contourCreate : STRING INT INT contourMethod INT INT scaleType numeric contourClipMode numeric numeric STRING + {fr->contourCreateCmd($1,$2,$3,(FVContour::Method)$4,$5,$6,(FrScale::ColorScaleType)$7,$8,$9,Vector($10,$11),$12);} + | POLYGON_ {fr->contourCreatePolygonCmd();} + ; + +contourDelete : /*empty */ {fr->contourDeleteCmd();} + | AUX_ {fr->contourDeleteAuxCmd();} + ; + +contourLoad : STRING {fr->contourLoadCmd($1);} + | STRING STRING INT yesno {fr->contourLoadCmd($1,$2,$3,$4);} + | STRING INT yesno STRING coordSystem skyFrame + { + // backward compatibility with backup + fr->contourLoadCmd($4,(Coord::CoordSystem)$5,(Coord::SkyFrame)$6,$1,$2,$3); + } + ; + +contourMethod : SMOOTH_ {$$ = FVContour::SMOOTH;} + | BLOCK_ {$$ = FVContour::BLOCK;} + ; + +contourPaste : STRING {fr->contourPasteCmd($1);} + | STRING STRING INT yesno {fr->contourPasteCmd($1,$2,$3,$4);} + ; + +contourSave : STRING coordSystem skyFrame + {fr->contourSaveCmd($1, (Coord::CoordSystem)$2, (Coord::SkyFrame)$3);} + | AUX_ STRING coordSystem skyFrame + {fr->contourSaveAuxCmd($2,(Coord::CoordSystem)$3,(Coord::SkyFrame)$4);} + ; + +crop : /* empty */ {fr->cropCmd();} + | numeric numeric numeric numeric coordSystem skyFrame + {fr->cropCmd(Vector($1,$2), Vector($3,$4), + (Coord::CoordSystem)$5, (Coord::SkyFrame)$6);} + | CENTER_ coord coordSystem skyFrame numeric numeric coordSystem skyDist + {fr->cropCenterCmd(Vector($2), (Coord::CoordSystem)$3, (Coord::SkyFrame)$4, Vector($5,$6), (Coord::CoordSystem)$7, (Coord::SkyDist)$8);} + | THREED_ crop3d + | BEGIN_ numeric numeric {fr->cropBeginCmd(Vector($2,$3));} + | MOTION_ numeric numeric {fr->cropMotionCmd(Vector($2,$3));} + | END_ numeric numeric {fr->cropEndCmd(Vector($2,$3));} + ; + +crop3d : /* empty */ {fr->crop3dCmd();} + | numeric numeric coordSystem {fr->crop3dCmd($1, $2, (Coord::CoordSystem)$3);} + | BEGIN_ numeric numeric INT {fr->crop3dBeginCmd(Vector($2,$3),$4);} + | MOTION_ numeric numeric INT {fr->crop3dMotionCmd(Vector($2,$3),$4);} + | END_ numeric numeric INT {fr->crop3dEndCmd(Vector($2,$3),$4);} + ; + +crosshair: internalSystem numeric numeric + {fr->crosshairCmd(Vector($2,$3), (Coord::InternalSystem)$1);} + | coordSystem skyFrame coord + {fr->crosshairCmd(Vector($3), (Coord::CoordSystem)$1, (Coord::SkyFrame)$2);} + | yesno {fr->crosshairCmd($1);} + | WARP_ numeric numeric {fr->crosshairWarpCmd(Vector($2,$3));} + + | BEGIN_ MOTION_ internalSystem numeric numeric + {fr->crosshairCmd(Vector($4,$5), (Coord::InternalSystem)$3);} + | MOTION_ internalSystem numeric numeric + {fr->crosshairCmd(Vector($3,$4), (Coord::InternalSystem)$2);} + | BEGIN_ MOTION_ coordSystem coord + {fr->crosshairCmd(Vector($4), (Coord::CoordSystem)$3);} + | MOTION_ coordSystem coord + {fr->crosshairCmd(Vector($3), (Coord::CoordSystem)$2);} + ; + +cube : AXES_ INT {fr->axesOrderCmd($2);} + ; + +fitsy : HAS_ EXT_ STRING {fr->fitsyHasExtCmd($3);} + ; + +get : BG_ COLOR_ {fr->getBgColorCmd();} + | BIN_ getBin + | BLOCK_ getBlock + | CLIP_ getClip + | COLORMAP_ getColorMap + | COLORBAR_ getColorbar + | COLORSCALE_ getColorScale + | CONTOUR_ getContour + | COORDINATES_ getCoord + | CROP_ getCrop + | CROSSHAIR_ getCrosshair + | CURSOR_ getCursor + | CUBE_ getCube + | DATA_ getData + | DATASEC_ {fr->getDATASECCmd();} + | FITS_ getFits + | GRID_ getGrid + | HISTOGRAM_ STRING STRING INT {fr->getHistogramCmd($2,$3,$4);} + | HORIZONTAL_ CUT_ STRING STRING numeric numeric internalSystem + {fr->getHorzCutCmd($3,$4,Vector($5,$6),(Coord::InternalSystem)$7);} + | IIS_ getiis + | INFO_ getInfo + | IRAF_ ALIGN_ {fr->getIRAFAlignCmd();} + | MINMAX_ {fr->getMinMaxCmd();} + | MARKER_ markerLayer markerGet + | MASK_ getMask + | NAN_ COLOR_ {fr->getNANColorCmd();} + | ORIENT_ {fr->getOrientCmd();} + | PAN_ getPan + | PIXEL_ TABLE_ internalSystem numeric numeric INT INT STRING + {fr->getPixelTableCmd(Vector($4,$5), (Coord::InternalSystem)$3, $6, $7, $8);} + | RGB_ getRGB + | ROTATE_ {fr->getRotateCmd();} + | SMOOTH_ getSmooth + | THREADS_ {fr->getThreadsCmd();} + | THREED_ getThreed + | TYPE_ {fr->getTypeCmd();} + | VALUE_ internalSystem numeric numeric + {fr->getValueCmd(Vector($3,$4),(Coord::InternalSystem)$2);} + | VERTICAL_ CUT_ STRING STRING numeric numeric internalSystem + {fr->getVertCutCmd($3,$4,Vector($5,$6),(Coord::InternalSystem)$7);} + | WCS_ getWCS + | ZOOM_ {fr->getZoomCmd();} + ; + +getBin : DEPTH_ {fr->getBinDepthCmd();} + | FACTOR_ {fr->getBinFactorCmd();} + | FUNCTION_ {fr->getBinFunctionCmd();} + | BUFFER_ SIZE_ {fr->getBinBufferSizeCmd();} + | CURSOR_ {fr->getBinCursorCmd();} + | FILTER_ {fr->getBinFilterCmd();} + | COLS_ getBinCols + | LIST_ {fr->getBinListCmd();} + ; + +getBinCols : /* empty */ {fr->getBinColsCmd();} + | MINMAX_ STRING {fr->getBinColsMinMaxCmd($2);} + | DIM_ STRING {fr->getBinColsDimCmd($2);} + ; + +getBlock : FACTOR_ {fr->getBlockCmd();} + ; + +getClip : getClipLimits + | SCOPE_ {fr->getClipScopeCmd();} + | MODE_ {fr->getClipModeCmd();} + | MINMAX_ getClipMinMax + | USER_ LEVEL_ {fr->getClipUserCmd();} + | ZSCALE_ getClipZScale + | PRESERVE_ + { + // backward compatibility with backup + fr->getClipPreserveCmd(); + } + ; + +getClipLimits: /* empty */ {fr->getClipCmd();} + | numeric {fr->getClipCmd($1);} + | MINMAX_ {fr->getClipCmd(FrScale::MINMAX);} + | ZSCALE_ {fr->getClipCmd(FrScale::ZSCALE);} + | ZMAX_ {fr->getClipCmd(FrScale::ZMAX);} + | USER_ {fr->getClipCmd(FrScale::USERCLIP);} + ; + +getClipMinMax : MODE_ {fr->getClipMinMaxModeCmd();} + | SAMPLE_ {fr->getClipMinMaxSampleCmd();} + ; + +getClipZScale: CONTRAST_ {fr->getClipZScaleContrastCmd();} + | SAMPLE_ {fr->getClipZScaleSampleCmd();} + | LINE_ {fr->getClipZScaleLineCmd();} + ; + +getColorbar: /* empty */ {fr->getColorbarCmd();} + | TAG_ {fr->getColorbarTagCmd();} + ; + +getColorMap : LEVEL_ getColorMapLevel + ; + +getColorMapLevel: INT {fr->getColorMapLevelCmd($1);} + | INT internalSystem numeric numeric + {fr->getColorMapLevelCmd($1,Vector($3,$4),(Coord::InternalSystem)$2);} + | INT numeric numeric scaleType numeric + {fr->getColorMapLevelCmd($1,$2,$3,(FrScale::ColorScaleType)$4,$5);} + ; + +getColorScale : /* empty */ {fr->getColorScaleCmd();} + | LEVEL_ getColorScaleLevel + | LOG_ {fr->getColorScaleLogCmd();} + ; + +getColorScaleLevel: INT numeric numeric scaleType numeric + {fr->getColorScaleLevelCmd($1,$2,$3,(FrScale::ColorScaleType)$4,$5);} + ; + +getContour: coordSystem skyFrame + {fr->getContourCmd((Coord::CoordSystem)$1,(Coord::SkyFrame)$2);} + | CLIP_ getContourClip + | COLOR_ {fr->getContourColorNameCmd();} + | DASH_ {fr->getContourDashCmd();} + | LEVEL_ {fr->getContourLevelCmd();} + | NUMBER_ LEVEL_ {fr->getContourNumLevelCmd();} + | METHOD_ {fr->getContourMethodCmd();} + | COLORSCALE_ getContourColorScale + | SMOOTH_ {fr->getContourSmoothCmd();} + | WIDTH_ {fr->getContourLineWidthCmd();} + ; + +getContourClip : /* empty */ {fr->getContourClipCmd();} + | MODE_ {fr->getContourClipModeCmd();} + ; + +getContourColorScale : /* empty */ {fr->getContourScaleCmd();} + | LOG_ {fr->getContourScaleLogCmd();} + ; + +getCoord : numeric numeric coordSystem skyFrame skyFormat + {fr->getCoordCmd(Vector($1,$2), (Coord::CoordSystem)$3, (Coord::SkyFrame)$4, (Coord::SkyFormat)$5);} + | internalSystem numeric numeric coordSystem skyFrame skyFormat + { + // backward compatibility + fr->getCoordCmd(Vector($2,$3), (Coord::CoordSystem)$4, (Coord::SkyFrame)$5, + (Coord::SkyFormat)$6); + } + | numeric coordSystem coordSystem INT + {fr->getCoord3axisCmd($1, (Coord::CoordSystem)$2, (Coord::CoordSystem)$3, $4);} + ; + +getCrop : coordSystem skyFrame skyFormat + {fr->getCropCmd((Coord::CoordSystem)$1, (Coord::SkyFrame)$2, (Coord::SkyFormat)$3);} + | CENTER_ coordSystem skyFrame skyFormat coordSystem skyDist + {fr->getCropCenterCmd((Coord::CoordSystem)$2, (Coord::SkyFrame)$3, (Coord::SkyFormat)$4, (Coord::CoordSystem)$5, (Coord::SkyDist)$6);} + | THREED_ coordSystem {fr->getCrop3dCmd((Coord::CoordSystem)$2);} + ; + +getCrosshair: internalSystem {fr->getCrosshairCmd((Coord::InternalSystem)$1);} + | coordSystem skyFrame skyFormat + {fr->getCrosshairCmd((Coord::CoordSystem)$1, (Coord::SkyFrame)$2, (Coord::SkyFormat)$3);} + | STATUS_ {fr->getCrosshairStatusCmd();} + ; + +getCube : AXES_ {fr->getAxesOrderCmd();} + ; + +getCursor : internalSystem {fr->getCursorCmd((Coord::InternalSystem)$1);} + | coordSystem skyFrame skyFormat + {fr->getCursorCmd((Coord::CoordSystem)$1, (Coord::SkyFrame)$2, (Coord::SkyFormat)$3);} + ; + +getData : coordSystem skyFrame coord numeric numeric STRING + {fr->getDataValuesCmd(1, Vector($3), (Coord::CoordSystem)$1, (Coord::SkyFrame)$2, Vector($4,$5), $6);} + | INT coordSystem skyFrame coord numeric numeric STRING + {fr->getDataValuesCmd($1, Vector($4), + (Coord::CoordSystem)$2, (Coord::SkyFrame)$3, Vector($5,$6), $7);} + | internalSystem numeric numeric INT INT + {fr->getDataValuesCmd(Vector($2,$3),(Coord::InternalSystem)$1, + Vector($4,$5));} + ; + +getInfo : STRING {fr->getInfoCmd($1);} + | CLIP_ {fr->getInfoClipCmd();} + | internalSystem numeric numeric STRING + {fr->getInfoCmd(Vector($2,$3), (Coord::InternalSystem)$1, $4);} + ; + +getiis : POINTER INT INT INT INT {fr->iisGetCmd((char*)$1,$2,$3,$4,$5);} + | CURSOR_ {fr->iisGetCursorCmd();} + | FILE_ NAME_ getIISFileName + ; + +getIISFileName : /* empty */ {fr->iisGetFileNameCmd();} + | INT {fr->iisGetFileNameCmd($1);} + | numeric numeric {fr->iisGetFileNameCmd(Vector($1,$2));} + ; + +getFits : NAXES_ /* empty */ {fr->getFitsNAxesCmd();} + | CENTER_ coordSystem skyFrame skyFormat + {fr->getFitsCenterCmd((Coord::CoordSystem)$2,(Coord::SkyFrame)$3,(Coord::SkyFormat)$4);} + | COUNT_ {fr->getFitsCountCmd();} + | DEPTH_ getFitsDepth + | BITPIX_ {fr->getBitpixCmd();} + | EXT_ getFitsExt + | FILE_ NAME_ getFitsFileName + | HEADER_ getFitsHeader + | HEIGHT_ {fr->getFitsHeightCmd();} + | OBJECT_ NAME_ {fr->getFitsObjectNameCmd();} + | SIZE_ {fr->getFitsSizeCmd();} + | SIZE_ coordSystem skyFrame skyDist + {fr->getFitsSizeCmd((Coord::CoordSystem)$2,(Coord::SkyFrame)$3,(Coord::SkyDist)$4);} + | SLICE_ getFitsSlice + | WIDTH_ {fr->getFitsWidthCmd();} + ; + +getFitsExt : INT {fr->getFitsExtCmd($1);} + | internalSystem numeric numeric + {fr->getFitsExtCmd(Vector($2,$3),(Coord::InternalSystem)$1);} + +getFitsHeader : INT {fr->getFitsHeaderCmd($1);} + | KEYWORD_ STRING {fr->getFitsHeaderKeywordCmd(1,$2);} + | INT KEYWORD_ STRING {fr->getFitsHeaderKeywordCmd($1,$3);} + | WCS_ INT {fr->getFitsHeaderWCSCmd($2);} + ; + +getFitsDepth : /* empty */ {fr->getFitsDepthCmd(2);} + | INT {fr->getFitsDepthCmd($1);} + ; + +getFitsFileName: fileNameType + {fr->getFitsFileNameCmd((Base::FileNameType)$1);} + | fileNameType internalSystem numeric numeric + {fr->getFitsFileNameCmd(Vector($3,$4), (Coord::InternalSystem)$2, + (Base::FileNameType)$1);} + | fileNameType INT + {fr->getFitsFileNameCmd($2, (Base::FileNameType)$1);} + ; + +getFitsSlice : /* empty */ {fr->getFitsSliceCmd(2);} + | INT {fr->getFitsSliceCmd($1);} + | coordSystem {fr->getFitsSliceCmd(2, (Coord::CoordSystem)$1);} + | INT coordSystem {fr->getFitsSliceCmd($1, (Coord::CoordSystem)$2);} + ; + +getGrid : /* empty */ {fr->getGridCmd();} + | OPTION_ {fr->getGridOptionCmd();} + | VAR_ {fr->getGridVarsCmd();} + ; + +getMask : COLOR_ {fr->getMaskColorCmd();} + | MARK_ {fr->getMaskMarkCmd();} + | TRANSPARENCY_{fr->getMaskTransparencyCmd();} + ; + +getPan : PRESERVE_ {fr->getPanPreserveCmd();} + ; + +getRGB : CHANNEL_ {fr->getRGBChannelCmd();} + | SYSTEM_ {fr->getRGBSystemCmd();} + | VIEW_ {fr->getRGBViewCmd();} + ; + +getSmooth : FUNCTION_ {fr->getSmoothFunctionCmd();} + | RADIUS_ {fr->getSmoothRadiusCmd();} + ; + +getThreed : VIEW_ getThreedView + | BORDER_ getThreedBorder + | COMPASS_ getThreedCompass + | HIGHLITE_ getThreedHighlite + | METHOD_ {fr->get3dRenderMethodCmd();} + | BACKGROUND_ {fr->get3dRenderBackgroundCmd();} + | SCALE_ {fr->get3dScaleCmd();} + ; + +getThreedBorder : {fr->get3dBorderCmd();} + | COLOR_ {fr->get3dBorderColorCmd();} + ; + +getThreedCompass : {fr->get3dCompassCmd();} + | COLOR_ {fr->get3dCompassColorCmd();} + ; + +getThreedHighlite : {fr->get3dHighliteCmd();} + | COLOR_ {fr->get3dHighliteColorCmd();} + ; + +getThreedView : {fr->get3dViewCmd();} + | POINT_ {fr->get3dViewPointCmd();} + ; + +getWCS : /* empty */ {fr->getWCSCmd();} + | ALIGN_ getWCSAlign + | NAME_ wcsSystem {fr->getWCSNameCmd((Coord::CoordSystem)$2);} + ; + +getWCSAlign : /* empty */ {fr->getWCSAlignCmd();} + | POINTER_ {fr->getWCSAlignPointerCmd();} + ; + +grid : CREATE_ gridCreate + | DELETE_ {fr->gridDeleteCmd();} + ; + +gridCreate: coordSystem skyFrame skyFormat gridType STRING STRING + {fr->gridCmd((Coord::CoordSystem)$1, (Coord::SkyFrame)$2, + (Coord::SkyFormat)$3, (Grid2d::GridType)$4, $5, $6);} + | coordSystem skyFrame skyFormat gridType STRING + { + // backward compatibility with backup + fr->gridCmd((Coord::CoordSystem)$1, (Coord::SkyFrame)$2, + (Coord::SkyFormat)$3, (Grid2d::GridType)$4, $5, ""); + } + ; + +gridType : ANALYSIS_ {$$=Grid2d::ANALYSIS;} + | PUBLICATION_ {$$=Grid2d::PUBLICATION;} + ; + +has : AMPLIFIER_ {fr->hasAmplifierCmd();} + | BIN_ hasBin + | CONTOUR_ hasContour + | CROP_ {fr->hasCropCmd();} + | DATAMIN_ {fr->hasDATAMINCmd();} + | DATASEC_ {fr->hasDATASECCmd();} + | DETECTOR_ {fr->hasDetectorCmd();} + | FITS_ hasFits + | GRID_ {fr->hasGridCmd();} + | IIS_ {fr->hasIISCmd();} + | IRAFMIN_ {fr->hasIRAFMINCmd();} + | MARKER_ hasMarker + | PHYSICAL_ {fr->hasPhysicalCmd();} + | SMOOTH_ {fr->hasSmoothCmd();} + | SYSTEM_ coordSystem {fr->hasSystemCmd((Coord::CoordSystem)$2);} + | WCS_ hasWCS + ; + +hasBin : COLUMN_ STRING {fr->hasBinColCmd($2);} + ; + +hasContour : /* empty */ {fr->hasContourCmd();} + | AUX_ {fr->hasContourAuxCmd();} + ; + +hasFits : /* empty */ {fr->hasFitsCmd();} + | BIN_ {fr->hasFitsBinCmd();} + | CUBE_ {fr->hasFitsCubeCmd();} + | MOSAIC_ {fr->hasFitsMosaicCmd();} + ; + +hasMarker : HIGHLITE_ {fr->hasMarkerHighlitedCmd();} + | SELECT_ {fr->hasMarkerSelectedCmd();} + | PASTE_ {fr->hasMarkerPasteCmd();} + | UNDO_ {fr->hasMarkerUndoCmd();} + ; + +hasWCS : coordSystem {fr->hasWCSCmd((Coord::CoordSystem)$1);} + | EQUATORIAL_ coordSystem {fr->hasWCSEquCmd((Coord::CoordSystem)$2);} + | CELESTRIAL_ coordSystem {fr->hasWCSCelCmd((Coord::CoordSystem)$2);} + | ALT_ {fr->hasWCSAltCmd();} + | THREED_ coordSystem {fr->hasWCSxCmd((Coord::CoordSystem)$2);} + ; + +iis : NEW_ INT INT {fr->iisCmd($2,$3);} + | ERASE_ {fr->iisEraseCmd();} + | MESSAGE_ STRING {fr->iisMessageCmd($2);} + | CURSOR_ iiscursor + | SET_ FILE_ NAME_ iisSetFileName + | SET_ POINTER INT INT INT INT + {fr->iisSetCmd((const char*)$2,$3,$4,$5,$6);} + | UPDATE_ {fr->iisUpdateCmd();} + | WCS_ numeric numeric numeric numeric + numeric numeric numeric numeric INT + {fr->iisWCSCmd(Matrix($2,$3,$4,$5,$6,$7),Vector($8,$9),$10);} + ; + +iisSetFileName : STRING {fr->iisSetFileNameCmd($1);} + | STRING INT {fr->iisSetFileNameCmd($1,$2);} + ; + +iiscursor: INT INT CANVAS_ + {fr->iisSetCursorCmd(Vector($1,$2),Coord::CANVAS);} + | INT INT coordSystem + {fr->iisSetCursorCmd(Vector($1,$2),(Coord::CoordSystem)$3);} + | MODE_ yesno {fr->iisCursorModeCmd($2);} + ; + +load : ARRAY_ loadArr + | ENVI_ loadENVI + | FITS_ loadFits + | INCR_ loadIncr + | NRRD_ loadNRRD + | PHOTO_ loadPhoto + ; + +loadArr : STRING ALLOC_ STRING layerType + {fr->loadArrAllocCmd($3, $1, (Base::LayerType)$4);} + | STRING ALLOCGZ_ STRING layerType + {fr->loadArrAllocGZCmd($3, $1, (Base::LayerType)$4);} + | STRING CHANNEL_ STRING layerType + {fr->loadArrChannelCmd($3, $1, (Base::LayerType)$4);} + | STRING MMAP_ layerType {fr->loadArrMMapCmd($1, (Base::LayerType)$3);} + | STRING MMAPINCR_ layerType + {fr->loadArrMMapIncrCmd($1, (Base::LayerType)$3);} + | STRING SHARED_ shmType INT layerType + {fr->loadArrShareCmd((Base::ShmType)$3, $4, $1, (Base::LayerType)$5);} + | STRING SOCKET_ INT layerType + {fr->loadArrSocketCmd($3, $1, (Base::LayerType)$4);} + | STRING SOCKETGZ_ INT layerType + {fr->loadArrSocketGZCmd($3, $1, (Base::LayerType)$4);} + | STRING VAR_ STRING layerType + {fr->loadArrVarCmd($3, $1, (Base::LayerType)$4);} + | RGB_ CUBE_ loadArrayRGBCube + ; + +loadArrayRGBCube : STRING ALLOC_ STRING {fr->loadArrayRGBCubeAllocCmd($3, $1);} + | STRING ALLOCGZ_ STRING {fr->loadArrayRGBCubeAllocGZCmd($3, $1);} + | STRING CHANNEL_ STRING {fr->loadArrayRGBCubeChannelCmd($3, $1);} + | STRING MMAP_ {fr->loadArrayRGBCubeMMapCmd($1);} + | STRING MMAPINCR_ {fr->loadArrayRGBCubeMMapIncrCmd($1);} + | STRING SHARED_ shmType INT + {fr->loadArrayRGBCubeShareCmd((Base::ShmType)$3, $4, $1);} + | STRING SOCKET_ INT {fr->loadArrayRGBCubeSocketCmd($3, $1);} + | STRING SOCKETGZ_ INT {fr->loadArrayRGBCubeSocketGZCmd($3, $1);} + | STRING VAR_ STRING {fr->loadArrayRGBCubeVarCmd($3, $1);} + ; + +loadENVI : STRING STRING SMMAP_ {fr->loadENVISMMapCmd($1,$2);} + ; + +loadFits: STRING ALLOC_ STRING layerType + {fr->loadFitsAllocCmd($3, $1, (Base::LayerType)$4);} + | STRING ALLOCGZ_ STRING layerType + {fr->loadFitsAllocGZCmd($3, $1, (Base::LayerType)$4);} + | STRING CHANNEL_ STRING layerType + {fr->loadFitsChannelCmd($3, $1, (Base::LayerType)$4);} + | STRING MMAP_ incrLoad layerType + {fr->loadFitsMMapCmd($1, (Base::LayerType)$4);} + | STRING STRING SMMAP_ incrLoad layerType + {fr->loadFitsSMMapCmd($1, $2, (Base::LayerType)$5);} + | STRING MMAPINCR_ incrLoad layerType + {fr->loadFitsMMapIncrCmd($1, (Base::LayerType)$4);} + | STRING SHARED_ shmType INT incrLoad layerType + {fr->loadFitsShareCmd((Base::ShmType)$3, $4, $1, (Base::LayerType)$6);} + | STRING SSHARED_ shmType INT INT incrLoad layerType + {fr->loadFitsSShareCmd((Base::ShmType)$3, $4, $5, $1, + (Base::LayerType)$7);} + | STRING SOCKET_ INT layerType + {fr->loadFitsSocketCmd($3, $1, (Base::LayerType)$4);} + | STRING SOCKETGZ_ INT layerType + {fr->loadFitsSocketGZCmd($3, $1, (Base::LayerType)$4);} + | STRING VAR_ STRING incrLoad layerType + {fr->loadFitsVarCmd($3, $1, (Base::LayerType)$5);} + | SLICE_ loadFitsSlice + | EXT_ CUBE_ loadFitsExtCube + | RGB_ IMAGE_ loadFitsRGBImage + | RGB_ CUBE_ loadFitsRGBCube + | MOSAIC_ loadFitsMosaic + ; + +loadFitsSlice:STRING ALLOC_ STRING {fr->loadSliceAllocCmd($3, $1);} + | STRING ALLOCGZ_ STRING {fr->loadSliceAllocGZCmd($3, $1);} + | STRING CHANNEL_ STRING {fr->loadSliceChannelCmd($3, $1);} + | STRING MMAP_ incrLoad {fr->loadSliceMMapCmd($1);} + | STRING STRING SMMAP_ incrLoad {fr->loadSliceSMMapCmd($1, $2);} + | STRING MMAPINCR_ incrLoad {fr->loadSliceMMapIncrCmd($1);} + | STRING SHARED_ shmType INT incrLoad + {fr->loadSliceShareCmd((Base::ShmType)$3, $4, $1);} + | STRING SSHARED_ shmType INT INT incrLoad + {fr->loadSliceSShareCmd((Base::ShmType)$3, $4, $5, $1);} + | STRING SOCKET_ INT {fr->loadSliceSocketCmd($3, $1);} + | STRING SOCKETGZ_ INT {fr->loadSliceSocketGZCmd($3, $1);} + | STRING VAR_ STRING incrLoad {fr->loadSliceVarCmd($3, $1);} + ; + +loadFitsExtCube: STRING ALLOC_ STRING {fr->loadExtCubeAllocCmd($3, $1);} + | STRING ALLOCGZ_ STRING {fr->loadExtCubeAllocGZCmd($3, $1);} + | STRING CHANNEL_ STRING {fr->loadExtCubeChannelCmd($3, $1);} + | STRING MMAP_ incrLoad {fr->loadExtCubeMMapCmd($1);} + | STRING MMAPINCR_ incrLoad {fr->loadExtCubeMMapIncrCmd($1);} + | STRING SHARED_ shmType INT incrLoad + {fr->loadExtCubeShareCmd((Base::ShmType)$3, $4, $1);} + | STRING SOCKET_ INT {fr->loadExtCubeSocketCmd($3, $1);} + | STRING SOCKETGZ_ INT {fr->loadExtCubeSocketGZCmd($3, $1);} + | STRING VAR_ STRING incrLoad {fr->loadExtCubeVarCmd($3, $1);} + ; + +loadFitsMosaic : IMAGE_ IRAF_ loadFitsMosaicImageIRAF + | IRAF_ loadFitsMosaicIRAF + | IMAGE_ loadFitsMosaicImageWCS + | loadFitsMosaicWCS + | IMAGE_ WFPC2_ loadFitsMosaicImageWFPC2 + ; + +loadFitsMosaicImageIRAF : STRING ALLOC_ STRING layerType + {fr->loadMosaicImageAllocCmd(Base::IRAF, Coord::WCS, + $3, $1, (Base::LayerType)$4);} + | STRING ALLOCGZ_ STRING layerType + {fr->loadMosaicImageAllocGZCmd(Base::IRAF, Coord::WCS, + $3, $1,(Base::LayerType)$4);} + | STRING CHANNEL_ STRING layerType + {fr->loadMosaicImageChannelCmd(Base::IRAF, Coord::WCS, + $3, $1,(Base::LayerType)$4);} + | STRING MMAP_ incrLoad layerType + {fr->loadMosaicImageMMapCmd(Base::IRAF, Coord::WCS, + $1, (Base::LayerType)$4);} + | STRING MMAPINCR_ incrLoad layerType + {fr->loadMosaicImageMMapIncrCmd(Base::IRAF, Coord::WCS, + $1, (Base::LayerType)$4);} + | STRING SHARED_ shmType INT incrLoad layerType + {fr->loadMosaicImageShareCmd(Base::IRAF, Coord::WCS, + (Base::ShmType)$3, $4, $1, (Base::LayerType)$6);} + | STRING SOCKET_ INT layerType + {fr->loadMosaicImageSocketCmd(Base::IRAF, Coord::WCS, + $3, $1, (Base::LayerType)$4);} + | STRING SOCKETGZ_ INT layerType + {fr->loadMosaicImageSocketGZCmd(Base::IRAF, Coord::WCS, + $3, $1, (Base::LayerType)$4);} + | STRING VAR_ STRING incrLoad layerType + {fr->loadMosaicImageVarCmd(Base::IRAF, Coord::WCS, + $3, $1, (Base::LayerType)$5);} + ; + +loadFitsMosaicIRAF : STRING ALLOC_ STRING layerType + {fr->loadMosaicAllocCmd(Base::IRAF, Coord::WCS, + $3, $1, (Base::LayerType)$4);} + | STRING ALLOCGZ_ STRING layerType + {fr->loadMosaicAllocGZCmd(Base::IRAF, Coord::WCS, + $3, $1, (Base::LayerType)$4);} + | STRING CHANNEL_ STRING layerType + {fr->loadMosaicChannelCmd(Base::IRAF, Coord::WCS, + $3, $1, (Base::LayerType)$4);} + | STRING MMAP_ incrLoad layerType + {fr->loadMosaicMMapCmd(Base::IRAF, Coord::WCS, + $1, (Base::LayerType)$4);} + | STRING STRING SMMAP_ incrLoad layerType + {fr->loadMosaicSMMapCmd(Base::IRAF, Coord::WCS, + $1, $2, (Base::LayerType)$5);} + | STRING MMAPINCR_ incrLoad layerType + {fr->loadMosaicMMapIncrCmd(Base::IRAF, Coord::WCS, + $1, (Base::LayerType)$4);} + | STRING SHARED_ shmType INT incrLoad layerType + {fr->loadMosaicShareCmd(Base::IRAF, Coord::WCS, + (Base::ShmType)$3, $4, $1, (Base::LayerType)$6);} + | STRING SSHARED_ shmType INT INT incrLoad layerType + {fr->loadMosaicSShareCmd(Base::IRAF, Coord::WCS, + (Base::ShmType)$3, $4, $5, $1, (Base::LayerType)$7);} + | STRING SOCKET_ INT layerType + {fr->loadMosaicSocketCmd(Base::IRAF, Coord::WCS, + $3, $1, (Base::LayerType)$4);} + | STRING SOCKETGZ_ INT layerType + {fr->loadMosaicSocketGZCmd(Base::IRAF, Coord::WCS, + $3, $1, (Base::LayerType)$4);} + | STRING VAR_ STRING incrLoad layerType + {fr->loadMosaicVarCmd(Base::IRAF, Coord::WCS, + $3, $1, (Base::LayerType)$5);} + ; + +loadFitsMosaicImageWCS : wcsSystem STRING ALLOC_ STRING layerType + {fr->loadMosaicImageAllocCmd(Base::WCSMOSAIC, (Coord::CoordSystem)$1, + $4, $2, (Base::LayerType)$5);} + | wcsSystem STRING ALLOCGZ_ STRING layerType + {fr->loadMosaicImageAllocGZCmd(Base::WCSMOSAIC, + (Coord::CoordSystem)$1, $4, $2, (Base::LayerType)$5);} + | wcsSystem STRING CHANNEL_ STRING layerType + {fr->loadMosaicImageChannelCmd(Base::WCSMOSAIC, + (Coord::CoordSystem)$1, $4, $2, (Base::LayerType)$5);} + | wcsSystem STRING MMAP_ incrLoad layerType + {fr->loadMosaicImageMMapCmd(Base::WCSMOSAIC, (Coord::CoordSystem)$1, + $2, (Base::LayerType)$5);} + | wcsSystem STRING MMAPINCR_ incrLoad layerType + {fr->loadMosaicImageMMapIncrCmd(Base::WCSMOSAIC, + (Coord::CoordSystem)$1, $2, (Base::LayerType)$5);} + | wcsSystem STRING SHARED_ shmType INT incrLoad layerType + {fr->loadMosaicImageShareCmd(Base::WCSMOSAIC, (Coord::CoordSystem)$1, + (Base::ShmType)$4, $5, $2, (Base::LayerType)$7);} + | wcsSystem STRING SOCKET_ INT layerType + {fr->loadMosaicImageSocketCmd(Base::WCSMOSAIC, (Coord::CoordSystem)$1, + $4, $2, (Base::LayerType)$5);} + | wcsSystem STRING SOCKETGZ_ INT layerType + {fr->loadMosaicImageSocketGZCmd(Base::WCSMOSAIC, + (Coord::CoordSystem)$1, $4, $2, (Base::LayerType)$5);} + | wcsSystem STRING VAR_ STRING incrLoad layerType + {fr->loadMosaicImageVarCmd(Base::WCSMOSAIC, (Coord::CoordSystem)$1, + $4, $2, (Base::LayerType)$6);} + ; + +loadFitsMosaicWCS : wcsSystem STRING ALLOC_ STRING layerType + {fr->loadMosaicAllocCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1, + $4, $2, (Base::LayerType)$5);} + | wcsSystem STRING ALLOCGZ_ STRING layerType + {fr->loadMosaicAllocGZCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1, + $4, $2, (Base::LayerType)$5);} + | wcsSystem STRING CHANNEL_ STRING layerType + {fr->loadMosaicChannelCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1, + $4, $2, (Base::LayerType)$5);} + | wcsSystem STRING MMAP_ incrLoad layerType + {fr->loadMosaicMMapCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1, + $2, (Base::LayerType)$5);} + | wcsSystem STRING STRING SMMAP_ incrLoad layerType + {fr->loadMosaicSMMapCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1, + $2, $3, (Base::LayerType)$6);} + | wcsSystem STRING MMAPINCR_ incrLoad layerType + {fr->loadMosaicMMapIncrCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1, + $2, (Base::LayerType)$5);} + | wcsSystem STRING SHARED_ shmType INT incrLoad layerType + {fr->loadMosaicShareCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1, + (Base::ShmType)$4, $5, $2, (Base::LayerType)$7);} + | wcsSystem STRING SSHARED_ shmType INT INT incrLoad layerType + {fr->loadMosaicSShareCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1, + (Base::ShmType)$4, $5, $6, $2, (Base::LayerType)$8);} + | wcsSystem STRING SOCKET_ INT layerType + {fr->loadMosaicSocketCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1, + $4, $2, (Base::LayerType)$5);} + | wcsSystem STRING SOCKETGZ_ INT layerType + {fr->loadMosaicSocketGZCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1, + $4, $2, (Base::LayerType)$5);} + | wcsSystem STRING VAR_ STRING incrLoad layerType + {fr->loadMosaicVarCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1, + $4, $2, (Base::LayerType)$6);} + ; + +loadFitsMosaicImageWFPC2 : STRING ALLOC_ STRING + {fr->loadMosaicImageWFPC2AllocCmd($3, $1);} + | STRING ALLOCGZ_ STRING {fr->loadMosaicImageWFPC2AllocGZCmd($3, $1);} + | STRING CHANNEL_ STRING {fr->loadMosaicImageWFPC2ChannelCmd($3, $1);} + | STRING MMAP_ incrLoad {fr->loadMosaicImageWFPC2MMapCmd($1);} + | STRING MMAPINCR_ incrLoad {fr->loadMosaicImageWFPC2MMapIncrCmd($1);} + | STRING SHARED_ shmType INT incrLoad + {fr->loadMosaicImageWFPC2ShareCmd((Base::ShmType)$3, $4, $1);} + | STRING SOCKET_ INT {fr->loadMosaicImageWFPC2SocketCmd($3, $1);} + | STRING SOCKETGZ_ INT {fr->loadMosaicImageWFPC2SocketGZCmd($3, $1);} + | STRING VAR_ STRING incrLoad {fr->loadMosaicImageWFPC2VarCmd($3, $1);} + ; +loadFitsRGBCube: STRING ALLOC_ STRING {fr->loadRGBCubeAllocCmd($3, $1);} + | STRING ALLOCGZ_ STRING {fr->loadRGBCubeAllocGZCmd($3, $1);} + | STRING CHANNEL_ STRING {fr->loadRGBCubeChannelCmd($3, $1);} + | STRING MMAP_ incrLoad {fr->loadRGBCubeMMapCmd($1);} + | STRING STRING SMMAP_ incrLoad {fr->loadRGBCubeSMMapCmd($1, $2);} + | STRING MMAPINCR_ incrLoad {fr->loadRGBCubeMMapIncrCmd($1);} + | STRING SHARED_ shmType INT incrLoad + {fr->loadRGBCubeShareCmd((Base::ShmType)$3, $4, $1);} + | STRING SSHARED_ shmType INT INT incrLoad + {fr->loadRGBCubeSShareCmd((Base::ShmType)$3, $4, $5, $1);} + | STRING SOCKET_ INT {fr->loadRGBCubeSocketCmd($3, $1);} + | STRING SOCKETGZ_ INT {fr->loadRGBCubeSocketGZCmd($3, $1);} + | STRING VAR_ STRING incrLoad {fr->loadRGBCubeVarCmd($3, $1);} + ; + +loadFitsRGBImage: STRING ALLOC_ STRING {fr->loadRGBImageAllocCmd($3, $1);} + | STRING ALLOCGZ_ STRING {fr->loadRGBImageAllocGZCmd($3, $1);} + | STRING CHANNEL_ STRING {fr->loadRGBImageChannelCmd($3, $1);} + | STRING MMAP_ incrLoad {fr->loadRGBImageMMapCmd($1);} + | STRING MMAPINCR_ incrLoad {fr->loadRGBImageMMapIncrCmd($1);} + | STRING SHARED_ shmType INT incrLoad + {fr->loadRGBImageShareCmd((Base::ShmType)$3, $4, $1);} + | STRING SOCKET_ INT {fr->loadRGBImageSocketCmd($3, $1);} + | STRING SOCKETGZ_ INT {fr->loadRGBImageSocketGZCmd($3, $1);} + | STRING VAR_ STRING incrLoad {fr->loadRGBImageVarCmd($3, $1);} + ; + +loadNRRD : STRING ALLOC_ STRING layerType + {fr->loadNRRDAllocCmd($3, $1, (Base::LayerType)$4);} + | STRING CHANNEL_ STRING layerType + {fr->loadNRRDChannelCmd($3, $1, (Base::LayerType)$4);} + | STRING MMAP_ layerType {fr->loadNRRDMMapCmd($1, (Base::LayerType)$3);} + | STRING SHARED_ shmType INT layerType + {fr->loadNRRDShareCmd((Base::ShmType)$3, $4, $1, (Base::LayerType)$5);} + | STRING SOCKET_ INT layerType + {fr->loadNRRDSocketCmd($3, $1, (Base::LayerType)$4);} + | STRING VAR_ STRING layerType + {fr->loadNRRDVarCmd($3, $1, (Base::LayerType)$4);} + ; + +loadPhoto: /* empty */ STRING STRING {fr->loadPhotoCmd($1,$2);} + | SLICE_ STRING STRING {fr->loadSlicePhotoCmd($2,$3);} + ; + +loadIncr: DATA_ INT INT INT INT INT {fr->loadIncrDataCmd($2,$3,$4,$5,$6);} + | MINMAX_ INT INT INT INT INT {fr->loadIncrMinMaxCmd($2,$3,$4,$5,$6);} + | END_ {fr->loadIncrEndCmd();} + ; + +macosx : PRINT_ { +#ifdef MAC_OSX_TK + fr->macosxPrintCmd(); +#endif + } + ; + +magnifier: yesno {fr->magnifierCmd($1);} + | GRAPHICS_ yesno {fr->magnifierGraphicsCmd($2);} + | CURSOR_ yesno {fr->magnifierCursorCmd($2);} + | COLOR_ STRING {fr->magnifierColorCmd($2);} + | STRING INT INT {fr->magnifierCmd($1, $2, $3);} + | UPDATE_ numeric numeric {fr->updateMagnifierCmd(Vector($2, $3));} + | ZOOM_ numeric {fr->magnifierZoomCmd($2);} + ; + +match : STRING STRING wcsSystem skyFrame STRING STRING wcsSystem skyFrame numeric wcsSystem skyDist STRING + { + fr->matchCmd($1,$2,(Coord::CoordSystem)$3,(Coord::SkyFrame)$4, + $5,$6,(Coord::CoordSystem)$7,(Coord::SkyFrame)$8, + $9,(Coord::CoordSystem)$10,(Coord::SkyDist)$11, + $12); + } + +marker : CENTROID_ markerCentroid + | COLOR_ STRING {fr->markerColorCmd($2);} + | COPY_ {fr->markerCopyCmd();} + | COMMAND_ markerFormat STRING + {fr->markerCommandCmd((Base::MarkerFormat)$2,$3);} + | COMMAND_ markerFormat VAR_ STRING + {fr->markerCommandVarCmd((Base::MarkerFormat)$2,$4);} + | COMPOSITE_ DELETE_ {fr->markerCompositeDeleteCmd();} + | CREATE_ {maperr =0;} markerCreate + | CUT_ {fr->markerCutCmd();} + | DELETE_ {fr->markerDeleteCmd();} + | DELETE_ ALL_ {fr->markerDeleteAllCmd();} + | EDIT_ markerEdit + | EPSILON_ INT {fr->markerEpsilonCmd($2);} + | FONT_ STRING {fr->markerFontCmd($2);} + + | HIGHLITE_ ALL_ {fr->markerHighliteAllCmd();} + | HIGHLITE_ ONLY_ numeric numeric + {fr->markerHighliteOnlyCmd(Vector($3,$4));} + | HIGHLITE_ TOGGLE_ numeric numeric + {fr->markerHighliteToggleCmd(Vector($3,$4));} + + | INT ANALYSIS_ analysisMethod yesno + {fr->markerAnalysisCmd($1, (Marker::AnalysisTask)$3, $4);} + + | INT ANGLE_ angle {fr->markerAngleCmd($1,$3);} + | INT ANGLE_ angle internalSystem {fr->markerAngleCmd($1,$3);} + | INT ANGLE_ angle coordSystem skyFrame + {fr->markerAngleCmd($1,$3,(Coord::CoordSystem)$4, (Coord::SkyFrame)$5);} + + | INT ANNULUS_ RADIUS_ numeric numeric INT internalSystem + {fr->markerAnnulusRadiusCmd($1, $4, $5, $6, (Coord::InternalSystem)$7);} + | INT ANNULUS_ RADIUS_ numeric numeric INT coordSystem skyDist + {fr->markerAnnulusRadiusCmd($1, $4, $5, $6, + (Coord::CoordSystem)$7, (Coord::SkyDist)$8);} + | INT ANNULUS_ RADIUS_ STRING coordSystem skyDist + {fr->markerAnnulusRadiusCmd($1, $4,(Coord::CoordSystem)$5,(Coord::SkyDist)$6);} + + | INT BOXANNULUS_ RADIUS_ numeric numeric numeric INT internalSystem + {fr->markerBoxAnnulusRadiusCmd($1, Vector($4, $5), + Vector($6, $6*$5/$4), $7, (Coord::InternalSystem)$8);} + | INT BOXANNULUS_ RADIUS_ numeric numeric numeric INT + coordSystem skyDist + {fr->markerBoxAnnulusRadiusCmd($1, Vector($4, $5), + Vector($6, $6*$5/$4), $7, (Coord::CoordSystem)$8, (Coord::SkyDist)$9);} + | INT BOXANNULUS_ RADIUS_ STRING coordSystem skyDist + {fr->markerBoxAnnulusRadiusCmd($1,$4,(Coord::CoordSystem)$5,(Coord::SkyDist)$6);} + + | INT BOX_ RADIUS_ numeric numeric internalSystem + {fr->markerBoxRadiusCmd($1, Vector($4,$5), (Coord::InternalSystem)$6);} + | INT BOX_ RADIUS_ numeric numeric coordSystem skyDist + {fr->markerBoxRadiusCmd($1, Vector($4,$5), + (Coord::CoordSystem)$6, (Coord::SkyDist)$7);} + | INT BPANDA_ EDIT_ angle angle INT numeric numeric numeric INT + {fr->markerBpandaEditCmd($1, $4, $5, $6, + Vector($7,$8), Vector($9,$9*$8/$7), $10);} + | INT BPANDA_ EDIT_ angle angle INT numeric numeric numeric INT + internalSystem + {fr->markerBpandaEditCmd($1, $4, $5, $6, + Vector($7,$8), Vector($9,$9*$8/$7), $10);} + | INT BPANDA_ EDIT_ angle angle INT numeric numeric numeric INT + coordSystem skyFrame + {fr->markerBpandaEditCmd($1, $4, $5, $6, + Vector($7,$8), Vector($9,$9*$8/$7), $10, + (Coord::CoordSystem)$11, (Coord::SkyFrame)$12);} + | INT BPANDA_ EDIT_ STRING STRING coordSystem skyFrame + coordSystem skyDist + {fr->markerBpandaEditCmd($1, $4, $5, + (Coord::CoordSystem)$6, (Coord::SkyFrame)$7, (Coord::CoordSystem)$8, (Coord::SkyDist)$9);} + + | INT CALLBACK_ markerCallBack STRING STRING + {fr->markerCallBackCmd($1,(CallBack::Type)$3,$4,$5);} + | INT CIRCLE_ RADIUS_ numeric internalSystem + {fr->markerCircleRadiusCmd($1, $4, (Coord::InternalSystem)$5);} + | INT CIRCLE_ RADIUS_ numeric coordSystem skyDist + {fr->markerCircleRadiusCmd($1, $4, (Coord::CoordSystem)$5, (Coord::SkyDist)$6);} + | INT COLOR_ STRING {fr->markerColorCmd($1,$3);} + | INT COMPASS_ ARROW_ yesno yesno + {fr->markerCompassArrowCmd($1,$4,$5);} + | INT COMPASS_ LABEL_ STRING STRING + {fr->markerCompassLabelCmd($1,$4,$5);} + | INT COMPASS_ RADIUS_ numeric internalSystem + {fr->markerCompassRadiusCmd($1,$4,(Coord::InternalSystem)$5);} + | INT COMPASS_ RADIUS_ numeric coordSystem skyDist + {fr->markerCompassRadiusCmd($1,$4,(Coord::CoordSystem)$5,(Coord::SkyDist)$6);} + | INT COMPASS_ SYSTEM_ coordSystem skyFrame + {fr->markerCompassSystemCmd($1, (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);} + | INT COMPOSITE_ GLOBAL_ yesno {fr->markerCompositeCmd($1,$4);} + | INT CPANDA_ EDIT_ angle angle INT numeric numeric INT + {fr->markerCpandaEditCmd($1, $4, $5, $6, $7, $8, $9);} + | INT CPANDA_ EDIT_ angle angle INT numeric numeric INT internalSystem + {fr->markerCpandaEditCmd($1, $4, $5, $6, $7, $8, $9);} + | INT CPANDA_ EDIT_ angle angle INT numeric numeric INT + coordSystem skyFrame + {fr->markerCpandaEditCmd($1, $4, $5, $6, $7, $8, $9, + (Coord::CoordSystem)$10, (Coord::SkyFrame)$11);} + | INT CPANDA_ EDIT_ STRING STRING coordSystem skyFrame + coordSystem skyDist + {fr->markerCpandaEditCmd($1, $4, $5, (Coord::CoordSystem)$6, (Coord::SkyFrame)$7, + (Coord::CoordSystem)$8, (Coord::SkyDist)$9);} + + | INT CREATE_ ANNULUS_ RADIUS_ numeric numeric + {fr->markerAnnulusCreateRadiusCmd($1,Vector($5,$6));} + | INT CREATE_ BOXANNULUS_ RADIUS_ numeric numeric + {fr->markerBoxAnnulusCreateRadiusCmd($1,Vector($5,$6));} + | INT CREATE_ BPANDA_ ANGLE_ numeric numeric + {fr->markerBpandaCreateAnglesCmd($1,Vector($5,$6));} + | INT CREATE_ BPANDA_ RADIUS_ numeric numeric + {fr->markerBpandaCreateRadiusCmd($1,Vector($5,$6));} + | INT CREATE_ ELLIPSEANNULUS_ RADIUS_ numeric numeric + {fr->markerEllipseAnnulusCreateRadiusCmd($1,Vector($5,$6));} + | INT CREATE_ EPANDA_ ANGLE_ numeric numeric + {fr->markerEpandaCreateAnglesCmd($1,Vector($5,$6));} + | INT CREATE_ EPANDA_ RADIUS_ numeric numeric + {fr->markerEpandaCreateRadiusCmd($1,Vector($5,$6));} + | INT CREATE_ CPANDA_ ANGLE_ numeric numeric + {fr->markerCpandaCreateAnglesCmd($1,Vector($5,$6));} + | INT CREATE_ CPANDA_ RADIUS_ numeric numeric + {fr->markerCpandaCreateRadiusCmd($1,Vector($5,$6));} + | INT CREATE_ POLYGON_ VERTEX_ INT numeric numeric + {fr->markerPolygonCreateVertexCmd($1,$5,Vector($6,$7));} + | INT CREATE_ SEGMENT_ VERTEX_ INT numeric numeric + {fr->markerSegmentCreateVertexCmd($1,$5,Vector($6,$7));} + + | INT DELETE_ {fr->markerDeleteCmd($1);} + | INT DELETE_ ANNULUS_ INT + {fr->markerAnnulusDeleteRadiusCmd($1,$4);} + | INT DELETE_ BOXANNULUS_ INT + {fr->markerBoxAnnulusDeleteRadiusCmd($1,$4);} + | INT DELETE_ BPANDA_ INT {fr->markerBpandaDeleteCmd($1,$4);} + | INT DELETE_ ELLIPSEANNULUS_ INT + {fr->markerEllipseAnnulusDeleteRadiusCmd($1,$4);} + | INT DELETE_ CALLBACK_ markerCallBack STRING + {fr->markerDeleteCallBackCmd($1,(CallBack::Type)$4,$5);} + | INT DELETE_ EPANDA_ INT {fr->markerEpandaDeleteCmd($1,$4);} + | INT DELETE_ CPANDA_ INT {fr->markerCpandaDeleteCmd($1,$4);} + | INT DELETE_ POLYGON_ VERTEX_ INT + {fr->markerPolygonDeleteVertexCmd($1,$5);} + | INT DELETE_ SEGMENT_ VERTEX_ INT + {fr->markerSegmentDeleteVertexCmd($1,$5);} + | INT DELETE_ TAG_ {fr->markerDeleteTagCmd($1);} + | INT DELETE_ TAG_ STRING {fr->markerDeleteTagCmd($1,$4);} + | INT DELETE_ TAG_ INT {fr->markerDeleteTagCmd($1,$4);} + + | INT EDIT_ BEGIN_ INT {fr->markerEditBeginCmd($1,$4);} + | INT ELLIPSE_ RADIUS_ numeric numeric internalSystem + {fr->markerEllipseRadiusCmd($1, Vector($4, $5), (Coord::InternalSystem)$6);} + | INT ELLIPSE_ RADIUS_ numeric numeric coordSystem skyDist + {fr->markerEllipseRadiusCmd($1, Vector($4, $5), + (Coord::CoordSystem)$6, (Coord::SkyDist)$7);} + | INT ELLIPSEANNULUS_ RADIUS_ numeric numeric numeric INT + internalSystem + {fr->markerEllipseAnnulusRadiusCmd($1, Vector($4,$5), + Vector($6,$6*$5/$4), $7, (Coord::InternalSystem)$8);} + | INT ELLIPSEANNULUS_ RADIUS_ numeric numeric numeric INT + coordSystem skyDist + {fr->markerEllipseAnnulusRadiusCmd($1, Vector($4,$5), + Vector($6,$6*$5/$4), $7, (Coord::CoordSystem)$8, (Coord::SkyDist)$9);} + | INT ELLIPSEANNULUS_ RADIUS_ STRING coordSystem skyDist + {fr->markerEllipseAnnulusRadiusCmd($1, $4, + (Coord::CoordSystem)$5, (Coord::SkyDist)$6);} + | INT EPANDA_ EDIT_ angle angle INT numeric numeric numeric INT + {fr->markerEpandaEditCmd($1, $4, $5, $6, + Vector($7,$8), Vector($9,$9*$8/$7), $10);} + | INT EPANDA_ EDIT_ angle angle INT numeric numeric numeric INT + internalSystem + {fr->markerEpandaEditCmd($1, $4, $5, $6, + Vector($7,$8), Vector($9,$9*$8/$7), $10);} + | INT EPANDA_ EDIT_ angle angle INT numeric numeric numeric INT + coordSystem skyFrame + {fr->markerEpandaEditCmd($1, $4, $5, $6, + Vector($7,$8), Vector($9,$9*$8/$7), $10, + (Coord::CoordSystem)$11, (Coord::SkyFrame)$12);} + | INT EPANDA_ EDIT_ STRING STRING coordSystem skyFrame + coordSystem skyDist + {fr->markerEpandaEditCmd($1, $4, $5, + (Coord::CoordSystem)$6, (Coord::SkyFrame)$7, + (Coord::CoordSystem)$8, (Coord::SkyDist)$9);} + + | INT FONT_ STRING {fr->markerFontCmd($1,$3);} + | INT HIGHLITE_ {fr->markerHighliteCmd($1);} + | INT HIGHLITE_ ONLY_{fr->markerHighliteOnlyCmd($1);} + + | INT LINE_ ARROW_ yesno yesno {fr->markerLineArrowCmd($1,$4,$5);} + | INT LINE_ POINT_ internalSystem coord coord + {fr->markerLineCmd($1, Vector($5), Vector($6), (Coord::InternalSystem)$4);} + | INT LINE_ POINT_ coordSystem skyFrame coord coord + {fr->markerLineCmd($1, Vector($6), Vector($7), + (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);} + + | INT MOVE_ numeric numeric + {fr->markerMoveCmd($1, Vector($3,$4));} + | INT MOVE_ FRONT_ {fr->markerFrontCmd($1);} + | INT MOVE_ BACK_ {fr->markerBackCmd($1);} + | INT MOVE_ TO_ internalSystem numeric numeric + {fr->markerMoveToCmd($1, Vector($5,$6), (Coord::InternalSystem)$4);} + | INT MOVE_ TO_ coordSystem skyFrame coord + {fr->markerMoveToCmd($1,Vector($6),(Coord::CoordSystem)$4,(Coord::SkyFrame)$5);} + + | INT POLYGON_ RESET_ numeric numeric internalSystem + {fr->markerPolygonResetCmd($1, Vector($4,$5),(Coord::InternalSystem)$6);} + | INT POLYGON_ RESET_ numeric numeric coordSystem skyDist + {fr->markerPolygonResetCmd($1, Vector($4,$5), + (Coord::CoordSystem)$6, (Coord::SkyDist)$7);} + | INT SEGMENT_ RESET_ numeric numeric internalSystem + {fr->markerSegmentResetCmd($1, Vector($4,$5),(Coord::InternalSystem)$6);} + | INT SEGMENT_ RESET_ numeric numeric coordSystem skyDist + {fr->markerSegmentResetCmd($1, Vector($4,$5), + (Coord::CoordSystem)$6, (Coord::SkyDist)$7);} + | INT POINT_ SHAPE_ pointShape + {fr->markerPointShapeCmd($1,(Point::PointShape)$4);} + | INT POINT_ SIZE_ INT {fr->markerPointSizeCmd($1,$4);} + + | INT PROJECTION_ internalSystem coord coord numeric + {fr->markerProjectionCmd($1, Vector($4), Vector($5), + (Coord::InternalSystem)$3, $6);} + | INT PROJECTION_ coordSystem skyFrame coord coord numeric + coordSystem skyDist + {fr->markerProjectionCmd($1, Vector($5), Vector($6), + (Coord::CoordSystem)$3, (Coord::SkyFrame)$4, $7, + (Coord::CoordSystem)$8, (Coord::SkyDist)$9);} + | INT PROPERTY_ markerProperty yesno + {fr->markerPropertyCmd($1,$3,$4);} + + | INT ROTATE_ BEGIN_ {fr->markerRotateBeginCmd($1);} + | INT RULER_ POINT_ internalSystem coord coord + {fr->markerRulerPointCmd($1, Vector($5), Vector($6), + (Coord::InternalSystem)$4);} + | INT RULER_ POINT_ coordSystem skyFrame coord coord + {fr->markerRulerPointCmd($1, Vector($6), Vector($7), + (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);} + | INT RULER_ SYSTEM_ coordSystem skyFrame coordSystem skyDist + {fr->markerRulerSystemCmd($1, (Coord::CoordSystem)$4, (Coord::SkyFrame)$5, + (Coord::CoordSystem)$6, (Coord::SkyDist)$7);} + + | INT SELECT_ {fr->markerSelectCmd($1);} + | INT SELECT_ ONLY_ {fr->markerSelectOnlyCmd($1);} + + | INT TAG_ STRING {fr->markerTagCmd($1,$3);} + | INT TEXT_ STRING {fr->markerTextCmd($1,$3);} + | INT TEXT_ ROTATE_ yesno {fr->markerTextRotateCmd($1,$4);} + + | INT UNHIGHLITE_ {fr->markerUnhighliteCmd($1);} + | INT UNSELECT_ {fr->markerUnselectCmd($1);} + + | INT VECTOR_ ARROW_ yesno {fr->markerVectorArrowCmd($1,$4);} + | INT VECTOR_ POINT_ internalSystem coord numeric angle + {fr->markerVectorCmd($1, Vector($5), (Coord::InternalSystem)$4, $6, $7);} + | INT VECTOR_ POINT_ coordSystem skyFrame coord + coordSystem skyDist numeric angle + {fr->markerVectorCmd($1, Vector($6), (Coord::CoordSystem)$4, (Coord::SkyFrame)$5, + $9, (Coord::CoordSystem)$7, (Coord::SkyDist)$8, $10);} + + | INT WIDTH_ INT {fr->markerLineWidthCmd($1,$3);} + + | KEY_ {fr->markerKeyCmd();} + | KEY_ numeric numeric {fr->markerKeyCmd(Vector($2,$3));} + + | LIST_ markerList + | LOAD_ markerLoad + | MOVE_ markerMoveSelected + | PRESERVE_ yesno {fr->markerPreserveCmd($2);} + | PROPERTY_ markerProperty yesno {fr->markerPropertyCmd($2,$3);} + | PROPERTY_ markerProperty yesno numeric numeric + {fr->markerPropertyCmd($2,$3,Vector($4,$5));} + | ROTATE_ BEGIN_ numeric numeric + {fr->markerRotateBeginCmd(Vector($3,$4));} + | ROTATE_ MOTION_ numeric numeric INT + {fr->markerRotateMotionCmd(Vector($3,$4),$5);} + | ROTATE_ END_ {fr->markerRotateEndCmd();} + | SAVE_ STRING markerFormat coordSystem skyFrame skyFormat yesno + {fr->markerSaveCmd($2, (Base::MarkerFormat)$3, (Coord::CoordSystem)$4, (Coord::SkyFrame)$5, (Coord::SkyFormat)$6, $7);} + | SAVE_ TEMPLATE_ STRING {fr->markerSaveTemplateCmd($3);} + | SELECT_ markerSelect + + | SHOW_ markerShow + + | STRING COLOR_ STRING {fr->markerColorCmd($1,$3);} + | STRING COPY_ {fr->markerCopyCmd($1);} + | STRING DELETE_ {fr->markerDeleteCmd($1);} + | STRING CUT_ {fr->markerCutCmd($1);} + | STRING FONT_ STRING {fr->markerFontCmd($1,$3);} + | STRING HIGHLITE_ {fr->markerHighliteCmd($1);} + | STRING HIGHLITE_ ONLY_ {fr->markerHighliteOnlyCmd($1);} + | STRING MOVE_ numeric numeric {fr->markerMoveCmd($1,Vector($3,$4));} + | STRING MOVE_ FRONT_ {fr->markerFrontCmd($1);} + | STRING MOVE_ BACK_ {fr->markerBackCmd($1);} + | STRING MOVE_ TO_ internalSystem coord + {fr->markerMoveToCmd($1,Vector($5),(Coord::InternalSystem)$4);} + | STRING MOVE_ TO_ coordSystem skyFrame coord + {fr->markerMoveToCmd($1,Vector($6),(Coord::CoordSystem)$4,(Coord::SkyFrame)$5);} + | STRING PROPERTY_ markerProperty yesno + {fr->markerPropertyCmd($1,$3,$4);} + | STRING SELECT_ {fr->markerSelectCmd($1);} + | STRING SELECT_ ONLY_ {fr->markerSelectOnlyCmd($1);} + | STRING UNHIGHLITE_ {fr->markerUnhighliteCmd($1);} + | STRING UNSELECT_ {fr->markerUnselectCmd($1);} + + | TAG_ EDIT_ STRING STRING {fr->markerTagEditCmd($3,$4);} + | TAG_ DELETE_ STRING {fr->markerTagDeleteCmd($3);} + | TAG_ DELETE_ ALL_ {fr->markerTagDeleteAllCmd();} + | TAG_ STRING {fr->markerTagCmd($2);} + | TAG_ UPDATE_ STRING {fr->markerTagUpdateCmd($3);} + + | PASTE_ {fr->markerPasteCmd();} + | PASTE_ coordSystem {fr->markerPasteCmd((Coord::CoordSystem)$2);} + | UNDO_ {fr->markerUndoCmd();} + | UNHIGHLITE_ ALL_ {fr->markerUnhighliteAllCmd();} + | UNSELECT_ ALL_ {fr->markerUnselectAllCmd();} + | WIDTH_ INT {fr->markerLineWidthCmd($2);} + ; + +markerCallBack : SELECT_ {$$ = CallBack::SELECTCB;} + | UNSELECT_ {$$ = CallBack::UNSELECTCB;} + | HIGHLITE_ {$$ = CallBack::HIGHLITECB;} + | UNHIGHLITE_ {$$ = CallBack::UNHIGHLITECB;} + | BEGIN_ MOVE_ {$$ = CallBack::MOVEBEGINCB;} + | MOVE_ {$$ = CallBack::MOVECB;} + | END_ MOVE_ {$$ = CallBack::MOVEENDCB;} + | BEGIN_ EDIT_ {$$ = CallBack::EDITBEGINCB;} + | EDIT_ {$$ = CallBack::EDITCB;} + | END_ EDIT_ {$$ = CallBack::EDITENDCB;} + | BEGIN_ ROTATE_ {$$ = CallBack::ROTATEBEGINCB;} + | ROTATE_ {$$ = CallBack::ROTATECB;} + | END_ ROTATE_ {$$ = CallBack::ROTATEENDCB;} + | DELETE_ {$$ = CallBack::DELETECB;} + | TEXT_ {$$ = CallBack::TEXTCB;} + | COLOR_ {$$ = CallBack::COLORCB;} + | WIDTH_ {$$ = CallBack::LINEWIDTHCB;} + | PROPERTY_ {$$ = CallBack::PROPERTYCB;} + | FONT_ {$$ = CallBack::FONTCB;} + | KEY_ {$$ = CallBack::KEYCB;} + | UPDATE_ {$$ = CallBack::UPDATECB;} + ; + +markerCentroid : /* empty */ {fr->markerCentroidCmd();} + | INT {fr->markerCentroidCmd($1);} + | AUTO_ yesno {fr->markerCentroidAutoCmd($2);} + | RADIUS_ numeric {fr->markerCentroidRadiusCmd($2);} + | ITERATION_ INT {fr->markerCentroidIterationCmd($2);} + | OPTION_ INT numeric + { + fr->markerCentroidIterationCmd($2); + fr->markerCentroidRadiusCmd($3); + } + ; + +markerCreate : + CIRCLE_ numeric numeric + numeric + markerProperties + {fr->createCircleCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + $4, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | ELLIPSE_ numeric numeric + numeric numeric + optangle + markerProperties + {fr->createEllipseCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + Vector($4,$5), + $6, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | BOX_ numeric numeric + numeric numeric + optangle + markerProperties + {fr->createBoxCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + Vector($4,$5), + $6, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | POLYGON_ numeric numeric + numeric numeric + markerProperties + {fr->createPolygonCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + Vector($4,$5), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | SEGMENT_ numeric numeric + numeric numeric + markerProperties + {fr->createSegmentCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + Vector($4,$5), + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | LINE_ numeric numeric + numeric numeric + markerProperties + {fr->createLineCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + fr->mapToRef(Vector($4,$5),Coord::CANVAS), + 0, 0, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | VECTOR_ numeric numeric + numeric numeric + markerProperties + {fr->createVectCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + fr->mapToRef(Vector($4,$5),Coord::CANVAS), + 1, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | TEXT_ numeric numeric + optangle + markerProperties + {fr->createTextCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + $4, 1, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | CIRCLE_ POINT_ numeric numeric pointSize markerProperties + {fr->createPointCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS), + Point::CIRCLE, $5, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | BOX_ POINT_ numeric numeric pointSize markerProperties + {fr->createPointCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS), + Point::BOX, $5, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | DIAMOND_ POINT_ numeric numeric pointSize markerProperties + {fr->createPointCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS), + Point::DIAMOND, $5, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | CROSS_ POINT_ numeric numeric pointSize markerProperties + {fr->createPointCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS), + Point::CROSS, $5, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | 'X' POINT_ numeric numeric pointSize markerProperties + {fr->createPointCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS), + Point::EX, $5, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | ARROW_ POINT_ numeric numeric pointSize markerProperties + {fr->createPointCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS), + Point::ARROW, $5, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | BOXCIRCLE_ POINT_ numeric numeric pointSize markerProperties + {fr->createPointCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS), + Point::BOXCIRCLE, $5, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + + | RULER_ numeric numeric + numeric numeric + coordSystem skyFrame coordSystem skyDist + markerProperties + {fr->createRulerCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + fr->mapToRef(Vector($4,$5),Coord::CANVAS), + (Coord::CoordSystem)$6, (Coord::SkyFrame)$7, (Coord::CoordSystem)$8, (Coord::SkyDist)$9, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | COMPASS_ numeric numeric + numeric + coordSystem skyFrame + markerProperties + {fr->createCompassCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + $4, + "N", "E", 1, 1, + (Coord::CoordSystem)$5, (Coord::SkyFrame)$6, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | PROJECTION_ numeric numeric + numeric numeric + numeric + markerProperties + {fr->createProjectionCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + fr->mapToRef(Vector($4,$5),Coord::CANVAS), + $6, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + + | ANNULUS_ numeric numeric + numeric numeric INT + markerProperties + {fr->createAnnulusCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + $4,$5,$6, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | ELLIPSEANNULUS_ numeric numeric + numeric numeric numeric INT + optangle + markerProperties + {fr->createEllipseAnnulusCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + Vector($4,$5), + Vector($6,$6*$4/$5),$7, + $8, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | BOXANNULUS_ numeric numeric + numeric numeric numeric INT + optangle + markerProperties + {fr->createBoxAnnulusCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + Vector($4,$5),Vector($6,$6*$4/$5),$7, + $8, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + + | CPANDA_ numeric numeric + angle angle INT + numeric numeric INT + markerProperties + {fr->createCpandaCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + $4,$5,$6, + $7,$8,$9, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | EPANDA_ numeric numeric + angle angle INT + numeric numeric numeric INT + optangle + markerProperties + {fr->createEpandaCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + $4,$5,$6, + Vector($7,$8), + Vector($9,$9*$7/$8),$10, + $11, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + | BPANDA_ numeric numeric + angle angle INT + numeric numeric numeric INT + optangle + markerProperties + {fr->createBpandaCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), + $4,$5,$6, + Vector($7,$8), + Vector($9,$9*$7/$8),$10, + $11, + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + + | COMPOSITE_ markerProperties + {fr->createCompositeCmd( + currentColor,currentDash,currentWidth,currentFont, + currentText,currentProps,NULL,taglist,cblist);} + + | TEMPLATE_ markerCreateTemplate + ; + +markerCreateTemplate : STRING numeric numeric + {fr->createTemplateCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), $1);} + | VAR_ STRING numeric numeric + {fr->createTemplateVarCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS), $2);} + | numeric numeric VAR_ STRING + { + // backward compatibility + fr->createTemplateVarCmd(fr->mapToRef(Vector($1,$2),Coord::CANVAS), $4); + } + | STRING coordSystem skyFrame coord + {fr->createTemplateCmd(Vector($4),(Coord::CoordSystem)$2,(Coord::SkyFrame)$3, $1);} + ; + +markerDash : INT INT {$$[0] = $1; $$[1] = $2;} + ; + +markerEdit : BEGIN_ numeric numeric INT + {fr->markerEditBeginCmd(Vector($2,$3),$4);} + | MOTION_ numeric numeric INT + {fr->markerEditMotionCmd(Vector($2,$3),$4);} + | END_ {fr->markerEditEndCmd();} + ; + +markerFormat : DS9_ {$$ = Base::DS9;} + | XML_ {$$ = Base::XML;} + | CIAO_ {$$ = Base::CIAO;} + | SAOTNG_ {$$ = Base::SAOTNG;} + | SAOIMAGE_ {$$ = Base::SAOIMAGE;} + | PROS_ {$$ = Base::PROS;} + | XY_ {$$ = Base::RAWXY;} + ; + +markerGet : CENTROID_ markerGetCentroid + | COLOR_ {fr->getMarkerColorCmd();} + | FONT_ {fr->getMarkerFontCmd();} + | EPSILON_ {fr->getMarkerEpsilonCmd();} + | HANDLE_ numeric numeric {fr->getMarkerHandleCmd(Vector($2,$3));} + | ID_ numeric numeric {fr->getMarkerIdCmd(Vector($2,$3));} + + | HIDE_ ANALYSIS_ CPANDA_ coordSystem + {fr->getMarkerAnalysisPandaCmd((Coord::CoordSystem)$4);} + | HIDE_ ANALYSIS_ HISTOGRAM_ STRING STRING INT + {fr->getMarkerAnalysisHistogramCmd($4,$5,$6);} + | HIDE_ ANALYSIS_ PLOT2D_ STRING STRING STRING STRING coordSystem skyFrame analysisParam + {fr->getMarkerAnalysisPlot2dCmd($4,$5,$6,$7,(Coord::CoordSystem)$8, (Coord::SkyFrame)$9, (Marker::AnalysisMethod)$10);} + | HIDE_ ANALYSIS_ PLOT3D_ STRING STRING coordSystem analysisParam + {fr->getMarkerAnalysisPlot3dCmd($4,$5,(Coord::CoordSystem)$6,(Marker::AnalysisMethod)$7);} + | HIDE_ ANALYSIS_ RADIAL_ STRING STRING STRING coordSystem + {fr->getMarkerAnalysisRadialCmd($4,$5,$6,(Coord::CoordSystem)$7);} + | HIDE_ ANALYSIS_ STATS_ coordSystem skyFrame + {fr->getMarkerAnalysisStatsCmd((Coord::CoordSystem)$4, (Coord::SkyFrame)$5);} + + | INT ANALYSIS_ CPANDA_ coordSystem + {fr->getMarkerAnalysisPandaCmd($1,(Coord::CoordSystem)$4);} + | INT ANALYSIS_ HISTOGRAM_ STRING STRING INT + {fr->getMarkerAnalysisHistogramCmd($1,$4,$5,$6);} + | INT ANALYSIS_ PLOT2D_ STRING STRING STRING STRING coordSystem skyFrame analysisParam + {fr->getMarkerAnalysisPlot2dCmd($1,$4,$5,$6,$7,(Coord::CoordSystem)$8, (Coord::SkyFrame)$9, (Marker::AnalysisMethod)$10);} + | INT ANALYSIS_ PLOT3D_ STRING STRING coordSystem analysisParam + {fr->getMarkerAnalysisPlot3dCmd($1,$4,$5,(Coord::CoordSystem)$6,(Marker::AnalysisMethod)$7);} + | INT ANALYSIS_ RADIAL_ STRING STRING STRING coordSystem + {fr->getMarkerAnalysisRadialCmd($1,$4,$5,$6,(Coord::CoordSystem)$7);} + | INT ANALYSIS_ STATS_ coordSystem skyFrame + {fr->getMarkerAnalysisStatsCmd($1,(Coord::CoordSystem)$4, (Coord::SkyFrame)$5);} + + | ID_ ALL_ {fr->getMarkerIdAllCmd();} + | INT ANGLE_ {fr->getMarkerAngleCmd($1);} + | INT ANGLE_ internalSystem {fr->getMarkerAngleCmd($1);} + | INT ANGLE_ coordSystem skyFrame + {fr->getMarkerAngleCmd($1,(Coord::CoordSystem)$3, (Coord::SkyFrame)$4);} + | INT ANNULUS_ RADIUS_ coordSystem skyDist + {fr->getMarkerAnnulusRadiusCmd($1, (Coord::CoordSystem)$4, (Coord::SkyDist)$5);} + + | INT BOXANNULUS_ RADIUS_ coordSystem skyDist + {fr->getMarkerBoxAnnulusRadiusCmd($1,(Coord::CoordSystem)$4,(Coord::SkyDist)$5);} + | INT BOX_ RADIUS_ coordSystem skyDist + {fr->getMarkerBoxRadiusCmd($1,(Coord::CoordSystem)$4, (Coord::SkyDist)$5);} + | INT BPANDA_ ANGLE_ {fr->getMarkerBpandaAnglesCmd($1);} + | INT BPANDA_ ANGLE_ internalSystem {fr->getMarkerBpandaAnglesCmd($1);} + | INT BPANDA_ ANGLE_ coordSystem skyFrame + {fr->getMarkerBpandaAnglesCmd($1, (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);} + | INT BPANDA_ RADIUS_ coordSystem skyDist + {fr->getMarkerBpandaRadiusCmd($1, (Coord::CoordSystem)$4, (Coord::SkyDist)$5);} + + | INT CENTER_ coordSystem skyFrame skyFormat + {fr->getMarkerCenterCmd($1, (Coord::CoordSystem)$3, (Coord::SkyFrame)$4, + (Coord::SkyFormat)$5);} + | INT CIRCLE_ RADIUS_ coordSystem skyDist + {fr->getMarkerCircleRadiusCmd($1, (Coord::CoordSystem)$4, (Coord::SkyDist)$5);} + | INT COLOR_ {fr->getMarkerColorCmd($1);} + | INT COMPASS_ ARROW_ {fr->getMarkerCompassArrowCmd($1);} + | INT COMPASS_ LABEL_ {fr->getMarkerCompassLabelCmd($1);} + | INT COMPASS_ RADIUS_ coordSystem skyDist + {fr->getMarkerCompassRadiusCmd($1, (Coord::CoordSystem)$4, (Coord::SkyDist)$5);} + | INT COMPASS_ SYSTEM_ {fr->getMarkerCompassSystemCmd($1);} + | INT COMPOSITE_ GLOBAL_ {fr->getMarkerCompositeCmd($1);} + | INT CPANDA_ ANGLE_ {fr->getMarkerCpandaAnglesCmd($1);} + | INT CPANDA_ ANGLE_ internalSystem {fr->getMarkerCpandaAnglesCmd($1);} + | INT CPANDA_ ANGLE_ coordSystem skyFrame + {fr->getMarkerCpandaAnglesCmd($1, (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);} + | INT CPANDA_ RADIUS_ coordSystem skyDist + {fr->getMarkerCpandaRadiusCmd($1, (Coord::CoordSystem)$4, (Coord::SkyDist)$5);} + | INT ELLIPSE_ RADIUS_ coordSystem skyDist + {fr->getMarkerEllipseRadiusCmd($1, (Coord::CoordSystem)$4, (Coord::SkyDist)$5);} + | INT ELLIPSEANNULUS_ RADIUS_ coordSystem skyDist + {fr->getMarkerEllipseAnnulusRadiusCmd($1, (Coord::CoordSystem)$4, + (Coord::SkyDist)$5);} + | INT EPANDA_ ANGLE_ {fr->getMarkerEpandaAnglesCmd($1);} + | INT EPANDA_ ANGLE_ internalSystem {fr->getMarkerEpandaAnglesCmd($1);} + | INT EPANDA_ ANGLE_ coordSystem skyFrame + {fr->getMarkerEpandaAnglesCmd($1, (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);} + | INT EPANDA_ RADIUS_ coordSystem skyDist + {fr->getMarkerEpandaRadiusCmd($1, (Coord::CoordSystem)$4, (Coord::SkyDist)$5);} + | INT FONT_ {fr->getMarkerFontCmd($1);} + | INT HIGHLITE_ {fr->getMarkerHighlitedCmd($1);} + | INT LINE_ ARROW_ {fr->getMarkerLineArrowCmd($1);} + | INT LINE_ LENGTH_ coordSystem skyDist + {fr->getMarkerLineLengthCmd($1, (Coord::CoordSystem)$4, (Coord::SkyDist)$5);} + | INT LINE_ POINT_ coordSystem skyFrame skyFormat + {fr->getMarkerLineCmd($1, (Coord::CoordSystem)$4, + (Coord::SkyFrame)$5, (Coord::SkyFormat)$6);} + | INT MAP_ LENGTH_ numeric coordSystem skyDist + {fr->getMarkerMapLenFromRefCmd($1, $4, + (Coord::CoordSystem)$5,(Coord::SkyDist)$6);} + + | INT POINT_ SHAPE_ {fr->getMarkerPointShapeCmd($1);} + | INT POINT_ SIZE_ {fr->getMarkerPointSizeCmd($1);} + | INT PROJECTION_ POINT_ coordSystem skyFrame skyFormat + {fr->getMarkerProjectionPointsCmd($1, (Coord::CoordSystem)$4, + (Coord::SkyFrame)$5, (Coord::SkyFormat)$6);} + | INT PROJECTION_ LENGTH_ coordSystem skyDist + {fr->getMarkerProjectionLengthCmd($1, (Coord::CoordSystem)$4, + (Coord::SkyDist)$5);} + | INT PROJECTION_ THICK_ coordSystem skyDist + {fr->getMarkerProjectionWidthCmd($1,(Coord::CoordSystem)$4,(Coord::SkyDist)$5);} + | INT PROPERTY_ {fr->getMarkerPropertyCmd($1);} + | INT PROPERTY_ markerProperty {fr->getMarkerPropertyCmd($1,$3);} + | INT RULER_ LENGTH_ coordSystem skyDist + {fr->getMarkerRulerLengthCmd($1,(Coord::CoordSystem)$4,(Coord::SkyDist)$5);} + | INT RULER_ POINT_ coordSystem skyFrame skyFormat + {fr->getMarkerRulerPointCmd($1, (Coord::CoordSystem)$4, + (Coord::SkyFrame)$5, (Coord::SkyFormat)$6);} + | INT RULER_ SYSTEM_ {fr->getMarkerRulerSystemCmd($1);} + | INT SELECT_ {fr->getMarkerSelectedCmd($1);} + + | INT TAG_ {fr->getMarkerTagCmd($1);} + | INT TAG_ INT {fr->getMarkerTagCmd($1,$3);} + | INT TEXT_ {fr->getMarkerTextCmd($1);} + | INT TEXT_ ROTATE_ {fr->getMarkerTextRotateCmd($1);} + | INT TYPE_ {fr->getMarkerTypeCmd($1);} + + | INT VECTOR_ ARROW_ {fr->getMarkerVectorArrowCmd($1);} + | INT VECTOR_ LENGTH_ coordSystem skyDist + {fr->getMarkerVectorLengthCmd($1, (Coord::CoordSystem)$4, (Coord::SkyDist)$5);} + | INT VECTOR_ POINT_ coordSystem skyFrame skyFormat + {fr->getMarkerVectorCmd($1, (Coord::CoordSystem)$4, + (Coord::SkyFrame)$5, (Coord::SkyFormat)$6);} + | INT WIDTH_ {fr->getMarkerLineWidthCmd($1);} + | HIGHLITE_ markerGetHighlite + | HIGHLITE_ NUMBER_ {fr->getMarkerHighlitedNumberCmd();} + | NUMBER_ {fr->getMarkerNumberCmd();} + | POLYGON_ SEGMENT_ numeric numeric + {fr->getMarkerPolygonSegmentCmd(Vector($3,$4));} + | SEGMENT_ SEGMENT_ numeric numeric + {fr->getMarkerSegmentSegmentCmd(Vector($3,$4));} + | PRESERVE_ {fr->getMarkerPreserveCmd();} + | PROPERTY_ markerProperty {fr->getMarkerPropertyCmd($2);} + | SELECT_ markerGetSelect + | SELECT_ NUMBER_ {fr->getMarkerSelectedNumberCmd();} + + | SHOW_ markerGetShow + + | STRING COLOR_ {fr->getMarkerColorCmd($1);} + | STRING FONT_ {fr->getMarkerFontCmd($1);} + | STRING ID_ {fr->getMarkerIdCmd($1);} + | STRING PROPERTY_ markerProperty {fr->getMarkerPropertyCmd($1,$3);} + | STRING TAG_ {fr->getMarkerTagCmd($1);} + | STRING TAG_ NUMBER_ {fr->getMarkerTagNumberCmd($1);} + + | TAG_ ALL_ {fr->getMarkerTagsCmd();} + | TAG_ DEFAULT_ NAME_ {fr->getMarkerTagDefaultNameCmd();} + + | WIDTH_ {fr->getMarkerLineWidthCmd();} + ; + +markerGetCentroid : AUTO_ {fr->getMarkerCentroidAutoCmd();} + | RADIUS_ {fr->getMarkerCentroidRadiusCmd();} + | ITERATION_ {fr->getMarkerCentroidIterationCmd();} + | OPTION_ {fr->getMarkerCentroidOptionCmd();} + ; + +markerGetHighlite : /* empty */ {fr->getMarkerHighlitedCmd();} + | numeric numeric {fr->getMarkerHighlitedCmd(Vector($1,$2));} + ; + +markerGetSelect : /* empty */ {fr->getMarkerSelectedCmd();} + | numeric numeric {fr->getMarkerSelectedCmd(Vector($1,$2));} + ; + +markerGetShow : /* empty */ {fr->getMarkerShowCmd();} + | TEXT_ {fr->getMarkerShowTextCmd();} + ; + +markerInitProp : { + strncpy(currentFont, "helvetica 10 normal roman", 32); + strncpy(currentColor, "green", 16); + currentDash[0] = 8; + currentDash[1] = 3; + currentWidth = 1; + strncpy(currentText, "", 80); + currentProps = defaultProps; + taglist.deleteAll(); + cblist.deleteAll(); + } + ; + +markerLayer : /* empty */ {fr->markerLayerCmd(Base::USER);} + | POINTER_ { + // backward compatibility + fr->markerLayerCmd(Base::USER); + } + | REGION_ {fr->markerLayerCmd(Base::USER);} + | USER_ { + // backward compatibility + fr->markerLayerCmd(Base::USER); + } + | CATALOG_ {fr->markerLayerCmd(Base::CATALOG);} + | ANALYSIS_ {fr->markerLayerCmd(Base::ANALYSIS);} + ; + +markerList : markerFormat coordSystem skyFrame skyFormat + yesno markerQuery markerTags + {fr->markerListCmd((Base::MarkerFormat)$1, + (Coord::CoordSystem)$2, (Coord::SkyFrame)$3, (Coord::SkyFormat)$4, $5, + 0, propQMask, propQValue, taglist);} + | SELECT_ markerFormat coordSystem skyFrame skyFormat + yesno markerQuery markerTags + {fr->markerListCmd((Base::MarkerFormat)$2, + (Coord::CoordSystem)$3, (Coord::SkyFrame)$4, (Coord::SkyFormat)$5, $6, + 1, propQMask, propQValue, taglist);} + ; + +markerLoad : markerFormat STRING + {fr->markerLoadCmd((Base::MarkerFormat)$1,$2);} + | markerFormat STRING coordSystem skyFrame + {fr->markerLoadCmd((Base::MarkerFormat)$1,$2, + (Coord::CoordSystem)$3,(Coord::SkyFrame)$4);} + | markerFormat INT + {fr->markerLoadCmd((Base::MarkerFormat)$1,$2);} + | markerFormat INT coordSystem skyFrame + {fr->markerLoadCmd((Base::MarkerFormat)$1,$2, + (Coord::CoordSystem)$3,(Coord::SkyFrame)$4);} + | FITS_ STRING STRING markerDash INT STRING + {fr->markerLoadFitsCmd($2, $3, $4, $5, $6);} + ; + +markerMoveSelected : numeric numeric {fr->markerMoveCmd(Vector($1,$2));} + | FRONT_ {fr->markerFrontCmd();} + | BACK_ {fr->markerBackCmd();} + | BEGIN_ numeric numeric {fr->markerMoveBeginCmd(Vector($2,$3));} + | MOTION_ numeric numeric {fr->markerMoveMotionCmd(Vector($2,$3));} + | END_ {fr->markerMoveEndCmd();} + | TO_ internalSystem coord + {fr->markerMoveToCmd(Vector($3), (Coord::InternalSystem)$2);} + | TO_ coordSystem skyFrame coord + {fr->markerMoveToCmd(Vector($4), (Coord::CoordSystem)$2, (Coord::SkyFrame)$3);} + ; + +markerProps : markerProps markerProp + | markerProp + ; + +markerProp : markerProperty '=' yesno {setProps(¤tProps,$1,$3);} + | COLOR_ '=' STRING {strncpy(currentColor,$3,16);} + | DASHLIST_ '=' INT INT {currentDash[0]=$3;currentDash[1]=$4;} + | WIDTH_ '=' INT {currentWidth = $3;} + | FONT_ '=' STRING {strncpy(currentFont,$3,32);} + | TEXT_ '=' STRING {strncpy(currentText,$3,80);} + | tag + | callback + ; + +markerProperty : NONE_ {$$ = Marker::NONE;} + | SELECT_ {$$ = Marker::SELECT;} + | HIGHLITE_ {$$ = Marker::HIGHLITE;} + | DASH_ {$$ = Marker::DASH;} + | FIXED_ {$$ = Marker::FIXED;} + | EDIT_ {$$ = Marker::EDIT;} + | MOVE_ {$$ = Marker::MOVE;} + | ROTATE_ {$$ = Marker::ROTATE;} + | DELETE_ {$$ = Marker::DELETE;} + | INCLUDE_ {$$ = Marker::INCLUDE;} + | SOURCE_ {$$ = Marker::SOURCE;} + ; + +markerProperties : /* empty */ markerInitProp + | markerInitProp markerProps + ; + +markerQuery: /* empty */ {propQMask=0;propQValue=0;} + | {propQMask=0;propQValue=0;} queries + ; + +markerSelect : ALL_ {fr->markerSelectAllCmd();} + | ONLY_ numeric numeric {fr->markerSelectOnlyCmd(Vector($2,$3));} + | TOGGLE_ {fr->markerSelectToggleCmd();} + | TOGGLE_ numeric numeric {fr->markerSelectToggleCmd(Vector($2,$3));} + ; + +markerShow : yesno {fr->markerShowCmd($1);} + | TEXT_ yesno {fr->markerShowTextCmd($2);} + ; + +queries : queries query + | query + ; + +query : markerProperty '=' yesno + {propQMask |= $1; setProps(&propQValue,$1,$3);} + ; + +markerTags: /* empty */ {taglist.deleteAll();} + | {taglist.deleteAll();} tags + ; + +tags : tags tag + | tag + ; + +tag : TAG_ '=' STRING {taglist.append(new Tag($3));} + ; + +callback : CALLBACK_ '=' markerCallBack STRING STRING {cblist.append( + new CallBack(fr->getInterp(),(CallBack::Type)$3,$4,$5));} + ; + +mask : CLEAR_ {fr->maskClearCmd();} + | COLOR_ STRING {fr->maskColorCmd($2);} + | MARK_ INT {fr->maskMarkCmd($2);} + | TRANSPARENCY_ numeric {fr->maskTransparencyCmd($2);} + ; + +orient : 'X' {fr->orientCmd(Coord::XX);} + | 'Y' {fr->orientCmd(Coord::YY);} + | XY_ {fr->orientCmd(Coord::XY);} + | NONE_ {fr->orientCmd(Coord::NORMAL);} + ; + +pan : numeric numeric numeric numeric + {fr->panCmd(Vector($1,$2),Vector($3,$4));} + | numeric numeric {fr->panCmd(Vector($1,$2));} + | internalSystem numeric numeric + { + // backward compatibility + fr->panCmd(Vector($2,$3)); + } + | coordSystem skyFrame coord + {fr->panCmd(Vector($3), (Coord::CoordSystem)$1, (Coord::SkyFrame)$2);} + | TO_ panTo + | BBOX_ numeric numeric {fr->panBBoxCmd(Vector($2,$3));} + | MOTION_ panMotion + | PRESERVE_ yesno {fr->panPreserveCmd($2);} + ; + +panTo : numeric numeric {fr->panToCmd(Vector($1,$2));} + | internalSystem numeric numeric + { + // backward compatibility + fr->panToCmd(Vector($2,$3)); + } + | coordSystem skyFrame coord + {fr->panToCmd(Vector($3), (Coord::CoordSystem)$1, (Coord::SkyFrame)$2);} + ; + +panMotion : BEGIN_ numeric numeric {fr->panBeginCmd(Vector($2,$3));} + | numeric numeric {fr->panMotionCmd(Vector($1,$2));} + | END_ numeric numeric {fr->panEndCmd(Vector($2,$3));} + ; + +panner : yesno {fr->pannerCmd($1);} + | WCS_ wcsSystem skyFrame + { + // backward compatibility + fr->pannerCmd((Coord::CoordSystem)$2,(Coord::SkyFrame)$3); + } + | STRING INT INT {fr->pannerCmd($1, $2, $3);} + | UPDATE_ {fr->updatePannerCmd();} + ; + +postscript : COLORSPACE_ pscolorspace + {fr->psColorSpaceCmd((Widget::PSColorSpace)$2);} + | LEVEL_ INT {fr->psLevelCmd($2);} + | RESOLUTION_ INT {fr->psResolutionCmd($2);} + | SCALE_ numeric { + // backward compatibility with backup + } + ; + +pscolorspace : BW_ {$$ = Widget::BW;} + | GRAY_ {$$ = Widget::GRAY;} + | RGB_ {$$ = Widget::RGB;} + | CMYK_ {$$ = Widget::CMYK;} + ; + +region : HIGHLITE_ regionHighlite + | SELECT_ regionSelect + ; + +regionHighlite : BEGIN_ numeric numeric + {fr->regionHighliteBeginCmd(Vector($2,$3));} + | MOTION_ numeric numeric + {fr->regionHighliteMotionCmd(Vector($2,$3));} + | END_ {fr->regionHighliteEndCmd();} + | SHIFT_ END_ {fr->regionHighliteShiftEndCmd();} + ; + +regionSelect : BEGIN_ numeric numeric + {fr->regionSelectBeginCmd(Vector($2,$3));} + | MOTION_ numeric numeric {fr->regionSelectMotionCmd(Vector($2,$3));} + | END_ {fr->regionSelectEndCmd();} + | SHIFT_ END_ {fr->regionSelectShiftEndCmd();} + ; + +renderMethod: MIP_ {$$ = Frame3dBase::MIP;} + | AIP_ {$$ = Frame3dBase::AIP;} + ; + +renderBackground: NONE_ {$$ = Frame3dBase::NONE;} + | AZIMUTH_ {$$ = Frame3dBase::AZIMUTH;} + | ELEVATION_ {$$ = Frame3dBase::ELEVATION;} + ; + +rgb : CHANNEL_ STRING {fr->setRGBChannelCmd($2);} + | SYSTEM_ coordSystem {fr->setRGBSystemCmd((Coord::CoordSystem)$2);} + | VIEW_ INT INT INT {fr->setRGBViewCmd($2,$3,$4);} + ; + +rotate : numeric {fr->rotateCmd(degToRad($1));} + | numeric DEGREES_ {fr->rotateCmd(degToRad($1));} + | MOTION_ rotateMotion + | TO_ numeric {fr->rotateToCmd(degToRad($2));} + | TO_ numeric DEGREES_ {fr->rotateToCmd(degToRad($2));} + ; + +rotateMotion : BEGIN_ {fr->rotateBeginCmd();} + | numeric {fr->rotateMotionCmd(degToRad($1));} + | END_ {fr->rotateEndCmd();} + ; + +save : ARRAY_ saveArray + | FITS_ saveFits + | NRRD_ saveNRRD + | ENVI_ saveENVI + | PHOTO_ STRING {fr->savePhotoCmd($2);} + ; + +saveArray : FILE_ STRING endian + {fr->saveArrayFileCmd($2, (FitsFile::ArchType)$3);} + | CHANNEL_ STRING endian + {fr->saveArrayChannelCmd($2, (FitsFile::ArchType)$3);} + | SOCKET_ INT endian + {fr->saveArraySocketCmd($2, (FitsFile::ArchType)$3);} + | RGB_ CUBE_ saveArrayRGBCube + ; + +saveArrayRGBCube : FILE_ STRING endian + {fr->saveArrayRGBCubeFileCmd($2, (FitsFile::ArchType)$3);} + | CHANNEL_ STRING endian + {fr->saveArrayRGBCubeChannelCmd($2, (FitsFile::ArchType)$3);} + | SOCKET_ INT endian + {fr->saveArrayRGBCubeSocketCmd($2, (FitsFile::ArchType)$3);} + +saveFits: /* empty */ saveFitsImage + | IMAGE_ saveFitsImage + | TABLE_ saveFitsTable + | SLICE_ saveFitsSlice + | EXT_ CUBE_ saveFitsExtCube + | MOSAIC_ saveFitsMosaic + | RGB_ IMAGE_ saveFitsRGBImage + | RGB_ CUBE_ saveFitsRGBCube + | RESAMPLE_ saveFitsResample + ; + +saveFitsImage : FILE_ STRING {fr->saveFitsFileCmd($2);} + | CHANNEL_ STRING {fr->saveFitsChannelCmd($2);} + | SOCKET_ INT {fr->saveFitsSocketCmd($2);} + ; + +saveFitsTable : FILE_ STRING {fr->saveFitsTableFileCmd($2);} + | CHANNEL_ STRING {fr->saveFitsTableChannelCmd($2);} + | SOCKET_ INT {fr->saveFitsTableSocketCmd($2);} + ; + +saveFitsSlice : FILE_ STRING {fr->saveFitsSliceFileCmd($2);} + | CHANNEL_ STRING {fr->saveFitsSliceChannelCmd($2);} + | SOCKET_ INT {fr->saveFitsSliceSocketCmd($2);} + ; + +saveFitsExtCube : FILE_ STRING {fr->saveFitsExtCubeFileCmd($2);} + | CHANNEL_ STRING {fr->saveFitsExtCubeChannelCmd($2);} + | SOCKET_ INT {fr->saveFitsExtCubeSocketCmd($2);} + ; + +saveFitsMosaic : IMAGE_ saveFitsMosaicImage + | FILE_ STRING INT {fr->saveFitsMosaicFileCmd($2,$3);} + | CHANNEL_ STRING INT {fr->saveFitsMosaicChannelCmd($2,$3);} + | SOCKET_ INT INT {fr->saveFitsMosaicSocketCmd($2,$3);} + ; + +saveFitsMosaicImage : FILE_ STRING {fr->saveFitsMosaicImageFileCmd($2);} + | CHANNEL_ STRING {fr->saveFitsMosaicImageChannelCmd($2);} + | SOCKET_ INT {fr->saveFitsMosaicImageSocketCmd($2);} + ; + +saveFitsRGBImage : FILE_ STRING {fr->saveFitsRGBImageFileCmd($2);} + | CHANNEL_ STRING {fr->saveFitsRGBImageChannelCmd($2);} + | SOCKET_ INT {fr->saveFitsRGBImageSocketCmd($2);} + ; + +saveFitsRGBCube : FILE_ STRING {fr->saveFitsRGBCubeFileCmd($2);} + | CHANNEL_ STRING {fr->saveFitsRGBCubeChannelCmd($2);} + | SOCKET_ INT {fr->saveFitsRGBCubeSocketCmd($2);} + ; + +saveFitsResample : FILE_ STRING {fr->saveFitsResampleFileCmd($2);} + | CHANNEL_ STRING {fr->saveFitsResampleChannelCmd($2);} + | SOCKET_ INT {fr->saveFitsResampleSocketCmd($2);} + ; + +saveNRRD : FILE_ STRING endian + {fr->saveNRRDFileCmd($2, (FitsFile::ArchType)$3);} + | CHANNEL_ STRING endian + {fr->saveNRRDChannelCmd($2, (FitsFile::ArchType)$3);} + | SOCKET_ INT endian + {fr->saveNRRDSocketCmd($2, (FitsFile::ArchType)$3);} + ; + +saveENVI : FILE_ STRING STRING endian + {fr->saveENVIFileCmd($2, $3, (FitsFile::ArchType)$4);} + ; + +smooth : smoothFunction INT {fr->smoothCmd((Context::SmoothFunction)$1,$2);} + | DELETE_ {fr->smoothDeleteCmd();} + ; + +smoothFunction : BOXCAR_ {$$ = Context::BOXCAR;} + | GAUSSIAN_ {$$ = Context::GAUSSIAN;} + | TOPHAT_ {$$ = Context::TOPHAT;} + ; + +update : /* empty */ {fr->updateFitsCmd(0);} + | INT numeric numeric numeric numeric + {fr->updateFitsCmd($1,BBox($2,$3,$4,$5),0);} + | NOW_ {fr->updateFitsCmd(1);} + | NOW_ INT numeric numeric numeric numeric + {fr->updateFitsCmd($2,BBox($3,$4,$5,$6),1);} + | FITS_ SLICE_ updateFitsSlice + ; + +updateFitsSlice : INT {fr->sliceCmd(2, $1);} + | numeric coordSystem {fr->sliceCmd(2, $1, (Coord::CoordSystem)$2);} + | INT INT {fr->sliceCmd($1, $2);} + | INT numeric coordSystem {fr->sliceCmd($1, $2, (Coord::CoordSystem)$3);} + ; + +warp : numeric numeric {fr->warpCmd(Vector($1,$2));} + | TO_ numeric numeric {fr->warpToCmd(Vector($2,$3));} + ; + +wcs : wcsSystem skyFrame skyFormat + {fr->wcsCmd((Coord::CoordSystem)$1, (Coord::SkyFrame)$2, (Coord::SkyFormat)$3);} + | ALIGN_ wcsAlign + | RESET_ INT {fr->wcsResetCmd($2);} + | REPLACE_ wcsReplace + | APPEND_ wcsAppend + ; + +wcsAppend : INT INT {fr->wcsAppendCmd($1,$2);} + | INT STRING {fr->wcsAppendCmd($1,$2);} + | TEXT_ INT STRING {fr->wcsAppendTxtCmd($2,$3);} + ; + +wcsReplace : INT INT {fr->wcsReplaceCmd($1,$2);} + | INT STRING {fr->wcsReplaceCmd($1,$2);} + | TEXT_ INT STRING {fr->wcsReplaceTxtCmd($2,$3);} + ; + +wcsAlign : INT {fr->wcsAlignCmd($1);} + | INT wcsSystem skyFrame + { + // used by backup + fr->wcsAlignCmd($1, (Coord::CoordSystem)$2, (Coord::SkyFrame)$3); + } + | INT POINTER wcsSystem skyFrame + {fr->wcsAlignCmd($1, (FitsImage*)$2, (Coord::CoordSystem)$3, (Coord::SkyFrame)$4);} + ; + +win32 : PRINT_ { +#ifdef __WIN32 + fr->win32PrintCmd(); +#endif + } + ; + +zoom : numeric numeric {fr->zoomCmd(Vector($1,$2));} + | numeric numeric ABOUT_ numeric numeric + {fr->zoomAboutCmd(Vector($1,$2),Vector($4,$5));} + | numeric numeric ABOUT_ internalSystem numeric numeric + { + // backward compatibility + fr->zoomAboutCmd(Vector($1,$2),Vector($5,$6)); + } + | numeric numeric ABOUT_ coordSystem skyFrame coord + {fr->zoomAboutCmd(Vector($1,$2),Vector($6), (Coord::CoordSystem)$4,(Coord::SkyFrame)$5);} + | TO_ zoomTo + ; + +zoomTo : FIT_ {fr->zoomToFitCmd(1);} + | FIT_ numeric {fr->zoomToFitCmd($2);} + | numeric numeric {fr->zoomToCmd(Vector($1,$2));} + | numeric numeric ABOUT_ numeric numeric + {fr->zoomToAboutCmd(Vector($1,$2),Vector($4,$5));} + | numeric numeric ABOUT_ internalSystem numeric numeric + { + // backward compatibility + fr->zoomToAboutCmd(Vector($1,$2),Vector($5,$6)); + } + | numeric numeric ABOUT_ coordSystem skyFrame coord + {fr->zoomToAboutCmd(Vector($1,$2), Vector($6), + (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);} + ; + +%% + +static void setProps(unsigned short* props, unsigned short prop, int value) +{ + if (value) + *props |= prop; + else + *props &= ~prop; +} diff --git a/tksao/frame/point.C b/tksao/frame/point.C new file mode 100644 index 0000000..76a53b4 --- /dev/null +++ b/tksao/frame/point.C @@ -0,0 +1,942 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "point.h" +#include "fitsimage.h" + +#define NUMSEG 16 + +Point::Point(Base* p, const Vector& ctr) + : Marker(p, ctr, 0) +{ + strcpy(type_, "point"); + + shape_ = CIRCLE; + shapeStr(shape_); + size_ = 11; + + handle = new Vector[4]; + numHandle = 4; + + updateBBox(); +} + +Point::Point(Base* p, const Vector& ctr, + PointShape ss, int size, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : Marker(p, ctr, 0, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + strcpy(type_, "point"); + + shape_ = ss; + shapeStr(ss); + size_ = size; + + handle = new Vector[4]; + numHandle = 4; + + updateBBox(); +} + +Point::Point(const Point& a) : Marker(a) +{ + shape_ = a.shape_; + shapestr_ = dupstr(a.shapestr_); + size_ = a.size_; +} + +Point::~Point() +{ + if (shapestr_) + delete [] shapestr_; +} + +// X11 + +void Point::renderX(Drawable drawable, Coord::InternalSystem sys, RenderMode mode) +{ + GC lgc = renderXGC(mode); + Vector* vv = NULL; + + switch (shape_) { + case CIRCLE: + renderXCircle(drawable, sys, mode, size_); + break; + case BOX: + renderXBox(drawable, sys, mode); + break; + case DIAMOND: + vv = generateDiamond(sys); + XDrawLine(display, drawable, lgc, vv[0][0], vv[0][1], vv[1][0], vv[1][1]); + XDrawLine(display, drawable, lgc, vv[1][0], vv[1][1], vv[2][0], vv[2][1]); + XDrawLine(display, drawable, lgc, vv[2][0], vv[2][1], vv[3][0], vv[3][1]); + XDrawLine(display, drawable, lgc, vv[3][0], vv[3][1], vv[0][0], vv[0][1]); + break; + case CROSS: + vv = generateCross(sys); + XDrawLine(display, drawable, lgc, vv[0][0], vv[0][1], vv[1][0], vv[1][1]); + XDrawLine(display, drawable, lgc, vv[2][0], vv[2][1], vv[3][0], vv[3][1]); + break; + case EX: + vv = generateEx(sys); + XDrawLine(display, drawable, lgc, vv[0][0], vv[0][1], vv[1][0], vv[1][1]); + XDrawLine(display, drawable, lgc, vv[2][0], vv[2][1], vv[3][0], vv[3][1]); + break; + case ARROW: + vv = generateArrow(sys); + XDrawLine(display, drawable, lgc, vv[0][0], vv[0][1], vv[3][0], vv[3][1]); + XDrawLine(display, drawable, lgc, vv[1][0], vv[1][1], vv[3][0], vv[3][1]); + XDrawLine(display, drawable, lgc, vv[2][0], vv[2][1], vv[3][0], vv[3][1]); + break; + case BOXCIRCLE: + renderXBox(drawable, sys, mode); + renderXCircle(drawable, sys, mode, size_-2); + break; + } + + if (vv) + delete [] vv; +} + +void Point::renderXCircle(Drawable drawable, Coord::InternalSystem sys, + RenderMode mode, int rr) +{ + GC lgc = renderXGC(mode); + if (parent->isAzElZero()) { + Vector cc = parent->mapFromRef(center,sys); + Vector v = cc*Translate(-Vector(rr,rr)/2); +#ifndef __WIN32 + XDrawArc(display, drawable, lgc, v[0], v[1], rr, rr, 0, 360*64); +#else + int ss = int(rr/2.+.5)*2; + XDrawArc(display, drawable, lgc, v[0], v[1], ss, ss, 0, 360*64); +#endif + } + else { + Vector* vv = generateCircle(sys, rr); + for (int ii=1; ii<=NUMSEG; ii++) + XDrawLine(display, drawable, lgc, vv[ii-1][0], vv[ii-1][1], + vv[ii][0], vv[ii][1]); + delete [] vv; + } +} + +void Point::renderXBox(Drawable drawable, Coord::InternalSystem sys, RenderMode mode) +{ + GC lgc = renderXGC(mode); + Vector* vv = generateBox(sys); + XDrawLine(display, drawable, lgc, vv[0][0], vv[0][1], vv[1][0], vv[1][1]); + XDrawLine(display, drawable, lgc, vv[1][0], vv[1][1], vv[2][0], vv[2][1]); + XDrawLine(display, drawable, lgc, vv[2][0], vv[2][1], vv[3][0], vv[3][1]); + XDrawLine(display, drawable, lgc, vv[3][0], vv[3][1], vv[0][0], vv[0][1]); + delete [] vv; +} + +void Point::renderXLineDash(GC lgc) +{ + char dl[2]; +#ifdef __WIN32 + dl[0] = dlist[0]/2; + dl[1] = dlist[1]/2; +#else + dl[0] = ceil(dlist[0]/2.); + dl[1] = ceil(dlist[1]/2.); +#endif + int ww = (highlited && canHighlite()) ? lineWidth*2 : lineWidth; + XSetDashes(display, lgc, 0, dl, 2); + XSetLineAttributes(display, lgc, ww, LineOnOffDash, CapButt, JoinMiter); +} + +// PS + +void Point::renderPS(int mode) +{ + renderPSGC(mode); + Vector* vv =NULL; + ostringstream str; + + switch (shape_) { + case CIRCLE: + renderPSCircle(mode, size_); + break; + case BOX: + renderPSBox(mode); + break; + case DIAMOND: + vv = generateDiamond(Coord::CANVAS); + str << "newpath " + << vv[0].TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << vv[1].TkCanvasPs(parent->canvas) << ' ' + << "lineto " + << vv[2].TkCanvasPs(parent->canvas) << ' ' + << "lineto " + << vv[3].TkCanvasPs(parent->canvas) << ' ' + << "lineto " + << "closepath stroke" << endl + << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + break; + case CROSS: + vv = generateCross(Coord::CANVAS); + str << "newpath " + << vv[0].TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << vv[1].TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl + << "newpath " + << vv[2].TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << vv[3].TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl + << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + break; + case EX: + vv = generateEx(Coord::CANVAS); + str << "newpath " + << vv[0].TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << vv[1].TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl + << "newpath " + << vv[2].TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << vv[3].TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl + << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + break; + case ARROW: + vv = generateArrow(Coord::CANVAS); + str << "newpath " + << vv[0].TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << vv[3].TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl + << "newpath " + << vv[1].TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << vv[3].TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl + << "newpath " + << vv[2].TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << vv[3].TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl + << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + break; + case BOXCIRCLE: + renderPSBox(mode); + renderPSCircle(mode,size_-2); + break; + } + + if (vv) + delete [] vv; +} + +void Point::renderPSCircle(int mode, int ss) +{ + if (parent->isAzElZero()) { + Vector cc = parent->mapFromRef(center,Coord::CANVAS); + ostringstream str; + str << "newpath " << cc.TkCanvasPs(parent->canvas) << ' ' << ss/2. + << " 0 360 arc stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } + else { + Vector* vv = generateCircle(Coord::CANVAS,ss); + ostringstream str; + str << "newpath " << vv[0].TkCanvasPs(parent->canvas) << " moveto " << endl; + for (int ii=1; iicanvas) << " lineto" << endl; + str << "closepath stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + delete [] vv; + } +} + +void Point::renderPSBox(int mode) +{ + Vector* vv = generateBox(Coord::CANVAS); + ostringstream str; + str << "newpath " + << vv[0].TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << vv[1].TkCanvasPs(parent->canvas) << ' ' + << "lineto " + << vv[2].TkCanvasPs(parent->canvas) << ' ' + << "lineto " + << vv[3].TkCanvasPs(parent->canvas) << ' ' + << "lineto " << endl + << "closepath stroke" << endl + << ends; + Tcl_AppendResult(parent->interp, (char*)str.str().c_str(), NULL); + delete [] vv; +} + +void Point::renderPSLineDash() +{ + ostringstream str; + str << lineWidth << " setlinewidth" << endl; + str << '[' << dlist[0]/2. << ' ' << dlist[1]/2. << "] 0 setdash" << endl << ends; + Tcl_AppendResult(parent->interp, (char*)str.str().c_str(), NULL); +} + +// MacOSX + +#ifdef MAC_OSX_TK +void Point::renderMACOSX() +{ + renderMACOSXGC(); + Vector* vv = NULL; + + switch (shape_) { + case CIRCLE: + renderMACOSXCircle(size_); + break; + case BOX: + renderMACOSXBox(); + break; + case DIAMOND: + vv = generateDiamond(Coord::CANVAS); + macosxDrawLines(vv,5); + break; + case CROSS: + vv = generateCross(Coord::CANVAS); + macosxDrawLine(vv[0],vv[1]); + macosxDrawLine(vv[2],vv[3]); + break; + case EX: + vv = generateEx(Coord::CANVAS); + macosxDrawLine(vv[0],vv[1]); + macosxDrawLine(vv[2],vv[3]); + break; + case ARROW: + vv = generateArrow(Coord::CANVAS); + macosxDrawLine(vv[0],vv[3]); + macosxDrawLine(vv[1],vv[3]); + macosxDrawLine(vv[2],vv[3]); + break; + case BOXCIRCLE: + renderMACOSXBox(); + renderMACOSXCircle(size_-2); + break; + } + + if (vv) + delete [] vv; +} + +void Point::renderMACOSXCircle(int ss) +{ + renderMACOSXGC(); + + if (parent->isAzElZero()) { + Vector cc = parent->mapFromRef(center,Coord::CANVAS); + macosxDrawArc(cc, ss/2., 0, M_TWOPI); + } + else { + Vector* vv = generateCircle(Coord::CANVAS, ss); + macosxDrawLines(vv,NUMSEG+1); + delete [] vv; + } +} + +void Point::renderMACOSXBox() +{ + renderMACOSXGC(); + + Vector* vv = generateBox(Coord::CANVAS); + macosxDrawLines(vv,5); + delete [] vv; +} + +void Point::renderMACOSXLineDash() +{ + macosxWidth(lineWidth); + float dl[2]; + dl[0] = dlist[0]/2.; + dl[1] = dlist[1]/2.; + macosxDash(dl,2); +} +#endif + +// WIN32 + +#ifdef __WIN32 +void Point::renderWIN32() +{ + renderWIN32GC(); + Vector* vv = NULL; + + switch (shape_) { + case CIRCLE: + renderWIN32Circle(size_); + break; + case BOX: + renderWIN32Box(); + break; + case DIAMOND: + vv = generateDiamond(Coord::CANVAS); + win32DrawLines(vv,5); + break; + case CROSS: + vv = generateCross(Coord::CANVAS); + win32DrawLine(vv[0],vv[1]); + win32DrawLine(vv[2],vv[3]); + break; + case EX: + vv = generateEx(Coord::CANVAS); + win32DrawLine(vv[0],vv[1]); + win32DrawLine(vv[2],vv[3]); + break; + case ARROW: + vv = generateArrow(Coord::CANVAS); + win32DrawLine(vv[0],vv[3]); + win32DrawLine(vv[1],vv[3]); + win32DrawLine(vv[2],vv[3]); + break; + case BOXCIRCLE: + renderWIN32Box(); + renderWIN32Circle(size_-2); + break; + } + + if (vv) + delete [] vv; +} + +void Point::renderWIN32Circle(int ss) +{ + if (parent->isAzElZero()) { + Vector cc = parent->mapFromRef(center,Coord::CANVAS); + win32DrawArc(cc, ss/2., 0, M_TWOPI); + } + else { + Vector* vv = generateCircle(Coord::CANVAS, ss); + win32DrawLines(vv,NUMSEG+1); + delete [] vv; + } +} + +void Point::renderWIN32Box() +{ + Vector* vv = generateBox(Coord::CANVAS); + win32DrawLines(vv,5); + delete [] vv; +} + +void Point::renderWIN32LineDash() +{ + win32Width(lineWidth); + float dl[2]; + dl[0] = dlist[0]/2.; + dl[1] = dlist[1]/2.; + win32Dash(dl,2); +} +#endif + +// Support + +Vector* Point::generateCircle(Coord::InternalSystem sys, int ss) +{ + Vector* vv = new Vector[NUMSEG+1]; + + Matrix mm; + Matrix nn; + setMatrices(sys,&mm,&nn); + + Vector cc = center*mm; + + for (int ii=0; iimapFromRef(bb,sys); + } + vv[NUMSEG] = vv[0]; + + return vv; +} + +Vector* Point::generateBox(Coord::InternalSystem sys) +{ + Vector* vv = new Vector[5]; + + Matrix mm; + Matrix nn; + setMatrices(sys,&mm,&nn); + + double ss = size_/2; + Vector cc = center*mm; + + Vector v1a = cc+Vector(-ss,-ss); + Vector v1b = v1a*nn; + vv[0] = parent->mapFromRef(v1b,sys); + + Vector v2a = cc+Vector(-ss,ss); + Vector v2b = v2a*nn; + vv[1] = parent->mapFromRef(v2b,sys); + + Vector v3a = cc+Vector(ss,ss); + Vector v3b = v3a*nn; + vv[2] = parent->mapFromRef(v3b,sys); + + Vector v4a = cc+Vector(ss,-ss); + Vector v4b = v4a*nn; + vv[3] = parent->mapFromRef(v4b,sys); + + vv[4] = vv[0]; + + return vv; +} + +Vector* Point::generateDiamond(Coord::InternalSystem sys) +{ + Vector* vv = new Vector[5]; + + Matrix mm; + Matrix nn; + setMatrices(sys,&mm,&nn); + + Vector xx = Vector(size_-1,0)/2; + Vector yy = Vector(0,size_-1)/2; + Vector cc = center*mm; + + Vector v1a = cc-xx; + Vector v1b = v1a*nn; + vv[0] = parent->mapFromRef(v1b,sys); + + Vector v2a = cc-yy; + Vector v2b = v2a*nn; + vv[1] = parent->mapFromRef(v2b,sys); + + Vector v3a = cc+xx; + Vector v3b = v3a*nn; + vv[2] = parent->mapFromRef(v3b,sys); + + Vector v4a = cc+yy; + Vector v4b = v4a*nn; + vv[3] = parent->mapFromRef(v4b,sys); + + vv[4] = vv[0]; + + return vv; +} + +Vector* Point::generateCross(Coord::InternalSystem sys) +{ + Vector* vv = new Vector[4]; + + Matrix mm; + Matrix nn; + setMatrices(sys,&mm,&nn); + + Vector xx = Vector(size_,0)/2; + Vector yy = Vector(0,size_)/2; + Vector cc = center*mm; + + Vector v1a = cc-xx; + Vector v1b = v1a*nn; + vv[0] = parent->mapFromRef(v1b,sys); + + Vector v2a = cc+xx; + Vector v2b = v2a*nn; + vv[1] = parent->mapFromRef(v2b,sys); + + Vector v3a = cc-yy; + Vector v3b = v3a*nn; + vv[2] = parent->mapFromRef(v3b,sys); + + Vector v4a = cc+yy; + Vector v4b = v4a*nn; + vv[3] = parent->mapFromRef(v4b,sys); + + return vv; +} + +Vector* Point::generateEx(Coord::InternalSystem sys) +{ + Vector* vv = new Vector[4]; + + Matrix mm; + Matrix nn; + setMatrices(sys,&mm,&nn); + + Vector xy = Vector(-size_,-size_)/2; + Vector yx = Vector( size_,-size_)/2; + Vector cc = center*mm; + + Vector v1a = cc+xy; + Vector v1b = v1a*nn; + vv[0] = parent->mapFromRef(v1b,sys); + + Vector v2a = cc-xy; + Vector v2b = v2a*nn; + vv[1] = parent->mapFromRef(v2b,sys); + + Vector v3a = cc+yx; + Vector v3b = v3a*nn; + vv[2] = parent->mapFromRef(v3b,sys); + + Vector v4a = cc-yx; + Vector v4b = v4a*nn; + vv[3] = parent->mapFromRef(v4b,sys); + + return vv; +} + +Vector* Point::generateArrow(Coord::InternalSystem sys) +{ + Vector* vv = new Vector[4]; + + Matrix mm; + Matrix nn; + setMatrices(sys,&mm,&nn); + + Vector xx = Vector(-size_,0)/2; + Vector yy = Vector(0,-size_)/2; + Vector cc = center*mm; + + Vector v1a = cc+xx; + Vector v1b = v1a*nn; + vv[0] = parent->mapFromRef(v1b,sys); + + Vector v2a = cc+yy; + Vector v2b = v2a*nn; + vv[1] = parent->mapFromRef(v2b,sys); + + Vector v3a = cc+xx+yy; + Vector v3b = v3a*nn; + vv[2] = parent->mapFromRef(v3b,sys); + + Vector v4a = cc; + Vector v4b = v4a*nn; + vv[3] = parent->mapFromRef(v4b,sys); + + return vv; +} + +void Point::shapeStr(PointShape ss) +{ + switch (ss) { + case CIRCLE: + shapestr_ = dupstr("circle"); + break; + case BOX: + shapestr_ = dupstr("box"); + break; + case DIAMOND: + shapestr_ = dupstr("diamond"); + break; + case CROSS: + shapestr_ = dupstr("cross"); + break; + case EX: + shapestr_ = dupstr("x"); + break; + case ARROW: + shapestr_ = dupstr("arrow"); + break; + case BOXCIRCLE: + shapestr_ = dupstr("boxcircle"); + break; + } +} + +void Point::setShape(PointShape ss) +{ + shape_ = ss; + shapeStr(ss); + updateBBox(); + doCallBack(CallBack::EDITCB); +} + +void Point::setSize(int size) +{ + size_ = size; + updateBBox(); + doCallBack(CallBack::EDITCB); +} + +void Point::updateHandles() +{ + // bound marker + double ss = size_/2; + Vector cc = center*parent->refToCanvas; + + Vector lla = cc+Vector(-ss,-ss); + Vector llb = lla*parent->canvasToRef; + Vector ll = parent->mapFromRef(llb,Coord::CANVAS); + + Vector lra = cc+Vector(-ss,ss); + Vector lrb = lra*parent->canvasToRef; + Vector lr = parent->mapFromRef(lrb,Coord::CANVAS); + + Vector ura = cc+Vector(ss,ss); + Vector urb = ura*parent->canvasToRef; + Vector ur = parent->mapFromRef(urb,Coord::CANVAS); + + Vector ula = cc+Vector(ss,-ss); + Vector ulb = ula*parent->canvasToRef; + Vector ul = parent->mapFromRef(ulb,Coord::CANVAS); + + handle[0] = ll; + handle[1] = lr; + handle[2] = ur; + handle[3] = ul; +} + +void Point::analysis(AnalysisTask mm, int which) +{ + switch (mm) { + case PLOT3D: + if (!analysisPlot3d_ && which) { + addCallBack(CallBack::MOVECB, analysisPlot3dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisPlot3dCB_[1], + parent->options->cmdName); + } + if (analysisPlot3d_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisPlot3dCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisPlot3dCB_[1]); + } + + analysisPlot3d_ = which; + break; + default: + // na + break; + } +} + +void Point::analysisPlot3d(char* xname, char* yname, + Coord::CoordSystem sys, + Marker::AnalysisMethod method) +{ + double* x; + double* y; + Vector ll = -Vector(.5,.5) * Translate(center); + Vector ur = Vector(.5,.5) * Translate(center); + BBox bb(ll,ur); + int num = parent->markerAnalysisPlot3d(this, &x, &y, bb, sys, method); + analysisXYResult(xname, yname, x, y, num); +} + +int Point::isInRef(const Vector& vv) +{ + Vector& pp = (Vector&)vv; + + if (pp[0]<-.5 || pp[0]>=.5 || pp[1]<-.5 || pp[1]>=.5) + return 0; + else + return 1; +} + +// list + +void Point::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 0); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listNonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' << setprecision(10) << vv << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' << ra << ',' << dec << ')'; + break; + } + } + else + listNonCel(ptr, str, sys); + } + + listPost(str, conj, strip); +} + +void Point::listNonCel(FitsImage* ptr, ostream& str, Coord::CoordSystem sys) +{ + Vector vv = ptr->mapFromRef(center,sys); + str << type_ << '(' << setprecision(8) << vv << ')'; +} + +void Point::listPost(ostream& str, int conj, int strip) +{ + // no props for semicolons + if (!strip) { + if (conj) + str << " ||"; + + str << " # point=" << shapestr_; + + if (size_ != POINTSIZE) + str << ' ' << size_; + listProperties(str,0); + } + else { + if (conj) + str << "||"; + else + str << ';'; + } +} + +void Point::listXML(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + FitsImage* ptr = parent->findFits(sys,center); + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowCenter(ptr,sys,sky,format); + + XMLRow(XMLPARAM,shapestr_); + XMLRow(XMLPARAM2,size_); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} + +void Point::listCiao(ostream& str, Coord::CoordSystem sys, int strip) +{ + FitsImage* ptr = parent->findFits(); + listCiaoPre(str); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + Vector vv = ptr->mapFromRef(center,Coord::PHYSICAL); + str << type_ << '(' << setprecision(8) << vv << ')'; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + listRADEC(ptr,center,sys,Coord::FK5,Coord::SEXAGESIMAL); + str << type_ << '(' << ra << ',' << dec << ')'; + } + break; + } + + listCiaoPost(str, strip); +} + +void Point::listPros(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int strip) +{ + FitsImage* ptr = parent->findFits(); + + switch (sys) { + case Coord::IMAGE: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + sys = Coord::IMAGE; + case Coord::PHYSICAL: + { + coord.listProsCoordSystem(str,sys,sky); + str << "; "; + Vector vv = ptr->mapFromRef(center,sys); + str << type_ << ' ' << setprecision(8) << vv; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + coord.listProsCoordSystem(str,sys,sky); + str << "; "; + + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << ' ' << setprecision(10) << setunit('d') << vv; + } + break; + case Coord::SEXAGESIMAL: + listRADECPros(ptr,center,sys,sky,format); + str << type_ << ' ' << ra << ' ' << dec; + break; + } + } + } + + listProsPost(str, strip); +} + +void Point::listSAOtng(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + int strip) +{ + FitsImage* ptr = parent->findFits(); + listSAOtngPre(str, strip); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + Vector vv = ptr->mapFromRef(center,Coord::IMAGE); + str << type_ << '(' << setprecision(8) << vv << ')'; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' << setprecision(10) << vv << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' << ra << ',' << dec << ')'; + break; + } + } + } + + listSAOtngPost(str,strip); +} + +void Point::listSAOimage(ostream& str, int strip) +{ + FitsImage* ptr = parent->findFits(); + listSAOimagePre(str); + + // all coords are in image coords + + Vector vv = ptr->mapFromRef(center,Coord::IMAGE); + str << type_ << '(' << setprecision(8) << vv << ')'; + + listSAOimagePost(str, strip); +} diff --git a/tksao/frame/point.h b/tksao/frame/point.h new file mode 100644 index 0000000..3226dad --- /dev/null +++ b/tksao/frame/point.h @@ -0,0 +1,110 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __point_h__ +#define __point_h__ + +#include "marker.h" + +class Point : public Marker { + public: + enum PointShape {CIRCLE,BOX,DIAMOND,CROSS,EX,ARROW,BOXCIRCLE}; + + protected: + PointShape shape_; + char* shapestr_; + int size_; + + protected: + Vector* generateCircle(Coord::InternalSystem, int); + Vector* generateBox(Coord::InternalSystem); + Vector* generateDiamond(Coord::InternalSystem); + Vector* generateCross(Coord::InternalSystem); + Vector* generateEx(Coord::InternalSystem); + Vector* generateArrow(Coord::InternalSystem); + + void renderXCircle(Drawable, Coord::InternalSystem, RenderMode, int); + void renderXBox(Drawable drawable, Coord::InternalSystem sys, RenderMode mode); + void renderXLineDash(GC lgc); + + void renderPSCircle(int,int); + void renderPSBox(int); + void renderPSLineDash(); + +#ifdef MAC_OSX_TK + void renderMACOSXCircle(int); + void renderMACOSXBox(); + void renderMACOSXLineDash(); +#endif + +#ifdef __WIN32 + void renderWIN32Circle(int); + void renderWIN32Box(); + void renderWIN32LineDash(); +#endif + + void shapeStr(PointShape); + void updateHandles(); + + int isInRef(const Vector&); + + void listNonCel(FitsImage*, ostream&, Coord::CoordSystem); + + public: + Point(Base* p, const Vector& ctr); + Point(Base* p, const Vector& ctr, + PointShape shape, int size, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + Point(const Point&); + virtual ~Point(); + + virtual Marker* dup() {return new Point(*this);} + + void renderX(Drawable, Coord::InternalSystem, RenderMode); + void renderPS(int mode); + +#ifdef MAC_OSX_TK + void renderMACOSX(); +#endif + +#ifdef __WIN32 + void renderWIN32(); +#endif + + const char* shape() {return shapestr_;} + void setShape(PointShape); + + int size() {return size_;} + void setSize(int); + + void editBegin(int) {} + void edit(const Vector& v, int h) {} + void editEnd() {} + + void rotateBegin() {} + void rotate(const Vector& v, int h) {} + void rotateEnd() {} + + void analysis(AnalysisTask, int); + void analysisPlot3d(char*, char*, Coord::CoordSystem sys, + Marker::AnalysisMethod); + + int isIn(const Vector& vv, Coord::InternalSystem sys) + {return isInRef(bckMap(vv,sys));} + int isIn(const Vector& vv, const Matrix& bck) + {return isInRef(vv*bck);} + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void listPost(ostream&, int, int); + virtual void listCiao(ostream&, Coord::CoordSystem, int); + virtual void listPros(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + virtual void listSAOtng(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + virtual void listSAOimage(ostream&, int); +}; + +#endif diff --git a/tksao/frame/polygon.C b/tksao/frame/polygon.C new file mode 100644 index 0000000..dd494db --- /dev/null +++ b/tksao/frame/polygon.C @@ -0,0 +1,571 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "polygon.h" +#include "fitsimage.h" + +Polygon::Polygon(Base* p, const Vector& ctr, + const Vector& b) + : BasePolygon(p,ctr,b) +{ + strcpy(type_, "polygon"); + reset(b); +} + +Polygon::Polygon(Base* p, const Vector& ctr, + const Vector& b, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BasePolygon(p, ctr, b, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + strcpy(type_, "polygon"); + reset(b); +} + +Polygon::Polygon(Base* p, const List& v, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BasePolygon(p, v, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + strcpy(type_, "polygon"); + + // check to see if the first and last node are the same + if (vertex.head()->vector[0] == vertex.tail()->vector[0] && + vertex.head()->vector[1] == vertex.tail()->vector[1]) + delete vertex.pop(); +} + +void Polygon::renderX(Drawable drawable, Coord::InternalSystem sys, + RenderMode mode) +{ + GC lgc = renderXGC(mode); + + vertex.head(); + Vector v1; + Vector v2 = fwdMap(vertex.current()->vector,sys); + int done = 0; + + do { + if (!vertex.next()) { + done = 1; + vertex.head(); + } + v1 = v2; + v2 = fwdMap(vertex.current()->vector,sys); + XDrawLine(display, drawable, lgc, v1[0], v1[1], v2[0], v2[1]); + } while (!done); +} + +void Polygon::renderPS(int mode) +{ + renderPSGC(mode); + + vertex.head(); + int first = 1; + do { + ostringstream str; + Vector v = fwdMap(vertex.current()->vector,Coord::CANVAS); + if (first) { + str << "newpath " << endl + << v.TkCanvasPs(parent->canvas) << " moveto" << endl << ends; + first = 0; + } + else + str << v.TkCanvasPs(parent->canvas) << " lineto" << endl << ends; + + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } while (vertex.next()); + + ostringstream str; + str << "closepath stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +#ifdef MAC_OSX_TK +void Polygon::renderMACOSX() +{ + renderMACOSXGC(); + + vertex.head(); + Vector v1; + Vector v2 = fwdMap(vertex.current()->vector,Coord::CANVAS); + int done = 0; + + do { + if (!vertex.next()) { + done = 1; + vertex.head(); + } + v1 = v2; + v2 = fwdMap(vertex.current()->vector,Coord::CANVAS); + macosxDrawLine(v1,v2); + } while (!done); +} +#endif + +#ifdef __WIN32 +void Polygon::renderWIN32() +{ + renderWIN32GC(); + + vertex.head(); + Vector v1; + Vector v2 = fwdMap(vertex.current()->vector,Coord::CANVAS); + int done = 0; + + do { + if (!vertex.next()) { + done = 1; + vertex.head(); + } + v1 = v2; + v2 = fwdMap(vertex.current()->vector,Coord::CANVAS); + win32DrawLine(v1,v2); + } while (!done); +} +#endif + +void Polygon::reset(const Vector& b) +{ + angle = 0; + vertex.deleteAll(); + + Vector bb = b; + vertex.append(new Vertex(-bb[0],-bb[1])); + vertex.append(new Vertex( bb[0],-bb[1])); + vertex.append(new Vertex( bb[0], bb[1])); + vertex.append(new Vertex(-bb[0], bb[1])); + + updateBBox(); +} + +int Polygon::isInRef(const Vector& v) +{ + /* + v[0]-- x value of point being tested + v[1]-- y value of point being tested + + This algorithm is from "An Introduction to Ray Tracing", Academic Press, + 1989, edited by Andrew Glassner, pg 53 + -- a point lies in a polygon if a line is extended from the point to + infinite in any direction and the number of intersections with the + polygon is odd. + This is valid for both concave and convex polygons. + Points on a vertex are considered inside. + Points on a edge are considered inside. + */ + + int crossings = 0; // number of crossings + + vertex.head(); + Vector v1; + Vector v2 = vertex.current()->vector - v; + + int sign = ((v2[1])>=0) ? 1 : -1; // init sign + + // for all edges + int done = 0; + + do { + // look at next two vertices + v1 = v2; + if (!vertex.next()) { + done = 1; + vertex.head(); + } + + v2 = vertex.current()->vector - v; + + int nextSign = (v2[1]>=0) ? 1 : -1; // sign holder for p2 + + if (sign != nextSign) { + if (v1[0]>0 && v2[0]>0) + crossings++; + else if (v1[0]>0 || v2[0]>0) { + if (v1[0]-(v1[1]*(v2[0]-v1[0])/(v2[1]-v1[1])) > 0) + crossings++; + } + sign = nextSign; + } + } while (!done); + + return fmod(float(crossings),float(2)) ? 1 : 0; // if odd, point is inside +} + +int Polygon::getSegment(const Vector& v) +{ + // v is in canvas coords + Matrix mm = fwdMatrix(); + + vertex.head(); + Vector v1; + Vector v2 = vertex.current()->vector * mm; + int done = 0; + + int ii = 1; + do { + v1 = v2; + if (!vertex.next()) { + vertex.head(); + done = 1; + } + v2 = vertex.current()->vector * mm; + + Vector l1 = parent->mapFromRef(v1,Coord::CANVAS); + Vector l2 = parent->mapFromRef(v2,Coord::CANVAS); + double a = (l2-l1).angle(); + Matrix mx = Translate(-l1) * FlipY() * Rotate(-a); + Vector end = l2*mx; + Vector vv = v*mx; + + if (vv[0]>0 && vv[0]-parent->markerEpsilon && vv[1]markerEpsilon) + return ii; + + ii++; + } while (!done); + + return 0; +} + +void Polygon::analysis(AnalysisTask mm, int which) +{ + switch (mm) { + case HISTOGRAM: + if (!analysisHistogram_ && which) { + addCallBack(CallBack::MOVECB, analysisHistogramCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisHistogramCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisHistogramCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisHistogramCB_[1], + parent->options->cmdName); + } + if (analysisHistogram_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisHistogramCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisHistogramCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisHistogramCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisHistogramCB_[1]); + } + + analysisHistogram_ = which; + break; + case PLOT3D: + if (!analysisPlot3d_ && which) { + addCallBack(CallBack::MOVECB, analysisPlot3dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisPlot3dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisPlot3dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisPlot3dCB_[1], + parent->options->cmdName); + } + if (analysisPlot3d_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisPlot3dCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisPlot3dCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisPlot3dCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisPlot3dCB_[1]); + } + + analysisPlot3d_ = which; + break; + case STATS: + if (!analysisStats_ && which) { + addCallBack(CallBack::MOVECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::EDITCB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::ROTATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisStatsCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisStatsCB_[1], + parent->options->cmdName); + } + if (analysisStats_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisStatsCB_[0]); + deleteCallBack(CallBack::ROTATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisStatsCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisStatsCB_[1]); + } + + analysisStats_ = which; + break; + default: + // na + break; + } +} + +void Polygon::analysisHistogram(char* xname, char* yname, int num) +{ + double* x; + double* y; + BBox bb(center); + + Matrix mm = Rotate(angle) * Translate(center); + vertex.head(); + do + bb.bound(vertex.current()->vector * mm); + while (vertex.next()); + + parent->markerAnalysisHistogram(this, &x, &y, bb, num); + analysisXYResult(xname, yname, x, y, num+1); +} + +void Polygon::analysisPlot3d(char* xname, char* yname, + Coord::CoordSystem sys, + Marker::AnalysisMethod method) +{ + double* x; + double* y; + BBox bb(center); + + Matrix mm = Rotate(angle) * Translate(center); + vertex.head(); + do + bb.bound(vertex.current()->vector * mm); + while (vertex.next()); + + int num = parent->markerAnalysisPlot3d(this, &x, &y, bb, sys, method); + analysisXYResult(xname, yname, x, y, num); +} + +void Polygon::analysisStats(Coord::CoordSystem sys, Coord::SkyFrame sky) +{ + ostringstream str; + BBox bb(center); + + Matrix mm = Rotate(angle) * Translate(center); + vertex.head(); + do + bb.bound(vertex.current()->vector * mm); + while (vertex.next()); + + parent->markerAnalysisStats(this, str, bb, sys, sky); + str << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +// list + +void Polygon::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 0); + listBase(ptr, str, sys, sky, format); + listPost(str, conj, strip); +} + +void Polygon::listCiao(ostream& str, Coord::CoordSystem sys, int strip) +{ + FitsImage* ptr = parent->findFits(); + Matrix mm = fwdMatrix(); + listCiaoPre(str); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + str << type_ << '('; + int first=1; + vertex.head(); + do { + if (!first) + str << ','; + first=0; + + Vector vv = + ptr->mapFromRef(vertex.current()->vector*mm,Coord::PHYSICAL); + str << setprecision(8) << vv; + } + while (vertex.next()); + str << ')'; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + str << type_ << '('; + int first=1; + vertex.head(); + do { + if (!first) + str << ','; + first=0; + + listRADEC(ptr,vertex.current()->vector*mm,sys, + Coord::FK5,Coord::SEXAGESIMAL); + str << ra << ',' << dec; + } + while (vertex.next()); + str << ')'; + } + } + + listCiaoPost(str, strip); +} + +void Polygon::listPros(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + int strip) +{ + FitsImage* ptr = parent->findFits(); + Matrix mm = fwdMatrix(); + + switch (sys) { + case Coord::IMAGE: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + sys = Coord::IMAGE; + case Coord::PHYSICAL: + { + coord.listProsCoordSystem(str,sys,sky); + str << "; " << type_; + vertex.head(); + do { + Vector vv = ptr->mapFromRef(vertex.current()->vector*mm,sys); + str << ' ' << setprecision(8) << vv; + } + while (vertex.next()); + } + break; + default: + if (ptr->hasWCSCel(sys)) { + coord.listProsCoordSystem(str,sys,sky); + str << "; " << type_; + + switch (format) { + case Coord::DEGREES: + { + vertex.head(); + do { + Vector vv = ptr->mapFromRef(vertex.current()->vector*mm,sys,sky); + str << ' ' << setprecision(10) << setunit('d') << vv; + } + while (vertex.next()); + } + break; + case Coord::SEXAGESIMAL: + vertex.head(); + do { + listRADECPros(ptr,vertex.current()->vector*mm,sys,sky,format); + str << ' ' << ra << ' ' << dec; + } + while (vertex.next()); + break; + } + } + } + + listProsPost(str, strip); +} + +void Polygon::listSAOtng(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format, + int strip) +{ + FitsImage* ptr = parent->findFits(); + Matrix mm = fwdMatrix(); + listSAOtngPre(str, strip); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + str << type_ << '('; + int first=1; + vertex.head(); + do { + if (!first) + str << ','; + first=0; + + Vector vv = ptr->mapFromRef(vertex.current()->vector*mm,sys); + str << setprecision(8) << vv; + } + while (vertex.next()); + str << ')'; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + str << type_ << '('; + int first=1; + vertex.head(); + do { + if (!first) + str << ','; + first=0; + + Vector vv = ptr->mapFromRef(vertex.current()->vector*mm,sys,sky); + str << setprecision(10) << vv; + } + while (vertex.next()); + str << ')'; + } + break; + case Coord::SEXAGESIMAL: + { + str << type_ << '('; + int first=1; + vertex.head(); + do { + if (!first) + str << ','; + first=0; + + listRADEC(ptr,vertex.current()->vector*mm,sys,sky,format); + str << ra << ',' << dec; + } + while (vertex.next()); + str << ')'; + } + break; + } + } + } + + listSAOtngPost(str, strip); +} + +void Polygon::listSAOimage(ostream& str, int strip) +{ + FitsImage* ptr = parent->findFits(); + listSAOimagePre(str); + Matrix mm = fwdMatrix(); + + str << type_ << '('; + int first=1; + vertex.head(); + do { + if (!first) + str << ','; + first=0; + + Vector vv = ptr->mapFromRef(vertex.current()->vector*mm,Coord::IMAGE); + str << setprecision(8) << vv; + } + while (vertex.next()); + + str << ')'; + listSAOimagePost(str, strip); +} + diff --git a/tksao/frame/polygon.h b/tksao/frame/polygon.h new file mode 100644 index 0000000..30d82e6 --- /dev/null +++ b/tksao/frame/polygon.h @@ -0,0 +1,64 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __polygon_h__ +#define __polygon_h__ + +#include "basepolygon.h" +#include "marker.h" +#include "list.h" + +class Polygon : public BasePolygon { + protected: + int isInRef(const Vector& v); + void renderX(Drawable, Coord::InternalSystem, RenderMode); + void renderPS(int); +#ifdef MAC_OSX_TK + void renderMACOSX(); +#endif +#ifdef __WIN32 + void renderWIN32(); +#endif + +public: + Polygon(Base* p, const Vector& ctr, + const Vector& b); + Polygon(Base* p, const Vector& ctr, + const Vector& b, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + Polygon(Base* p, const List& v, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + Polygon(const Polygon& a) : BasePolygon(a) {} + + Marker* dup() {return new Polygon(*this);} + + void analysis(AnalysisTask, int); + void analysisHistogram(char*, char*, int); + void analysisPlot3d(char*, char*, Coord::CoordSystem, Marker::AnalysisMethod); + void analysisStats(Coord::CoordSystem, Coord::SkyFrame sky); + + int isIn(const Vector& vv) {return isIn(vv, Coord::CANVAS);} + int isIn(const Vector& vv, Coord::InternalSystem sys) + {return isInRef(bckMap(vv,sys));} + + int isIn(const Vector& vv, const Matrix& bck) + {return isInRef(vv*bck);} + + int getSegment(const Vector&); + void reset(const Vector&); + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listCiao(ostream&, Coord::CoordSystem, int); + void listSAOtng(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); + void listSAOimage(ostream&, int); + void listPros(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); +}; + +#endif diff --git a/tksao/frame/projection.C b/tksao/frame/projection.C new file mode 100644 index 0000000..186266f --- /dev/null +++ b/tksao/frame/projection.C @@ -0,0 +1,434 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "projection.h" +#include "fitsimage.h" + +Projection::Projection(const Projection& a) : BaseLine(a) +{ + width = a.width; + p3 = a.p3; + p4 = a.p4; +} + +Projection::Projection(Base* p, const Vector& ptr1, const Vector& ptr2, + double wd, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BaseLine(p, ptr1, ptr2, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + width = wd; + + strcpy(type_,"projection"); + handle = new Vector[3]; + numHandle = 3; + + // this causes a focus problem with MacOSX and X11? + // analysis(PLOT2D,1); + updateBBox(); +} + +void Projection::renderX(Drawable drawable, Coord::InternalSystem sys, + RenderMode mode) +{ + GC lgc = renderXGC(mode); + + Vector aa = parent->mapFromRef(p1,sys); + Vector bb = parent->mapFromRef(p2,sys); + + XDrawLine(display, drawable, lgc, aa[0], aa[1], bb[0], bb[1]); + + if (width>0) { + renderXLineDash(lgc); + + Matrix imm = bckMatrix(); + Vector a = p1*imm; + Vector b = p2*imm; + Vector c = Vector(0,-width); + + Vector ll = fwdMap(a,sys); + Vector lr = fwdMap(b,sys); + Vector ul = fwdMap(a+c,sys); + Vector ur = fwdMap(b+c,sys); + + XDrawLine(display, drawable, lgc, lr[0], lr[1], ur[0], ur[1]); + XDrawLine(display, drawable, lgc, ur[0], ur[1], ul[0], ul[1]); + XDrawLine(display, drawable, lgc, ul[0], ul[1], ll[0], ll[1]); + } +} + +GC Projection::renderXGC(RenderMode mode) +{ + // set width, color, dash + switch (mode) { + case SRC: + XSetForeground(display, gc, color); + renderXLineNoDash(gc); + return gc; + + case XOR: + renderXLineDash(gcxor); + return gcxor; + } +} + +void Projection::renderPS(int mode) +{ + renderPSGC(mode); + + Vector aa = parent->mapFromRef(p1,Coord::CANVAS); + Vector bb = parent->mapFromRef(p2,Coord::CANVAS); + { + ostringstream str; + str << "newpath " + << aa.TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << bb.TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } + + if (width>0) { + renderPSLineDash(); + + Matrix imm = bckMatrix(); + Vector a = p1*imm; + Vector b = p2*imm; + Vector c = Vector(0,-width); + + Vector ll = fwdMap(a,Coord::CANVAS); + Vector lr = fwdMap(b,Coord::CANVAS); + Vector ul = fwdMap(a+c,Coord::CANVAS); + Vector ur = fwdMap(b+c,Coord::CANVAS); + + ostringstream str; + str << "newpath " + << lr.TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << ur.TkCanvasPs(parent->canvas) << ' ' + << "lineto " + << ul.TkCanvasPs(parent->canvas) << ' ' + << "lineto " + << ll.TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } +} + +void Projection::renderPSGC(int mode) +{ + renderPSColor(mode, parent->getXColor(colorName)); + renderPSLineNoDash(); +} + +#ifdef MAC_OSX_TK +void Projection::renderMACOSX() +{ + renderMACOSXGC(); + + Vector aa = parent->mapFromRef(p1,Coord::CANVAS); + Vector bb = parent->mapFromRef(p2,Coord::CANVAS); + + macosxDrawLine(aa,bb); + + if (width>0) { + renderMACOSXLineDash(); + + Matrix imm = bckMatrix(); + Vector a = p1*imm; + Vector b = p2*imm; + Vector c = Vector(0,-width); + + Vector ll = fwdMap(a,Coord::CANVAS); + Vector lr = fwdMap(b,Coord::CANVAS); + Vector ul = fwdMap(a+c,Coord::CANVAS); + Vector ur = fwdMap(b+c,Coord::CANVAS); + + macosxDrawLine(lr,ur); + macosxDrawLine(ur,ul); + macosxDrawLine(ul,ll); + } +} + +void Projection::renderMACOSXGC() +{ + macosxColor(parent->getXColor(colorName)); + renderMACOSXLineNoDash(); +} +#endif + +#ifdef __WIN32 +void Projection::renderWIN32() +{ + renderWIN32GC(); + + Vector aa = parent->mapFromRef(p1,Coord::CANVAS); + Vector bb = parent->mapFromRef(p2,Coord::CANVAS); + + win32DrawLine(aa,bb); + + if (width>0) { + renderWIN32LineDash(); + + Matrix imm = bckMatrix(); + Vector a = p1*imm; + Vector b = p2*imm; + Vector c = Vector(0,-width); + + Vector ll = fwdMap(a,Coord::CANVAS); + Vector lr = fwdMap(b,Coord::CANVAS); + Vector ul = fwdMap(a+c,Coord::CANVAS); + Vector ur = fwdMap(b+c,Coord::CANVAS); + + win32DrawLine(lr,ur); + win32DrawLine(ur,ul); + win32DrawLine(ul,ll); + } +} + +void Projection::renderWIN32GC() +{ + win32Color(parent->getXColor(colorName)); + renderWIN32LineNoDash(); +} +#endif + +// Support + +void Projection::updateHandles() +{ + center = (p2-p1)/2 + p1; + angle = (p2-p1).angle(); + + Matrix imm = bckMatrix(); + Vector a = p1*imm; + Vector b = p2*imm; + Vector c = Vector(0,-width); + p3 = fwdMap(a+c,Coord::CANVAS); + p4 = fwdMap(b+c,Coord::CANVAS); + Vector hh = fwdMap(((b-a)/2+a)+c,Coord::CANVAS); + + // generate handles in Coord::CANVAS coords + handle[0] = parent->mapFromRef(p1,Coord::CANVAS); + handle[1] = parent->mapFromRef(p2,Coord::CANVAS); + handle[2] = hh; +} + +void Projection::calcAllBBox() +{ + // p3/p4 are already in Coord::CANVAS coords + bbox.bound(p3); + bbox.bound(p4); + Marker::calcAllBBox(); +} + +void Projection::edit(const Vector& v, int h) +{ + switch (h) { + case 1: + p1 = v; + break; + case 2: + p2 = v; + break; + case 3: + Matrix mm = bckMatrix(); + width = -(v * mm)[1]; + if (width<0) + width = 0; + break; + } + + updateBBox(); + doCallBack(CallBack::EDITCB); +} + +int Projection::isIn(const Vector& v) +{ + Vector zz = parent->zoom(); + if (width * zz.length() > parent->markerEpsilon) { + Matrix imm = bckMatrix(); + Vector a = p1*imm; + Vector b = p2*imm; + + Vector vv = -bckMap(v,Coord::CANVAS); + return (vv[0]>a[0] && vv[0]0 && vv[1]options->cmdName); + addCallBack(CallBack::EDITCB, analysisPlot2dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::UPDATECB, analysisPlot2dCB_[0], + parent->options->cmdName); + addCallBack(CallBack::DELETECB, analysisPlot2dCB_[1], + parent->options->cmdName); + } + if (analysisPlot2d_ && !which) { + deleteCallBack(CallBack::MOVECB, analysisPlot2dCB_[0]); + deleteCallBack(CallBack::EDITCB, analysisPlot2dCB_[0]); + deleteCallBack(CallBack::UPDATECB, analysisPlot2dCB_[0]); + deleteCallBack(CallBack::DELETECB, analysisPlot2dCB_[1]); + } + + analysisPlot2d_ = which; + break; + default: + // na + break; + } +} + +void Projection::analysisPlot2d(char* xname, char* yname, + char* xcname, char* ycname, + Coord::CoordSystem sys, Coord::SkyFrame sky, + Marker::AnalysisMethod method) +{ + double* x; + double* y; + double* xc; + double* yc; + + int num = parent->markerAnalysisPlot2d(this, &x, &y, &xc, &yc, p1, p2, width, + sys, sky, method); + analysisXYEEResult(xname, yname, xcname, ycname, x, y, xc, yc, num); +} + +// list + +void Projection::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + if (!strip) { + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 1); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listNonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSEqu(sys)) { + double ww = ptr->mapLenFromRef(width,sys,Coord::ARCSEC); + switch (format) { + case Coord::DEGREES: + { + Vector v1 = ptr->mapFromRef(p1,sys,sky); + Vector v2 = ptr->mapFromRef(p2,sys,sky); + str << type_ << '(' << setprecision(10) << v1 << ',' << v2 << ',' + << setprecision(3) << fixed << ww << '"' << ')'; + str.unsetf(ios_base::floatfield); + } + break; + case Coord::SEXAGESIMAL: + str << type_ << '('; + listRADEC(ptr,p1,sys,sky,format); + str << ra << ',' << dec << ','; + listRADEC(ptr,p2,sys,sky,format); + str << ra << ',' << dec << ','; + + str << setprecision(3) << fixed << ww << '"' << ')'; + str.unsetf(ios_base::floatfield); + break; + } + } + else + listNonCel(ptr, str, sys); + } + + if (conj) + str << " ||"; + + listProperties(str, 0); + } +} + +void Projection::listNonCel(FitsImage* ptr, ostream& str, + Coord::CoordSystem sys) +{ + Vector v1 = ptr->mapFromRef(p1,sys); + Vector v2 = ptr->mapFromRef(p2,sys); + double ww = ptr->mapLenFromRef(width,sys); + str << type_ << '(' << setprecision(8) << v1 << ',' << v2 << ',' + << ww << ')'; +} + +void Projection::listXML(ostream& str, Coord::CoordSystem sys, + Coord::SkyFrame sky, Coord::SkyFormat format) +{ + FitsImage* ptr = parent->findFits(sys,center); + Vector vv[2]; + vv[0] = p1; + vv[1] = p2; + double rr = ptr->mapLenFromRef(width,sys,Coord::ARCSEC); + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowPoint(ptr,sys,sky,format,vv,2); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + XMLRow(XMLR,rr,8); + break; + default: + if (ptr->hasWCS(sys)) { + if (ptr->hasWCSCel(sys)) + XMLRowARCSEC(XMLR,rr); + else + XMLRow(XMLR,rr,8); + } + break; + } + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} + + + diff --git a/tksao/frame/projection.h b/tksao/frame/projection.h new file mode 100644 index 0000000..2825091 --- /dev/null +++ b/tksao/frame/projection.h @@ -0,0 +1,68 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __projection_h__ +#define __projection_h__ + +#include "baseline.h" + +class Projection : public BaseLine { + private: + double width; + Vector p3; // used for bbox + Vector p4; + + private: + void renderX(Drawable, Coord::InternalSystem, RenderMode); + GC renderXGC(RenderMode); + + void renderPS(int); + void renderPSGC(int); + +#ifdef MAC_OSX_TK + void renderMACOSX(); + void renderMACOSXGC(); +#endif + +#ifdef __WIN32 + void renderWIN32(); + void renderWIN32GC(); +#endif + + void updateHandles(); + void calcAllBBox(); + + protected: + void listNonCel(FitsImage*, ostream&, Coord::CoordSystem); + + public: + Projection(const Projection&); + Projection(Base* p, const Vector& ptr1, const Vector& ptr2, + double wd, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + + Marker* dup() {return new Projection(*this);} + int isIn(const Vector&); + + void updateCoords(const Matrix&); + + void edit(const Vector&, int); + + void analysis(AnalysisTask, int); + void analysisPlot2d(char*, char*, char*, char*, + Coord::CoordSystem, Coord::SkyFrame, + Marker::AnalysisMethod); + + void set(const Vector&, const Vector&, double); + void setWidth(double); + double getWidth() {return width;} + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); +}; + +#endif diff --git a/tksao/frame/proslex.C b/tksao/frame/proslex.C new file mode 100644 index 0000000..9765f49 --- /dev/null +++ b/tksao/frame/proslex.C @@ -0,0 +1,2244 @@ +#line 2 "frame/proslex.C" + +#line 4 "frame/proslex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer prosFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *prosalloc (yy_size_t ); +void *prosrealloc (void *,yy_size_t ); +void prosfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 52 +#define YY_END_OF_BUFFER 53 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[198] = + { 0, + 0, 0, 2, 2, 53, 51, 47, 50, 51, 51, + 51, 51, 51, 22, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 14, 46, 46, 46, 46, 51, 51, + 2, 1, 47, 48, 0, 43, 0, 44, 0, 22, + 24, 33, 29, 23, 22, 0, 46, 25, 46, 46, + 27, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 16, 46, 46, 46, 46, 49, 0, + 45, 2, 24, 35, 31, 23, 25, 0, 0, 27, + 34, 30, 26, 0, 28, 25, 0, 46, 0, 23, + 46, 46, 46, 5, 46, 46, 46, 46, 46, 46, + + 46, 46, 15, 46, 46, 46, 46, 46, 36, 32, + 0, 23, 0, 0, 24, 0, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 0, 0, 0, 37, 0, 46, 0, + 46, 46, 4, 46, 7, 46, 46, 46, 46, 12, + 46, 46, 18, 46, 46, 46, 0, 0, 38, 37, + 0, 0, 41, 0, 0, 39, 46, 6, 46, 46, + 46, 46, 46, 46, 46, 20, 46, 41, 39, 42, + 40, 3, 46, 8, 46, 46, 13, 46, 19, 21, + 9, 46, 11, 17, 46, 10, 0 + + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 5, 1, 1, 1, 1, 6, 1, + 1, 1, 7, 1, 7, 8, 1, 9, 10, 11, + 12, 12, 13, 12, 12, 12, 14, 15, 1, 1, + 1, 1, 1, 1, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 26, 38, 39, 26, + 1, 40, 1, 1, 1, 1, 41, 42, 43, 44, + + 45, 46, 47, 48, 49, 50, 26, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 26, 62, + 63, 26, 64, 1, 65, 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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[66] = + { 0, + 1, 1, 2, 1, 3, 3, 1, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[204] = + { 0, + 0, 0, 134, 131, 130, 1540, 123, 1540, 121, 116, + 114, 58, 64, 74, 94, 98, 90, 121, 162, 127, + 138, 150, 154, 166, 170, 187, 182, 214, 62, 52, + 0, 1540, 114, 1540, 96, 1540, 86, 1540, 233, 255, + 308, 1540, 1540, 361, 414, 239, 222, 467, 478, 270, + 281, 286, 318, 330, 301, 342, 380, 385, 396, 489, + 433, 495, 500, 438, 459, 520, 524, 528, 1540, 25, + 1540, 0, 581, 1540, 1540, 634, 539, 553, 563, 1540, + 1540, 1540, 1540, 595, 1540, 1540, 606, 621, 646, 105, + 673, 656, 455, 573, 688, 692, 705, 709, 729, 733, + + 660, 745, 751, 756, 767, 771, 783, 787, 1540, 1540, + 794, 818, 826, 838, 850, 857, 872, 880, 890, 894, + 905, 811, 913, 918, 930, 942, 946, 961, 966, 972, + 978, 986, 990, 1009, 1024, 863, 1033, 999, 1041, 1047, + 1093, 1057, 1061, 1065, 1073, 1081, 1103, 1114, 1118, 1126, + 1130, 1142, 1150, 1158, 1164, 1175, 1183, 1210, 1197, 1221, + 1236, 1242, 1252, 1252, 1268, 1282, 1290, 1298, 1303, 1314, + 1325, 1330, 1336, 1356, 1341, 1360, 1375, 1540, 1540, 1540, + 1540, 1380, 1393, 1397, 1401, 1409, 1414, 1426, 1432, 1440, + 1451, 1455, 1459, 1467, 1473, 1478, 1540, 1524, 1527, 1530, + + 78, 1533, 1536 + } ; + +static yyconst flex_int16_t yy_def[204] = + { 0, + 197, 1, 198, 198, 197, 197, 197, 197, 197, 199, + 200, 197, 197, 201, 201, 201, 201, 201, 201, 201, + 201, 201, 201, 201, 201, 201, 201, 201, 197, 202, + 203, 197, 197, 197, 199, 197, 200, 197, 197, 197, + 197, 197, 197, 197, 201, 197, 201, 201, 201, 49, + 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, + 201, 201, 201, 201, 201, 201, 201, 201, 197, 202, + 197, 203, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 49, 197, 49, + 49, 201, 201, 201, 201, 201, 201, 201, 201, 201, + + 201, 201, 201, 201, 201, 201, 201, 201, 197, 197, + 197, 197, 197, 197, 197, 197, 49, 49, 201, 201, + 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, + 201, 201, 201, 197, 197, 197, 197, 197, 49, 197, + 49, 201, 201, 201, 201, 201, 201, 201, 201, 201, + 201, 201, 201, 201, 201, 201, 197, 197, 197, 197, + 197, 197, 201, 197, 197, 201, 201, 201, 201, 201, + 201, 201, 201, 201, 201, 201, 201, 197, 197, 197, + 197, 201, 201, 201, 201, 201, 201, 201, 201, 201, + 201, 201, 201, 201, 201, 201, 0, 197, 197, 197, + + 197, 197, 197 + } ; + +static yyconst flex_int16_t yy_nxt[1606] = + { 0, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, + 14, 14, 14, 14, 6, 15, 16, 17, 18, 19, + 20, 21, 20, 20, 22, 20, 23, 20, 24, 25, + 26, 20, 27, 20, 20, 20, 28, 20, 20, 29, + 15, 16, 17, 18, 19, 20, 21, 20, 20, 22, + 23, 20, 24, 25, 26, 20, 27, 20, 20, 20, + 28, 20, 20, 30, 6, 39, 40, 40, 40, 40, + 40, 40, 41, 41, 41, 41, 41, 41, 42, 43, + 47, 44, 45, 45, 45, 45, 45, 45, 46, 71, + 69, 38, 48, 49, 197, 197, 50, 197, 197, 197, + + 36, 197, 197, 197, 197, 197, 51, 53, 197, 74, + 75, 197, 197, 55, 69, 33, 71, 48, 49, 38, + 36, 50, 52, 34, 33, 197, 197, 54, 197, 197, + 51, 197, 197, 32, 197, 197, 32, 197, 55, 197, + 56, 197, 197, 197, 197, 197, 52, 197, 197, 197, + 197, 54, 197, 60, 197, 197, 197, 197, 197, 197, + 61, 197, 197, 197, 197, 56, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 60, 57, + 197, 197, 197, 62, 197, 197, 197, 197, 58, 197, + 63, 197, 197, 59, 197, 197, 197, 197, 64, 197, + + 197, 197, 197, 197, 57, 197, 197, 62, 197, 65, + 197, 67, 58, 197, 197, 63, 66, 59, 197, 197, + 197, 197, 64, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 68, 65, 67, 197, 197, 197, 197, + 66, 73, 73, 73, 73, 73, 73, 87, 87, 87, + 87, 87, 87, 197, 197, 197, 197, 197, 68, 74, + 75, 197, 76, 40, 40, 40, 40, 40, 40, 46, + 197, 197, 197, 77, 78, 197, 197, 79, 91, 91, + 91, 91, 91, 91, 197, 197, 197, 80, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 77, 78, + + 197, 197, 79, 197, 197, 197, 197, 197, 197, 197, + 197, 80, 81, 82, 92, 197, 41, 41, 41, 41, + 41, 41, 197, 197, 197, 197, 83, 84, 197, 197, + 197, 93, 197, 95, 197, 197, 197, 197, 92, 197, + 85, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 83, 84, 197, 197, 197, 197, 95, 96, 197, + 197, 197, 197, 197, 85, 42, 43, 94, 197, 41, + 41, 41, 41, 41, 41, 197, 197, 197, 197, 86, + 78, 197, 197, 96, 197, 197, 197, 197, 197, 197, + 197, 94, 197, 80, 197, 197, 197, 197, 197, 197, + + 197, 197, 197, 197, 86, 78, 97, 197, 197, 197, + 197, 98, 197, 197, 197, 197, 197, 80, 42, 43, + 197, 44, 45, 45, 45, 45, 45, 45, 46, 197, + 97, 99, 48, 49, 197, 98, 50, 197, 197, 197, + 197, 101, 197, 197, 197, 197, 51, 197, 197, 197, + 197, 197, 197, 197, 197, 99, 197, 48, 49, 197, + 197, 50, 197, 197, 197, 197, 197, 120, 197, 197, + 51, 197, 197, 197, 197, 88, 88, 88, 88, 88, + 88, 197, 197, 197, 89, 197, 90, 90, 90, 90, + 90, 90, 197, 197, 197, 197, 197, 104, 197, 197, + + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 100, 102, 197, 197, 197, + 103, 104, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 100, + 197, 102, 197, 105, 197, 103, 106, 111, 111, 111, + 111, 111, 111, 197, 197, 197, 197, 197, 107, 89, + 108, 112, 112, 112, 112, 112, 112, 197, 105, 197, + 106, 113, 113, 113, 113, 113, 113, 197, 197, 197, + 197, 197, 107, 197, 108, 109, 110, 197, 197, 73, + 73, 73, 73, 73, 73, 197, 197, 197, 197, 83, + + 84, 114, 197, 115, 115, 115, 115, 115, 115, 197, + 197, 197, 197, 85, 87, 87, 87, 87, 87, 87, + 116, 197, 197, 197, 83, 84, 197, 197, 197, 88, + 88, 88, 88, 88, 88, 197, 197, 85, 74, 75, + 197, 197, 73, 73, 73, 73, 73, 73, 117, 197, + 197, 197, 86, 78, 112, 112, 112, 112, 112, 112, + 197, 197, 197, 197, 197, 197, 80, 197, 127, 197, + 197, 197, 117, 197, 197, 197, 197, 86, 78, 197, + 197, 91, 91, 91, 91, 91, 91, 197, 197, 197, + 80, 119, 197, 197, 197, 197, 197, 197, 197, 197, + + 118, 197, 197, 197, 197, 121, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 119, 197, 197, 197, 197, + 197, 197, 197, 197, 118, 197, 197, 122, 123, 197, + 121, 197, 124, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 125, 197, 197, 197, 126, 197, + 197, 122, 197, 123, 197, 197, 197, 124, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 128, 125, + 197, 197, 197, 126, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 129, + 197, 197, 197, 128, 197, 130, 197, 197, 197, 132, + + 197, 197, 111, 111, 111, 111, 111, 111, 197, 131, + 197, 197, 197, 129, 197, 197, 197, 197, 197, 130, + 133, 134, 74, 75, 132, 197, 112, 112, 112, 112, + 112, 112, 145, 131, 113, 113, 113, 113, 113, 113, + 197, 197, 197, 197, 133, 134, 115, 115, 115, 115, + 115, 115, 197, 135, 109, 110, 197, 145, 115, 115, + 115, 115, 115, 115, 136, 137, 137, 137, 137, 137, + 137, 159, 159, 159, 159, 159, 159, 135, 197, 138, + 139, 139, 139, 139, 139, 139, 197, 140, 141, 141, + 141, 141, 141, 141, 197, 197, 197, 197, 197, 197, + + 197, 197, 143, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 142, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 144, 197, 197, 197, 197, 197, 197, 197, 197, + 142, 197, 197, 146, 197, 197, 197, 197, 147, 197, + 197, 197, 197, 197, 150, 144, 197, 197, 197, 149, + 197, 197, 197, 197, 148, 197, 197, 146, 197, 197, + 197, 197, 147, 197, 197, 197, 197, 197, 151, 197, + 197, 197, 197, 197, 149, 197, 197, 197, 148, 152, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 154, + + 197, 197, 197, 151, 197, 197, 153, 161, 161, 161, + 161, 161, 161, 156, 152, 155, 138, 157, 157, 157, + 157, 157, 157, 197, 154, 197, 197, 197, 197, 197, + 153, 140, 158, 158, 158, 158, 158, 158, 156, 155, + 160, 137, 137, 137, 137, 137, 137, 197, 162, 139, + 139, 139, 139, 139, 139, 164, 164, 164, 164, 164, + 164, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 163, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 168, 197, 197, 197, 197, 197, + 197, 197, 167, 197, 197, 197, 197, 197, 163, 197, + + 165, 141, 141, 141, 141, 141, 141, 197, 197, 168, + 197, 197, 197, 197, 197, 169, 167, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 166, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 170, 197, 197, 169, + 197, 197, 197, 171, 197, 173, 197, 197, 197, 197, + 166, 197, 172, 197, 197, 197, 197, 197, 197, 174, + 170, 197, 197, 197, 197, 197, 197, 171, 197, 197, + 173, 197, 197, 197, 197, 197, 172, 197, 197, 197, + 197, 197, 197, 197, 174, 197, 197, 175, 197, 197, + 162, 157, 157, 157, 157, 157, 157, 197, 197, 197, + + 197, 176, 197, 197, 177, 159, 159, 159, 159, 159, + 159, 175, 197, 197, 197, 197, 178, 165, 158, 158, + 158, 158, 158, 158, 197, 176, 197, 197, 177, 159, + 159, 159, 159, 159, 159, 197, 197, 197, 197, 197, + 178, 197, 197, 179, 161, 161, 161, 161, 161, 161, + 161, 161, 161, 161, 161, 161, 197, 197, 197, 197, + 164, 164, 164, 164, 164, 164, 197, 179, 197, 180, + 197, 197, 197, 197, 197, 178, 164, 164, 164, 164, + 164, 164, 197, 197, 197, 181, 197, 197, 197, 197, + 197, 197, 197, 180, 197, 197, 197, 197, 197, 178, + + 197, 179, 197, 197, 197, 197, 197, 197, 197, 181, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 182, 197, 179, 183, 197, 197, 197, + 197, 197, 197, 184, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 182, 197, 197, + 197, 183, 197, 186, 197, 197, 197, 185, 184, 197, + 197, 197, 187, 197, 197, 197, 197, 197, 197, 189, + 197, 188, 197, 197, 197, 197, 197, 197, 186, 197, + 197, 185, 197, 197, 197, 197, 187, 197, 197, 197, + 197, 197, 197, 189, 197, 197, 188, 197, 197, 197, + + 197, 197, 197, 190, 197, 197, 197, 197, 197, 197, + 191, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 192, 197, 193, 190, 197, 197, + 197, 197, 197, 197, 197, 191, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 192, + 197, 193, 194, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 195, 197, 197, 197, 197, 197, 194, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 195, 197, 197, 197, 196, + + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 196, 31, 31, 31, 35, 197, 35, + 37, 197, 37, 70, 197, 70, 72, 197, 72, 5, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + + 197, 197, 197, 197, 197 + } ; + +static yyconst flex_int16_t yy_chk[1606] = + { 0, + 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, 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, 1, 1, + 1, 1, 1, 1, 1, 12, 12, 12, 12, 12, + 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, + 201, 14, 14, 14, 14, 14, 14, 14, 14, 70, + 29, 37, 14, 14, 17, 17, 14, 17, 15, 15, + + 35, 15, 16, 16, 17, 16, 14, 16, 15, 90, + 90, 90, 16, 17, 29, 33, 30, 14, 14, 11, + 10, 14, 15, 9, 7, 18, 18, 16, 18, 5, + 14, 20, 20, 4, 20, 18, 3, 0, 17, 0, + 18, 20, 21, 21, 0, 21, 15, 0, 0, 0, + 0, 16, 21, 21, 22, 22, 0, 22, 23, 23, + 22, 23, 0, 0, 22, 18, 19, 19, 23, 19, + 24, 24, 0, 24, 25, 25, 19, 25, 21, 19, + 24, 0, 0, 23, 25, 0, 27, 27, 19, 27, + 25, 26, 26, 19, 26, 0, 27, 0, 25, 0, + + 0, 26, 0, 0, 19, 0, 0, 23, 0, 26, + 0, 27, 19, 0, 0, 25, 26, 19, 28, 28, + 0, 28, 25, 0, 0, 0, 47, 47, 28, 47, + 0, 0, 0, 28, 26, 27, 47, 0, 0, 0, + 26, 39, 39, 39, 39, 39, 39, 46, 46, 46, + 46, 46, 46, 0, 0, 0, 0, 0, 28, 40, + 40, 0, 40, 40, 40, 40, 40, 40, 40, 40, + 0, 0, 0, 40, 40, 0, 50, 40, 50, 50, + 50, 50, 50, 50, 0, 51, 51, 40, 51, 0, + 52, 52, 0, 52, 0, 51, 0, 0, 40, 40, + + 52, 0, 40, 0, 0, 55, 55, 0, 55, 0, + 0, 40, 41, 41, 52, 55, 41, 41, 41, 41, + 41, 41, 53, 53, 0, 53, 41, 41, 0, 0, + 0, 53, 53, 55, 54, 54, 0, 54, 52, 0, + 41, 0, 0, 0, 54, 0, 56, 56, 0, 56, + 0, 41, 41, 0, 0, 0, 56, 55, 56, 0, + 0, 0, 0, 0, 41, 44, 44, 54, 0, 44, + 44, 44, 44, 44, 44, 0, 0, 0, 0, 44, + 44, 0, 0, 56, 57, 57, 0, 57, 0, 58, + 58, 54, 58, 44, 57, 0, 0, 0, 0, 58, + + 59, 59, 0, 59, 44, 44, 57, 0, 0, 0, + 59, 58, 0, 0, 0, 0, 0, 44, 45, 45, + 0, 45, 45, 45, 45, 45, 45, 45, 45, 0, + 57, 59, 45, 45, 0, 58, 45, 61, 61, 0, + 61, 61, 64, 64, 0, 64, 45, 61, 0, 0, + 0, 0, 64, 0, 0, 59, 0, 45, 45, 93, + 93, 45, 93, 65, 65, 0, 65, 93, 0, 93, + 45, 48, 48, 65, 48, 48, 48, 48, 48, 48, + 48, 48, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 60, 60, 0, 60, 65, 0, 62, + + 62, 0, 62, 60, 63, 63, 0, 63, 0, 62, + 0, 0, 0, 0, 63, 60, 62, 0, 0, 0, + 63, 65, 0, 0, 66, 66, 0, 66, 67, 67, + 0, 67, 68, 68, 66, 68, 0, 0, 67, 60, + 0, 62, 68, 66, 0, 63, 66, 77, 77, 77, + 77, 77, 77, 0, 0, 0, 0, 0, 67, 78, + 68, 78, 78, 78, 78, 78, 78, 0, 66, 0, + 66, 79, 79, 79, 79, 79, 79, 94, 94, 0, + 94, 0, 67, 0, 68, 73, 73, 94, 0, 73, + 73, 73, 73, 73, 73, 0, 0, 0, 0, 73, + + 73, 84, 0, 84, 84, 84, 84, 84, 84, 0, + 0, 0, 0, 73, 87, 87, 87, 87, 87, 87, + 87, 0, 0, 0, 73, 73, 0, 88, 0, 88, + 88, 88, 88, 88, 88, 0, 0, 73, 76, 76, + 0, 0, 76, 76, 76, 76, 76, 76, 88, 0, + 0, 0, 76, 76, 89, 89, 89, 89, 89, 89, + 92, 92, 0, 92, 101, 101, 76, 101, 101, 0, + 92, 0, 88, 0, 101, 0, 0, 76, 76, 91, + 0, 91, 91, 91, 91, 91, 91, 0, 0, 0, + 76, 92, 95, 95, 0, 95, 96, 96, 0, 96, + + 91, 0, 95, 0, 0, 95, 96, 0, 0, 97, + 97, 0, 97, 98, 98, 92, 98, 0, 0, 97, + 0, 0, 0, 98, 91, 0, 0, 96, 97, 0, + 95, 0, 98, 99, 99, 0, 99, 100, 100, 0, + 100, 0, 0, 99, 99, 0, 0, 100, 100, 102, + 102, 96, 102, 97, 0, 103, 103, 98, 103, 102, + 104, 104, 0, 104, 0, 103, 0, 0, 102, 99, + 104, 105, 105, 100, 105, 106, 106, 0, 106, 0, + 0, 105, 0, 0, 0, 106, 0, 107, 107, 104, + 107, 108, 108, 102, 108, 105, 0, 107, 0, 107, + + 0, 108, 111, 111, 111, 111, 111, 111, 0, 106, + 0, 0, 0, 104, 0, 122, 122, 0, 122, 105, + 108, 111, 112, 112, 107, 122, 112, 112, 112, 112, + 112, 112, 122, 106, 113, 113, 113, 113, 113, 113, + 0, 0, 0, 0, 108, 111, 114, 114, 114, 114, + 114, 114, 0, 113, 115, 115, 0, 122, 115, 115, + 115, 115, 115, 115, 116, 116, 116, 116, 116, 116, + 116, 136, 136, 136, 136, 136, 136, 113, 117, 117, + 117, 117, 117, 117, 117, 117, 118, 118, 118, 118, + 118, 118, 118, 118, 119, 119, 0, 119, 120, 120, + + 0, 120, 120, 0, 119, 0, 0, 0, 120, 121, + 121, 0, 121, 0, 0, 0, 119, 123, 123, 121, + 123, 0, 124, 124, 0, 124, 0, 123, 0, 0, + 0, 121, 124, 0, 125, 125, 0, 125, 0, 0, + 119, 0, 0, 123, 125, 0, 126, 126, 124, 126, + 127, 127, 0, 127, 127, 121, 126, 0, 0, 126, + 127, 0, 0, 0, 125, 128, 128, 123, 128, 0, + 129, 129, 124, 129, 0, 128, 130, 130, 128, 130, + 129, 0, 131, 131, 126, 131, 130, 0, 125, 129, + 132, 132, 131, 132, 133, 133, 0, 133, 0, 131, + + 132, 0, 0, 128, 133, 0, 130, 138, 138, 138, + 138, 138, 138, 133, 129, 132, 134, 134, 134, 134, + 134, 134, 134, 0, 131, 0, 0, 0, 0, 0, + 130, 135, 135, 135, 135, 135, 135, 135, 133, 132, + 137, 137, 137, 137, 137, 137, 137, 139, 139, 139, + 139, 139, 139, 139, 139, 140, 140, 140, 140, 140, + 140, 142, 142, 0, 142, 143, 143, 0, 143, 144, + 144, 142, 144, 0, 139, 143, 0, 145, 145, 144, + 145, 0, 0, 0, 144, 146, 146, 145, 146, 0, + 0, 0, 142, 0, 0, 146, 0, 0, 139, 141, + + 141, 141, 141, 141, 141, 141, 141, 147, 147, 144, + 147, 0, 0, 0, 0, 146, 142, 147, 148, 148, + 0, 148, 149, 149, 0, 149, 141, 0, 148, 0, + 150, 150, 149, 150, 151, 151, 147, 151, 0, 146, + 150, 0, 0, 148, 151, 151, 152, 152, 0, 152, + 141, 0, 149, 0, 153, 153, 152, 153, 0, 152, + 147, 0, 154, 154, 153, 154, 0, 148, 155, 155, + 151, 155, 154, 0, 0, 0, 149, 0, 155, 156, + 156, 0, 156, 0, 152, 0, 0, 154, 0, 156, + 157, 157, 157, 157, 157, 157, 157, 0, 0, 0, + + 0, 155, 0, 0, 156, 159, 159, 159, 159, 159, + 159, 154, 0, 0, 0, 0, 157, 158, 158, 158, + 158, 158, 158, 158, 0, 155, 0, 0, 156, 160, + 160, 160, 160, 160, 160, 0, 0, 0, 0, 0, + 157, 0, 0, 158, 161, 161, 161, 161, 161, 161, + 162, 162, 162, 162, 162, 162, 163, 163, 0, 163, + 164, 164, 164, 164, 164, 164, 163, 158, 0, 161, + 0, 0, 0, 0, 0, 162, 165, 165, 165, 165, + 165, 165, 0, 0, 0, 164, 166, 166, 0, 166, + 0, 0, 0, 161, 167, 167, 166, 167, 0, 162, + + 0, 165, 168, 168, 167, 168, 0, 169, 169, 164, + 169, 0, 168, 0, 0, 0, 0, 169, 170, 170, + 0, 170, 0, 167, 0, 165, 169, 0, 170, 171, + 171, 0, 171, 170, 172, 172, 0, 172, 0, 171, + 173, 173, 0, 173, 172, 175, 175, 167, 175, 0, + 173, 169, 0, 172, 0, 175, 0, 171, 170, 0, + 174, 174, 173, 174, 176, 176, 0, 176, 0, 175, + 174, 174, 0, 0, 176, 0, 0, 0, 172, 177, + 177, 171, 177, 0, 182, 182, 173, 182, 0, 177, + 0, 0, 0, 175, 182, 0, 174, 183, 183, 0, + + 183, 184, 184, 177, 184, 185, 185, 183, 185, 0, + 183, 184, 0, 186, 186, 185, 186, 0, 187, 187, + 0, 187, 0, 186, 185, 0, 186, 177, 187, 0, + 188, 188, 0, 188, 0, 183, 189, 189, 0, 189, + 188, 0, 0, 0, 190, 190, 189, 190, 0, 185, + 0, 186, 188, 0, 190, 191, 191, 0, 191, 192, + 192, 0, 192, 193, 193, 191, 193, 0, 0, 192, + 192, 194, 194, 193, 194, 0, 188, 195, 195, 0, + 195, 194, 196, 196, 0, 196, 0, 195, 0, 0, + 0, 0, 196, 0, 0, 192, 0, 0, 0, 195, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 195, 198, 198, 198, 199, 0, 199, + 200, 0, 200, 202, 0, 202, 203, 0, 203, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, + + 197, 197, 197, 197, 197 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "frame/proslex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 12 "frame/proslex.L" + #include + #include + #include + + #include "util.h" + #include "prosparser.H" + + extern YYSTYPE* proslval; + extern prosFlexLexer* proslexx; + +/* rules */ +#line 846 "frame/proslex.C" + +#define INITIAL 0 +#define DISCARD 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 30 "frame/proslex.L" + + +#line 950 "frame/proslex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 198 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 197 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +#line 32 "frame/proslex.L" +{ // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(proslval->str,""); // feed a blank string + return STRING; + } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 39 "frame/proslex.L" +{ // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(PROSBUFSIZE-1) ? yyleng:(PROSBUFSIZE-1); + strncpy(proslval->str,yytext,ll); + proslval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 47 "frame/proslex.L" +{return ANNULUS_;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 48 "frame/proslex.L" +{return B1950_;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 49 "frame/proslex.L" +{return BOX_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 50 "frame/proslex.L" +{return CIRCLE_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 51 "frame/proslex.L" +{return DEBUG_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 52 "frame/proslex.L" +{return ELLIPSE_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 53 "frame/proslex.L" +{return ECLIPTIC_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 54 "frame/proslex.L" +{return EQUATORIAL_;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 55 "frame/proslex.L" +{return GALACTIC_;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 56 "frame/proslex.L" +{return J2000_;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 57 "frame/proslex.L" +{return LOGICAL_;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 58 "frame/proslex.L" +{return N_;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 59 "frame/proslex.L" +{return OFF_;} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 60 "frame/proslex.L" +{return ON_;} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 61 "frame/proslex.L" +{return PHYSICAL_;} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 62 "frame/proslex.L" +{return POINT_;} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 63 "frame/proslex.L" +{return POLYGON_;} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 64 "frame/proslex.L" +{return ROTBOX_;} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 65 "frame/proslex.L" +{return VERSION_;} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 67 "frame/proslex.L" +{ // Integer + proslval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 23: +#line 73 "frame/proslex.L" +case 24: +YY_RULE_SETUP +#line 73 "frame/proslex.L" +{ // Real Number + proslval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 25: +#line 79 "frame/proslex.L" +case 26: +YY_RULE_SETUP +#line 79 "frame/proslex.L" +{ // degrees + yytext[yyleng-1] = '\0'; + proslval->real = atof(yytext); + return ANGDEGREE; + } + YY_BREAK +case 27: +#line 86 "frame/proslex.L" +case 28: +YY_RULE_SETUP +#line 86 "frame/proslex.L" +{ // radians + yytext[yyleng-1] = '\0'; + proslval->real = atof(yytext); + return ANGRADIAN; + } + YY_BREAK +case 29: +#line 93 "frame/proslex.L" +case 30: +#line 94 "frame/proslex.L" +case 31: +#line 95 "frame/proslex.L" +case 32: +YY_RULE_SETUP +#line 95 "frame/proslex.L" +{ // minutes of arc + yytext[yyleng-1] = '\0'; + proslval->real = atof(yytext); + return ARCMINUTE; + } + YY_BREAK +case 33: +#line 102 "frame/proslex.L" +case 34: +#line 103 "frame/proslex.L" +case 35: +#line 104 "frame/proslex.L" +case 36: +YY_RULE_SETUP +#line 104 "frame/proslex.L" +{ // seconds of arc + yytext[yyleng-1] = '\0'; + proslval->real = atof(yytext); + return ARCSECOND; + } + YY_BREAK +case 37: +#line 111 "frame/proslex.L" +case 38: +YY_RULE_SETUP +#line 111 "frame/proslex.L" +{ // Sexagesimal + int ll = yyleng <(PROSBUFSIZE-1) ? yyleng:(PROSBUFSIZE-1); + strncpy(proslval->str,yytext,ll); + proslval->str[ll] = '\0'; + return SEXSTR; + } + YY_BREAK +case 39: +#line 119 "frame/proslex.L" +case 40: +YY_RULE_SETUP +#line 119 "frame/proslex.L" +{ // HMS + int ll = yyleng <(PROSBUFSIZE-1) ? yyleng:(PROSBUFSIZE-1); + strncpy(proslval->str,yytext,ll); + proslval->str[ll] = '\0'; + return HMSSTR; + } + YY_BREAK +case 41: +#line 127 "frame/proslex.L" +case 42: +YY_RULE_SETUP +#line 127 "frame/proslex.L" +{ // DMS + int ll = yyleng <(PROSBUFSIZE-1) ? yyleng:(PROSBUFSIZE-1); + strncpy(proslval->str,yytext,ll); + proslval->str[ll] = '\0'; + return DMSSTR; + } + YY_BREAK +case 43: +#line 135 "frame/proslex.L" +case 44: +YY_RULE_SETUP +#line 135 "frame/proslex.L" +{ // Quoted String + int ll=(yyleng-2)<(PROSBUFSIZE-1)?(yyleng-2):(PROSBUFSIZE-1); + strncpy(proslval->str,yytext+1,ll); // skip the " " + proslval->str[ll] = '\0'; // Remove the '"' + return STRING; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 142 "frame/proslex.L" +{ // Quoted String + int ll=(yyleng-2)<(PROSBUFSIZE-1)?(yyleng-2):(PROSBUFSIZE-1); + strncpy(proslval->str,yytext+1,ll); // skip the '{' + proslval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 149 "frame/proslex.L" +{ // General String + int ll = yyleng <(PROSBUFSIZE-1) ? yyleng:(PROSBUFSIZE-1); + strncpy(proslval->str,yytext,ll); + proslval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 156 "frame/proslex.L" +{ // White Spaces + } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 159 "frame/proslex.L" +{ // windows line feed + return '\n'; + } + YY_BREAK +case 49: +YY_RULE_SETUP +#line 163 "frame/proslex.L" +{ // fake line feed + return '\n'; + } + YY_BREAK +case 50: +/* rule 50 can match eol */ +YY_RULE_SETUP +#line 167 "frame/proslex.L" +{ // linefeed + return '\n'; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(DISCARD): +#line 171 "frame/proslex.L" +{ // eof + return EOF_; + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 175 "frame/proslex.L" +{ // Else, return the char + return yytext[0]; + } + YY_BREAK +case 52: +YY_RULE_SETUP +#line 179 "frame/proslex.L" +ECHO; + YY_BREAK +#line 1332 "frame/proslex.C" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + prosfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + prosfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + prosrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) prosrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 198 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 198 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 197); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) prosalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) prosalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + prosfree((void *) b->yy_ch_buf ); + + prosfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)prosalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)prosrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) prosalloc(new_size ); + + else + (yy_start_stack) = (int *) prosrealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *prosalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *prosrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void prosfree (void * ptr ) +{ + free( (char *) ptr ); /* see prosrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 179 "frame/proslex.L" + + + +void prosDiscard(int doit) +{ + if (proslexx) + proslexx->begin(DISCARD, doit); +} + +void prosFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} + diff --git a/tksao/frame/proslex.L b/tksao/frame/proslex.L new file mode 100644 index 0000000..d607cad --- /dev/null +++ b/tksao/frame/proslex.L @@ -0,0 +1,192 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ + +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + + #include "util.h" + #include "prosparser.H" + + extern YYSTYPE* proslval; + extern prosFlexLexer* proslexx; +%} + +%x DISCARD + +D [0-9] +E [Ee][+-]?{D}+ + +/* rules */ + +%% + +[\n] { // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(proslval->str,""); // feed a blank string + return STRING; + } + +[^\n]* { // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(PROSBUFSIZE-1) ? yyleng:(PROSBUFSIZE-1); + strncpy(proslval->str,yytext,ll); + proslval->str[ll] = '\0'; + return STRING; + } + +annulus {return ANNULUS_;} +b1950 {return B1950_;} +box {return BOX_;} +circle {return CIRCLE_;} +debug {return DEBUG_;} +ellipse {return ELLIPSE_;} +ecliptic {return ECLIPTIC_;} +equatorial {return EQUATORIAL_;} +galactic {return GALACTIC_;} +j2000 {return J2000_;} +logical {return LOGICAL_;} +n {return N_;} +off {return OFF_;} +on {return ON_;} +physical {return PHYSICAL_;} +point {return POINT_;} +polygon {return POLYGON_;} +rotbox {return ROTBOX_;} +version {return VERSION_;} + +[+-]?{D}+ { // Integer + proslval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + proslval->real = atof(yytext); + return REAL; + } + +[+-]?{D}+"."?d | +[+-]?{D}*"."{D}+d { // degrees + yytext[yyleng-1] = '\0'; + proslval->real = atof(yytext); + return ANGDEGREE; + } + +[+-]?{D}+"."?r | +[+-]?{D}*"."{D}+r { // radians + yytext[yyleng-1] = '\0'; + proslval->real = atof(yytext); + return ANGRADIAN; + } + +{D}+"."?' | +{D}*"."{D}+' | +[+-]?{D}+"."?({E})?' | +[+-]?{D}*"."{D}+({E})?' { // minutes of arc + yytext[yyleng-1] = '\0'; + proslval->real = atof(yytext); + return ARCMINUTE; + } + +{D}+"."?\" | +{D}*"."{D}+\" | +[+-]?{D}+"."?({E})?\" | +[+-]?{D}*"."{D}+({E})?\" { // seconds of arc + yytext[yyleng-1] = '\0'; + proslval->real = atof(yytext); + return ARCSECOND; + } + +[+-]?{D}+:{D}+:{D}+"."? | +[+-]?{D}+:{D}+:{D}*"."{D}+ { // Sexagesimal + int ll = yyleng <(PROSBUFSIZE-1) ? yyleng:(PROSBUFSIZE-1); + strncpy(proslval->str,yytext,ll); + proslval->str[ll] = '\0'; + return SEXSTR; + } + +[+-]?{D}+h{D}+m{D}+"."?s | +[+-]?{D}+h{D}+m{D}*"."{D}+s { // HMS + int ll = yyleng <(PROSBUFSIZE-1) ? yyleng:(PROSBUFSIZE-1); + strncpy(proslval->str,yytext,ll); + proslval->str[ll] = '\0'; + return HMSSTR; + } + +[+-]?{D}+d{D}+m{D}+"."?s | +[+-]?{D}+d{D}+m{D}*"."{D}+s { // DMS + int ll = yyleng <(PROSBUFSIZE-1) ? yyleng:(PROSBUFSIZE-1); + strncpy(proslval->str,yytext,ll); + proslval->str[ll] = '\0'; + return DMSSTR; + } + +\"[^\"\n]*\" | +\'[^\'\n]*\' { // Quoted String + int ll=(yyleng-2)<(PROSBUFSIZE-1)?(yyleng-2):(PROSBUFSIZE-1); + strncpy(proslval->str,yytext+1,ll); // skip the " " + proslval->str[ll] = '\0'; // Remove the '"' + return STRING; + } + +\{[^\}\n]*\} { // Quoted String + int ll=(yyleng-2)<(PROSBUFSIZE-1)?(yyleng-2):(PROSBUFSIZE-1); + strncpy(proslval->str,yytext+1,ll); // skip the '{' + proslval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + +[0-9A-Za-z]+ { // General String + int ll = yyleng <(PROSBUFSIZE-1) ? yyleng:(PROSBUFSIZE-1); + strncpy(proslval->str,yytext,ll); + proslval->str[ll] = '\0'; + return STRING; + } + +[ \t]+ { // White Spaces + } + +\r\n { // windows line feed + return '\n'; + } + +\\n { // fake line feed + return '\n'; + } + +\n { // linefeed + return '\n'; + } + +<> { // eof + return EOF_; + } + +. { // Else, return the char + return yytext[0]; + } + +%% + +void prosDiscard(int doit) +{ + if (proslexx) + proslexx->begin(DISCARD, doit); +} + +void prosFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} diff --git a/tksao/frame/prosparser.C b/tksao/frame/prosparser.C new file mode 100644 index 0000000..13b8715 --- /dev/null +++ b/tksao/frame/prosparser.C @@ -0,0 +1,2335 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse prosparse +#define yylex proslex +#define yyerror proserror +#define yylval proslval +#define yychar proschar +#define yydebug prosdebug +#define yynerrs prosnerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + STRING = 260, + ANGDEGREE = 261, + ARCMINUTE = 262, + ARCSECOND = 263, + ANGRADIAN = 264, + SEXSTR = 265, + HMSSTR = 266, + DMSSTR = 267, + EOF_ = 268, + ANNULUS_ = 269, + B1950_ = 270, + BOX_ = 271, + CIRCLE_ = 272, + DEBUG_ = 273, + ECLIPTIC_ = 274, + ELLIPSE_ = 275, + EQUATORIAL_ = 276, + GALACTIC_ = 277, + J2000_ = 278, + LOGICAL_ = 279, + N_ = 280, + OFF_ = 281, + ON_ = 282, + PHYSICAL_ = 283, + POINT_ = 284, + POLYGON_ = 285, + ROTBOX_ = 286, + VERSION_ = 287 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define STRING 260 +#define ANGDEGREE 261 +#define ARCMINUTE 262 +#define ARCSECOND 263 +#define ANGRADIAN 264 +#define SEXSTR 265 +#define HMSSTR 266 +#define DMSSTR 267 +#define EOF_ 268 +#define ANNULUS_ 269 +#define B1950_ 270 +#define BOX_ 271 +#define CIRCLE_ 272 +#define DEBUG_ 273 +#define ECLIPTIC_ 274 +#define ELLIPSE_ 275 +#define EQUATORIAL_ 276 +#define GALACTIC_ 277 +#define J2000_ 278 +#define LOGICAL_ 279 +#define N_ 280 +#define OFF_ 281 +#define ON_ 282 +#define PHYSICAL_ 283 +#define POINT_ 284 +#define POLYGON_ 285 +#define ROTBOX_ 286 +#define VERSION_ 287 + + + + +/* Copy the first part of user declarations. */ +#line 10 "frame/prosparser.Y" + +#define YYDEBUG 1 + +#define FITSPTR (fr->findFits()) +#define DISCARD_(x) {yyclearin; prosDiscard(x);} + +#include +#include +#include + +#include "base.h" +#include "fitsimage.h" +#include "basemarker.h" + +#undef yyFlexLexer +#define yyFlexLexer prosFlexLexer +#include + +extern int proslex(void*, prosFlexLexer*); +extern void proserror(Base*, prosFlexLexer*, const char*); +extern void prosDiscard(int); + +static Coord::CoordSystem globalSystem; +static Coord::SkyFrame globalSky; +static Coord::CoordSystem localSystem; +static Coord::SkyFrame localSky; + +static unsigned short globalProps; +static unsigned short localProps; + +static const char *color = "green"; +static int dash[] ={8,3}; +static const char *font = "helvetica 10 normal roman"; +static const char *text = ""; + +static char localComment[80]; + +static List polylist; +static List taglist; +static List cblist; + +static double aAnnuli[MAXANNULI]; +static Vector aVector[MAXANNULI]; +static int aNum; +static int aStatus; +static Vector aCenter; +static double aAngle; +static unsigned short aProps; +static char aComment[80]; + +static void setProps(unsigned short* props, unsigned short prop, int value); +static Coord::CoordSystem checkWCSSystem(); +static Coord::SkyFrame checkWCSSky(); + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 65 "frame/prosparser.Y" +{ +#define PROSBUFSIZE 2048 + double real; + int integer; + char str[PROSBUFSIZE]; + double vector[3]; +} +/* Line 193 of yacc.c. */ +#line 231 "frame/prosparser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 244 "frame/prosparser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 215 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 44 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 41 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 90 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 187 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 287 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 33, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 42, 2, 43, 2, 2, 41, 2, + 36, 37, 2, 39, 35, 40, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 34, + 2, 38, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 7, 11, 14, 15, 18, 20, 21, + 25, 26, 30, 34, 36, 38, 40, 42, 44, 46, + 48, 50, 51, 53, 54, 56, 57, 59, 60, 62, + 64, 66, 68, 70, 72, 74, 76, 80, 84, 88, + 92, 96, 98, 100, 102, 106, 110, 114, 118, 122, + 124, 126, 129, 131, 133, 135, 137, 139, 141, 142, + 143, 144, 146, 148, 156, 166, 167, 180, 192, 202, + 221, 231, 241, 260, 266, 267, 274, 278, 280, 282, + 286, 288, 290, 291, 292, 293, 297, 298, 302, 304, + 305 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 45, 0, -1, 68, 46, 78, -1, 46, 47, 50, + -1, 47, 50, -1, -1, 18, 52, -1, 32, -1, + -1, 65, 48, 79, -1, -1, 66, 49, 79, -1, + 69, 70, 71, -1, 81, -1, 33, -1, 34, -1, + 13, -1, 4, -1, 3, -1, 27, -1, 26, -1, + -1, 35, -1, -1, 36, -1, -1, 37, -1, -1, + 57, -1, 51, -1, 6, -1, 9, -1, 51, -1, + 6, -1, 7, -1, 8, -1, 51, 53, 51, -1, + 6, 53, 6, -1, 7, 53, 7, -1, 8, 53, + 8, -1, 25, 38, 3, -1, 10, -1, 11, -1, + 12, -1, 61, 53, 61, -1, 62, 53, 63, -1, + 63, 53, 63, -1, 51, 53, 51, -1, 6, 53, + 6, -1, 24, -1, 28, -1, 21, 67, -1, 15, + -1, 23, -1, 22, -1, 19, -1, 15, -1, 23, + -1, -1, -1, -1, 39, -1, 40, -1, 17, 54, + 64, 53, 58, 55, 83, -1, 14, 54, 64, 53, + 58, 53, 58, 55, 83, -1, -1, 14, 54, 64, + 53, 58, 53, 58, 53, 72, 76, 55, 83, -1, + 14, 54, 64, 53, 58, 53, 58, 53, 60, 55, + 83, -1, 20, 54, 64, 53, 59, 53, 56, 55, + 83, -1, 20, 54, 64, 53, 59, 53, 56, 55, + 41, 42, 20, 54, 64, 53, 59, 53, 56, 55, + -1, 16, 54, 64, 53, 59, 53, 56, 55, 83, + -1, 31, 54, 64, 53, 59, 53, 56, 55, 83, + -1, 16, 54, 64, 53, 59, 53, 56, 55, 41, + 42, 16, 54, 64, 53, 59, 53, 56, 55, -1, + 29, 54, 64, 55, 83, -1, -1, 30, 73, 54, + 74, 55, 83, -1, 74, 53, 75, -1, 75, -1, + 64, -1, 76, 53, 77, -1, 77, -1, 58, -1, + -1, -1, -1, 43, 80, 5, -1, -1, 43, 82, + 5, -1, 78, -1, -1, 43, 84, 5, 78, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 125, 125, 128, 129, 132, 133, 134, 135, 135, + 136, 136, 137, 138, 141, 142, 143, 146, 147, 150, + 151, 154, 155, 158, 159, 162, 163, 166, 167, 170, + 171, 172, 175, 176, 177, 178, 181, 188, 195, 202, + 211, 214, 217, 220, 223, 236, 244, 252, 259, 269, + 270, 273, 274, 275, 276, 277, 280, 281, 284, 295, + 307, 308, 309, 313, 317, 321, 321, 330, 335, 351, + 358, 374, 379, 386, 390, 390, 395, 396, 399, 402, + 403, 406, 410, 437, 438, 438, 441, 441, 444, 445, + 445 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "INT", "REAL", "STRING", "ANGDEGREE", + "ARCMINUTE", "ARCSECOND", "ANGRADIAN", "SEXSTR", "HMSSTR", "DMSSTR", + "EOF_", "ANNULUS_", "B1950_", "BOX_", "CIRCLE_", "DEBUG_", "ECLIPTIC_", + "ELLIPSE_", "EQUATORIAL_", "GALACTIC_", "J2000_", "LOGICAL_", "N_", + "OFF_", "ON_", "PHYSICAL_", "POINT_", "POLYGON_", "ROTBOX_", "VERSION_", + "'\\n'", "';'", "','", "'('", "')'", "'='", "'+'", "'-'", "'&'", "'!'", + "'#'", "$accept", "start", "commands", "command", "@1", "@2", + "terminator", "numeric", "debug", "sp", "bp", "ep", "optangle", "angle", + "value", "vvalue", "numberof", "sexagesimal", "hms", "dms", "coord", + "coordSystem", "skyFrame", "equatorial", "initGlobal", "initLocal", + "include", "shape", "@3", "@4", "polyNodes", "polyNode", "aRads", "aRad", + "processAnnulus", "comment", "@5", "generalComment", "@6", + "shapeComment", "@7", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 10, 59, 44, 40, 41, 61, 43, + 45, 38, 33, 35 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 44, 45, 46, 46, 47, 47, 47, 48, 47, + 49, 47, 47, 47, 50, 50, 50, 51, 51, 52, + 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, + 57, 57, 58, 58, 58, 58, 59, 59, 59, 59, + 60, 61, 62, 63, 64, 64, 64, 64, 64, 65, + 65, 66, 66, 66, 66, 66, 67, 67, 68, 69, + 70, 70, 70, 71, 71, 72, 71, 71, 71, 71, + 71, 71, 71, 71, 73, 71, 74, 74, 75, 76, + 76, 77, 78, 79, 80, 79, 82, 81, 83, 84, + 83 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 3, 3, 2, 0, 2, 1, 0, 3, + 0, 3, 3, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, + 3, 1, 1, 1, 3, 3, 3, 3, 3, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 7, 9, 0, 12, 11, 9, 18, + 9, 9, 18, 5, 0, 6, 3, 1, 1, 3, + 1, 1, 0, 0, 0, 3, 0, 3, 1, 0, + 4 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 58, 0, 59, 1, 52, 0, 55, 0, 54, 53, + 49, 50, 7, 86, 59, 0, 8, 10, 60, 13, + 20, 19, 6, 56, 57, 51, 0, 0, 2, 16, + 14, 15, 4, 83, 83, 61, 62, 0, 87, 3, + 84, 9, 11, 23, 23, 23, 23, 23, 74, 23, + 12, 0, 24, 0, 0, 0, 0, 0, 23, 0, + 85, 18, 17, 21, 41, 42, 43, 21, 21, 21, + 21, 21, 21, 21, 21, 25, 0, 21, 22, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 26, 82, + 78, 21, 77, 0, 48, 47, 44, 45, 46, 33, + 34, 35, 32, 21, 21, 21, 21, 21, 21, 25, + 21, 89, 88, 73, 0, 82, 21, 0, 0, 0, + 0, 0, 27, 82, 27, 0, 76, 75, 27, 21, + 37, 38, 39, 36, 30, 31, 29, 25, 28, 63, + 25, 82, 25, 65, 82, 82, 82, 90, 82, 0, + 25, 0, 64, 0, 70, 0, 68, 71, 0, 82, + 81, 21, 80, 0, 0, 40, 67, 0, 82, 23, + 23, 79, 66, 0, 0, 21, 21, 0, 0, 21, + 21, 27, 27, 25, 25, 72, 69 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 1, 14, 15, 33, 34, 32, 67, 22, 79, + 53, 89, 137, 138, 160, 108, 150, 68, 69, 70, + 90, 16, 17, 25, 2, 18, 37, 50, 151, 58, + 91, 92, 161, 162, 112, 41, 51, 19, 26, 113, + 125 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -92 +static const yytype_int16 yypact[] = +{ + -92, 2, 163, -92, -92, 17, -92, 19, -92, -92, + -92, -92, -92, -92, 132, 7, -92, -92, 6, -92, + -92, -92, -92, -92, -92, -92, 13, 7, -92, -92, + -92, -92, -92, -36, -36, -92, -92, 72, -92, -92, + -92, -92, -92, 12, 12, 12, 12, 12, -92, 12, + -92, 48, -92, 197, 197, 197, 197, 197, 12, 197, + -92, -92, -92, 32, -92, -92, -92, 32, 32, 32, + 32, 32, 32, 32, 32, 33, 197, 32, -92, 63, + 52, 65, 61, 61, 118, 207, 118, 207, -92, 40, + -92, 155, -92, 207, -92, -92, -92, -92, -92, -92, + -92, -92, -92, 32, 32, 32, 32, 32, 32, 33, + 32, -92, -92, -92, 197, 40, 32, 118, 90, 91, + 89, 52, 102, 40, 102, 105, -92, -92, 102, 155, + -92, -92, -92, -92, -92, -92, -92, 33, -92, -92, + 33, -92, 33, 82, 40, -19, -5, -92, 40, 74, + 33, 118, -92, 73, -92, 75, -92, -92, 115, 40, + -92, 155, -92, 107, 116, -92, -92, 118, 40, 12, + 12, -92, -92, 197, 197, 32, 32, 207, 207, 32, + 32, 102, 102, 33, 33, -92, -92 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -92, -92, -92, 121, -92, -92, 112, -8, -92, -42, + -41, -90, -91, -92, -63, -78, -92, 59, -92, -25, + -43, -92, -92, -92, -92, -92, -92, -92, -92, -92, + -92, 27, -92, -23, -14, 108, -92, -92, -92, -64, + -92 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -83 +static const yytype_int16 yytable[] = +{ + 28, 115, 3, 54, 55, 56, 57, 40, 59, 110, + 71, 72, 73, 74, 75, 116, 77, 76, 38, 123, + 29, 103, 153, 109, 111, 80, 81, 82, 83, 84, + 85, 86, 87, 140, 23, 93, 155, 142, 111, 144, + 30, 31, 24, 20, 21, 35, 36, 145, 52, 114, + 146, 127, 148, 60, 129, 61, 62, 97, 98, 139, + 159, 117, 118, 119, 120, 121, 122, 78, 124, 94, + 88, 168, 95, 66, 128, 64, 102, 107, 102, 107, + 152, 154, 156, 111, 157, 107, 43, 143, 44, 45, + 183, 184, 46, 185, 186, 166, 130, 132, 131, 179, + 180, 47, 48, 49, 172, 61, 62, 149, 134, 102, + 141, 135, 158, 133, 136, 163, 136, 164, 165, 167, + 136, 61, 62, 169, 99, 100, 101, 147, 173, 174, + 175, 176, -82, 177, 178, 27, 170, 181, 182, 39, + 96, 126, 42, 102, 171, -5, 0, 4, 0, 0, + 5, 6, 0, 7, 8, 9, 10, 0, 0, 102, + 11, 0, 0, 0, 12, -5, -5, 0, -25, 107, + 107, 0, 0, 136, 136, 13, -5, 0, 4, 0, + 0, 5, 6, 0, 7, 8, 9, 10, -25, -25, + 78, 11, 88, 0, 0, 12, -5, -5, -25, 0, + 61, 62, 0, 63, 0, 0, 13, 64, 65, 66, + 61, 62, 0, 104, 105, 106 +}; + +static const yytype_int16 yycheck[] = +{ + 14, 91, 0, 44, 45, 46, 47, 43, 49, 87, + 53, 54, 55, 56, 57, 93, 59, 58, 5, 109, + 13, 84, 41, 86, 43, 67, 68, 69, 70, 71, + 72, 73, 74, 124, 15, 77, 41, 128, 43, 129, + 33, 34, 23, 26, 27, 39, 40, 137, 36, 91, + 140, 115, 142, 5, 117, 3, 4, 82, 83, 123, + 150, 103, 104, 105, 106, 107, 108, 35, 110, 6, + 37, 161, 80, 12, 116, 10, 84, 85, 86, 87, + 144, 145, 146, 43, 148, 93, 14, 129, 16, 17, + 181, 182, 20, 183, 184, 159, 6, 8, 7, 177, + 178, 29, 30, 31, 168, 3, 4, 25, 6, 117, + 5, 9, 38, 121, 122, 42, 124, 42, 3, 161, + 128, 3, 4, 16, 6, 7, 8, 141, 169, 170, + 173, 174, 0, 175, 176, 14, 20, 179, 180, 27, + 81, 114, 34, 151, 167, 13, -1, 15, -1, -1, + 18, 19, -1, 21, 22, 23, 24, -1, -1, 167, + 28, -1, -1, -1, 32, 33, 34, -1, 13, 177, + 178, -1, -1, 181, 182, 43, 13, -1, 15, -1, + -1, 18, 19, -1, 21, 22, 23, 24, 33, 34, + 35, 28, 37, -1, -1, 32, 33, 34, 43, -1, + 3, 4, -1, 6, -1, -1, 43, 10, 11, 12, + 3, 4, -1, 6, 7, 8 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 45, 68, 0, 15, 18, 19, 21, 22, 23, + 24, 28, 32, 43, 46, 47, 65, 66, 69, 81, + 26, 27, 52, 15, 23, 67, 82, 47, 78, 13, + 33, 34, 50, 48, 49, 39, 40, 70, 5, 50, + 43, 79, 79, 14, 16, 17, 20, 29, 30, 31, + 71, 80, 36, 54, 54, 54, 54, 54, 73, 54, + 5, 3, 4, 6, 10, 11, 12, 51, 61, 62, + 63, 64, 64, 64, 64, 64, 54, 64, 35, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 37, 55, + 64, 74, 75, 53, 6, 51, 61, 63, 63, 6, + 7, 8, 51, 58, 6, 7, 8, 51, 59, 58, + 59, 43, 78, 83, 53, 55, 59, 53, 53, 53, + 53, 53, 53, 55, 53, 84, 75, 83, 53, 58, + 6, 7, 8, 51, 6, 9, 51, 56, 57, 83, + 56, 5, 56, 53, 55, 55, 55, 78, 55, 25, + 60, 72, 83, 41, 83, 41, 83, 83, 38, 55, + 58, 76, 77, 42, 42, 3, 83, 53, 55, 16, + 20, 77, 83, 54, 54, 64, 64, 53, 53, 59, + 59, 53, 53, 56, 56, 55, 55 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (fr, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, fr, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, prosFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + prosFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (fr); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, prosFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + prosFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Base* fr, prosFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, fr, ll) + YYSTYPE *yyvsp; + int yyrule; + Base* fr; + prosFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , fr, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, fr, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Base* fr, prosFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, fr, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + Base* fr; + prosFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (fr); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (Base* fr, prosFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (Base* fr, prosFlexLexer* ll) +#else +int +yyparse (fr, ll) + Base* fr; + prosFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 7: +#line 134 "frame/prosparser.Y" + {cerr << "PROS" << endl;;} + break; + + case 8: +#line 135 "frame/prosparser.Y" + {globalSystem = (Coord::CoordSystem)(yyvsp[(1) - (1)].integer);;} + break; + + case 10: +#line 136 "frame/prosparser.Y" + {globalSystem = Coord::WCS; globalSky = (Coord::SkyFrame)(yyvsp[(1) - (1)].integer);;} + break; + + case 16: +#line 143 "frame/prosparser.Y" + {YYACCEPT;;} + break; + + case 17: +#line 146 "frame/prosparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 18: +#line 147 "frame/prosparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].integer);;} + break; + + case 19: +#line 150 "frame/prosparser.Y" + {yydebug=1;;} + break; + + case 20: +#line 151 "frame/prosparser.Y" + {yydebug=0;;} + break; + + case 27: +#line 166 "frame/prosparser.Y" + {(yyval.real) = 0;;} + break; + + case 28: +#line 167 "frame/prosparser.Y" + {(yyval.real) = (yyvsp[(1) - (1)].real);;} + break; + + case 29: +#line 170 "frame/prosparser.Y" + {(yyval.real) = degToRad((yyvsp[(1) - (1)].real));;} + break; + + case 30: +#line 171 "frame/prosparser.Y" + {(yyval.real) = degToRad((yyvsp[(1) - (1)].real));;} + break; + + case 31: +#line 172 "frame/prosparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 32: +#line 175 "frame/prosparser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), Coord::IMAGE);;} + break; + + case 33: +#line 176 "frame/prosparser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), checkWCSSystem(), Coord::DEGREE);;} + break; + + case 34: +#line 177 "frame/prosparser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), checkWCSSystem(), Coord::ARCMIN);;} + break; + + case 35: +#line 178 "frame/prosparser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), checkWCSSystem(), Coord::ARCSEC);;} + break; + + case 36: +#line 182 "frame/prosparser.Y" + { + Vector r = FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::IMAGE); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 37: +#line 189 "frame/prosparser.Y" + { + Vector r=FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)),checkWCSSystem(),Coord::DEGREE); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 38: +#line 196 "frame/prosparser.Y" + { + Vector r=FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)),checkWCSSystem(),Coord::ARCMIN); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 39: +#line 203 "frame/prosparser.Y" + { + Vector r=FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)),checkWCSSystem(),Coord::ARCSEC); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 40: +#line 211 "frame/prosparser.Y" + {(yyval.integer) = (yyvsp[(3) - (3)].integer);;} + break; + + case 41: +#line 214 "frame/prosparser.Y" + {(yyval.real) = parseSEXStr((yyvsp[(1) - (1)].str));;} + break; + + case 42: +#line 217 "frame/prosparser.Y" + {(yyval.real) = parseHMSStr((yyvsp[(1) - (1)].str));;} + break; + + case 43: +#line 220 "frame/prosparser.Y" + {(yyval.real) = parseDMSStr((yyvsp[(1) - (1)].str));;} + break; + + case 44: +#line 224 "frame/prosparser.Y" + { + Vector r; + Coord::CoordSystem sys = checkWCSSystem(); + Coord::SkyFrame sky = checkWCSSky(); + if (sky == Coord::GALACTIC || sky == Coord::ECLIPTIC) + r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), sys, sky); + else + r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real)*360./24.,(yyvsp[(3) - (3)].real)), sys, sky); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 45: +#line 237 "frame/prosparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), + checkWCSSystem(), checkWCSSky()); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 46: +#line 245 "frame/prosparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), + checkWCSSystem(), checkWCSSky()); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 47: +#line 253 "frame/prosparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), localSystem, localSky); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 48: +#line 260 "frame/prosparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), + checkWCSSystem(), checkWCSSky()); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 49: +#line 269 "frame/prosparser.Y" + {(yyval.integer) = Coord::IMAGE;;} + break; + + case 50: +#line 270 "frame/prosparser.Y" + {(yyval.integer) = Coord::PHYSICAL;;} + break; + + case 51: +#line 273 "frame/prosparser.Y" + {(yyval.integer) = (yyvsp[(2) - (2)].integer);;} + break; + + case 52: +#line 274 "frame/prosparser.Y" + {(yyval.integer) = Coord::FK4;;} + break; + + case 53: +#line 275 "frame/prosparser.Y" + {(yyval.integer) = Coord::FK5;;} + break; + + case 54: +#line 276 "frame/prosparser.Y" + {(yyval.integer) = Coord::GALACTIC;;} + break; + + case 55: +#line 277 "frame/prosparser.Y" + {(yyval.integer) = Coord::ECLIPTIC;;} + break; + + case 56: +#line 280 "frame/prosparser.Y" + {(yyval.integer) = Coord::FK4;;} + break; + + case 57: +#line 281 "frame/prosparser.Y" + {(yyval.integer) = Coord::FK5;;} + break; + + case 58: +#line 284 "frame/prosparser.Y" + { + // global properties + globalSystem = Coord::IMAGE; + globalSky = Coord::FK5; + globalProps = + Marker::SELECT | Marker::EDIT | Marker::MOVE | + Marker::ROTATE | Marker::DELETE | Marker::HIGHLITE | + Marker::INCLUDE | Marker::SOURCE; + ;} + break; + + case 59: +#line 295 "frame/prosparser.Y" + { + // reset maperr flag + maperr =0; + + // global properties + localSystem = globalSystem; + localSky = globalSky; + localProps = globalProps; + strcpy(localComment,""); + ;} + break; + + case 60: +#line 307 "frame/prosparser.Y" + {setProps(&localProps, Marker::INCLUDE, 1);;} + break; + + case 61: +#line 308 "frame/prosparser.Y" + {setProps(&localProps, Marker::INCLUDE, 1);;} + break; + + case 62: +#line 309 "frame/prosparser.Y" + {setProps(&localProps, Marker::INCLUDE, 0);;} + break; + + case 63: +#line 314 "frame/prosparser.Y" + {fr->createCircleCmd(Vector((yyvsp[(3) - (7)].vector)), + (yyvsp[(5) - (7)].real), + color,dash,1,font,text,localProps,localComment,taglist,cblist);;} + break; + + case 64: +#line 318 "frame/prosparser.Y" + {fr->createAnnulusCmd(Vector((yyvsp[(3) - (9)].vector)), + (yyvsp[(5) - (9)].real),(yyvsp[(7) - (9)].real),1, + color,dash,1,font,text,localProps,localComment,taglist,cblist);;} + break; + + case 65: +#line 321 "frame/prosparser.Y" + {aNum=2;;} + break; + + case 66: +#line 323 "frame/prosparser.Y" + { + aAnnuli[0] = (yyvsp[(5) - (12)].real); + aAnnuli[1] = (yyvsp[(7) - (12)].real); + fr->createAnnulusCmd(Vector((yyvsp[(3) - (12)].vector)), + aNum,aAnnuli, + color,dash,1,font,text,localProps,localComment,taglist,cblist); + ;} + break; + + case 67: +#line 331 "frame/prosparser.Y" + {fr->createAnnulusCmd(Vector((yyvsp[(3) - (11)].vector)), + (yyvsp[(5) - (11)].real),(yyvsp[(7) - (11)].real),(yyvsp[(9) - (11)].integer), + color,dash,1,font,text,localProps,localComment,taglist,cblist);;} + break; + + case 68: +#line 336 "frame/prosparser.Y" + { + // for ellipse annulus + aStatus = 1; + aCenter = Vector((yyvsp[(3) - (9)].vector)); + aAngle = (yyvsp[(7) - (9)].real); + aVector[0] = Vector((yyvsp[(5) - (9)].vector)); + aNum = 1; + strncpy(aComment,localComment,80); + aProps = localProps; + + fr->createEllipseCmd(Vector((yyvsp[(3) - (9)].vector)), + Vector((yyvsp[(5) - (9)].vector)), + (yyvsp[(7) - (9)].real), + color,dash,1,font,text,localProps,localComment,taglist,cblist); + ;} + break; + + case 69: +#line 353 "frame/prosparser.Y" + { + aStatus = 2; + aVector[aNum++] = Vector((yyvsp[(5) - (18)].vector)); + ;} + break; + + case 70: +#line 359 "frame/prosparser.Y" + { + // for box annulus + aStatus = 3; + aCenter = Vector((yyvsp[(3) - (9)].vector)); + aAngle = (yyvsp[(7) - (9)].real); + aVector[0] = Vector((yyvsp[(5) - (9)].vector)); + aNum = 1; + strncpy(aComment,localComment,80); + aProps = localProps; + + fr->createBoxCmd(Vector((yyvsp[(3) - (9)].vector)), + Vector((yyvsp[(5) - (9)].vector)), + (yyvsp[(7) - (9)].real), + color,dash,1,font,text,localProps,localComment,taglist,cblist); + ;} + break; + + case 71: +#line 375 "frame/prosparser.Y" + {fr->createBoxCmd(Vector((yyvsp[(3) - (9)].vector)), + Vector((yyvsp[(5) - (9)].vector)), + (yyvsp[(7) - (9)].real), + color,dash,1,font,text,localProps,localComment,taglist,cblist);;} + break; + + case 72: +#line 381 "frame/prosparser.Y" + { + aStatus = 4; + aVector[aNum++] = Vector((yyvsp[(5) - (18)].vector)); + ;} + break; + + case 73: +#line 387 "frame/prosparser.Y" + {fr->createPointCmd(Vector((yyvsp[(3) - (5)].vector)), Point::BOXCIRCLE, POINTSIZE, + color,dash,1,font,text,localProps,localComment,taglist,cblist);;} + break; + + case 74: +#line 390 "frame/prosparser.Y" + {polylist.deleteAll();;} + break; + + case 75: +#line 391 "frame/prosparser.Y" + {fr->createPolygonCmd(polylist, + color,dash,1,font,text,localProps,localComment,taglist,cblist);;} + break; + + case 78: +#line 399 "frame/prosparser.Y" + {polylist.append(new Vertex((yyvsp[(1) - (1)].vector)));;} + break; + + case 81: +#line 406 "frame/prosparser.Y" + {aAnnuli[aNum++] = (yyvsp[(1) - (1)].real);;} + break; + + case 82: +#line 410 "frame/prosparser.Y" + { + switch (aStatus) { + case 0: // do nothing + break; + case 1: // we found just an ellipse, do nothing + break; + case 2: // ok we have an ellipse annulus + fr->markerDeleteLastCmd(); // delete the previous ellipse + fr->createEllipseAnnulusCmd(aCenter, + aNum,aVector, + aAngle, + color,dash,1,font,text,aProps,aComment,taglist,cblist); + break; + case 3: // we found just a box, do nothing + break; + case 4: // ok, we have a box annulus + fr->markerDeleteLastCmd(); // delete the previous box + fr->createBoxAnnulusCmd(aCenter, + aNum,aVector, + aAngle, + color,dash,1,font,text,aProps,aComment,taglist,cblist); + break; + } + aStatus = 0; + ;} + break; + + case 84: +#line 438 "frame/prosparser.Y" + {DISCARD_(1);;} + break; + + case 86: +#line 441 "frame/prosparser.Y" + {DISCARD_(1);;} + break; + + case 89: +#line 445 "frame/prosparser.Y" + {DISCARD_(0);;} + break; + + case 90: +#line 446 "frame/prosparser.Y" + {strncpy(localComment,(yyvsp[(3) - (4)].str),80);;} + break; + + +/* Line 1267 of yacc.c. */ +#line 2090 "frame/prosparser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (fr, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (fr, ll, yymsg); + } + else + { + yyerror (fr, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, fr, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, fr, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (fr, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, fr, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, fr, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 449 "frame/prosparser.Y" + + +static void setProps(unsigned short* props, unsigned short prop, int value) +{ + if (value) + *props |= prop; + else + *props &= ~prop; +} + +static Coord::CoordSystem checkWCSSystem() +{ + switch (localSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::WCS; + default: + return localSystem; + } +} + +static Coord::SkyFrame checkWCSSky() +{ + switch (localSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::FK5; + default: + return localSky; + } +} + diff --git a/tksao/frame/prosparser.H b/tksao/frame/prosparser.H new file mode 100644 index 0000000..91ffecb --- /dev/null +++ b/tksao/frame/prosparser.H @@ -0,0 +1,128 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + STRING = 260, + ANGDEGREE = 261, + ARCMINUTE = 262, + ARCSECOND = 263, + ANGRADIAN = 264, + SEXSTR = 265, + HMSSTR = 266, + DMSSTR = 267, + EOF_ = 268, + ANNULUS_ = 269, + B1950_ = 270, + BOX_ = 271, + CIRCLE_ = 272, + DEBUG_ = 273, + ECLIPTIC_ = 274, + ELLIPSE_ = 275, + EQUATORIAL_ = 276, + GALACTIC_ = 277, + J2000_ = 278, + LOGICAL_ = 279, + N_ = 280, + OFF_ = 281, + ON_ = 282, + PHYSICAL_ = 283, + POINT_ = 284, + POLYGON_ = 285, + ROTBOX_ = 286, + VERSION_ = 287 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define STRING 260 +#define ANGDEGREE 261 +#define ARCMINUTE 262 +#define ARCSECOND 263 +#define ANGRADIAN 264 +#define SEXSTR 265 +#define HMSSTR 266 +#define DMSSTR 267 +#define EOF_ 268 +#define ANNULUS_ 269 +#define B1950_ 270 +#define BOX_ 271 +#define CIRCLE_ 272 +#define DEBUG_ 273 +#define ECLIPTIC_ 274 +#define ELLIPSE_ 275 +#define EQUATORIAL_ 276 +#define GALACTIC_ 277 +#define J2000_ 278 +#define LOGICAL_ 279 +#define N_ 280 +#define OFF_ 281 +#define ON_ 282 +#define PHYSICAL_ 283 +#define POINT_ 284 +#define POLYGON_ 285 +#define ROTBOX_ 286 +#define VERSION_ 287 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 65 "frame/prosparser.Y" +{ +#define PROSBUFSIZE 2048 + double real; + int integer; + char str[PROSBUFSIZE]; + double vector[3]; +} +/* Line 1529 of yacc.c. */ +#line 121 "frame/prosparser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/frame/prosparser.Y b/tksao/frame/prosparser.Y new file mode 100644 index 0000000..26c62ef --- /dev/null +++ b/tksao/frame/prosparser.Y @@ -0,0 +1,479 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {Base* fr} +%lex-param {prosFlexLexer* ll} +%parse-param {prosFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#define FITSPTR (fr->findFits()) +#define DISCARD_(x) {yyclearin; prosDiscard(x);} + +#include +#include +#include + +#include "base.h" +#include "fitsimage.h" +#include "basemarker.h" + +#undef yyFlexLexer +#define yyFlexLexer prosFlexLexer +#include + +extern int proslex(void*, prosFlexLexer*); +extern void proserror(Base*, prosFlexLexer*, const char*); +extern void prosDiscard(int); + +static Coord::CoordSystem globalSystem; +static Coord::SkyFrame globalSky; +static Coord::CoordSystem localSystem; +static Coord::SkyFrame localSky; + +static unsigned short globalProps; +static unsigned short localProps; + +static const char *color = "green"; +static int dash[] ={8,3}; +static const char *font = "helvetica 10 normal roman"; +static const char *text = ""; + +static char localComment[80]; + +static List polylist; +static List taglist; +static List cblist; + +static double aAnnuli[MAXANNULI]; +static Vector aVector[MAXANNULI]; +static int aNum; +static int aStatus; +static Vector aCenter; +static double aAngle; +static unsigned short aProps; +static char aComment[80]; + +static void setProps(unsigned short* props, unsigned short prop, int value); +static Coord::CoordSystem checkWCSSystem(); +static Coord::SkyFrame checkWCSSky(); +%} + +%union { +#define PROSBUFSIZE 2048 + double real; + int integer; + char str[PROSBUFSIZE]; + double vector[3]; +} + +%type numeric + +%type angle +%type optangle +%type value +%type vvalue +%type sexagesimal +%type hms +%type dms +%type coord +%type coordSystem +%type skyFrame +%type equatorial +%type numberof + +%token INT +%token REAL +%token STRING + +%token ANGDEGREE +%token ARCMINUTE +%token ARCSECOND +%token ANGRADIAN + +%token SEXSTR +%token HMSSTR +%token DMSSTR + +%token EOF_ + +%token ANNULUS_ +%token B1950_ +%token BOX_ +%token CIRCLE_ +%token DEBUG_ +%token ECLIPTIC_ +%token ELLIPSE_ +%token EQUATORIAL_ +%token GALACTIC_ +%token J2000_ +%token LOGICAL_ +%token N_ +%token OFF_ +%token ON_ +%token PHYSICAL_ +%token POINT_ +%token POLYGON_ +%token ROTBOX_ +%token VERSION_ + +%% + +start : initGlobal commands processAnnulus + ; + +commands: commands command terminator + | command terminator + ; + +command : /* empty */ + | DEBUG_ debug + | VERSION_ {cerr << "PROS" << endl;} + | coordSystem {globalSystem = (Coord::CoordSystem)$1;} comment + | skyFrame {globalSystem = Coord::WCS; globalSky = (Coord::SkyFrame)$1;} comment + | initLocal include shape + | generalComment + ; + +terminator: '\n' + | ';' + | EOF_ {YYACCEPT;} + ; + +numeric : REAL {$$=$1;} + | INT {$$=$1;} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + ; + +sp : /* empty */ + | ',' + ; + +bp : /* empty */ + | '(' + ; + +ep : /* emtpy */ + | ')' + ; + +optangle: /* empty */ {$$ = 0;} + | angle {$$ = $1;} + ; + +angle : numeric {$$ = degToRad($1);} /* assume degree */ + | ANGDEGREE {$$ = degToRad($1);} + | ANGRADIAN {$$=$1;} + ; + +value : numeric {$$ = FITSPTR->mapLenToRef($1, Coord::IMAGE);} + | ANGDEGREE {$$ = FITSPTR->mapLenToRef($1, checkWCSSystem(), Coord::DEGREE);} + | ARCMINUTE {$$ = FITSPTR->mapLenToRef($1, checkWCSSystem(), Coord::ARCMIN);} + | ARCSECOND {$$ = FITSPTR->mapLenToRef($1, checkWCSSystem(), Coord::ARCSEC);} + ; + +vvalue : numeric sp numeric + { + Vector r = FITSPTR->mapLenToRef(Vector($1,$3), Coord::IMAGE); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | ANGDEGREE sp ANGDEGREE + { + Vector r=FITSPTR->mapLenToRef(Vector($1,$3),checkWCSSystem(),Coord::DEGREE); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | ARCMINUTE sp ARCMINUTE + { + Vector r=FITSPTR->mapLenToRef(Vector($1,$3),checkWCSSystem(),Coord::ARCMIN); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | ARCSECOND sp ARCSECOND + { + Vector r=FITSPTR->mapLenToRef(Vector($1,$3),checkWCSSystem(),Coord::ARCSEC); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + ; + +numberof: N_ '=' INT {$$ = $3;} + ; + +sexagesimal: SEXSTR {$$ = parseSEXStr($1);} + ; + +hms : HMSSTR {$$ = parseHMSStr($1);} + ; + +dms : DMSSTR {$$ = parseDMSStr($1);} + ; + +coord : sexagesimal sp sexagesimal + { + Vector r; + Coord::CoordSystem sys = checkWCSSystem(); + Coord::SkyFrame sky = checkWCSSky(); + if (sky == Coord::GALACTIC || sky == Coord::ECLIPTIC) + r = FITSPTR->mapToRef(Vector($1,$3), sys, sky); + else + r = FITSPTR->mapToRef(Vector($1*360./24.,$3), sys, sky); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | hms sp dms + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), + checkWCSSystem(), checkWCSSky()); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | dms sp dms + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), + checkWCSSystem(), checkWCSSky()); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | numeric sp numeric + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), localSystem, localSky); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | ANGDEGREE sp ANGDEGREE + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), + checkWCSSystem(), checkWCSSky()); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + ; + +coordSystem : LOGICAL_ {$$ = Coord::IMAGE;} + | PHYSICAL_ {$$ = Coord::PHYSICAL;} + ; + +skyFrame : EQUATORIAL_ equatorial {$$ = $2;} + | B1950_ {$$ = Coord::FK4;} + | J2000_ {$$ = Coord::FK5;} + | GALACTIC_ {$$ = Coord::GALACTIC;} + | ECLIPTIC_ {$$ = Coord::ECLIPTIC;} + ; + +equatorial : B1950_ {$$ = Coord::FK4;} + | J2000_ {$$ = Coord::FK5;} + ; + +initGlobal:{ + // global properties + globalSystem = Coord::IMAGE; + globalSky = Coord::FK5; + globalProps = + Marker::SELECT | Marker::EDIT | Marker::MOVE | + Marker::ROTATE | Marker::DELETE | Marker::HIGHLITE | + Marker::INCLUDE | Marker::SOURCE; + } + ; + +initLocal : { + // reset maperr flag + maperr =0; + + // global properties + localSystem = globalSystem; + localSky = globalSky; + localProps = globalProps; + strcpy(localComment,""); + } + ; + +include : /* empty */ {setProps(&localProps, Marker::INCLUDE, 1);} + | '+' {setProps(&localProps, Marker::INCLUDE, 1);} + | '-' {setProps(&localProps, Marker::INCLUDE, 0);} + ; + +shape : + CIRCLE_ bp coord sp value ep shapeComment + {fr->createCircleCmd(Vector($3), + $5, + color,dash,1,font,text,localProps,localComment,taglist,cblist);} + | ANNULUS_ bp coord sp value sp value ep shapeComment + {fr->createAnnulusCmd(Vector($3), + $5,$7,1, + color,dash,1,font,text,localProps,localComment,taglist,cblist);} + | ANNULUS_ bp coord sp value sp value sp {aNum=2;} aRads ep + shapeComment + { + aAnnuli[0] = $5; + aAnnuli[1] = $7; + fr->createAnnulusCmd(Vector($3), + aNum,aAnnuli, + color,dash,1,font,text,localProps,localComment,taglist,cblist); + } + | ANNULUS_ bp coord sp value sp value sp numberof ep shapeComment + {fr->createAnnulusCmd(Vector($3), + $5,$7,$9, + color,dash,1,font,text,localProps,localComment,taglist,cblist);} + + | ELLIPSE_ bp coord sp vvalue sp optangle ep shapeComment + { + // for ellipse annulus + aStatus = 1; + aCenter = Vector($3); + aAngle = $7; + aVector[0] = Vector($5); + aNum = 1; + strncpy(aComment,localComment,80); + aProps = localProps; + + fr->createEllipseCmd(Vector($3), + Vector($5), + $7, + color,dash,1,font,text,localProps,localComment,taglist,cblist); + } + | ELLIPSE_ bp coord sp vvalue sp optangle ep '&' '!' + ELLIPSE_ bp coord sp vvalue sp optangle ep + { + aStatus = 2; + aVector[aNum++] = Vector($5); + } + + | BOX_ bp coord sp vvalue sp optangle ep shapeComment + { + // for box annulus + aStatus = 3; + aCenter = Vector($3); + aAngle = $7; + aVector[0] = Vector($5); + aNum = 1; + strncpy(aComment,localComment,80); + aProps = localProps; + + fr->createBoxCmd(Vector($3), + Vector($5), + $7, + color,dash,1,font,text,localProps,localComment,taglist,cblist); + } + | ROTBOX_ bp coord sp vvalue sp optangle ep shapeComment + {fr->createBoxCmd(Vector($3), + Vector($5), + $7, + color,dash,1,font,text,localProps,localComment,taglist,cblist);} + | BOX_ bp coord sp vvalue sp optangle ep '&' '!' + BOX_ bp coord sp vvalue sp optangle ep + { + aStatus = 4; + aVector[aNum++] = Vector($5); + } + + | POINT_ bp coord ep shapeComment + {fr->createPointCmd(Vector($3), Point::BOXCIRCLE, POINTSIZE, + color,dash,1,font,text,localProps,localComment,taglist,cblist);} + + | POLYGON_ {polylist.deleteAll();} bp polyNodes ep shapeComment + {fr->createPolygonCmd(polylist, + color,dash,1,font,text,localProps,localComment,taglist,cblist);} + ; + +polyNodes : polyNodes sp polyNode + | polyNode + ; + +polyNode : coord {polylist.append(new Vertex($1));} + ; + +aRads : aRads sp aRad + | aRad + ; + +aRad : value {aAnnuli[aNum++] = $1;} + ; + +processAnnulus : /* empty */ + { + switch (aStatus) { + case 0: // do nothing + break; + case 1: // we found just an ellipse, do nothing + break; + case 2: // ok we have an ellipse annulus + fr->markerDeleteLastCmd(); // delete the previous ellipse + fr->createEllipseAnnulusCmd(aCenter, + aNum,aVector, + aAngle, + color,dash,1,font,text,aProps,aComment,taglist,cblist); + break; + case 3: // we found just a box, do nothing + break; + case 4: // ok, we have a box annulus + fr->markerDeleteLastCmd(); // delete the previous box + fr->createBoxAnnulusCmd(aCenter, + aNum,aVector, + aAngle, + color,dash,1,font,text,aProps,aComment,taglist,cblist); + break; + } + aStatus = 0; + } + ; + +comment : /* empty */ + | '#' {DISCARD_(1);} STRING + ; + +generalComment : '#' {DISCARD_(1);} STRING + ; + +shapeComment : /* empty */ processAnnulus + | '#' {DISCARD_(0);} STRING processAnnulus + {strncpy(localComment,$3,80);} + ; + +%% + +static void setProps(unsigned short* props, unsigned short prop, int value) +{ + if (value) + *props |= prop; + else + *props &= ~prop; +} + +static Coord::CoordSystem checkWCSSystem() +{ + switch (localSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::WCS; + default: + return localSystem; + } +} + +static Coord::SkyFrame checkWCSSky() +{ + switch (localSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::FK5; + default: + return localSky; + } +} diff --git a/tksao/frame/raytrace.C b/tksao/frame/raytrace.C new file mode 100644 index 0000000..1028406 --- /dev/null +++ b/tksao/frame/raytrace.C @@ -0,0 +1,53 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "raytrace.h" + +RayTrace::RayTrace() +{ + az_ =0; + el_ =0; + width_ =0; + height_ =0; + zbuf_ =NULL; + mkzbuf_ =NULL; + + next_ =NULL; + previous_ =NULL; +} + +RayTrace::RayTrace(double az, double el, int width, int height, + Matrix3d mm, BBox3d bb) +{ + az_ = az; + el_ = el; + width_ = width; + height_ = height; + mm_ = mm; + bb_ = bb; + + zbuf_ = new float[width_*height_]; + if (!zbuf_) + return; + memset(zbuf_, 0, width_*height_*sizeof(float)); + + mkzbuf_ = new unsigned char[width_*height_]; + if (!mkzbuf_) + return; + memset(mkzbuf_, 0, width_*height_); + + next_ =NULL; + previous_ =NULL; +} + +RayTrace::~RayTrace() +{ + if (zbuf_) + delete [] zbuf_; + if (mkzbuf_) + delete [] mkzbuf_; +} + diff --git a/tksao/frame/raytrace.h b/tksao/frame/raytrace.h new file mode 100644 index 0000000..2c5430a --- /dev/null +++ b/tksao/frame/raytrace.h @@ -0,0 +1,36 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __raytrace_h__ +#define __raytrace_h__ + +#include "list.h" +#include "vector3d.h" + +class RayTrace { + public: + double az_; + double el_; + int width_; + int height_; + Matrix3d mm_; + BBox3d bb_; + float* zbuf_; + unsigned char* mkzbuf_; + + RayTrace* next_; + RayTrace* previous_; + + public: + RayTrace(); + RayTrace(double, double, int, int, Matrix3d, BBox3d); + ~RayTrace(); + + RayTrace* previous() {return previous_;} + void setPrevious(RayTrace* r) {previous_ = r;} + RayTrace* next() {return next_;} + void setNext(RayTrace* r) {next_ = r;} +}; + +#endif diff --git a/tksao/frame/ruler.C b/tksao/frame/ruler.C new file mode 100644 index 0000000..047f746 --- /dev/null +++ b/tksao/frame/ruler.C @@ -0,0 +1,544 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "ruler.h" +#include "fitsimage.h" + +Ruler::Ruler(const Ruler& a) : BaseLine(a) +{ + p3 = a.p3; + coordSystem = a.coordSystem; + skyFrame = a.skyFrame; + distSystem = a.distSystem; + distDist = a.distDist; + dist = a.dist; +} + +Ruler::Ruler(Base* p, const Vector& ptr1, const Vector& ptr2, + Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::CoordSystem distsys, Coord::SkyDist distfor, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BaseLine(p, ptr1, ptr2, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + coordSystem = sys; + skyFrame = sky; + distSystem = distsys; + distDist = distfor; + dist = 0; + + strcpy(type_,"ruler"); + handle = new Vector[2]; + numHandle = 2; + + updateBBox(); +} + +void Ruler::renderX(Drawable drawable, Coord::InternalSystem sys, RenderMode mode) +{ + GC lgc = renderXGC(mode); + + Vector aa = parent->mapFromRef(p1,sys); + Vector bb = parent->mapFromRef(p2,sys); + Vector cc = parent->mapFromRef(p3,sys); + Vector dd = modifyArrow(p2,p1,sys); + Vector ee = modifyArrow(p1,p2,sys); + + // line + XDrawLine(display, drawable, lgc, dd[0], dd[1], ee[0], ee[1]); + renderXArrow(drawable, p2, p1, sys, lgc); + renderXArrow(drawable, p1, p2, sys, lgc); + + // axes + renderXLineDash(lgc); + XDrawLine(display, drawable, lgc, aa[0], aa[1], cc[0], cc[1]); + XDrawLine(display, drawable, lgc, bb[0], bb[1], cc[0], cc[1]); + + // dist + ostringstream str; + distToStr(str); + str << ends; + + if (tkfont_) { + XSetFont(display, lgc, Tk_FontId(tkfont_)); + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(tkfont_, &metrics); + char* buf = dupstr(str.str().c_str()); + int width = Tk_TextWidth(tkfont_, buf, strlen(buf)); + + Vector tt = ((bb-aa)/2+aa) * Translate(-width/2.,-metrics.descent); + Tk_DrawChars(display, drawable, lgc, tkfont_, buf, strlen(buf), + tt[0], tt[1]); + if (buf) + delete [] buf; + } +} + +GC Ruler::renderXGC(RenderMode mode) +{ + // set width, color, dash + switch (mode) { + case SRC: + XSetForeground(display, gc, color); + renderXLineNoDash(gc); + return gc; + + case XOR: + renderXLineDash(gcxor); + return gcxor; + } + + // so compiler will not complain + return gc; +} + +void Ruler::renderPS(int mode) +{ + renderPSGC(mode); + + Vector aa = parent->mapFromRef(p1,Coord::CANVAS); + Vector bb = parent->mapFromRef(p2,Coord::CANVAS); + Vector cc = parent->mapFromRef(p3,Coord::CANVAS); + Vector dd = modifyArrow(p2,p1,Coord::CANVAS); + Vector ee = modifyArrow(p1,p2,Coord::CANVAS); + + // line + { + ostringstream str; + str << "newpath " + << dd.TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << ee.TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + renderPSArrow(p2,p1,Coord::CANVAS); + renderPSArrow(p1,p2,Coord::CANVAS); + } + + // axes + renderPSLineDash(); + { + ostringstream str; + str << "newpath " + << aa.TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << cc.TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl + << "newpath " + << bb.TkCanvasPs(parent->canvas) << ' ' + << "moveto " + << cc.TkCanvasPs(parent->canvas) << ' ' + << "lineto stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } + + + // dist + if (psfont_) { + ostringstream vstr; + ostringstream str; + + const char* ff = Tk_NameOfFont(psfont_); + str << '/' << psFontName(ff) + << " findfont " << int(psFontSize(ff)*parent->getDisplayRatio()) + << " scalefont setfont" << endl; + + distToStr(vstr); + vstr << ends; + char* buf = dupstr(vstr.str().c_str()); + Vector tt = ((bb-aa)/2 + aa).TkCanvasPs(parent->canvas); + str << "gsave" << endl + << "newpath " << endl + << tt << " moveto" << endl + << '(' << psQuote(buf) << ')' << endl + << "dup true charpath pathbbox " << endl + << "closepath " << endl + << "3 -1 roll sub 2.5 div " << endl + << "3 1 roll sub 2 div exch " << endl + << tt << " moveto rmoveto show " << endl + << "grestore" << endl; + + str << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + if (buf) + delete buf; + } +} + +void Ruler::renderPSGC(int mode) +{ + renderPSColor(mode, parent->getXColor(colorName)); + renderPSLineNoDash(); +} + +#ifdef MAC_OSX_TK +void Ruler::renderMACOSX() +{ + renderMACOSXGC(); + + Vector aa = parent->mapFromRef(p1,Coord::CANVAS); + Vector bb = parent->mapFromRef(p2,Coord::CANVAS); + Vector cc = parent->mapFromRef(p3,Coord::CANVAS); + Vector dd = modifyArrow(p2,p1,Coord::CANVAS); + Vector ee = modifyArrow(p1,p2,Coord::CANVAS); + + // line + macosxDrawLine(dd,ee); + renderMACOSXArrow(p2,p1,Coord::CANVAS); + renderMACOSXArrow(p1,p2,Coord::CANVAS); + + // axes + renderMACOSXLineDash(); + macosxDrawLine(aa,cc); + macosxDrawLine(bb,cc); + + // dist + { + ostringstream vstr; + distToStr(vstr); + vstr << ends; + + if (psfont_) { + Tcl_DString psdstr; + Tcl_DStringInit(&psdstr); + int psSize = Tk_PostscriptFontName(psfont_, &psdstr); + macosxFont(Tcl_DStringValue(&psdstr), psSize); + Tcl_DStringFree(&psdstr); + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(psfont_, &metrics); + char* buf = dupstr(vstr.str().c_str()); + int width = Tk_TextWidth(psfont_, buf, strlen(buf)); + + Vector tt = ((bb-aa)/2 + aa) * Translate(-width/2., -metrics.descent); + macosxDrawText(tt, 0, buf); + if (buf) + delete buf; + } + } +} + +void Ruler::renderMACOSXGC() +{ + macosxColor(parent->getXColor(colorName)); + renderMACOSXLineNoDash(); +} +#endif + +// WIN32 +#ifdef __WIN32 +void Ruler::renderWIN32() +{ + renderWIN32GC(); + + Vector aa = parent->mapFromRef(p1,Coord::CANVAS); + Vector bb = parent->mapFromRef(p2,Coord::CANVAS); + Vector cc = parent->mapFromRef(p3,Coord::CANVAS); + Vector dd = modifyArrow(p2,p1,Coord::CANVAS); + Vector ee = modifyArrow(p1,p2,Coord::CANVAS); + + // line + win32DrawLine(dd,ee); + renderWIN32Arrow(p2,p1,Coord::CANVAS); + renderWIN32Arrow(p1,p2,Coord::CANVAS); + + // axes + renderWIN32LineDash(); + win32DrawLine(aa,cc); + win32DrawLine(bb,cc); + + // dist + { + ostringstream vstr; + distToStr(vstr); + vstr << ends; + + if (tkfont_) { + win32Font(tkfont_); + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(tkfont_, &metrics); + char* buf = dupstr(vstr.str().c_str()); + int width = Tk_TextWidth(tkfont_, buf, strlen(buf)); + + Vector tt = ((bb-aa)/2 + aa) * Translate(-width/2., -metrics.descent); + win32DrawText(tt, 0, buf); + if (buf) + delete buf; + } + } +} + +void Ruler::renderWIN32GC() +{ + win32Color(parent->getXColor(colorName)); + renderWIN32LineNoDash(); +} +#endif + +// Support + +void Ruler::updateHandles() +{ + center = (p2-p1)/2 + p1; + angle = (p2-p1).angle(); + + // calc p3, dist + FitsImage* ptr = parent->findFits(coordSystem,center); + Vector a = ptr->mapFromRef(p1,coordSystem,skyFrame); + Vector b = ptr->mapFromRef(p2,coordSystem,skyFrame); + p3 = ptr->mapToRef(Vector(b[0],a[1]),coordSystem,skyFrame); + dist = ptr->mapDistFromRef(p2, p1, distSystem, distDist); + + // generate handles in canvas coords + handle[0] = parent->mapFromRef(p1,Coord::CANVAS); + handle[1] = parent->mapFromRef(p2,Coord::CANVAS); +} + +void Ruler::calcAllBBox() +{ + // P3 + bbox.bound(parent->mapFromRef(p3,Coord::CANVAS)); + + // make room for text + if (tkfont_) { + Vector v = (p2-p1)/2 + p1; + + ostringstream str; + distToStr(str); + str << ends; + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(tkfont_, &metrics); + char* buf = dupstr(str.str().c_str()); + int width = Tk_TextWidth(tkfont_, buf, strlen(buf)); + + Vector ll = parent->mapFromRef(v,Coord::CANVAS) * + Translate(-width/2.,-metrics.descent); + Vector ur = parent->mapFromRef(v,Coord::CANVAS) * + Translate(width/2.,metrics.ascent); + + bbox.bound(ll); + bbox.bound(ur); + + if (buf) + delete [] buf; + } + + Marker::calcAllBBox(); +} + +void Ruler::updateCoords(const Matrix& mx) +{ + p3*=mx; + BaseLine::updateCoords(mx); +} + +int Ruler::isOn(const Vector& v, const Vector& v1, const Vector& v2) +{ + // v : canvas coords + // v1: ref coords + // v2: ref coords + + // do this in canvas coords, not ref coords + + Vector l1 = parent->mapFromRef(v1,Coord::CANVAS); + Vector l2 = parent->mapFromRef(v2,Coord::CANVAS); + double a = (l2-l1).angle(); + + Matrix m = Translate(-l1) * Rotate(a); + Vector end = l2*m; + Vector vv = v*m; + return (vv[0]>0 && vv[0]-parent->markerEpsilon && vv[1]markerEpsilon); +} + +int Ruler::isIn(const Vector& vv) +{ + // test to see if point is on edge, if so, considered inside + + if (isOn(vv,p1,p2) || isOn(vv,p1,p3) || isOn(vv,p2,p3)) + return 1; + + /* + v[0]-- x value of point being tested + v[1]-- y value of point being tested + + This algorithm is from "An Introduction to Ray Tracing", Academic Press, + 1989, edited by Andrew Glassner, pg 53 + -- a point lies in a polygon if a line is extended from the point to + infinite + in any direction and the number of intersections with the polygon is odd. + This is valid for both concave and convex polygons. + Points on a vertex are considered inside. + Points on a edge are considered inside. + */ + + // analysis in ref coords + Vector v = parent->mapToRef(vv,Coord::CANVAS); + + int crossings = 0; // number of crossings + int sign; + + // for all edges + + for (int i=0; i<3; i++) { + Vector v1, v2; + switch (i) { + case 0: + v1 = p1-v; + v2 = p2-v; + sign = ((v1[1])>=0) ? 1 : -1; // init sign + break; + case 1: + v1 = p2-v; + v2 = p3-v; + break; + case 2: + v1 = p3-v; + v2 = p1-v; + break; + } + + int nextSign = (v2[1]>=0) ? 1 : -1; // sign holder for p2 + + if (sign != nextSign) { + if (v1[0]>0 && v2[0]>0) + crossings++; + else if (v1[0]>0 || v2[0]>0) { + if (v1[0]-(v1[1]*(v2[0]-v1[0])/(v2[1]-v1[1])) > 0) + crossings++; + } + sign = nextSign; + } + } + + return fmod(float(crossings),float(2)) ? 1 : 0; // if odd, point is inside +} + +void Ruler::setCoordSystem(Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::CoordSystem dsys, Coord::SkyDist dist) +{ + coordSystem = sys; + skyFrame = sky; + distSystem = dsys; + distDist = dist; + updateBBox(); +} + +void Ruler::distToStr(ostringstream& str) +{ + switch (distSystem) { + case Coord::IMAGE: + str << dist << " img"; + break; + case Coord::PHYSICAL: + str << dist << " phy"; + break; + case Coord::AMPLIFIER: + str << dist << " amp"; + break; + case Coord::DETECTOR: + str << dist << " det"; + break; + default: + if (parent->findFits()->hasWCSCel(distSystem)) + switch (distDist) { + case Coord::DEGREE: + str << dist << " deg"; + break; + case Coord::ARCMIN: + str << dist << '\''; + break; + case Coord::ARCSEC: + str << dist << '"'; + break; + } + else + str << dist << " lin"; + } +} + +// list + +void Ruler::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + if (!strip) { + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 1); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listNonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector v1 = ptr->mapFromRef(p1,sys,sky); + Vector v2 = ptr->mapFromRef(p2,sys,sky); + str << type_ << '(' << setprecision(10) << v1 << ',' << v2 << ')'; + } + break; + case Coord::SEXAGESIMAL: + str << type_ << '('; + listRADEC(ptr,p1,sys,sky,format); + str << ra << ',' << dec << ','; + listRADEC(ptr,p2,sys,sky,format); + str << ra << ',' << dec << ')'; + break; + } + } + else + listNonCel(ptr, str, sys); + } + + if (conj) + str << " ||"; + + str << " ruler="; + coord.listCoordSystem(str, coordSystem, skyFrame, ptr); + str << ' '; + coord.listDistSystem(str, distSystem, distDist, ptr); + listProperties(str, 0); + } +} + +void Ruler::listXML(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + FitsImage* ptr = parent->findFits(sys,center); + Vector vv[2]; + vv[0] = p1; + vv[1] = p2; + + ostringstream sysstr; + coord.listCoordSystem(sysstr, coordSystem, skyFrame, ptr); + sysstr << ends; + + ostringstream diststr; + coord.listDistSystem(diststr, distSystem, distDist, ptr); + diststr << ends; + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowPoint(ptr,sys,sky,format,vv,2); + XMLRow(XMLPARAM,(char*)(sysstr.str().c_str())); + XMLRow(XMLPARAM2,(char*)(diststr.str().c_str())); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} + diff --git a/tksao/frame/ruler.h b/tksao/frame/ruler.h new file mode 100644 index 0000000..5eeb511 --- /dev/null +++ b/tksao/frame/ruler.h @@ -0,0 +1,73 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __ruler_h__ +#define __ruler_h__ + +#include "baseline.h" + +class Ruler : public BaseLine { +private: + Vector p3; + Coord::CoordSystem coordSystem; + Coord::SkyFrame skyFrame; + Coord::CoordSystem distSystem; + Coord::SkyDist distDist; + double dist; + +private: + void renderX(Drawable, Coord::InternalSystem, RenderMode); + GC renderXGC(RenderMode); + + void renderPS(int); + void renderPSGC(int); + +#ifdef MAC_OSX_TK + void renderMACOSX(); + void renderMACOSXGC(); +#endif + +#ifdef __WIN32 + void renderWIN32(); + void renderWIN32GC(); +#endif + + void updateHandles(); + void calcAllBBox(); + + int isOn(const Vector&, const Vector&, const Vector&); + void distToStr(ostringstream&); + +public: + Ruler(const Ruler&); + Ruler(Base* p, const Vector& ptr1, const Vector& ptr2, + Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::CoordSystem distsys, Coord::SkyDist distfor, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + + Marker* dup() {return new Ruler(*this);} + + void updateCoords(const Matrix&); + + int isIn(const Vector&); + + const Vector& getP1() {return p1;} + const Vector& getP2() {return p2;} + const Vector& getP3() {return p3;} + void setCoordSystem(Coord::CoordSystem, Coord::SkyFrame, Coord::CoordSystem, Coord::SkyDist); + + Coord::CoordSystem getSystem() {return coordSystem;} + Coord::SkyFrame getSkyFrame() {return skyFrame;} + + Coord::CoordSystem getDistSystem() {return distSystem;} + Coord::SkyDist getDistDist() {return distDist;} + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); +}; + +#endif diff --git a/tksao/frame/saolex.C b/tksao/frame/saolex.C new file mode 100644 index 0000000..4e80cf2 --- /dev/null +++ b/tksao/frame/saolex.C @@ -0,0 +1,1803 @@ +#line 2 "frame/saolex.C" + +#line 4 "frame/saolex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer saoFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *saoalloc (yy_size_t ); +void *saorealloc (void *,yy_size_t ); +void saofree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 27 +#define YY_END_OF_BUFFER 28 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[101] = + { 0, + 0, 0, 2, 2, 28, 26, 22, 25, 26, 26, + 26, 26, 26, 15, 21, 21, 21, 21, 21, 21, + 8, 21, 21, 21, 21, 26, 26, 2, 1, 22, + 23, 0, 18, 0, 19, 0, 15, 17, 16, 15, + 21, 21, 21, 21, 21, 21, 21, 21, 10, 21, + 21, 21, 24, 0, 20, 2, 0, 0, 0, 16, + 21, 4, 21, 21, 21, 9, 21, 21, 21, 21, + 16, 0, 17, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 6, 21, 11, 21, 21, 21, 21, + 5, 21, 21, 13, 21, 3, 7, 12, 14, 0 + + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 5, 1, 1, 1, 1, 6, 1, + 1, 1, 7, 1, 7, 8, 1, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 1, 1, 1, + 1, 1, 1, 1, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 17, 17, 19, 17, 20, 21, 22, + 17, 23, 24, 25, 26, 27, 17, 28, 29, 17, + 1, 30, 1, 1, 1, 1, 31, 32, 33, 34, + + 35, 36, 37, 17, 38, 17, 17, 39, 17, 40, + 41, 42, 17, 43, 44, 45, 46, 47, 17, 48, + 49, 17, 50, 1, 51, 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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[52] = + { 0, + 1, 1, 2, 1, 1, 1, 1, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, + 1 + } ; + +static yyconst flex_int16_t yy_base[107] = + { 0, + 0, 0, 252, 246, 248, 266, 245, 266, 243, 240, + 236, 44, 232, 46, 48, 49, 51, 50, 53, 232, + 230, 58, 54, 55, 66, 47, 186, 0, 266, 233, + 266, 229, 266, 226, 266, 222, 91, 68, 77, 99, + 221, 102, 96, 89, 98, 107, 106, 112, 220, 111, + 115, 120, 266, 176, 266, 0, 115, 124, 217, 75, + 127, 213, 134, 130, 136, 203, 139, 143, 150, 144, + 199, 195, 192, 147, 156, 154, 161, 169, 173, 157, + 179, 176, 185, 182, 172, 163, 192, 177, 198, 199, + 149, 201, 204, 124, 210, 94, 85, 71, 63, 266, + + 250, 253, 256, 62, 259, 262 + } ; + +static yyconst flex_int16_t yy_def[107] = + { 0, + 100, 1, 101, 101, 100, 100, 100, 100, 100, 102, + 103, 100, 100, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 100, 105, 106, 100, 100, + 100, 102, 100, 103, 100, 100, 100, 100, 100, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 100, 105, 100, 106, 100, 100, 100, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 100, 100, 100, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 0, + + 100, 100, 100, 100, 100, 100 + } ; + +static yyconst flex_int16_t yy_nxt[318] = + { 0, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 20, 20, 20, 20, 21, + 22, 23, 24, 20, 20, 20, 25, 20, 20, 26, + 15, 16, 17, 18, 19, 20, 20, 20, 20, 21, + 22, 23, 24, 20, 20, 20, 25, 20, 20, 27, + 6, 36, 37, 39, 40, 100, 100, 100, 100, 42, + 100, 100, 100, 46, 41, 100, 53, 43, 45, 44, + 100, 47, 48, 100, 50, 51, 38, 49, 100, 52, + 42, 58, 100, 60, 46, 38, 53, 43, 45, 44, + 57, 47, 100, 48, 50, 51, 100, 49, 39, 37, + + 52, 100, 58, 100, 57, 100, 39, 40, 59, 100, + 60, 57, 42, 100, 100, 61, 62, 64, 100, 100, + 63, 59, 100, 71, 65, 57, 66, 100, 67, 68, + 72, 100, 73, 42, 100, 61, 62, 100, 64, 69, + 63, 100, 70, 100, 65, 75, 100, 66, 67, 68, + 100, 100, 74, 77, 100, 76, 100, 100, 78, 69, + 80, 100, 70, 100, 100, 82, 75, 81, 100, 84, + 100, 79, 74, 77, 83, 76, 100, 88, 78, 100, + 100, 80, 85, 100, 100, 82, 100, 81, 87, 100, + 84, 79, 100, 86, 83, 92, 89, 88, 91, 100, + + 73, 90, 85, 73, 94, 100, 100, 71, 100, 87, + 100, 100, 93, 86, 97, 92, 89, 100, 95, 91, + 100, 90, 96, 98, 94, 71, 55, 100, 100, 99, + 38, 35, 93, 33, 30, 97, 55, 100, 95, 100, + 38, 35, 96, 98, 33, 31, 30, 100, 29, 99, + 28, 28, 28, 32, 29, 32, 34, 100, 34, 54, + 100, 54, 56, 100, 56, 5, 100, 100, 100, 100, + 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, + + 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, 100, 100 + } ; + +static yyconst flex_int16_t yy_chk[318] = + { 0, + 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, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 12, 12, 14, 14, 15, 16, 18, 17, 14, + 19, 23, 24, 18, 104, 22, 26, 15, 17, 16, + 99, 19, 22, 25, 23, 24, 38, 22, 98, 25, + 14, 38, 60, 60, 18, 39, 26, 15, 17, 16, + 39, 19, 97, 22, 23, 24, 44, 22, 37, 37, + + 25, 96, 38, 43, 37, 45, 40, 40, 42, 42, + 42, 39, 40, 47, 46, 43, 44, 46, 50, 48, + 45, 57, 51, 57, 47, 37, 48, 52, 50, 50, + 58, 94, 58, 40, 61, 43, 44, 64, 46, 51, + 45, 63, 52, 65, 47, 63, 67, 48, 50, 50, + 68, 70, 61, 65, 74, 64, 91, 69, 67, 51, + 69, 76, 52, 75, 80, 74, 63, 70, 77, 76, + 86, 68, 61, 65, 75, 64, 78, 80, 67, 85, + 79, 69, 77, 82, 88, 74, 81, 70, 79, 84, + 76, 68, 83, 78, 75, 85, 81, 80, 83, 87, + + 73, 82, 77, 72, 88, 89, 90, 71, 92, 79, + 66, 93, 87, 78, 92, 85, 81, 95, 89, 83, + 62, 82, 90, 93, 88, 59, 54, 49, 41, 95, + 36, 34, 87, 32, 30, 92, 27, 21, 89, 20, + 13, 11, 90, 93, 10, 9, 7, 5, 4, 95, + 101, 101, 101, 102, 3, 102, 103, 0, 103, 105, + 0, 105, 106, 0, 106, 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, + + 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, 100, 100 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "frame/saolex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 12 "frame/saolex.L" + #include + #include + #include + + #include "util.h" + #include "saoparser.H" + + extern YYSTYPE* saolval; + extern saoFlexLexer* saolexx; + +/* rules */ +#line 528 "frame/saolex.C" + +#define INITIAL 0 +#define DISCARD 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 30 "frame/saolex.L" + + +#line 632 "frame/saolex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 101 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 100 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +#line 32 "frame/saolex.L" +{ // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(saolval->str,""); // feed a blank string + return STRING; + } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 39 "frame/saolex.L" +{ // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(SAOBUFSIZE-1) ? yyleng:(SAOBUFSIZE-1); + strncpy(saolval->str,yytext,ll); + saolval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 47 "frame/saolex.L" +{return ANNULUS_;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 48 "frame/saolex.L" +{return BOX_;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 49 "frame/saolex.L" +{return CIRCLE_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 50 "frame/saolex.L" +{return DEBUG_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 51 "frame/saolex.L" +{return ELLIPSE_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 52 "frame/saolex.L" +{return N_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 53 "frame/saolex.L" +{return OFF_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 54 "frame/saolex.L" +{return ON_;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 55 "frame/saolex.L" +{return POINT_;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 56 "frame/saolex.L" +{return POLYGON_;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 57 "frame/saolex.L" +{return ROTBOX_;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 58 "frame/saolex.L" +{return VERSION_;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 60 "frame/saolex.L" +{ // Integer + saolval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 16: +#line 66 "frame/saolex.L" +case 17: +YY_RULE_SETUP +#line 66 "frame/saolex.L" +{ // Real Number + saolval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 18: +#line 72 "frame/saolex.L" +case 19: +YY_RULE_SETUP +#line 72 "frame/saolex.L" +{ // Quoted String + int ll = (yyleng-2)<(SAOBUFSIZE-1)?(yyleng-2):(SAOBUFSIZE-1); + strncpy(saolval->str,yytext+1,ll); // skip the " " + saolval->str[ll] = '\0'; // Remove the '"' + return STRING; + } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 79 "frame/saolex.L" +{ // Quoted String + int ll = (yyleng-2)<(SAOBUFSIZE-1)?(yyleng-2):(SAOBUFSIZE-1); + strncpy(saolval->str,yytext+1,ll); // skip the '{' + saolval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 86 "frame/saolex.L" +{ // General String + int ll = yyleng <(SAOBUFSIZE-1) ? yyleng:(SAOBUFSIZE-1); + strncpy(saolval->str,yytext,ll); + saolval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 93 "frame/saolex.L" +{ // White Spaces + } + YY_BREAK +case 23: +/* rule 23 can match eol */ +YY_RULE_SETUP +#line 96 "frame/saolex.L" +{ // windows line feed + return '\n'; + } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 100 "frame/saolex.L" +{ // fake line feed + return '\n'; + } + YY_BREAK +case 25: +/* rule 25 can match eol */ +YY_RULE_SETUP +#line 104 "frame/saolex.L" +{ // linefeed + return '\n'; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(DISCARD): +#line 108 "frame/saolex.L" +{ // eof + return EOF_; + } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 112 "frame/saolex.L" +{ // Else, return the char + return yytext[0]; + } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 116 "frame/saolex.L" +ECHO; + YY_BREAK +#line 891 "frame/saolex.C" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + saofree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + saofree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + saorealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) saorealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 101 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 101 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 100); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) saoalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) saoalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + saofree((void *) b->yy_ch_buf ); + + saofree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)saoalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)saorealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) saoalloc(new_size ); + + else + (yy_start_stack) = (int *) saorealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *saoalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *saorealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void saofree (void * ptr ) +{ + free( (char *) ptr ); /* see saorealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 116 "frame/saolex.L" + + + +void saoDiscard(int doit) +{ + if (saolexx) + saolexx->begin(DISCARD, doit); +} + +void saoFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} + diff --git a/tksao/frame/saolex.L b/tksao/frame/saolex.L new file mode 100644 index 0000000..d9e320c --- /dev/null +++ b/tksao/frame/saolex.L @@ -0,0 +1,129 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ + +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + + #include "util.h" + #include "saoparser.H" + + extern YYSTYPE* saolval; + extern saoFlexLexer* saolexx; +%} + +%x DISCARD + +D [0-9] +E [Ee][+-]?{D}+ + +/* rules */ + +%% + +[\n] { // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(saolval->str,""); // feed a blank string + return STRING; + } + +[^\n]* { // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(SAOBUFSIZE-1) ? yyleng:(SAOBUFSIZE-1); + strncpy(saolval->str,yytext,ll); + saolval->str[ll] = '\0'; + return STRING; + } + +annulus {return ANNULUS_;} +box {return BOX_;} +circle {return CIRCLE_;} +debug {return DEBUG_;} +ellipse {return ELLIPSE_;} +n {return N_;} +off {return OFF_;} +on {return ON_;} +point {return POINT_;} +polygon {return POLYGON_;} +rotbox {return ROTBOX_;} +version {return VERSION_;} + +[+-]?{D}+ { // Integer + saolval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + saolval->real = atof(yytext); + return REAL; + } + +\"[^\"\n]*\" | +\'[^\'\n]*\' { // Quoted String + int ll = (yyleng-2)<(SAOBUFSIZE-1)?(yyleng-2):(SAOBUFSIZE-1); + strncpy(saolval->str,yytext+1,ll); // skip the " " + saolval->str[ll] = '\0'; // Remove the '"' + return STRING; + } + +\{[^\}\n]*\} { // Quoted String + int ll = (yyleng-2)<(SAOBUFSIZE-1)?(yyleng-2):(SAOBUFSIZE-1); + strncpy(saolval->str,yytext+1,ll); // skip the '{' + saolval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + +[0-9A-Za-z]+ { // General String + int ll = yyleng <(SAOBUFSIZE-1) ? yyleng:(SAOBUFSIZE-1); + strncpy(saolval->str,yytext,ll); + saolval->str[ll] = '\0'; + return STRING; + } + +[ \t]+ { // White Spaces + } + +\r\n { // windows line feed + return '\n'; + } + +\\n { // fake line feed + return '\n'; + } + +\n { // linefeed + return '\n'; + } + +<> { // eof + return EOF_; + } + +. { // Else, return the char + return yytext[0]; + } + +%% + +void saoDiscard(int doit) +{ + if (saolexx) + saolexx->begin(DISCARD, doit); +} + +void saoFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} diff --git a/tksao/frame/saoparser.C b/tksao/frame/saoparser.C new file mode 100644 index 0000000..d8f1158 --- /dev/null +++ b/tksao/frame/saoparser.C @@ -0,0 +1,2036 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse saoparse +#define yylex saolex +#define yyerror saoerror +#define yylval saolval +#define yychar saochar +#define yydebug saodebug +#define yynerrs saonerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + STRING = 260, + EOF_ = 261, + ANNULUS_ = 262, + BOX_ = 263, + CIRCLE_ = 264, + DEBUG_ = 265, + ELLIPSE_ = 266, + N_ = 267, + OFF_ = 268, + ON_ = 269, + POINT_ = 270, + POLYGON_ = 271, + ROTBOX_ = 272, + VERSION_ = 273 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define STRING 260 +#define EOF_ 261 +#define ANNULUS_ 262 +#define BOX_ 263 +#define CIRCLE_ 264 +#define DEBUG_ 265 +#define ELLIPSE_ 266 +#define N_ 267 +#define OFF_ 268 +#define ON_ 269 +#define POINT_ 270 +#define POLYGON_ 271 +#define ROTBOX_ 272 +#define VERSION_ 273 + + + + +/* Copy the first part of user declarations. */ +#line 10 "frame/saoparser.Y" + +#define YYDEBUG 1 + +#define FITSPTR (fr->findFits()) +#define DISCARD_(x) {yyclearin; saoDiscard(x);} + +#include +#include +#include + +#include "base.h" +#include "fitsimage.h" +#include "basemarker.h" + +#undef yyFlexLexer +#define yyFlexLexer saoFlexLexer +#include + +extern int saolex(void*, saoFlexLexer*); +extern void saoerror(Base*, saoFlexLexer*, const char*); +extern void saoDiscard(int); + +static unsigned short globalProps; +static unsigned short localProps; + +static const char *color = "green"; +static int dash[] = {8,3}; +static const char *font = "helvetica 10 normal roman"; +static const char *text = ""; + +static char localComment[80]; + +static List polylist; +static List taglist; +static List cblist; + +static double aAnnuli[MAXANNULI]; +static Vector aVector[MAXANNULI]; +static int aNum; +static int aStatus; +static Vector aCenter; +static double aAngle; +static unsigned short aProps; +static char aComment[80]; + +static void setProps(unsigned short* props, unsigned short prop, int value); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 59 "frame/saoparser.Y" +{ +#define SAOBUFSIZE 2048 + double real; + int integer; + char str[SAOBUFSIZE]; + double vector[3]; +} +/* Line 193 of yacc.c. */ +#line 197 "frame/saoparser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 210 "frame/saoparser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 160 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 30 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 31 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 59 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 139 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 273 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 19, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 28, 2, 29, 2, 2, 27, 2, + 22, 23, 2, 25, 21, 26, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 20, + 2, 24, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 7, 11, 14, 15, 18, 20, 24, + 26, 28, 30, 32, 34, 36, 38, 40, 41, 43, + 44, 46, 47, 49, 50, 52, 54, 56, 60, 64, + 68, 69, 70, 71, 73, 75, 83, 93, 94, 107, + 119, 129, 148, 158, 168, 187, 193, 194, 201, 205, + 207, 209, 213, 215, 217, 218, 219, 223, 225, 226 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 31, 0, -1, 46, 32, 56, -1, 32, 33, 34, + -1, 33, 34, -1, -1, 10, 36, -1, 18, -1, + 47, 48, 49, -1, 57, -1, 19, -1, 20, -1, + 6, -1, 4, -1, 3, -1, 14, -1, 13, -1, + -1, 21, -1, -1, 22, -1, -1, 23, -1, -1, + 41, -1, 35, -1, 35, -1, 35, 37, 35, -1, + 12, 24, 3, -1, 35, 37, 35, -1, -1, -1, + -1, 25, -1, 26, -1, 9, 38, 45, 37, 42, + 39, 59, -1, 7, 38, 45, 37, 42, 37, 42, + 39, 59, -1, -1, 7, 38, 45, 37, 42, 37, + 42, 37, 50, 54, 39, 59, -1, 7, 38, 45, + 37, 42, 37, 42, 37, 44, 39, 59, -1, 11, + 38, 45, 37, 43, 37, 40, 39, 59, -1, 11, + 38, 45, 37, 43, 37, 40, 39, 27, 28, 11, + 38, 45, 37, 43, 37, 40, 39, -1, 8, 38, + 45, 37, 43, 37, 40, 39, 59, -1, 17, 38, + 45, 37, 43, 37, 40, 39, 59, -1, 8, 38, + 45, 37, 43, 37, 40, 39, 27, 28, 8, 38, + 45, 37, 43, 37, 40, 39, -1, 15, 38, 45, + 39, 59, -1, -1, 16, 51, 38, 52, 39, 59, + -1, 52, 37, 53, -1, 53, -1, 45, -1, 54, + 37, 55, -1, 55, -1, 42, -1, -1, -1, 29, + 58, 5, -1, 56, -1, -1, 29, 60, 5, 56, + -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 97, 97, 100, 101, 104, 105, 106, 107, 108, + 111, 112, 113, 116, 117, 120, 121, 124, 125, 128, + 129, 132, 133, 136, 137, 140, 143, 146, 155, 158, + 167, 175, 183, 184, 185, 188, 192, 196, 196, 205, + 211, 227, 234, 250, 255, 262, 266, 266, 271, 272, + 275, 278, 279, 282, 286, 313, 313, 316, 317, 317 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "INT", "REAL", "STRING", "EOF_", + "ANNULUS_", "BOX_", "CIRCLE_", "DEBUG_", "ELLIPSE_", "N_", "OFF_", "ON_", + "POINT_", "POLYGON_", "ROTBOX_", "VERSION_", "'\\n'", "';'", "','", + "'('", "')'", "'='", "'+'", "'-'", "'&'", "'!'", "'#'", "$accept", + "start", "commands", "command", "terminator", "numeric", "debug", "sp", + "bp", "ep", "optangle", "angle", "value", "vvalue", "numberof", "coord", + "initGlobal", "initLocal", "include", "shape", "@1", "@2", "polyNodes", + "polyNode", "aRads", "aRad", "processAnnulus", "generalComment", "@3", + "shapeComment", "@4", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 10, + 59, 44, 40, 41, 61, 43, 45, 38, 33, 35 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 30, 31, 32, 32, 33, 33, 33, 33, 33, + 34, 34, 34, 35, 35, 36, 36, 37, 37, 38, + 38, 39, 39, 40, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 48, 48, 49, 49, 50, 49, 49, + 49, 49, 49, 49, 49, 49, 51, 49, 52, 52, + 53, 54, 54, 55, 56, 58, 57, 59, 60, 59 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 3, 3, 2, 0, 2, 1, 3, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 1, 1, 3, 3, 3, + 0, 0, 0, 1, 1, 7, 9, 0, 12, 11, + 9, 18, 9, 9, 18, 5, 0, 6, 3, 1, + 1, 3, 1, 1, 0, 0, 3, 1, 0, 4 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 30, 0, 31, 1, 0, 7, 55, 31, 0, 32, + 9, 16, 15, 6, 0, 0, 2, 12, 10, 11, + 4, 33, 34, 0, 56, 3, 19, 19, 19, 19, + 19, 46, 19, 8, 20, 0, 0, 0, 0, 0, + 19, 0, 14, 13, 17, 17, 17, 17, 17, 21, + 0, 17, 18, 0, 0, 0, 0, 0, 22, 54, + 50, 21, 49, 0, 29, 26, 17, 17, 17, 21, + 17, 58, 57, 45, 0, 54, 17, 0, 0, 23, + 54, 23, 0, 48, 47, 23, 21, 27, 25, 21, + 24, 35, 21, 54, 21, 37, 54, 54, 54, 59, + 54, 0, 21, 0, 36, 0, 42, 0, 40, 43, + 0, 54, 53, 21, 52, 0, 0, 28, 39, 0, + 54, 19, 19, 51, 38, 0, 0, 17, 17, 0, + 0, 17, 17, 23, 23, 21, 21, 44, 41 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 1, 7, 8, 20, 44, 13, 53, 35, 59, + 89, 90, 112, 68, 102, 60, 2, 9, 23, 33, + 103, 40, 61, 62, 113, 114, 72, 10, 14, 73, + 82 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -71 +static const yytype_int16 yypact[] = +{ + -71, 21, 119, -71, 11, -71, -71, 116, 16, 31, + -71, -71, -71, -71, 22, 16, -71, -71, -71, -71, + -71, -71, -71, 135, -71, -71, 9, 9, 9, 9, + 9, -71, 9, -71, -71, 69, 69, 69, 69, 69, + 9, 69, -71, -71, 20, 20, 20, 20, 20, 26, + 69, 20, -71, 69, 69, 69, 69, 69, -71, 33, + -71, 56, -71, 69, -71, -71, 20, 20, 20, 26, + 20, -71, -71, -71, 69, 33, 20, 69, 69, 69, + 33, 69, 61, -71, -71, 69, 137, -71, -71, 26, + -71, -71, 26, -71, 26, 58, 33, -1, 3, -71, + 33, 52, 26, 69, -71, 50, -71, 53, -71, -71, + 79, 33, -71, 56, -71, 75, 73, -71, -71, 69, + 33, 9, 9, -71, -71, 69, 69, 20, 20, 69, + 69, 20, 20, 69, 69, 26, 26, -71, -71 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -71, -71, -71, 80, 71, -10, -71, -28, -27, 19, + -70, -71, -40, -2, -71, -29, -71, -71, -71, -71, + -71, -71, -71, 15, -71, -21, -3, -71, -71, -46, + -71 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -55 +static const yytype_int16 yytable[] = +{ + 36, 37, 38, 39, 16, 41, 45, 46, 47, 48, + 49, 92, 51, 50, 66, 94, 69, 54, 55, 56, + 57, 3, 17, 63, 11, 12, 105, 24, 71, 84, + 107, 34, 71, 74, 91, 18, 19, 86, 77, 78, + 79, 52, 81, 64, 65, 67, 65, 67, 85, 58, + 104, 106, 108, 67, 109, 70, 21, 22, 95, -17, + -17, 76, 71, 135, 136, 118, 93, 65, 87, 88, + 101, 88, 42, 43, 124, 88, 110, 52, 115, 58, + 75, 116, 117, 121, 122, 119, 25, 15, 80, 83, + 99, 0, 0, 65, 125, 126, 127, 128, 123, 129, + 130, 0, 0, 133, 134, 96, 0, 0, 97, 65, + 0, 98, 0, 100, 0, 0, -54, 0, 0, 67, + 67, 111, -5, 88, 88, -5, 4, 131, 132, 4, + 0, 0, 120, 0, 5, -5, -5, 5, -5, -5, + -17, -17, 26, 27, 28, 6, 29, 0, 6, -17, + 30, 31, 32, 0, 137, 138, 0, 0, 52, 0, + 58 +}; + +static const yytype_int16 yycheck[] = +{ + 27, 28, 29, 30, 7, 32, 35, 36, 37, 38, + 39, 81, 41, 40, 54, 85, 56, 45, 46, 47, + 48, 0, 6, 51, 13, 14, 27, 5, 29, 75, + 27, 22, 29, 61, 80, 19, 20, 77, 66, 67, + 68, 21, 70, 53, 54, 55, 56, 57, 76, 23, + 96, 97, 98, 63, 100, 57, 25, 26, 86, 3, + 4, 63, 29, 133, 134, 111, 5, 77, 78, 79, + 12, 81, 3, 4, 120, 85, 24, 21, 28, 23, + 61, 28, 3, 8, 11, 113, 15, 7, 69, 74, + 93, -1, -1, 103, 121, 122, 125, 126, 119, 127, + 128, -1, -1, 131, 132, 86, -1, -1, 89, 119, + -1, 92, -1, 94, -1, -1, 0, -1, -1, 129, + 130, 102, 6, 133, 134, 6, 10, 129, 130, 10, + -1, -1, 113, -1, 18, 19, 20, 18, 19, 20, + 3, 4, 7, 8, 9, 29, 11, -1, 29, 12, + 15, 16, 17, -1, 135, 136, -1, -1, 21, -1, + 23 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 31, 46, 0, 10, 18, 29, 32, 33, 47, + 57, 13, 14, 36, 58, 33, 56, 6, 19, 20, + 34, 25, 26, 48, 5, 34, 7, 8, 9, 11, + 15, 16, 17, 49, 22, 38, 38, 38, 38, 38, + 51, 38, 3, 4, 35, 45, 45, 45, 45, 45, + 38, 45, 21, 37, 37, 37, 37, 37, 23, 39, + 45, 52, 53, 37, 35, 35, 42, 35, 43, 42, + 43, 29, 56, 59, 37, 39, 43, 37, 37, 37, + 39, 37, 60, 53, 59, 37, 42, 35, 35, 40, + 41, 59, 40, 5, 40, 37, 39, 39, 39, 56, + 39, 12, 44, 50, 59, 27, 59, 27, 59, 59, + 24, 39, 42, 54, 55, 28, 28, 3, 59, 37, + 39, 8, 11, 55, 59, 38, 38, 45, 45, 37, + 37, 43, 43, 37, 37, 40, 40, 39, 39 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (fr, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, fr, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, saoFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + saoFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (fr); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, saoFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + saoFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Base* fr, saoFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, fr, ll) + YYSTYPE *yyvsp; + int yyrule; + Base* fr; + saoFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , fr, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, fr, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Base* fr, saoFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, fr, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + Base* fr; + saoFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (fr); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (Base* fr, saoFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (Base* fr, saoFlexLexer* ll) +#else +int +yyparse (fr, ll) + Base* fr; + saoFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 7: +#line 106 "frame/saoparser.Y" + {cerr << "SAOimage" << endl;;} + break; + + case 12: +#line 113 "frame/saoparser.Y" + {YYACCEPT;;} + break; + + case 13: +#line 116 "frame/saoparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 14: +#line 117 "frame/saoparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].integer);;} + break; + + case 15: +#line 120 "frame/saoparser.Y" + {yydebug=1;;} + break; + + case 16: +#line 121 "frame/saoparser.Y" + {yydebug=0;;} + break; + + case 23: +#line 136 "frame/saoparser.Y" + {(yyval.real) = 0;;} + break; + + case 24: +#line 137 "frame/saoparser.Y" + {(yyval.real) = (yyvsp[(1) - (1)].real);;} + break; + + case 25: +#line 140 "frame/saoparser.Y" + {(yyval.real) = degToRad((yyvsp[(1) - (1)].real));;} + break; + + case 26: +#line 143 "frame/saoparser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real), Coord::IMAGE);;} + break; + + case 27: +#line 147 "frame/saoparser.Y" + { + Vector r = FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::IMAGE); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 28: +#line 155 "frame/saoparser.Y" + {(yyval.integer) = (yyvsp[(3) - (3)].integer);;} + break; + + case 29: +#line 159 "frame/saoparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::IMAGE); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 30: +#line 167 "frame/saoparser.Y" + { + globalProps = + Marker::SELECT | Marker::EDIT | Marker::MOVE | + Marker::ROTATE | Marker::DELETE | Marker::HIGHLITE | + Marker::INCLUDE | Marker::SOURCE; + ;} + break; + + case 31: +#line 175 "frame/saoparser.Y" + { + // reset maperr flag + maperr =0; + + localProps = globalProps; + ;} + break; + + case 32: +#line 183 "frame/saoparser.Y" + {setProps(&localProps, Marker::INCLUDE, 1);;} + break; + + case 33: +#line 184 "frame/saoparser.Y" + {setProps(&localProps, Marker::INCLUDE, 1);;} + break; + + case 34: +#line 185 "frame/saoparser.Y" + {setProps(&localProps, Marker::INCLUDE, 0);;} + break; + + case 35: +#line 189 "frame/saoparser.Y" + {fr->createCircleCmd(Vector((yyvsp[(3) - (7)].vector)), + (yyvsp[(5) - (7)].real), + color,dash,1,font,text,localProps,localComment,taglist,cblist);;} + break; + + case 36: +#line 193 "frame/saoparser.Y" + {fr->createAnnulusCmd(Vector((yyvsp[(3) - (9)].vector)), + (yyvsp[(5) - (9)].real),(yyvsp[(7) - (9)].real),1, + color,dash,1,font,text,localProps,localComment,taglist,cblist);;} + break; + + case 37: +#line 196 "frame/saoparser.Y" + {aNum=2;;} + break; + + case 38: +#line 198 "frame/saoparser.Y" + { + aAnnuli[0] = (yyvsp[(5) - (12)].real); + aAnnuli[1] = (yyvsp[(7) - (12)].real); + fr->createAnnulusCmd(Vector((yyvsp[(3) - (12)].vector)), + aNum,aAnnuli, + color,dash,1,font,text,localProps,localComment,taglist,cblist); + ;} + break; + + case 39: +#line 206 "frame/saoparser.Y" + {fr->createAnnulusCmd(Vector((yyvsp[(3) - (11)].vector)), + (yyvsp[(5) - (11)].real),(yyvsp[(7) - (11)].real),(yyvsp[(9) - (11)].integer), + color,dash,1,font,text,localProps,localComment,taglist,cblist);;} + break; + + case 40: +#line 212 "frame/saoparser.Y" + { + // for ellipse annulus + aStatus = 1; + aCenter = Vector((yyvsp[(3) - (9)].vector)); + aAngle = (yyvsp[(7) - (9)].real); + aVector[0] = Vector((yyvsp[(5) - (9)].vector)); + aNum = 1; + strncpy(aComment,localComment,80); + aProps = localProps; + + fr->createEllipseCmd(Vector((yyvsp[(3) - (9)].vector)), + Vector((yyvsp[(5) - (9)].vector)), + (yyvsp[(7) - (9)].real), + color,dash,1,font,text,localProps,localComment,taglist,cblist); + ;} + break; + + case 41: +#line 229 "frame/saoparser.Y" + { + aStatus = 2; + aVector[aNum++] = Vector((yyvsp[(5) - (18)].vector)); + ;} + break; + + case 42: +#line 235 "frame/saoparser.Y" + { + // for box annulus + aStatus = 3; + aCenter = Vector((yyvsp[(3) - (9)].vector)); + aAngle = (yyvsp[(7) - (9)].real); + aVector[0] = Vector((yyvsp[(5) - (9)].vector)); + aNum = 1; + strncpy(aComment,localComment,80); + aProps = localProps; + + fr->createBoxCmd(Vector((yyvsp[(3) - (9)].vector)), + Vector((yyvsp[(5) - (9)].vector)), + (yyvsp[(7) - (9)].real), + color,dash,1,font,text,localProps,localComment,taglist,cblist); + ;} + break; + + case 43: +#line 251 "frame/saoparser.Y" + {fr->createBoxCmd(Vector((yyvsp[(3) - (9)].vector)), + Vector((yyvsp[(5) - (9)].vector)), + (yyvsp[(7) - (9)].real), + color,dash,1,font,text,localProps,localComment,taglist,cblist);;} + break; + + case 44: +#line 257 "frame/saoparser.Y" + { + aStatus = 4; + aVector[aNum++] = Vector((yyvsp[(5) - (18)].vector)); + ;} + break; + + case 45: +#line 263 "frame/saoparser.Y" + {fr->createPointCmd(Vector((yyvsp[(3) - (5)].vector)), Point::BOXCIRCLE, POINTSIZE, + color,dash,1,font,text,localProps,localComment,taglist,cblist);;} + break; + + case 46: +#line 266 "frame/saoparser.Y" + {polylist.deleteAll();;} + break; + + case 47: +#line 267 "frame/saoparser.Y" + {fr->createPolygonCmd(polylist, + color,dash,1,font,text,localProps,localComment,taglist,cblist);;} + break; + + case 50: +#line 275 "frame/saoparser.Y" + {polylist.append(new Vertex((yyvsp[(1) - (1)].vector)));;} + break; + + case 53: +#line 282 "frame/saoparser.Y" + {aAnnuli[aNum++] = (yyvsp[(1) - (1)].real);;} + break; + + case 54: +#line 286 "frame/saoparser.Y" + { + switch (aStatus) { + case 0: // do nothing + break; + case 1: // we found just an ellipse, do nothing + break; + case 2: // ok we have an ellipse annulus + fr->markerDeleteLastCmd(); // delete the previous ellipse + fr->createEllipseAnnulusCmd(aCenter, + aNum,aVector, + aAngle, + color,dash,1,font,text,aProps,aComment,taglist,cblist); + break; + case 3: // we found just a box, do nothing + break; + case 4: // ok, we have a box annulus + fr->markerDeleteLastCmd(); // delete the previous box + fr->createBoxAnnulusCmd(aCenter, + aNum,aVector, + aAngle, + color,dash,1,font,text,aProps,aComment,taglist,cblist); + break; + } + aStatus = 0; + ;} + break; + + case 55: +#line 313 "frame/saoparser.Y" + {DISCARD_(1);;} + break; + + case 58: +#line 317 "frame/saoparser.Y" + {DISCARD_(0);;} + break; + + case 59: +#line 318 "frame/saoparser.Y" + {strncpy(localComment,(yyvsp[(3) - (4)].str),80);;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1813 "frame/saoparser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (fr, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (fr, ll, yymsg); + } + else + { + yyerror (fr, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, fr, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, fr, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (fr, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, fr, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, fr, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 321 "frame/saoparser.Y" + + +static void setProps(unsigned short* props, unsigned short prop, int value) +{ + if (value) + *props |= prop; + else + *props &= ~prop; +} + diff --git a/tksao/frame/saoparser.H b/tksao/frame/saoparser.H new file mode 100644 index 0000000..b3fcf10 --- /dev/null +++ b/tksao/frame/saoparser.H @@ -0,0 +1,100 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + STRING = 260, + EOF_ = 261, + ANNULUS_ = 262, + BOX_ = 263, + CIRCLE_ = 264, + DEBUG_ = 265, + ELLIPSE_ = 266, + N_ = 267, + OFF_ = 268, + ON_ = 269, + POINT_ = 270, + POLYGON_ = 271, + ROTBOX_ = 272, + VERSION_ = 273 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define STRING 260 +#define EOF_ 261 +#define ANNULUS_ 262 +#define BOX_ 263 +#define CIRCLE_ 264 +#define DEBUG_ 265 +#define ELLIPSE_ 266 +#define N_ 267 +#define OFF_ 268 +#define ON_ 269 +#define POINT_ 270 +#define POLYGON_ 271 +#define ROTBOX_ 272 +#define VERSION_ 273 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 59 "frame/saoparser.Y" +{ +#define SAOBUFSIZE 2048 + double real; + int integer; + char str[SAOBUFSIZE]; + double vector[3]; +} +/* Line 1529 of yacc.c. */ +#line 93 "frame/saoparser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/frame/saoparser.Y b/tksao/frame/saoparser.Y new file mode 100644 index 0000000..6440ea6 --- /dev/null +++ b/tksao/frame/saoparser.Y @@ -0,0 +1,329 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {Base* fr} +%lex-param {saoFlexLexer* ll} +%parse-param {saoFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#define FITSPTR (fr->findFits()) +#define DISCARD_(x) {yyclearin; saoDiscard(x);} + +#include +#include +#include + +#include "base.h" +#include "fitsimage.h" +#include "basemarker.h" + +#undef yyFlexLexer +#define yyFlexLexer saoFlexLexer +#include + +extern int saolex(void*, saoFlexLexer*); +extern void saoerror(Base*, saoFlexLexer*, const char*); +extern void saoDiscard(int); + +static unsigned short globalProps; +static unsigned short localProps; + +static const char *color = "green"; +static int dash[] = {8,3}; +static const char *font = "helvetica 10 normal roman"; +static const char *text = ""; + +static char localComment[80]; + +static List polylist; +static List taglist; +static List cblist; + +static double aAnnuli[MAXANNULI]; +static Vector aVector[MAXANNULI]; +static int aNum; +static int aStatus; +static Vector aCenter; +static double aAngle; +static unsigned short aProps; +static char aComment[80]; + +static void setProps(unsigned short* props, unsigned short prop, int value); + +%} + +%union { +#define SAOBUFSIZE 2048 + double real; + int integer; + char str[SAOBUFSIZE]; + double vector[3]; +} + +%type numeric + +%type angle +%type optangle +%type value +%type vvalue +%type coord +%type numberof + +%token INT +%token REAL +%token STRING + +%token EOF_ + +%token ANNULUS_ +%token BOX_ +%token CIRCLE_ +%token DEBUG_ +%token ELLIPSE_ +%token N_ +%token OFF_ +%token ON_ +%token POINT_ +%token POLYGON_ +%token ROTBOX_ +%token VERSION_ + +%% + +start : initGlobal commands processAnnulus + ; + +commands: commands command terminator + | command terminator + ; + +command : /* empty */ + | DEBUG_ debug + | VERSION_ {cerr << "SAOimage" << endl;} + | initLocal include shape + | generalComment + ; + +terminator: '\n' + | ';' + | EOF_ {YYACCEPT;} + ; + +numeric : REAL {$$=$1;} + | INT {$$=$1;} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + ; + +sp : /* empty */ + | ',' + ; + +bp : /* empty */ + | '(' + ; + +ep : /* emtpy */ + | ')' + ; + +optangle: /* empty */ {$$ = 0;} + | angle {$$ = $1;} + ; + +angle : numeric {$$ = degToRad($1);} /* assume degree */ + ; + +value : numeric {$$ = FITSPTR->mapLenToRef($1, Coord::IMAGE);} + ; + +vvalue : numeric sp numeric + { + Vector r = FITSPTR->mapLenToRef(Vector($1,$3), Coord::IMAGE); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + ; + +numberof: N_ '=' INT {$$ = $3;} + ; + +coord : numeric sp numeric + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), Coord::IMAGE); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + ; + +initGlobal:{ + globalProps = + Marker::SELECT | Marker::EDIT | Marker::MOVE | + Marker::ROTATE | Marker::DELETE | Marker::HIGHLITE | + Marker::INCLUDE | Marker::SOURCE; + } + ; + +initLocal : { + // reset maperr flag + maperr =0; + + localProps = globalProps; + } + ; + +include : /* empty */ {setProps(&localProps, Marker::INCLUDE, 1);} + | '+' {setProps(&localProps, Marker::INCLUDE, 1);} + | '-' {setProps(&localProps, Marker::INCLUDE, 0);} + ; + +shape : CIRCLE_ bp coord sp value ep shapeComment + {fr->createCircleCmd(Vector($3), + $5, + color,dash,1,font,text,localProps,localComment,taglist,cblist);} + | ANNULUS_ bp coord sp value sp value ep shapeComment + {fr->createAnnulusCmd(Vector($3), + $5,$7,1, + color,dash,1,font,text,localProps,localComment,taglist,cblist);} + | ANNULUS_ bp coord sp value sp value sp {aNum=2;} aRads ep + shapeComment + { + aAnnuli[0] = $5; + aAnnuli[1] = $7; + fr->createAnnulusCmd(Vector($3), + aNum,aAnnuli, + color,dash,1,font,text,localProps,localComment,taglist,cblist); + } + | ANNULUS_ bp coord sp value sp value sp numberof ep shapeComment + {fr->createAnnulusCmd(Vector($3), + $5,$7,$9, + color,dash,1,font,text,localProps,localComment,taglist,cblist);} + + + | ELLIPSE_ bp coord sp vvalue sp optangle ep shapeComment + { + // for ellipse annulus + aStatus = 1; + aCenter = Vector($3); + aAngle = $7; + aVector[0] = Vector($5); + aNum = 1; + strncpy(aComment,localComment,80); + aProps = localProps; + + fr->createEllipseCmd(Vector($3), + Vector($5), + $7, + color,dash,1,font,text,localProps,localComment,taglist,cblist); + } + | ELLIPSE_ bp coord sp vvalue sp optangle ep '&' '!' + ELLIPSE_ bp coord sp vvalue sp optangle ep + { + aStatus = 2; + aVector[aNum++] = Vector($5); + } + + | BOX_ bp coord sp vvalue sp optangle ep shapeComment + { + // for box annulus + aStatus = 3; + aCenter = Vector($3); + aAngle = $7; + aVector[0] = Vector($5); + aNum = 1; + strncpy(aComment,localComment,80); + aProps = localProps; + + fr->createBoxCmd(Vector($3), + Vector($5), + $7, + color,dash,1,font,text,localProps,localComment,taglist,cblist); + } + | ROTBOX_ bp coord sp vvalue sp optangle ep shapeComment + {fr->createBoxCmd(Vector($3), + Vector($5), + $7, + color,dash,1,font,text,localProps,localComment,taglist,cblist);} + | BOX_ bp coord sp vvalue sp optangle ep '&' '!' + BOX_ bp coord sp vvalue sp optangle ep + { + aStatus = 4; + aVector[aNum++] = Vector($5); + } + + | POINT_ bp coord ep shapeComment + {fr->createPointCmd(Vector($3), Point::BOXCIRCLE, POINTSIZE, + color,dash,1,font,text,localProps,localComment,taglist,cblist);} + + | POLYGON_ {polylist.deleteAll();} bp polyNodes ep shapeComment + {fr->createPolygonCmd(polylist, + color,dash,1,font,text,localProps,localComment,taglist,cblist);} + ; + +polyNodes : polyNodes sp polyNode + | polyNode + ; + +polyNode : coord {polylist.append(new Vertex($1));} + ; + +aRads : aRads sp aRad + | aRad + ; + +aRad : value {aAnnuli[aNum++] = $1;} + ; + +processAnnulus : /* empty */ + { + switch (aStatus) { + case 0: // do nothing + break; + case 1: // we found just an ellipse, do nothing + break; + case 2: // ok we have an ellipse annulus + fr->markerDeleteLastCmd(); // delete the previous ellipse + fr->createEllipseAnnulusCmd(aCenter, + aNum,aVector, + aAngle, + color,dash,1,font,text,aProps,aComment,taglist,cblist); + break; + case 3: // we found just a box, do nothing + break; + case 4: // ok, we have a box annulus + fr->markerDeleteLastCmd(); // delete the previous box + fr->createBoxAnnulusCmd(aCenter, + aNum,aVector, + aAngle, + color,dash,1,font,text,aProps,aComment,taglist,cblist); + break; + } + aStatus = 0; + } + ; + +generalComment : '#' {DISCARD_(1);} STRING + ; + +shapeComment : /* empty */ processAnnulus + | '#' {DISCARD_(0);} STRING processAnnulus + {strncpy(localComment,$3,80);} + ; + +%% + +static void setProps(unsigned short* props, unsigned short prop, int value) +{ + if (value) + *props |= prop; + else + *props &= ~prop; +} diff --git a/tksao/frame/segment.C b/tksao/frame/segment.C new file mode 100644 index 0000000..ce99203 --- /dev/null +++ b/tksao/frame/segment.C @@ -0,0 +1,173 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "segment.h" +#include "fitsimage.h" + +Segment::Segment(Base* p, const Vector& ctr, + const Vector& b) + : BasePolygon(p,ctr,b) +{ + strcpy(type_, "segment"); + reset(b); +} + +Segment::Segment(Base* p, const Vector& ctr, + const Vector& b, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BasePolygon(p, ctr, b, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + strcpy(type_, "segment"); + reset(b); +} + +Segment::Segment(Base* p, const List& v, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : BasePolygon(p, v, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + strcpy(type_, "segment"); +} + +void Segment::renderX(Drawable drawable, Coord::InternalSystem sys, + RenderMode mode) +{ + GC lgc = renderXGC(mode); + + vertex.head(); + Vector v1; + Vector v2 = fwdMap(vertex.current()->vector,sys); + vertex.next(); + + do { + v1 = v2; + v2 = fwdMap(vertex.current()->vector,sys); + XDrawLine(display, drawable, lgc, v1[0], v1[1], v2[0], v2[1]); + } while (vertex.next()); +} + +void Segment::renderPS(int mode) +{ + renderPSGC(mode); + + vertex.head(); + int first = 1; + ostringstream str; + do { + Vector v = fwdMap(vertex.current()->vector,Coord::CANVAS); + if (first) { + str << "newpath " << endl + << v.TkCanvasPs(parent->canvas) << " moveto" << endl; + first = 0; + } + else + str << v.TkCanvasPs(parent->canvas) << " lineto" << endl; + } while (vertex.next()); + + str << "stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +#ifdef MAC_OSX_TK +void Segment::renderMACOSX() +{ + renderMACOSXGC(); + + vertex.head(); + Vector v1; + Vector v2 = fwdMap(vertex.current()->vector,Coord::CANVAS); + vertex.next(); + + do { + v1 = v2; + v2 = fwdMap(vertex.current()->vector,Coord::CANVAS); + macosxDrawLine(v1,v2); + } while (vertex.next()); +} +#endif + +#ifdef __WIN32 +void Segment::renderWIN32() +{ + renderWIN32GC(); + + vertex.head(); + Vector v1; + Vector v2 = fwdMap(vertex.current()->vector,Coord::CANVAS); + vertex.next(); + + do { + v1 = v2; + v2 = fwdMap(vertex.current()->vector,Coord::CANVAS); + win32DrawLine(v1,v2); + } while (vertex.next()); +} +#endif + +void Segment::reset(const Vector& b) +{ + angle = 0; + vertex.deleteAll(); + + Vector bb = b; + vertex.append(new Vertex(-bb[0],-bb[1])); + vertex.append(new Vertex( bb[0], bb[1])); + + updateBBox(); +} + +int Segment::getSegment(const Vector& v) +{ + // v is in canvas coords + Matrix mm = fwdMatrix(); + + vertex.head(); + Vector v1; + Vector v2 = vertex.current()->vector * mm; + vertex.next(); + + int ii = 1; + do { + v1 = v2; + v2 = vertex.current()->vector * mm; + + Vector l1 = parent->mapFromRef(v1,Coord::CANVAS); + Vector l2 = parent->mapFromRef(v2,Coord::CANVAS); + double a = (l2-l1).angle(); + Matrix mx = Translate(-l1) * FlipY() * Rotate(-a); + Vector end = l2*mx; + Vector vv = v*mx; + + if (vv[0]>0 && vv[0]-parent->markerEpsilon && vv[1]markerEpsilon) + return ii; + + ii++; + } while (vertex.next()); + + return 0; +} + +// list + +void Segment::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + if (!strip) { + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 1); + listBase(ptr, str, sys, sky, format); + + if (conj) + str << " ||"; + listProperties(str, 0); + } +} diff --git a/tksao/frame/segment.h b/tksao/frame/segment.h new file mode 100644 index 0000000..ae331e4 --- /dev/null +++ b/tksao/frame/segment.h @@ -0,0 +1,47 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __segment_h__ +#define __segment_h__ + +#include "basepolygon.h" +#include "marker.h" +#include "list.h" + +class Segment : public BasePolygon { + protected: + void renderX(Drawable, Coord::InternalSystem, RenderMode); + void renderPS(int); +#ifdef MAC_OSX_TK + void renderMACOSX(); +#endif +#ifdef __WIN32 + void renderWIN32(); +#endif + +public: + Segment(Base* p, const Vector& ctr, + const Vector& b); + Segment(Base* p, const Vector& ctr, + const Vector& b, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + Segment(Base* p, const List& v, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + Segment(const Segment& a) : BasePolygon(a) {} + + Marker* dup() {return new Segment(*this);} + + int getSegment(const Vector&); + void reset(const Vector&); + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); +}; + +#endif diff --git a/tksao/frame/sigbus.h b/tksao/frame/sigbus.h new file mode 100644 index 0000000..04645b3 --- /dev/null +++ b/tksao/frame/sigbus.h @@ -0,0 +1,44 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __sigbus_h__ +#define __sigbus_h__ + +#ifdef __WIN32 +#define INTERP +#define SETSIGBUS +#define CLEARSIGBUS +#else + +// Signal Support +#include +#include + +static sigjmp_buf crashbuf; +static struct sigaction sigact, osigbus, osigsegv; +static void crashHandler(int dummy) { + siglongjmp(crashbuf, 1); +} +#define INTERP interp +#define SETSIGBUS \ + if (sigsetjmp(crashbuf, 1)) { \ + Tcl_SetVar2(INTERP, "ds9", "msg", "A SIGBUS or SIGSEGV error has been received.", TCL_GLOBAL_ONLY); \ + Tcl_SetVar2(INTERP, "ds9", "msg,level", "error", TCL_GLOBAL_ONLY); \ + } \ + else { \ + sigact.sa_handler = crashHandler; \ + sigemptyset(&sigact.sa_mask); \ + sigact.sa_flags = 0; \ + sigaction(SIGSEGV, &sigact, &osigsegv); \ + sigaction(SIGBUS, &sigact, &osigbus); + +#define CLEARSIGBUS \ + } \ + sigaction(SIGSEGV, &osigsegv, NULL); \ + sigaction(SIGBUS, &osigbus, NULL); + +#endif + +#endif + diff --git a/tksao/frame/tag.C b/tksao/frame/tag.C new file mode 100644 index 0000000..cec405b --- /dev/null +++ b/tksao/frame/tag.C @@ -0,0 +1,37 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "tag.h" +#include "util.h" + +Tag::Tag(const Tag& t) +{ + tag_ = dupstr(t.tag_); +} + +Tag::Tag(const char* t) +{ + tag_ = dupstr(t); +} + +Tag& Tag::operator=(const Tag& t) +{ + tag_ = dupstr(t.tag_); + return *this; +} + +Tag::~Tag() +{ + if (tag_) + delete [] tag_; +} + +void Tag::set(const char* t) +{ + if (tag_) + delete tag_; + + tag_ = dupstr(t); +} + diff --git a/tksao/frame/tag.h b/tksao/frame/tag.h new file mode 100644 index 0000000..43a98d2 --- /dev/null +++ b/tksao/frame/tag.h @@ -0,0 +1,33 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __tag_h__ +#define __tag_h__ + +#include +#include +#include +using namespace std; + +class Tag { + char* tag_; + + Tag* previous_; + Tag* next_; + + public: + Tag(const char*); + Tag(const Tag&); + Tag& operator=(const Tag&); + ~Tag(); + + const char* tag() {return tag_;} + void set(const char*); + Tag* previous() {return previous_;} + void setPrevious(Tag* t) {previous_ = t;} + Tag* next() {return next_;} + void setNext(Tag* t) {next_ = t;} +}; + +#endif diff --git a/tksao/frame/text.C b/tksao/frame/text.C new file mode 100644 index 0000000..2873043 --- /dev/null +++ b/tksao/frame/text.C @@ -0,0 +1,324 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "text.h" +#include "fitsimage.h" + +EXTERN void TkDrawAngledChars(Display *display, + Drawable drawable, GC gc, Tk_Font tkfont, + const char *source, int numBytes, double x, + double y, double angle); + +Text::Text(const Text& a) : Marker(a) +{ + rotate = a.rotate; +} + +Text::Text(Base* p, const Vector& ctr, + double ang, int rot, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : Marker(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + strcpy(type_,"text"); + handle = new Vector[4]; + numHandle = 4; + rotate = rot; + + updateBBox(); +} + +void Text::renderX(Drawable drawable, Coord::InternalSystem sys, RenderMode mode) +{ + if (text && *text && tkfont_) { + GC lgc = renderXGC(mode); + XSetFont(display, lgc, Tk_FontId(tkfont_)); + + // origin is center of text + Tk_FontMetrics metrics; + Tk_GetFontMetrics(tkfont_, &metrics); + int width = Tk_TextWidth(tkfont_, text, strlen(text)); + int delta = (metrics.ascent-metrics.descent)/2.; + + double ang = rotate ? calcAngle() : 0; + Vector cc = parent->mapFromRef(center,sys); + Matrix mm = Translate(-cc) * + Translate(-width/2., delta) * + Rotate(ang) * + Translate(cc); + Vector vv = cc * mm; + + TkDrawAngledChars(display, drawable, lgc, tkfont_, + text, strlen(text), + vv[0], vv[1], radToDeg(ang)); + } +} + +void Text::renderPS(int mode) +{ + renderPSGC(mode); + + if (text && *text && psfont_) { + ostringstream str; + + const char* ff = Tk_NameOfFont(psfont_); + str << '/' << psFontName(ff) + << " findfont " << int(psFontSize(ff)*parent->getDisplayRatio()) + << " scalefont setfont" << endl; + + double ang = rotate ? calcAngle() : 0; + Vector cc = (parent->mapFromRef(center,Coord::CANVAS)).TkCanvasPs(parent->canvas); + str << "gsave" << endl + << "newpath " << endl + << cc << " moveto" << endl + << '(' << psQuote(text) << ')' << endl + << "dup true charpath pathbbox " << endl + << "closepath " << endl + << "3 -1 roll sub 3.6 div neg " << endl + << "3 1 roll sub 2 div exch " << endl + << cc << " moveto " << endl + << radToDeg(ang) << " rotate " << endl + << " rmoveto show" << endl + << "grestore" << endl; + + str << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } +} + +#ifdef MAC_OSX_TK +void Text::renderMACOSX() +{ + renderMACOSXGC(); + + if (text && *text && psfont_) { + Tcl_DString psdstr; + Tcl_DStringInit(&psdstr); + int psSize = Tk_PostscriptFontName(psfont_, &psdstr); + macosxFont(Tcl_DStringValue(&psdstr), psSize); + Tcl_DStringFree(&psdstr); + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(psfont_, &metrics); + int width = Tk_TextWidth(psfont_, text, strlen(text)); + + double ang = rotate ? calcAngle() : 0; + Vector cc = parent->mapFromRef(center,Coord::CANVAS); + Matrix mm = Translate(-cc) * + Translate(-width/2.,metrics.descent) * + Rotate(ang) * + Translate(cc); + + macosxDrawText(cc*mm, 0, text); + } +} +#endif + +#ifdef __WIN32 +void Text::renderWIN32() +{ + renderWIN32GC(); + + if (text && *text && tkfont_) { + win32Font(tkfont_); + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(tkfont_, &metrics); + int width = Tk_TextWidth(tkfont_, text, strlen(text)); + int delta = (metrics.ascent-metrics.descent)/2.; + + double ang = rotate ? calcAngle() : 0; + Vector cc = parent->mapFromRef(center,Coord::CANVAS); + Matrix mm = Translate(-cc) * + Translate(-width/2., delta) * + Rotate(ang) * + Translate(cc); + Vector vv = cc * mm; + + win32DrawText(vv, 0, text); + } +} +#endif + +// Support + +void Text::updateHandles() +{ + Vector cc = parent->mapFromRef(center,Coord::CANVAS); + + if (text && *text && tkfont_) { + Tk_FontMetrics metrics; + Tk_GetFontMetrics(tkfont_, &metrics); + int width = Tk_TextWidth(tkfont_, text, strlen(text)); + + Vector s(width, metrics.linespace); + double ang = rotate ? calcAngle() : 0; + Matrix mm = Rotate(ang) * Translate(cc); + handle[0] = Vector(-s[0],-s[1])/2 * mm; + handle[1] = Vector( s[0],-s[1])/2 * mm; + handle[2] = Vector( s[0], s[1])/2 * mm; + handle[3] = Vector(-s[0], s[1])/2 * mm; + } + else { + Vector s(10,10); + Matrix mm = Translate(cc); + handle[0] = Vector(-s[0],-s[1])/2 * mm; + handle[1] = Vector( s[0],-s[1])/2 * mm; + handle[2] = Vector( s[0], s[1])/2 * mm; + handle[3] = Vector(-s[0], s[1])/2 * mm; + } +} + +void Text::calcAllBBox() +{ + allBBox = bbox; +} + +int Text::isIn(const Vector& vv) +{ + if (text && *text && tkfont_) { + // origin is center of text + Tk_FontMetrics metrics; + Tk_GetFontMetrics(tkfont_, &metrics); + float ww = Tk_TextWidth(tkfont_, text, strlen(text))/2./parent->zoom_[0]; + float hh = metrics.linespace/2./parent->zoom_[1]; + + Vector pp = bckMap(vv,Coord::CANVAS); + + if (pp[0]<-ww || pp[0]>ww || pp[1]<-hh || pp[1]>hh) + return 0; + else + return 1; + } + else + return 0; +} + +void Text::setRotate(int rot) +{ + rotate = rot ? 1 : 0; + updateBBox(); +} + +// list + +void Text::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + if (!text || !*text) + return; + + if (!strip) { + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 1); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listNonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' << setprecision(10) << vv << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' << ra << ',' << dec << ')'; + break; + } + } + else + listNonCel(ptr, str, sys); + } + + if (conj) + str << " ||"; + + if (angle != 0) + str << " textangle=" << radToDeg(parent->mapAngleFromRef(angle,sys,sky)); + if (!rotate) + str << " textrotate=" << 0; + listProperties(str, 0); + } +} + +void Text::listNonCel(FitsImage* ptr, ostream& str, Coord::CoordSystem sys) +{ + Vector vv = ptr->mapFromRef(center,sys); + str << type_ << '(' << setprecision(8) << vv << ')'; +} + +void Text::listXML(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + FitsImage* ptr = parent->findFits(sys,center); + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowCenter(ptr,sys,sky,format); + XMLRowAng(sys,sky); + XMLRow(XMLPARAM,rotate); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} + +void Text::listSAOtng(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int strip) +{ + if (!text || !*text) + return; + + FitsImage* ptr = parent->findFits(); + if (properties&INCLUDE) + str << '+'; + else + str << '-'; + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + { + Vector vv = ptr->mapFromRef(center,Coord::IMAGE); + str << type_ << '(' << setprecision(8) << vv << ", \"" << text << "\")"; + } + break; + default: + if (ptr->hasWCSCel(sys)) { + switch (format) { + case Coord::DEGREES: + { + Vector vv = ptr->mapFromRef(center,sys,sky); + str << type_ << '(' << setprecision(10) << vv + << ", \"" << text << "\")"; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,center,sys,sky,format); + str << type_ << '(' << ra << ',' << dec << ", \"" << text << "\")"; + break; + } + } + } + + listSAOtngPost(str, strip); +} + + + + diff --git a/tksao/frame/text.h b/tksao/frame/text.h new file mode 100644 index 0000000..dcb4d77 --- /dev/null +++ b/tksao/frame/text.h @@ -0,0 +1,66 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __text_h__ +#define __text_h__ + +#include "marker.h" + +class Text : public Marker { + private: + int rotate; + + private: + void renderX(Drawable, Coord::InternalSystem, RenderMode); + void renderXText(Drawable, Coord::InternalSystem, RenderMode) {} + void renderXInclude(Drawable, Coord::InternalSystem, RenderMode) {} + + void renderPS(int); + void renderPSText(int) {} + void renderPSInclude(int) {} + +#ifdef MAC_OSX_TK + void renderMACOSX(); + void renderMACOSXText() {} + void renderMACOSXInclude() {} +#endif + +#ifdef __WIN32 + void renderWIN32(); + void renderWIN32Text() {} + void renderWIN32Include() {} +#endif + + void updateHandles(); + void calcAllBBox(); + + protected: + void listNonCel(FitsImage*, ostream&, Coord::CoordSystem); + + public: + Text(const Text&); + Text(Base* p, const Vector& ctr, + double a, int r, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + + Marker* dup() {return new Text(*this);} + + int isIn(const Vector&); + + void editBegin(int) {} + void edit(const Vector& v, int h) {} + void editEnd() {} + + void setRotate(int); + int getRotate() {return rotate;} + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void listSAOtng(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int); +}; + +#endif diff --git a/tksao/frame/tnglex.C b/tksao/frame/tnglex.C new file mode 100644 index 0000000..042c8b6 --- /dev/null +++ b/tksao/frame/tnglex.C @@ -0,0 +1,2209 @@ +#line 2 "frame/tnglex.C" + +#line 4 "frame/tnglex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer tngFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *tngalloc (yy_size_t ); +void *tngrealloc (void *,yy_size_t ); +void tngfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 57 +#define YY_END_OF_BUFFER 58 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[250] = + { 0, + 0, 0, 2, 2, 58, 56, 52, 55, 56, 56, + 56, 56, 56, 41, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 56, 56, 2, 1, 52, 53, + 0, 48, 0, 49, 0, 41, 43, 42, 41, 0, + 51, 44, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 29, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 54, 0, 50, 2, + 44, 0, 45, 0, 0, 0, 42, 51, 51, 51, + + 51, 5, 51, 51, 51, 51, 51, 51, 51, 51, + 16, 18, 51, 51, 51, 51, 23, 51, 51, 51, + 51, 28, 51, 51, 51, 51, 34, 51, 51, 51, + 51, 51, 51, 42, 0, 43, 0, 51, 51, 51, + 7, 51, 9, 10, 51, 51, 51, 51, 51, 0, + 51, 51, 51, 51, 24, 51, 26, 51, 51, 51, + 51, 51, 51, 51, 37, 51, 51, 51, 0, 46, + 3, 51, 6, 51, 11, 51, 51, 51, 51, 0, + 51, 51, 21, 51, 25, 51, 51, 51, 32, 51, + 51, 51, 51, 39, 51, 47, 46, 51, 8, 51, + + 51, 51, 51, 0, 19, 51, 51, 51, 51, 31, + 51, 35, 51, 51, 40, 51, 12, 51, 13, 51, + 0, 51, 51, 27, 51, 33, 51, 38, 51, 14, + 15, 17, 20, 51, 30, 51, 51, 51, 51, 4, + 51, 51, 51, 51, 51, 51, 22, 36, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 5, 1, 1, 1, 1, 6, 1, + 1, 1, 7, 1, 8, 9, 1, 10, 11, 12, + 13, 14, 15, 13, 13, 13, 16, 17, 1, 1, + 1, 1, 1, 1, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 34, + 1, 43, 1, 1, 1, 1, 44, 45, 46, 47, + + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 34, 60, 61, 62, 63, 64, 65, 66, + 67, 34, 68, 1, 69, 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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[70] = + { 0, + 1, 1, 2, 1, 1, 1, 1, 1, 3, 4, + 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, + 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 1, 3, 3, 3, 4, 4, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[257] = + { 0, + 0, 0, 210, 208, 195, 1179, 187, 1179, 164, 155, + 133, 61, 68, 76, 85, 90, 86, 87, 97, 104, + 124, 148, 120, 137, 138, 154, 152, 168, 164, 165, + 170, 193, 182, 199, 87, 58, 0, 1179, 118, 1179, + 111, 1179, 109, 1179, 224, 239, 184, 221, 279, 260, + 171, 205, 321, 208, 293, 302, 300, 248, 298, 288, + 334, 249, 289, 338, 345, 339, 340, 354, 361, 364, + 363, 377, 374, 368, 380, 250, 379, 392, 398, 405, + 402, 395, 421, 425, 430, 426, 1179, 42, 1179, 0, + 1179, 456, 1179, 481, 463, 488, 496, 442, 505, 506, + + 507, 268, 508, 510, 521, 522, 523, 525, 527, 528, + 428, 305, 540, 547, 564, 554, 432, 557, 578, 575, + 581, 585, 590, 591, 600, 602, 605, 607, 611, 618, + 628, 621, 623, 660, 680, 687, 695, 637, 632, 703, + 644, 704, 651, 668, 705, 706, 707, 708, 717, 94, + 718, 729, 730, 728, 670, 733, 735, 747, 754, 756, + 759, 760, 772, 773, 774, 786, 792, 785, 812, 835, + 788, 820, 790, 843, 822, 844, 825, 847, 850, 118, + 860, 861, 854, 864, 865, 867, 879, 884, 886, 896, + 893, 897, 900, 902, 909, 923, 949, 934, 907, 933, + + 931, 958, 959, 102, 935, 961, 962, 968, 979, 964, + 986, 981, 982, 993, 984, 1002, 1005, 1011, 1012, 1016, + 360, 1025, 1018, 1027, 1032, 1037, 1039, 1042, 1043, 1046, + 1049, 1179, 1053, 1058, 1060, 1063, 1069, 1076, 1079, 1074, + 1080, 1086, 1089, 1095, 1109, 1110, 1096, 1105, 1179, 1156, + 1160, 1164, 1166, 1170, 1174, 96 + } ; + +static yyconst flex_int16_t yy_def[257] = + { 0, + 249, 1, 250, 250, 249, 249, 249, 249, 249, 251, + 252, 249, 249, 253, 253, 253, 253, 253, 253, 253, + 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, + 253, 253, 253, 253, 249, 254, 255, 249, 249, 249, + 251, 249, 252, 249, 249, 249, 256, 256, 253, 249, + 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, + 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, + 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, + 253, 253, 253, 253, 253, 253, 249, 254, 249, 255, + 249, 249, 249, 249, 249, 249, 253, 253, 253, 253, + + 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, + 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, + 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, + 253, 253, 253, 249, 249, 249, 249, 253, 253, 253, + 253, 253, 253, 253, 253, 253, 253, 253, 253, 249, + 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, + 253, 253, 253, 253, 253, 253, 253, 253, 249, 249, + 253, 253, 253, 253, 253, 253, 253, 253, 253, 249, + 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, + 253, 253, 253, 253, 253, 249, 249, 253, 253, 253, + + 253, 253, 253, 249, 253, 253, 253, 253, 253, 253, + 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, + 249, 253, 253, 253, 253, 253, 253, 253, 253, 253, + 253, 249, 253, 253, 253, 253, 253, 253, 253, 253, + 253, 253, 253, 253, 253, 253, 253, 253, 0, 249, + 249, 249, 249, 249, 249, 249 + } ; + +static yyconst flex_int16_t yy_nxt[1249] = + { 0, + 6, 7, 8, 9, 10, 11, 12, 12, 13, 14, + 14, 14, 14, 14, 14, 14, 6, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 15, 25, 26, + 15, 27, 28, 15, 29, 30, 31, 15, 32, 33, + 15, 34, 35, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 15, 25, 26, 15, 27, 28, 29, + 30, 31, 15, 32, 33, 15, 34, 36, 6, 45, + 46, 46, 46, 46, 46, 46, 46, 47, 47, 47, + 47, 47, 47, 47, 48, 49, 49, 49, 49, 49, + 49, 49, 50, 249, 249, 249, 52, 53, 249, 47, + + 54, 249, 249, 249, 60, 249, 249, 55, 61, 221, + 89, 58, 249, 249, 44, 42, 62, 87, 56, 39, + 249, 57, 52, 53, 180, 63, 89, 59, 249, 64, + 60, 65, 249, 55, 61, 66, 249, 58, 44, 71, + 249, 67, 62, 87, 56, 249, 249, 57, 72, 204, + 180, 63, 59, 249, 249, 64, 249, 65, 68, 42, + 249, 66, 249, 73, 249, 71, 40, 67, 249, 69, + 249, 74, 249, 249, 75, 204, 249, 70, 249, 249, + 249, 249, 76, 68, 249, 80, 249, 249, 39, 73, + 249, 83, 77, 78, 249, 69, 81, 74, 249, 79, + + 75, 249, 82, 70, 93, 94, 85, 249, 76, 249, + 38, 80, 38, 249, 84, 249, 249, 83, 77, 78, + 86, 249, 81, 98, 249, 79, 249, 82, 249, 249, + 93, 94, 85, 47, 47, 47, 47, 47, 47, 47, + 84, 91, 92, 249, 249, 249, 86, 48, 46, 46, + 46, 46, 46, 46, 46, 50, 249, 249, 249, 91, + 92, 249, 249, 249, 249, 249, 249, 91, 92, 95, + 95, 95, 95, 95, 95, 95, 249, 108, 249, 249, + 249, 249, 103, 249, 249, 91, 92, 48, 49, 49, + 49, 49, 49, 49, 49, 50, 249, 249, 249, 52, + + 53, 249, 249, 108, 249, 249, 249, 103, 249, 249, + 249, 249, 99, 249, 249, 104, 249, 109, 249, 100, + 249, 249, 249, 249, 105, 52, 53, 96, 96, 249, + 97, 97, 97, 97, 97, 97, 97, 249, 99, 101, + 102, 104, 249, 109, 249, 100, 249, 249, 249, 105, + 249, 249, 106, 249, 249, 249, 249, 107, 111, 112, + 249, 249, 249, 249, 101, 102, 110, 249, 114, 249, + 249, 249, 249, 113, 249, 115, 249, 249, 106, 249, + 249, 232, 249, 107, 249, 249, 119, 249, 249, 116, + 249, 121, 110, 249, 114, 249, 249, 118, 113, 117, + + 249, 115, 122, 249, 120, 249, 249, 232, 249, 249, + 249, 249, 249, 249, 249, 116, 249, 121, 249, 249, + 123, 249, 118, 125, 117, 127, 126, 129, 122, 249, + 120, 249, 124, 249, 249, 150, 249, 249, 249, 128, + 249, 249, 249, 249, 249, 123, 249, 249, 249, 125, + 249, 127, 126, 129, 133, 132, 138, 124, 249, 131, + 249, 130, 96, 96, 128, 134, 134, 134, 134, 134, + 134, 134, 95, 95, 95, 95, 95, 95, 95, 137, + 133, 132, 249, 249, 131, 249, 130, 135, 135, 249, + 136, 136, 136, 136, 136, 136, 136, 134, 134, 134, + + 134, 134, 134, 134, 249, 97, 97, 97, 97, 97, + 97, 97, 249, 249, 249, 249, 249, 249, 249, 249, + 249, 249, 249, 249, 249, 140, 249, 142, 141, 249, + 249, 249, 139, 249, 249, 249, 249, 249, 249, 249, + 143, 249, 144, 249, 249, 249, 249, 249, 249, 149, + 147, 140, 148, 142, 141, 249, 249, 146, 139, 145, + 249, 249, 249, 249, 152, 249, 143, 249, 144, 151, + 249, 249, 249, 249, 249, 149, 147, 249, 148, 154, + 249, 249, 146, 249, 145, 153, 249, 156, 249, 249, + 152, 249, 155, 249, 249, 151, 157, 249, 249, 249, + + 249, 249, 158, 249, 249, 154, 249, 249, 249, 249, + 249, 153, 160, 249, 249, 249, 249, 155, 249, 249, + 249, 249, 157, 249, 249, 159, 249, 249, 158, 249, + 161, 249, 164, 249, 249, 249, 249, 249, 160, 249, + 249, 163, 249, 162, 249, 249, 171, 249, 249, 249, + 159, 168, 249, 249, 165, 172, 161, 167, 164, 249, + 249, 249, 249, 166, 249, 249, 163, 249, 162, 134, + 134, 134, 134, 134, 134, 134, 249, 168, 249, 165, + 249, 172, 167, 249, 249, 249, 249, 249, 166, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + + 136, 136, 136, 169, 170, 170, 170, 170, 170, 170, + 170, 249, 249, 249, 249, 249, 249, 249, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 176, 175, 249, + 173, 249, 174, 249, 249, 181, 249, 249, 249, 177, + 178, 249, 185, 249, 249, 249, 249, 179, 182, 249, + 249, 249, 249, 176, 175, 249, 173, 249, 174, 184, + 183, 181, 249, 249, 249, 177, 178, 249, 249, 249, + 249, 249, 249, 179, 182, 249, 249, 186, 249, 187, + 249, 249, 249, 190, 188, 184, 183, 249, 249, 249, + 249, 191, 249, 249, 249, 189, 249, 249, 249, 249, + + 249, 249, 249, 186, 249, 187, 249, 192, 249, 190, + 188, 193, 249, 194, 249, 249, 195, 191, 249, 249, + 189, 196, 196, 196, 196, 196, 196, 196, 249, 249, + 249, 249, 192, 249, 249, 249, 249, 193, 249, 194, + 249, 249, 195, 197, 170, 170, 170, 170, 170, 170, + 170, 249, 249, 249, 198, 249, 249, 249, 249, 249, + 249, 201, 249, 249, 199, 200, 249, 203, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 249, 249, 198, + 249, 249, 202, 249, 249, 207, 201, 249, 249, 249, + 199, 200, 249, 203, 249, 249, 205, 206, 209, 249, + + 249, 249, 249, 208, 249, 249, 249, 202, 249, 249, + 249, 207, 249, 249, 212, 249, 249, 249, 249, 210, + 213, 205, 206, 249, 209, 249, 249, 211, 208, 249, + 249, 214, 196, 196, 196, 196, 196, 196, 196, 249, + 212, 249, 249, 249, 210, 249, 213, 249, 215, 249, + 249, 249, 249, 211, 249, 249, 218, 214, 196, 196, + 196, 196, 196, 196, 196, 216, 249, 249, 217, 249, + 249, 249, 249, 215, 249, 249, 249, 249, 249, 219, + 249, 223, 218, 249, 249, 224, 222, 249, 220, 249, + 249, 216, 249, 217, 249, 249, 225, 249, 249, 227, + + 249, 249, 249, 249, 249, 219, 249, 223, 249, 249, + 249, 224, 222, 249, 220, 249, 226, 249, 249, 249, + 249, 249, 225, 228, 249, 227, 249, 249, 249, 249, + 230, 249, 249, 249, 249, 249, 249, 231, 249, 229, + 249, 249, 226, 249, 233, 249, 234, 249, 249, 228, + 249, 249, 249, 249, 249, 249, 230, 249, 249, 249, + 235, 249, 249, 231, 229, 249, 249, 236, 249, 249, + 233, 249, 234, 237, 249, 249, 249, 249, 249, 249, + 239, 249, 249, 238, 249, 249, 235, 249, 249, 240, + 249, 249, 249, 236, 249, 249, 249, 249, 242, 237, + + 249, 249, 249, 249, 249, 249, 239, 249, 241, 238, + 249, 249, 249, 249, 245, 240, 243, 249, 249, 249, + 246, 249, 244, 249, 242, 249, 249, 249, 247, 248, + 249, 249, 249, 249, 241, 249, 249, 249, 249, 249, + 245, 243, 249, 249, 249, 249, 246, 244, 249, 249, + 249, 249, 249, 249, 247, 248, 37, 37, 37, 37, + 41, 249, 41, 41, 43, 249, 43, 43, 51, 51, + 88, 249, 88, 88, 90, 249, 90, 90, 5, 249, + 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + + 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 249 + } ; + +static yyconst flex_int16_t yy_chk[1249] = + { 0, + 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, 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, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, + 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, + 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 15, 17, 18, 14, 14, 16, 256, + + 16, 15, 17, 18, 18, 19, 16, 16, 18, 204, + 88, 17, 20, 19, 43, 41, 19, 35, 16, 39, + 20, 16, 14, 14, 150, 19, 36, 17, 23, 20, + 18, 20, 21, 16, 18, 20, 23, 17, 11, 23, + 21, 21, 19, 35, 16, 24, 25, 16, 24, 180, + 150, 19, 17, 24, 25, 20, 22, 20, 21, 10, + 27, 20, 26, 25, 22, 23, 9, 21, 27, 22, + 26, 26, 29, 30, 27, 180, 28, 22, 31, 51, + 29, 30, 27, 21, 28, 29, 31, 51, 7, 25, + 33, 31, 28, 28, 5, 22, 30, 26, 33, 28, + + 27, 32, 30, 22, 47, 47, 33, 34, 27, 32, + 4, 29, 3, 52, 32, 34, 54, 31, 28, 28, + 34, 52, 30, 54, 54, 28, 0, 30, 0, 0, + 47, 47, 33, 45, 45, 45, 45, 45, 45, 45, + 32, 48, 48, 0, 0, 0, 34, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 58, 62, 76, 46, + 46, 0, 0, 0, 58, 62, 76, 48, 48, 50, + 50, 50, 50, 50, 50, 50, 102, 62, 0, 0, + 0, 0, 58, 0, 102, 46, 46, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 60, 63, 0, 49, + + 49, 55, 0, 62, 60, 63, 59, 58, 57, 55, + 56, 0, 55, 112, 59, 59, 57, 63, 56, 56, + 0, 112, 0, 0, 60, 49, 49, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 55, 56, + 57, 59, 61, 63, 0, 56, 64, 66, 67, 60, + 61, 0, 61, 65, 64, 66, 67, 61, 65, 65, + 0, 65, 68, 0, 56, 57, 64, 0, 67, 69, + 68, 71, 70, 66, 0, 68, 74, 69, 61, 71, + 70, 221, 73, 61, 74, 72, 72, 77, 75, 69, + 73, 74, 64, 72, 67, 77, 75, 71, 66, 70, + + 78, 68, 75, 82, 73, 0, 79, 221, 78, 0, + 81, 82, 0, 80, 79, 69, 0, 74, 81, 0, + 77, 80, 71, 79, 70, 80, 79, 82, 75, 83, + 73, 0, 78, 84, 86, 111, 111, 83, 85, 81, + 117, 84, 86, 0, 111, 77, 85, 0, 117, 79, + 98, 80, 79, 82, 86, 85, 98, 78, 98, 84, + 0, 83, 92, 92, 81, 92, 92, 92, 92, 92, + 92, 92, 95, 95, 95, 95, 95, 95, 95, 95, + 86, 85, 0, 0, 84, 0, 83, 94, 94, 0, + 94, 94, 94, 94, 94, 94, 94, 96, 96, 96, + + 96, 96, 96, 96, 97, 97, 97, 97, 97, 97, + 97, 97, 97, 99, 100, 101, 103, 0, 104, 0, + 0, 99, 100, 101, 103, 100, 104, 103, 101, 105, + 106, 107, 99, 108, 0, 109, 110, 105, 106, 107, + 104, 108, 105, 109, 110, 0, 0, 0, 113, 110, + 108, 100, 109, 103, 101, 114, 113, 107, 99, 106, + 0, 0, 116, 114, 114, 118, 104, 0, 105, 113, + 116, 0, 115, 118, 0, 110, 108, 0, 109, 116, + 115, 0, 107, 120, 106, 115, 119, 119, 0, 121, + 114, 120, 118, 122, 119, 113, 120, 121, 123, 124, + + 0, 122, 121, 0, 0, 116, 123, 124, 125, 0, + 126, 115, 124, 127, 0, 128, 125, 118, 126, 129, + 0, 127, 120, 128, 0, 123, 130, 129, 121, 132, + 125, 133, 129, 0, 130, 0, 131, 132, 124, 133, + 139, 128, 0, 126, 131, 138, 138, 0, 139, 0, + 123, 133, 141, 138, 130, 139, 125, 132, 129, 143, + 141, 0, 0, 131, 0, 0, 128, 143, 126, 134, + 134, 134, 134, 134, 134, 134, 144, 133, 155, 130, + 0, 139, 132, 0, 144, 0, 155, 0, 131, 135, + 135, 135, 135, 135, 135, 135, 136, 136, 136, 136, + + 136, 136, 136, 137, 137, 137, 137, 137, 137, 137, + 137, 140, 142, 145, 146, 147, 148, 0, 0, 140, + 142, 145, 146, 147, 148, 149, 151, 146, 145, 0, + 140, 0, 142, 149, 151, 151, 154, 152, 153, 147, + 148, 156, 156, 157, 154, 152, 153, 149, 152, 156, + 0, 157, 0, 146, 145, 158, 140, 0, 142, 154, + 153, 151, 159, 158, 160, 147, 148, 161, 162, 0, + 159, 0, 160, 149, 152, 161, 162, 158, 0, 159, + 163, 164, 165, 162, 160, 154, 153, 0, 163, 164, + 165, 163, 0, 168, 166, 161, 171, 0, 173, 0, + + 167, 168, 166, 158, 171, 159, 173, 164, 167, 162, + 160, 166, 0, 167, 0, 0, 168, 163, 0, 0, + 161, 169, 169, 169, 169, 169, 169, 169, 172, 0, + 175, 0, 164, 177, 0, 0, 172, 166, 175, 167, + 0, 177, 168, 170, 170, 170, 170, 170, 170, 170, + 170, 174, 176, 0, 172, 178, 0, 0, 179, 174, + 176, 177, 183, 178, 174, 176, 179, 179, 181, 182, + 183, 0, 184, 185, 0, 186, 181, 182, 0, 172, + 184, 185, 178, 186, 0, 184, 177, 187, 0, 0, + 174, 176, 188, 179, 189, 187, 181, 182, 187, 0, + + 188, 191, 189, 186, 190, 192, 0, 178, 193, 191, + 194, 184, 190, 192, 191, 199, 193, 195, 194, 188, + 192, 181, 182, 199, 187, 195, 0, 190, 186, 0, + 0, 193, 196, 196, 196, 196, 196, 196, 196, 201, + 191, 200, 198, 205, 188, 0, 192, 201, 195, 200, + 198, 205, 0, 190, 0, 0, 201, 193, 197, 197, + 197, 197, 197, 197, 197, 198, 202, 203, 200, 206, + 207, 0, 210, 195, 202, 203, 208, 206, 207, 202, + 210, 207, 201, 0, 208, 208, 206, 209, 203, 212, + 213, 198, 215, 200, 211, 209, 209, 212, 213, 213, + + 215, 214, 211, 0, 0, 202, 0, 207, 0, 214, + 216, 208, 206, 217, 203, 0, 211, 0, 216, 218, + 219, 217, 209, 214, 220, 213, 223, 218, 219, 0, + 218, 0, 220, 222, 223, 224, 0, 220, 0, 216, + 225, 222, 211, 224, 222, 226, 223, 227, 225, 214, + 228, 229, 0, 226, 230, 227, 218, 231, 228, 229, + 225, 233, 230, 220, 216, 231, 234, 227, 235, 233, + 222, 236, 223, 229, 234, 0, 235, 237, 0, 236, + 236, 0, 240, 234, 238, 237, 225, 239, 241, 237, + 240, 0, 238, 227, 242, 239, 241, 243, 239, 229, + + 0, 0, 242, 244, 247, 243, 236, 0, 238, 234, + 0, 244, 247, 248, 243, 237, 241, 245, 246, 0, + 244, 248, 242, 0, 239, 245, 246, 0, 245, 246, + 0, 0, 0, 0, 238, 0, 0, 0, 0, 0, + 243, 241, 0, 0, 0, 0, 244, 242, 0, 0, + 0, 0, 0, 0, 245, 246, 250, 250, 250, 250, + 251, 0, 251, 251, 252, 0, 252, 252, 253, 253, + 254, 0, 254, 254, 255, 0, 255, 255, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + + 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 249 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "frame/tnglex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 12 "frame/tnglex.L" + #include + #include + #include + + #include "util.h" + #include "tngparser.H" + + extern YYSTYPE* tnglval; + extern tngFlexLexer* tnglexx; + +/* rules */ +#line 781 "frame/tnglex.C" + +#define INITIAL 0 +#define DISCARD 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 30 "frame/tnglex.L" + + +#line 885 "frame/tnglex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 250 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 249 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +#line 32 "frame/tnglex.L" +{ // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(tnglval->str,""); // feed a blank string + return STRING; + } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 39 "frame/tnglex.L" +{ // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(TNGBUFSIZE-1) ? yyleng:(TNGBUFSIZE-1); + strncpy(tnglval->str,yytext,ll); + tnglval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 47 "frame/tnglex.L" +{return B1950_;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 48 "frame/tnglex.L" +{return BACKGROUND_;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 49 "frame/tnglex.L" +{return BOX_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 50 "frame/tnglex.L" +{return BLACK_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 51 "frame/tnglex.L" +{return BLUE_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 52 "frame/tnglex.L" +{return CIRCLE_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 53 "frame/tnglex.L" +{return CYAN_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 54 "frame/tnglex.L" +{return DATE_;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 55 "frame/tnglex.L" +{return DEBUG_;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 56 "frame/tnglex.L" +{return DEGREES_;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 57 "frame/tnglex.L" +{return ELLIPSE_;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 58 "frame/tnglex.L" +{return ECLIPTIC_;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 59 "frame/tnglex.L" +{return FILENAME_;} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 60 "frame/tnglex.L" +{return FK4_;} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 61 "frame/tnglex.L" +{return FK4_NO_E_;} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 62 "frame/tnglex.L" +{return FK5_;} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 63 "frame/tnglex.L" +{return FORMAT_;} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 64 "frame/tnglex.L" +{return GALACTIC_;} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 65 "frame/tnglex.L" +{return GREEN_;} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 66 "frame/tnglex.L" +{return HELIOECLIPTIC_;} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 67 "frame/tnglex.L" +{return HMS_;} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 68 "frame/tnglex.L" +{return ICRS_;} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 69 "frame/tnglex.L" +{return J2000_;} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 70 "frame/tnglex.L" +{return LINE_;} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 71 "frame/tnglex.L" +{return MAGENTA_;} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 72 "frame/tnglex.L" +{return OFF_;} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 73 "frame/tnglex.L" +{return ON_;} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 74 "frame/tnglex.L" +{return PHYSICAL_;} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 75 "frame/tnglex.L" +{return PIXELS_;} + YY_BREAK +case 32: +YY_RULE_SETUP +#line 76 "frame/tnglex.L" +{return POINT_;} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 77 "frame/tnglex.L" +{return POLYGON_;} + YY_BREAK +case 34: +YY_RULE_SETUP +#line 78 "frame/tnglex.L" +{return RED_;} + YY_BREAK +case 35: +YY_RULE_SETUP +#line 79 "frame/tnglex.L" +{return SOURCE_;} + YY_BREAK +case 36: +YY_RULE_SETUP +#line 80 "frame/tnglex.L" +{return SUPERGALACTIC_;} + YY_BREAK +case 37: +YY_RULE_SETUP +#line 81 "frame/tnglex.L" +{return TEXT_;} + YY_BREAK +case 38: +YY_RULE_SETUP +#line 82 "frame/tnglex.L" +{return VERSION_;} + YY_BREAK +case 39: +YY_RULE_SETUP +#line 83 "frame/tnglex.L" +{return WHITE_;} + YY_BREAK +case 40: +YY_RULE_SETUP +#line 84 "frame/tnglex.L" +{return YELLOW_;} + YY_BREAK +case 41: +YY_RULE_SETUP +#line 86 "frame/tnglex.L" +{ // Integer + tnglval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 42: +#line 92 "frame/tnglex.L" +case 43: +YY_RULE_SETUP +#line 92 "frame/tnglex.L" +{ // Real Number + tnglval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 44: +#line 98 "frame/tnglex.L" +case 45: +YY_RULE_SETUP +#line 98 "frame/tnglex.L" +{ // degrees + yytext[yyleng-1] = '\0'; + tnglval->real = atof(yytext); + return ANGDEGREE; + } + YY_BREAK +case 46: +#line 105 "frame/tnglex.L" +case 47: +YY_RULE_SETUP +#line 105 "frame/tnglex.L" +{ // Sexagesimal + int ll = yyleng <(TNGBUFSIZE-1)?yyleng:(TNGBUFSIZE-1); + strncpy(tnglval->str,yytext,ll); + tnglval->str[ll] = '\0'; + return SEXSTR; + } + YY_BREAK +case 48: +#line 113 "frame/tnglex.L" +case 49: +YY_RULE_SETUP +#line 113 "frame/tnglex.L" +{ // Quoted String + int ll = (yyleng-2)<(TNGBUFSIZE-1)?(yyleng-2):(TNGBUFSIZE-1); + strncpy(tnglval->str,yytext+1,yyleng-2); // skip the " " + tnglval->str[ll] = '\0'; // Remove the '"' + return STRING; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 120 "frame/tnglex.L" +{ // Quoted String + int ll = (yyleng-2)<(TNGBUFSIZE-1)?(yyleng-2):(TNGBUFSIZE-1); + strncpy(tnglval->str,yytext+1,yyleng-2); // skip the '{' + tnglval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 127 "frame/tnglex.L" +{ // General String + int ll = yyleng <(TNGBUFSIZE-1) ? yyleng:(TNGBUFSIZE-1); + strncpy(tnglval->str,yytext,ll); + tnglval->str[ll] = '\0'; + return STRING; + } + YY_BREAK +case 52: +YY_RULE_SETUP +#line 134 "frame/tnglex.L" +{ // White Spaces + } + YY_BREAK +case 53: +/* rule 53 can match eol */ +YY_RULE_SETUP +#line 137 "frame/tnglex.L" +{ // windows line feed + return '\n'; + } + YY_BREAK +case 54: +YY_RULE_SETUP +#line 141 "frame/tnglex.L" +{ // fake line feed + return '\n'; + } + YY_BREAK +case 55: +/* rule 55 can match eol */ +YY_RULE_SETUP +#line 145 "frame/tnglex.L" +{ // linefeed + return '\n'; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(DISCARD): +#line 149 "frame/tnglex.L" +{ // eof + return EOF_; + } + YY_BREAK +case 56: +YY_RULE_SETUP +#line 153 "frame/tnglex.L" +{ // Else, return the char + return yytext[0]; + } + YY_BREAK +case 57: +YY_RULE_SETUP +#line 157 "frame/tnglex.L" +ECHO; + YY_BREAK +#line 1297 "frame/tnglex.C" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + tngfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + tngfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + tngrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) tngrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 250 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 250 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 249); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) tngalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) tngalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + tngfree((void *) b->yy_ch_buf ); + + tngfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)tngalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)tngrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) tngalloc(new_size ); + + else + (yy_start_stack) = (int *) tngrealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *tngalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *tngrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void tngfree (void * ptr ) +{ + free( (char *) ptr ); /* see tngrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 157 "frame/tnglex.L" + + + +void tngDiscard(int doit) +{ + if (tnglexx) + tnglexx->begin(DISCARD, doit); +} + +void tngFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} + diff --git a/tksao/frame/tnglex.L b/tksao/frame/tnglex.L new file mode 100644 index 0000000..7cd20e2 --- /dev/null +++ b/tksao/frame/tnglex.L @@ -0,0 +1,170 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ + +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + + #include "util.h" + #include "tngparser.H" + + extern YYSTYPE* tnglval; + extern tngFlexLexer* tnglexx; +%} + +%x DISCARD + +D [0-9] +E [Ee][+-]?{D}+ + +/* rules */ + +%% + +[\n] { // special case-- #\n + BEGIN INITIAL; + yyless(0); // put back the terminator + strcpy(tnglval->str,""); // feed a blank string + return STRING; + } + +[^\n]* { // Discard reset of line + BEGIN INITIAL; + int ll = yyleng <(TNGBUFSIZE-1) ? yyleng:(TNGBUFSIZE-1); + strncpy(tnglval->str,yytext,ll); + tnglval->str[ll] = '\0'; + return STRING; + } + +b1950 {return B1950_;} +background {return BACKGROUND_;} +box {return BOX_;} +black {return BLACK_;} +blue {return BLUE_;} +circle {return CIRCLE_;} +cyan {return CYAN_;} +date {return DATE_;} +debug {return DEBUG_;} +degrees {return DEGREES_;} +ellipse {return ELLIPSE_;} +ecliptic {return ECLIPTIC_;} +filename {return FILENAME_;} +fk4 {return FK4_;} +fk4-no-e {return FK4_NO_E_;} +fk5 {return FK5_;} +format {return FORMAT_;} +galactic {return GALACTIC_;} +green {return GREEN_;} +helioecliptic {return HELIOECLIPTIC_;} +hms {return HMS_;} +icrs {return ICRS_;} +j2000 {return J2000_;} +lin[e] {return LINE_;} +magenta {return MAGENTA_;} +off {return OFF_;} +on {return ON_;} +physical {return PHYSICAL_;} +pixels {return PIXELS_;} +point {return POINT_;} +polygon {return POLYGON_;} +red {return RED_;} +source {return SOURCE_;} +supergalactic {return SUPERGALACTIC_;} +text {return TEXT_;} +version {return VERSION_;} +white {return WHITE_;} +yellow {return YELLOW_;} + +[+-]?{D}+ { // Integer + tnglval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + tnglval->real = atof(yytext); + return REAL; + } + +[+-]?{D}+"."?d | +[+-]?{D}*"."{D}+d { // degrees + yytext[yyleng-1] = '\0'; + tnglval->real = atof(yytext); + return ANGDEGREE; + } + +[+-]?{D}+:{D}+:{D}+"."? | +[+-]?{D}+:{D}+:{D}*"."{D}+ { // Sexagesimal + int ll = yyleng <(TNGBUFSIZE-1)?yyleng:(TNGBUFSIZE-1); + strncpy(tnglval->str,yytext,ll); + tnglval->str[ll] = '\0'; + return SEXSTR; + } + +\"[^\"\n]*\" | +\'[^\'\n]*\' { // Quoted String + int ll = (yyleng-2)<(TNGBUFSIZE-1)?(yyleng-2):(TNGBUFSIZE-1); + strncpy(tnglval->str,yytext+1,yyleng-2); // skip the " " + tnglval->str[ll] = '\0'; // Remove the '"' + return STRING; + } + +\{[^\}\n]*\} { // Quoted String + int ll = (yyleng-2)<(TNGBUFSIZE-1)?(yyleng-2):(TNGBUFSIZE-1); + strncpy(tnglval->str,yytext+1,yyleng-2); // skip the '{' + tnglval->str[ll] = '\0'; // Remove the '}' + return STRING; + } + +[0-9A-Za-z]+ { // General String + int ll = yyleng <(TNGBUFSIZE-1) ? yyleng:(TNGBUFSIZE-1); + strncpy(tnglval->str,yytext,ll); + tnglval->str[ll] = '\0'; + return STRING; + } + +[ \t]+ { // White Spaces + } + +\r\n { // windows line feed + return '\n'; + } + +\\n { // fake line feed + return '\n'; + } + +\n { // linefeed + return '\n'; + } + +<> { // eof + return EOF_; + } + +. { // Else, return the char + return yytext[0]; + } + +%% + +void tngDiscard(int doit) +{ + if (tnglexx) + tnglexx->begin(DISCARD, doit); +} + +void tngFlexLexer::begin(int which, int doit) +{ + BEGIN which; + if (doit) + yyless(0); +} diff --git a/tksao/frame/tngparser.C b/tksao/frame/tngparser.C new file mode 100644 index 0000000..40af2ff --- /dev/null +++ b/tksao/frame/tngparser.C @@ -0,0 +1,2252 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse tngparse +#define yylex tnglex +#define yyerror tngerror +#define yylval tnglval +#define yychar tngchar +#define yydebug tngdebug +#define yynerrs tngnerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + STRING = 260, + ANGDEGREE = 261, + SEXSTR = 262, + EOF_ = 263, + B1950_ = 264, + BACKGROUND_ = 265, + BOX_ = 266, + BLACK_ = 267, + BLUE_ = 268, + CIRCLE_ = 269, + CYAN_ = 270, + DATE_ = 271, + DEBUG_ = 272, + DEGREES_ = 273, + ECLIPTIC_ = 274, + ELLIPSE_ = 275, + FILENAME_ = 276, + FK4_ = 277, + FK4_NO_E_ = 278, + FK5_ = 279, + FORMAT_ = 280, + GALACTIC_ = 281, + GREEN_ = 282, + HELIOECLIPTIC_ = 283, + HMS_ = 284, + ICRS_ = 285, + J2000_ = 286, + LINE_ = 287, + MAGENTA_ = 288, + OFF_ = 289, + ON_ = 290, + PHYSICAL_ = 291, + PIXELS_ = 292, + POINT_ = 293, + POLYGON_ = 294, + RED_ = 295, + SOURCE_ = 296, + SUPERGALACTIC_ = 297, + TEXT_ = 298, + VERSION_ = 299, + WHITE_ = 300, + YELLOW_ = 301 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define STRING 260 +#define ANGDEGREE 261 +#define SEXSTR 262 +#define EOF_ 263 +#define B1950_ 264 +#define BACKGROUND_ 265 +#define BOX_ 266 +#define BLACK_ 267 +#define BLUE_ 268 +#define CIRCLE_ 269 +#define CYAN_ 270 +#define DATE_ 271 +#define DEBUG_ 272 +#define DEGREES_ 273 +#define ECLIPTIC_ 274 +#define ELLIPSE_ 275 +#define FILENAME_ 276 +#define FK4_ 277 +#define FK4_NO_E_ 278 +#define FK5_ 279 +#define FORMAT_ 280 +#define GALACTIC_ 281 +#define GREEN_ 282 +#define HELIOECLIPTIC_ 283 +#define HMS_ 284 +#define ICRS_ 285 +#define J2000_ 286 +#define LINE_ 287 +#define MAGENTA_ 288 +#define OFF_ 289 +#define ON_ 290 +#define PHYSICAL_ 291 +#define PIXELS_ 292 +#define POINT_ 293 +#define POLYGON_ 294 +#define RED_ 295 +#define SOURCE_ 296 +#define SUPERGALACTIC_ 297 +#define TEXT_ 298 +#define VERSION_ 299 +#define WHITE_ 300 +#define YELLOW_ 301 + + + + +/* Copy the first part of user declarations. */ +#line 10 "frame/tngparser.Y" + +#define YYDEBUG 1 + +#define FITSPTR (fr->findFits()) +#define DISCARD_(x) {yyclearin; tngDiscard(x);} + +#include +#include +#include + +#include "base.h" +#include "fitsimage.h" +#include "basemarker.h" + +#undef yyFlexLexer +#define yyFlexLexer tngFlexLexer +#include + +extern int tnglex(void*, tngFlexLexer*); +extern void tngerror(Base*, tngFlexLexer*, const char*); +extern void tngDiscard(int); + +static Coord::CoordSystem globalSystem; +static Coord::SkyFrame globalSky; +static Coord::CoordSystem localSystem; +static Coord::SkyFrame localSky; + +static unsigned short globalProps; +static unsigned short localProps; + +static char globalColor[16]; +static char localColor[16]; + +static int dash[] = {8,3}; + +static char globalFont[32]; + +static char globalText[80]; +static char localText[80]; + +static char localComment[80]; + +static List polylist; +static List taglist; +static List cblist; + +static void setProps(unsigned short* props, unsigned short prop, int value); +static Coord::CoordSystem checkWCSSystem(); +static Coord::SkyFrame checkWCSSky(); + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 61 "frame/tngparser.Y" +{ +#define TNGBUFSIZE 2048 + double real; + int integer; + char str[TNGBUFSIZE]; + double vector[3]; +} +/* Line 193 of yacc.c. */ +#line 255 "frame/tngparser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 268 "frame/tngparser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 155 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 56 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 33 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 85 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 148 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 301 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 47, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 54, 2, 2, 2, 2, + 50, 51, 2, 52, 49, 53, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 55, 48, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 6, 10, 13, 14, 17, 19, 23, + 25, 27, 29, 31, 33, 35, 37, 39, 40, 42, + 43, 45, 46, 48, 49, 51, 53, 55, 57, 61, + 63, 67, 71, 75, 77, 79, 81, 83, 85, 87, + 89, 91, 93, 95, 96, 97, 98, 100, 102, 110, + 120, 130, 138, 144, 145, 154, 155, 162, 166, 168, + 170, 175, 176, 182, 183, 189, 190, 194, 195, 198, + 201, 204, 207, 210, 213, 216, 219, 222, 225, 226, + 230, 233, 236, 238, 243, 244 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 57, 0, -1, 73, 58, -1, 58, 59, 60, -1, + 59, 60, -1, -1, 17, 62, -1, 44, -1, 74, + 75, 76, -1, 81, -1, 47, -1, 48, -1, 8, + -1, 4, -1, 3, -1, 35, -1, 34, -1, -1, + 49, -1, -1, 50, -1, -1, 51, -1, -1, 67, + -1, 61, -1, 6, -1, 61, -1, 61, 63, 61, + -1, 7, -1, 70, 63, 70, -1, 61, 63, 61, + -1, 6, 63, 6, -1, 22, -1, 9, -1, 23, + -1, 24, -1, 31, -1, 30, -1, 26, -1, 42, + -1, 19, -1, 28, -1, -1, -1, -1, 52, -1, + 53, -1, 14, 64, 71, 63, 68, 65, 85, -1, + 20, 64, 71, 63, 69, 63, 66, 65, 85, -1, + 11, 64, 71, 63, 69, 63, 66, 65, 85, -1, + 32, 64, 71, 63, 71, 65, 85, -1, 38, 64, + 71, 65, 85, -1, -1, 43, 64, 71, 63, 5, + 65, 77, 85, -1, -1, 39, 78, 64, 79, 65, + 85, -1, 79, 63, 80, -1, 80, -1, 71, -1, + 54, 25, 55, 87, -1, -1, 54, 21, 55, 82, + 5, -1, -1, 54, 16, 55, 83, 5, -1, -1, + 54, 84, 5, -1, -1, 54, 45, -1, 54, 12, + -1, 54, 40, -1, 54, 27, -1, 54, 13, -1, + 54, 15, -1, 54, 33, -1, 54, 46, -1, 54, + 41, -1, 54, 10, -1, -1, 54, 86, 5, -1, + 29, 88, -1, 18, 88, -1, 37, -1, 37, 50, + 36, 51, -1, -1, 50, 72, 51, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 130, 130, 133, 134, 137, 138, 139, 140, 141, + 144, 145, 146, 149, 150, 153, 154, 157, 158, 161, + 162, 165, 166, 169, 170, 173, 174, 177, 180, 189, + 192, 206, 213, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 235, 249, 265, 266, 267, 270, 276, + 283, 290, 297, 302, 302, 308, 308, 314, 315, 318, + 321, 322, 322, 323, 323, 324, 324, 327, 328, 329, + 330, 331, 332, 333, 334, 335, 336, 341, 346, 346, + 349, 350, 351, 352, 356, 360 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "INT", "REAL", "STRING", "ANGDEGREE", + "SEXSTR", "EOF_", "B1950_", "BACKGROUND_", "BOX_", "BLACK_", "BLUE_", + "CIRCLE_", "CYAN_", "DATE_", "DEBUG_", "DEGREES_", "ECLIPTIC_", + "ELLIPSE_", "FILENAME_", "FK4_", "FK4_NO_E_", "FK5_", "FORMAT_", + "GALACTIC_", "GREEN_", "HELIOECLIPTIC_", "HMS_", "ICRS_", "J2000_", + "LINE_", "MAGENTA_", "OFF_", "ON_", "PHYSICAL_", "PIXELS_", "POINT_", + "POLYGON_", "RED_", "SOURCE_", "SUPERGALACTIC_", "TEXT_", "VERSION_", + "WHITE_", "YELLOW_", "'\\n'", "';'", "','", "'('", "')'", "'+'", "'-'", + "'#'", "':'", "$accept", "start", "commands", "command", "terminator", + "numeric", "debug", "sp", "bp", "ep", "optangle", "angle", "value", + "vvalue", "sexagesimal", "coord", "skyFrame", "initGlobal", "initLocal", + "include", "shape", "@1", "@2", "polyNodes", "polyNode", + "generalComment", "@3", "@4", "@5", "shapeComment", "@6", "tngFormat", + "tngWCS", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 10, 59, 44, + 40, 41, 43, 45, 35, 58 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 56, 57, 58, 58, 59, 59, 59, 59, 59, + 60, 60, 60, 61, 61, 62, 62, 63, 63, 64, + 64, 65, 65, 66, 66, 67, 67, 68, 69, 70, + 71, 71, 71, 72, 72, 72, 72, 72, 72, 72, + 72, 72, 72, 73, 74, 75, 75, 75, 76, 76, + 76, 76, 76, 77, 76, 78, 76, 79, 79, 80, + 81, 82, 81, 83, 81, 84, 81, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 86, 85, + 87, 87, 87, 87, 88, 88 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 2, 3, 2, 0, 2, 1, 3, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 1, 1, 1, 3, 1, + 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 1, 1, 7, 9, + 9, 7, 5, 0, 8, 0, 6, 3, 1, 1, + 4, 0, 5, 0, 5, 0, 3, 0, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 0, 3, + 2, 2, 1, 4, 0, 3 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 43, 0, 44, 1, 0, 7, 65, 44, 0, 45, + 9, 16, 15, 6, 0, 0, 0, 0, 0, 12, + 10, 11, 4, 46, 47, 0, 63, 61, 0, 66, + 3, 19, 19, 19, 19, 19, 55, 19, 8, 0, + 0, 84, 84, 82, 60, 20, 0, 0, 0, 0, + 0, 19, 0, 64, 62, 0, 81, 80, 0, 14, + 13, 17, 29, 17, 17, 17, 17, 17, 17, 21, + 0, 17, 34, 41, 33, 35, 36, 39, 42, 38, + 37, 40, 0, 0, 18, 0, 0, 0, 0, 0, + 0, 0, 22, 67, 59, 17, 58, 0, 85, 83, + 32, 31, 30, 17, 17, 27, 21, 17, 21, 78, + 52, 0, 67, 21, 0, 23, 67, 23, 67, 77, + 69, 72, 73, 71, 74, 70, 76, 68, 75, 0, + 57, 56, 53, 28, 26, 25, 21, 24, 48, 21, + 51, 79, 67, 67, 67, 54, 50, 49 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 1, 7, 8, 22, 63, 13, 85, 46, 93, + 136, 137, 106, 104, 64, 94, 82, 2, 9, 25, + 38, 142, 51, 95, 96, 10, 40, 39, 17, 110, + 129, 44, 56 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -108 +static const yytype_int8 yypact[] = +{ + -108, 2, -5, -108, -21, -108, 67, 0, -7, -46, + -108, -108, -108, -108, -45, -30, -17, 40, -7, -108, + -108, -108, -108, -108, -108, 105, -108, -108, -14, -108, + -108, -4, -4, -4, -4, -4, -108, -4, -108, 45, + 46, 3, 3, 11, -108, -108, 127, 127, 127, 127, + 127, -4, 127, -108, -108, 87, -108, -108, 16, -108, + -108, 15, -108, 15, 15, 15, 15, 15, 15, 14, + 127, 15, -108, -108, -108, -108, -108, -108, -108, -108, + -108, -108, 17, 18, -108, 70, 29, 78, 29, 29, + 29, 127, -108, 32, -108, 8, -108, 82, -108, -108, + -108, -108, -108, 15, 15, -108, 14, 15, 14, 62, + -108, 127, 32, 14, 29, 117, 32, 117, 32, -108, + -108, -108, -108, -108, -108, -108, -108, -108, -108, 85, + -108, -108, -108, -108, -108, -108, 14, -108, -108, 14, + -108, -108, 32, 32, 32, -108, -108, -108 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -108, -108, -108, 84, 75, 38, -108, -37, 47, -35, + -23, -108, -108, 7, 12, -28, -108, -108, -108, -108, + -108, -108, -108, -108, -11, -108, -108, -108, -108, -107, + -108, -108, 63 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -22 +static const yytype_int16 yytable[] = +{ + -2, 19, 3, -5, 41, 131, 23, 24, -5, 138, + 26, 140, 4, 11, 12, 42, -21, 4, 65, 66, + 67, 68, 69, 43, 71, 27, 86, 87, 88, 89, + 90, 91, 59, 60, 97, 145, 146, 147, 28, 5, + 20, 21, -5, -5, 5, 29, 45, -5, -5, 6, + 53, 54, 83, 55, 6, -21, -21, 84, 111, 92, + 112, 58, -21, 108, 84, 92, 114, 115, 98, 99, + 117, 116, 119, 118, 120, 121, 100, 122, 132, 47, + 48, 49, 50, 14, 52, 62, 109, 113, 15, 123, + 141, 18, 16, 30, 139, 124, 72, 107, 70, 102, + 130, 143, 125, 126, 144, 57, 73, 127, 128, 74, + 75, 76, 0, 77, 0, 78, 31, 79, 80, 32, + 59, 60, 0, 134, 101, 33, 103, 105, 103, 81, + 59, 60, 0, 61, 62, 0, 0, 34, 0, 0, + 0, 0, 0, 35, 36, 0, 0, 0, 37, 0, + 0, 0, 133, 135, 0, 135 +}; + +static const yytype_int16 yycheck[] = +{ + 0, 8, 0, 8, 18, 112, 52, 53, 8, 116, + 55, 118, 17, 34, 35, 29, 8, 17, 46, 47, + 48, 49, 50, 37, 52, 55, 63, 64, 65, 66, + 67, 68, 3, 4, 71, 142, 143, 144, 55, 44, + 47, 48, 47, 48, 44, 5, 50, 47, 48, 54, + 5, 5, 36, 50, 54, 47, 48, 49, 95, 51, + 95, 50, 54, 91, 49, 51, 103, 104, 51, 51, + 107, 106, 10, 108, 12, 13, 6, 15, 113, 32, + 33, 34, 35, 16, 37, 7, 54, 5, 21, 27, + 5, 7, 25, 18, 117, 33, 9, 90, 51, 87, + 111, 136, 40, 41, 139, 42, 19, 45, 46, 22, + 23, 24, -1, 26, -1, 28, 11, 30, 31, 14, + 3, 4, -1, 6, 86, 20, 88, 89, 90, 42, + 3, 4, -1, 6, 7, -1, -1, 32, -1, -1, + -1, -1, -1, 38, 39, -1, -1, -1, 43, -1, + -1, -1, 114, 115, -1, 117 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 57, 73, 0, 17, 44, 54, 58, 59, 74, + 81, 34, 35, 62, 16, 21, 25, 84, 59, 8, + 47, 48, 60, 52, 53, 75, 55, 55, 55, 5, + 60, 11, 14, 20, 32, 38, 39, 43, 76, 83, + 82, 18, 29, 37, 87, 50, 64, 64, 64, 64, + 64, 78, 64, 5, 5, 50, 88, 88, 50, 3, + 4, 6, 7, 61, 70, 71, 71, 71, 71, 71, + 64, 71, 9, 19, 22, 23, 24, 26, 28, 30, + 31, 42, 72, 36, 49, 63, 63, 63, 63, 63, + 63, 63, 51, 65, 71, 79, 80, 63, 51, 51, + 6, 61, 70, 61, 69, 61, 68, 69, 71, 54, + 85, 63, 65, 5, 63, 63, 65, 63, 65, 10, + 12, 13, 15, 27, 33, 40, 41, 45, 46, 86, + 80, 85, 65, 61, 6, 61, 66, 67, 85, 66, + 85, 5, 77, 65, 65, 85, 85, 85 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (fr, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, fr, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, tngFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + tngFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (fr); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, tngFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + tngFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Base* fr, tngFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, fr, ll) + YYSTYPE *yyvsp; + int yyrule; + Base* fr; + tngFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , fr, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, fr, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Base* fr, tngFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, fr, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + Base* fr; + tngFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (fr); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (Base* fr, tngFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (Base* fr, tngFlexLexer* ll) +#else +int +yyparse (fr, ll) + Base* fr; + tngFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 7: +#line 139 "frame/tngparser.Y" + {cerr << "SAOtng" << endl;;} + break; + + case 12: +#line 146 "frame/tngparser.Y" + {YYACCEPT;;} + break; + + case 13: +#line 149 "frame/tngparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 14: +#line 150 "frame/tngparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].integer);;} + break; + + case 15: +#line 153 "frame/tngparser.Y" + {yydebug=1;;} + break; + + case 16: +#line 154 "frame/tngparser.Y" + {yydebug=0;;} + break; + + case 23: +#line 169 "frame/tngparser.Y" + {(yyval.real) = 0;;} + break; + + case 24: +#line 170 "frame/tngparser.Y" + {(yyval.real) = (yyvsp[(1) - (1)].real);;} + break; + + case 25: +#line 173 "frame/tngparser.Y" + {(yyval.real) = degToRad((yyvsp[(1) - (1)].real));;} + break; + + case 26: +#line 174 "frame/tngparser.Y" + {(yyval.real) = degToRad((yyvsp[(1) - (1)].real));;} + break; + + case 27: +#line 177 "frame/tngparser.Y" + {(yyval.real) = FITSPTR->mapLenToRef((yyvsp[(1) - (1)].real),Coord::IMAGE);;} + break; + + case 28: +#line 181 "frame/tngparser.Y" + { + Vector r = FITSPTR->mapLenToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), Coord::IMAGE); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 29: +#line 189 "frame/tngparser.Y" + {(yyval.real) = parseSEXStr((yyvsp[(1) - (1)].str));;} + break; + + case 30: +#line 193 "frame/tngparser.Y" + { + Vector r; + Coord::CoordSystem sys = checkWCSSystem(); + Coord::SkyFrame sky = checkWCSSky(); + if (sky == Coord::GALACTIC || sky == Coord::ECLIPTIC) + r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), sys, sky); + else + r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real)*360./24.,(yyvsp[(3) - (3)].real)), sys, sky); + + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 31: +#line 207 "frame/tngparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), localSystem, localSky); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 32: +#line 214 "frame/tngparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)), + checkWCSSystem(), checkWCSSky()); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 33: +#line 223 "frame/tngparser.Y" + {(yyval.integer) = Coord::FK4;;} + break; + + case 34: +#line 224 "frame/tngparser.Y" + {(yyval.integer) = Coord::FK4;;} + break; + + case 35: +#line 225 "frame/tngparser.Y" + {(yyval.integer) = Coord::FK4_NO_E;;} + break; + + case 36: +#line 226 "frame/tngparser.Y" + {(yyval.integer) = Coord::FK5;;} + break; + + case 37: +#line 227 "frame/tngparser.Y" + {(yyval.integer) = Coord::FK5;;} + break; + + case 38: +#line 228 "frame/tngparser.Y" + {(yyval.integer) = Coord::ICRS;;} + break; + + case 39: +#line 229 "frame/tngparser.Y" + {(yyval.integer) = Coord::GALACTIC;;} + break; + + case 40: +#line 230 "frame/tngparser.Y" + {(yyval.integer) = Coord::SUPERGALACTIC;;} + break; + + case 41: +#line 231 "frame/tngparser.Y" + {(yyval.integer) = Coord::ECLIPTIC;;} + break; + + case 42: +#line 232 "frame/tngparser.Y" + {(yyval.integer) = Coord::HELIOECLIPTIC;;} + break; + + case 43: +#line 235 "frame/tngparser.Y" + { + // global properties + globalSystem = Coord::IMAGE; + globalSky = Coord::FK5; + globalProps = + Marker::SELECT | Marker::EDIT | Marker::MOVE | + Marker::ROTATE | Marker::DELETE | Marker::HIGHLITE | + Marker::INCLUDE | Marker::SOURCE; + strcpy(globalColor,"green"); + strcpy(globalFont,"helvetica 10 normal roman"); + strcpy(globalText,""); + ;} + break; + + case 44: +#line 249 "frame/tngparser.Y" + { + // reset maperr flag + maperr =0; + + // global properties + localSystem = globalSystem; + localSky = globalSky; + localProps = globalProps; + strcpy(localColor,globalColor); + strcpy(localText,globalText); + strcpy(localComment,""); + + strcpy(globalText,""); + ;} + break; + + case 45: +#line 265 "frame/tngparser.Y" + {setProps(&localProps, Marker::INCLUDE, 1);;} + break; + + case 46: +#line 266 "frame/tngparser.Y" + {setProps(&localProps, Marker::INCLUDE, 1);;} + break; + + case 47: +#line 267 "frame/tngparser.Y" + {setProps(&localProps, Marker::INCLUDE, 0);;} + break; + + case 48: +#line 271 "frame/tngparser.Y" + {fr->createCircleCmd(Vector((yyvsp[(3) - (7)].vector)), + (yyvsp[(5) - (7)].real), + localColor,dash,1,globalFont,localText, + localProps,localComment,taglist,cblist);;} + break; + + case 49: +#line 277 "frame/tngparser.Y" + {fr->createEllipseCmd(Vector((yyvsp[(3) - (9)].vector)), + Vector((yyvsp[(5) - (9)].vector)), + (yyvsp[(7) - (9)].real), + localColor,dash,1,globalFont,localText, + localProps,localComment,taglist,cblist);;} + break; + + case 50: +#line 284 "frame/tngparser.Y" + {fr->createBoxCmd(Vector((yyvsp[(3) - (9)].vector)), + Vector((yyvsp[(5) - (9)].vector)), + (yyvsp[(7) - (9)].real), + localColor,dash,1,globalFont,localText, + localProps,localComment,taglist,cblist);;} + break; + + case 51: +#line 291 "frame/tngparser.Y" + {fr->createLineCmd(Vector((yyvsp[(3) - (7)].vector)), + Vector((yyvsp[(5) - (7)].vector)), + 0,0, + localColor,dash,1,globalFont,localText, + localProps,localComment,taglist,cblist);;} + break; + + case 52: +#line 298 "frame/tngparser.Y" + {fr->createPointCmd(Vector((yyvsp[(3) - (5)].vector)), Point::BOXCIRCLE, POINTSIZE, + localColor,dash,1,globalFont,localText, + localProps,localComment,taglist,cblist);;} + break; + + case 53: +#line 302 "frame/tngparser.Y" + {strncpy(localText,(yyvsp[(5) - (6)].str),80);;} + break; + + case 54: +#line 303 "frame/tngparser.Y" + {fr->createTextCmd(Vector((yyvsp[(3) - (8)].vector)), + 0, 1, + localColor,dash,1,globalFont,localText, + localProps,localComment,taglist,cblist);;} + break; + + case 55: +#line 308 "frame/tngparser.Y" + {polylist.deleteAll();;} + break; + + case 56: +#line 309 "frame/tngparser.Y" + {fr->createPolygonCmd(polylist, + localColor,dash,1,globalFont,localText, + localProps,localComment,taglist,cblist);;} + break; + + case 59: +#line 318 "frame/tngparser.Y" + {polylist.append(new Vertex((yyvsp[(1) - (1)].vector)));;} + break; + + case 61: +#line 322 "frame/tngparser.Y" + {DISCARD_(0);;} + break; + + case 63: +#line 323 "frame/tngparser.Y" + {DISCARD_(0);;} + break; + + case 65: +#line 324 "frame/tngparser.Y" + {DISCARD_(1);;} + break; + + case 66: +#line 324 "frame/tngparser.Y" + {strncpy(globalText,(yyvsp[(3) - (3)].str),80);;} + break; + + case 68: +#line 328 "frame/tngparser.Y" + {strcpy(localColor,"white");;} + break; + + case 69: +#line 329 "frame/tngparser.Y" + {strcpy(localColor,"black");;} + break; + + case 70: +#line 330 "frame/tngparser.Y" + {strcpy(localColor,"red");;} + break; + + case 71: +#line 331 "frame/tngparser.Y" + {strcpy(localColor,"green");;} + break; + + case 72: +#line 332 "frame/tngparser.Y" + {strcpy(localColor,"blue");;} + break; + + case 73: +#line 333 "frame/tngparser.Y" + {strcpy(localColor,"cyan");;} + break; + + case 74: +#line 334 "frame/tngparser.Y" + {strcpy(localColor,"magenta");;} + break; + + case 75: +#line 335 "frame/tngparser.Y" + {strcpy(localColor,"yellow");;} + break; + + case 76: +#line 337 "frame/tngparser.Y" + { + strcpy(localColor,"green"); + setProps(&localProps,Marker::SOURCE,1); + ;} + break; + + case 77: +#line 342 "frame/tngparser.Y" + { + strcpy(localColor,"red"); + setProps(&localProps,Marker::SOURCE,0); + ;} + break; + + case 78: +#line 346 "frame/tngparser.Y" + {DISCARD_(1);;} + break; + + case 79: +#line 346 "frame/tngparser.Y" + {strncpy(localComment,(yyvsp[(3) - (3)].str),80);;} + break; + + case 82: +#line 351 "frame/tngparser.Y" + {globalSystem = localSystem = Coord::IMAGE;;} + break; + + case 83: +#line 352 "frame/tngparser.Y" + {globalSystem = localSystem = Coord::IMAGE;;} + break; + + case 84: +#line 356 "frame/tngparser.Y" + { + globalSystem = localSystem = Coord::WCS; + globalSky = localSky = Coord::FK5; + ;} + break; + + case 85: +#line 361 "frame/tngparser.Y" + { + globalSystem = localSystem = Coord::WCS; + globalSky = localSky = (Coord::SkyFrame)(yyvsp[(2) - (3)].integer); + ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 2007 "frame/tngparser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (fr, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (fr, ll, yymsg); + } + else + { + yyerror (fr, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, fr, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, fr, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (fr, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, fr, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, fr, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 367 "frame/tngparser.Y" + + +static void setProps(unsigned short* props, unsigned short prop, int value) +{ + if (value) + *props |= prop; + else + *props &= ~prop; +} + +static Coord::CoordSystem checkWCSSystem() +{ + switch (localSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::WCS; + default: + return localSystem; + } +} + +static Coord::SkyFrame checkWCSSky() +{ + switch (localSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::FK5; + default: + return localSky; + } +} + diff --git a/tksao/frame/tngparser.H b/tksao/frame/tngparser.H new file mode 100644 index 0000000..864c0e7 --- /dev/null +++ b/tksao/frame/tngparser.H @@ -0,0 +1,156 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + STRING = 260, + ANGDEGREE = 261, + SEXSTR = 262, + EOF_ = 263, + B1950_ = 264, + BACKGROUND_ = 265, + BOX_ = 266, + BLACK_ = 267, + BLUE_ = 268, + CIRCLE_ = 269, + CYAN_ = 270, + DATE_ = 271, + DEBUG_ = 272, + DEGREES_ = 273, + ECLIPTIC_ = 274, + ELLIPSE_ = 275, + FILENAME_ = 276, + FK4_ = 277, + FK4_NO_E_ = 278, + FK5_ = 279, + FORMAT_ = 280, + GALACTIC_ = 281, + GREEN_ = 282, + HELIOECLIPTIC_ = 283, + HMS_ = 284, + ICRS_ = 285, + J2000_ = 286, + LINE_ = 287, + MAGENTA_ = 288, + OFF_ = 289, + ON_ = 290, + PHYSICAL_ = 291, + PIXELS_ = 292, + POINT_ = 293, + POLYGON_ = 294, + RED_ = 295, + SOURCE_ = 296, + SUPERGALACTIC_ = 297, + TEXT_ = 298, + VERSION_ = 299, + WHITE_ = 300, + YELLOW_ = 301 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define STRING 260 +#define ANGDEGREE 261 +#define SEXSTR 262 +#define EOF_ 263 +#define B1950_ 264 +#define BACKGROUND_ 265 +#define BOX_ 266 +#define BLACK_ 267 +#define BLUE_ 268 +#define CIRCLE_ 269 +#define CYAN_ 270 +#define DATE_ 271 +#define DEBUG_ 272 +#define DEGREES_ 273 +#define ECLIPTIC_ 274 +#define ELLIPSE_ 275 +#define FILENAME_ 276 +#define FK4_ 277 +#define FK4_NO_E_ 278 +#define FK5_ 279 +#define FORMAT_ 280 +#define GALACTIC_ 281 +#define GREEN_ 282 +#define HELIOECLIPTIC_ 283 +#define HMS_ 284 +#define ICRS_ 285 +#define J2000_ 286 +#define LINE_ 287 +#define MAGENTA_ 288 +#define OFF_ 289 +#define ON_ 290 +#define PHYSICAL_ 291 +#define PIXELS_ 292 +#define POINT_ 293 +#define POLYGON_ 294 +#define RED_ 295 +#define SOURCE_ 296 +#define SUPERGALACTIC_ 297 +#define TEXT_ 298 +#define VERSION_ 299 +#define WHITE_ 300 +#define YELLOW_ 301 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 61 "frame/tngparser.Y" +{ +#define TNGBUFSIZE 2048 + double real; + int integer; + char str[TNGBUFSIZE]; + double vector[3]; +} +/* Line 1529 of yacc.c. */ +#line 149 "frame/tngparser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/frame/tngparser.Y b/tksao/frame/tngparser.Y new file mode 100644 index 0000000..b3887e1 --- /dev/null +++ b/tksao/frame/tngparser.Y @@ -0,0 +1,397 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {Base* fr} +%lex-param {tngFlexLexer* ll} +%parse-param {tngFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#define FITSPTR (fr->findFits()) +#define DISCARD_(x) {yyclearin; tngDiscard(x);} + +#include +#include +#include + +#include "base.h" +#include "fitsimage.h" +#include "basemarker.h" + +#undef yyFlexLexer +#define yyFlexLexer tngFlexLexer +#include + +extern int tnglex(void*, tngFlexLexer*); +extern void tngerror(Base*, tngFlexLexer*, const char*); +extern void tngDiscard(int); + +static Coord::CoordSystem globalSystem; +static Coord::SkyFrame globalSky; +static Coord::CoordSystem localSystem; +static Coord::SkyFrame localSky; + +static unsigned short globalProps; +static unsigned short localProps; + +static char globalColor[16]; +static char localColor[16]; + +static int dash[] = {8,3}; + +static char globalFont[32]; + +static char globalText[80]; +static char localText[80]; + +static char localComment[80]; + +static List polylist; +static List taglist; +static List cblist; + +static void setProps(unsigned short* props, unsigned short prop, int value); +static Coord::CoordSystem checkWCSSystem(); +static Coord::SkyFrame checkWCSSky(); +%} + +%union { +#define TNGBUFSIZE 2048 + double real; + int integer; + char str[TNGBUFSIZE]; + double vector[3]; +} + +%type numeric + +%type angle +%type optangle +%type value +%type vvalue +%type sexagesimal +%type coord +%type skyFrame + +%token INT +%token REAL +%token STRING + +%token ANGDEGREE + +%token SEXSTR + +%token EOF_ + +%token B1950_ +%token BACKGROUND_ +%token BOX_ +%token BLACK_ +%token BLUE_ +%token CIRCLE_ +%token CYAN_ +%token DATE_ +%token DEBUG_ +%token DEGREES_ +%token ECLIPTIC_ +%token ELLIPSE_ +%token FILENAME_ +%token FK4_ +%token FK4_NO_E_ +%token FK5_ +%token FORMAT_ +%token GALACTIC_ +%token GREEN_ +%token HELIOECLIPTIC_ +%token HMS_ +%token ICRS_ +%token J2000_ +%token LINE_ +%token MAGENTA_ +%token OFF_ +%token ON_ +%token PHYSICAL_ +%token PIXELS_ +%token POINT_ +%token POLYGON_ +%token RED_ +%token SOURCE_ +%token SUPERGALACTIC_ +%token TEXT_ +%token VERSION_ +%token WHITE_ +%token YELLOW_ + +%% + +start : initGlobal commands + ; + +commands: commands command terminator + | command terminator + ; + +command : /* empty */ + | DEBUG_ debug + | VERSION_ {cerr << "SAOtng" << endl;} + | initLocal include shape + | generalComment + ; + +terminator: '\n' + | ';' + | EOF_ {YYACCEPT;} + ; + +numeric : REAL {$$=$1;} + | INT {$$=$1;} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + ; + +sp : /* empty */ + | ',' + ; + +bp : /* empty */ + | '(' + ; + +ep : /* emtpy */ + | ')' + ; + +optangle: /* empty */ {$$ = 0;} + | angle {$$ = $1;} + ; + +angle : numeric {$$ = degToRad($1);} /* assume degree */ + | ANGDEGREE {$$ = degToRad($1);} + ; + +value : numeric {$$ = FITSPTR->mapLenToRef($1,Coord::IMAGE);} + ; + +vvalue : numeric sp numeric + { + Vector r = FITSPTR->mapLenToRef(Vector($1,$3), Coord::IMAGE); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + ; + +sexagesimal: SEXSTR {$$ = parseSEXStr($1);} + ; + +coord : sexagesimal sp sexagesimal + { + Vector r; + Coord::CoordSystem sys = checkWCSSystem(); + Coord::SkyFrame sky = checkWCSSky(); + if (sky == Coord::GALACTIC || sky == Coord::ECLIPTIC) + r = FITSPTR->mapToRef(Vector($1,$3), sys, sky); + else + r = FITSPTR->mapToRef(Vector($1*360./24.,$3), sys, sky); + + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | numeric sp numeric + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), localSystem, localSky); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | ANGDEGREE sp ANGDEGREE + { + Vector r = FITSPTR->mapToRef(Vector($1,$3), + checkWCSSystem(), checkWCSSky()); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + ; + +skyFrame : FK4_ {$$ = Coord::FK4;} + | B1950_ {$$ = Coord::FK4;} + | FK4_NO_E_ {$$ = Coord::FK4_NO_E;} + | FK5_ {$$ = Coord::FK5;} + | J2000_ {$$ = Coord::FK5;} + | ICRS_ {$$ = Coord::ICRS;} + | GALACTIC_ {$$ = Coord::GALACTIC;} + | SUPERGALACTIC_ {$$ = Coord::SUPERGALACTIC;} + | ECLIPTIC_ {$$ = Coord::ECLIPTIC;} + | HELIOECLIPTIC_ {$$ = Coord::HELIOECLIPTIC;} + ; + +initGlobal:{ + // global properties + globalSystem = Coord::IMAGE; + globalSky = Coord::FK5; + globalProps = + Marker::SELECT | Marker::EDIT | Marker::MOVE | + Marker::ROTATE | Marker::DELETE | Marker::HIGHLITE | + Marker::INCLUDE | Marker::SOURCE; + strcpy(globalColor,"green"); + strcpy(globalFont,"helvetica 10 normal roman"); + strcpy(globalText,""); + } + ; + +initLocal : { + // reset maperr flag + maperr =0; + + // global properties + localSystem = globalSystem; + localSky = globalSky; + localProps = globalProps; + strcpy(localColor,globalColor); + strcpy(localText,globalText); + strcpy(localComment,""); + + strcpy(globalText,""); + } + ; + +include : /* empty */ {setProps(&localProps, Marker::INCLUDE, 1);} + | '+' {setProps(&localProps, Marker::INCLUDE, 1);} + | '-' {setProps(&localProps, Marker::INCLUDE, 0);} + ; + +shape : CIRCLE_ bp coord sp value ep shapeComment + {fr->createCircleCmd(Vector($3), + $5, + localColor,dash,1,globalFont,localText, + localProps,localComment,taglist,cblist);} + + | ELLIPSE_ bp coord sp vvalue sp optangle ep shapeComment + {fr->createEllipseCmd(Vector($3), + Vector($5), + $7, + localColor,dash,1,globalFont,localText, + localProps,localComment,taglist,cblist);} + + | BOX_ bp coord sp vvalue sp optangle ep shapeComment + {fr->createBoxCmd(Vector($3), + Vector($5), + $7, + localColor,dash,1,globalFont,localText, + localProps,localComment,taglist,cblist);} + + | LINE_ bp coord sp coord ep shapeComment + {fr->createLineCmd(Vector($3), + Vector($5), + 0,0, + localColor,dash,1,globalFont,localText, + localProps,localComment,taglist,cblist);} + + | POINT_ bp coord ep shapeComment + {fr->createPointCmd(Vector($3), Point::BOXCIRCLE, POINTSIZE, + localColor,dash,1,globalFont,localText, + localProps,localComment,taglist,cblist);} + + | TEXT_ bp coord sp STRING ep {strncpy(localText,$5,80);} shapeComment + {fr->createTextCmd(Vector($3), + 0, 1, + localColor,dash,1,globalFont,localText, + localProps,localComment,taglist,cblist);} + + | POLYGON_ {polylist.deleteAll();} bp polyNodes ep shapeComment + {fr->createPolygonCmd(polylist, + localColor,dash,1,globalFont,localText, + localProps,localComment,taglist,cblist);} + ; + +polyNodes : polyNodes sp polyNode + | polyNode + ; + +polyNode : coord {polylist.append(new Vertex($1));} + ; + +generalComment : '#' FORMAT_ ':' tngFormat + | '#' FILENAME_ ':' {DISCARD_(0);} STRING + | '#' DATE_ ':' {DISCARD_(0);} STRING + | '#' {DISCARD_(1);} STRING {strncpy(globalText,$3,80);} + ; + +shapeComment : /* empty */ + | '#' WHITE_ {strcpy(localColor,"white");} + | '#' BLACK_ {strcpy(localColor,"black");} + | '#' RED_ {strcpy(localColor,"red");} + | '#' GREEN_ {strcpy(localColor,"green");} + | '#' BLUE_ {strcpy(localColor,"blue");} + | '#' CYAN_ {strcpy(localColor,"cyan");} + | '#' MAGENTA_ {strcpy(localColor,"magenta");} + | '#' YELLOW_ {strcpy(localColor,"yellow");} + | '#' SOURCE_ + { + strcpy(localColor,"green"); + setProps(&localProps,Marker::SOURCE,1); + } + | '#' BACKGROUND_ + { + strcpy(localColor,"red"); + setProps(&localProps,Marker::SOURCE,0); + } + | '#' {DISCARD_(1);} STRING {strncpy(localComment,$3,80);} + ; + +tngFormat : HMS_ tngWCS + | DEGREES_ tngWCS + | PIXELS_ {globalSystem = localSystem = Coord::IMAGE;} + | PIXELS_ '(' PHYSICAL_ ')' {globalSystem = localSystem = Coord::IMAGE;} + ; + +tngWCS : /* empty */ + { + globalSystem = localSystem = Coord::WCS; + globalSky = localSky = Coord::FK5; + } + | '(' skyFrame ')' + { + globalSystem = localSystem = Coord::WCS; + globalSky = localSky = (Coord::SkyFrame)$2; + } + ; + +%% + +static void setProps(unsigned short* props, unsigned short prop, int value) +{ + if (value) + *props |= prop; + else + *props &= ~prop; +} + +static Coord::CoordSystem checkWCSSystem() +{ + switch (localSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::WCS; + default: + return localSystem; + } +} + +static Coord::SkyFrame checkWCSSky() +{ + switch (localSystem) { + case Coord::IMAGE: + case Coord::PHYSICAL: + return Coord::FK5; + default: + return localSky; + } +} diff --git a/tksao/frame/vect.C b/tksao/frame/vect.C new file mode 100644 index 0000000..e9e9dff --- /dev/null +++ b/tksao/frame/vect.C @@ -0,0 +1,146 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "vect.h" +#include "fitsimage.h" + +Vect::Vect(Base* p, const Vector& pt, double mag, double ang) + : Line(p, pt, pt) +{ + strcpy(type_,"vector"); + p2 = Vector(mag,0) * Rotate(ang) * FlipY() * Translate(p1); + updateBBox(); +} + +Vect::Vect(Base* p, const Vector& pt, + double mag, double ang, + int arr, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : Line(p, pt, pt, 0, arr, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + strcpy(type_,"vector"); + p2 = Vector(mag,0) * Rotate(ang) * FlipY() * Translate(p1); + updateBBox(); +} + +Vect::Vect(Base* p, const Vector& ptr1, + const Vector& ptr2, + int arr, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb) + : Line(p, ptr1, ptr2, 0, arr, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) +{ + strcpy(type_,"vector"); +} + +void Vect::setPoints(const Vector& pt, double mag, double ang) +{ + p1 = pt; + p2 = Vector(mag,0) * Rotate(ang) * FlipY() * Translate(p1); + updateBBox(); + + doCallBack(CallBack::EDITCB); +} + +// list + +void Vect::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format, int conj, int strip) +{ + if (!strip) { + FitsImage* ptr = parent->findFits(sys,center); + listPre(str, sys, sky, ptr, strip, 1); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + listNonCel(ptr, str, sys); + break; + default: + if (ptr->hasWCSCel(sys)) { + double rr = ptr->mapLenFromRef((p2-p1).length(),sys,Coord::ARCSEC); + double aa = parent->mapAngleFromRef((p2-p1).angle(),sys,sky); + switch (format) { + case Coord::DEGREES: + { + Vector v1 = ptr->mapFromRef(p1,sys,sky); + str << type_ << '(' << setprecision(10) << v1 << ',' + << setprecision(3) << fixed << rr << '"' << ','; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(aa) << ')'; + } + break; + case Coord::SEXAGESIMAL: + listRADEC(ptr,p1,sys,sky,format); + str << type_ << '(' << ra << ',' << dec << ',' + << setprecision(3) << fixed << rr << '"' << ','; + str.unsetf(ios_base::floatfield); + str << setprecision(8) << radToDeg(aa) << ')'; + break; + } + } + else + listNonCel(ptr, str, sys); + } + + if (conj) + str << " ||"; + + str << " vector=" << p2Arrow; + listProperties(str, 0); + } +} + +void Vect::listNonCel(FitsImage* ptr, ostream& str, Coord::CoordSystem sys) +{ + Vector v1 = ptr->mapFromRef(p1,sys); + double rr = ptr->mapLenFromRef((p2-p1).length(),sys); + double aa = parent->mapAngleFromRef((p2-p1).angle(),sys); + str << type_ << '(' << setprecision(8) << v1 << ',' + << rr << ',' << radToDeg(aa) << ')'; +} + +void Vect::listXML(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, + Coord::SkyFormat format) +{ + FitsImage* ptr = parent->findFits(sys,center); + double rr = ptr->mapLenFromRef((p2-p1).length(),sys,Coord::ARCSEC); + + XMLRowInit(); + XMLRow(XMLSHAPE,type_); + + XMLRowPoint(ptr,sys,sky,format,p1); + + switch (sys) { + case Coord::IMAGE: + case Coord::PHYSICAL: + case Coord::DETECTOR: + case Coord::AMPLIFIER: + XMLRow(XMLR,rr,8); + break; + default: + if (ptr->hasWCS(sys)) { + if (ptr->hasWCSCel(sys)) + XMLRowARCSEC(XMLR,rr); + else + XMLRow(XMLR,rr,8); + } + break; + } + + XMLRowAng(sys,sky); + XMLRow(XMLPARAM,p2Arrow); + + XMLRowProps(ptr,sys); + XMLRowEnd(str); +} diff --git a/tksao/frame/vect.h b/tksao/frame/vect.h new file mode 100644 index 0000000..294fe5b --- /dev/null +++ b/tksao/frame/vect.h @@ -0,0 +1,44 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __vect_h__ +#define __vect_h__ + +#include "line.h" + +class Vect : public Line { + protected: + void listNonCel(FitsImage*, ostream&, Coord::CoordSystem); + +public: + Vect(Base* p, const Vector& pt, + double mag, double ang); + Vect(Base* p, const Vector& pt, + double mag, double ang, + int arr, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + Vect(Base* p, const Vector& ptr1, + const Vector& ptr2, + int arr, + const char* clr, int* dsh, + int wth, const char* fnt, const char* txt, + unsigned short prop, const char* cmt, + const List& tg, const List& cb); + + virtual Marker* dup() {return new Vect(*this);} + + int getArrow() {return p2Arrow;} + void setArrow(int w) {p2Arrow = w ? 1 : 0;} + + void setPoints(const Vector& pt, double mag, double ang); + + void list(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int, int); + void listXML(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); + void listSAOtng(ostream&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, int) {} +}; + +#endif diff --git a/tksao/frame/xml.h b/tksao/frame/xml.h new file mode 100644 index 0000000..4439226 --- /dev/null +++ b/tksao/frame/xml.h @@ -0,0 +1,12 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __xml_h__ +#define __xml_h__ + +#define XMLNUMCOL 34 + +enum XMLColName {XMLSHAPE,XMLX,XMLY,XMLXV,XMLYV,XMLR,XMLR2,XMLRV,XMLRV2,XMLANG,XMLANGV,XMLTILE,XMLCOLOR,XMLWIDTH,XMLTEXT,XMLFONT,XMLSELECT,XMLHIGHLITE,XMLEDIT,XMLMOVE,XMLROTATE,XMLDELETE,XMLFIXED,XMLINCLUDE,XMLSOURCE,XMLDASH,XMLDASHLIST,XMLTAG,XMLPARAM,XMLPARAM2,XMLPARAM3,XMLPARAM4,XMLPARAM5,XMLCOMMENT}; + +#endif diff --git a/tksao/frame/xylex.C b/tksao/frame/xylex.C new file mode 100644 index 0000000..855eb53 --- /dev/null +++ b/tksao/frame/xylex.C @@ -0,0 +1,2047 @@ +#line 2 "frame/xylex.C" + +#line 4 "frame/xylex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer xyFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *xyalloc (yy_size_t ); +void *xyrealloc (void *,yy_size_t ); +void xyfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 61 +#define YY_END_OF_BUFFER 62 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[197] = + { 0, + 0, 0, 62, 60, 59, 60, 57, 60, 59, 60, + 48, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 58, 57, 0, + 48, 50, 49, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 0, 0, 0, 0, 0, 49, + 0, 0, 0, 3, 0, 0, 0, 7, 9, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 21, + 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, + + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 0, 51, 0, 0, + 0, 0, 0, 2, 4, 0, 0, 0, 0, 0, + 13, 14, 0, 0, 0, 0, 52, 51, 0, 0, + 55, 0, 0, 53, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 56, 54, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 20, 0, 5, 6, 8, + 10, 0, 18, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 11, 19, 0 + + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, + 1, 1, 5, 6, 7, 8, 1, 9, 10, 11, + 12, 13, 14, 12, 12, 12, 15, 16, 6, 1, + 1, 1, 1, 1, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 1, 1, 1, 1, 1, 1, 43, 44, 45, 46, + + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 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, 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, + 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, 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, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[69] = + { 0, + 1, 2, 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, 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, + 1, 1, 1, 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[198] = + { 0, + 0, 0, 303, 615, 615, 300, 0, 61, 615, 68, + 76, 64, 291, 75, 74, 79, 72, 84, 81, 84, + 289, 73, 84, 81, 70, 87, 90, 615, 0, 132, + 0, 139, 152, 165, 178, 191, 198, 78, 224, 91, + 179, 84, 102, 127, 128, 123, 141, 212, 136, 146, + 615, 128, 182, 182, 182, 215, 222, 235, 242, 256, + 263, 230, 205, 615, 222, 239, 236, 211, 615, 245, + 238, 244, 257, 163, 256, 615, 247, 262, 256, 302, + 284, 301, 363, 371, 379, 370, 162, 373, 378, 366, + 369, 381, 370, 615, 381, 161, 384, 379, 371, 381, + + 615, 615, 615, 615, 615, 615, 615, 615, 615, 615, + 615, 615, 615, 615, 615, 615, 615, 615, 615, 615, + 615, 615, 615, 615, 615, 615, 398, 425, 405, 433, + 440, 448, 442, 615, 615, 429, 430, 436, 433, 449, + 615, 615, 454, 453, 450, 443, 466, 492, 501, 508, + 615, 515, 542, 615, 457, 501, 508, 111, 509, 516, + 509, 521, 522, 510, 615, 615, 520, 508, 525, 524, + 527, 519, 615, 520, 521, 615, 544, 615, 615, 615, + 615, 554, 615, 563, 615, 549, 563, 547, 548, 560, + 561, 568, 569, 615, 615, 615, 116 + + } ; + +static yyconst flex_int16_t yy_def[198] = + { 0, + 196, 1, 196, 196, 196, 196, 197, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 197, 196, + 11, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 0, 196 + + } ; + +static yyconst flex_int16_t yy_nxt[684] = + { 0, + 4, 5, 6, 7, 8, 9, 8, 10, 11, 11, + 11, 11, 11, 11, 11, 4, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 4, 22, 4, 4, + 23, 24, 4, 4, 25, 4, 4, 26, 27, 4, + 4, 4, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 4, 22, 4, 4, 23, 24, 4, 4, + 25, 4, 4, 26, 27, 4, 4, 4, 30, 31, + 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, + 32, 32, 32, 33, 31, 31, 31, 31, 31, 31, + 31, 34, 38, 40, 41, 35, 36, 42, 43, 37, + + 44, 45, 46, 49, 52, 50, 53, 54, 55, 62, + 64, 67, 47, 51, 68, 69, 29, 170, 38, 40, + 41, 35, 36, 42, 43, 37, 44, 45, 46, 49, + 52, 50, 53, 54, 55, 62, 64, 67, 47, 51, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 70, 71, 72, 73, 75, 56, + 32, 32, 32, 32, 32, 32, 32, 76, 77, 142, + 134, 96, 36, 57, 57, 57, 57, 57, 57, 57, + 70, 71, 72, 73, 75, 56, 58, 58, 58, 58, + 58, 58, 58, 76, 77, 59, 65, 59, 36, 60, + + 60, 60, 60, 60, 60, 60, 61, 61, 61, 61, + 61, 61, 61, 78, 66, 79, 80, 91, 87, 81, + 74, 81, 65, 82, 82, 82, 82, 82, 82, 82, + 57, 57, 57, 57, 57, 57, 57, 83, 63, 78, + 66, 79, 80, 58, 58, 58, 58, 58, 58, 58, + 60, 60, 60, 60, 60, 60, 60, 86, 88, 89, + 90, 92, 93, 84, 60, 60, 60, 60, 60, 60, + 60, 61, 61, 61, 61, 61, 61, 61, 94, 95, + 97, 98, 99, 86, 88, 89, 90, 92, 93, 84, + 100, 85, 82, 82, 82, 82, 82, 82, 82, 48, + + 39, 28, 196, 196, 94, 95, 97, 98, 99, 82, + 82, 82, 82, 82, 82, 82, 100, 85, 101, 102, + 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 123, 124, 125, 126, 101, 102, 103, 104, 105, 106, + 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, + 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, + 127, 128, 128, 128, 128, 128, 128, 128, 129, 130, + 130, 130, 130, 130, 130, 130, 131, 132, 132, 132, + 132, 132, 132, 132, 133, 135, 136, 137, 138, 139, + + 140, 141, 143, 144, 145, 146, 147, 147, 147, 147, + 147, 147, 147, 149, 149, 149, 149, 149, 149, 149, + 133, 135, 136, 137, 138, 139, 140, 141, 143, 144, + 145, 146, 148, 128, 128, 128, 128, 128, 128, 128, + 150, 130, 130, 130, 130, 130, 130, 130, 152, 152, + 152, 152, 152, 152, 152, 153, 132, 132, 132, 132, + 132, 132, 132, 155, 156, 157, 158, 151, 159, 160, + 161, 162, 163, 164, 147, 147, 147, 147, 147, 147, + 147, 167, 154, 196, 196, 196, 196, 196, 196, 155, + 156, 157, 158, 151, 159, 160, 161, 162, 163, 164, + + 147, 147, 147, 147, 147, 147, 147, 167, 154, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 152, 152, 152, 152, 152, 152, 152, + 196, 168, 169, 171, 172, 165, 173, 174, 175, 176, + 177, 178, 151, 179, 180, 181, 182, 183, 184, 166, + 152, 152, 152, 152, 152, 152, 152, 168, 169, 171, + 172, 165, 173, 174, 175, 176, 177, 178, 151, 179, + 180, 181, 182, 183, 184, 166, 154, 185, 186, 187, + 188, 189, 190, 191, 192, 193, 194, 195, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + + 196, 196, 154, 185, 186, 187, 188, 189, 190, 191, + 192, 193, 194, 195, 3, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196 + } ; + +static yyconst flex_int16_t yy_chk[684] = + { 0, + 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, 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, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 8, 8, + 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, + 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 12, 14, 15, 11, 11, 16, 17, 11, + + 18, 19, 20, 22, 24, 23, 25, 26, 27, 38, + 40, 42, 20, 23, 43, 43, 197, 158, 12, 14, + 15, 11, 11, 16, 17, 11, 18, 19, 20, 22, + 24, 23, 25, 26, 27, 38, 40, 42, 20, 23, + 30, 30, 30, 30, 30, 30, 30, 32, 32, 32, + 32, 32, 32, 32, 44, 45, 46, 47, 49, 32, + 33, 33, 33, 33, 33, 33, 33, 50, 52, 96, + 87, 74, 33, 34, 34, 34, 34, 34, 34, 34, + 44, 45, 46, 47, 49, 32, 35, 35, 35, 35, + 35, 35, 35, 50, 52, 36, 41, 36, 33, 36, + + 36, 36, 36, 36, 36, 36, 37, 37, 37, 37, + 37, 37, 37, 53, 41, 54, 55, 68, 63, 56, + 48, 56, 41, 56, 56, 56, 56, 56, 56, 56, + 57, 57, 57, 57, 57, 57, 57, 57, 39, 53, + 41, 54, 55, 58, 58, 58, 58, 58, 58, 58, + 59, 59, 59, 59, 59, 59, 59, 62, 65, 66, + 67, 70, 71, 58, 60, 60, 60, 60, 60, 60, + 60, 61, 61, 61, 61, 61, 61, 61, 72, 73, + 75, 77, 78, 62, 65, 66, 67, 70, 71, 58, + 79, 61, 81, 81, 81, 81, 81, 81, 81, 21, + + 13, 6, 3, 0, 72, 73, 75, 77, 78, 82, + 82, 82, 82, 82, 82, 82, 79, 61, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 83, 83, 83, 83, 83, 83, 83, 83, 84, 84, + 84, 84, 84, 84, 84, 84, 85, 85, 85, 85, + 85, 85, 85, 85, 86, 88, 89, 90, 91, 92, + + 93, 95, 97, 98, 99, 100, 127, 127, 127, 127, + 127, 127, 127, 129, 129, 129, 129, 129, 129, 129, + 86, 88, 89, 90, 91, 92, 93, 95, 97, 98, + 99, 100, 128, 128, 128, 128, 128, 128, 128, 128, + 130, 130, 130, 130, 130, 130, 130, 130, 131, 131, + 131, 131, 131, 131, 131, 132, 132, 132, 132, 132, + 132, 132, 132, 133, 136, 137, 138, 130, 139, 140, + 143, 144, 145, 146, 147, 147, 147, 147, 147, 147, + 147, 155, 132, 0, 0, 0, 0, 0, 0, 133, + 136, 137, 138, 130, 139, 140, 143, 144, 145, 146, + + 148, 148, 148, 148, 148, 148, 148, 155, 132, 149, + 149, 149, 149, 149, 149, 149, 150, 150, 150, 150, + 150, 150, 150, 152, 152, 152, 152, 152, 152, 152, + 0, 156, 157, 159, 160, 149, 161, 162, 163, 164, + 167, 168, 150, 169, 170, 171, 172, 174, 175, 152, + 153, 153, 153, 153, 153, 153, 153, 156, 157, 159, + 160, 149, 161, 162, 163, 164, 167, 168, 150, 169, + 170, 171, 172, 174, 175, 152, 153, 177, 182, 184, + 186, 187, 188, 189, 190, 191, 192, 193, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 153, 177, 182, 184, 186, 187, 188, 189, + 190, 191, 192, 193, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "frame/xylex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 12 "frame/xylex.L" + #include + #include + #include + + #include "util.h" + #include "xyparser.H" + + extern YYSTYPE* xylval; +/* rules */ +#line 638 "frame/xylex.C" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 27 "frame/xylex.L" + + +#line 741 "frame/xylex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 197 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 196 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 29 "frame/xylex.L" +{return AMPLIFIER_;} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 30 "frame/xylex.L" +{return B1950_;} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 31 "frame/xylex.L" +{return CCD_;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 32 "frame/xylex.L" +{return DEBUG_;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 33 "frame/xylex.L" +{return DETECTOR_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 34 "frame/xylex.L" +{return ECLIPTIC_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 35 "frame/xylex.L" +{return FK4_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 36 "frame/xylex.L" +{return FK4_NO_E_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 37 "frame/xylex.L" +{return FK5_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 38 "frame/xylex.L" +{return GALACTIC_;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 39 "frame/xylex.L" +{return HELIOECLIPTIC_;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 40 "frame/xylex.L" +{return ICRS_;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 41 "frame/xylex.L" +{return IMAGE_;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 42 "frame/xylex.L" +{return J2000_;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 43 "frame/xylex.L" +{return LOGICAL_;} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 44 "frame/xylex.L" +{return OFF_;} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 45 "frame/xylex.L" +{return ON_;} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 46 "frame/xylex.L" +{return PHYSICAL_;} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 47 "frame/xylex.L" +{return SUPERGALACTIC_;} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 48 "frame/xylex.L" +{return VERSION_;} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 49 "frame/xylex.L" +{return WCS_;} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 50 "frame/xylex.L" +{return WCSA_;} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 51 "frame/xylex.L" +{return WCSB_;} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 52 "frame/xylex.L" +{return WCSC_;} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 53 "frame/xylex.L" +{return WCSD_;} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 54 "frame/xylex.L" +{return WCSE_;} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 55 "frame/xylex.L" +{return WCSF_;} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 56 "frame/xylex.L" +{return WCSG_;} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 57 "frame/xylex.L" +{return WCSH_;} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 58 "frame/xylex.L" +{return WCSI_;} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 59 "frame/xylex.L" +{return WCSJ_;} + YY_BREAK +case 32: +YY_RULE_SETUP +#line 60 "frame/xylex.L" +{return WCSK_;} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 61 "frame/xylex.L" +{return WCSL_;} + YY_BREAK +case 34: +YY_RULE_SETUP +#line 62 "frame/xylex.L" +{return WCSM_;} + YY_BREAK +case 35: +YY_RULE_SETUP +#line 63 "frame/xylex.L" +{return WCSN_;} + YY_BREAK +case 36: +YY_RULE_SETUP +#line 64 "frame/xylex.L" +{return WCSO_;} + YY_BREAK +case 37: +YY_RULE_SETUP +#line 65 "frame/xylex.L" +{return WCSP_;} + YY_BREAK +case 38: +YY_RULE_SETUP +#line 66 "frame/xylex.L" +{return WCSQ_;} + YY_BREAK +case 39: +YY_RULE_SETUP +#line 67 "frame/xylex.L" +{return WCSR_;} + YY_BREAK +case 40: +YY_RULE_SETUP +#line 68 "frame/xylex.L" +{return WCSS_;} + YY_BREAK +case 41: +YY_RULE_SETUP +#line 69 "frame/xylex.L" +{return WCST_;} + YY_BREAK +case 42: +YY_RULE_SETUP +#line 70 "frame/xylex.L" +{return WCSU_;} + YY_BREAK +case 43: +YY_RULE_SETUP +#line 71 "frame/xylex.L" +{return WCSV_;} + YY_BREAK +case 44: +YY_RULE_SETUP +#line 72 "frame/xylex.L" +{return WCSW_;} + YY_BREAK +case 45: +YY_RULE_SETUP +#line 73 "frame/xylex.L" +{return WCSX_;} + YY_BREAK +case 46: +YY_RULE_SETUP +#line 74 "frame/xylex.L" +{return WCSY_;} + YY_BREAK +case 47: +YY_RULE_SETUP +#line 75 "frame/xylex.L" +{return WCSZ_;} + YY_BREAK +case 48: +YY_RULE_SETUP +#line 77 "frame/xylex.L" +{ // Integer + xylval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 49: +#line 83 "frame/xylex.L" +case 50: +YY_RULE_SETUP +#line 83 "frame/xylex.L" +{ // Real Number + xylval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 51: +#line 89 "frame/xylex.L" +case 52: +YY_RULE_SETUP +#line 89 "frame/xylex.L" +{ // Sexagesimal + int ll = yyleng <(XYBUFSIZE-1) ? yyleng:(XYBUFSIZE-1); + strncpy(xylval->str,yytext,ll); + xylval->str[ll] = '\0'; + return SEXSTR; + } + YY_BREAK +case 53: +#line 97 "frame/xylex.L" +case 54: +YY_RULE_SETUP +#line 97 "frame/xylex.L" +{ // HMS + int ll = yyleng <(XYBUFSIZE-1) ? yyleng:(XYBUFSIZE-1); + strncpy(xylval->str,yytext,ll); + xylval->str[ll] = '\0'; + return HMSSTR; + } + YY_BREAK +case 55: +#line 105 "frame/xylex.L" +case 56: +YY_RULE_SETUP +#line 105 "frame/xylex.L" +{ // DMS + int ll = yyleng <(XYBUFSIZE-1) ? yyleng:(XYBUFSIZE-1); + strncpy(xylval->str,yytext,ll); + xylval->str[ll] = '\0'; + return DMSSTR; + } + YY_BREAK +case 57: +YY_RULE_SETUP +#line 112 "frame/xylex.L" +{ // comment, eat it + } + YY_BREAK +case 58: +/* rule 58 can match eol */ +YY_RULE_SETUP +#line 115 "frame/xylex.L" +{ // windows line feed + return '\n'; + } + YY_BREAK +case 59: +/* rule 59 can match eol */ +YY_RULE_SETUP +#line 119 "frame/xylex.L" +{ // special chars + return yytext[0]; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +#line 123 "frame/xylex.L" +{ // eof + return EOF_; + } + YY_BREAK +case 60: +YY_RULE_SETUP +#line 127 "frame/xylex.L" +{ // Else, eat it + } + YY_BREAK +case 61: +YY_RULE_SETUP +#line 130 "frame/xylex.L" +ECHO; + YY_BREAK +#line 1148 "frame/xylex.C" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + xyfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + xyfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + xyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) xyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 197 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 197 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 196); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) xyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) xyalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + xyfree((void *) b->yy_ch_buf ); + + xyfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)xyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)xyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) xyalloc(new_size ); + + else + (yy_start_stack) = (int *) xyrealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *xyalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *xyrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void xyfree (void * ptr ) +{ + free( (char *) ptr ); /* see xyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 130 "frame/xylex.L" + + + diff --git a/tksao/frame/xylex.L b/tksao/frame/xylex.L new file mode 100644 index 0000000..cbbc4a7 --- /dev/null +++ b/tksao/frame/xylex.L @@ -0,0 +1,130 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ + +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + + #include "util.h" + #include "xyparser.H" + + extern YYSTYPE* xylval; +%} + +D [0-9] +E [Ee][+-]?{D}+ + +/* rules */ + +%% + +amplifier {return AMPLIFIER_;} +b1950 {return B1950_;} +ccd {return CCD_;} +debug {return DEBUG_;} +detector {return DETECTOR_;} +ecliptic {return ECLIPTIC_;} +fk4 {return FK4_;} +fk4-no-e {return FK4_NO_E_;} +fk5 {return FK5_;} +galactic {return GALACTIC_;} +helioecliptic {return HELIOECLIPTIC_;} +icrs {return ICRS_;} +image {return IMAGE_;} +j2000 {return J2000_;} +logical {return LOGICAL_;} +off {return OFF_;} +on {return ON_;} +physical {return PHYSICAL_;} +supergalactic {return SUPERGALACTIC_;} +version {return VERSION_;} +wcs {return WCS_;} +wcsa {return WCSA_;} +wcsb {return WCSB_;} +wcsc {return WCSC_;} +wcsd {return WCSD_;} +wcse {return WCSE_;} +wcsf {return WCSF_;} +wcsg {return WCSG_;} +wcsh {return WCSH_;} +wcsi {return WCSI_;} +wcsj {return WCSJ_;} +wcsk {return WCSK_;} +wcsl {return WCSL_;} +wcsm {return WCSM_;} +wcsn {return WCSN_;} +wcso {return WCSO_;} +wcsp {return WCSP_;} +wcsq {return WCSQ_;} +wcsr {return WCSR_;} +wcss {return WCSS_;} +wcst {return WCST_;} +wcsu {return WCSU_;} +wcsv {return WCSV_;} +wcsw {return WCSW_;} +wcsx {return WCSX_;} +wcsy {return WCSY_;} +wcsz {return WCSZ_;} + +[+-]?{D}+ { // Integer + xylval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + xylval->real = atof(yytext); + return REAL; + } + +[+-]?{D}+:{D}+:{D}+"."? | +[+-]?{D}+:{D}+:{D}*"."{D}+ { // Sexagesimal + int ll = yyleng <(XYBUFSIZE-1) ? yyleng:(XYBUFSIZE-1); + strncpy(xylval->str,yytext,ll); + xylval->str[ll] = '\0'; + return SEXSTR; + } + +[+-]?{D}+h{D}+m{D}+"."?s | +[+-]?{D}+h{D}+m{D}*"."{D}+s { // HMS + int ll = yyleng <(XYBUFSIZE-1) ? yyleng:(XYBUFSIZE-1); + strncpy(xylval->str,yytext,ll); + xylval->str[ll] = '\0'; + return HMSSTR; + } + +[+-]?{D}+d{D}+m{D}+"."?s | +[+-]?{D}+d{D}+m{D}*"."{D}+s { // DMS + int ll = yyleng <(XYBUFSIZE-1) ? yyleng:(XYBUFSIZE-1); + strncpy(xylval->str,yytext,ll); + xylval->str[ll] = '\0'; + return DMSSTR; + } + +#.* { // comment, eat it + } + +\r\n { // windows line feed + return '\n'; + } + +[\n;,] { // special chars + return yytext[0]; + } + +<> { // eof + return EOF_; + } + +. { // Else, eat it + } + +%% diff --git a/tksao/frame/xyparser.C b/tksao/frame/xyparser.C new file mode 100644 index 0000000..f69bd18 --- /dev/null +++ b/tksao/frame/xyparser.C @@ -0,0 +1,2149 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse xyparse +#define yylex xylex +#define yyerror xyerror +#define yylval xylval +#define yychar xychar +#define yydebug xydebug +#define yynerrs xynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + ANGDEGREE = 260, + SEXSTR = 261, + HMSSTR = 262, + DMSSTR = 263, + EOF_ = 264, + AMPLIFIER_ = 265, + B1950_ = 266, + CCD_ = 267, + DEBUG_ = 268, + DETECTOR_ = 269, + ECLIPTIC_ = 270, + FK4_ = 271, + FK4_NO_E_ = 272, + FK5_ = 273, + GALACTIC_ = 274, + HELIOECLIPTIC_ = 275, + ICRS_ = 276, + IMAGE_ = 277, + J2000_ = 278, + LOGICAL_ = 279, + OFF_ = 280, + ON_ = 281, + PHYSICAL_ = 282, + SUPERGALACTIC_ = 283, + VERSION_ = 284, + WCS_ = 285, + WCSA_ = 286, + WCSB_ = 287, + WCSC_ = 288, + WCSD_ = 289, + WCSE_ = 290, + WCSF_ = 291, + WCSG_ = 292, + WCSH_ = 293, + WCSI_ = 294, + WCSJ_ = 295, + WCSK_ = 296, + WCSL_ = 297, + WCSM_ = 298, + WCSN_ = 299, + WCSO_ = 300, + WCSP_ = 301, + WCSQ_ = 302, + WCSR_ = 303, + WCSS_ = 304, + WCST_ = 305, + WCSU_ = 306, + WCSV_ = 307, + WCSW_ = 308, + WCSX_ = 309, + WCSY_ = 310, + WCSZ_ = 311 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define ANGDEGREE 260 +#define SEXSTR 261 +#define HMSSTR 262 +#define DMSSTR 263 +#define EOF_ 264 +#define AMPLIFIER_ 265 +#define B1950_ 266 +#define CCD_ 267 +#define DEBUG_ 268 +#define DETECTOR_ 269 +#define ECLIPTIC_ 270 +#define FK4_ 271 +#define FK4_NO_E_ 272 +#define FK5_ 273 +#define GALACTIC_ 274 +#define HELIOECLIPTIC_ 275 +#define ICRS_ 276 +#define IMAGE_ 277 +#define J2000_ 278 +#define LOGICAL_ 279 +#define OFF_ 280 +#define ON_ 281 +#define PHYSICAL_ 282 +#define SUPERGALACTIC_ 283 +#define VERSION_ 284 +#define WCS_ 285 +#define WCSA_ 286 +#define WCSB_ 287 +#define WCSC_ 288 +#define WCSD_ 289 +#define WCSE_ 290 +#define WCSF_ 291 +#define WCSG_ 292 +#define WCSH_ 293 +#define WCSI_ 294 +#define WCSJ_ 295 +#define WCSK_ 296 +#define WCSL_ 297 +#define WCSM_ 298 +#define WCSN_ 299 +#define WCSO_ 300 +#define WCSP_ 301 +#define WCSQ_ 302 +#define WCSR_ 303 +#define WCSS_ 304 +#define WCST_ 305 +#define WCSU_ 306 +#define WCSV_ 307 +#define WCSW_ 308 +#define WCSX_ 309 +#define WCSY_ 310 +#define WCSZ_ 311 + + + + +/* Copy the first part of user declarations. */ +#line 10 "frame/xyparser.Y" + +#define YYDEBUG 1 + +#define FITSPTR (fr->findFits()) + +#include +#include +#include + +#include "base.h" +#include "fitsimage.h" +#include "basemarker.h" + +#undef yyFlexLexer +#define yyFlexLexer xyFlexLexer +#include + +extern int xylex(void*, xyFlexLexer*); +extern void xyerror(Base*, xyFlexLexer*, const char*); + +static const char *color = "green"; +static int dash[] = {8,3}; +static const char *font = "helvetica 10 normal roman"; +static const char *text = ""; + +static Coord::CoordSystem globalSystem; +static Coord::SkyFrame globalSky; +static Coord::CoordSystem localSystem; +static Coord::SkyFrame localSky; + +static List taglist; +static List cblist; + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 44 "frame/xyparser.Y" +{ +#define XYBUFSIZE 2048 + double real; + int integer; + char str[XYBUFSIZE]; + double vector[3]; +} +/* Line 193 of yacc.c. */ +#line 258 "frame/xyparser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 271 "frame/xyparser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 126 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 60 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 20 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 78 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 91 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 311 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 57, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 59, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 58, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 4, 7, 11, 14, 15, 18, 20, + 22, 25, 26, 30, 31, 33, 36, 38, 40, 42, + 44, 46, 48, 50, 52, 54, 55, 57, 59, 61, + 63, 67, 71, 75, 79, 83, 85, 87, 89, 91, + 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, + 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, + 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, + 153, 155, 157, 159, 161, 163, 165, 167, 169 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 61, 0, -1, -1, 62, 63, -1, 63, 64, 69, + -1, 64, 69, -1, -1, 13, 71, -1, 29, -1, + 77, -1, 77, 78, -1, -1, 65, 79, 66, -1, + -1, 67, -1, 67, 68, -1, 68, -1, 70, -1, + 57, -1, 58, -1, 9, -1, 4, -1, 3, -1, + 26, -1, 25, -1, -1, 59, -1, 6, -1, 7, + -1, 8, -1, 73, 72, 73, -1, 74, 72, 75, + -1, 75, 72, 75, -1, 70, 72, 70, -1, 5, + 72, 5, -1, 22, -1, 24, -1, 27, -1, 12, + -1, 10, -1, 14, -1, 30, -1, 31, -1, 32, + -1, 33, -1, 34, -1, 35, -1, 36, -1, 37, + -1, 38, -1, 39, -1, 40, -1, 41, -1, 42, + -1, 43, -1, 44, -1, 45, -1, 46, -1, 47, + -1, 48, -1, 49, -1, 50, -1, 51, -1, 52, + -1, 53, -1, 54, -1, 55, -1, 56, -1, 16, + -1, 11, -1, 17, -1, 18, -1, 23, -1, 21, + -1, 19, -1, 28, -1, 15, -1, 20, -1, 76, + -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 122, 122, 122, 128, 129, 132, 133, 134, 135, + 136, 138, 138, 141, 142, 145, 146, 149, 152, 153, + 154, 157, 158, 161, 162, 165, 166, 169, 172, 175, + 178, 189, 196, 203, 210, 219, 220, 221, 222, 223, + 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, + 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, + 244, 245, 246, 247, 248, 249, 250, 251, 254, 255, + 256, 257, 258, 259, 260, 261, 262, 263, 266 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "INT", "REAL", "ANGDEGREE", "SEXSTR", + "HMSSTR", "DMSSTR", "EOF_", "AMPLIFIER_", "B1950_", "CCD_", "DEBUG_", + "DETECTOR_", "ECLIPTIC_", "FK4_", "FK4_NO_E_", "FK5_", "GALACTIC_", + "HELIOECLIPTIC_", "ICRS_", "IMAGE_", "J2000_", "LOGICAL_", "OFF_", "ON_", + "PHYSICAL_", "SUPERGALACTIC_", "VERSION_", "WCS_", "WCSA_", "WCSB_", + "WCSC_", "WCSD_", "WCSE_", "WCSF_", "WCSG_", "WCSH_", "WCSI_", "WCSJ_", + "WCSK_", "WCSL_", "WCSM_", "WCSN_", "WCSO_", "WCSP_", "WCSQ_", "WCSR_", + "WCSS_", "WCST_", "WCSU_", "WCSV_", "WCSW_", "WCSX_", "WCSY_", "WCSZ_", + "'\\n'", "';'", "','", "$accept", "start", "@1", "commands", "command", + "@2", "comment", "junks", "junk", "terminator", "numeric", "debug", "sp", + "sexagesimal", "hms", "dms", "coord", "coordSystem", "skyFrame", "shape", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 10, 59, 44 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 60, 62, 61, 63, 63, 64, 64, 64, 64, + 64, 65, 64, 66, 66, 67, 67, 68, 69, 69, + 69, 70, 70, 71, 71, 72, 72, 73, 74, 75, + 76, 76, 76, 76, 76, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 78, 78, + 78, 78, 78, 78, 78, 78, 78, 78, 79 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 2, 3, 2, 0, 2, 1, 1, + 2, 0, 3, 0, 1, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, + 3, 3, 3, 3, 3, 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, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 2, 0, 11, 1, 39, 38, 0, 40, 35, 36, + 37, 8, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 11, + 0, 0, 9, 24, 23, 7, 0, 20, 18, 19, + 5, 22, 21, 25, 27, 28, 29, 25, 25, 25, + 25, 78, 13, 69, 76, 68, 70, 71, 74, 77, + 73, 72, 75, 10, 4, 26, 0, 0, 0, 0, + 0, 12, 14, 16, 17, 34, 33, 30, 31, 32, + 15 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 1, 2, 39, 40, 41, 81, 82, 83, 50, + 84, 45, 76, 58, 59, 60, 61, 42, 73, 62 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -40 +static const yytype_int8 yypact[] = +{ + -40, 11, 50, -40, -40, -40, -18, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, 0, + 8, -2, 98, -40, -40, -40, 8, -40, -40, -40, + -40, -40, -40, -36, -40, -40, -40, -36, -36, -36, + -36, -40, 12, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, 21, 12, 22, 61, + 61, -40, 12, -40, -40, -40, -40, -40, -40, -40, + -40 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -40, -40, -40, -40, 31, -40, -40, -40, -11, 27, + -16, -40, -39, -3, -40, -12, -40, -40, -40, -40 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -7 +static const yytype_int8 yytable[] = +{ + -3, 51, 52, 53, 54, 55, 56, 43, 44, -6, + 4, 3, 5, 6, 7, 51, 52, 47, 77, 78, + 79, 80, 8, 75, 9, 57, 85, 10, 54, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, -6, -6, -6, + 4, 86, 5, 6, 7, 48, 49, 88, 89, 56, + 46, 90, 8, 74, 9, 87, 0, 10, 0, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, -6, -6, 63, + 0, 0, 0, 64, 65, 66, 67, 68, 69, 70, + 0, 71, 0, 0, 0, 0, 72 +}; + +static const yytype_int8 yycheck[] = +{ + 0, 3, 4, 5, 6, 7, 8, 25, 26, 9, + 10, 0, 12, 13, 14, 3, 4, 9, 57, 58, + 59, 60, 22, 59, 24, 41, 5, 27, 6, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 9, + 10, 77, 12, 13, 14, 57, 58, 79, 80, 8, + 39, 82, 22, 46, 24, 78, -1, 27, -1, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 11, + -1, -1, -1, 15, 16, 17, 18, 19, 20, 21, + -1, 23, -1, -1, -1, -1, 28 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 61, 62, 0, 10, 12, 13, 14, 22, 24, + 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 63, + 64, 65, 77, 25, 26, 71, 64, 9, 57, 58, + 69, 3, 4, 5, 6, 7, 8, 70, 73, 74, + 75, 76, 79, 11, 15, 16, 17, 18, 19, 20, + 21, 23, 28, 78, 69, 59, 72, 72, 72, 72, + 72, 66, 67, 68, 70, 5, 70, 73, 75, 75, + 68 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (fr, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, fr, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, xyFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + xyFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (fr); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Base* fr, xyFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, fr, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Base* fr; + xyFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, fr, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Base* fr, xyFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, fr, ll) + YYSTYPE *yyvsp; + int yyrule; + Base* fr; + xyFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , fr, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, fr, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Base* fr, xyFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, fr, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + Base* fr; + xyFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (fr); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (Base* fr, xyFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (Base* fr, xyFlexLexer* ll) +#else +int +yyparse (fr, ll) + Base* fr; + xyFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 122 "frame/xyparser.Y" + { + globalSystem = fr->xySystem(); + globalSky = fr->xySky(); + ;} + break; + + case 8: +#line 134 "frame/xyparser.Y" + {cerr << "X Y Format 1.0" << endl;;} + break; + + case 9: +#line 135 "frame/xyparser.Y" + {globalSystem = (Coord::CoordSystem)(yyvsp[(1) - (1)].integer);;} + break; + + case 10: +#line 137 "frame/xyparser.Y" + {globalSystem = (Coord::CoordSystem)(yyvsp[(1) - (2)].integer); globalSky = (Coord::SkyFrame)(yyvsp[(2) - (2)].integer);;} + break; + + case 11: +#line 138 "frame/xyparser.Y" + {localSystem = globalSystem; localSky = globalSky; maperr = 0;;} + break; + + case 17: +#line 149 "frame/xyparser.Y" + {;} + break; + + case 20: +#line 154 "frame/xyparser.Y" + {YYACCEPT;;} + break; + + case 21: +#line 157 "frame/xyparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 22: +#line 158 "frame/xyparser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].integer);;} + break; + + case 23: +#line 161 "frame/xyparser.Y" + {yydebug=1;;} + break; + + case 24: +#line 162 "frame/xyparser.Y" + {yydebug=0;;} + break; + + case 27: +#line 169 "frame/xyparser.Y" + {(yyval.real) = parseSEXStr((yyvsp[(1) - (1)].str));;} + break; + + case 28: +#line 172 "frame/xyparser.Y" + {(yyval.real) = parseHMSStr((yyvsp[(1) - (1)].str));;} + break; + + case 29: +#line 175 "frame/xyparser.Y" + {(yyval.real) = parseDMSStr((yyvsp[(1) - (1)].str));;} + break; + + case 30: +#line 179 "frame/xyparser.Y" + { + Vector r; + if (localSky == Coord::GALACTIC || localSky == Coord::ECLIPTIC) + r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)),localSystem,localSky); + else + r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real)*360./24.,(yyvsp[(3) - (3)].real)),localSystem,localSky); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 31: +#line 190 "frame/xyparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)),localSystem,localSky); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 32: +#line 197 "frame/xyparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)),localSystem,localSky); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 33: +#line 204 "frame/xyparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)),localSystem,localSky); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 34: +#line 211 "frame/xyparser.Y" + { + Vector r = FITSPTR->mapToRef(Vector((yyvsp[(1) - (3)].real),(yyvsp[(3) - (3)].real)),localSystem,localSky); + (yyval.vector)[0] = r[0]; + (yyval.vector)[1] = r[1]; + (yyval.vector)[2] = r[2]; + ;} + break; + + case 35: +#line 219 "frame/xyparser.Y" + {(yyval.integer) = Coord::IMAGE;;} + break; + + case 36: +#line 220 "frame/xyparser.Y" + {(yyval.integer) = Coord::IMAGE;;} + break; + + case 37: +#line 221 "frame/xyparser.Y" + {(yyval.integer) = Coord::PHYSICAL;;} + break; + + case 38: +#line 222 "frame/xyparser.Y" + {(yyval.integer) = Coord::PHYSICAL;;} + break; + + case 39: +#line 223 "frame/xyparser.Y" + {(yyval.integer) = Coord::AMPLIFIER;;} + break; + + case 40: +#line 224 "frame/xyparser.Y" + {(yyval.integer) = Coord::DETECTOR;;} + break; + + case 41: +#line 225 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCS;;} + break; + + case 42: +#line 226 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSA;;} + break; + + case 43: +#line 227 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSB;;} + break; + + case 44: +#line 228 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSC;;} + break; + + case 45: +#line 229 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSD;;} + break; + + case 46: +#line 230 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSE;;} + break; + + case 47: +#line 231 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSF;;} + break; + + case 48: +#line 232 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSG;;} + break; + + case 49: +#line 233 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSH;;} + break; + + case 50: +#line 234 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSI;;} + break; + + case 51: +#line 235 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSJ;;} + break; + + case 52: +#line 236 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSK;;} + break; + + case 53: +#line 237 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSL;;} + break; + + case 54: +#line 238 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSM;;} + break; + + case 55: +#line 239 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSN;;} + break; + + case 56: +#line 240 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSO;;} + break; + + case 57: +#line 241 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSP;;} + break; + + case 58: +#line 242 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSQ;;} + break; + + case 59: +#line 243 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSR;;} + break; + + case 60: +#line 244 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSS;;} + break; + + case 61: +#line 245 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCST;;} + break; + + case 62: +#line 246 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSU;;} + break; + + case 63: +#line 247 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSV;;} + break; + + case 64: +#line 248 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSW;;} + break; + + case 65: +#line 249 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSX;;} + break; + + case 66: +#line 250 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSY;;} + break; + + case 67: +#line 251 "frame/xyparser.Y" + {(yyval.integer) = Coord::WCSZ;;} + break; + + case 68: +#line 254 "frame/xyparser.Y" + {(yyval.integer) = Coord::FK4;;} + break; + + case 69: +#line 255 "frame/xyparser.Y" + {(yyval.integer) = Coord::FK4;;} + break; + + case 70: +#line 256 "frame/xyparser.Y" + {(yyval.integer) = Coord::FK4_NO_E;;} + break; + + case 71: +#line 257 "frame/xyparser.Y" + {(yyval.integer) = Coord::FK5;;} + break; + + case 72: +#line 258 "frame/xyparser.Y" + {(yyval.integer) = Coord::FK5;;} + break; + + case 73: +#line 259 "frame/xyparser.Y" + {(yyval.integer) = Coord::ICRS;;} + break; + + case 74: +#line 260 "frame/xyparser.Y" + {(yyval.integer) = Coord::GALACTIC;;} + break; + + case 75: +#line 261 "frame/xyparser.Y" + {(yyval.integer) = Coord::SUPERGALACTIC;;} + break; + + case 76: +#line 262 "frame/xyparser.Y" + {(yyval.integer) = Coord::ECLIPTIC;;} + break; + + case 77: +#line 263 "frame/xyparser.Y" + {(yyval.integer) = Coord::HELIOECLIPTIC;;} + break; + + case 78: +#line 266 "frame/xyparser.Y" + {fr->createPointCmd(Vector((yyvsp[(1) - (1)].vector)), Point::BOXCIRCLE, POINTSIZE, + color,dash,1,font,text, + Marker::SELECT | Marker::EDIT | Marker::MOVE | Marker::ROTATE | + Marker::DELETE | Marker::HIGHLITE | + Marker::INCLUDE | Marker::SOURCE, + "",taglist,cblist); + ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1934 "frame/xyparser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (fr, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (fr, ll, yymsg); + } + else + { + yyerror (fr, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, fr, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, fr, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (fr, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, fr, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, fr, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 275 "frame/xyparser.Y" + + diff --git a/tksao/frame/xyparser.H b/tksao/frame/xyparser.H new file mode 100644 index 0000000..8e4aec6 --- /dev/null +++ b/tksao/frame/xyparser.H @@ -0,0 +1,176 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + ANGDEGREE = 260, + SEXSTR = 261, + HMSSTR = 262, + DMSSTR = 263, + EOF_ = 264, + AMPLIFIER_ = 265, + B1950_ = 266, + CCD_ = 267, + DEBUG_ = 268, + DETECTOR_ = 269, + ECLIPTIC_ = 270, + FK4_ = 271, + FK4_NO_E_ = 272, + FK5_ = 273, + GALACTIC_ = 274, + HELIOECLIPTIC_ = 275, + ICRS_ = 276, + IMAGE_ = 277, + J2000_ = 278, + LOGICAL_ = 279, + OFF_ = 280, + ON_ = 281, + PHYSICAL_ = 282, + SUPERGALACTIC_ = 283, + VERSION_ = 284, + WCS_ = 285, + WCSA_ = 286, + WCSB_ = 287, + WCSC_ = 288, + WCSD_ = 289, + WCSE_ = 290, + WCSF_ = 291, + WCSG_ = 292, + WCSH_ = 293, + WCSI_ = 294, + WCSJ_ = 295, + WCSK_ = 296, + WCSL_ = 297, + WCSM_ = 298, + WCSN_ = 299, + WCSO_ = 300, + WCSP_ = 301, + WCSQ_ = 302, + WCSR_ = 303, + WCSS_ = 304, + WCST_ = 305, + WCSU_ = 306, + WCSV_ = 307, + WCSW_ = 308, + WCSX_ = 309, + WCSY_ = 310, + WCSZ_ = 311 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define ANGDEGREE 260 +#define SEXSTR 261 +#define HMSSTR 262 +#define DMSSTR 263 +#define EOF_ 264 +#define AMPLIFIER_ 265 +#define B1950_ 266 +#define CCD_ 267 +#define DEBUG_ 268 +#define DETECTOR_ 269 +#define ECLIPTIC_ 270 +#define FK4_ 271 +#define FK4_NO_E_ 272 +#define FK5_ 273 +#define GALACTIC_ 274 +#define HELIOECLIPTIC_ 275 +#define ICRS_ 276 +#define IMAGE_ 277 +#define J2000_ 278 +#define LOGICAL_ 279 +#define OFF_ 280 +#define ON_ 281 +#define PHYSICAL_ 282 +#define SUPERGALACTIC_ 283 +#define VERSION_ 284 +#define WCS_ 285 +#define WCSA_ 286 +#define WCSB_ 287 +#define WCSC_ 288 +#define WCSD_ 289 +#define WCSE_ 290 +#define WCSF_ 291 +#define WCSG_ 292 +#define WCSH_ 293 +#define WCSI_ 294 +#define WCSJ_ 295 +#define WCSK_ 296 +#define WCSL_ 297 +#define WCSM_ 298 +#define WCSN_ 299 +#define WCSO_ 300 +#define WCSP_ 301 +#define WCSQ_ 302 +#define WCSR_ 303 +#define WCSS_ 304 +#define WCST_ 305 +#define WCSU_ 306 +#define WCSV_ 307 +#define WCSW_ 308 +#define WCSX_ 309 +#define WCSY_ 310 +#define WCSZ_ 311 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 44 "frame/xyparser.Y" +{ +#define XYBUFSIZE 2048 + double real; + int integer; + char str[XYBUFSIZE]; + double vector[3]; +} +/* Line 1529 of yacc.c. */ +#line 169 "frame/xyparser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/frame/xyparser.Y b/tksao/frame/xyparser.Y new file mode 100644 index 0000000..eb711ac --- /dev/null +++ b/tksao/frame/xyparser.Y @@ -0,0 +1,275 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {Base* fr} +%lex-param {xyFlexLexer* ll} +%parse-param {xyFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#define FITSPTR (fr->findFits()) + +#include +#include +#include + +#include "base.h" +#include "fitsimage.h" +#include "basemarker.h" + +#undef yyFlexLexer +#define yyFlexLexer xyFlexLexer +#include + +extern int xylex(void*, xyFlexLexer*); +extern void xyerror(Base*, xyFlexLexer*, const char*); + +static const char *color = "green"; +static int dash[] = {8,3}; +static const char *font = "helvetica 10 normal roman"; +static const char *text = ""; + +static Coord::CoordSystem globalSystem; +static Coord::SkyFrame globalSky; +static Coord::CoordSystem localSystem; +static Coord::SkyFrame localSky; + +static List taglist; +static List cblist; +%} + +%union { +#define XYBUFSIZE 2048 + double real; + int integer; + char str[XYBUFSIZE]; + double vector[3]; +} + +%type numeric + +%type sexagesimal +%type hms +%type dms +%type coord +%type coordSystem +%type skyFrame + +%token INT +%token REAL + +%token ANGDEGREE + +%token SEXSTR +%token HMSSTR +%token DMSSTR + +%token EOF_ + +%token AMPLIFIER_ +%token B1950_ +%token CCD_ +%token DEBUG_ +%token DETECTOR_ +%token ECLIPTIC_ +%token FK4_ +%token FK4_NO_E_ +%token FK5_ +%token GALACTIC_ +%token HELIOECLIPTIC_ +%token ICRS_ +%token IMAGE_ +%token J2000_ +%token LOGICAL_ +%token OFF_ +%token ON_ +%token PHYSICAL_ +%token SUPERGALACTIC_ +%token VERSION_ +%token WCS_ +%token WCSA_ +%token WCSB_ +%token WCSC_ +%token WCSD_ +%token WCSE_ +%token WCSF_ +%token WCSG_ +%token WCSH_ +%token WCSI_ +%token WCSJ_ +%token WCSK_ +%token WCSL_ +%token WCSM_ +%token WCSN_ +%token WCSO_ +%token WCSP_ +%token WCSQ_ +%token WCSR_ +%token WCSS_ +%token WCST_ +%token WCSU_ +%token WCSV_ +%token WCSW_ +%token WCSX_ +%token WCSY_ +%token WCSZ_ + +%% + +start : { + globalSystem = fr->xySystem(); + globalSky = fr->xySky(); + } commands + ; + +commands: commands command terminator + | command terminator + ; + +command : /* empty */ + | DEBUG_ debug + | VERSION_ {cerr << "X Y Format 1.0" << endl;} + | coordSystem {globalSystem = (Coord::CoordSystem)$1;} + | coordSystem skyFrame + {globalSystem = (Coord::CoordSystem)$1; globalSky = (Coord::SkyFrame)$2;} + | {localSystem = globalSystem; localSky = globalSky; maperr = 0;} shape comment + ; + +comment : /* empty */ + | junks + ; + +junks : junks junk + | junk + ; + +junk : numeric {} + ; + +terminator: '\n' + | ';' + | EOF_ {YYACCEPT;} + ; + +numeric : REAL {$$=$1;} + | INT {$$=$1;} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + ; + +sp : /* empty */ + | ',' + ; + +sexagesimal: SEXSTR {$$ = parseSEXStr($1);} + ; + +hms : HMSSTR {$$ = parseHMSStr($1);} + ; + +dms : DMSSTR {$$ = parseDMSStr($1);} + ; + +coord : sexagesimal sp sexagesimal + { + Vector r; + if (localSky == Coord::GALACTIC || localSky == Coord::ECLIPTIC) + r = FITSPTR->mapToRef(Vector($1,$3),localSystem,localSky); + else + r = FITSPTR->mapToRef(Vector($1*360./24.,$3),localSystem,localSky); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | hms sp dms + { + Vector r = FITSPTR->mapToRef(Vector($1,$3),localSystem,localSky); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | dms sp dms + { + Vector r = FITSPTR->mapToRef(Vector($1,$3),localSystem,localSky); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | numeric sp numeric + { + Vector r = FITSPTR->mapToRef(Vector($1,$3),localSystem,localSky); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + | ANGDEGREE sp ANGDEGREE + { + Vector r = FITSPTR->mapToRef(Vector($1,$3),localSystem,localSky); + $$[0] = r[0]; + $$[1] = r[1]; + $$[2] = r[2]; + } + ; + +coordSystem : IMAGE_ {$$ = Coord::IMAGE;} + | LOGICAL_ {$$ = Coord::IMAGE;} + | PHYSICAL_ {$$ = Coord::PHYSICAL;} + | CCD_ {$$ = Coord::PHYSICAL;} + | AMPLIFIER_ {$$ = Coord::AMPLIFIER;} + | DETECTOR_ {$$ = Coord::DETECTOR;} + | WCS_ {$$ = Coord::WCS;} + | WCSA_ {$$ = Coord::WCSA;} + | WCSB_ {$$ = Coord::WCSB;} + | WCSC_ {$$ = Coord::WCSC;} + | WCSD_ {$$ = Coord::WCSD;} + | WCSE_ {$$ = Coord::WCSE;} + | WCSF_ {$$ = Coord::WCSF;} + | WCSG_ {$$ = Coord::WCSG;} + | WCSH_ {$$ = Coord::WCSH;} + | WCSI_ {$$ = Coord::WCSI;} + | WCSJ_ {$$ = Coord::WCSJ;} + | WCSK_ {$$ = Coord::WCSK;} + | WCSL_ {$$ = Coord::WCSL;} + | WCSM_ {$$ = Coord::WCSM;} + | WCSN_ {$$ = Coord::WCSN;} + | WCSO_ {$$ = Coord::WCSO;} + | WCSP_ {$$ = Coord::WCSP;} + | WCSQ_ {$$ = Coord::WCSQ;} + | WCSR_ {$$ = Coord::WCSR;} + | WCSS_ {$$ = Coord::WCSS;} + | WCST_ {$$ = Coord::WCST;} + | WCSU_ {$$ = Coord::WCSU;} + | WCSV_ {$$ = Coord::WCSV;} + | WCSW_ {$$ = Coord::WCSW;} + | WCSX_ {$$ = Coord::WCSX;} + | WCSY_ {$$ = Coord::WCSY;} + | WCSZ_ {$$ = Coord::WCSZ;} + ; + +skyFrame : FK4_ {$$ = Coord::FK4;} + | B1950_ {$$ = Coord::FK4;} + | FK4_NO_E_ {$$ = Coord::FK4_NO_E;} + | FK5_ {$$ = Coord::FK5;} + | J2000_ {$$ = Coord::FK5;} + | ICRS_ {$$ = Coord::ICRS;} + | GALACTIC_ {$$ = Coord::GALACTIC;} + | SUPERGALACTIC_ {$$ = Coord::SUPERGALACTIC;} + | ECLIPTIC_ {$$ = Coord::ECLIPTIC;} + | HELIOECLIPTIC_ {$$ = Coord::HELIOECLIPTIC;} + ; + +shape : coord {fr->createPointCmd(Vector($1), Point::BOXCIRCLE, POINTSIZE, + color,dash,1,font,text, + Marker::SELECT | Marker::EDIT | Marker::MOVE | Marker::ROTATE | + Marker::DELETE | Marker::HIGHLITE | + Marker::INCLUDE | Marker::SOURCE, + "",taglist,cblist); + } + ; + +%% diff --git a/tksao/list/list.C b/tksao/list/list.C new file mode 100644 index 0000000..b877233 --- /dev/null +++ b/tksao/list/list.C @@ -0,0 +1,398 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "list.h" +#include "vector.h" +#include "marker.h" +#include "callback.h" +#include "contour.h" +#include "fitsmask.h" +#include "sao.h" +#include "lut.h" +#include "colormap.h" +#include "colortag.h" +#include "raytrace.h" + +template List::List() +{ + head_ = NULL; + tail_ = NULL; + current_ = NULL; + count_ = 0; +} + +template List::List(const List& aa) +{ + head_ = NULL; + tail_ = NULL; + current_ = NULL; + count_ = 0; + + List& a = (List&)aa; + if (a.head()) + do + append(new T((T)(*(a.current_)))); + while (a.next()); +} + +// this is needed because of Marker virtual functions +template <> List::List(const List& aa) +{ + head_ = NULL; + tail_ = NULL; + current_ = NULL; + count_ = 0; + + List& a = (List&)aa; + if (a.head()) + do + append(a.current_->dup()); + while (a.next()); +} + +// this is needed because of ColorMapInfo virtual functions +template <> List::List(const List& aa) +{ + head_ = NULL; + tail_ = NULL; + current_ = NULL; + count_ = 0; + + List& a = (List&)aa; + if (a.head()) + do + append(a.current_->dup()); + while (a.next()); +} + +template List::~List() +{ + T* ptr = head_; + while (ptr) { + T* tmp = ptr->next(); + delete ptr; + ptr = tmp; + } +} + +template List& List::operator=(const List& aa) +{ + deleteAll(); + + List& a = (List&)aa; + if (a.head()) + do + append(new T((T)(*(a.current_)))); + while (a.next()); + + return *this; +} + +// this is needed because of Marker virtual functions +template <> List& List::operator=(const List& aa) +{ + deleteAll(); + + List& a = (List&)aa; + if (a.head()) + do + append(a.current_->dup()); + while (a.next()); + + return *this; +} + +// this is needed because of ColorMapInfo virtual functions +template <> List& List::operator=(const List& aa) +{ + deleteAll(); + + List& a = (List&)aa; + if (a.head()) + do + append(a.current_->dup()); + while (a.next()); + + return *this; +} + +template void List::insertHead(T* t) +{ + if (head_ && t) { + t->setNext(head_); + t->setPrevious(NULL); + head_->setPrevious(t); + head_ = t; + } + else { + head_ = t; + tail_ = t; + } + + current_ = head_; + count_++; +} + +template void List::insert(int which, T* t) +{ + head(); + for (int i=0; inext(); + + t->setPrevious(current_); + t->setNext(n); + + current_->setNext(t); + + if (n) + n->setPrevious(t); + else + tail_ = t; + + count_++; + } +} + +template void List::insertNext(T* c, T* t) +{ + if (c && t) { + T* n = c->next(); + + t->setPrevious(c); + t->setNext(n); + + c->setNext(t); + + if (n) + n->setPrevious(t); + else + tail_ = t; + + count_++; + } +} + +template void List::insertPrev(T* c, T* t) +{ + if (c && t) { + T* p = c->previous(); + + t->setPrevious(p); + t->setNext(c); + + c->setPrevious(t); + + if (p) + p->setNext(t); + else + head_ = t; + + count_++; + } +} + +template void List::append(T* p) +{ + if (tail_) { + p->setPrevious(tail_); + p->setNext(NULL); + tail_->setNext(p); + tail_ = p; + } + else { + p->setPrevious(NULL); + p->setNext(NULL); + head_ = p; + tail_ = p; + } + + current_ = tail_; + count_++; +} + +template void List::deleteAll() +{ + T* ptr = head_; + while (ptr) { + T* tmp = ptr->next(); + delete ptr; + ptr = tmp; + } + + head_ = NULL; + tail_ = NULL; + + current_ = NULL; + count_ = 0; +} + +template T* List::pop() +{ + if (tail_) { + T* m = tail_; + if (tail_ != head_) { + T* p = tail_->previous(); + p->setNext(NULL); + tail_ = p; + current_ = p; + count_--; + } + else { + head_ = NULL; + tail_ = NULL; + current_ = NULL; + count_ = 0; + } + return m; + } + + return NULL; +} + +template T* List::fifo() +{ + if (head_) { + T* m = head_; + if (tail_ != head_) { + T* n = head_->next(); + n->setPrevious(NULL); + head_ = n; + current_ = n; + count_--; + } + else { + head_ = NULL; + tail_ = NULL; + current_ = NULL; + count_ = 0; + } + return m; + } + + return NULL; +} + +template T* List::extract() +{ + T* ptr = current_; + + T* p = ptr->previous(); + T* n = ptr->next(); + + if (p) + p->setNext(n); + if (n) + n->setPrevious(p); + + if (head_ == ptr) + head_ = n; + + if (tail_ == ptr) + tail_ = p; + + current_ = NULL; + count_--; + + ptr->setNext(NULL); + ptr->setPrevious(NULL); + + return ptr; +} + +template T* List::extractNext(T* ptr) +{ + T* p = ptr->previous(); + T* n = ptr->next(); + + if (p) + p->setNext(n); + if (n) + n->setPrevious(p); + + if (head_ == ptr) + head_ = n; + + if (tail_ == ptr) + tail_ = p; + + current_ = NULL; + count_--; + + ptr->setNext(NULL); + ptr->setPrevious(NULL); + + return n; +} + +template T* List::extractPrev(T* ptr) +{ + T* p = ptr->previous(); + T* n = ptr->next(); + + if (p) + p->setNext(n); + if (n) + n->setPrevious(p); + + if (head_ == ptr) + head_ = n; + + if (tail_ == ptr) + tail_ = p; + + current_ = NULL; + count_--; + + ptr->setNext(NULL); + ptr->setPrevious(NULL); + + return p; +} + +template T* List::operator[](int which) +{ + head(); + for (int i=0; i int List::index(T* t) +{ + int cnt=0; + head(); + while (current_) { + if (current_ == t) + return cnt; + cnt++; + next(); + } + + return -1; +} + +template void List::transverse(void (*proc)(T*)) +{ + if (head()) + do + proc(current_); + while (next()); +} + +template class List; +template class List; +template class List; +template class List; +template class List; +template class List; +template class List; +template class List; +template class List; +template class List; +template class List; +template class List; diff --git a/tksao/list/list.h b/tksao/list/list.h new file mode 100644 index 0000000..c312ebd --- /dev/null +++ b/tksao/list/list.h @@ -0,0 +1,52 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __list_h__ +#define __list_h__ + +#include + +template +class List { +private: + T* head_; + T* tail_; + int count_; + T* current_; + +public: + List(); + List(const List&); + ~List(); + List& operator=(const List&); + + void insertHead(T*); + void insert(int, T*); + void insertNext(T*,T*); + void insertPrev(T*,T*); + void append(T*); + T* pop(); + T* fifo(); + T* extract(); + T* extractNext(T*); + T* extractPrev(T*); + void deleteAll(); + T* begin() {return head_;} + T* end() {return tail_;} + T* head() {return current_ = head_;} + T* tail() {return current_ = tail_;} + T* next() {return current_ ? current_ = current_->next() : NULL;} + int isNext() {return current_->next() ? 1 : 0;} + T* previous() {return current_ ? current_ = current_->previous() : NULL;} + int isPrevious() {return current_->previous() ? 1 : 0;} + T* current() {return current_;} + int count() {return count_;} + int isEmpty() {return (count_==0) ? 1 : 0;} + T* operator[](int i); + int index(T*); + + void transverse(void (*proc)(T*)); +}; + +#endif diff --git a/tksao/magnifier/lex.C b/tksao/magnifier/lex.C new file mode 100644 index 0000000..9819b31 --- /dev/null +++ b/tksao/magnifier/lex.C @@ -0,0 +1,1708 @@ +#line 2 "magnifier/lex.C" + +#line 4 "magnifier/lex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer mgFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *mgalloc (yy_size_t ); +void *mgrealloc (void *,yy_size_t ); +void mgfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 24 +#define YY_END_OF_BUFFER 25 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[86] = + { 0, + 0, 0, 25, 23, 22, 24, 23, 20, 20, 23, + 23, 23, 23, 23, 23, 10, 23, 23, 23, 23, + 23, 23, 23, 18, 22, 20, 0, 0, 0, 0, + 0, 0, 0, 0, 11, 0, 9, 0, 0, 0, + 0, 0, 0, 0, 21, 0, 0, 0, 0, 5, + 0, 0, 8, 0, 0, 0, 0, 0, 0, 19, + 1, 0, 0, 0, 0, 7, 0, 13, 14, 0, + 0, 0, 2, 3, 4, 0, 12, 0, 0, 17, + 6, 15, 0, 16, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 4, 1, 4, 1, 1, 5, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 1, 1, 1, + 1, 1, 1, 1, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 1, 1, 16, 1, 17, 18, 19, + 1, 20, 21, 22, 23, 24, 25, 26, 27, 1, + 1, 1, 1, 1, 1, 1, 28, 29, 30, 31, + + 32, 33, 34, 35, 36, 1, 1, 37, 1, 38, + 39, 40, 1, 41, 42, 43, 44, 45, 46, 47, + 48, 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, + 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, 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, 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, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[49] = + { 0, + 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, + 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, + 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[87] = + { 0, + 0, 0, 159, 175, 154, 175, 44, 46, 48, 47, + 40, 46, 51, 48, 49, 43, 50, 52, 51, 46, + 49, 58, 55, 60, 153, 68, 0, 57, 83, 87, + 81, 76, 84, 90, 175, 89, 175, 81, 85, 81, + 95, 86, 97, 87, 0, 83, 103, 88, 91, 175, + 100, 103, 175, 106, 111, 126, 132, 119, 119, 175, + 175, 122, 130, 133, 131, 175, 124, 175, 175, 125, + 133, 135, 175, 175, 175, 128, 175, 140, 134, 175, + 175, 175, 136, 175, 175, 152 + } ; + +static yyconst flex_int16_t yy_def[87] = + { 0, + 85, 1, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 86, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 86, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 0, 85 + } ; + +static yyconst flex_int16_t yy_nxt[224] = + { 0, + 4, 5, 6, 7, 8, 9, 4, 10, 11, 12, + 4, 13, 14, 15, 4, 4, 16, 17, 4, 18, + 19, 20, 21, 22, 23, 4, 24, 4, 10, 11, + 12, 4, 13, 14, 15, 4, 4, 16, 17, 4, + 18, 19, 20, 21, 22, 23, 4, 24, 26, 26, + 26, 26, 26, 26, 28, 29, 30, 31, 32, 33, + 35, 36, 38, 34, 39, 40, 37, 41, 42, 43, + 44, 27, 26, 26, 46, 28, 29, 30, 31, 32, + 33, 35, 36, 38, 34, 39, 40, 37, 41, 42, + 43, 44, 27, 47, 48, 46, 49, 50, 51, 52, + + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 47, 48, 67, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 68, 69, 67, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + 82, 83, 84, 45, 25, 25, 68, 69, 85, 70, + 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 81, 82, 83, 84, 3, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85 + } ; + +static yyconst flex_int16_t yy_chk[224] = + { 0, + 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, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 7, 7, + 8, 8, 9, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 15, 19, 20, 17, 21, 22, 23, + 24, 8, 26, 26, 28, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 15, 19, 20, 17, 21, 22, + 23, 24, 8, 29, 30, 28, 31, 32, 33, 34, + + 36, 38, 39, 40, 41, 42, 43, 44, 46, 47, + 48, 49, 51, 52, 29, 30, 54, 31, 32, 33, + 34, 36, 38, 39, 40, 41, 42, 43, 44, 46, + 47, 48, 49, 51, 52, 55, 56, 54, 57, 58, + 59, 62, 63, 64, 65, 67, 70, 71, 72, 76, + 78, 79, 83, 86, 25, 5, 55, 56, 3, 57, + 58, 59, 62, 63, 64, 65, 67, 70, 71, 72, + 76, 78, 79, 83, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "magnifier/lex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 12 "magnifier/lex.L" + #include + #include + #include + + #include "parser.H" + + extern YYSTYPE* mglval; +/* rules */ +#line 496 "magnifier/lex.C" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 26 "magnifier/lex.L" + + +#line 599 "magnifier/lex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 86 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 85 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 28 "magnifier/lex.L" +{return BBOX_;} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 29 "magnifier/lex.L" +{return CLEAR_;} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 30 "magnifier/lex.L" +{return DEBUG_;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 31 "magnifier/lex.L" +{return FALSE_;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 32 "magnifier/lex.L" +{return GET_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 33 "magnifier/lex.L" +{return HEIGHT_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 34 "magnifier/lex.L" +{return HIDE_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 35 "magnifier/lex.L" +{return OFF_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 36 "magnifier/lex.L" +{return ON_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 37 "magnifier/lex.L" +{return N_;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 38 "magnifier/lex.L" +{return NO_;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 39 "magnifier/lex.L" +{return RESET_;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 40 "magnifier/lex.L" +{return SHOW_;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 41 "magnifier/lex.L" +{return TRUE_;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 42 "magnifier/lex.L" +{return UPDATE_;} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 43 "magnifier/lex.L" +{return VERSION_;} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 44 "magnifier/lex.L" +{return WIDTH_;} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 45 "magnifier/lex.L" +{return Y_;} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 46 "magnifier/lex.L" +{return YES_;} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 48 "magnifier/lex.L" +{ // Integer + mglval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 53 "magnifier/lex.L" +{ // Pointer + mglval->ptr = (void*)strtoul(yytext,NULL,16); + return POINTER; + } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 58 "magnifier/lex.L" +{ // White Spaces + } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 61 "magnifier/lex.L" +{ // Else, return the char + return yytext[0]; + } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 65 "magnifier/lex.L" +ECHO; + YY_BREAK +#line 807 "magnifier/lex.C" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + mgfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + mgfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + mgrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) mgrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 86 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 86 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 85); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) mgalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) mgalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + mgfree((void *) b->yy_ch_buf ); + + mgfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)mgalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)mgrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) mgalloc(new_size ); + + else + (yy_start_stack) = (int *) mgrealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *mgalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *mgrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void mgfree (void * ptr ) +{ + free( (char *) ptr ); /* see mgrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 65 "magnifier/lex.L" + + + diff --git a/tksao/magnifier/lex.L b/tksao/magnifier/lex.L new file mode 100644 index 0000000..05c586d --- /dev/null +++ b/tksao/magnifier/lex.L @@ -0,0 +1,65 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ + +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + + #include "parser.H" + + extern YYSTYPE* mglval; +%} + +D [0-9] +E [Ee][+-]?{D}+ + +/* rules */ + +%% + +bbox {return BBOX_;} +clear {return CLEAR_;} +debug {return DEBUG_;} +false {return FALSE_;} +get {return GET_;} +height {return HEIGHT_;} +hide {return HIDE_;} +off {return OFF_;} +on {return ON_;} +n {return N_;} +no {return NO_;} +reset {return RESET_;} +show {return SHOW_;} +true {return TRUE_;} +update {return UPDATE_;} +version {return VERSION_;} +width {return WIDTH_;} +y {return Y_;} +yes {return YES_;} + +[+-]?{D}+ { // Integer + mglval->integer = atoi(yytext); + return INT; + } + +0[xX][0-9a-fA-F]+ { // Pointer + mglval->ptr = (void*)strtoul(yytext,NULL,16); + return POINTER; + } + +[ \t]+ { // White Spaces + } + +. { // Else, return the char + return yytext[0]; + } + +%% diff --git a/tksao/magnifier/magnifier.C b/tksao/magnifier/magnifier.C new file mode 100644 index 0000000..5d55824 --- /dev/null +++ b/tksao/magnifier/magnifier.C @@ -0,0 +1,114 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "magnifier.h" +#include "util.h" + +// Parser Stuff +#undef yyFlexLexer +#define yyFlexLexer mgFlexLexer +#include + +void* mglval; +extern int mgparse(Magnifier*, mgFlexLexer*); + +int mglex(void* vval, mgFlexLexer* ll) +{ + mglval = vval; + return ll ? ll->yylex() : 0; +} + +void mgerror(Magnifier* mg, mgFlexLexer* ll, const char* m) +{ + mg->error(m); + const char* cmd = ll ? ll->YYText() : (const char*)NULL; + if (cmd && cmd[0] != '\n') { + mg->error(": "); + mg->error(cmd); + } +} + +// Public Member Functions + +Magnifier::Magnifier(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : Widget(i, c, item) +{ + thumbnail = 0; + needsUpdate = 0; +} + +int Magnifier::parse(istringstream& istr) +{ + result = TCL_OK; + mgFlexLexer* ll = new mgFlexLexer(&istr); + mgparse(this, ll); + delete ll; + + return result; +} + +void Magnifier::update() +{ + needsUpdate = 1; + redrawNow(); +} + +// Required Virtual Functions + +// UpdatePixmap. This function is responsable for creating a valid +// pixmap the size of the current Magnifier + +int Magnifier::updatePixmap(const BBox& bb) +{ + if (!widgetGC) + widgetGC = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + + // create a valid pixmap if needed + // bb is in canvas coords + + if (!pixmap) + if (!(pixmap = Tk_GetPixmap(display, Tk_WindowId(tkwin), + options->width, options->height, depth))) { + internalError("Magnifier: Unable to Create Pixmap"); + return TCL_OK; + } + + if (needsUpdate) { + if (thumbnail) { + XSetClipOrigin(display, widgetGC, 0, 0); + XCopyArea(display, thumbnail, pixmap, widgetGC, 0, 0, + options->width, options->height, 0, 0); + } + else + clearPixmap(); + + needsUpdate = 0; + } + + return TCL_OK; +} + +void Magnifier::invalidPixmap() +{ + Widget::invalidPixmap(); + update(); +} + +// Command Functions + +void Magnifier::getBBoxCmd() +{ + ostringstream str; + str << options->width << " " << options->height << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Magnifier::updateCmd(void* p) +{ + thumbnail = (Pixmap)p; + update(); +} + diff --git a/tksao/magnifier/magnifier.h b/tksao/magnifier/magnifier.h new file mode 100644 index 0000000..44ed85c --- /dev/null +++ b/tksao/magnifier/magnifier.h @@ -0,0 +1,40 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __magnifier_h__ +#define __magnifier_h__ + +#include "widget.h" + +class Magnifier : public Widget { +private: + Pixmap thumbnail; // current gterm thumbnail pixmap + double crosshairSize; // size of crosshair (diameter) + double crosshairAngle; // angle of rotation (radians) + GC crosshairGC; // gc for crosshairs + int useCrosshair; // flag to render crosshair + int needsUpdate; // flag to indicate update needed + +protected: + virtual void clearPixmap() =0; + +private: + int updatePixmap(const BBox&); // renders image/graphics into pixmap + void update(); + void invalidPixmap(); + +public: + Magnifier(Tcl_Interp*, Tk_Canvas, Tk_Item*); + + int parse(istringstream&); // parse subcommands + + // SubCommandFunctions + + void crosshairCmd(int); + void getBBoxCmd(); + void updateCmd(void*); +}; + +#endif + diff --git a/tksao/magnifier/magnifiertrue.C b/tksao/magnifier/magnifiertrue.C new file mode 100644 index 0000000..c035b56 --- /dev/null +++ b/tksao/magnifier/magnifiertrue.C @@ -0,0 +1,117 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "magnifiertrue.h" +#include "util.h" + +// Tk Canvas Widget Function Declarations + +int MagnifierTrueColorCreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int, + Tcl_Obj *const []); + +// MagnifierTrueColor Specs + +static Tk_CustomOption tagsOption = { + Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL +}; + +static Tk_ConfigSpec magnifierTrueColorSpecs[] = { + + {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "magnifier", + Tk_Offset(WidgetOptions, cmdName), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1", + Tk_Offset(WidgetOptions, x), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1", + Tk_Offset(WidgetOptions, y), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "256", + Tk_Offset(WidgetOptions, width), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "256", + Tk_Offset(WidgetOptions, height), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw", + Tk_Offset(WidgetOptions, anchor), 0, NULL}, + {TK_CONFIG_CUSTOM, (char*)"-tags", NULL, NULL, NULL, + 0, TK_CONFIG_NULL_OK, &tagsOption}, + + {TK_CONFIG_STRING, (char*)"-helvetica", NULL, NULL, "helvetica", + Tk_Offset(WidgetOptions, helvetica), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier", + Tk_Offset(WidgetOptions, courier), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times", + Tk_Offset(WidgetOptions, times), 0, NULL}, + + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}, +}; + +// Tk Static Structure + +static Tk_ItemType magnifierTrueColorType = { + (char*)"magnifiertruecolor", // name + sizeof(WidgetOptions), // size + MagnifierTrueColorCreateProc, // configProc + magnifierTrueColorSpecs, // configSpecs + WidgetConfigProc, // configProc + WidgetCoordProc, // coordProc + WidgetDeleteProc, // deleteProc + WidgetDisplayProc, // displayProc + 0, // alwaysRedraw + WidgetPointProc, // pointProc + WidgetAreaProc, // areaProc + WidgetPostscriptProc, // postscriptProc + WidgetScaleProc, // scaleProc + WidgetTranslateProc, // translateProc + (Tk_ItemIndexProc*)NULL, // indexProc + (Tk_ItemCursorProc*)NULL, // icursorProc + (Tk_ItemSelectionProc*)NULL, // selectionProc + (Tk_ItemInsertProc*)NULL, // insertProc + (Tk_ItemDCharsProc*)NULL, // dCharsProc + (Tk_ItemType*)NULL // nextPtr +}; + +// Non-Member Functions + +int MagnifierTrueColor_Init(Tcl_Interp* interp) +{ + Tk_CreateItemType(&magnifierTrueColorType); + return TCL_OK; +} + +int MagnifierTrueColorCreateProc(Tcl_Interp* interp, Tk_Canvas canvas, + Tk_Item* item, int argc, Tcl_Obj *const argv[]) +{ + MagnifierTrueColor* magnifier = new MagnifierTrueColor(interp, canvas, item); + + // and set default configuration + + if (magnifier->configure(argc, (const char**)argv, 0) != TCL_OK) { + delete magnifier; + Tcl_AppendResult(interp, " error occured while creating magnifier.", NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +MagnifierTrueColor::MagnifierTrueColor(Tcl_Interp* i, Tk_Canvas c, + Tk_Item* item) : Magnifier(i, c, item) +{ + configSpecs = magnifierTrueColorSpecs; // magnifier configure options +} + +void MagnifierTrueColor::clearPixmap() +{ + XImage* xmap = XGetImage(display, pixmap, 0, 0, options->width, + options->height, AllPlanes, ZPixmap); + if (!xmap) { + internalError("MagnifierTrueColor: Unable to Create XImage"); + return; + } + + memset(xmap->data, 255, xmap->bytes_per_line * xmap->height); + + TkPutImage(NULL, 0, display, pixmap, widgetGC, xmap, + 0, 0, 0, 0, options->width, options->height); + XDestroyImage(xmap); +} diff --git a/tksao/magnifier/magnifiertrue.h b/tksao/magnifier/magnifiertrue.h new file mode 100644 index 0000000..3e6ea4d --- /dev/null +++ b/tksao/magnifier/magnifiertrue.h @@ -0,0 +1,18 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __magnifiertrue_h__ +#define __magnifiertrue_h__ + +#include "magnifier.h" + +class MagnifierTrueColor : public Magnifier { +private: + void clearPixmap(); + +public: + MagnifierTrueColor(Tcl_Interp*, Tk_Canvas, Tk_Item*); +}; + +#endif diff --git a/tksao/magnifier/parser.C b/tksao/magnifier/parser.C new file mode 100644 index 0000000..798d0aa --- /dev/null +++ b/tksao/magnifier/parser.C @@ -0,0 +1,1670 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse mgparse +#define yylex mglex +#define yyerror mgerror +#define yylval mglval +#define yychar mgchar +#define yydebug mgdebug +#define yynerrs mgnerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + POINTER = 259, + BBOX_ = 260, + CLEAR_ = 261, + DEBUG_ = 262, + FALSE_ = 263, + GET_ = 264, + HEIGHT_ = 265, + HIDE_ = 266, + OFF_ = 267, + ON_ = 268, + N_ = 269, + NO_ = 270, + RESET_ = 271, + SHOW_ = 272, + TRUE_ = 273, + UPDATE_ = 274, + VERSION_ = 275, + WIDTH_ = 276, + Y_ = 277, + YES_ = 278 + }; +#endif +/* Tokens. */ +#define INT 258 +#define POINTER 259 +#define BBOX_ 260 +#define CLEAR_ 261 +#define DEBUG_ 262 +#define FALSE_ 263 +#define GET_ 264 +#define HEIGHT_ 265 +#define HIDE_ 266 +#define OFF_ 267 +#define ON_ 268 +#define N_ 269 +#define NO_ 270 +#define RESET_ 271 +#define SHOW_ 272 +#define TRUE_ 273 +#define UPDATE_ 274 +#define VERSION_ 275 +#define WIDTH_ 276 +#define Y_ 277 +#define YES_ 278 + + + + +/* Copy the first part of user declarations. */ +#line 10 "magnifier/parser.Y" + +#define YYDEBUG 1 + +#include +#include "magnifier.h" + +#undef yyFlexLexer +#define yyFlexLexer mgFlexLexer +#include + +extern int mglex(void*, mgFlexLexer*); +extern void mgerror(Magnifier*, mgFlexLexer*, const char*); + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 24 "magnifier/parser.Y" +{ + float real; + int integer; + void* ptr; + char str[1024]; +} +/* Line 193 of yacc.c. */ +#line 171 "magnifier/parser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 184 "magnifier/parser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 18 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 21 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 24 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 4 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 14 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 19 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 278 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 6, 8, 11, 13, 15, 17, 20, + 22, 24, 26, 28, 30 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 25, 0, -1, 7, 26, -1, 6, -1, 9, 27, + -1, 11, -1, 16, -1, 17, -1, 19, 4, -1, + 20, -1, 13, -1, 12, -1, 5, -1, 10, -1, + 21, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 56, 56, 57, 58, 59, 60, 61, 62, 63, + 66, 67, 70, 71, 72 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "INT", "POINTER", "BBOX_", "CLEAR_", + "DEBUG_", "FALSE_", "GET_", "HEIGHT_", "HIDE_", "OFF_", "ON_", "N_", + "NO_", "RESET_", "SHOW_", "TRUE_", "UPDATE_", "VERSION_", "WIDTH_", "Y_", + "YES_", "$accept", "command", "debug", "get", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 24, 25, 25, 25, 25, 25, 25, 25, 25, + 26, 26, 27, 27, 27 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 2, 1, 2, 1, 1, 1, 2, 1, + 1, 1, 1, 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 3, 0, 0, 5, 6, 7, 0, 9, 0, + 11, 10, 2, 12, 13, 14, 4, 8, 1 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 9, 12, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -12 +static const yytype_int8 yypact[] = +{ + 1, -12, -11, -5, -12, -12, -12, -1, -12, 4, + -12, -12, -12, -12, -12, -12, -12, -12, -12 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -12, -12, -12, -12 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_uint8 yytable[] = +{ + 13, 10, 11, 17, 18, 14, 0, 1, 2, 0, + 3, 0, 4, 0, 0, 0, 15, 5, 6, 0, + 7, 8 +}; + +static const yytype_int8 yycheck[] = +{ + 5, 12, 13, 4, 0, 10, -1, 6, 7, -1, + 9, -1, 11, -1, -1, -1, 21, 16, 17, -1, + 19, 20 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 6, 7, 9, 11, 16, 17, 19, 20, 25, + 12, 13, 26, 5, 10, 21, 27, 4, 0 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (mg, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, mg, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Magnifier* mg, mgFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, mg, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Magnifier* mg; + mgFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (mg); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Magnifier* mg, mgFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, mg, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Magnifier* mg; + mgFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, mg, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Magnifier* mg, mgFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, mg, ll) + YYSTYPE *yyvsp; + int yyrule; + Magnifier* mg; + mgFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , mg, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, mg, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Magnifier* mg, mgFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, mg, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + Magnifier* mg; + mgFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (mg); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (Magnifier* mg, mgFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (Magnifier* mg, mgFlexLexer* ll) +#else +int +yyparse (mg, ll) + Magnifier* mg; + mgFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 3: +#line 57 "magnifier/parser.Y" + {mg->updateCmd(0);;} + break; + + case 5: +#line 59 "magnifier/parser.Y" + {mg->hideCmd();;} + break; + + case 6: +#line 60 "magnifier/parser.Y" + {mg->resetCmd();;} + break; + + case 7: +#line 61 "magnifier/parser.Y" + {mg->showCmd();;} + break; + + case 8: +#line 62 "magnifier/parser.Y" + {mg->updateCmd((yyvsp[(2) - (2)].ptr));;} + break; + + case 9: +#line 63 "magnifier/parser.Y" + {mg->msg("Magnifier 1.0");;} + break; + + case 10: +#line 66 "magnifier/parser.Y" + {yydebug=1;;} + break; + + case 11: +#line 67 "magnifier/parser.Y" + {yydebug=0;;} + break; + + case 12: +#line 70 "magnifier/parser.Y" + {mg->getBBoxCmd();;} + break; + + case 13: +#line 71 "magnifier/parser.Y" + {mg->getHeightCmd();;} + break; + + case 14: +#line 72 "magnifier/parser.Y" + {mg->getWidthCmd();;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1451 "magnifier/parser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (mg, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (mg, ll, yymsg); + } + else + { + yyerror (mg, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, mg, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, mg, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (mg, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, mg, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, mg, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 75 "magnifier/parser.Y" + + + + + + diff --git a/tksao/magnifier/parser.H b/tksao/magnifier/parser.H new file mode 100644 index 0000000..04cd122 --- /dev/null +++ b/tksao/magnifier/parser.H @@ -0,0 +1,109 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + POINTER = 259, + BBOX_ = 260, + CLEAR_ = 261, + DEBUG_ = 262, + FALSE_ = 263, + GET_ = 264, + HEIGHT_ = 265, + HIDE_ = 266, + OFF_ = 267, + ON_ = 268, + N_ = 269, + NO_ = 270, + RESET_ = 271, + SHOW_ = 272, + TRUE_ = 273, + UPDATE_ = 274, + VERSION_ = 275, + WIDTH_ = 276, + Y_ = 277, + YES_ = 278 + }; +#endif +/* Tokens. */ +#define INT 258 +#define POINTER 259 +#define BBOX_ 260 +#define CLEAR_ 261 +#define DEBUG_ 262 +#define FALSE_ 263 +#define GET_ 264 +#define HEIGHT_ 265 +#define HIDE_ 266 +#define OFF_ 267 +#define ON_ 268 +#define N_ 269 +#define NO_ 270 +#define RESET_ 271 +#define SHOW_ 272 +#define TRUE_ 273 +#define UPDATE_ 274 +#define VERSION_ 275 +#define WIDTH_ 276 +#define Y_ 277 +#define YES_ 278 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 24 "magnifier/parser.Y" +{ + float real; + int integer; + void* ptr; + char str[1024]; +} +/* Line 1529 of yacc.c. */ +#line 102 "magnifier/parser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/magnifier/parser.Y b/tksao/magnifier/parser.Y new file mode 100644 index 0000000..b1e7681 --- /dev/null +++ b/tksao/magnifier/parser.Y @@ -0,0 +1,79 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {Magnifier* mg} +%lex-param {mgFlexLexer* ll} +%parse-param {mgFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#include +#include "magnifier.h" + +#undef yyFlexLexer +#define yyFlexLexer mgFlexLexer +#include + +extern int mglex(void*, mgFlexLexer*); +extern void mgerror(Magnifier*, mgFlexLexer*, const char*); +%} + +%union { + float real; + int integer; + void* ptr; + char str[1024]; +} + +%token INT +%token POINTER + +%token BBOX_ +%token CLEAR_ +%token DEBUG_ +%token FALSE_ +%token GET_ +%token HEIGHT_ +%token HIDE_ +%token OFF_ +%token ON_ +%token N_ +%token NO_ +%token RESET_ +%token SHOW_ +%token TRUE_ +%token UPDATE_ +%token VERSION_ +%token WIDTH_ +%token Y_ +%token YES_ + +%% + +command : DEBUG_ debug + | CLEAR_ {mg->updateCmd(0);} + | GET_ get + | HIDE_ {mg->hideCmd();} + | RESET_ {mg->resetCmd();} + | SHOW_ {mg->showCmd();} + | UPDATE_ POINTER {mg->updateCmd($2);} + | VERSION_ {mg->msg("Magnifier 1.0");} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + ; + +get : BBOX_ {mg->getBBoxCmd();} + | HEIGHT_ {mg->getHeightCmd();} + | WIDTH_ {mg->getWidthCmd();} + ; + +%% + + + + diff --git a/tksao/panner/lex.C b/tksao/panner/lex.C new file mode 100644 index 0000000..0d976f1 --- /dev/null +++ b/tksao/panner/lex.C @@ -0,0 +1,1832 @@ +#line 2 "panner/lex.C" + +#line 4 "panner/lex.C" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer pnFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *pnalloc (yy_size_t ); +void *pnrealloc (void *,yy_size_t ); +void pnfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 38 +#define YY_END_OF_BUFFER 39 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[144] = + { 0, + 0, 0, 39, 37, 36, 38, 37, 37, 32, 32, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 15, + 37, 37, 37, 37, 37, 37, 37, 37, 30, 36, + 0, 32, 34, 33, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, + 0, 18, 0, 0, 0, 0, 24, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 33, 35, 0, 0, + 0, 0, 0, 6, 0, 8, 0, 0, 0, 0, + 0, 0, 17, 19, 0, 0, 0, 0, 0, 0, + 0, 28, 0, 31, 0, 34, 1, 0, 0, 0, + + 0, 0, 0, 10, 0, 0, 0, 0, 0, 21, + 22, 23, 0, 0, 27, 0, 2, 3, 0, 5, + 7, 0, 0, 12, 0, 0, 20, 0, 0, 29, + 0, 9, 0, 0, 14, 25, 0, 4, 0, 13, + 26, 11, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 4, 1, 4, 5, 1, 6, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, + 1, 1, 1, 1, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 1, 1, 17, 18, 19, 20, 21, + 1, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 1, 1, 1, 1, 1, 1, 31, 32, 33, 34, + + 35, 36, 37, 38, 39, 1, 1, 40, 41, 42, + 43, 44, 1, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 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, 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, + 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, 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, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[54] = + { 0, + 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[145] = + { 0, + 0, 0, 300, 320, 297, 320, 49, 51, 54, 57, + 56, 50, 59, 53, 65, 62, 63, 58, 58, 60, + 68, 75, 72, 70, 91, 91, 102, 107, 104, 296, + 112, 115, 118, 135, 122, 0, 111, 118, 121, 125, + 135, 134, 131, 125, 135, 146, 144, 132, 135, 320, + 148, 320, 143, 140, 144, 135, 320, 144, 162, 154, + 155, 155, 168, 166, 187, 191, 197, 0, 162, 179, + 197, 185, 182, 320, 185, 320, 195, 198, 196, 200, + 207, 200, 320, 320, 205, 192, 208, 209, 214, 200, + 203, 320, 201, 320, 220, 229, 320, 222, 227, 242, + + 237, 240, 238, 320, 237, 243, 239, 237, 234, 320, + 320, 320, 235, 244, 320, 246, 320, 320, 239, 320, + 320, 239, 249, 320, 250, 248, 320, 256, 249, 320, + 247, 320, 247, 276, 320, 320, 276, 320, 284, 320, + 320, 320, 320, 295 + } ; + +static yyconst flex_int16_t yy_def[145] = + { 0, + 143, 1, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 144, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 144, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 0, 143 + } ; + +static yyconst flex_int16_t yy_nxt[374] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 4, 11, 12, + 13, 14, 15, 16, 17, 18, 4, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 4, 29, 4, + 4, 11, 12, 13, 14, 15, 16, 17, 18, 4, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 4, 29, 4, 31, 32, 32, 33, 33, 34, 32, + 32, 34, 32, 32, 37, 35, 39, 38, 35, 40, + 41, 42, 43, 44, 45, 47, 48, 49, 46, 50, + 51, 36, 53, 54, 55, 56, 52, 37, 35, 39, + 38, 35, 40, 41, 42, 43, 44, 45, 47, 48, + + 49, 46, 50, 51, 36, 53, 54, 55, 56, 52, + 57, 59, 58, 60, 61, 64, 62, 33, 33, 34, + 32, 32, 63, 33, 33, 66, 35, 67, 67, 65, + 69, 70, 71, 57, 59, 58, 60, 61, 64, 62, + 33, 33, 72, 73, 74, 63, 35, 75, 76, 35, + 77, 80, 65, 69, 70, 71, 78, 81, 82, 79, + 83, 84, 85, 86, 87, 72, 73, 74, 88, 35, + 75, 76, 89, 77, 80, 90, 91, 92, 93, 78, + 81, 82, 79, 83, 84, 85, 86, 87, 94, 97, + 95, 88, 96, 96, 98, 89, 67, 67, 90, 91, + + 92, 93, 67, 67, 99, 100, 101, 102, 103, 104, + 105, 94, 97, 106, 107, 108, 109, 98, 110, 111, + 112, 113, 114, 115, 116, 96, 96, 99, 100, 101, + 102, 103, 104, 105, 96, 96, 106, 107, 108, 109, + 117, 110, 111, 112, 113, 114, 115, 116, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, + 130, 131, 132, 117, 133, 134, 135, 136, 137, 138, + 139, 118, 119, 120, 121, 122, 123, 124, 125, 126, + 127, 128, 129, 130, 131, 132, 140, 133, 134, 135, + 136, 137, 138, 139, 141, 142, 68, 30, 30, 143, + + 143, 143, 143, 143, 143, 143, 143, 143, 143, 140, + 143, 143, 143, 143, 143, 143, 143, 141, 142, 3, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143 + } ; + +static yyconst flex_int16_t yy_chk[374] = + { 0, + 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, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 7, 7, 7, 8, 8, 9, 9, + 9, 10, 10, 10, 11, 9, 12, 11, 10, 12, + 13, 14, 15, 16, 17, 18, 18, 19, 17, 20, + 21, 9, 22, 23, 24, 24, 21, 11, 9, 12, + 11, 10, 12, 13, 14, 15, 16, 17, 18, 18, + + 19, 17, 20, 21, 9, 22, 23, 24, 24, 21, + 25, 26, 25, 27, 28, 29, 28, 31, 31, 32, + 32, 32, 28, 33, 33, 35, 32, 35, 35, 33, + 37, 38, 39, 25, 26, 25, 27, 28, 29, 28, + 34, 34, 40, 41, 42, 28, 34, 43, 44, 32, + 45, 47, 33, 37, 38, 39, 46, 48, 49, 46, + 51, 53, 54, 55, 56, 40, 41, 42, 58, 34, + 43, 44, 59, 45, 47, 60, 61, 62, 63, 46, + 48, 49, 46, 51, 53, 54, 55, 56, 64, 69, + 65, 58, 65, 65, 70, 59, 66, 66, 60, 61, + + 62, 63, 67, 67, 71, 72, 73, 75, 77, 78, + 79, 64, 69, 80, 81, 82, 85, 70, 86, 87, + 88, 89, 90, 91, 93, 95, 95, 71, 72, 73, + 75, 77, 78, 79, 96, 96, 80, 81, 82, 85, + 98, 86, 87, 88, 89, 90, 91, 93, 99, 100, + 101, 102, 103, 105, 106, 107, 108, 109, 113, 114, + 116, 119, 122, 98, 123, 125, 126, 128, 129, 131, + 133, 99, 100, 101, 102, 103, 105, 106, 107, 108, + 109, 113, 114, 116, 119, 122, 134, 123, 125, 126, + 128, 129, 131, 133, 137, 139, 144, 30, 5, 3, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 134, + 0, 0, 0, 0, 0, 0, 0, 137, 139, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "panner/lex.L" +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ +#line 12 "panner/lex.L" + #include + #include + #include + + #include "parser.H" + + extern YYSTYPE* pnlval; +/* rules */ +#line 550 "panner/lex.C" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 26 "panner/lex.L" + + +#line 653 "panner/lex.C" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 144 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 143 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 28 "panner/lex.L" +{return BBOX_;} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 29 "panner/lex.L" +{return BEGIN_;} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 30 "panner/lex.L" +{return CLEAR_;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 31 "panner/lex.L" +{return COMPASS_;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 32 "panner/lex.L" +{return DEBUG_;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 33 "panner/lex.L" +{return END_;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 34 "panner/lex.L" +{return FALSE_;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 35 "panner/lex.L" +{return GET_;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 36 "panner/lex.L" +{return HEIGHT_;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 37 "panner/lex.L" +{return HIDE_;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 38 "panner/lex.L" +{return HIGHLITE_;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 39 "panner/lex.L" +{return IMAGE_;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 40 "panner/lex.L" +{return INVALID_;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 41 "panner/lex.L" +{return MOTION_;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 42 "panner/lex.L" +{return N_;} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 43 "panner/lex.L" +{return NO_;} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 44 "panner/lex.L" +{return OFF_;} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 45 "panner/lex.L" +{return ON_;} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 46 "panner/lex.L" +{return PAN_;} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 47 "panner/lex.L" +{return RESET_;} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 48 "panner/lex.L" +{return SHOW_;} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 49 "panner/lex.L" +{return SIZE_;} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 50 "panner/lex.L" +{return TRUE_;} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 51 "panner/lex.L" +{return TO_;} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 52 "panner/lex.L" +{return UPDATE_;} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 53 "panner/lex.L" +{return VERSION_;} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 54 "panner/lex.L" +{return WARP_;} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 55 "panner/lex.L" +{return WCS_;} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 56 "panner/lex.L" +{return WIDTH_;} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 57 "panner/lex.L" +{return Y_;} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 58 "panner/lex.L" +{return YES_;} + YY_BREAK +case 32: +YY_RULE_SETUP +#line 61 "panner/lex.L" +{ // Integer + pnlval->integer = atoi(yytext); + return INT; + } + YY_BREAK +case 33: +#line 67 "panner/lex.L" +case 34: +YY_RULE_SETUP +#line 67 "panner/lex.L" +{ // Real Number + pnlval->real = atof(yytext); + return REAL; + } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 72 "panner/lex.L" +{ // Pointer + pnlval->ptr = (void*)strtoul(yytext,NULL,16); + return POINTER; + } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 77 "panner/lex.L" +{ // White Spaces + } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 80 "panner/lex.L" +{ // Else, return the char + return yytext[0]; + } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 84 "panner/lex.L" +ECHO; + YY_BREAK +#line 931 "panner/lex.C" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + pnfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + pnfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +size_t yyFlexLexer::LexerInput( char* buf, size_t /* max_size */ ) +#else +size_t yyFlexLexer::LexerInput( char* buf, size_t max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, size_t size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + pnrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) pnrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 144 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 144 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 143); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) pnalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) pnalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + pnfree((void *) b->yy_ch_buf ); + + pnfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)pnalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)pnrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) pnalloc(new_size ); + + else + (yy_start_stack) = (int *) pnrealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *pnalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *pnrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void pnfree (void * ptr ) +{ + free( (char *) ptr ); /* see pnrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 84 "panner/lex.L" + + + diff --git a/tksao/panner/lex.L b/tksao/panner/lex.L new file mode 100644 index 0000000..22c43ff --- /dev/null +++ b/tksao/panner/lex.L @@ -0,0 +1,84 @@ +/* Copyright (C) 1999-2016 + * Smithsonian Astrophysical Observatory, Cambridge, MA, USA + * For conditions of distribution and use, see copyright notice in "copyright" + */ + +%option noyywrap +%option caseless +%option never-interactive +%option c++ + +%{ + #include + #include + #include + + #include "parser.H" + + extern YYSTYPE* pnlval; +%} + +D [0-9] +E [Ee][+-]?{D}+ + +/* rules */ + +%% + +bbox {return BBOX_;} +begin {return BEGIN_;} +clear {return CLEAR_;} +compass {return COMPASS_;} +debug {return DEBUG_;} +end {return END_;} +false {return FALSE_;} +get {return GET_;} +height {return HEIGHT_;} +hide {return HIDE_;} +highlite {return HIGHLITE_;} +image {return IMAGE_;} +invalid {return INVALID_;} +motion {return MOTION_;} +n {return N_;} +no {return NO_;} +off {return OFF_;} +on {return ON_;} +pan {return PAN_;} +reset {return RESET_;} +show {return SHOW_;} +size {return SIZE_;} +true {return TRUE_;} +to {return TO_;} +update {return UPDATE_;} +version {return VERSION_;} +warp {return WARP_;} +wcs {return WCS_;} +width {return WIDTH_;} +y {return Y_;} +yes {return YES_;} + + +[+-]?{D}+ { // Integer + pnlval->integer = atoi(yytext); + return INT; + } + +[+-]?{D}+"."?({E})? | +[+-]?{D}*"."{D}+({E})? { // Real Number + pnlval->real = atof(yytext); + return REAL; + } + +0[xX][0-9a-fA-F]+ { // Pointer + pnlval->ptr = (void*)strtoul(yytext,NULL,16); + return POINTER; + } + +[ \t]+ { // White Spaces + } + +. { // Else, return the char + return yytext[0]; + } + +%% diff --git a/tksao/panner/panner.C b/tksao/panner/panner.C new file mode 100644 index 0000000..4e0251b --- /dev/null +++ b/tksao/panner/panner.C @@ -0,0 +1,434 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include + +#include "panner.h" +#include "util.h" + +// Parser Stuff +#undef yyFlexLexer +#define yyFlexLexer pnFlexLexer +#include + +void* pnlval; +extern int pnparse(Panner*, pnFlexLexer*); + +int pnlex(void* vval, pnFlexLexer* ll) +{ + pnlval = vval; + return ll ? ll->yylex() : 0; +} + +void pnerror(Panner* pn, pnFlexLexer* ll, const char* m) +{ + pn->error(m); + const char* cmd = ll ? ll->YYText() : (const char*)NULL; + if (cmd && cmd[0] != '\n') { + pn->error(": "); + pn->error(cmd); + } +} + +// Public Member Functions + +Panner::Panner(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) : Widget(i, c, item) +{ + thumbnail = 0; + highLite = 0; + panning = 0; + needsUpdate = 0; + + bboxGC = NULL; + useBBox = 1; + + compassGC = NULL; + threed = 0; + useCompass = 1; + validWCSCompass = 0; + + tkfont_ = NULL; +} + +Panner::~Panner() +{ + if (bboxGC) + XFreeGC(display, bboxGC); + + if (compassGC) + XFreeGC(display, compassGC); + + if (tkfont_) + Tk_FreeFont(tkfont_); +} + +int Panner::parse(istringstream& istr) +{ + result = TCL_OK; + pnFlexLexer* ll = new pnFlexLexer(&istr); + pnparse(this, ll); + delete ll; + + return result; +} + +void Panner::update() +{ + needsUpdate = 1; + redraw(); +} + +// Required Virtual Functions + +// UpdatePixmap. This function is responsable for creating a valid +// pixmap the size of the current Panner + +int Panner::updatePixmap(const BBox& bb) +{ + if (!widgetGC) + widgetGC = XCreateGC(display, Tk_WindowId(tkwin), 0, NULL); + + // bb is in canvas coords + // create a valid pixmap if needed + + if (!pixmap) { + if (!(pixmap = Tk_GetPixmap(display, Tk_WindowId(tkwin), + options->width, options->height, depth))) { + internalError("Panner: Unable to Create Pixmap"); + return TCL_OK; + } + + updateGCs(); + } + + if (needsUpdate) { + if (thumbnail) { + XSetClipOrigin(display, widgetGC, 0, 0); + XCopyArea(display, thumbnail, pixmap, widgetGC, 0, 0, + options->width, options->height, 0, 0); + + if (useBBox) + renderBBox(); + + if (useCompass) { + renderImageCompass(); + if (validWCSCompass) + renderWCSCompass(); + } + } + else + clearPixmap(); + + needsUpdate = 0; + } + + return TCL_OK; +} + +void Panner::invalidPixmap() +{ + Widget::invalidPixmap(); + update(); +} + +// Command Functions + +void Panner::getBBoxCmd() +{ + Vector v = bbox[0]; + for (int i=1; i<4; i++) + v += bbox[i]; + v /= 4; + + ostringstream str; + str << v << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Panner::getSizeCmd() +{ + ostringstream str; + str << options->width << " " << options->height << ends; + Tcl_AppendResult(interp, str.str().c_str(), NULL); +} + +void Panner::highLiteCmd(int which) +{ + if (highLite != which) { + highLite = !highLite; + update(); + } +} + +void Panner::highLiteCmd(const Vector& v) +{ + if (highLite != isInBBox(v)) { + highLite = !highLite; + update(); + } +} + +void Panner::panToCmd(const Vector& v) +{ + for (int i=0; i<4; i++) + bbox[i] = v; + update(); +} + +void Panner::panBeginCmd(const Vector& v) +{ + if (useBBox && isInBBox(v)) { + panStart = v; + panning = 1; + } +} + +void Panner::panMotionCmd(const Vector& v) +{ + if (panning && useBBox) { + Vector diff = v - panStart; + for (int i=0; i<4; i++) + bbox[i] += diff; + + panStart = v; + update(); + } +} + +void Panner::panEndCmd(const Vector& v) +{ + if (panning && useBBox) { + Vector diff = v - panStart; + for (int i=0; i<4; i++) + bbox[i] += diff; + + panning = 0; + update(); + } +} + +void Panner::setCompassCmd(int w) +{ + useCompass = w ? 1 : 0; + update(); +} + +void Panner::setBBoxCmd(int w) +{ + useBBox = w ? 1 : 0; + update(); +} + +void Panner::updateCmd(void* p) +{ + thumbnail = (Pixmap)p; + update(); +} + +void Panner::updateBBoxCmd(const Vector& ll, const Vector& lr, + const Vector& ur, const Vector& ul) +{ + bbox[0] = ll; + bbox[1] = lr; + bbox[2] = ur; + bbox[3] = ul; + + update(); +} + +void Panner::updateImageCompassCmd(Vector xx, Vector yy) +{ + threed =0; + imageX = xx; + imageY = yy; + update(); +} + +void Panner::updateImageCompassCmd(Vector xx, Vector yy, Vector zz) +{ + threed =1; + imageX = xx; + imageY = yy; + imageZ = zz; + update(); +} + +void Panner::updateWCSCompassCmd() +{ + validWCSCompass = 0; + update(); +} + +void Panner::updateWCSCompassCmd(const Vector& nn, const Vector& ee) +{ + validWCSCompass = 1; + wcsNorth = nn; + wcsEast = ee; + update(); + } + +void Panner::warpCmd(const Vector& vv) +{ + warp((Vector&)vv); +} + +// Private Functions + +void Panner::updateGCs() +{ + if (!bboxGC) { + bboxGC = XCreateGC(display, pixmap, 0, NULL); + XSetForeground(display, bboxGC, getColor("cyan")); + } + + if (!tkfont_) { + ostringstream fstr; +#ifdef MAC_OSX_TK + fstr << '{' << options->helvetica << '}' << ' ' << int(9*getDisplayRatio()) << " roman normal" << ends; +#else + fstr << '{' << options->helvetica << '}' << " 9 roman normal" << ends; +#endif + tkfont_ = Tk_GetFont(interp, tkwin, fstr.str().c_str()); + if (tkfont_) + Tk_GetFontMetrics(tkfont_, &metric); + } + + if (!compassGC) { + compassGC = XCreateGC(display, pixmap, 0, NULL); + XSetLineAttributes(display, compassGC, 1, LineSolid, CapButt, JoinMiter); + if (tkfont_) + XSetFont(display, compassGC, Tk_FontId(tkfont_)); + } +} + +void Panner::renderBBox() +{ + XSetLineAttributes(display, bboxGC, (highLite ? 2 : 1), LineSolid, + CapButt,JoinMiter); + + for (int i=0; i<3; i++) + XDrawLine(display, pixmap, bboxGC, (int)(bbox[i])[0], (int)(bbox[i])[1], + (int)(bbox[i+1])[0], (int)(bbox[i+1])[1]); + XDrawLine(display, pixmap, bboxGC, (int)(bbox[3])[0], (int)(bbox[3])[1], + (int)(bbox[0])[0], (int)(bbox[0])[1]); +} + +void Panner::renderImageCompass() +{ + float length = (options->width/2 + options->height/2)/2 * .4; + Vector center(options->width/2., options->height/2.); + + renderArm(int(length*imageX.length()), center, + Rotate(-imageX.angle()), "X", getColor("green")); + renderArm(int(length*imageY.length()), center, + Rotate(-imageY.angle()), "Y", getColor("green")); + if (threed) { + renderArm(int(length*imageZ.length()), center, + Rotate(-imageZ.angle()), "Z", getColor("green")); + } +} + +void Panner::renderWCSCompass() +{ + float length = (options->width/2 + options->height/2)/2 * .25; + Vector center(options->width/2., options->height/2.); + + renderArm(int(length*wcsEast.length()), center, + Rotate(-wcsEast.angle()), "E", getColor("yellow")); + renderArm(int(length*wcsNorth.length()), center, + Rotate(-wcsNorth.angle()), "N", getColor("yellow")); +} + +void Panner::renderArm(int length, Vector center, Rotate rot, + const char* str, int color) +{ + if (length<=0) + return; + + // set GC + XSetForeground(display, compassGC, color); + const int textOffset = 15; // Text offset + const int tip = 6; // length from end of line to tip of arrow + const int tail = 2; // length from end of line to tails of arrow + const int wc = 2; // width of arrow at end of line + const int wt = 3; // width of arrow at tails + + // Arrow-- oriented on Y axis + Vector arrow[6]; + arrow[0] = Vector(0, tip); + arrow[1] = Vector(-wc, 0); + arrow[2] = Vector(-wt, -tail); + arrow[3] = Vector(0, 0); + arrow[4] = Vector(wt, -tail); + arrow[5] = Vector(wc, 0); + + // Staff-- oriented on X axis + XPoint arrowArray[6]; + Matrix arrowMatrix = Rotate(M_PI_2) * + Translate(length,0) * + rot * + Translate(center); + for (int i=0; i<6; i++) { + Vector r = (arrow[i] * arrowMatrix).round(); + arrowArray[i].x = (int)r[0]; + arrowArray[i].y = (int)r[1]; + } + + Vector c = ((Vector&)center).round(); + Vector end = (Vector(length, 0) * rot * Translate(center)).round(); + XDrawLine(display, pixmap, compassGC, (int)c[0], (int)c[1], + (int)end[0], (int)end[1]); + XFillPolygon(display, pixmap, compassGC, arrowArray, 6, + Nonconvex, CoordModeOrigin); + + if (tkfont_) { + Vector et = Vector((length + textOffset), 0) * rot * Translate(center) * + Translate(-Tk_TextWidth(tkfont_, str, 1)/2., metric.ascent/2.); + Tk_DrawChars(display, pixmap, compassGC, tkfont_, str, 1, + (int)et[0], (int)et[1]); + } +} + +int Panner::isInBBox(const Vector& v) +{ + /* + v[0]-- x value of point being tested + v[1]-- y value of point being tested + + This algorithm is from "An Introduction to Ray Tracing", Academic Press, + 1989, edited by Andrew Glassner, pg 53 + -- a point lies in a polygon if a line is extended from the point to + infinite in any direction and the number of intersections with the + polygon is odd. + This is valid for both concave and convex polygons. + Points on a vertex are considered inside. + Points on a edge are considered inside. + */ + + int crossings = 0; // number of crossings + Vector v1; + Vector v2 = bbox[0] - v; + int sign = ((v2[1])>=0) ? 1 : -1; // init sign + + // for all edges + for (int i=1; i<4; i++) { + // look at next two vertices + v1 = v2; + v2 = bbox[i] - v; + int nextSign = (v2[1]>=0) ? 1 : -1; // sign holder for p2 + + if (sign != nextSign) { + if (v1[0]>0 && v2[0]>0) + crossings++; + else if (v1[0]>0 || v2[0]>0) { + if (v1[0]-(v1[1]*(v2[0]-v1[0])/(v2[1]-v1[1])) > 0) + crossings++; + } + sign = nextSign; + } + } + + return fmod(float(crossings),float(2)) ? 1 : 0; // if odd, point is inside +} diff --git a/tksao/panner/panner.h b/tksao/panner/panner.h new file mode 100644 index 0000000..7aa7404 --- /dev/null +++ b/tksao/panner/panner.h @@ -0,0 +1,79 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __panner_h__ +#define __panner_h__ + +#include "widget.h" + +class Panner : public Widget { + private: + Pixmap thumbnail; // current frame thumbnail pixmap + int highLite; // flag to highlite bbox + int panning; // flag for panning status + Vector panStart; // initial location of panning operation + int needsUpdate; // flag to indicate refresh needed + + GC bboxGC; // bbox gc + int useBBox; // flag to use BBox + Vector bbox[4]; // current view + + GC compassGC; // compass gc + Vector imageX; + Vector imageY; + Vector imageZ; + int threed; // 2d or 3d compass + int useCompass; // flag to use image/wcs compass + Vector wcsNorth; + Vector wcsEast; + int validWCSCompass; // flag to indicate wcs data is valid + + Tk_Font tkfont_; // Tk font + Tk_FontMetrics metric; // Tk font metric + + private: + void update(); // use existing pixmap, just update + void invalidPixmap(); // new pixmap, then update + + protected: + virtual void clearPixmap() =0; // clear pixmap + + private: + int updatePixmap(const BBox&); // renders image/graphics into pixmap + void renderBBox(); + int isInBBox(const Vector&); + void renderImageCompass(); + void renderWCSCompass(); + void renderArm(int, Vector, Rotate, const char*, int); + void updateGCs(); + + public: + Panner(Tcl_Interp*, Tk_Canvas, Tk_Item*); + virtual ~Panner(); + + int parse(istringstream&); // parse subcommands + + // SubCommandFunctions + + void getBBoxCmd(); + void getSizeCmd(); + void highLiteCmd(int); + void highLiteCmd(const Vector&); + void panToCmd(const Vector&); + void panBeginCmd(const Vector&); + void panMotionCmd(const Vector&); + void panEndCmd(const Vector&); + void setCompassCmd(int); + void setBBoxCmd(int); + void updateCmd(void*); + void updateBBoxCmd(const Vector&, const Vector&, + const Vector&, const Vector&); + void updateImageCompassCmd(Vector, Vector); + void updateImageCompassCmd(Vector, Vector, Vector); + void updateWCSCompassCmd(); + void updateWCSCompassCmd(const Vector&, const Vector&); + void warpCmd(const Vector&); +}; + +#endif diff --git a/tksao/panner/pannertrue.C b/tksao/panner/pannertrue.C new file mode 100644 index 0000000..7bbabe2 --- /dev/null +++ b/tksao/panner/pannertrue.C @@ -0,0 +1,119 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "pannertrue.h" +#include "util.h" + +// Tk Canvas Widget Function Declarations + +int PannerTrueColorCreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int, + Tcl_Obj *const []); + +// PannerTrueColor Specs + +static Tk_CustomOption tagsOption = { + Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL +}; + +static Tk_ConfigSpec pannerTrueColorSpecs[] = { + + {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "panner", + Tk_Offset(WidgetOptions, cmdName), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1", + Tk_Offset(WidgetOptions, x), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1", + Tk_Offset(WidgetOptions, y), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "256", + Tk_Offset(WidgetOptions, width), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "256", + Tk_Offset(WidgetOptions, height), TK_CONFIG_OPTION_SPECIFIED, NULL}, + {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw", + Tk_Offset(WidgetOptions, anchor), 0, NULL}, + {TK_CONFIG_CUSTOM, (char*)"-tags", NULL, NULL, NULL, + 0, TK_CONFIG_NULL_OK, &tagsOption}, + + {TK_CONFIG_STRING, (char*)"-helvetica", NULL, NULL, "helvetica", + Tk_Offset(WidgetOptions, helvetica), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier", + Tk_Offset(WidgetOptions, courier), 0, NULL}, + {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times", + Tk_Offset(WidgetOptions, times), 0, NULL}, + + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}, +}; + +// Tk Static Structure + +static Tk_ItemType pannerTrueColorType = { + (char*)"pannertruecolor", // name + sizeof(WidgetOptions), // size + PannerTrueColorCreateProc, // configProc + pannerTrueColorSpecs, // configSpecs + WidgetConfigProc, // configProc + WidgetCoordProc, // coordProc + WidgetDeleteProc, // deleteProc + WidgetDisplayProc, // displayProc + 0, // alwaysRedraw + WidgetPointProc, // pointProc + WidgetAreaProc, // areaProc + WidgetPostscriptProc, // postscriptProc + WidgetScaleProc, // scaleProc + WidgetTranslateProc, // translateProc + (Tk_ItemIndexProc*)NULL, // indexProc + WidgetICursorProc, // icursorProc + (Tk_ItemSelectionProc*)NULL, // selectionProc + (Tk_ItemInsertProc*)NULL, // insertProc + (Tk_ItemDCharsProc*)NULL, // dCharsProc + (Tk_ItemType*)NULL // nextPtr +}; + +// Non-Member Functions + +int PannerTrueColor_Init(Tcl_Interp* interp) +{ + Tk_CreateItemType(&pannerTrueColorType); + return TCL_OK; +} + +int PannerTrueColorCreateProc(Tcl_Interp* interp, Tk_Canvas canvas, + Tk_Item* item, int argc, Tcl_Obj *const argv[]) +{ + PannerTrueColor* panner = new PannerTrueColor(interp, canvas, item); + + // and set default configuration + + if (panner->configure(argc, (const char**)argv, 0) != TCL_OK) { + delete panner; + Tcl_AppendResult(interp, " error occured while creating pannerTrueColor.", + NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +PannerTrueColor::PannerTrueColor(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) + : Panner(i, c, item) +{ + configSpecs = pannerTrueColorSpecs; // panner configure options +} + +void PannerTrueColor::clearPixmap() +{ + XImage* xmap = XGetImage(display, pixmap, 0, 0, + options->width, options->height, + AllPlanes, ZPixmap); + if (!xmap) { + internalError("Panner: Unable to Create XImage"); + return; + } + + memset(xmap->data, 255, xmap->bytes_per_line * xmap->height); + + TkPutImage(NULL, 0, display, pixmap, widgetGC, xmap, + 0, 0, 0, 0, options->width, options->height); + XDestroyImage(xmap); +} diff --git a/tksao/panner/pannertrue.h b/tksao/panner/pannertrue.h new file mode 100644 index 0000000..ac30353 --- /dev/null +++ b/tksao/panner/pannertrue.h @@ -0,0 +1,19 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __pannertrue_h__ +#define __pannertrue_h__ + +#include "panner.h" + +class PannerTrueColor : public Panner { +private: + void clearPixmap(); + +public: + PannerTrueColor(Tcl_Interp*, Tk_Canvas, Tk_Item*); +}; + +#endif + diff --git a/tksao/panner/parser.C b/tksao/panner/parser.C new file mode 100644 index 0000000..93c522f --- /dev/null +++ b/tksao/panner/parser.C @@ -0,0 +1,1923 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse pnparse +#define yylex pnlex +#define yyerror pnerror +#define yylval pnlval +#define yychar pnchar +#define yydebug pndebug +#define yynerrs pnnerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + POINTER = 260, + BBOX_ = 261, + BEGIN_ = 262, + CLEAR_ = 263, + COMPASS_ = 264, + DEBUG_ = 265, + END_ = 266, + FALSE_ = 267, + GET_ = 268, + HEIGHT_ = 269, + HIDE_ = 270, + HIGHLITE_ = 271, + IMAGE_ = 272, + INVALID_ = 273, + MOTION_ = 274, + N_ = 275, + NO_ = 276, + OFF_ = 277, + ON_ = 278, + PAN_ = 279, + RESET_ = 280, + SHOW_ = 281, + SIZE_ = 282, + TRUE_ = 283, + TO_ = 284, + UPDATE_ = 285, + VERSION_ = 286, + WARP_ = 287, + WCS_ = 288, + WIDTH_ = 289, + Y_ = 290, + YES_ = 291 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define POINTER 260 +#define BBOX_ 261 +#define BEGIN_ 262 +#define CLEAR_ 263 +#define COMPASS_ 264 +#define DEBUG_ 265 +#define END_ 266 +#define FALSE_ 267 +#define GET_ 268 +#define HEIGHT_ 269 +#define HIDE_ 270 +#define HIGHLITE_ 271 +#define IMAGE_ 272 +#define INVALID_ 273 +#define MOTION_ 274 +#define N_ 275 +#define NO_ 276 +#define OFF_ 277 +#define ON_ 278 +#define PAN_ 279 +#define RESET_ 280 +#define SHOW_ 281 +#define SIZE_ 282 +#define TRUE_ 283 +#define TO_ 284 +#define UPDATE_ 285 +#define VERSION_ 286 +#define WARP_ 287 +#define WCS_ 288 +#define WIDTH_ 289 +#define Y_ 290 +#define YES_ 291 + + + + +/* Copy the first part of user declarations. */ +#line 10 "panner/parser.Y" + +#define YYDEBUG 1 + +#include +#include "panner.h" + +#undef yyFlexLexer +#define yyFlexLexer pnFlexLexer +#include + +extern int pnlex(void*, pnFlexLexer*); +extern void pnerror(Panner*, pnFlexLexer*, const char*); + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 24 "panner/parser.Y" +{ + float real; + int integer; + void* ptr; + char str[1024]; +} +/* Line 193 of yacc.c. */ +#line 197 "panner/parser.C" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 210 "panner/parser.C" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 57 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 118 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 37 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 12 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 50 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 93 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 291 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 6, 9, 11, 14, 18, 21, 23, + 26, 29, 31, 33, 36, 38, 42, 46, 48, 50, + 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, + 72, 74, 76, 78, 80, 82, 84, 87, 89, 91, + 95, 99, 103, 107, 109, 119, 123, 127, 132, 139, + 144 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 38, 0, -1, 10, 40, -1, 6, 42, -1, 8, + -1, 9, 41, -1, 17, 9, 41, -1, 13, 43, + -1, 15, -1, 16, 44, -1, 24, 45, -1, 25, + -1, 26, -1, 30, 46, -1, 31, -1, 32, 39, + 39, -1, 33, 9, 41, -1, 4, -1, 3, -1, + 23, -1, 22, -1, 3, -1, 36, -1, 35, -1, + 23, -1, 28, -1, 21, -1, 20, -1, 22, -1, + 12, -1, 23, -1, 22, -1, 6, -1, 14, -1, + 27, -1, 34, -1, 39, 39, -1, 22, -1, 23, + -1, 7, 39, 39, -1, 19, 39, 39, -1, 11, + 39, 39, -1, 29, 39, 39, -1, 5, -1, 6, + 39, 39, 39, 39, 39, 39, 39, 39, -1, 17, + 9, 47, -1, 33, 9, 48, -1, 39, 39, 39, + 39, -1, 39, 39, 39, 39, 39, 39, -1, 39, + 39, 39, 39, -1, 18, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 72, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 89, 90, 93, + 94, 97, 99, 100, 101, 102, 104, 105, 106, 107, + 110, 111, 114, 115, 116, 117, 120, 121, 122, 125, + 126, 127, 128, 131, 132, 136, 137, 140, 142, 147, + 149 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "INT", "REAL", "POINTER", "BBOX_", + "BEGIN_", "CLEAR_", "COMPASS_", "DEBUG_", "END_", "FALSE_", "GET_", + "HEIGHT_", "HIDE_", "HIGHLITE_", "IMAGE_", "INVALID_", "MOTION_", "N_", + "NO_", "OFF_", "ON_", "PAN_", "RESET_", "SHOW_", "SIZE_", "TRUE_", "TO_", + "UPDATE_", "VERSION_", "WARP_", "WCS_", "WIDTH_", "Y_", "YES_", + "$accept", "command", "numeric", "debug", "yesno", "bbox", "get", + "highLite", "pan", "update", "updateImageCompass", "updateWCSCompass", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 37, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 39, 39, 40, + 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, + 42, 42, 43, 43, 43, 43, 44, 44, 44, 45, + 45, 45, 45, 46, 46, 46, 46, 47, 47, 48, + 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 2, 2, 1, 2, 3, 2, 1, 2, + 2, 1, 1, 2, 1, 3, 3, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 2, 1, 1, 3, + 3, 3, 3, 1, 9, 3, 3, 4, 6, 4, + 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 0, 4, 0, 0, 0, 8, 0, 0, 0, + 11, 12, 0, 14, 0, 0, 0, 31, 30, 3, + 21, 29, 27, 26, 28, 24, 25, 23, 22, 5, + 20, 19, 2, 32, 33, 34, 35, 7, 18, 17, + 37, 38, 0, 9, 0, 0, 0, 0, 0, 10, + 43, 0, 0, 0, 13, 0, 0, 1, 36, 6, + 0, 0, 0, 0, 0, 0, 0, 15, 16, 39, + 41, 40, 42, 0, 0, 45, 50, 0, 46, 0, + 0, 0, 0, 0, 0, 0, 47, 49, 0, 0, + 0, 48, 44 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 16, 42, 32, 29, 19, 37, 43, 49, 54, + 75, 78 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -37 +static const yytype_int8 yypact[] = +{ + 85, -12, -37, 61, -7, -5, -37, 1, 17, 6, + -37, -37, -3, -37, 15, 18, 12, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, 15, -37, 61, 15, 15, 15, 15, -37, + -37, 15, 27, 29, -37, 15, 61, -37, -37, -37, + 15, 15, 15, 15, 15, 15, 3, -37, -37, -37, + -37, -37, -37, 15, 15, -37, -37, 15, -37, 15, + 15, 15, 15, 15, 15, 15, 15, -37, 15, 15, + 15, -37, -37 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -37, -37, -14, -37, -36, -37, -37, -37, -37, -37, + -37, -37 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_uint8 yytable[] = +{ + 55, 33, 50, 51, 38, 39, 38, 39, 59, 34, + 17, 18, 57, 45, 52, 30, 31, 46, 38, 39, + 68, 76, 35, 40, 41, 47, 44, 56, 58, 36, + 53, 60, 61, 62, 63, 48, 65, 64, 66, 0, + 0, 67, 0, 0, 0, 0, 69, 70, 71, 72, + 73, 74, 77, 0, 0, 0, 0, 0, 0, 79, + 80, 0, 0, 81, 20, 82, 83, 84, 85, 86, + 87, 88, 89, 21, 90, 91, 92, 0, 0, 0, + 0, 22, 23, 24, 25, 0, 0, 0, 0, 26, + 0, 1, 0, 2, 3, 4, 27, 28, 5, 0, + 6, 7, 8, 0, 0, 0, 0, 0, 0, 9, + 10, 11, 0, 0, 0, 12, 13, 14, 15 +}; + +static const yytype_int8 yycheck[] = +{ + 14, 6, 5, 6, 3, 4, 3, 4, 44, 14, + 22, 23, 0, 7, 17, 22, 23, 11, 3, 4, + 56, 18, 27, 22, 23, 19, 9, 9, 42, 34, + 33, 45, 46, 47, 48, 29, 9, 51, 9, -1, + -1, 55, -1, -1, -1, -1, 60, 61, 62, 63, + 64, 65, 66, -1, -1, -1, -1, -1, -1, 73, + 74, -1, -1, 77, 3, 79, 80, 81, 82, 83, + 84, 85, 86, 12, 88, 89, 90, -1, -1, -1, + -1, 20, 21, 22, 23, -1, -1, -1, -1, 28, + -1, 6, -1, 8, 9, 10, 35, 36, 13, -1, + 15, 16, 17, -1, -1, -1, -1, -1, -1, 24, + 25, 26, -1, -1, -1, 30, 31, 32, 33 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 6, 8, 9, 10, 13, 15, 16, 17, 24, + 25, 26, 30, 31, 32, 33, 38, 22, 23, 42, + 3, 12, 20, 21, 22, 23, 28, 35, 36, 41, + 22, 23, 40, 6, 14, 27, 34, 43, 3, 4, + 22, 23, 39, 44, 9, 7, 11, 19, 29, 45, + 5, 6, 17, 33, 46, 39, 9, 0, 39, 41, + 39, 39, 39, 39, 39, 9, 9, 39, 41, 39, + 39, 39, 39, 39, 39, 47, 18, 39, 48, 39, + 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 39 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (pn, ll, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, ll) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, pn, ll); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Panner* pn, pnFlexLexer* ll) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, pn, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Panner* pn; + pnFlexLexer* ll; +#endif +{ + if (!yyvaluep) + return; + YYUSE (pn); + YYUSE (ll); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Panner* pn, pnFlexLexer* ll) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, pn, ll) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + Panner* pn; + pnFlexLexer* ll; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, pn, ll); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Panner* pn, pnFlexLexer* ll) +#else +static void +yy_reduce_print (yyvsp, yyrule, pn, ll) + YYSTYPE *yyvsp; + int yyrule; + Panner* pn; + pnFlexLexer* ll; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , pn, ll); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, pn, ll); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Panner* pn, pnFlexLexer* ll) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, pn, ll) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + Panner* pn; + pnFlexLexer* ll; +#endif +{ + YYUSE (yyvaluep); + YYUSE (pn); + YYUSE (ll); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (Panner* pn, pnFlexLexer* ll); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (Panner* pn, pnFlexLexer* ll) +#else +int +yyparse (pn, ll) + Panner* pn; + pnFlexLexer* ll; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 4: +#line 74 "panner/parser.Y" + {pn->updateCmd(0);;} + break; + + case 5: +#line 75 "panner/parser.Y" + {pn->setCompassCmd((yyvsp[(2) - (2)].integer));;} + break; + + case 6: +#line 76 "panner/parser.Y" + {pn->setCompassCmd((yyvsp[(3) - (3)].integer));;} + break; + + case 8: +#line 78 "panner/parser.Y" + {pn->hideCmd();;} + break; + + case 11: +#line 81 "panner/parser.Y" + {pn->resetCmd();;} + break; + + case 12: +#line 82 "panner/parser.Y" + {pn->showCmd();;} + break; + + case 14: +#line 84 "panner/parser.Y" + {pn->msg("Panner 1.0");;} + break; + + case 15: +#line 85 "panner/parser.Y" + {pn->warpCmd(Vector((yyvsp[(2) - (3)].real), (yyvsp[(3) - (3)].real)));;} + break; + + case 16: +#line 86 "panner/parser.Y" + {pn->setCompassCmd((yyvsp[(3) - (3)].integer));;} + break; + + case 17: +#line 89 "panner/parser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].real);;} + break; + + case 18: +#line 90 "panner/parser.Y" + {(yyval.real)=(yyvsp[(1) - (1)].integer);;} + break; + + case 19: +#line 93 "panner/parser.Y" + {yydebug=1;;} + break; + + case 20: +#line 94 "panner/parser.Y" + {yydebug=0;;} + break; + + case 21: +#line 97 "panner/parser.Y" + {(yyval.integer)=((yyvsp[(1) - (1)].integer) ? 1 : 0);;} + break; + + case 22: +#line 99 "panner/parser.Y" + {(yyval.integer)=1;;} + break; + + case 23: +#line 100 "panner/parser.Y" + {(yyval.integer)=1;;} + break; + + case 24: +#line 101 "panner/parser.Y" + {(yyval.integer)=1;;} + break; + + case 25: +#line 102 "panner/parser.Y" + {(yyval.integer)=1;;} + break; + + case 26: +#line 104 "panner/parser.Y" + {(yyval.integer)=0;;} + break; + + case 27: +#line 105 "panner/parser.Y" + {(yyval.integer)=0;;} + break; + + case 28: +#line 106 "panner/parser.Y" + {(yyval.integer)=0;;} + break; + + case 29: +#line 107 "panner/parser.Y" + {(yyval.integer)=0;;} + break; + + case 30: +#line 110 "panner/parser.Y" + {pn->setBBoxCmd(1);;} + break; + + case 31: +#line 111 "panner/parser.Y" + {pn->setBBoxCmd(0);;} + break; + + case 32: +#line 114 "panner/parser.Y" + {pn->getBBoxCmd();;} + break; + + case 33: +#line 115 "panner/parser.Y" + {pn->getHeightCmd();;} + break; + + case 34: +#line 116 "panner/parser.Y" + {pn->getSizeCmd();;} + break; + + case 35: +#line 117 "panner/parser.Y" + {pn->getWidthCmd();;} + break; + + case 36: +#line 120 "panner/parser.Y" + {pn->highLiteCmd(Vector((yyvsp[(1) - (2)].real),(yyvsp[(2) - (2)].real)));;} + break; + + case 37: +#line 121 "panner/parser.Y" + {pn->highLiteCmd(0);;} + break; + + case 38: +#line 122 "panner/parser.Y" + {pn->highLiteCmd(1);;} + break; + + case 39: +#line 125 "panner/parser.Y" + {pn->panBeginCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 40: +#line 126 "panner/parser.Y" + {pn->panMotionCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 41: +#line 127 "panner/parser.Y" + {pn->panEndCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 42: +#line 128 "panner/parser.Y" + {pn->panToCmd(Vector((yyvsp[(2) - (3)].real),(yyvsp[(3) - (3)].real)));;} + break; + + case 43: +#line 131 "panner/parser.Y" + {pn->updateCmd((yyvsp[(1) - (1)].ptr));;} + break; + + case 44: +#line 134 "panner/parser.Y" + {pn->updateBBoxCmd(Vector((yyvsp[(2) - (9)].real),(yyvsp[(3) - (9)].real)),Vector((yyvsp[(4) - (9)].real),(yyvsp[(5) - (9)].real)), + Vector((yyvsp[(6) - (9)].real),(yyvsp[(7) - (9)].real)),Vector((yyvsp[(8) - (9)].real),(yyvsp[(9) - (9)].real)));;} + break; + + case 47: +#line 141 "panner/parser.Y" + {pn->updateImageCompassCmd(Vector((yyvsp[(1) - (4)].real),(yyvsp[(2) - (4)].real)),Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)));;} + break; + + case 48: +#line 143 "panner/parser.Y" + {pn->updateImageCompassCmd(Vector((yyvsp[(1) - (6)].real),(yyvsp[(2) - (6)].real)), Vector((yyvsp[(3) - (6)].real),(yyvsp[(4) - (6)].real)), + Vector((yyvsp[(5) - (6)].real),(yyvsp[(6) - (6)].real)));;} + break; + + case 49: +#line 148 "panner/parser.Y" + {pn->updateWCSCompassCmd(Vector((yyvsp[(1) - (4)].real),(yyvsp[(2) - (4)].real)),Vector((yyvsp[(3) - (4)].real),(yyvsp[(4) - (4)].real)));;} + break; + + case 50: +#line 149 "panner/parser.Y" + {pn->updateWCSCompassCmd();;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1706 "panner/parser.C" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (pn, ll, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (pn, ll, yymsg); + } + else + { + yyerror (pn, ll, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, pn, ll); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, pn, ll); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (pn, ll, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, pn, ll); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, pn, ll); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 152 "panner/parser.Y" + + + + diff --git a/tksao/panner/parser.H b/tksao/panner/parser.H new file mode 100644 index 0000000..2537fdb --- /dev/null +++ b/tksao/panner/parser.H @@ -0,0 +1,135 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INT = 258, + REAL = 259, + POINTER = 260, + BBOX_ = 261, + BEGIN_ = 262, + CLEAR_ = 263, + COMPASS_ = 264, + DEBUG_ = 265, + END_ = 266, + FALSE_ = 267, + GET_ = 268, + HEIGHT_ = 269, + HIDE_ = 270, + HIGHLITE_ = 271, + IMAGE_ = 272, + INVALID_ = 273, + MOTION_ = 274, + N_ = 275, + NO_ = 276, + OFF_ = 277, + ON_ = 278, + PAN_ = 279, + RESET_ = 280, + SHOW_ = 281, + SIZE_ = 282, + TRUE_ = 283, + TO_ = 284, + UPDATE_ = 285, + VERSION_ = 286, + WARP_ = 287, + WCS_ = 288, + WIDTH_ = 289, + Y_ = 290, + YES_ = 291 + }; +#endif +/* Tokens. */ +#define INT 258 +#define REAL 259 +#define POINTER 260 +#define BBOX_ 261 +#define BEGIN_ 262 +#define CLEAR_ 263 +#define COMPASS_ 264 +#define DEBUG_ 265 +#define END_ 266 +#define FALSE_ 267 +#define GET_ 268 +#define HEIGHT_ 269 +#define HIDE_ 270 +#define HIGHLITE_ 271 +#define IMAGE_ 272 +#define INVALID_ 273 +#define MOTION_ 274 +#define N_ 275 +#define NO_ 276 +#define OFF_ 277 +#define ON_ 278 +#define PAN_ 279 +#define RESET_ 280 +#define SHOW_ 281 +#define SIZE_ 282 +#define TRUE_ 283 +#define TO_ 284 +#define UPDATE_ 285 +#define VERSION_ 286 +#define WARP_ 287 +#define WCS_ 288 +#define WIDTH_ 289 +#define Y_ 290 +#define YES_ 291 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 24 "panner/parser.Y" +{ + float real; + int integer; + void* ptr; + char str[1024]; +} +/* Line 1529 of yacc.c. */ +#line 128 "panner/parser.H" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/tksao/panner/parser.Y b/tksao/panner/parser.Y new file mode 100644 index 0000000..024b2ec --- /dev/null +++ b/tksao/panner/parser.Y @@ -0,0 +1,154 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +%pure-parser +%parse-param {Panner* pn} +%lex-param {pnFlexLexer* ll} +%parse-param {pnFlexLexer* ll} + +%{ +#define YYDEBUG 1 + +#include +#include "panner.h" + +#undef yyFlexLexer +#define yyFlexLexer pnFlexLexer +#include + +extern int pnlex(void*, pnFlexLexer*); +extern void pnerror(Panner*, pnFlexLexer*, const char*); +%} + +%union { + float real; + int integer; + void* ptr; + char str[1024]; +} + +%type numeric +%type yesno + +%token INT +%token REAL +%token POINTER + +%token BBOX_ +%token BEGIN_ +%token CLEAR_ +%token COMPASS_ +%token DEBUG_ +%token END_ +%token FALSE_ +%token GET_ +%token HEIGHT_ +%token HIDE_ +%token HIGHLITE_ +%token IMAGE_ +%token INVALID_ +%token MOTION_ +%token N_ +%token NO_ +%token OFF_ +%token ON_ +%token PAN_ +%token RESET_ +%token SHOW_ +%token SIZE_ +%token TRUE_ +%token TO_ +%token UPDATE_ +%token VERSION_ +%token WARP_ +%token WCS_ +%token WIDTH_ +%token Y_ +%token YES_ + +%% + +command : DEBUG_ debug + | BBOX_ bbox + | CLEAR_ {pn->updateCmd(0);} + | COMPASS_ yesno {pn->setCompassCmd($2);} + | IMAGE_ COMPASS_ yesno {pn->setCompassCmd($3);} + | GET_ get + | HIDE_ {pn->hideCmd();} + | HIGHLITE_ highLite + | PAN_ pan + | RESET_ {pn->resetCmd();} + | SHOW_ {pn->showCmd();} + | UPDATE_ update + | VERSION_ {pn->msg("Panner 1.0");} + | WARP_ numeric numeric {pn->warpCmd(Vector($2, $3));} + | WCS_ COMPASS_ yesno {pn->setCompassCmd($3);} + ; + +numeric : REAL {$$=$1;} + | INT {$$=$1;} + ; + +debug : ON_ {yydebug=1;} + | OFF_ {yydebug=0;} + ; + +yesno : INT {$$=($1 ? 1 : 0);} + + | YES_ {$$=1;} + | Y_ {$$=1;} + | ON_ {$$=1;} + | TRUE_ {$$=1;} + + | NO_ {$$=0;} + | N_ {$$=0;} + | OFF_ {$$=0;} + | FALSE_ {$$=0;} + ; + +bbox : ON_ {pn->setBBoxCmd(1);} + | OFF_ {pn->setBBoxCmd(0);} + ; + +get : BBOX_ {pn->getBBoxCmd();} + | HEIGHT_ {pn->getHeightCmd();} + | SIZE_ {pn->getSizeCmd();} + | WIDTH_ {pn->getWidthCmd();} + ; + +highLite: numeric numeric {pn->highLiteCmd(Vector($1,$2));} + | OFF_ {pn->highLiteCmd(0);} + | ON_ {pn->highLiteCmd(1);} + ; + +pan : BEGIN_ numeric numeric {pn->panBeginCmd(Vector($2,$3));} + | MOTION_ numeric numeric {pn->panMotionCmd(Vector($2,$3));} + | END_ numeric numeric {pn->panEndCmd(Vector($2,$3));} + | TO_ numeric numeric {pn->panToCmd(Vector($2,$3));} + ; + +update : POINTER {pn->updateCmd($1);} + | BBOX_ numeric numeric numeric numeric + numeric numeric numeric numeric + {pn->updateBBoxCmd(Vector($2,$3),Vector($4,$5), + Vector($6,$7),Vector($8,$9));} + | IMAGE_ COMPASS_ updateImageCompass + | WCS_ COMPASS_ updateWCSCompass + ; + +updateImageCompass : numeric numeric numeric numeric + {pn->updateImageCompassCmd(Vector($1,$2),Vector($3,$4));} + | numeric numeric numeric numeric numeric numeric + {pn->updateImageCompassCmd(Vector($1,$2), Vector($3,$4), + Vector($5,$6));} + ; + +updateWCSCompass : numeric numeric numeric numeric + {pn->updateWCSCompassCmd(Vector($1,$2),Vector($3,$4));} + | INVALID_ {pn->updateWCSCompassCmd();} + ; + +%% + + diff --git a/tksao/pkgIndex.tcl.in b/tksao/pkgIndex.tcl.in new file mode 100755 index 0000000..d7566b4 --- /dev/null +++ b/tksao/pkgIndex.tcl.in @@ -0,0 +1,5 @@ +# +# Tcl package index file +# +package ifneeded @PACKAGE_NAME@ @PACKAGE_VERSION@ \ + [list load [file join $dir @PKG_LIB_FILE@] @PACKAGE_NAME@] diff --git a/tksao/saotk.C b/tksao/saotk.C new file mode 100644 index 0000000..9e238ad --- /dev/null +++ b/tksao/saotk.C @@ -0,0 +1,100 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +extern int FrameTrueColor8_Init(Tcl_Interp*); +extern int FrameTrueColor16_Init(Tcl_Interp*); +extern int FrameTrueColor24_Init(Tcl_Interp*); + +extern int FrameRGBTrueColor8_Init(Tcl_Interp*); +extern int FrameRGBTrueColor16_Init(Tcl_Interp*); +extern int FrameRGBTrueColor24_Init(Tcl_Interp*); + +extern int Frame3dTrueColor8_Init(Tcl_Interp*); +extern int Frame3dTrueColor16_Init(Tcl_Interp*); +extern int Frame3dTrueColor24_Init(Tcl_Interp*); + +extern int ColorbarTrueColor8_Init(Tcl_Interp*); +extern int ColorbarTrueColor16_Init(Tcl_Interp*); +extern int ColorbarTrueColor24_Init(Tcl_Interp*); + +extern int ColorbarRGBTrueColor8_Init(Tcl_Interp*); +extern int ColorbarRGBTrueColor16_Init(Tcl_Interp*); +extern int ColorbarRGBTrueColor24_Init(Tcl_Interp*); + +extern int PannerTrueColor_Init(Tcl_Interp*); + +extern int MagnifierTrueColor_Init(Tcl_Interp*); + +extern "C" { + int Tksao_Init(Tcl_Interp* interp); + int SaotkCmd(ClientData data, Tcl_Interp *interp, int argc, + const char* argv[]); +} + +int Tksao_Init(Tcl_Interp* interp) { + if (Tcl_InitStubs(interp, TCL_PATCH_LEVEL, 0) == NULL) + return TCL_ERROR; + if (Tk_InitStubs(interp, TK_PATCH_LEVEL, 0) == NULL) + return TCL_ERROR; + + if (FrameTrueColor8_Init(interp) == TCL_ERROR) + return TCL_ERROR; + if (FrameTrueColor16_Init(interp) == TCL_ERROR) + return TCL_ERROR; + if (FrameTrueColor24_Init(interp) == TCL_ERROR) + return TCL_ERROR; + + if (FrameRGBTrueColor8_Init(interp) == TCL_ERROR) + return TCL_ERROR; + if (FrameRGBTrueColor16_Init(interp) == TCL_ERROR) + return TCL_ERROR; + if (FrameRGBTrueColor24_Init(interp) == TCL_ERROR) + return TCL_ERROR; + + if (Frame3dTrueColor8_Init(interp) == TCL_ERROR) + return TCL_ERROR; + if (Frame3dTrueColor16_Init(interp) == TCL_ERROR) + return TCL_ERROR; + if (Frame3dTrueColor24_Init(interp) == TCL_ERROR) + return TCL_ERROR; + + if (ColorbarTrueColor8_Init(interp) == TCL_ERROR) + return TCL_ERROR; + if (ColorbarTrueColor16_Init(interp) == TCL_ERROR) + return TCL_ERROR; + if (ColorbarTrueColor24_Init(interp) == TCL_ERROR) + return TCL_ERROR; + + if (PannerTrueColor_Init(interp) == TCL_ERROR) + return TCL_ERROR; + + if (MagnifierTrueColor_Init(interp) == TCL_ERROR) + return TCL_ERROR; + + if (ColorbarRGBTrueColor8_Init(interp) == TCL_ERROR) + return TCL_ERROR; + if (ColorbarRGBTrueColor16_Init(interp) == TCL_ERROR) + return TCL_ERROR; + if (ColorbarRGBTrueColor24_Init(interp) == TCL_ERROR) + return TCL_ERROR; + + // dummy command + // needed for auto_load, since all of our real work are canvas widgets, + // tcl commands + + Tcl_CreateCommand(interp, "saotk", (Tcl_CmdProc* )SaotkCmd, + (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); + + if (Tcl_PkgProvide(interp, PACKAGE_NAME, PACKAGE_VERSION) != TCL_OK) + return TCL_ERROR; + + return TCL_OK; +} + +int SaotkCmd(ClientData data, Tcl_Interp *interp, int argc, const char* argv[]) +{ + return TCL_OK; +} diff --git a/tksao/tclconfig/ChangeLog b/tksao/tclconfig/ChangeLog new file mode 100644 index 0000000..ffda2bb --- /dev/null +++ b/tksao/tclconfig/ChangeLog @@ -0,0 +1,980 @@ +2013-07-04 Jan Nijtmans + + * unix/tcl.m4: Bug [3324676]: AC_PROG_INSTALL incompat, + Bug [3606445]: Unneeded -DHAVE_NO_SEH=1 when not building on Windows + +2013-07-02 Jan Nijtmans + + * unix/tcl.m4: Bug [32afa6e256]: dirent64 check is incorrect in tcl.m4 + (thanks to Brian Griffin) + +2013-06-20 Jan Nijtmans + + * unix/tcl.m4: Use X11/Xlib.h for checking where X11 can be found + in stead of X11/XIntrinsic.h. Suggested by Pietro Cerutti. + +2013-06-04 Jan Nijtmans + + * unix/tcl.m4: Eliminate NO_VIZ macro as current + zlib uses HAVE_HIDDEN in stead. One more last-moment + fix for FreeBSD by Pietro Cerutti + +2013-05-19 Jan Nijtmans + + * unix/tcl.m4: Fix for FreeBSD, and remove support for old + FreeBSD versions. Patch by Pietro Cerutti + +2013-03-12 Jan Nijtmans + + * unix/tcl.m4: Patch by Andrew Shadura, providing better support for + * three architectures they have in Debian. + +2012-08-07 Stuart Cassoff + + * tcl.m4: Added "-DNDEBUG" to CFLAGS_DEFAULT + when building with --disable-symbols. + +2012-08-07 Stuart Cassoff + + * tcl.m4: [Bug 3555058]: Checkin [30736d63f0] broke + CFLAGS_DEFAULT, LDFLAGS_DEFAULT + +2012-08-07 Stuart Cassoff + + * tcl.m4: [Bug 3511806]: Checkin [30736d63f0] broke CFLAGS + +2012-08-07 Jan Nijtmans + + * tcl.m4: [Bug 3511806]: Checkin [30736d63f0] broke CFLAGS + +2012-07-25 Jan Nijtmans + + * tcl.m4: My previous commit (2012-04-03) broke the ActiveTcl + build for AMD64, because of the quotes in "C://AMD64/cl.exe". + It turns out that the AC_TRY_COMPILE macro cannot handle that. + +2012-07-22 Stuart Cassoff + + * tcl.m4: Tidy: consistency, spelling, phrasing, whitespace. + No functional change. + +2012-04-03 Jan Nijtmans + + * tcl.m4: [Bug 3511806] Compiler checks too early + This change allows to build the cygwin and mingw32 ports of + Tcl/Tk extensions to build out-of-the-box using a native or + cross-compiler, e.g. on Cygwin, Linux or Darwin. + +2011-04-02 Jan Nijtmans + + * install-sh: Fix issue with library stripping in install-sh + (backported from kevin_walzer's patch from Tcl 8.6 trunk) + +2011-04-05 Andreas Kupries + + * tcl.m4: Applied patch by Jeff Lawson. Nicer error message when + tclConfig.sh was not found. + +2010-12-15 Stuart Cassoff + + * install-sh: Upgrade to newer install-sh and use it. + * tcl.m4: + +2010-12-14 Stuart Cassoff + + * tcl.m4: Better building on OpenBSD. + +2010-12-14 Jan Nijtmans + + * tcl.m4: when using gcc, don't try to determine Win64 SDK + +2010-12-12 Jan Nijtmans + + * tcl.m4: Determine correctly a cross-compiler-windres + +2010-11-23 Jan Nijtmans + + * tcl.m4: add some cross-compile support, borrowed from Tcl 8.6 + +2010-09-16 Jeff Hobbs + + * tcl.m4: correct HP-UX LDFLAGS (only used when building big shell) + +2010-09-14 Jeff Hobbs + + * tcl.m4: add extra if check for .manifest file generation + Add notice about package name and version being built. + +2010-09-09 Jan Nijtmans + + * tcl.m4: [FREQ #3058486] TEA_LOAD_CONFIG doesn't set all BUILD_ vars + Slightly related: defining BUILD_$1 on all platforms - not only win - + allows the -fvisibility feature to be used in extensions as well, at + least if you compile against tcl >= 8.5. + +2010-08-26 Jeff Hobbs + + * tcl.m4: ensure safe quoting for autoheader usage + +2010-08-19 Jeff Hobbs + + * tcl.m4: add TEA_ADD_CLEANFILES macro to make adding cleanfiles + easier, and add *.exp to CLEANFILES Windows default. + (TEA_MAKE_LIB): Enhanced to check for MSVC that requires manifests + and auto-embed it into proj DLL via MAKE_SHARED_LIB. Also define + VC_MANIFEST_EMBED_DLL and VC_MANIFEST_EMBED_EXE that do the same + magic in case it is needed for extended TEA projects. + +2010-08-16 Jeff Hobbs + + *** Bump to TEA_VERSION 3.9 *** + If upgrading from TEA_VERSION 3.8, copy over tcl.m4, change + TEA_INIT to use 3.9 and reconfigure (ac-2.59+). + BUILD_${PACKAGE_NAME} will be auto-defined on Windows for + correct setting of TCL_STORAGE_CLASS. + TEA_LOAD_CONFIG users should remove the SHLIB_LD_LIBS setting done + in configure.in (LIBS will be automagically populated by + TEA_LOAD_CONFIG). + TEA_EXPORT_CONFIG has been added for ${pkg}Config.sh creators + SHLIB_LD_FLAGS was deprecated a while ago, remove it if it is + still in your Makefile.in. + + * tcl.m4: add /usr/lib64 to set of auto-search dirs. [Bug 1230554] + Auto-define BUILD_$PACKAGE_NAME so users don't need to. This + needs to correspond with $pkg.h define magic for TCL_STORAGE_CLASS. + Auto-define CLEANFILES. Users can expand it. + (SHLIB_LD_LIBS): define to '${LIBS}' default and change it only if + necessary. Platforms not using this may simply not work or have + very funky linkers. + (TEA_LOAD_CONFIG): When loading config for another extension, + auto-add stub libraries found with TEA_ADD_LIBS. Eases + configure.in for modules like itk and img::*. + (TEA_EXPORT_CONFIG): Add standardized function for exporting a + ${pkg}Config.sh. See use by img::* and itcl. + +2010-08-12 Jeff Hobbs + + *** Bump to TEA_VERSION 3.8 *** + If upgrading from TEA_VERSION 3.7, copy over tcl.m4, change + TEA_INIT to use 3.8 and reconfigure (ac-2.59+). + No other changes should be necessary. + + * tcl.m4: remove more vestigial bits from removed platforms. + Add back SCO_SV-3.2*. + Remove use of DL_LIBS and DL_OBJS and related baggage - these are + only needed by the core to support 'load'. + Allow for macosx in TEA_ADD_SOURCES. + Correct check for found_xincludes=no in TEA_PATH_UNIX_X. + +2010-08-11 Jeff Hobbs + + * tcl.m4: remove the following old platform configurations: + UNIX_SV*|UnixWare-5*, SunOS-4.*, SINIX*5.4*, SCO_SV-3.2*, + OSF1-1.*, NEXTSTEP-*, NetBSD-1.*|FreeBSD-[[1-2]].*, MP-RAS-*, + IRIX-5.*, HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*, dgux*, + BSD/OS-2.1*|BSD/OS-3* + (AIX): drop AIX-pre4 support and use of ldAix, use -bexpall/-brtl + +2010-07-05 Jan Nijtmans + + * tcl.m4: [Patch #1055668] removal of exported internals from + tclInt.h (EXTERN macro) + +2010-04-14 Jan Nijtmans + + * tcl.m4 - Backport a lot of quoting fixes from tcl8.6/unix/tcl.m4 + - Fix determination of CYGPATH for CYGWIN + With those fixes, itcl and tdbc compile fine with CYGWIN + +2010-04-06 Jan Nijtmans + + * install-sh [Bug 2982540] configure and install* script files + should always have LF + +2010-02-19 Stuart Cassoff + + * tcl.m4: Correct compiler/linker flags for threaded builds on + OpenBSD. + +2010-01-19 Jan Nijtmans + + * tcl.m4: Detect CYGWIN variant: win32 or unix + +2010-01-03 Donal K. Fellows + + * unix/tcl.m4 (TEA_CONFIG_CFLAGS): [Tcl Bug 1636685]: Use the + configuration for modern FreeBSD suggested by the FreeBSD porter. + +2009-10-22 Jan Nijtmans + + * tcl.m4: [Tcl Patch #2883533] tcl.m4 support for Haiku OS + +2009-04-27 Jeff Hobbs + + * tcl.m4 (TEA_CONFIG_CFLAGS): harden the check to add _r to CC on + AIX with threads. + +2009-04-10 Daniel Steffen + + * tcl.m4 (Darwin): check for 64-bit TkAqua. + +2009-03-26 Jan Nijtmans + + * tclconfig/tcl.m4: Adapt LDFLAGS and LD_SEARCH_FLAGS + together with SHLIB_LD definition to unbreak building on HPUX. + +2009-03-20 Andreas Kupries + + * tclconfig/tcl.m4: Changed SHLIB_LD definition to unbreak + building on HPUX. + +2009-03-16 Joe English + + * tcl.m4(TEA_PUBLIC_TK_HEADERS): Look at ${TK_INCLUDE_SPEC} + (found in tkConfig.sh) when trying to guess where tk.h might be + [Patch 1960628]. + +2009-03-11 Joe English + + * tcl.m4: Allow ${SHLIB_SUFFIX} to be overridden at + configure-time [Patch 1960628]. Also fix some comment typos, + and an uninitialized variable bug-waiting-to-happen. + +2008-12-21 Jan Nijtmans + + * tcl.m4: [Bug 2073255] Tcl_GetString(NULL) doesn't crash on HP-UX + (this bug report was for Tcl, but holds for TEA as well.) + +2008-12-20 Daniel Steffen + + * tcl.m4: sync with tdbc tcl.m4 changes + (SunOS-5.11): Sun cc SHLIB_LD: use LDFLAGS_DEFAULT instead of LDFLAGS + +2008-12-02 Jeff Hobbs + + *** Bump to TEA_VERSION 3.7 *** + + * tcl.m4: in private header check, check for Port.h instead + of Int.h to ensure all private headers are available. + +2008-11-04 Daniel Steffen + + * tcl.m4 (Darwin): sync TEA_PRIVATE_TK_HEADERS handling of + Tk.framework PrivateHeaders with TEA_PRIVATE_TCL_HEADERS. + +2008-11-04 Jeff Hobbs + + * tcl.m4 (TEA_PATH_TCLCONFIG, TEA_PATH_TKCONFIG): exit with error + when tclConfig.sh cannot be found. [Bug #1997760] + (TEA_PRIVATE_TCL_HEADERS, TEA_PRIVATE_TK_HEADERS): allow for + finding the headers installed in the public areas, e.g. a result of + make install-private-headers. [Bug #1631922] + +2008-08-12 Daniel Steffen + + * tcl.m4 (Darwin): link shlib with current and compatiblity version + flags; look for libX11.dylib when searching for X11 libraries. + +2008-06-12 Daniel Steffen + + * tcl.m4 (SunOS-5.11): fix 64bit amd64 support with gcc & Sun cc. + +2008-03-27 Daniel Steffen + + * tcl.m4 (SunOS-5.1x): fix 64bit support for Sun cc. [Bug 1921166] + +2008-02-01 Donal K. Fellows + + * tcl.m4 (TEA_CONFIG_CFLAGS): Updated to work at least in part with + more modern VC versions. Currently just made the linker flags more + flexible; more work may be needed. + +2007-10-26 Daniel Steffen + + * tcl.m4 (Darwin): add support for 64-bit X11. + +2007-10-23 Jeff Hobbs + + *** Tagged tea-3-branch to start TEA 4 development on HEAD *** + +2007-09-17 Joe English + + * tcl.m4: use '${CC} -shared' instead of 'ld -Bshareable' + to build shared libraries on current NetBSDs [Bug 1749251]. + +2007-09-15 Daniel Steffen + + * tcl.m4: replace all direct references to compiler by ${CC} to + enable CC overriding at configure & make time. + (SunOS-5.1x): replace direct use of '/usr/ccs/bin/ld' in SHLIB_LD by + 'cc' compiler driver. + +2007-08-08 Jeff Hobbs + + * tcl.m4: check Ttk dir for Tk private headers (8.5). + Add some comments to other bits. + +2007-06-25 Jeff Hobbs + + * tcl.m4 (TEA_PROG_TCLSH, TEA_PROG_WISH): move where / is added. + +2007-06-13 Jeff Hobbs + + * tcl.m4: fix --with-tkinclude alignment. [Bug 1506111] + +2007-06-06 Daniel Steffen + + * tcl.m4 (Darwin): fix 64bit arch removal in fat 32&64bit builds. + +2007-05-18 Donal K. Fellows + + * tcl.m4: Added quoting so that paths with spaces cause fewer + problems. + +2007-03-07 Daniel Steffen + + * tcl.m4 (Darwin): s/CFLAGS/CPPFLAGS/ in -mmacosx-version-min check. + +2007-02-15 Jeff Hobbs + + * tcl.m4: correct private header check to search in generic subdir + +2007-02-09 Jeff Hobbs + + *** Bump to TEA_VERSION 3.6 *** + + * tcl.m4: correct -d to -f + (TEA_CONFIG_CFLAGS): SHLIB_SUFFIX is .so on HP ia64 [Bug 1615058] + +2007-02-08 Jeff Hobbs + + * tcl.m4 (TEA_PRIVATE_TCL_HEADERS, TEA_PRIVATE_TK_HEADERS): check + that the dirs actually have private headers. [Bug 1631922] + +2007-02-04 Daniel Steffen + + * tcl.m4: add caching to -pipe check. + +2007-01-25 Daniel Steffen + + * tcl.m4: integrate CPPFLAGS into CFLAGS as late as possible and + move (rather than duplicate) -isysroot flags from CFLAGS to CPPFLAGS to + avoid errors about multiple -isysroot flags from some older gcc builds. + +2006-01-19 Daniel Steffen + + * tcl.m4: ensure CPPFLAGS env var is used when set. [Bug 1586861] + (Darwin): add -isysroot and -mmacosx-version-min flags to CPPFLAGS when + present in CFLAGS to avoid discrepancies between what headers configure + sees during preprocessing tests and compiling tests. + +2006-12-19 Daniel Steffen + + * tcl.m4 (Darwin): --enable-64bit: verify linking with 64bit -arch flag + succeeds before enabling 64bit build. + +2006-12-16 Daniel Steffen + + * tcl.m4 (Linux): fix previous change to use makefile variable + LDFLAGS_DEFAULT instead of LDFLAGS in SHLIB_LD, to ensure linker + flags in sampleextension Makefile are picked up. + +2006-11-26 Daniel Steffen + + * tcl.m4 (Linux): --enable-64bit support. [Patch 1597389], [Bug 1230558] + +2006-08-18 Daniel Steffen + + * tcl.m4 (Darwin): add support for --enable-64bit on x86_64, for + universal builds including x86_64 and for use of -mmacosx-version-min + instead of MACOSX_DEPLOYMENT_TARGET. For Tk extensions, remove 64-bit + arch flags from CFLAGS like in the Tk configure, as neither TkAqua nor + TkX11 can be built for 64-bit at present. + +2006-03-28 Jeff Hobbs + + * tcl.m4: []-quote AC_DEFUN functions. + (TEA_PATH_TKCONFIG): Fixed Windows-specific check for tkConfig.sh. + (TEA_MAKE_LIB): Prepend 'lib' for Windows-gcc configs. + +2006-03-07 Joe English + + * tcl.m4: Set SHLIB_LD_FLAGS='${LIBS}' on NetBSD, + as per the other *BSD variants [Bug 1334613]. + +2006-01-25 Jeff Hobbs + + *** Bump to TEA version 3.5 *** + + * tcl.m4: keep LD_SEARCH_FLAGS and CC_SEARCH_FLAGS synchronous + with core tcl.m4 meaning. + +2006-01-24 Daniel Steffen + + * tcl.m4 (Darwin): use makefile variable LDFLAGS_DEFAULT instead of + LDFLAGS in SHLIB_LD, to ensure linker flags in sampleextension Makefile + are picked up. [Bug 1403343] + +2006-01-23 Jeff Hobbs + + * tcl.m4: add C:/Tcl/lib and C:/Progra~1/Tcl/lib dirs to check for + *Config.sh on Windows. [Bug 1407544] + +2006-01-23 Daniel Steffen + + * tcl.m4 (Darwin): for Tk extensions, remove -arch ppc64 from CFLAGS + like in the Tk configure, as neither TkAqua nor TkX11 can be built for + 64bit at present (no 64bit GUI libraries). + +2006-01-22 Jeff Hobbs + + * tcl.m4: restore system=windows on Windows. + Remove error if 'ar' isn't found (it may not be on Windows). + Do not add -lxnet or define _XOPEN_SOURCE on HP-UX by default. + Ensure the C|LDFLAGS_DEFAULT gets the fully sub'd value at + configure time. + +2006-01-10 Daniel Steffen + + * tcl.m4: add caching, use AC_CACHE_CHECK instead of AC_CACHE_VAL + where possible, consistent message quoting, sync relevant + tcl/unix/tcl.m4 HEAD changes and gratuitous formatting differences + (notably sunc removal of support for for ancient BSD's, IRIX 4, + RISCos and Ultrix by kennykb), Darwin improvements to + TEA_LOAD_*CONFIG to make linking work against Tcl/Tk frameworks + installed in arbitrary location, change TEA_PROG_* search order + (look in *_BIN_DIR parents before *_PREFIX). + +2006-01-05 Jeff Hobbs + + * tcl.m4: add dkf's system config refactor + +2006-01-04 Jeff Hobbs + + * tcl.m4: remove extraneous ' that causes bash 3.1 to choke + +2005-12-19 Joe English + + * tcl.m4 (TEA_PATH_TCLCONFIG &c): Look for tclConfig.sh &c + in ${libdir}, where they are installed by default [Patch #1377407]. + +2005-12-05 Don Porter + + * tcl.m4 (TEA_PUBLIC_*_HEADERS): Better support for finding + header files for uninstalled Tcl and Tk. + +2005-12-02 Jeff Hobbs + + * tcl.m4: correctly bump TEA_VERSION var to 3.4 + +2005-12-01 Daniel Steffen + + * unix/tcl.m4 (Darwin): fixed error when MACOSX_DEPLOYMENT_TARGET unset + +2005-11-29 Jeff Hobbs + + * tcl.m4: *** Bump to TEA version 3.4 *** + Add Windows x64 build support. + Remove TEA_PATH_NOSPACE and handle the problem with ""s where + necessary - the macro relied on TCLSH_PROG which didn't work for + cross-compiles. + +2005-11-27 Daniel Steffen + + * tcl.m4 (Darwin): add 64bit support, add CFLAGS to SHLIB_LD to + support passing -isysroot in env(CFLAGS) to configure (flag can't + be present twice, so can't be in both CFLAGS and LDFLAGS during + configure), don't use -prebind when deploying on 10.4. + (TEA_ENABLE_LANGINFO, TEA_TIME_HANDLER): add/fix caching. + +2005-10-30 Daniel Steffen + + * tcl.m4: fixed two tests for TEA_WINDOWINGSYSTEM = "aqua" that + should have been for `uname -s` = "Darwin" instead; added some + missing quoting. + (TEA_PROG_TCLSH, TEA_PROG_WISH): fix incorrect assumption that + install location of tclConfig.sh/tkConfig.sh allows to determine + the tclsh/wish install dir via ../bin. Indeed tcl/tk can be + configured with arbitrary --libdir and --bindir (independent of + prefix) and such a configuration is in fact standard with Darwin + framework builds. At least now also check ${TCL_PREFIX}/bin + resp. ${TK_PREFIX}/bin for presence of tclsh resp. wish (if tcl/tk + have been configured with arbitrary --bindir, this will still not + find them, for a general solution *Config.sh would need to contain + the values of bindir/libdir/includedir passed to configure). + +2005-10-07 Jeff Hobbs + + * tcl.m4: Fix Solaris 5.10 check and Solaris AMD64 64-bit builds. + +2005-10-04 Jeff Hobbs + + * tcl.m4 (TEA_PRIVATE_TCL_HEADERS): add / to finish sed macro + (TEA_ENABLE_THREADS): don't check for pthread_attr_setstacksize func + +2005-09-13 Jeff Hobbs + + * tcl.m4: *** Update to TEA version 3.3 *** + define TEA_WINDOWINGSYSTEM in TEA_LOAD_TKCONFIG. + Make --enable-threads the default (users can --disable-threads). + Improve AIX ${CC}_r fix to better check existing ${CC} value. + Do the appropriate evals to not require the *TOP_DIR_NATIVE vars + be set for extensions that use private headers. + Make aqua check for Xlib compat headers the same as win32. + +2005-07-26 Mo DeJong + + * tcl.m4 (TEA_PROG_TCLSH, TEA_BUILD_TCLSH, + TEA_PROG_WISH, TEA_BUILD_WISH): Remove + TEA_BUILD_TCLSH and TEA_BUILD_WISH because + of complaints that it broke the build when + only an installed version of Tcl was available + at extension build time. The TEA_PROG_TCLSH and + TEA_PROG_WISH macros will no longer search the + path at all. The build tclsh or installed + tclsh shell will now be found by TEA_PROG_TCLSH. + +2005-07-24 Mo DeJong + + * tcl.m4 (TEA_PROG_TCLSH, TEA_BUILD_TCLSH, + TEA_PROG_WISH, TEA_BUILD_WISH): + Split confused search for tclsh on PATH and + build and install locations into two macros. + TEA_PROG_TCLSH and TEA_PROG_WISH search the + system PATH for an installed tclsh or wish. + The TEA_BUILD_TCLSH and TEA_BUILD_WISH + macros determine the name of tclsh or + wish in the Tcl or Tk build directory even + if tclsh or wish has not yet been built. + [Tcl bug 1160114] + [Tcl patch 1244153] + +2005-06-23 Daniel Steffen + + * tcl.m4 (TEA_PRIVATE_TK_HEADERS): add ${TK_SRC_DIR}/macosx to + TK_INCLUDES when building against TkAqua. + + * tcl.m4 (TEA_PATH_X): fixed missing comma in AC_DEFINE + + * tcl.m4: changes to better support framework builds of Tcl and Tk out + of the box: search framework install locations for *Config.sh, and if in + presence of a framework build, use the framework's Headers and + PrivateHeaders directories for public and private includes. [FR 947735] + +2005-06-18 Daniel Steffen + + * tcl.m4 (Darwin): add -headerpad_max_install_names to LDFLAGS to + ensure we can always relocate binaries with install_name_tool. + +2005-06-04 Daniel Steffen + + * tcl.m4 (TEA_PATH_X): for TEA_WINDOWINGSYSTEM == aqua, check if xlib + compat headers are available in tkheaders location, otherwise add xlib + sourcedir to TK_XINCLUDES. + +2005-04-25 Daniel Steffen + + * tcl.m4: added AC_DEFINE* descriptions (from core tcl.m4) to allow + use with autoheader. + (Darwin): added configure checks for recently added linker flags + -single_module and -search_paths_first to allow building with older + tools (and on Mac OS X 10.1), use -single_module in SHLIB_LD. + (TEA_MISSING_POSIX_HEADERS): added caching of dirent.h check. + (TEA_BUGGY_STRTOD): added caching (sync with core tcl.m4). + +2005-03-24 Jeff Hobbs + + * tcl.m4 (TEA_TCL_64BIT_FLAGS): use Tcl header defaults for wide + int type only on Windows when __int64 is detected as valid. + +2005-03-24 Don Porter + + * README.txt: Update reference to "SC_* macros" to "TEA_* macros". + * tcl.m4: Incorporated recent improvements in SC_PATH_TCLCONFIG + and SC_PATH_TKCONFIG into TEA_PATH_TCLCONFIG and TEA_PATH_TKCONFIG. + Corrected search path in TEA_PATH_CONFIG and added + AC_SUBST($1_BIN_DIR) to TEA_LOAD_CONFIG so that packages that load + the configuration of another package can know where they loaded + it from. + +2005-03-18 Jeff Hobbs + + * tcl.m4 (TEA_CONFIG_CFLAGS): correct 2005-03-17 change to have + variant LD_SEARCH_FLAGS for gcc and cc builds. + + * tcl.m4 (TEA_PROG_TCLSH, TEA_PROG_WISH): correct x-compile check. + +2005-03-17 Jeff Hobbs + + * tcl.m4: Correct gcc build and HP-UX-11. + +2005-02-08 Jeff Hobbs + + * tcl.m4 (TEA_ADD_LIBS): don't touch lib args starting with -. + (TEA_CONFIG_CFLAGS): only define _DLL for CE in shared build. + (TEA_MAKE_LIB): set RANLIB* to : on Windows (it's not needed). + +2005-02-01 Jeff Hobbs + + * tcl.m4: redo of 2005-01-27 changes to correctly handle paths + with spaces. Win/CE and Win/64 builds now require a prebuilt + tclsh to handle conversion to short pathnames. This is done in + the new TEA_PATH_NOSPACE macro. For Win/CE|64, make CC just the + compiler and move the necessary includes to CFLAGS. + (TEA_CONFIG_CFLAGS): Add Solaris 64-bit gcc build support. + (TEA_PROG_TCLSH, TEA_PROG_WISH): Allow TCLSH_PROG and WISH_PROG to + be set in the env and prevent resetting. + (TEA_ADD_LIBS): On Windows using GCC (mingw), convert foo.lib + args to -lfoo, for use with mingw. + *** POTENTIAL INCOMPATABILITY *** + (TEA_CONFIG_CFLAGS): Fix AIX gcc builds to work out-of-box. + Bumped TEA to 3.2. + +2005-01-27 Jeff Hobbs + + * tcl.m4: remove cygpath calls to support msys. + Update base CE build assumption to "420,ARMV4,ARM,Pocket PC 2003". + Make STLIB_LD use $LINKBIN -lib. + +2005-01-25 Daniel Steffen + + * tcl.m4 (Darwin): fixed bug with static build linking to dynamic + library in /usr/lib etc instead of linking to static library earlier + in search path. [Tcl Bug 956908] + Removed obsolete references to Rhapsody. + +2004-12-29 Jeff Hobbs + + * tcl.m4: Updates for VC7 compatibility, fixing CFLAGS and LDFLAGS + options, using better default -O levels. [Bug 1092952, 1091967] + +2004-12-29 Joe English + + * tcl.m4: Do not use ${DBGX} suffix when building + shared libraries [patch #1081595, TIP #34] + +2004-09-07 Jeff Hobbs + + * tcl.m4 (TEA_CONFIG_CFLAGS): support eVC4 Win/CE builds + +2004-08-10 Jeff Hobbs + + * tcl.m4 (TEA_INIT, TEA_PREFIX): update handling of exec_prefix to + work around subdir configures since autoconf only propagates the + prefix (not exec_prefix). + +2004-07-23 Daniel Steffen + + * tcl.m4 (TEA_CONFIG_CFLAGS): Darwin section: brought inline with + Tcl 8.5 HEAD config, removed core specific & obsolete settings. + +2004-07-22 Jeff Hobbs + + * tcl.m4 (TEA_PATH_X): check in TK_DEFS for MAC_OSX_TK to see if + we are compiling on Aqua. Add TEA_WINDOWINGSYSTEM var that + reflects 'tk windowingsystem' value. + +2004-07-16 Jeff Hobbs + + * tcl.m4 (TEA_ENABLE_THREADS): force a threaded build when + building against a threaded core. + (CFLAGS_WARNING): Remove -Wconversion for gcc builds + (TEA_CONFIG_CFLAGS): Reorder configure.in for better 64-bit build + configuration, replacing EXTRA_CFLAGS with CFLAGS. [Bug #874058] + Update to latest Tcl 8.5 head config settings. + Call this TEA version 3.1. + +2004-04-29 Jeff Hobbs + + * tcl.m4 (TEA_TCL_64BIT_FLAGS): replace AC_TRY_RUN test with + AC_TRY_COMPILE for the long vs. long long check. (kenny) + +2004-04-26 Jeff Hobbs + + * tcl.m4 (TEA_TCL_64BIT_FLAGS): update against core tcl.m4 to + define TCL_WIDE_INT_IS_LONG if 'using long'. + +2004-03-19 Jeff Hobbs + + * tcl.m4: correct Windows builds getting LDFLAGS info in MAKE_LIB + +2004-02-11 Jeff Hobbs + + * tcl.m4: correct TCL_INCLUDES for private headers on Windows - it + doesn't need the eval. + +2004-02-10 Jeff Hobbs + + * tcl.m4: don't require TK_INCLUDES and TCL_INCLUDES to have the + DIR_NATIVE vars defined when using private headers on unix. + Allow $... to TEA_ADD_SOURCES for constructs like + TEA_ADD_SOURCES([\$(WIN_OBJECTS)]), that allow the developer to + place more in the Makefile.in. + tkUnixPort.h checks for HAVE_LIMITS_H, so do both HAVE and + CHECK on limits.h + +2003-12-10 Jeff Hobbs + + * Makefile.in: added TEA_ADD_LIBS, TEA_ADD_INCLUDES and + * configure: TEA_ADD_CFLAGS to configurable parameters with + * configure.in: PKG_* equivs in the Makefile. This allows the + * tclconfig/tcl.m4: user to worry less about actual magic VAR names. + Corrected Makefile.in to note that TEA_ADD_TCL_SOURCES requires + exact file names. + +2003-12-09 Jeff Hobbs + + * tcl.m4: updated OpenBSD support based on [Patch #775246] (cassoff) + +2003-12-05 Jeff Hobbs + + * configure: + * configure.in: + * Makefile.in (VPATH): readd $(srcdir) to front of VPATH as the + first part of VPATH can get chopped off. + Change .c.$(OBJEXT) rule to .c.@OBJEXT@ to support more makes. + * tclconfig/tcl.m4: add TEA_ADD_STUB_SOURCES to support libstub + generation and TEA_ADD_TCL_SOURCES to replace RUNTIME_SOURCES as + the way the user specifies library files. + +2003-12-03 Jeff Hobbs + + * configure: Update of TEA spec to (hopefully) simplify + * configure.in: some aspects of TEA by making use of more + * Makefile.in: AC 2.5x features. Use PACKAGE_NAME (instead + * generic/tclsample.c: of PACKAGE) and PACKAGE_VERSION (instead of + * tclconfig/tcl.m4: VERSION) arguments to AC_INIT as the TEA + package name and version. + Provide a version argument to TEA_INIT - starting with 3.0. + Drop all use of interior shell substs that older makefiles didn't + like. Use PKG_* naming convention instead. + Move specification of source files and public headers into + configure.in with TEA_ADD_SOURCES and TEA_ADD_HEADERS. These will + be munged during ./configure into the right obj file names (no + $(SOURCES:.c=.obj) needed). + There is almost nothing that should be touched in Makefile.in now + for the developer. May want to add a TEA_ADD_TCL_SOURCES for the + RUNTIME_SOURCES that remains. + Use SHLID_LD_FLAGS (instead of SHLID_LDFLAGS) as Tcl does. + Only specify the user requested LDFLAGS/CFLAGS in the Makefile, + don't mention the _OPTIMIZE/_DEBUG variants. + +2003-10-15 Jeff Hobbs + + * tcl.m4: create a TEA_SETUP_COMPILER_CC the precedes the + TEA_SETUP_COMPILER macro. They are split so the check for CC + occurs before any use of CC. Also add AC_PROG_CPP to the compiler + checks. + +2003-10-06 Jeff Hobbs + + * tcl.m4: Updated for autoconf 2.5x prereq. + Where TCL_WIDE_INT_TYPE would be __int64, defer to the code checks + in tcl.h, which also handles TCL_LL_MODIFIER* properly. + +2003-04-22 Jeff Hobbs + + * tcl.m4: correct default setting of ARCH for WinCE builds. + Correct \ escaping for CE sed macros. + +2003-04-10 Jeff Hobbs + + * tcl.m4: replace $(syscal) construct with older `syscall` for + systems where sh != bash. + +2003-04-09 Jeff Hobbs + + * tcl.m4 (TEA_WITH_CELIB): add --enable-wince and --with-celib + options for Windows/CE compilation support. Requires the + Microsoft eMbedded SDK and Keuchel's celib emulation layer. + +2003-02-18 Jeff Hobbs + + * tcl.m4 (TEA_ENABLE_THREADS): Make sure -lpthread gets passed on + the link line when checking for the pthread_attr_setstacksize + symbol. (dejong) + + * tcl.m4 (TEA_SETUP_COMPILER): added default calls to + TEA_TCL_EARLY_FLAGS, TEA_TCL_64BIT_FLAGS, + TEA_MISSING_POSIX_HEADERS and TEA_BUGGY_STRTOD. + +2003-02-14 Jeff Hobbs + + * tcl.m4: correct HP-UX ia64 --enable-64bit build flags + +2003-01-29 Jeff Hobbs + + * tcl.m4: check $prefix/lib as well as $exec_prefix/lib when + looking for tcl|tkConfig.sh, as this check is done before we would + set exec_prefix when the user does not define it. + +2003-01-21 Mo DeJong + + * tcl.m4 (TEA_CONFIG_CFLAGS): Fix build support + for mingw, the previous implementation would + use VC++ when compiling with mingw gcc. Don't + pass -fPIC since gcc always compiles pic code + under win32. Change some hard coded cases + of gcc to ${CC}. + +2002-10-15 Jeff Hobbs + + * tcl.m4: move the CFLAGS definition from TEA_ENABLE_SHARED to + TEA_MAKE_LIB because setting too early confuses other AC_* macros. + Correct the HP-11 SHLIB_LD_LIBS setting. + + * tcl.m4: add the CFLAGS definition into TEA_ENABLE_SHARED and + make it pick up the env CFLAGS at configure time. + +2002-10-09 Jeff Hobbs + + * tcl.m4: add --enable-symbols=mem option to enable TCL_MEM_DEBUG. + Improved AIX 64-bit build support, allow it on AIX-4 as well. + Enable 64-bit HP-11 compilation with gcc. + Enable 64-bit IRIX64-6 cc build support. + Correct FreeBSD thread library linkage. + Add OSF1 static build support. + Improve SunOS-5 shared build SHLIB_LD macro. + +2002-07-20 Zoran Vasiljevic + + * tcl.m4: Added MINGW32 to list of systems checked for Windows build. + Also, fixes some indentation issues with "--with-XXX" options. + +2002-04-23 Jeff Hobbs + + * tcl.m4 (TEA_ENABLE_THREADS): added USE_THREAD_ALLOC define to + use new threaded allocatory by default on Unix for Tcl 8.4. + (TEA_CONFIG_CFLAGS): corrected LD_SEARCH_FLAGS for FreeBSD-3+. + +2002-04-22 Jeff Hobbs + + * tcl.m4 (TEA_SETUP_COMPILER): removed call to AC_CYGWIN so that + we can use autoconf 2.5x as well as 2.13. This prevents us from + being able to warn against the use of cygwin gcc at configure + time, but allows autoconf 2.5x, which is what is shipped with most + newer systems. + +2002-04-11 Jeff Hobbs + + * tcl.m4: Enabled COFF as well as CV style debug info with + --enable-symbols to allow Dr. Watson users to see function info. + More info on debugging levels can be obtained at: + http://msdn.microsoft.com/library/en-us/dnvc60/html/gendepdebug.asp + +2002-04-03 Jeff Hobbs + + * tcl.m4: change all SC_* macros to TEA_*. The SC_ was for + Scriptics, which is no more. TEA represents a better, independent + prefix that won't need changing. + Added preliminary mingw gcc support. [Patch #538772] + Added TEA_PREFIX macro that handles defaulting the prefix and + exec_prefix vars to those used by Tcl if none were specified. + Added TEA_SETUP_COMPILER macro that encompasses the AC_PROG_CC + check and several other basic AC_PROG checks needed for making + executables. This greatly simplifies user's configure.in files. + Collapsed AIX-5 defines into AIX-* with extra checks for doing the + ELF stuff on AIX-5-ia64. + Updated TEA_ENABLE_THREADS to take an optional arg to allow + switching it on by default (for Thread) and add sanity checking to + warn the user if configuring threads incompatibly. + +2002-03-29 Jeff Hobbs + + * tcl.m4: made sure that SHLIB_LDFLAGS was set to LDFLAGS_DEFAULT. + Removed --enable-64bit support for AIX-4 because it wasn't correct. + Added -MT or -MD Windows linker switches to properly support + symbols-enabled builds. + +2002-03-28 Jeff Hobbs + + * tcl.m4: called AC_MSG_ERROR when SC_TEA_INIT wasn't called first + instead of calling it as that inlines it each time in shell code. + Changed Windows CFLAGS_OPTIMIZE to use -O2 instead of -Oti. + Noted TCL_LIB_VERSIONS_OK=nodots for Windows builds. + A few changes to support itcl (and perhaps others): + Added support for making your own stub libraries to SC_MAKE_LIB. + New SC_PATH_CONFIG and SC_LOAD_CONFIG that take a package name arg + and find that ${pkg}Config.sh file. itk uses this for itcl. + +2002-03-27 Jeff Hobbs + + * tcl.m4: made SC_LOAD_TKCONFIG recognize when working with a Tk + build dir setup. + Added EXTRA_CFLAGS and SHLIB_LD_LIBS substs to SC_CONFIG_CFLAGS. + Added XLIBSW onto LIBS when it is defined. + Remove TCL_LIBS from MAKE_LIB and correctly use SHLIB_LD_LIBS + instead to not rely as much on tclConfig.sh cached info. + Add TK_BIN_DIR to paths to find wish in SC_PROG_WISH. + These move towards making TEA much more independent of *Config.sh. + +2002-03-19 Jeff Hobbs + + * tcl.m4: corrected forgotten (UN)SHARED_LIB_SUFFIX and + SHLIB_SUFFIX defines for Win. + (SC_PATH_X): made this only do the check on unix platforms. + +2002-03-12 Jeff Hobbs + + * README.txt: updated to reflect fewer files + +2002-03-06 Jeff Hobbs + + * config.guess (removed): + * config.sub (removed): removed unnecessary files + + * installFile.tcl (removed): + * mkinstalldirs (removed): these aren't really necessary for + making TEA work + + * tcl.m4 (SC_PUBLIC_TCL_HEADERS, SC_PUBLIC_TK_HEADERS): don't + check /usr(/local)/include for includes on Windows when not using + gcc + +2002-03-05 Jeff Hobbs + + * tcl.m4: added warnings on Windows, removed RELPATH define and + added TCL_LIBS to MAKE_LIB macro. + + This import represents 2.0.0, or a new start at attempting to + make TEA much easier for C extension developers. + + **** moved from tclpro project to core tcl project, **** + **** renamed to 'tclconfig' **** + +2001-03-15 Karl Lehenbauer + + * installFile.tcl: Added updating of the modification time of + the target file whether we overwrote it or decided that it + hadn't changed. This was necessary for us to be able to + determine whether or not a module install touched the file. + +2001-03-08 Karl Lehenbauer + + * installFile.tcl: Added support for converting new-style (1.1+) + Cygnus drive paths to Tcl-style. + +2001-01-15 + + * tcl.m4: Added FreeBSD clause. + +2001-01-03 + + * tcl.m4: Fixed typo in SC_LIB_SPEC where it is checking + for exec-prefix. + +2000-12-01 + + * tcl.m4: Concatenated most of the Ajuba acsite.m4 file + so we don't need to modify the autoconf installation. + * config.guess: + * config.sub: + * installFile.tcl: + Added files from the itcl config subdirectory, + which should go away. + +2000-7-29 + + * Fixed the use of TCL_SRC_DIR and TK_SRC_DIR within + TCL_PRIVATE_INCLUDES and TK_PRIVATE_INCLUDES to match their recent + change from $(srcdir) to $(srcdir)/.. diff --git a/tksao/tclconfig/README.txt b/tksao/tclconfig/README.txt new file mode 100644 index 0000000..59b5a3e --- /dev/null +++ b/tksao/tclconfig/README.txt @@ -0,0 +1,26 @@ +These files comprise the basic building blocks for a Tcl Extension +Architecture (TEA) extension. For more information on TEA see: + + http://www.tcl.tk/doc/tea/ + +This package is part of the Tcl project at SourceForge, and latest +sources should be available there: + + http://tcl.sourceforge.net/ + +This package is a freely available open source package. You can do +virtually anything you like with it, such as modifying it, redistributing +it, and selling it either in whole or in part. + +CONTENTS +======== +The following is a short description of the files you will find in +the sample extension. + +README.txt This file + +install-sh Program used for copying binaries and script files + to their install locations. + +tcl.m4 Collection of Tcl autoconf macros. Included by a package's + aclocal.m4 to define TEA_* macros. diff --git a/tksao/tclconfig/install-sh b/tksao/tclconfig/install-sh new file mode 100755 index 0000000..7c34c3f --- /dev/null +++ b/tksao/tclconfig/install-sh @@ -0,0 +1,528 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2011-04-20.01; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# 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 +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +nl=' +' +IFS=" "" $nl" + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +no_target_directory= + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -S $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -S) stripcmd="$stripprog $2" + shift;; + + -t) dst_arg=$2 + shift;; + + -T) no_target_directory=true;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dst_arg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" + + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/tksao/tclconfig/tcl.m4 b/tksao/tclconfig/tcl.m4 new file mode 100644 index 0000000..c641fe0 --- /dev/null +++ b/tksao/tclconfig/tcl.m4 @@ -0,0 +1,4150 @@ +# tcl.m4 -- +# +# This file provides a set of autoconf macros to help TEA-enable +# a Tcl extension. +# +# Copyright (c) 1999-2000 Ajuba Solutions. +# Copyright (c) 2002-2005 ActiveState Corporation. +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. + +AC_PREREQ(2.57) + +dnl TEA extensions pass us the version of TEA they think they +dnl are compatible with (must be set in TEA_INIT below) +dnl TEA_VERSION="3.9" + +# Possible values for key variables defined: +# +# TEA_WINDOWINGSYSTEM - win32 aqua x11 (mirrors 'tk windowingsystem') +# TEA_PLATFORM - windows unix +# + +#------------------------------------------------------------------------ +# TEA_PATH_TCLCONFIG -- +# +# Locate the tclConfig.sh file and perform a sanity check on +# the Tcl compile flags +# +# Arguments: +# none +# +# Results: +# +# Adds the following arguments to configure: +# --with-tcl=... +# +# Defines the following vars: +# TCL_BIN_DIR Full path to the directory containing +# the tclConfig.sh file +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_PATH_TCLCONFIG], [ + dnl TEA specific: Make sure we are initialized + AC_REQUIRE([TEA_INIT]) + # + # Ok, lets find the tcl configuration + # First, look for one uninstalled. + # the alternative search directory is invoked by --with-tcl + # + + if test x"${no_tcl}" = x ; then + # we reset no_tcl in case something fails here + no_tcl=true + AC_ARG_WITH(tcl, + AC_HELP_STRING([--with-tcl], + [directory containing tcl configuration (tclConfig.sh)]), + with_tclconfig="${withval}") + AC_MSG_CHECKING([for Tcl configuration]) + AC_CACHE_VAL(ac_cv_c_tclconfig,[ + + # First check to see if --with-tcl was specified. + if test x"${with_tclconfig}" != x ; then + case "${with_tclconfig}" in + */tclConfig.sh ) + if test -f "${with_tclconfig}"; then + AC_MSG_WARN([--with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself]) + with_tclconfig="`echo "${with_tclconfig}" | sed 's!/tclConfig\.sh$!!'`" + fi ;; + esac + if test -f "${with_tclconfig}/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd "${with_tclconfig}"; pwd)`" + else + AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh]) + fi + fi + + # then check for a private Tcl installation + if test x"${ac_cv_c_tclconfig}" = x ; then + for i in \ + ../tcl \ + `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \ + `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \ + `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \ + ../../tcl \ + `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \ + `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \ + `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \ + ../../../tcl \ + `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \ + `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \ + `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do + if test "${TEA_PLATFORM}" = "windows" \ + -a -f "$i/win/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd $i/win; pwd)`" + break + fi + if test -f "$i/unix/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd $i/unix; pwd)`" + break + fi + done + fi + + # on Darwin, check in Framework installation locations + if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then + for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ + `ls -d /Library/Frameworks 2>/dev/null` \ + `ls -d /Network/Library/Frameworks 2>/dev/null` \ + `ls -d /System/Library/Frameworks 2>/dev/null` \ + ; do + if test -f "$i/Tcl.framework/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd $i/Tcl.framework; pwd)`" + break + fi + done + fi + + # TEA specific: on Windows, check in common installation locations + if test "${TEA_PLATFORM}" = "windows" \ + -a x"${ac_cv_c_tclconfig}" = x ; then + for i in `ls -d C:/Tcl/lib 2>/dev/null` \ + `ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \ + ; do + if test -f "$i/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd $i; pwd)`" + break + fi + done + fi + + # check in a few common install locations + if test x"${ac_cv_c_tclconfig}" = x ; then + for i in `ls -d ${libdir} 2>/dev/null` \ + `ls -d ${exec_prefix}/lib 2>/dev/null` \ + `ls -d ${prefix}/lib 2>/dev/null` \ + `ls -d /usr/local/lib 2>/dev/null` \ + `ls -d /usr/contrib/lib 2>/dev/null` \ + `ls -d /usr/lib 2>/dev/null` \ + `ls -d /usr/lib64 2>/dev/null` \ + ; do + if test -f "$i/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd $i; pwd)`" + break + fi + done + fi + + # check in a few other private locations + if test x"${ac_cv_c_tclconfig}" = x ; then + for i in \ + ${srcdir}/../tcl \ + `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \ + `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \ + `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do + if test "${TEA_PLATFORM}" = "windows" \ + -a -f "$i/win/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd $i/win; pwd)`" + break + fi + if test -f "$i/unix/tclConfig.sh" ; then + ac_cv_c_tclconfig="`(cd $i/unix; pwd)`" + break + fi + done + fi + ]) + + if test x"${ac_cv_c_tclconfig}" = x ; then + TCL_BIN_DIR="# no Tcl configs found" + AC_MSG_ERROR([Can't find Tcl configuration definitions. Use --with-tcl to specify a directory containing tclConfig.sh]) + else + no_tcl= + TCL_BIN_DIR="${ac_cv_c_tclconfig}" + AC_MSG_RESULT([found ${TCL_BIN_DIR}/tclConfig.sh]) + fi + fi +]) + +#------------------------------------------------------------------------ +# TEA_PATH_TKCONFIG -- +# +# Locate the tkConfig.sh file +# +# Arguments: +# none +# +# Results: +# +# Adds the following arguments to configure: +# --with-tk=... +# +# Defines the following vars: +# TK_BIN_DIR Full path to the directory containing +# the tkConfig.sh file +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_PATH_TKCONFIG], [ + # + # Ok, lets find the tk configuration + # First, look for one uninstalled. + # the alternative search directory is invoked by --with-tk + # + + if test x"${no_tk}" = x ; then + # we reset no_tk in case something fails here + no_tk=true + AC_ARG_WITH(tk, + AC_HELP_STRING([--with-tk], + [directory containing tk configuration (tkConfig.sh)]), + with_tkconfig="${withval}") + AC_MSG_CHECKING([for Tk configuration]) + AC_CACHE_VAL(ac_cv_c_tkconfig,[ + + # First check to see if --with-tkconfig was specified. + if test x"${with_tkconfig}" != x ; then + case "${with_tkconfig}" in + */tkConfig.sh ) + if test -f "${with_tkconfig}"; then + AC_MSG_WARN([--with-tk argument should refer to directory containing tkConfig.sh, not to tkConfig.sh itself]) + with_tkconfig="`echo "${with_tkconfig}" | sed 's!/tkConfig\.sh$!!'`" + fi ;; + esac + if test -f "${with_tkconfig}/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd "${with_tkconfig}"; pwd)`" + else + AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh]) + fi + fi + + # then check for a private Tk library + if test x"${ac_cv_c_tkconfig}" = x ; then + for i in \ + ../tk \ + `ls -dr ../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \ + `ls -dr ../tk[[8-9]].[[0-9]] 2>/dev/null` \ + `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \ + ../../tk \ + `ls -dr ../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \ + `ls -dr ../../tk[[8-9]].[[0-9]] 2>/dev/null` \ + `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \ + ../../../tk \ + `ls -dr ../../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \ + `ls -dr ../../../tk[[8-9]].[[0-9]] 2>/dev/null` \ + `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do + if test "${TEA_PLATFORM}" = "windows" \ + -a -f "$i/win/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd $i/win; pwd)`" + break + fi + if test -f "$i/unix/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd $i/unix; pwd)`" + break + fi + done + fi + + # on Darwin, check in Framework installation locations + if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tkconfig}" = x ; then + for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ + `ls -d /Library/Frameworks 2>/dev/null` \ + `ls -d /Network/Library/Frameworks 2>/dev/null` \ + `ls -d /System/Library/Frameworks 2>/dev/null` \ + ; do + if test -f "$i/Tk.framework/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd $i/Tk.framework; pwd)`" + break + fi + done + fi + + # check in a few common install locations + if test x"${ac_cv_c_tkconfig}" = x ; then + for i in `ls -d ${libdir} 2>/dev/null` \ + `ls -d ${exec_prefix}/lib 2>/dev/null` \ + `ls -d ${prefix}/lib 2>/dev/null` \ + `ls -d /usr/local/lib 2>/dev/null` \ + `ls -d /usr/contrib/lib 2>/dev/null` \ + `ls -d /usr/lib 2>/dev/null` \ + `ls -d /usr/lib64 2>/dev/null` \ + ; do + if test -f "$i/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd $i; pwd)`" + break + fi + done + fi + + # TEA specific: on Windows, check in common installation locations + if test "${TEA_PLATFORM}" = "windows" \ + -a x"${ac_cv_c_tkconfig}" = x ; then + for i in `ls -d C:/Tcl/lib 2>/dev/null` \ + `ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \ + ; do + if test -f "$i/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd $i; pwd)`" + break + fi + done + fi + + # check in a few other private locations + if test x"${ac_cv_c_tkconfig}" = x ; then + for i in \ + ${srcdir}/../tk \ + `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \ + `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]] 2>/dev/null` \ + `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do + if test "${TEA_PLATFORM}" = "windows" \ + -a -f "$i/win/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd $i/win; pwd)`" + break + fi + if test -f "$i/unix/tkConfig.sh" ; then + ac_cv_c_tkconfig="`(cd $i/unix; pwd)`" + break + fi + done + fi + ]) + + if test x"${ac_cv_c_tkconfig}" = x ; then + TK_BIN_DIR="# no Tk configs found" + AC_MSG_ERROR([Can't find Tk configuration definitions. Use --with-tk to specify a directory containing tkConfig.sh]) + else + no_tk= + TK_BIN_DIR="${ac_cv_c_tkconfig}" + AC_MSG_RESULT([found ${TK_BIN_DIR}/tkConfig.sh]) + fi + fi +]) + +#------------------------------------------------------------------------ +# TEA_LOAD_TCLCONFIG -- +# +# Load the tclConfig.sh file +# +# Arguments: +# +# Requires the following vars to be set: +# TCL_BIN_DIR +# +# Results: +# +# Substitutes the following vars: +# TCL_BIN_DIR +# TCL_SRC_DIR +# TCL_LIB_FILE +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_LOAD_TCLCONFIG], [ + AC_MSG_CHECKING([for existence of ${TCL_BIN_DIR}/tclConfig.sh]) + + if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then + AC_MSG_RESULT([loading]) + . "${TCL_BIN_DIR}/tclConfig.sh" + else + AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh]) + fi + + # eval is required to do the TCL_DBGX substitution + eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\"" + eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\"" + + # If the TCL_BIN_DIR is the build directory (not the install directory), + # then set the common variable name to the value of the build variables. + # For example, the variable TCL_LIB_SPEC will be set to the value + # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC + # instead of TCL_BUILD_LIB_SPEC since it will work with both an + # installed and uninstalled version of Tcl. + if test -f "${TCL_BIN_DIR}/Makefile" ; then + TCL_LIB_SPEC="${TCL_BUILD_LIB_SPEC}" + TCL_STUB_LIB_SPEC="${TCL_BUILD_STUB_LIB_SPEC}" + TCL_STUB_LIB_PATH="${TCL_BUILD_STUB_LIB_PATH}" + elif test "`uname -s`" = "Darwin"; then + # If Tcl was built as a framework, attempt to use the libraries + # from the framework at the given location so that linking works + # against Tcl.framework installed in an arbitrary location. + case ${TCL_DEFS} in + *TCL_FRAMEWORK*) + if test -f "${TCL_BIN_DIR}/${TCL_LIB_FILE}"; then + for i in "`cd "${TCL_BIN_DIR}"; pwd`" \ + "`cd "${TCL_BIN_DIR}"/../..; pwd`"; do + if test "`basename "$i"`" = "${TCL_LIB_FILE}.framework"; then + TCL_LIB_SPEC="-F`dirname "$i" | sed -e 's/ /\\\\ /g'` -framework ${TCL_LIB_FILE}" + break + fi + done + fi + if test -f "${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"; then + TCL_STUB_LIB_SPEC="-L`echo "${TCL_BIN_DIR}" | sed -e 's/ /\\\\ /g'` ${TCL_STUB_LIB_FLAG}" + TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}" + fi + ;; + esac + fi + + # eval is required to do the TCL_DBGX substitution + eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\"" + eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\"" + eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\"" + eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\"" + + AC_SUBST(TCL_VERSION) + AC_SUBST(TCL_PATCH_LEVEL) + AC_SUBST(TCL_BIN_DIR) + AC_SUBST(TCL_SRC_DIR) + + AC_SUBST(TCL_LIB_FILE) + AC_SUBST(TCL_LIB_FLAG) + AC_SUBST(TCL_LIB_SPEC) + + AC_SUBST(TCL_STUB_LIB_FILE) + AC_SUBST(TCL_STUB_LIB_FLAG) + AC_SUBST(TCL_STUB_LIB_SPEC) + + AC_MSG_CHECKING([platform]) + hold_cc=$CC; CC="$TCL_CC" + AC_TRY_COMPILE(,[ + #ifdef _WIN32 + #error win32 + #endif + ], TEA_PLATFORM="unix", + TEA_PLATFORM="windows" + ) + CC=$hold_cc + AC_MSG_RESULT($TEA_PLATFORM) + + # The BUILD_$pkg is to define the correct extern storage class + # handling when making this package + AC_DEFINE_UNQUOTED(BUILD_${PACKAGE_NAME}, [], + [Building extension source?]) + # Do this here as we have fully defined TEA_PLATFORM now + if test "${TEA_PLATFORM}" = "windows" ; then + EXEEXT=".exe" + CLEANFILES="$CLEANFILES *.lib *.dll *.pdb *.exp" + fi + + # TEA specific: + AC_SUBST(CLEANFILES) + AC_SUBST(TCL_LIBS) + AC_SUBST(TCL_DEFS) + AC_SUBST(TCL_EXTRA_CFLAGS) + AC_SUBST(TCL_LD_FLAGS) + AC_SUBST(TCL_SHLIB_LD_LIBS) +]) + +#------------------------------------------------------------------------ +# TEA_LOAD_TKCONFIG -- +# +# Load the tkConfig.sh file +# +# Arguments: +# +# Requires the following vars to be set: +# TK_BIN_DIR +# +# Results: +# +# Sets the following vars that should be in tkConfig.sh: +# TK_BIN_DIR +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_LOAD_TKCONFIG], [ + AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh]) + + if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then + AC_MSG_RESULT([loading]) + . "${TK_BIN_DIR}/tkConfig.sh" + else + AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh]) + fi + + # eval is required to do the TK_DBGX substitution + eval "TK_LIB_FILE=\"${TK_LIB_FILE}\"" + eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\"" + + # If the TK_BIN_DIR is the build directory (not the install directory), + # then set the common variable name to the value of the build variables. + # For example, the variable TK_LIB_SPEC will be set to the value + # of TK_BUILD_LIB_SPEC. An extension should make use of TK_LIB_SPEC + # instead of TK_BUILD_LIB_SPEC since it will work with both an + # installed and uninstalled version of Tcl. + if test -f "${TK_BIN_DIR}/Makefile" ; then + TK_LIB_SPEC="${TK_BUILD_LIB_SPEC}" + TK_STUB_LIB_SPEC="${TK_BUILD_STUB_LIB_SPEC}" + TK_STUB_LIB_PATH="${TK_BUILD_STUB_LIB_PATH}" + elif test "`uname -s`" = "Darwin"; then + # If Tk was built as a framework, attempt to use the libraries + # from the framework at the given location so that linking works + # against Tk.framework installed in an arbitrary location. + case ${TK_DEFS} in + *TK_FRAMEWORK*) + if test -f "${TK_BIN_DIR}/${TK_LIB_FILE}"; then + for i in "`cd "${TK_BIN_DIR}"; pwd`" \ + "`cd "${TK_BIN_DIR}"/../..; pwd`"; do + if test "`basename "$i"`" = "${TK_LIB_FILE}.framework"; then + TK_LIB_SPEC="-F`dirname "$i" | sed -e 's/ /\\\\ /g'` -framework ${TK_LIB_FILE}" + break + fi + done + fi + if test -f "${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"; then + TK_STUB_LIB_SPEC="-L` echo "${TK_BIN_DIR}" | sed -e 's/ /\\\\ /g'` ${TK_STUB_LIB_FLAG}" + TK_STUB_LIB_PATH="${TK_BIN_DIR}/${TK_STUB_LIB_FILE}" + fi + ;; + esac + fi + + # eval is required to do the TK_DBGX substitution + eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\"" + eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\"" + eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\"" + eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\"" + + # TEA specific: Ensure windowingsystem is defined + if test "${TEA_PLATFORM}" = "unix" ; then + case ${TK_DEFS} in + *MAC_OSX_TK*) + AC_DEFINE(MAC_OSX_TK, 1, [Are we building against Mac OS X TkAqua?]) + TEA_WINDOWINGSYSTEM="aqua" + ;; + *) + TEA_WINDOWINGSYSTEM="x11" + ;; + esac + elif test "${TEA_PLATFORM}" = "windows" ; then + TEA_WINDOWINGSYSTEM="win32" + fi + + AC_SUBST(TK_VERSION) + AC_SUBST(TK_BIN_DIR) + AC_SUBST(TK_SRC_DIR) + + AC_SUBST(TK_LIB_FILE) + AC_SUBST(TK_LIB_FLAG) + AC_SUBST(TK_LIB_SPEC) + + AC_SUBST(TK_STUB_LIB_FILE) + AC_SUBST(TK_STUB_LIB_FLAG) + AC_SUBST(TK_STUB_LIB_SPEC) + + # TEA specific: + AC_SUBST(TK_LIBS) + AC_SUBST(TK_XINCLUDES) +]) + +#------------------------------------------------------------------------ +# TEA_PROG_TCLSH +# Determine the fully qualified path name of the tclsh executable +# in the Tcl build directory or the tclsh installed in a bin +# directory. This macro will correctly determine the name +# of the tclsh executable even if tclsh has not yet been +# built in the build directory. The tclsh found is always +# associated with a tclConfig.sh file. This tclsh should be used +# only for running extension test cases. It should never be +# or generation of files (like pkgIndex.tcl) at build time. +# +# Arguments: +# none +# +# Results: +# Substitutes the following vars: +# TCLSH_PROG +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_PROG_TCLSH], [ + AC_MSG_CHECKING([for tclsh]) + if test -f "${TCL_BIN_DIR}/Makefile" ; then + # tclConfig.sh is in Tcl build directory + if test "${TEA_PLATFORM}" = "windows"; then + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" + else + TCLSH_PROG="${TCL_BIN_DIR}/tclsh" + fi + else + # tclConfig.sh is in install location + if test "${TEA_PLATFORM}" = "windows"; then + TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" + else + TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}${TCL_DBGX}" + fi + list="`ls -d ${TCL_BIN_DIR}/../bin 2>/dev/null` \ + `ls -d ${TCL_BIN_DIR}/.. 2>/dev/null` \ + `ls -d ${TCL_PREFIX}/bin 2>/dev/null`" + for i in $list ; do + if test -f "$i/${TCLSH_PROG}" ; then + REAL_TCL_BIN_DIR="`cd "$i"; pwd`/" + break + fi + done + TCLSH_PROG="${REAL_TCL_BIN_DIR}${TCLSH_PROG}" + fi + AC_MSG_RESULT([${TCLSH_PROG}]) + AC_SUBST(TCLSH_PROG) +]) + +#------------------------------------------------------------------------ +# TEA_PROG_WISH +# Determine the fully qualified path name of the wish executable +# in the Tk build directory or the wish installed in a bin +# directory. This macro will correctly determine the name +# of the wish executable even if wish has not yet been +# built in the build directory. The wish found is always +# associated with a tkConfig.sh file. This wish should be used +# only for running extension test cases. It should never be +# or generation of files (like pkgIndex.tcl) at build time. +# +# Arguments: +# none +# +# Results: +# Substitutes the following vars: +# WISH_PROG +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_PROG_WISH], [ + AC_MSG_CHECKING([for wish]) + if test -f "${TK_BIN_DIR}/Makefile" ; then + # tkConfig.sh is in Tk build directory + if test "${TEA_PLATFORM}" = "windows"; then + WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}" + else + WISH_PROG="${TK_BIN_DIR}/wish" + fi + else + # tkConfig.sh is in install location + if test "${TEA_PLATFORM}" = "windows"; then + WISH_PROG="wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}" + else + WISH_PROG="wish${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}${TK_DBGX}" + fi + list="`ls -d ${TK_BIN_DIR}/../bin 2>/dev/null` \ + `ls -d ${TK_BIN_DIR}/.. 2>/dev/null` \ + `ls -d ${TK_PREFIX}/bin 2>/dev/null`" + for i in $list ; do + if test -f "$i/${WISH_PROG}" ; then + REAL_TK_BIN_DIR="`cd "$i"; pwd`/" + break + fi + done + WISH_PROG="${REAL_TK_BIN_DIR}${WISH_PROG}" + fi + AC_MSG_RESULT([${WISH_PROG}]) + AC_SUBST(WISH_PROG) +]) + +#------------------------------------------------------------------------ +# TEA_ENABLE_SHARED -- +# +# Allows the building of shared libraries +# +# Arguments: +# none +# +# Results: +# +# Adds the following arguments to configure: +# --enable-shared=yes|no +# +# Defines the following vars: +# STATIC_BUILD Used for building import/export libraries +# on Windows. +# +# Sets the following vars: +# SHARED_BUILD Value of 1 or 0 +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_ENABLE_SHARED], [ + AC_MSG_CHECKING([how to build libraries]) + AC_ARG_ENABLE(shared, + AC_HELP_STRING([--enable-shared], + [build and link with shared libraries (default: on)]), + [tcl_ok=$enableval], [tcl_ok=yes]) + + if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + tcl_ok=$enableval + else + tcl_ok=yes + fi + + if test "$tcl_ok" = "yes" ; then + AC_MSG_RESULT([shared]) + SHARED_BUILD=1 + else + AC_MSG_RESULT([static]) + SHARED_BUILD=0 + AC_DEFINE(STATIC_BUILD, 1, [Is this a static build?]) + fi + AC_SUBST(SHARED_BUILD) +]) + +#------------------------------------------------------------------------ +# TEA_ENABLE_THREADS -- +# +# Specify if thread support should be enabled. If "yes" is specified +# as an arg (optional), threads are enabled by default, "no" means +# threads are disabled. "yes" is the default. +# +# TCL_THREADS is checked so that if you are compiling an extension +# against a threaded core, your extension must be compiled threaded +# as well. +# +# Note that it is legal to have a thread enabled extension run in a +# threaded or non-threaded Tcl core, but a non-threaded extension may +# only run in a non-threaded Tcl core. +# +# Arguments: +# none +# +# Results: +# +# Adds the following arguments to configure: +# --enable-threads +# +# Sets the following vars: +# THREADS_LIBS Thread library(s) +# +# Defines the following vars: +# TCL_THREADS +# _REENTRANT +# _THREAD_SAFE +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_ENABLE_THREADS], [ + AC_ARG_ENABLE(threads, + AC_HELP_STRING([--enable-threads], + [build with threads]), + [tcl_ok=$enableval], [tcl_ok=yes]) + + if test "${enable_threads+set}" = set; then + enableval="$enable_threads" + tcl_ok=$enableval + else + tcl_ok=yes + fi + + if test "$tcl_ok" = "yes" -o "${TCL_THREADS}" = 1; then + TCL_THREADS=1 + + if test "${TEA_PLATFORM}" != "windows" ; then + # We are always OK on Windows, so check what this platform wants: + + # USE_THREAD_ALLOC tells us to try the special thread-based + # allocator that significantly reduces lock contention + AC_DEFINE(USE_THREAD_ALLOC, 1, + [Do we want to use the threaded memory allocator?]) + AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?]) + if test "`uname -s`" = "SunOS" ; then + AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, + [Do we really want to follow the standard? Yes we do!]) + fi + AC_DEFINE(_THREAD_SAFE, 1, [Do we want the thread-safe OS API?]) + AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no) + if test "$tcl_ok" = "no"; then + # Check a little harder for __pthread_mutex_init in the same + # library, as some systems hide it there until pthread.h is + # defined. We could alternatively do an AC_TRY_COMPILE with + # pthread.h, but that will work with libpthread really doesn't + # exist, like AIX 4.2. [Bug: 4359] + AC_CHECK_LIB(pthread, __pthread_mutex_init, + tcl_ok=yes, tcl_ok=no) + fi + + if test "$tcl_ok" = "yes"; then + # The space is needed + THREADS_LIBS=" -lpthread" + else + AC_CHECK_LIB(pthreads, pthread_mutex_init, + tcl_ok=yes, tcl_ok=no) + if test "$tcl_ok" = "yes"; then + # The space is needed + THREADS_LIBS=" -lpthreads" + else + AC_CHECK_LIB(c, pthread_mutex_init, + tcl_ok=yes, tcl_ok=no) + if test "$tcl_ok" = "no"; then + AC_CHECK_LIB(c_r, pthread_mutex_init, + tcl_ok=yes, tcl_ok=no) + if test "$tcl_ok" = "yes"; then + # The space is needed + THREADS_LIBS=" -pthread" + else + TCL_THREADS=0 + AC_MSG_WARN([Do not know how to find pthread lib on your system - thread support disabled]) + fi + fi + fi + fi + fi + else + TCL_THREADS=0 + fi + # Do checking message here to not mess up interleaved configure output + AC_MSG_CHECKING([for building with threads]) + if test "${TCL_THREADS}" = 1; then + AC_DEFINE(TCL_THREADS, 1, [Are we building with threads enabled?]) + AC_MSG_RESULT([yes (default)]) + else + AC_MSG_RESULT([no]) + fi + # TCL_THREADS sanity checking. See if our request for building with + # threads is the same as the way Tcl was built. If not, warn the user. + case ${TCL_DEFS} in + *THREADS=1*) + if test "${TCL_THREADS}" = "0"; then + AC_MSG_WARN([ + Building ${PACKAGE_NAME} without threads enabled, but building against Tcl + that IS thread-enabled. It is recommended to use --enable-threads.]) + fi + ;; + *) + if test "${TCL_THREADS}" = "1"; then + AC_MSG_WARN([ + --enable-threads requested, but building against a Tcl that is NOT + thread-enabled. This is an OK configuration that will also run in + a thread-enabled core.]) + fi + ;; + esac + AC_SUBST(TCL_THREADS) +]) + +#------------------------------------------------------------------------ +# TEA_ENABLE_SYMBOLS -- +# +# Specify if debugging symbols should be used. +# Memory (TCL_MEM_DEBUG) debugging can also be enabled. +# +# Arguments: +# none +# +# TEA varies from core Tcl in that C|LDFLAGS_DEFAULT receives +# the value of C|LDFLAGS_OPTIMIZE|DEBUG already substituted. +# Requires the following vars to be set in the Makefile: +# CFLAGS_DEFAULT +# LDFLAGS_DEFAULT +# +# Results: +# +# Adds the following arguments to configure: +# --enable-symbols +# +# Defines the following vars: +# CFLAGS_DEFAULT Sets to $(CFLAGS_DEBUG) if true +# Sets to "$(CFLAGS_OPTIMIZE) -DNDEBUG" if false +# LDFLAGS_DEFAULT Sets to $(LDFLAGS_DEBUG) if true +# Sets to $(LDFLAGS_OPTIMIZE) if false +# DBGX Formerly used as debug library extension; +# always blank now. +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_ENABLE_SYMBOLS], [ + dnl TEA specific: Make sure we are initialized + AC_REQUIRE([TEA_CONFIG_CFLAGS]) + AC_MSG_CHECKING([for build with symbols]) + AC_ARG_ENABLE(symbols, + AC_HELP_STRING([--enable-symbols], + [build with debugging symbols (default: off)]), + [tcl_ok=$enableval], [tcl_ok=no]) + DBGX="" + if test "$tcl_ok" = "no"; then + CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE} -DNDEBUG" + LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}" + AC_MSG_RESULT([no]) + else + CFLAGS_DEFAULT="${CFLAGS_DEBUG}" + LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}" + if test "$tcl_ok" = "yes"; then + AC_MSG_RESULT([yes (standard debugging)]) + fi + fi + # TEA specific: + if test "${TEA_PLATFORM}" != "windows" ; then + LDFLAGS_DEFAULT="${LDFLAGS}" + fi + AC_SUBST(CFLAGS_DEFAULT) + AC_SUBST(LDFLAGS_DEFAULT) + AC_SUBST(TCL_DBGX) + + if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then + AC_DEFINE(TCL_MEM_DEBUG, 1, [Is memory debugging enabled?]) + fi + + if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then + if test "$tcl_ok" = "all"; then + AC_MSG_RESULT([enabled symbols mem debugging]) + else + AC_MSG_RESULT([enabled $tcl_ok debugging]) + fi + fi +]) + +#------------------------------------------------------------------------ +# TEA_ENABLE_LANGINFO -- +# +# Allows use of modern nl_langinfo check for better l10n. +# This is only relevant for Unix. +# +# Arguments: +# none +# +# Results: +# +# Adds the following arguments to configure: +# --enable-langinfo=yes|no (default is yes) +# +# Defines the following vars: +# HAVE_LANGINFO Triggers use of nl_langinfo if defined. +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_ENABLE_LANGINFO], [ + AC_ARG_ENABLE(langinfo, + AC_HELP_STRING([--enable-langinfo], + [use nl_langinfo if possible to determine encoding at startup, otherwise use old heuristic (default: on)]), + [langinfo_ok=$enableval], [langinfo_ok=yes]) + + HAVE_LANGINFO=0 + if test "$langinfo_ok" = "yes"; then + AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no]) + fi + AC_MSG_CHECKING([whether to use nl_langinfo]) + if test "$langinfo_ok" = "yes"; then + AC_CACHE_VAL(tcl_cv_langinfo_h, [ + AC_TRY_COMPILE([#include ], [nl_langinfo(CODESET);], + [tcl_cv_langinfo_h=yes],[tcl_cv_langinfo_h=no])]) + AC_MSG_RESULT([$tcl_cv_langinfo_h]) + if test $tcl_cv_langinfo_h = yes; then + AC_DEFINE(HAVE_LANGINFO, 1, [Do we have nl_langinfo()?]) + fi + else + AC_MSG_RESULT([$langinfo_ok]) + fi +]) + +#-------------------------------------------------------------------- +# TEA_CONFIG_SYSTEM +# +# Determine what the system is (some things cannot be easily checked +# on a feature-driven basis, alas). This can usually be done via the +# "uname" command. +# +# Arguments: +# none +# +# Results: +# Defines the following var: +# +# system - System/platform/version identification code. +#-------------------------------------------------------------------- + +AC_DEFUN([TEA_CONFIG_SYSTEM], [ + AC_CACHE_CHECK([system version], tcl_cv_sys_version, [ + # TEA specific: + if test "${TEA_PLATFORM}" = "windows" ; then + tcl_cv_sys_version=windows + else + tcl_cv_sys_version=`uname -s`-`uname -r` + if test "$?" -ne 0 ; then + AC_MSG_WARN([can't find uname command]) + tcl_cv_sys_version=unknown + else + if test "`uname -s`" = "AIX" ; then + tcl_cv_sys_version=AIX-`uname -v`.`uname -r` + fi + fi + fi + ]) + system=$tcl_cv_sys_version +]) + +#-------------------------------------------------------------------- +# TEA_CONFIG_CFLAGS +# +# Try to determine the proper flags to pass to the compiler +# for building shared libraries and other such nonsense. +# +# Arguments: +# none +# +# Results: +# +# Defines and substitutes the following vars: +# +# DL_OBJS, DL_LIBS - removed for TEA, only needed by core. +# LDFLAGS - Flags to pass to the compiler when linking object +# files into an executable application binary such +# as tclsh. +# LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib", +# that tell the run-time dynamic linker where to look +# for shared libraries such as libtcl.so. Depends on +# the variable LIB_RUNTIME_DIR in the Makefile. Could +# be the same as CC_SEARCH_FLAGS if ${CC} is used to link. +# CC_SEARCH_FLAGS-Flags to pass to ${CC}, such as "-Wl,-rpath,/usr/local/tcl/lib", +# that tell the run-time dynamic linker where to look +# for shared libraries such as libtcl.so. Depends on +# the variable LIB_RUNTIME_DIR in the Makefile. +# SHLIB_CFLAGS - Flags to pass to cc when compiling the components +# of a shared library (may request position-independent +# code, among other things). +# SHLIB_LD - Base command to use for combining object files +# into a shared library. +# SHLIB_LD_LIBS - Dependent libraries for the linker to scan when +# creating shared libraries. This symbol typically +# goes at the end of the "ld" commands that build +# shared libraries. The value of the symbol defaults to +# "${LIBS}" if all of the dependent libraries should +# be specified when creating a shared library. If +# dependent libraries should not be specified (as on +# SunOS 4.x, where they cause the link to fail, or in +# general if Tcl and Tk aren't themselves shared +# libraries), then this symbol has an empty string +# as its value. +# SHLIB_SUFFIX - Suffix to use for the names of dynamically loadable +# extensions. An empty string means we don't know how +# to use shared libraries on this platform. +# LIB_SUFFIX - Specifies everything that comes after the "libfoo" +# in a static or shared library name, using the $PACKAGE_VERSION variable +# to put the version in the right place. This is used +# by platforms that need non-standard library names. +# Examples: ${PACKAGE_VERSION}.so.1.1 on NetBSD, since it needs +# to have a version after the .so, and ${PACKAGE_VERSION}.a +# on AIX, since a shared library needs to have +# a .a extension whereas shared objects for loadable +# extensions have a .so extension. Defaults to +# ${PACKAGE_VERSION}${SHLIB_SUFFIX}. +# CFLAGS_DEBUG - +# Flags used when running the compiler in debug mode +# CFLAGS_OPTIMIZE - +# Flags used when running the compiler in optimize mode +# CFLAGS - Additional CFLAGS added as necessary (usually 64-bit) +#-------------------------------------------------------------------- + +AC_DEFUN([TEA_CONFIG_CFLAGS], [ + dnl TEA specific: Make sure we are initialized + AC_REQUIRE([TEA_INIT]) + + # Step 0.a: Enable 64 bit support? + + AC_MSG_CHECKING([if 64bit support is requested]) + AC_ARG_ENABLE(64bit, + AC_HELP_STRING([--enable-64bit], + [enable 64bit support (default: off)]), + [do64bit=$enableval], [do64bit=no]) + AC_MSG_RESULT([$do64bit]) + + # Step 0.b: Enable Solaris 64 bit VIS support? + + AC_MSG_CHECKING([if 64bit Sparc VIS support is requested]) + AC_ARG_ENABLE(64bit-vis, + AC_HELP_STRING([--enable-64bit-vis], + [enable 64bit Sparc VIS support (default: off)]), + [do64bitVIS=$enableval], [do64bitVIS=no]) + AC_MSG_RESULT([$do64bitVIS]) + # Force 64bit on with VIS + AS_IF([test "$do64bitVIS" = "yes"], [do64bit=yes]) + + # Step 0.c: Check if visibility support is available. Do this here so + # that platform specific alternatives can be used below if this fails. + + AC_CACHE_CHECK([if compiler supports visibility "hidden"], + tcl_cv_cc_visibility_hidden, [ + hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror" + AC_TRY_LINK([ + extern __attribute__((__visibility__("hidden"))) void f(void); + void f(void) {}], [f();], tcl_cv_cc_visibility_hidden=yes, + tcl_cv_cc_visibility_hidden=no) + CFLAGS=$hold_cflags]) + AS_IF([test $tcl_cv_cc_visibility_hidden = yes], [ + AC_DEFINE(MODULE_SCOPE, + [extern __attribute__((__visibility__("hidden")))], + [Compiler support for module scope symbols]) + AC_DEFINE(HAVE_HIDDEN, [1], [Compiler support for module scope symbols]) + ]) + + # Step 0.d: Disable -rpath support? + + AC_MSG_CHECKING([if rpath support is requested]) + AC_ARG_ENABLE(rpath, + AC_HELP_STRING([--disable-rpath], + [disable rpath support (default: on)]), + [doRpath=$enableval], [doRpath=yes]) + AC_MSG_RESULT([$doRpath]) + + # TEA specific: Cross-compiling options for Windows/CE builds? + + AS_IF([test "${TEA_PLATFORM}" = windows], [ + AC_MSG_CHECKING([if Windows/CE build is requested]) + AC_ARG_ENABLE(wince, + AC_HELP_STRING([--enable-wince], + [enable Win/CE support (where applicable)]), + [doWince=$enableval], [doWince=no]) + AC_MSG_RESULT([$doWince]) + ]) + + # Set the variable "system" to hold the name and version number + # for the system. + + TEA_CONFIG_SYSTEM + + # Require ranlib early so we can override it in special cases below. + + AC_REQUIRE([AC_PROG_RANLIB]) + + # Set configuration options based on system name and version. + # This is similar to Tcl's unix/tcl.m4 except that we've added a + # "windows" case and removed some core-only vars. + + do64bit_ok=no + # default to '{$LIBS}' and set to "" on per-platform necessary basis + SHLIB_LD_LIBS='${LIBS}' + # When ld needs options to work in 64-bit mode, put them in + # LDFLAGS_ARCH so they eventually end up in LDFLAGS even if [load] + # is disabled by the user. [Bug 1016796] + LDFLAGS_ARCH="" + UNSHARED_LIB_SUFFIX="" + # TEA specific: use PACKAGE_VERSION instead of VERSION + TCL_TRIM_DOTS='`echo ${PACKAGE_VERSION} | tr -d .`' + ECHO_VERSION='`echo ${PACKAGE_VERSION}`' + TCL_LIB_VERSIONS_OK=ok + CFLAGS_DEBUG=-g + AS_IF([test "$GCC" = yes], [ + CFLAGS_OPTIMIZE=-O2 + CFLAGS_WARNING="-Wall" + ], [ + CFLAGS_OPTIMIZE=-O + CFLAGS_WARNING="" + ]) + AC_CHECK_TOOL(AR, ar) + STLIB_LD='${AR} cr' + LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH" + AS_IF([test "x$SHLIB_VERSION" = x],[SHLIB_VERSION="1.0"]) + case $system in + # TEA specific: + windows) + # This is a 2-stage check to make sure we have the 64-bit SDK + # We have to know where the SDK is installed. + # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs + # MACHINE is IX86 for LINK, but this is used by the manifest, + # which requires x86|amd64|ia64. + MACHINE="X86" + if test "$do64bit" != "no" ; then + if test "x${MSSDK}x" = "xx" ; then + MSSDK="C:/Progra~1/Microsoft Platform SDK" + fi + MSSDK=`echo "$MSSDK" | sed -e 's!\\\!/!g'` + PATH64="" + case "$do64bit" in + amd64|x64|yes) + MACHINE="AMD64" ; # default to AMD64 64-bit build + PATH64="${MSSDK}/Bin/Win64/x86/AMD64" + ;; + ia64) + MACHINE="IA64" + PATH64="${MSSDK}/Bin/Win64" + ;; + esac + if test "$GCC" != "yes" -a ! -d "${PATH64}" ; then + AC_MSG_WARN([Could not find 64-bit $MACHINE SDK to enable 64bit mode]) + AC_MSG_WARN([Ensure latest Platform SDK is installed]) + do64bit="no" + else + AC_MSG_RESULT([ Using 64-bit $MACHINE mode]) + do64bit_ok="yes" + fi + fi + + if test "$doWince" != "no" ; then + if test "$do64bit" != "no" ; then + AC_MSG_ERROR([Windows/CE and 64-bit builds incompatible]) + fi + if test "$GCC" = "yes" ; then + AC_MSG_ERROR([Windows/CE and GCC builds incompatible]) + fi + TEA_PATH_CELIB + # Set defaults for common evc4/PPC2003 setup + # Currently Tcl requires 300+, possibly 420+ for sockets + CEVERSION=420; # could be 211 300 301 400 420 ... + TARGETCPU=ARMV4; # could be ARMV4 ARM MIPS SH3 X86 ... + ARCH=ARM; # could be ARM MIPS X86EM ... + PLATFORM="Pocket PC 2003"; # or "Pocket PC 2002" + if test "$doWince" != "yes"; then + # If !yes then the user specified something + # Reset ARCH to allow user to skip specifying it + ARCH= + eval `echo $doWince | awk -F, '{ \ + if (length([$]1)) { printf "CEVERSION=\"%s\"\n", [$]1; \ + if ([$]1 < 400) { printf "PLATFORM=\"Pocket PC 2002\"\n" } }; \ + if (length([$]2)) { printf "TARGETCPU=\"%s\"\n", toupper([$]2) }; \ + if (length([$]3)) { printf "ARCH=\"%s\"\n", toupper([$]3) }; \ + if (length([$]4)) { printf "PLATFORM=\"%s\"\n", [$]4 }; \ + }'` + if test "x${ARCH}" = "x" ; then + ARCH=$TARGETCPU; + fi + fi + OSVERSION=WCE$CEVERSION; + if test "x${WCEROOT}" = "x" ; then + WCEROOT="C:/Program Files/Microsoft eMbedded C++ 4.0" + if test ! -d "${WCEROOT}" ; then + WCEROOT="C:/Program Files/Microsoft eMbedded Tools" + fi + fi + if test "x${SDKROOT}" = "x" ; then + SDKROOT="C:/Program Files/Windows CE Tools" + if test ! -d "${SDKROOT}" ; then + SDKROOT="C:/Windows CE Tools" + fi + fi + WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'` + SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'` + if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" \ + -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then + AC_MSG_ERROR([could not find PocketPC SDK or target compiler to enable WinCE mode [$CEVERSION,$TARGETCPU,$ARCH,$PLATFORM]]) + doWince="no" + else + # We could PATH_NOSPACE these, but that's not important, + # as long as we quote them when used. + CEINCLUDE="${SDKROOT}/${OSVERSION}/${PLATFORM}/include" + if test -d "${CEINCLUDE}/${TARGETCPU}" ; then + CEINCLUDE="${CEINCLUDE}/${TARGETCPU}" + fi + CELIBPATH="${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" + fi + fi + + if test "$GCC" != "yes" ; then + if test "${SHARED_BUILD}" = "0" ; then + runtime=-MT + else + runtime=-MD + fi + + if test "$do64bit" != "no" ; then + # All this magic is necessary for the Win64 SDK RC1 - hobbs + CC="\"${PATH64}/cl.exe\"" + CFLAGS="${CFLAGS} -I\"${MSSDK}/Include\" -I\"${MSSDK}/Include/crt\" -I\"${MSSDK}/Include/crt/sys\"" + RC="\"${MSSDK}/bin/rc.exe\"" + lflags="-nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\"" + LINKBIN="\"${PATH64}/link.exe\"" + CFLAGS_DEBUG="-nologo -Zi -Od -W3 ${runtime}d" + CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}" + # Avoid 'unresolved external symbol __security_cookie' + # errors, c.f. http://support.microsoft.com/?id=894573 + TEA_ADD_LIBS([bufferoverflowU.lib]) + elif test "$doWince" != "no" ; then + CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin" + if test "${TARGETCPU}" = "X86"; then + CC="\"${CEBINROOT}/cl.exe\"" + else + CC="\"${CEBINROOT}/cl${ARCH}.exe\"" + fi + CFLAGS="$CFLAGS -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\"" + RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\"" + arch=`echo ${ARCH} | awk '{print tolower([$]0)}'` + defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _WINDOWS" + if test "${SHARED_BUILD}" = "1" ; then + # Static CE builds require static celib as well + defs="${defs} _DLL" + fi + for i in $defs ; do + AC_DEFINE_UNQUOTED($i, 1, [WinCE def ]$i) + done + AC_DEFINE_UNQUOTED(_WIN32_WCE, $CEVERSION, [_WIN32_WCE version]) + AC_DEFINE_UNQUOTED(UNDER_CE, $CEVERSION, [UNDER_CE version]) + CFLAGS_DEBUG="-nologo -Zi -Od" + CFLAGS_OPTIMIZE="-nologo -Ox" + lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'` + lflags="-MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo" + LINKBIN="\"${CEBINROOT}/link.exe\"" + AC_SUBST(CELIB_DIR) + else + RC="rc" + lflags="-nologo" + LINKBIN="link" + CFLAGS_DEBUG="-nologo -Z7 -Od -W3 -WX ${runtime}d" + CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}" + fi + fi + + if test "$GCC" = "yes"; then + # mingw gcc mode + AC_CHECK_TOOL(RC, windres) + CFLAGS_DEBUG="-g" + CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" + SHLIB_LD='${CC} -shared' + UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' + LDFLAGS_CONSOLE="-wl,--subsystem,console ${lflags}" + LDFLAGS_WINDOW="-wl,--subsystem,windows ${lflags}" + + AC_CACHE_CHECK(for cross-compile version of gcc, + ac_cv_cross, + AC_TRY_COMPILE([ + #ifdef __WIN32__ + #error cross-compiler + #endif + ], [], + ac_cv_cross=yes, + ac_cv_cross=no) + ) + if test "$ac_cv_cross" = "yes"; then + case "$do64bit" in + amd64|x64|yes) + CC="x86_64-w64-mingw32-gcc" + LD="x86_64-w64-mingw32-ld" + AR="x86_64-w64-mingw32-ar" + RANLIB="x86_64-w64-mingw32-ranlib" + RC="x86_64-w64-mingw32-windres" + ;; + *) + CC="i686-w64-mingw32-gcc" + LD="i686-w64-mingw32-ld" + AR="i686-w64-mingw32-ar" + RANLIB="i686-w64-mingw32-ranlib" + RC="i686-w64-mingw32-windres" + ;; + esac + fi + + else + SHLIB_LD="${LINKBIN} -dll ${lflags}" + # link -lib only works when -lib is the first arg + STLIB_LD="${LINKBIN} -lib ${lflags}" + UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.lib' + PATHTYPE=-w + # For information on what debugtype is most useful, see: + # http://msdn.microsoft.com/library/en-us/dnvc60/html/gendepdebug.asp + # and also + # http://msdn2.microsoft.com/en-us/library/y0zzbyt4%28VS.80%29.aspx + # This essentially turns it all on. + LDFLAGS_DEBUG="-debug -debugtype:cv" + LDFLAGS_OPTIMIZE="-release" + if test "$doWince" != "no" ; then + LDFLAGS_CONSOLE="-link ${lflags}" + LDFLAGS_WINDOW=${LDFLAGS_CONSOLE} + else + LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}" + LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}" + fi + fi + + SHLIB_SUFFIX=".dll" + SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.dll' + + TCL_LIB_VERSIONS_OK=nodots + ;; + AIX-*) + AS_IF([test "${TCL_THREADS}" = "1" -a "$GCC" != "yes"], [ + # AIX requires the _r compiler when gcc isn't being used + case "${CC}" in + *_r|*_r\ *) + # ok ... + ;; + *) + # Make sure only first arg gets _r + CC=`echo "$CC" | sed -e 's/^\([[^ ]]*\)/\1_r/'` + ;; + esac + AC_MSG_RESULT([Using $CC for compiling with threads]) + ]) + LIBS="$LIBS -lc" + SHLIB_CFLAGS="" + SHLIB_SUFFIX=".so" + + LD_LIBRARY_PATH_VAR="LIBPATH" + + # Check to enable 64-bit flags for compiler/linker + AS_IF([test "$do64bit" = yes], [ + AS_IF([test "$GCC" = yes], [ + AC_MSG_WARN([64bit mode not supported with GCC on $system]) + ], [ + do64bit_ok=yes + CFLAGS="$CFLAGS -q64" + LDFLAGS_ARCH="-q64" + RANLIB="${RANLIB} -X64" + AR="${AR} -X64" + SHLIB_LD_FLAGS="-b64" + ]) + ]) + + AS_IF([test "`uname -m`" = ia64], [ + # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC + SHLIB_LD="/usr/ccs/bin/ld -G -z text" + AS_IF([test "$GCC" = yes], [ + CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' + ], [ + CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}' + ]) + LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' + ], [ + AS_IF([test "$GCC" = yes], [ + SHLIB_LD='${CC} -shared -Wl,-bexpall' + ], [ + SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bexpall -H512 -T512 -bnoentry" + LDFLAGS="$LDFLAGS -brtl" + ]) + SHLIB_LD="${SHLIB_LD} ${SHLIB_LD_FLAGS}" + CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + ]) + ;; + BeOS*) + SHLIB_CFLAGS="-fPIC" + SHLIB_LD='${CC} -nostart' + SHLIB_SUFFIX=".so" + + #----------------------------------------------------------- + # Check for inet_ntoa in -lbind, for BeOS (which also needs + # -lsocket, even if the network functions are in -lnet which + # is always linked to, for compatibility. + #----------------------------------------------------------- + AC_CHECK_LIB(bind, inet_ntoa, [LIBS="$LIBS -lbind -lsocket"]) + ;; + BSD/OS-4.*) + SHLIB_CFLAGS="-export-dynamic -fPIC" + SHLIB_LD='${CC} -shared' + SHLIB_SUFFIX=".so" + LDFLAGS="$LDFLAGS -export-dynamic" + CC_SEARCH_FLAGS="" + LD_SEARCH_FLAGS="" + ;; + CYGWIN_*) + SHLIB_CFLAGS="" + SHLIB_LD='${CC} -shared' + SHLIB_SUFFIX=".dll" + EXEEXT=".exe" + CC_SEARCH_FLAGS="" + LD_SEARCH_FLAGS="" + ;; + Haiku*) + LDFLAGS="$LDFLAGS -Wl,--export-dynamic" + SHLIB_CFLAGS="-fPIC" + SHLIB_SUFFIX=".so" + SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS}' + AC_CHECK_LIB(network, inet_ntoa, [LIBS="$LIBS -lnetwork"]) + ;; + HP-UX-*.11.*) + # Use updated header definitions where possible + AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, [Do we want to use the XOPEN network library?]) + # TEA specific: Needed by Tcl, but not most extensions + #AC_DEFINE(_XOPEN_SOURCE, 1, [Do we want to use the XOPEN network library?]) + #LIBS="$LIBS -lxnet" # Use the XOPEN network library + + AS_IF([test "`uname -m`" = ia64], [ + SHLIB_SUFFIX=".so" + # Use newer C++ library for C++ extensions + #if test "$GCC" != "yes" ; then + # CPPFLAGS="-AA" + #fi + ], [ + SHLIB_SUFFIX=".sl" + ]) + AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no) + AS_IF([test "$tcl_ok" = yes], [ + LDFLAGS="$LDFLAGS -Wl,-E" + CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.' + LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.' + LD_LIBRARY_PATH_VAR="SHLIB_PATH" + ]) + AS_IF([test "$GCC" = yes], [ + SHLIB_LD='${CC} -shared' + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + ], [ + CFLAGS="$CFLAGS -z" + # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc + #CFLAGS="$CFLAGS +DAportable" + SHLIB_CFLAGS="+z" + SHLIB_LD="ld -b" + ]) + + # Check to enable 64-bit flags for compiler/linker + AS_IF([test "$do64bit" = "yes"], [ + AS_IF([test "$GCC" = yes], [ + case `${CC} -dumpmachine` in + hppa64*) + # 64-bit gcc in use. Fix flags for GNU ld. + do64bit_ok=yes + SHLIB_LD='${CC} -shared' + AS_IF([test $doRpath = yes], [ + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + ;; + *) + AC_MSG_WARN([64bit mode not supported with GCC on $system]) + ;; + esac + ], [ + do64bit_ok=yes + CFLAGS="$CFLAGS +DD64" + LDFLAGS_ARCH="+DD64" + ]) + ]) ;; + IRIX-6.*) + SHLIB_CFLAGS="" + SHLIB_LD="ld -n32 -shared -rdata_shared" + SHLIB_SUFFIX=".so" + AS_IF([test $doRpath = yes], [ + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}']) + AS_IF([test "$GCC" = yes], [ + CFLAGS="$CFLAGS -mabi=n32" + LDFLAGS="$LDFLAGS -mabi=n32" + ], [ + case $system in + IRIX-6.3) + # Use to build 6.2 compatible binaries on 6.3. + CFLAGS="$CFLAGS -n32 -D_OLD_TERMIOS" + ;; + *) + CFLAGS="$CFLAGS -n32" + ;; + esac + LDFLAGS="$LDFLAGS -n32" + ]) + ;; + IRIX64-6.*) + SHLIB_CFLAGS="" + SHLIB_LD="ld -n32 -shared -rdata_shared" + SHLIB_SUFFIX=".so" + AS_IF([test $doRpath = yes], [ + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}']) + + # Check to enable 64-bit flags for compiler/linker + + AS_IF([test "$do64bit" = yes], [ + AS_IF([test "$GCC" = yes], [ + AC_MSG_WARN([64bit mode not supported by gcc]) + ], [ + do64bit_ok=yes + SHLIB_LD="ld -64 -shared -rdata_shared" + CFLAGS="$CFLAGS -64" + LDFLAGS_ARCH="-64" + ]) + ]) + ;; + Linux*|GNU*|NetBSD-Debian) + SHLIB_CFLAGS="-fPIC" + SHLIB_SUFFIX=".so" + + # TEA specific: + CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" + + # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS + SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS_DEFAULT}' + LDFLAGS="$LDFLAGS -Wl,--export-dynamic" + AS_IF([test $doRpath = yes], [ + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + AS_IF([test "`uname -m`" = "alpha"], [CFLAGS="$CFLAGS -mieee"]) + AS_IF([test $do64bit = yes], [ + AC_CACHE_CHECK([if compiler accepts -m64 flag], tcl_cv_cc_m64, [ + hold_cflags=$CFLAGS + CFLAGS="$CFLAGS -m64" + AC_TRY_LINK(,, tcl_cv_cc_m64=yes, tcl_cv_cc_m64=no) + CFLAGS=$hold_cflags]) + AS_IF([test $tcl_cv_cc_m64 = yes], [ + CFLAGS="$CFLAGS -m64" + do64bit_ok=yes + ]) + ]) + + # The combo of gcc + glibc has a bug related to inlining of + # functions like strtod(). The -fno-builtin flag should address + # this problem but it does not work. The -fno-inline flag is kind + # of overkill but it works. Disable inlining only when one of the + # files in compat/*.c is being linked in. + + AS_IF([test x"${USE_COMPAT}" != x],[CFLAGS="$CFLAGS -fno-inline"]) + ;; + Lynx*) + SHLIB_CFLAGS="-fPIC" + SHLIB_SUFFIX=".so" + CFLAGS_OPTIMIZE=-02 + SHLIB_LD='${CC} -shared' + LD_FLAGS="-Wl,--export-dynamic" + AS_IF([test $doRpath = yes], [ + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) + ;; + OpenBSD-*) + arch=`arch -s` + case "$arch" in + vax) + SHLIB_SUFFIX="" + SHARED_LIB_SUFFIX="" + LDFLAGS="" + ;; + *) + SHLIB_CFLAGS="-fPIC" + SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}' + SHLIB_SUFFIX=".so" + AS_IF([test $doRpath = yes], [ + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}' + LDFLAGS="-Wl,-export-dynamic" + ;; + esac + case "$arch" in + vax) + CFLAGS_OPTIMIZE="-O1" + ;; + *) + CFLAGS_OPTIMIZE="-O2" + ;; + esac + AS_IF([test "${TCL_THREADS}" = "1"], [ + # On OpenBSD: Compile with -pthread + # Don't link with -lpthread + LIBS=`echo $LIBS | sed s/-lpthread//` + CFLAGS="$CFLAGS -pthread" + ]) + # OpenBSD doesn't do version numbers with dots. + UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' + TCL_LIB_VERSIONS_OK=nodots + ;; + NetBSD-*) + # NetBSD has ELF and can use 'cc -shared' to build shared libs + SHLIB_CFLAGS="-fPIC" + SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}' + SHLIB_SUFFIX=".so" + LDFLAGS="$LDFLAGS -export-dynamic" + AS_IF([test $doRpath = yes], [ + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + AS_IF([test "${TCL_THREADS}" = "1"], [ + # The -pthread needs to go in the CFLAGS, not LIBS + LIBS=`echo $LIBS | sed s/-pthread//` + CFLAGS="$CFLAGS -pthread" + LDFLAGS="$LDFLAGS -pthread" + ]) + ;; + FreeBSD-*) + # This configuration from FreeBSD Ports. + SHLIB_CFLAGS="-fPIC" + SHLIB_LD="${CC} -shared" + TCL_SHLIB_LD_EXTRAS="-Wl,-soname=\$[@]" + SHLIB_SUFFIX=".so" + LDFLAGS="" + AS_IF([test $doRpath = yes], [ + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) + AS_IF([test "${TCL_THREADS}" = "1"], [ + # The -pthread needs to go in the LDFLAGS, not LIBS + LIBS=`echo $LIBS | sed s/-pthread//` + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LDFLAGS="$LDFLAGS $PTHREAD_LIBS"]) + # Version numbers are dot-stripped by system policy. + TCL_TRIM_DOTS=`echo ${PACKAGE_VERSION} | tr -d .` + UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' + SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1' + TCL_LIB_VERSIONS_OK=nodots + ;; + Darwin-*) + CFLAGS_OPTIMIZE="-Os" + SHLIB_CFLAGS="-fno-common" + # To avoid discrepancies between what headers configure sees during + # preprocessing tests and compiling tests, move any -isysroot and + # -mmacosx-version-min flags from CFLAGS to CPPFLAGS: + CPPFLAGS="${CPPFLAGS} `echo " ${CFLAGS}" | \ + awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \ + if ([$]i~/^(isysroot|mmacosx-version-min)/) print "-"[$]i}'`" + CFLAGS="`echo " ${CFLAGS}" | \ + awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \ + if (!([$]i~/^(isysroot|mmacosx-version-min)/)) print "-"[$]i}'`" + AS_IF([test $do64bit = yes], [ + case `arch` in + ppc) + AC_CACHE_CHECK([if compiler accepts -arch ppc64 flag], + tcl_cv_cc_arch_ppc64, [ + hold_cflags=$CFLAGS + CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5" + AC_TRY_LINK(,, tcl_cv_cc_arch_ppc64=yes, + tcl_cv_cc_arch_ppc64=no) + CFLAGS=$hold_cflags]) + AS_IF([test $tcl_cv_cc_arch_ppc64 = yes], [ + CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5" + do64bit_ok=yes + ]);; + i386) + AC_CACHE_CHECK([if compiler accepts -arch x86_64 flag], + tcl_cv_cc_arch_x86_64, [ + hold_cflags=$CFLAGS + CFLAGS="$CFLAGS -arch x86_64" + AC_TRY_LINK(,, tcl_cv_cc_arch_x86_64=yes, + tcl_cv_cc_arch_x86_64=no) + CFLAGS=$hold_cflags]) + AS_IF([test $tcl_cv_cc_arch_x86_64 = yes], [ + CFLAGS="$CFLAGS -arch x86_64" + do64bit_ok=yes + ]);; + *) + AC_MSG_WARN([Don't know how enable 64-bit on architecture `arch`]);; + esac + ], [ + # Check for combined 32-bit and 64-bit fat build + AS_IF([echo "$CFLAGS " |grep -E -q -- '-arch (ppc64|x86_64) ' \ + && echo "$CFLAGS " |grep -E -q -- '-arch (ppc|i386) '], [ + fat_32_64=yes]) + ]) + # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS + SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS_DEFAULT}' + AC_CACHE_CHECK([if ld accepts -single_module flag], tcl_cv_ld_single_module, [ + hold_ldflags=$LDFLAGS + LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module" + AC_TRY_LINK(, [int i;], tcl_cv_ld_single_module=yes, tcl_cv_ld_single_module=no) + LDFLAGS=$hold_ldflags]) + AS_IF([test $tcl_cv_ld_single_module = yes], [ + SHLIB_LD="${SHLIB_LD} -Wl,-single_module" + ]) + # TEA specific: link shlib with current and compatibility version flags + vers=`echo ${PACKAGE_VERSION} | sed -e 's/^\([[0-9]]\{1,5\}\)\(\(\.[[0-9]]\{1,3\}\)\{0,2\}\).*$/\1\2/p' -e d` + SHLIB_LD="${SHLIB_LD} -current_version ${vers:-0} -compatibility_version ${vers:-0}" + SHLIB_SUFFIX=".dylib" + # Don't use -prebind when building for Mac OS X 10.4 or later only: + AS_IF([test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F '10\\.' '{print int([$]2)}'`" -lt 4 -a \ + "`echo "${CPPFLAGS}" | awk -F '-mmacosx-version-min=10\\.' '{print int([$]2)}'`" -lt 4], [ + LDFLAGS="$LDFLAGS -prebind"]) + LDFLAGS="$LDFLAGS -headerpad_max_install_names" + AC_CACHE_CHECK([if ld accepts -search_paths_first flag], + tcl_cv_ld_search_paths_first, [ + hold_ldflags=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,-search_paths_first" + AC_TRY_LINK(, [int i;], tcl_cv_ld_search_paths_first=yes, + tcl_cv_ld_search_paths_first=no) + LDFLAGS=$hold_ldflags]) + AS_IF([test $tcl_cv_ld_search_paths_first = yes], [ + LDFLAGS="$LDFLAGS -Wl,-search_paths_first" + ]) + AS_IF([test "$tcl_cv_cc_visibility_hidden" != yes], [ + AC_DEFINE(MODULE_SCOPE, [__private_extern__], + [Compiler support for module scope symbols]) + tcl_cv_cc_visibility_hidden=yes + ]) + CC_SEARCH_FLAGS="" + LD_SEARCH_FLAGS="" + LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH" + # TEA specific: for combined 32 & 64 bit fat builds of Tk + # extensions, verify that 64-bit build is possible. + AS_IF([test "$fat_32_64" = yes && test -n "${TK_BIN_DIR}"], [ + AS_IF([test "${TEA_WINDOWINGSYSTEM}" = x11], [ + AC_CACHE_CHECK([for 64-bit X11], tcl_cv_lib_x11_64, [ + for v in CFLAGS CPPFLAGS LDFLAGS; do + eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"' + done + CPPFLAGS="$CPPFLAGS -I/usr/X11R6/include" + LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11" + AC_TRY_LINK([#include ], [XrmInitialize();], + tcl_cv_lib_x11_64=yes, tcl_cv_lib_x11_64=no) + for v in CFLAGS CPPFLAGS LDFLAGS; do + eval $v'="$hold_'$v'"' + done]) + ]) + AS_IF([test "${TEA_WINDOWINGSYSTEM}" = aqua], [ + AC_CACHE_CHECK([for 64-bit Tk], tcl_cv_lib_tk_64, [ + for v in CFLAGS CPPFLAGS LDFLAGS; do + eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"' + done + CPPFLAGS="$CPPFLAGS -DUSE_TCL_STUBS=1 -DUSE_TK_STUBS=1 ${TCL_INCLUDES} ${TK_INCLUDES}" + LDFLAGS="$LDFLAGS ${TCL_STUB_LIB_SPEC} ${TK_STUB_LIB_SPEC}" + AC_TRY_LINK([#include ], [Tk_InitStubs(NULL, "", 0);], + tcl_cv_lib_tk_64=yes, tcl_cv_lib_tk_64=no) + for v in CFLAGS CPPFLAGS LDFLAGS; do + eval $v'="$hold_'$v'"' + done]) + ]) + # remove 64-bit arch flags from CFLAGS et al. if configuration + # does not support 64-bit. + AS_IF([test "$tcl_cv_lib_tk_64" = no -o "$tcl_cv_lib_x11_64" = no], [ + AC_MSG_NOTICE([Removing 64-bit architectures from compiler & linker flags]) + for v in CFLAGS CPPFLAGS LDFLAGS; do + eval $v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"' + done]) + ]) + ;; + OS/390-*) + CFLAGS_OPTIMIZE="" # Optimizer is buggy + AC_DEFINE(_OE_SOCKETS, 1, # needed in sys/socket.h + [Should OS/390 do the right thing with sockets?]) + ;; + OSF1-V*) + # Digital OSF/1 + SHLIB_CFLAGS="" + AS_IF([test "$SHARED_BUILD" = 1], [ + SHLIB_LD='ld -shared -expect_unresolved "*"' + ], [ + SHLIB_LD='ld -non_shared -expect_unresolved "*"' + ]) + SHLIB_SUFFIX=".so" + AS_IF([test $doRpath = yes], [ + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}']) + AS_IF([test "$GCC" = yes], [CFLAGS="$CFLAGS -mieee"], [ + CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee"]) + # see pthread_intro(3) for pthread support on osf1, k.furukawa + AS_IF([test "${TCL_THREADS}" = 1], [ + CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE" + CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64" + LIBS=`echo $LIBS | sed s/-lpthreads//` + AS_IF([test "$GCC" = yes], [ + LIBS="$LIBS -lpthread -lmach -lexc" + ], [ + CFLAGS="$CFLAGS -pthread" + LDFLAGS="$LDFLAGS -pthread" + ]) + ]) + ;; + QNX-6*) + # QNX RTP + # This may work for all QNX, but it was only reported for v6. + SHLIB_CFLAGS="-fPIC" + SHLIB_LD="ld -Bshareable -x" + SHLIB_LD_LIBS="" + SHLIB_SUFFIX=".so" + CC_SEARCH_FLAGS="" + LD_SEARCH_FLAGS="" + ;; + SCO_SV-3.2*) + AS_IF([test "$GCC" = yes], [ + SHLIB_CFLAGS="-fPIC -melf" + LDFLAGS="$LDFLAGS -melf -Wl,-Bexport" + ], [ + SHLIB_CFLAGS="-Kpic -belf" + LDFLAGS="$LDFLAGS -belf -Wl,-Bexport" + ]) + SHLIB_LD="ld -G" + SHLIB_LD_LIBS="" + SHLIB_SUFFIX=".so" + CC_SEARCH_FLAGS="" + LD_SEARCH_FLAGS="" + ;; + SunOS-5.[[0-6]]) + # Careful to not let 5.10+ fall into this case + + # Note: If _REENTRANT isn't defined, then Solaris + # won't define thread-safe library routines. + + AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?]) + AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, + [Do we really want to follow the standard? Yes we do!]) + + SHLIB_CFLAGS="-KPIC" + SHLIB_SUFFIX=".so" + AS_IF([test "$GCC" = yes], [ + SHLIB_LD='${CC} -shared' + CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + ], [ + SHLIB_LD="/usr/ccs/bin/ld -G -z text" + CC_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + ]) + ;; + SunOS-5*) + # Note: If _REENTRANT isn't defined, then Solaris + # won't define thread-safe library routines. + + AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?]) + AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, + [Do we really want to follow the standard? Yes we do!]) + + SHLIB_CFLAGS="-KPIC" + + # Check to enable 64-bit flags for compiler/linker + AS_IF([test "$do64bit" = yes], [ + arch=`isainfo` + AS_IF([test "$arch" = "sparcv9 sparc"], [ + AS_IF([test "$GCC" = yes], [ + AS_IF([test "`${CC} -dumpversion | awk -F. '{print [$]1}'`" -lt 3], [ + AC_MSG_WARN([64bit mode not supported with GCC < 3.2 on $system]) + ], [ + do64bit_ok=yes + CFLAGS="$CFLAGS -m64 -mcpu=v9" + LDFLAGS="$LDFLAGS -m64 -mcpu=v9" + SHLIB_CFLAGS="-fPIC" + ]) + ], [ + do64bit_ok=yes + AS_IF([test "$do64bitVIS" = yes], [ + CFLAGS="$CFLAGS -xarch=v9a" + LDFLAGS_ARCH="-xarch=v9a" + ], [ + CFLAGS="$CFLAGS -xarch=v9" + LDFLAGS_ARCH="-xarch=v9" + ]) + # Solaris 64 uses this as well + #LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH_64" + ]) + ], [AS_IF([test "$arch" = "amd64 i386"], [ + AS_IF([test "$GCC" = yes], [ + case $system in + SunOS-5.1[[1-9]]*|SunOS-5.[[2-9]][[0-9]]*) + do64bit_ok=yes + CFLAGS="$CFLAGS -m64" + LDFLAGS="$LDFLAGS -m64";; + *) + AC_MSG_WARN([64bit mode not supported with GCC on $system]);; + esac + ], [ + do64bit_ok=yes + case $system in + SunOS-5.1[[1-9]]*|SunOS-5.[[2-9]][[0-9]]*) + CFLAGS="$CFLAGS -m64" + LDFLAGS="$LDFLAGS -m64";; + *) + CFLAGS="$CFLAGS -xarch=amd64" + LDFLAGS="$LDFLAGS -xarch=amd64";; + esac + ]) + ], [AC_MSG_WARN([64bit mode not supported for $arch])])]) + ]) + + SHLIB_SUFFIX=".so" + AS_IF([test "$GCC" = yes], [ + SHLIB_LD='${CC} -shared' + CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + AS_IF([test "$do64bit_ok" = yes], [ + AS_IF([test "$arch" = "sparcv9 sparc"], [ + # We need to specify -static-libgcc or we need to + # add the path to the sparv9 libgcc. + # JH: static-libgcc is necessary for core Tcl, but may + # not be necessary for extensions. + SHLIB_LD="$SHLIB_LD -m64 -mcpu=v9 -static-libgcc" + # for finding sparcv9 libgcc, get the regular libgcc + # path, remove so name and append 'sparcv9' + #v9gcclibdir="`gcc -print-file-name=libgcc_s.so` | ..." + #CC_SEARCH_FLAGS="${CC_SEARCH_FLAGS},-R,$v9gcclibdir" + ], [AS_IF([test "$arch" = "amd64 i386"], [ + # JH: static-libgcc is necessary for core Tcl, but may + # not be necessary for extensions. + SHLIB_LD="$SHLIB_LD -m64 -static-libgcc" + ])]) + ]) + ], [ + case $system in + SunOS-5.[[1-9]][[0-9]]*) + # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS + SHLIB_LD='${CC} -G -z text ${LDFLAGS_DEFAULT}';; + *) + SHLIB_LD='/usr/ccs/bin/ld -G -z text';; + esac + CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' + LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' + ]) + ;; + UNIX_SV* | UnixWare-5*) + SHLIB_CFLAGS="-KPIC" + SHLIB_LD='${CC} -G' + SHLIB_LD_LIBS="" + SHLIB_SUFFIX=".so" + # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers + # that don't grok the -Bexport option. Test that it does. + AC_CACHE_CHECK([for ld accepts -Bexport flag], tcl_cv_ld_Bexport, [ + hold_ldflags=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,-Bexport" + AC_TRY_LINK(, [int i;], tcl_cv_ld_Bexport=yes, tcl_cv_ld_Bexport=no) + LDFLAGS=$hold_ldflags]) + AS_IF([test $tcl_cv_ld_Bexport = yes], [ + LDFLAGS="$LDFLAGS -Wl,-Bexport" + ]) + CC_SEARCH_FLAGS="" + LD_SEARCH_FLAGS="" + ;; + esac + + AS_IF([test "$do64bit" = yes -a "$do64bit_ok" = no], [ + AC_MSG_WARN([64bit support being disabled -- don't know magic for this platform]) + ]) + +dnl # Add any CPPFLAGS set in the environment to our CFLAGS, but delay doing so +dnl # until the end of configure, as configure's compile and link tests use +dnl # both CPPFLAGS and CFLAGS (unlike our compile and link) but configure's +dnl # preprocessing tests use only CPPFLAGS. + AC_CONFIG_COMMANDS_PRE([CFLAGS="${CFLAGS} ${CPPFLAGS}"; CPPFLAGS=""]) + + # Add in the arch flags late to ensure it wasn't removed. + # Not necessary in TEA, but this is aligned with core + LDFLAGS="$LDFLAGS $LDFLAGS_ARCH" + + # If we're running gcc, then change the C flags for compiling shared + # libraries to the right flags for gcc, instead of those for the + # standard manufacturer compiler. + + AS_IF([test "$GCC" = yes], [ + case $system in + AIX-*) ;; + BSD/OS*) ;; + CYGWIN_*|MINGW32_*) ;; + IRIX*) ;; + NetBSD-*|FreeBSD-*|OpenBSD-*) ;; + Darwin-*) ;; + SCO_SV-3.2*) ;; + windows) ;; + *) SHLIB_CFLAGS="-fPIC" ;; + esac]) + + AS_IF([test "$tcl_cv_cc_visibility_hidden" != yes], [ + AC_DEFINE(MODULE_SCOPE, [extern], + [No Compiler support for module scope symbols]) + ]) + + AS_IF([test "$SHARED_LIB_SUFFIX" = ""], [ + # TEA specific: use PACKAGE_VERSION instead of VERSION + SHARED_LIB_SUFFIX='${PACKAGE_VERSION}${SHLIB_SUFFIX}']) + AS_IF([test "$UNSHARED_LIB_SUFFIX" = ""], [ + # TEA specific: use PACKAGE_VERSION instead of VERSION + UNSHARED_LIB_SUFFIX='${PACKAGE_VERSION}.a']) + + if test "${GCC}" = "yes" -a ${SHLIB_SUFFIX} = ".dll"; then + AC_CACHE_CHECK(for SEH support in compiler, + tcl_cv_seh, + AC_TRY_RUN([ +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN + + int main(int argc, char** argv) { + int a, b = 0; + __try { + a = 666 / b; + } + __except (EXCEPTION_EXECUTE_HANDLER) { + return 0; + } + return 1; + } + ], + tcl_cv_seh=yes, + tcl_cv_seh=no, + tcl_cv_seh=no) + ) + if test "$tcl_cv_seh" = "no" ; then + AC_DEFINE(HAVE_NO_SEH, 1, + [Defined when mingw does not support SEH]) + fi + + # + # Check to see if the excpt.h include file provided contains the + # definition for EXCEPTION_DISPOSITION; if not, which is the case + # with Cygwin's version as of 2002-04-10, define it to be int, + # sufficient for getting the current code to work. + # + AC_CACHE_CHECK(for EXCEPTION_DISPOSITION support in include files, + tcl_cv_eh_disposition, + AC_TRY_COMPILE([ +# define WIN32_LEAN_AND_MEAN +# include +# undef WIN32_LEAN_AND_MEAN + ],[ + EXCEPTION_DISPOSITION x; + ], + tcl_cv_eh_disposition=yes, + tcl_cv_eh_disposition=no) + ) + if test "$tcl_cv_eh_disposition" = "no" ; then + AC_DEFINE(EXCEPTION_DISPOSITION, int, + [Defined when cygwin/mingw does not support EXCEPTION DISPOSITION]) + fi + + # Check to see if winnt.h defines CHAR, SHORT, and LONG + # even if VOID has already been #defined. The win32api + # used by mingw and cygwin is known to do this. + + AC_CACHE_CHECK(for winnt.h that ignores VOID define, + tcl_cv_winnt_ignore_void, + AC_TRY_COMPILE([ +#define VOID void +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN + ], [ + CHAR c; + SHORT s; + LONG l; + ], + tcl_cv_winnt_ignore_void=yes, + tcl_cv_winnt_ignore_void=no) + ) + if test "$tcl_cv_winnt_ignore_void" = "yes" ; then + AC_DEFINE(HAVE_WINNT_IGNORE_VOID, 1, + [Defined when cygwin/mingw ignores VOID define in winnt.h]) + fi + fi + + # See if the compiler supports casting to a union type. + # This is used to stop gcc from printing a compiler + # warning when initializing a union member. + + AC_CACHE_CHECK(for cast to union support, + tcl_cv_cast_to_union, + AC_TRY_COMPILE([], + [ + union foo { int i; double d; }; + union foo f = (union foo) (int) 0; + ], + tcl_cv_cast_to_union=yes, + tcl_cv_cast_to_union=no) + ) + if test "$tcl_cv_cast_to_union" = "yes"; then + AC_DEFINE(HAVE_CAST_TO_UNION, 1, + [Defined when compiler supports casting to union type.]) + fi + + AC_SUBST(CFLAGS_DEBUG) + AC_SUBST(CFLAGS_OPTIMIZE) + AC_SUBST(CFLAGS_WARNING) + + AC_SUBST(STLIB_LD) + AC_SUBST(SHLIB_LD) + + AC_SUBST(SHLIB_LD_LIBS) + AC_SUBST(SHLIB_CFLAGS) + + AC_SUBST(LD_LIBRARY_PATH_VAR) + + # These must be called after we do the basic CFLAGS checks and + # verify any possible 64-bit or similar switches are necessary + TEA_TCL_EARLY_FLAGS + TEA_TCL_64BIT_FLAGS +]) + +#-------------------------------------------------------------------- +# TEA_SERIAL_PORT +# +# Determine which interface to use to talk to the serial port. +# Note that #include lines must begin in leftmost column for +# some compilers to recognize them as preprocessor directives, +# and some build environments have stdin not pointing at a +# pseudo-terminal (usually /dev/null instead.) +# +# Arguments: +# none +# +# Results: +# +# Defines only one of the following vars: +# HAVE_SYS_MODEM_H +# USE_TERMIOS +# USE_TERMIO +# USE_SGTTY +#-------------------------------------------------------------------- + +AC_DEFUN([TEA_SERIAL_PORT], [ + AC_CHECK_HEADERS(sys/modem.h) + AC_CACHE_CHECK([termios vs. termio vs. sgtty], tcl_cv_api_serial, [ + AC_TRY_RUN([ +#include + +int main() { + struct termios t; + if (tcgetattr(0, &t) == 0) { + cfsetospeed(&t, 0); + t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB; + return 0; + } + return 1; +}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no) + if test $tcl_cv_api_serial = no ; then + AC_TRY_RUN([ +#include + +int main() { + struct termio t; + if (ioctl(0, TCGETA, &t) == 0) { + t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB; + return 0; + } + return 1; +}], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no) + fi + if test $tcl_cv_api_serial = no ; then + AC_TRY_RUN([ +#include + +int main() { + struct sgttyb t; + if (ioctl(0, TIOCGETP, &t) == 0) { + t.sg_ospeed = 0; + t.sg_flags |= ODDP | EVENP | RAW; + return 0; + } + return 1; +}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=no, tcl_cv_api_serial=no) + fi + if test $tcl_cv_api_serial = no ; then + AC_TRY_RUN([ +#include +#include + +int main() { + struct termios t; + if (tcgetattr(0, &t) == 0 + || errno == ENOTTY || errno == ENXIO || errno == EINVAL) { + cfsetospeed(&t, 0); + t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB; + return 0; + } + return 1; +}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no) + fi + if test $tcl_cv_api_serial = no; then + AC_TRY_RUN([ +#include +#include + +int main() { + struct termio t; + if (ioctl(0, TCGETA, &t) == 0 + || errno == ENOTTY || errno == ENXIO || errno == EINVAL) { + t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB; + return 0; + } + return 1; + }], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no) + fi + if test $tcl_cv_api_serial = no; then + AC_TRY_RUN([ +#include +#include + +int main() { + struct sgttyb t; + if (ioctl(0, TIOCGETP, &t) == 0 + || errno == ENOTTY || errno == ENXIO || errno == EINVAL) { + t.sg_ospeed = 0; + t.sg_flags |= ODDP | EVENP | RAW; + return 0; + } + return 1; +}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none) + fi]) + case $tcl_cv_api_serial in + termios) AC_DEFINE(USE_TERMIOS, 1, [Use the termios API for serial lines]);; + termio) AC_DEFINE(USE_TERMIO, 1, [Use the termio API for serial lines]);; + sgtty) AC_DEFINE(USE_SGTTY, 1, [Use the sgtty API for serial lines]);; + esac +]) + +#-------------------------------------------------------------------- +# TEA_MISSING_POSIX_HEADERS +# +# Supply substitutes for missing POSIX header files. Special +# notes: +# - stdlib.h doesn't define strtol, strtoul, or +# strtod in some versions of SunOS +# - some versions of string.h don't declare procedures such +# as strstr +# +# Arguments: +# none +# +# Results: +# +# Defines some of the following vars: +# NO_DIRENT_H +# NO_ERRNO_H +# NO_VALUES_H +# HAVE_LIMITS_H or NO_LIMITS_H +# NO_STDLIB_H +# NO_STRING_H +# NO_SYS_WAIT_H +# NO_DLFCN_H +# HAVE_SYS_PARAM_H +# +# HAVE_STRING_H ? +# +# tkUnixPort.h checks for HAVE_LIMITS_H, so do both HAVE and +# CHECK on limits.h +#-------------------------------------------------------------------- + +AC_DEFUN([TEA_MISSING_POSIX_HEADERS], [ + AC_CACHE_CHECK([dirent.h], tcl_cv_dirent_h, [ + AC_TRY_LINK([#include +#include ], [ +#ifndef _POSIX_SOURCE +# ifdef __Lynx__ + /* + * Generate compilation error to make the test fail: Lynx headers + * are only valid if really in the POSIX environment. + */ + + missing_procedure(); +# endif +#endif +DIR *d; +struct dirent *entryPtr; +char *p; +d = opendir("foobar"); +entryPtr = readdir(d); +p = entryPtr->d_name; +closedir(d); +], tcl_cv_dirent_h=yes, tcl_cv_dirent_h=no)]) + + if test $tcl_cv_dirent_h = no; then + AC_DEFINE(NO_DIRENT_H, 1, [Do we have ?]) + fi + + # TEA specific: + AC_CHECK_HEADER(errno.h, , [AC_DEFINE(NO_ERRNO_H, 1, [Do we have ?])]) + AC_CHECK_HEADER(float.h, , [AC_DEFINE(NO_FLOAT_H, 1, [Do we have ?])]) + AC_CHECK_HEADER(values.h, , [AC_DEFINE(NO_VALUES_H, 1, [Do we have ?])]) + AC_CHECK_HEADER(limits.h, + [AC_DEFINE(HAVE_LIMITS_H, 1, [Do we have ?])], + [AC_DEFINE(NO_LIMITS_H, 1, [Do we have ?])]) + AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0) + AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0) + AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0) + AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0) + if test $tcl_ok = 0; then + AC_DEFINE(NO_STDLIB_H, 1, [Do we have ?]) + fi + AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0) + AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0) + AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0) + + # See also memmove check below for a place where NO_STRING_H can be + # set and why. + + if test $tcl_ok = 0; then + AC_DEFINE(NO_STRING_H, 1, [Do we have ?]) + fi + + AC_CHECK_HEADER(sys/wait.h, , [AC_DEFINE(NO_SYS_WAIT_H, 1, [Do we have ?])]) + AC_CHECK_HEADER(dlfcn.h, , [AC_DEFINE(NO_DLFCN_H, 1, [Do we have ?])]) + + # OS/390 lacks sys/param.h (and doesn't need it, by chance). + AC_HAVE_HEADERS(sys/param.h) +]) + +#-------------------------------------------------------------------- +# TEA_PATH_X +# +# Locate the X11 header files and the X11 library archive. Try +# the ac_path_x macro first, but if it doesn't find the X stuff +# (e.g. because there's no xmkmf program) then check through +# a list of possible directories. Under some conditions the +# autoconf macro will return an include directory that contains +# no include files, so double-check its result just to be safe. +# +# This should be called after TEA_CONFIG_CFLAGS as setting the +# LIBS line can confuse some configure macro magic. +# +# Arguments: +# none +# +# Results: +# +# Sets the following vars: +# XINCLUDES +# XLIBSW +# PKG_LIBS (appends to) +#-------------------------------------------------------------------- + +AC_DEFUN([TEA_PATH_X], [ + if test "${TEA_WINDOWINGSYSTEM}" = "x11" ; then + TEA_PATH_UNIX_X + fi +]) + +AC_DEFUN([TEA_PATH_UNIX_X], [ + AC_PATH_X + not_really_there="" + if test "$no_x" = ""; then + if test "$x_includes" = ""; then + AC_TRY_CPP([#include ], , not_really_there="yes") + else + if test ! -r $x_includes/X11/Xlib.h; then + not_really_there="yes" + fi + fi + fi + if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then + AC_MSG_CHECKING([for X11 header files]) + found_xincludes="no" + AC_TRY_CPP([#include ], found_xincludes="yes", found_xincludes="no") + if test "$found_xincludes" = "no"; then + dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/X11R6/include /usr/X11R5/include /usr/include/X11R5 /usr/include/X11R4 /usr/openwin/include /usr/X11/include /usr/sww/include" + for i in $dirs ; do + if test -r $i/X11/Xlib.h; then + AC_MSG_RESULT([$i]) + XINCLUDES=" -I$i" + found_xincludes="yes" + break + fi + done + fi + else + if test "$x_includes" != ""; then + XINCLUDES="-I$x_includes" + found_xincludes="yes" + fi + fi + if test "$found_xincludes" = "no"; then + AC_MSG_RESULT([couldn't find any!]) + fi + + if test "$no_x" = yes; then + AC_MSG_CHECKING([for X11 libraries]) + XLIBSW=nope + dirs="/usr/unsupported/lib /usr/local/lib /usr/X386/lib /usr/X11R6/lib /usr/X11R5/lib /usr/lib/X11R5 /usr/lib/X11R4 /usr/openwin/lib /usr/X11/lib /usr/sww/X11/lib" + for i in $dirs ; do + if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl -o -r $i/libX11.dylib; then + AC_MSG_RESULT([$i]) + XLIBSW="-L$i -lX11" + x_libraries="$i" + break + fi + done + else + if test "$x_libraries" = ""; then + XLIBSW=-lX11 + else + XLIBSW="-L$x_libraries -lX11" + fi + fi + if test "$XLIBSW" = nope ; then + AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow) + fi + if test "$XLIBSW" = nope ; then + AC_MSG_RESULT([could not find any! Using -lX11.]) + XLIBSW=-lX11 + fi + # TEA specific: + if test x"${XLIBSW}" != x ; then + PKG_LIBS="${PKG_LIBS} ${XLIBSW}" + fi +]) + +#-------------------------------------------------------------------- +# TEA_BLOCKING_STYLE +# +# The statements below check for systems where POSIX-style +# non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented. +# On these systems (mostly older ones), use the old BSD-style +# FIONBIO approach instead. +# +# Arguments: +# none +# +# Results: +# +# Defines some of the following vars: +# HAVE_SYS_IOCTL_H +# HAVE_SYS_FILIO_H +# USE_FIONBIO +# O_NONBLOCK +#-------------------------------------------------------------------- + +AC_DEFUN([TEA_BLOCKING_STYLE], [ + AC_CHECK_HEADERS(sys/ioctl.h) + AC_CHECK_HEADERS(sys/filio.h) + TEA_CONFIG_SYSTEM + AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O]) + case $system in + OSF*) + AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?]) + AC_MSG_RESULT([FIONBIO]) + ;; + *) + AC_MSG_RESULT([O_NONBLOCK]) + ;; + esac +]) + +#-------------------------------------------------------------------- +# TEA_TIME_HANDLER +# +# Checks how the system deals with time.h, what time structures +# are used on the system, and what fields the structures have. +# +# Arguments: +# none +# +# Results: +# +# Defines some of the following vars: +# USE_DELTA_FOR_TZ +# HAVE_TM_GMTOFF +# HAVE_TM_TZADJ +# HAVE_TIMEZONE_VAR +#-------------------------------------------------------------------- + +AC_DEFUN([TEA_TIME_HANDLER], [ + AC_CHECK_HEADERS(sys/time.h) + AC_HEADER_TIME + AC_STRUCT_TIMEZONE + + AC_CHECK_FUNCS(gmtime_r localtime_r) + + AC_CACHE_CHECK([tm_tzadj in struct tm], tcl_cv_member_tm_tzadj, [ + AC_TRY_COMPILE([#include ], [struct tm tm; tm.tm_tzadj;], + tcl_cv_member_tm_tzadj=yes, tcl_cv_member_tm_tzadj=no)]) + if test $tcl_cv_member_tm_tzadj = yes ; then + AC_DEFINE(HAVE_TM_TZADJ, 1, [Should we use the tm_tzadj field of struct tm?]) + fi + + AC_CACHE_CHECK([tm_gmtoff in struct tm], tcl_cv_member_tm_gmtoff, [ + AC_TRY_COMPILE([#include ], [struct tm tm; tm.tm_gmtoff;], + tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no)]) + if test $tcl_cv_member_tm_gmtoff = yes ; then + AC_DEFINE(HAVE_TM_GMTOFF, 1, [Should we use the tm_gmtoff field of struct tm?]) + fi + + # + # Its important to include time.h in this check, as some systems + # (like convex) have timezone functions, etc. + # + AC_CACHE_CHECK([long timezone variable], tcl_cv_timezone_long, [ + AC_TRY_COMPILE([#include ], + [extern long timezone; + timezone += 1; + exit (0);], + tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no)]) + if test $tcl_cv_timezone_long = yes ; then + AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?]) + else + # + # On some systems (eg IRIX 6.2), timezone is a time_t and not a long. + # + AC_CACHE_CHECK([time_t timezone variable], tcl_cv_timezone_time, [ + AC_TRY_COMPILE([#include ], + [extern time_t timezone; + timezone += 1; + exit (0);], + tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no)]) + if test $tcl_cv_timezone_time = yes ; then + AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?]) + fi + fi +]) + +#-------------------------------------------------------------------- +# TEA_BUGGY_STRTOD +# +# Under Solaris 2.4, strtod returns the wrong value for the +# terminating character under some conditions. Check for this +# and if the problem exists use a substitute procedure +# "fixstrtod" (provided by Tcl) that corrects the error. +# Also, on Compaq's Tru64 Unix 5.0, +# strtod(" ") returns 0.0 instead of a failure to convert. +# +# Arguments: +# none +# +# Results: +# +# Might defines some of the following vars: +# strtod (=fixstrtod) +#-------------------------------------------------------------------- + +AC_DEFUN([TEA_BUGGY_STRTOD], [ + AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0) + if test "$tcl_strtod" = 1; then + AC_CACHE_CHECK([for Solaris2.4/Tru64 strtod bugs], tcl_cv_strtod_buggy,[ + AC_TRY_RUN([ + extern double strtod(); + int main() { + char *infString="Inf", *nanString="NaN", *spaceString=" "; + char *term; + double value; + value = strtod(infString, &term); + if ((term != infString) && (term[-1] == 0)) { + exit(1); + } + value = strtod(nanString, &term); + if ((term != nanString) && (term[-1] == 0)) { + exit(1); + } + value = strtod(spaceString, &term); + if (term == (spaceString+1)) { + exit(1); + } + exit(0); + }], tcl_cv_strtod_buggy=ok, tcl_cv_strtod_buggy=buggy, + tcl_cv_strtod_buggy=buggy)]) + if test "$tcl_cv_strtod_buggy" = buggy; then + AC_LIBOBJ([fixstrtod]) + USE_COMPAT=1 + AC_DEFINE(strtod, fixstrtod, [Do we want to use the strtod() in compat?]) + fi + fi +]) + +#-------------------------------------------------------------------- +# TEA_TCL_LINK_LIBS +# +# Search for the libraries needed to link the Tcl shell. +# Things like the math library (-lm) and socket stuff (-lsocket vs. +# -lnsl) are dealt with here. +# +# Arguments: +# Requires the following vars to be set in the Makefile: +# DL_LIBS (not in TEA, only needed in core) +# LIBS +# MATH_LIBS +# +# Results: +# +# Substitutes the following vars: +# TCL_LIBS +# MATH_LIBS +# +# Might append to the following vars: +# LIBS +# +# Might define the following vars: +# HAVE_NET_ERRNO_H +#-------------------------------------------------------------------- + +AC_DEFUN([TEA_TCL_LINK_LIBS], [ + #-------------------------------------------------------------------- + # On a few very rare systems, all of the libm.a stuff is + # already in libc.a. Set compiler flags accordingly. + # Also, Linux requires the "ieee" library for math to work + # right (and it must appear before "-lm"). + #-------------------------------------------------------------------- + + AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm") + AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"]) + + #-------------------------------------------------------------------- + # Interactive UNIX requires -linet instead of -lsocket, plus it + # needs net/errno.h to define the socket-related error codes. + #-------------------------------------------------------------------- + + AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"]) + AC_CHECK_HEADER(net/errno.h, [ + AC_DEFINE(HAVE_NET_ERRNO_H, 1, [Do we have ?])]) + + #-------------------------------------------------------------------- + # Check for the existence of the -lsocket and -lnsl libraries. + # The order here is important, so that they end up in the right + # order in the command line generated by make. Here are some + # special considerations: + # 1. Use "connect" and "accept" to check for -lsocket, and + # "gethostbyname" to check for -lnsl. + # 2. Use each function name only once: can't redo a check because + # autoconf caches the results of the last check and won't redo it. + # 3. Use -lnsl and -lsocket only if they supply procedures that + # aren't already present in the normal libraries. This is because + # IRIX 5.2 has libraries, but they aren't needed and they're + # bogus: they goof up name resolution if used. + # 4. On some SVR4 systems, can't use -lsocket without -lnsl too. + # To get around this problem, check for both libraries together + # if -lsocket doesn't work by itself. + #-------------------------------------------------------------------- + + tcl_checkBoth=0 + AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1) + if test "$tcl_checkSocket" = 1; then + AC_CHECK_FUNC(setsockopt, , [AC_CHECK_LIB(socket, setsockopt, + LIBS="$LIBS -lsocket", tcl_checkBoth=1)]) + fi + if test "$tcl_checkBoth" = 1; then + tk_oldLibs=$LIBS + LIBS="$LIBS -lsocket -lnsl" + AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs]) + fi + AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname, + [LIBS="$LIBS -lnsl"])]) + + # TEA specific: Don't perform the eval of the libraries here because + # DL_LIBS won't be set until we call TEA_CONFIG_CFLAGS + + TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}' + AC_SUBST(TCL_LIBS) + AC_SUBST(MATH_LIBS) +]) + +#-------------------------------------------------------------------- +# TEA_TCL_EARLY_FLAGS +# +# Check for what flags are needed to be passed so the correct OS +# features are available. +# +# Arguments: +# None +# +# Results: +# +# Might define the following vars: +# _ISOC99_SOURCE +# _LARGEFILE64_SOURCE +# _LARGEFILE_SOURCE64 +#-------------------------------------------------------------------- + +AC_DEFUN([TEA_TCL_EARLY_FLAG],[ + AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]), + AC_TRY_COMPILE([$2], $3, [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no, + AC_TRY_COMPILE([[#define ]$1[ 1 +]$2], $3, + [tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes, + [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no))) + if test ["x${tcl_cv_flag_]translit($1,[A-Z],[a-z])[}" = "xyes"] ; then + AC_DEFINE($1, 1, [Add the ]$1[ flag when building]) + tcl_flags="$tcl_flags $1" + fi +]) + +AC_DEFUN([TEA_TCL_EARLY_FLAGS],[ + AC_MSG_CHECKING([for required early compiler flags]) + tcl_flags="" + TEA_TCL_EARLY_FLAG(_ISOC99_SOURCE,[#include ], + [char *p = (char *)strtoll; char *q = (char *)strtoull;]) + TEA_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include ], + [struct stat64 buf; int i = stat64("/", &buf);]) + TEA_TCL_EARLY_FLAG(_LARGEFILE_SOURCE64,[#include ], + [char *p = (char *)open64;]) + if test "x${tcl_flags}" = "x" ; then + AC_MSG_RESULT([none]) + else + AC_MSG_RESULT([${tcl_flags}]) + fi +]) + +#-------------------------------------------------------------------- +# TEA_TCL_64BIT_FLAGS +# +# Check for what is defined in the way of 64-bit features. +# +# Arguments: +# None +# +# Results: +# +# Might define the following vars: +# TCL_WIDE_INT_IS_LONG +# TCL_WIDE_INT_TYPE +# HAVE_STRUCT_DIRENT64 +# HAVE_STRUCT_STAT64 +# HAVE_TYPE_OFF64_T +#-------------------------------------------------------------------- + +AC_DEFUN([TEA_TCL_64BIT_FLAGS], [ + AC_MSG_CHECKING([for 64-bit integer type]) + AC_CACHE_VAL(tcl_cv_type_64bit,[ + tcl_cv_type_64bit=none + # See if the compiler knows natively about __int64 + AC_TRY_COMPILE(,[__int64 value = (__int64) 0;], + tcl_type_64bit=__int64, tcl_type_64bit="long long") + # See if we should use long anyway Note that we substitute in the + # type that is our current guess for a 64-bit type inside this check + # program, so it should be modified only carefully... + AC_TRY_COMPILE(,[switch (0) { + case 1: case (sizeof(]${tcl_type_64bit}[)==sizeof(long)): ; + }],tcl_cv_type_64bit=${tcl_type_64bit})]) + if test "${tcl_cv_type_64bit}" = none ; then + AC_DEFINE(TCL_WIDE_INT_IS_LONG, 1, [Are wide integers to be implemented with C 'long's?]) + AC_MSG_RESULT([using long]) + elif test "${tcl_cv_type_64bit}" = "__int64" \ + -a "${TEA_PLATFORM}" = "windows" ; then + # TEA specific: We actually want to use the default tcl.h checks in + # this case to handle both TCL_WIDE_INT_TYPE and TCL_LL_MODIFIER* + AC_MSG_RESULT([using Tcl header defaults]) + else + AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit}, + [What type should be used to define wide integers?]) + AC_MSG_RESULT([${tcl_cv_type_64bit}]) + + # Now check for auxiliary declarations + AC_CACHE_CHECK([for struct dirent64], tcl_cv_struct_dirent64,[ + AC_TRY_COMPILE([#include +#include ],[struct dirent64 p;], + tcl_cv_struct_dirent64=yes,tcl_cv_struct_dirent64=no)]) + if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then + AC_DEFINE(HAVE_STRUCT_DIRENT64, 1, [Is 'struct dirent64' in ?]) + fi + + AC_CACHE_CHECK([for struct stat64], tcl_cv_struct_stat64,[ + AC_TRY_COMPILE([#include ],[struct stat64 p; +], + tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)]) + if test "x${tcl_cv_struct_stat64}" = "xyes" ; then + AC_DEFINE(HAVE_STRUCT_STAT64, 1, [Is 'struct stat64' in ?]) + fi + + AC_CHECK_FUNCS(open64 lseek64) + AC_MSG_CHECKING([for off64_t]) + AC_CACHE_VAL(tcl_cv_type_off64_t,[ + AC_TRY_COMPILE([#include ],[off64_t offset; +], + tcl_cv_type_off64_t=yes,tcl_cv_type_off64_t=no)]) + dnl Define HAVE_TYPE_OFF64_T only when the off64_t type and the + dnl functions lseek64 and open64 are defined. + if test "x${tcl_cv_type_off64_t}" = "xyes" && \ + test "x${ac_cv_func_lseek64}" = "xyes" && \ + test "x${ac_cv_func_open64}" = "xyes" ; then + AC_DEFINE(HAVE_TYPE_OFF64_T, 1, [Is off64_t in ?]) + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + fi +]) + +## +## Here ends the standard Tcl configuration bits and starts the +## TEA specific functions +## + +#------------------------------------------------------------------------ +# TEA_INIT -- +# +# Init various Tcl Extension Architecture (TEA) variables. +# This should be the first called TEA_* macro. +# +# Arguments: +# none +# +# Results: +# +# Defines and substs the following vars: +# CYGPATH +# EXEEXT +# Defines only: +# TEA_VERSION +# TEA_INITED +# TEA_PLATFORM (windows or unix) +# +# "cygpath" is used on windows to generate native path names for include +# files. These variables should only be used with the compiler and linker +# since they generate native path names. +# +# EXEEXT +# Select the executable extension based on the host type. This +# is a lightweight replacement for AC_EXEEXT that doesn't require +# a compiler. +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_INIT], [ + # TEA extensions pass this us the version of TEA they think they + # are compatible with. + TEA_VERSION="3.9" + + AC_MSG_CHECKING([for correct TEA configuration]) + if test x"${PACKAGE_NAME}" = x ; then + AC_MSG_ERROR([ +The PACKAGE_NAME variable must be defined by your TEA configure.in]) + fi + if test x"$1" = x ; then + AC_MSG_ERROR([ +TEA version not specified.]) + elif test "$1" != "${TEA_VERSION}" ; then + AC_MSG_RESULT([warning: requested TEA version "$1", have "${TEA_VERSION}"]) + else + AC_MSG_RESULT([ok (TEA ${TEA_VERSION})]) + fi + + # If the user did not set CFLAGS, set it now to keep macros + # like AC_PROG_CC and AC_TRY_COMPILE from adding "-g -O2". + if test "${CFLAGS+set}" != "set" ; then + CFLAGS="" + fi + + case "`uname -s`" in + *win32*|*WIN32*|*MINGW32_*) + AC_CHECK_PROG(CYGPATH, cygpath, cygpath -w, echo) + EXEEXT=".exe" + TEA_PLATFORM="windows" + ;; + *CYGWIN_*) + CYGPATH=echo + EXEEXT=".exe" + # TEA_PLATFORM is determined later in LOAD_TCLCONFIG + ;; + *) + CYGPATH=echo + # Maybe we are cross-compiling.... + case ${host_alias} in + *mingw32*) + EXEEXT=".exe" + TEA_PLATFORM="windows" + ;; + *) + EXEEXT="" + TEA_PLATFORM="unix" + ;; + esac + ;; + esac + + # Check if exec_prefix is set. If not use fall back to prefix. + # Note when adjusted, so that TEA_PREFIX can correct for this. + # This is needed for recursive configures, since autoconf propagates + # $prefix, but not $exec_prefix (doh!). + if test x$exec_prefix = xNONE ; then + exec_prefix_default=yes + exec_prefix=$prefix + fi + + AC_MSG_NOTICE([configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}]) + + AC_SUBST(EXEEXT) + AC_SUBST(CYGPATH) + + # This package name must be replaced statically for AC_SUBST to work + AC_SUBST(PKG_LIB_FILE) + # Substitute STUB_LIB_FILE in case package creates a stub library too. + AC_SUBST(PKG_STUB_LIB_FILE) + + # We AC_SUBST these here to ensure they are subst'ed, + # in case the user doesn't call TEA_ADD_... + AC_SUBST(PKG_STUB_SOURCES) + AC_SUBST(PKG_STUB_OBJECTS) + AC_SUBST(PKG_TCL_SOURCES) + AC_SUBST(PKG_HEADERS) + AC_SUBST(PKG_INCLUDES) + AC_SUBST(PKG_LIBS) + AC_SUBST(PKG_CFLAGS) +]) + +#------------------------------------------------------------------------ +# TEA_ADD_SOURCES -- +# +# Specify one or more source files. Users should check for +# the right platform before adding to their list. +# It is not important to specify the directory, as long as it is +# in the generic, win or unix subdirectory of $(srcdir). +# +# Arguments: +# one or more file names +# +# Results: +# +# Defines and substs the following vars: +# PKG_SOURCES +# PKG_OBJECTS +#------------------------------------------------------------------------ +AC_DEFUN([TEA_ADD_SOURCES], [ + vars="$@" + for i in $vars; do + case $i in + [\$]*) + # allow $-var names + PKG_SOURCES="$PKG_SOURCES $i" + PKG_OBJECTS="$PKG_OBJECTS $i" + ;; + *) + # check for existence - allows for generic/win/unix VPATH + # To add more dirs here (like 'src'), you have to update VPATH + # in Makefile.in as well + if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \ + -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \ + -a ! -f "${srcdir}/macosx/$i" \ + ; then + AC_MSG_ERROR([could not find source file '$i']) + fi + PKG_SOURCES="$PKG_SOURCES $i" + # this assumes it is in a VPATH dir +# i=`basename $i` + # handle user calling this before or after TEA_SETUP_COMPILER + if test x"${OBJEXT}" != x ; then + j="`echo $i | sed -e 's/\.[[^.]]*$//'`.${OBJEXT}" + else + j="`echo $i | sed -e 's/\.[[^.]]*$//'`.\${OBJEXT}" + fi + PKG_OBJECTS="$PKG_OBJECTS $j" + ;; + esac + done + AC_SUBST(PKG_SOURCES) + AC_SUBST(PKG_OBJECTS) +]) + +#------------------------------------------------------------------------ +# TEA_ADD_STUB_SOURCES -- +# +# Specify one or more source files. Users should check for +# the right platform before adding to their list. +# It is not important to specify the directory, as long as it is +# in the generic, win or unix subdirectory of $(srcdir). +# +# Arguments: +# one or more file names +# +# Results: +# +# Defines and substs the following vars: +# PKG_STUB_SOURCES +# PKG_STUB_OBJECTS +#------------------------------------------------------------------------ +AC_DEFUN([TEA_ADD_STUB_SOURCES], [ + vars="$@" + for i in $vars; do + # check for existence - allows for generic/win/unix VPATH + if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \ + -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \ + -a ! -f "${srcdir}/macosx/$i" \ + ; then + AC_MSG_ERROR([could not find stub source file '$i']) + fi + PKG_STUB_SOURCES="$PKG_STUB_SOURCES $i" + # this assumes it is in a VPATH dir + i=`basename $i` + # handle user calling this before or after TEA_SETUP_COMPILER + if test x"${OBJEXT}" != x ; then + j="`echo $i | sed -e 's/\.[[^.]]*$//'`.${OBJEXT}" + else + j="`echo $i | sed -e 's/\.[[^.]]*$//'`.\${OBJEXT}" + fi + PKG_STUB_OBJECTS="$PKG_STUB_OBJECTS $j" + done + AC_SUBST(PKG_STUB_SOURCES) + AC_SUBST(PKG_STUB_OBJECTS) +]) + +#------------------------------------------------------------------------ +# TEA_ADD_TCL_SOURCES -- +# +# Specify one or more Tcl source files. These should be platform +# independent runtime files. +# +# Arguments: +# one or more file names +# +# Results: +# +# Defines and substs the following vars: +# PKG_TCL_SOURCES +#------------------------------------------------------------------------ +AC_DEFUN([TEA_ADD_TCL_SOURCES], [ + vars="$@" + for i in $vars; do + # check for existence, be strict because it is installed + if test ! -f "${srcdir}/$i" ; then + AC_MSG_ERROR([could not find tcl source file '${srcdir}/$i']) + fi + PKG_TCL_SOURCES="$PKG_TCL_SOURCES $i" + done + AC_SUBST(PKG_TCL_SOURCES) +]) + +#------------------------------------------------------------------------ +# TEA_ADD_HEADERS -- +# +# Specify one or more source headers. Users should check for +# the right platform before adding to their list. +# +# Arguments: +# one or more file names +# +# Results: +# +# Defines and substs the following vars: +# PKG_HEADERS +#------------------------------------------------------------------------ +AC_DEFUN([TEA_ADD_HEADERS], [ + vars="$@" + for i in $vars; do + # check for existence, be strict because it is installed + if test ! -f "${srcdir}/$i" ; then + AC_MSG_ERROR([could not find header file '${srcdir}/$i']) + fi + PKG_HEADERS="$PKG_HEADERS $i" + done + AC_SUBST(PKG_HEADERS) +]) + +#------------------------------------------------------------------------ +# TEA_ADD_INCLUDES -- +# +# Specify one or more include dirs. Users should check for +# the right platform before adding to their list. +# +# Arguments: +# one or more file names +# +# Results: +# +# Defines and substs the following vars: +# PKG_INCLUDES +#------------------------------------------------------------------------ +AC_DEFUN([TEA_ADD_INCLUDES], [ + vars="$@" + for i in $vars; do + PKG_INCLUDES="$PKG_INCLUDES $i" + done + AC_SUBST(PKG_INCLUDES) +]) + +#------------------------------------------------------------------------ +# TEA_ADD_LIBS -- +# +# Specify one or more libraries. Users should check for +# the right platform before adding to their list. For Windows, +# libraries provided in "foo.lib" format will be converted to +# "-lfoo" when using GCC (mingw). +# +# Arguments: +# one or more file names +# +# Results: +# +# Defines and substs the following vars: +# PKG_LIBS +#------------------------------------------------------------------------ +AC_DEFUN([TEA_ADD_LIBS], [ + vars="$@" + for i in $vars; do + if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then + # Convert foo.lib to -lfoo for GCC. No-op if not *.lib + i=`echo "$i" | sed -e 's/^\([[^-]].*\)\.lib[$]/-l\1/i'` + fi + PKG_LIBS="$PKG_LIBS $i" + done + AC_SUBST(PKG_LIBS) +]) + +#------------------------------------------------------------------------ +# TEA_ADD_CFLAGS -- +# +# Specify one or more CFLAGS. Users should check for +# the right platform before adding to their list. +# +# Arguments: +# one or more file names +# +# Results: +# +# Defines and substs the following vars: +# PKG_CFLAGS +#------------------------------------------------------------------------ +AC_DEFUN([TEA_ADD_CFLAGS], [ + PKG_CFLAGS="$PKG_CFLAGS $@" + AC_SUBST(PKG_CFLAGS) +]) + +#------------------------------------------------------------------------ +# TEA_ADD_CLEANFILES -- +# +# Specify one or more CLEANFILES. +# +# Arguments: +# one or more file names to clean target +# +# Results: +# +# Appends to CLEANFILES, already defined for subst in LOAD_TCLCONFIG +#------------------------------------------------------------------------ +AC_DEFUN([TEA_ADD_CLEANFILES], [ + CLEANFILES="$CLEANFILES $@" +]) + +#------------------------------------------------------------------------ +# TEA_PREFIX -- +# +# Handle the --prefix=... option by defaulting to what Tcl gave +# +# Arguments: +# none +# +# Results: +# +# If --prefix or --exec-prefix was not specified, $prefix and +# $exec_prefix will be set to the values given to Tcl when it was +# configured. +#------------------------------------------------------------------------ +AC_DEFUN([TEA_PREFIX], [ + if test "${prefix}" = "NONE"; then + prefix_default=yes + if test x"${TCL_PREFIX}" != x; then + AC_MSG_NOTICE([--prefix defaulting to TCL_PREFIX ${TCL_PREFIX}]) + prefix=${TCL_PREFIX} + else + AC_MSG_NOTICE([--prefix defaulting to /usr/local]) + prefix=/usr/local + fi + fi + if test "${exec_prefix}" = "NONE" -a x"${prefix_default}" = x"yes" \ + -o x"${exec_prefix_default}" = x"yes" ; then + if test x"${TCL_EXEC_PREFIX}" != x; then + AC_MSG_NOTICE([--exec-prefix defaulting to TCL_EXEC_PREFIX ${TCL_EXEC_PREFIX}]) + exec_prefix=${TCL_EXEC_PREFIX} + else + AC_MSG_NOTICE([--exec-prefix defaulting to ${prefix}]) + exec_prefix=$prefix + fi + fi +]) + +#------------------------------------------------------------------------ +# TEA_SETUP_COMPILER_CC -- +# +# Do compiler checks the way we want. This is just a replacement +# for AC_PROG_CC in TEA configure.in files to make them cleaner. +# +# Arguments: +# none +# +# Results: +# +# Sets up CC var and other standard bits we need to make executables. +#------------------------------------------------------------------------ +AC_DEFUN([TEA_SETUP_COMPILER_CC], [ + # Don't put any macros that use the compiler (e.g. AC_TRY_COMPILE) + # in this macro, they need to go into TEA_SETUP_COMPILER instead. + + AC_PROG_CC + AC_PROG_CPP + + INSTALL="\$(SHELL) \$(srcdir)/tclconfig/install-sh -c" + AC_SUBST(INSTALL) + + #-------------------------------------------------------------------- + # Checks to see if the make program sets the $MAKE variable. + #-------------------------------------------------------------------- + + AC_PROG_MAKE_SET + + #-------------------------------------------------------------------- + # Find ranlib + #-------------------------------------------------------------------- + + AC_CHECK_TOOL(RANLIB, ranlib) + + #-------------------------------------------------------------------- + # Determines the correct binary file extension (.o, .obj, .exe etc.) + #-------------------------------------------------------------------- + + AC_OBJEXT + AC_EXEEXT +]) + +#------------------------------------------------------------------------ +# TEA_SETUP_COMPILER -- +# +# Do compiler checks that use the compiler. This must go after +# TEA_SETUP_COMPILER_CC, which does the actual compiler check. +# +# Arguments: +# none +# +# Results: +# +# Sets up CC var and other standard bits we need to make executables. +#------------------------------------------------------------------------ +AC_DEFUN([TEA_SETUP_COMPILER], [ + # Any macros that use the compiler (e.g. AC_TRY_COMPILE) have to go here. + AC_REQUIRE([TEA_SETUP_COMPILER_CC]) + + #------------------------------------------------------------------------ + # If we're using GCC, see if the compiler understands -pipe. If so, use it. + # It makes compiling go faster. (This is only a performance feature.) + #------------------------------------------------------------------------ + + if test -z "$no_pipe" -a -n "$GCC"; then + AC_CACHE_CHECK([if the compiler understands -pipe], + tcl_cv_cc_pipe, [ + hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -pipe" + AC_TRY_COMPILE(,, tcl_cv_cc_pipe=yes, tcl_cv_cc_pipe=no) + CFLAGS=$hold_cflags]) + if test $tcl_cv_cc_pipe = yes; then + CFLAGS="$CFLAGS -pipe" + fi + fi + + #-------------------------------------------------------------------- + # Common compiler flag setup + #-------------------------------------------------------------------- + + AC_C_BIGENDIAN + if test "${TEA_PLATFORM}" = "unix" ; then + TEA_TCL_LINK_LIBS + TEA_MISSING_POSIX_HEADERS + # Let the user call this, because if it triggers, they will + # need a compat/strtod.c that is correct. Users can also + # use Tcl_GetDouble(FromObj) instead. + #TEA_BUGGY_STRTOD + fi +]) + +#------------------------------------------------------------------------ +# TEA_MAKE_LIB -- +# +# Generate a line that can be used to build a shared/unshared library +# in a platform independent manner. +# +# Arguments: +# none +# +# Requires: +# +# Results: +# +# Defines the following vars: +# CFLAGS - Done late here to note disturb other AC macros +# MAKE_LIB - Command to execute to build the Tcl library; +# differs depending on whether or not Tcl is being +# compiled as a shared library. +# MAKE_SHARED_LIB Makefile rule for building a shared library +# MAKE_STATIC_LIB Makefile rule for building a static library +# MAKE_STUB_LIB Makefile rule for building a stub library +# VC_MANIFEST_EMBED_DLL Makefile rule for embedded VC manifest in DLL +# VC_MANIFEST_EMBED_EXE Makefile rule for embedded VC manifest in EXE +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_MAKE_LIB], [ + if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes"; then + MAKE_STATIC_LIB="\${STLIB_LD} -out:\[$]@ \$(PKG_OBJECTS)" + MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LD_LIBS} \${LDFLAGS_DEFAULT} -out:\[$]@ \$(PKG_OBJECTS)" + AC_EGREP_CPP([manifest needed], [ +#if defined(_MSC_VER) && _MSC_VER >= 1400 +print("manifest needed") +#endif + ], [ + # Could do a CHECK_PROG for mt, but should always be with MSVC8+ + VC_MANIFEST_EMBED_DLL="if test -f \[$]@.manifest ; then mt.exe -nologo -manifest \[$]@.manifest -outputresource:\[$]@\;2 ; fi" + VC_MANIFEST_EMBED_EXE="if test -f \[$]@.manifest ; then mt.exe -nologo -manifest \[$]@.manifest -outputresource:\[$]@\;1 ; fi" + MAKE_SHARED_LIB="${MAKE_SHARED_LIB} ; ${VC_MANIFEST_EMBED_DLL}" + TEA_ADD_CLEANFILES([*.manifest]) + ]) + MAKE_STUB_LIB="\${STLIB_LD} -out:\[$]@ \$(PKG_STUB_OBJECTS)" + else + MAKE_STATIC_LIB="\${STLIB_LD} \[$]@ \$(PKG_OBJECTS)" + MAKE_SHARED_LIB="\${SHLIB_LD} -o \[$]@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}" + MAKE_STUB_LIB="\${STLIB_LD} \[$]@ \$(PKG_STUB_OBJECTS)" + fi + + if test "${SHARED_BUILD}" = "1" ; then + MAKE_LIB="${MAKE_SHARED_LIB} " + else + MAKE_LIB="${MAKE_STATIC_LIB} " + fi + + #-------------------------------------------------------------------- + # Shared libraries and static libraries have different names. + # Use the double eval to make sure any variables in the suffix is + # substituted. (@@@ Might not be necessary anymore) + #-------------------------------------------------------------------- + + if test "${TEA_PLATFORM}" = "windows" ; then + if test "${SHARED_BUILD}" = "1" ; then + # We force the unresolved linking of symbols that are really in + # the private libraries of Tcl and Tk. + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}`\"" + if test x"${TK_BIN_DIR}" != x ; then + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TK_BIN_DIR}/${TK_STUB_LIB_FILE}`\"" + fi + eval eval "PKG_LIB_FILE=${PACKAGE_NAME}${SHARED_LIB_SUFFIX}" + else + eval eval "PKG_LIB_FILE=${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}" + fi + # Some packages build their own stubs libraries + eval eval "PKG_STUB_LIB_FILE=${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}" + if test "$GCC" = "yes"; then + PKG_STUB_LIB_FILE=lib${PKG_STUB_LIB_FILE} + fi + # These aren't needed on Windows (either MSVC or gcc) + RANLIB=: + RANLIB_STUB=: + else + RANLIB_STUB="${RANLIB}" + if test "${SHARED_BUILD}" = "1" ; then + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TCL_STUB_LIB_SPEC}" + if test x"${TK_BIN_DIR}" != x ; then + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TK_STUB_LIB_SPEC}" + fi + eval eval "PKG_LIB_FILE=lib${PACKAGE_NAME}${SHARED_LIB_SUFFIX}" + RANLIB=: + else + eval eval "PKG_LIB_FILE=lib${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}" + fi + # Some packages build their own stubs libraries + eval eval "PKG_STUB_LIB_FILE=lib${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}" + fi + + # These are escaped so that only CFLAGS is picked up at configure time. + # The other values will be substituted at make time. + CFLAGS="${CFLAGS} \${CFLAGS_DEFAULT} \${CFLAGS_WARNING}" + if test "${SHARED_BUILD}" = "1" ; then + CFLAGS="${CFLAGS} \${SHLIB_CFLAGS}" + fi + + AC_SUBST(MAKE_LIB) + AC_SUBST(MAKE_SHARED_LIB) + AC_SUBST(MAKE_STATIC_LIB) + AC_SUBST(MAKE_STUB_LIB) + AC_SUBST(RANLIB_STUB) + AC_SUBST(VC_MANIFEST_EMBED_DLL) + AC_SUBST(VC_MANIFEST_EMBED_EXE) +]) + +#------------------------------------------------------------------------ +# TEA_LIB_SPEC -- +# +# Compute the name of an existing object library located in libdir +# from the given base name and produce the appropriate linker flags. +# +# Arguments: +# basename The base name of the library without version +# numbers, extensions, or "lib" prefixes. +# extra_dir Extra directory in which to search for the +# library. This location is used first, then +# $prefix/$exec-prefix, then some defaults. +# +# Requires: +# TEA_INIT and TEA_PREFIX must be called first. +# +# Results: +# +# Defines the following vars: +# ${basename}_LIB_NAME The computed library name. +# ${basename}_LIB_SPEC The computed linker flags. +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_LIB_SPEC], [ + AC_MSG_CHECKING([for $1 library]) + + # Look in exec-prefix for the library (defined by TEA_PREFIX). + + tea_lib_name_dir="${exec_prefix}/lib" + + # Or in a user-specified location. + + if test x"$2" != x ; then + tea_extra_lib_dir=$2 + else + tea_extra_lib_dir=NONE + fi + + for i in \ + `ls -dr ${tea_extra_lib_dir}/$1[[0-9]]*.lib 2>/dev/null ` \ + `ls -dr ${tea_extra_lib_dir}/lib$1[[0-9]]* 2>/dev/null ` \ + `ls -dr ${tea_lib_name_dir}/$1[[0-9]]*.lib 2>/dev/null ` \ + `ls -dr ${tea_lib_name_dir}/lib$1[[0-9]]* 2>/dev/null ` \ + `ls -dr /usr/lib/$1[[0-9]]*.lib 2>/dev/null ` \ + `ls -dr /usr/lib/lib$1[[0-9]]* 2>/dev/null ` \ + `ls -dr /usr/lib64/$1[[0-9]]*.lib 2>/dev/null ` \ + `ls -dr /usr/lib64/lib$1[[0-9]]* 2>/dev/null ` \ + `ls -dr /usr/local/lib/$1[[0-9]]*.lib 2>/dev/null ` \ + `ls -dr /usr/local/lib/lib$1[[0-9]]* 2>/dev/null ` ; do + if test -f "$i" ; then + tea_lib_name_dir=`dirname $i` + $1_LIB_NAME=`basename $i` + $1_LIB_PATH_NAME=$i + break + fi + done + + if test "${TEA_PLATFORM}" = "windows"; then + $1_LIB_SPEC=\"`${CYGPATH} ${$1_LIB_PATH_NAME} 2>/dev/null`\" + else + # Strip off the leading "lib" and trailing ".a" or ".so" + + tea_lib_name_lib=`echo ${$1_LIB_NAME}|sed -e 's/^lib//' -e 's/\.[[^.]]*$//' -e 's/\.so.*//'` + $1_LIB_SPEC="-L${tea_lib_name_dir} -l${tea_lib_name_lib}" + fi + + if test "x${$1_LIB_NAME}" = x ; then + AC_MSG_ERROR([not found]) + else + AC_MSG_RESULT([${$1_LIB_SPEC}]) + fi +]) + +#------------------------------------------------------------------------ +# TEA_PRIVATE_TCL_HEADERS -- +# +# Locate the private Tcl include files +# +# Arguments: +# +# Requires: +# TCL_SRC_DIR Assumes that TEA_LOAD_TCLCONFIG has +# already been called. +# +# Results: +# +# Substitutes the following vars: +# TCL_TOP_DIR_NATIVE +# TCL_INCLUDES +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_PRIVATE_TCL_HEADERS], [ + # Allow for --with-tclinclude to take effect and define ${ac_cv_c_tclh} + AC_REQUIRE([TEA_PUBLIC_TCL_HEADERS]) + AC_MSG_CHECKING([for Tcl private include files]) + + TCL_SRC_DIR_NATIVE=`${CYGPATH} ${TCL_SRC_DIR}` + TCL_TOP_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}\" + + # Check to see if tclPort.h isn't already with the public headers + # Don't look for tclInt.h because that resides with tcl.h in the core + # sources, but the Port headers are in a different directory + if test "${TEA_PLATFORM}" = "windows" -a \ + -f "${ac_cv_c_tclh}/tclWinPort.h"; then + result="private headers found with public headers" + elif test "${TEA_PLATFORM}" = "unix" -a \ + -f "${ac_cv_c_tclh}/tclUnixPort.h"; then + result="private headers found with public headers" + else + TCL_GENERIC_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/generic\" + if test "${TEA_PLATFORM}" = "windows"; then + TCL_PLATFORM_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/win\" + else + TCL_PLATFORM_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/unix\" + fi + # Overwrite the previous TCL_INCLUDES as this should capture both + # public and private headers in the same set. + # We want to ensure these are substituted so as not to require + # any *_NATIVE vars be defined in the Makefile + TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}" + if test "`uname -s`" = "Darwin"; then + # If Tcl was built as a framework, attempt to use + # the framework's Headers and PrivateHeaders directories + case ${TCL_DEFS} in + *TCL_FRAMEWORK*) + if test -d "${TCL_BIN_DIR}/Headers" -a \ + -d "${TCL_BIN_DIR}/PrivateHeaders"; then + TCL_INCLUDES="-I\"${TCL_BIN_DIR}/Headers\" -I\"${TCL_BIN_DIR}/PrivateHeaders\" ${TCL_INCLUDES}" + else + TCL_INCLUDES="${TCL_INCLUDES} ${TCL_INCLUDE_SPEC} `echo "${TCL_INCLUDE_SPEC}" | sed -e 's/Headers/PrivateHeaders/'`" + fi + ;; + esac + result="Using ${TCL_INCLUDES}" + else + if test ! -f "${TCL_SRC_DIR}/generic/tclInt.h" ; then + AC_MSG_ERROR([Cannot find private header tclInt.h in ${TCL_SRC_DIR}]) + fi + result="Using srcdir found in tclConfig.sh: ${TCL_SRC_DIR}" + fi + fi + + AC_SUBST(TCL_TOP_DIR_NATIVE) + + AC_SUBST(TCL_INCLUDES) + AC_MSG_RESULT([${result}]) +]) + +#------------------------------------------------------------------------ +# TEA_PUBLIC_TCL_HEADERS -- +# +# Locate the installed public Tcl header files +# +# Arguments: +# None. +# +# Requires: +# CYGPATH must be set +# +# Results: +# +# Adds a --with-tclinclude switch to configure. +# Result is cached. +# +# Substitutes the following vars: +# TCL_INCLUDES +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_PUBLIC_TCL_HEADERS], [ + AC_MSG_CHECKING([for Tcl public headers]) + + AC_ARG_WITH(tclinclude, [ --with-tclinclude directory containing the public Tcl header files], with_tclinclude=${withval}) + + AC_CACHE_VAL(ac_cv_c_tclh, [ + # Use the value from --with-tclinclude, if it was given + + if test x"${with_tclinclude}" != x ; then + if test -f "${with_tclinclude}/tcl.h" ; then + ac_cv_c_tclh=${with_tclinclude} + else + AC_MSG_ERROR([${with_tclinclude} directory does not contain tcl.h]) + fi + else + list="" + if test "`uname -s`" = "Darwin"; then + # If Tcl was built as a framework, attempt to use + # the framework's Headers directory + case ${TCL_DEFS} in + *TCL_FRAMEWORK*) + list="`ls -d ${TCL_BIN_DIR}/Headers 2>/dev/null`" + ;; + esac + fi + + # Look in the source dir only if Tcl is not installed, + # and in that situation, look there before installed locations. + if test -f "${TCL_BIN_DIR}/Makefile" ; then + list="$list `ls -d ${TCL_SRC_DIR}/generic 2>/dev/null`" + fi + + # Check order: pkg --prefix location, Tcl's --prefix location, + # relative to directory of tclConfig.sh. + + eval "temp_includedir=${includedir}" + list="$list \ + `ls -d ${temp_includedir} 2>/dev/null` \ + `ls -d ${TCL_PREFIX}/include 2>/dev/null` \ + `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null`" + if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then + list="$list /usr/local/include /usr/include" + if test x"${TCL_INCLUDE_SPEC}" != x ; then + d=`echo "${TCL_INCLUDE_SPEC}" | sed -e 's/^-I//'` + list="$list `ls -d ${d} 2>/dev/null`" + fi + fi + for i in $list ; do + if test -f "$i/tcl.h" ; then + ac_cv_c_tclh=$i + break + fi + done + fi + ]) + + # Print a message based on how we determined the include path + + if test x"${ac_cv_c_tclh}" = x ; then + AC_MSG_ERROR([tcl.h not found. Please specify its location with --with-tclinclude]) + else + AC_MSG_RESULT([${ac_cv_c_tclh}]) + fi + + # Convert to a native path and substitute into the output files. + + INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclh}` + + TCL_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\" + + AC_SUBST(TCL_INCLUDES) +]) + +#------------------------------------------------------------------------ +# TEA_PRIVATE_TK_HEADERS -- +# +# Locate the private Tk include files +# +# Arguments: +# +# Requires: +# TK_SRC_DIR Assumes that TEA_LOAD_TKCONFIG has +# already been called. +# +# Results: +# +# Substitutes the following vars: +# TK_INCLUDES +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_PRIVATE_TK_HEADERS], [ + # Allow for --with-tkinclude to take effect and define ${ac_cv_c_tkh} + AC_REQUIRE([TEA_PUBLIC_TK_HEADERS]) + AC_MSG_CHECKING([for Tk private include files]) + + TK_SRC_DIR_NATIVE=`${CYGPATH} ${TK_SRC_DIR}` + TK_TOP_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}\" + + # Check to see if tkPort.h isn't already with the public headers + # Don't look for tkInt.h because that resides with tk.h in the core + # sources, but the Port headers are in a different directory + if test "${TEA_PLATFORM}" = "windows" -a \ + -f "${ac_cv_c_tkh}/tkWinPort.h"; then + result="private headers found with public headers" + elif test "${TEA_PLATFORM}" = "unix" -a \ + -f "${ac_cv_c_tkh}/tkUnixPort.h"; then + result="private headers found with public headers" + else + TK_GENERIC_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/generic\" + TK_XLIB_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/xlib\" + if test "${TEA_PLATFORM}" = "windows"; then + TK_PLATFORM_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/win\" + else + TK_PLATFORM_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/unix\" + fi + # Overwrite the previous TK_INCLUDES as this should capture both + # public and private headers in the same set. + # We want to ensure these are substituted so as not to require + # any *_NATIVE vars be defined in the Makefile + TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE}" + # Detect and add ttk subdir + if test -d "${TK_SRC_DIR}/generic/ttk"; then + TK_INCLUDES="${TK_INCLUDES} -I\"${TK_SRC_DIR_NATIVE}/generic/ttk\"" + fi + if test "${TEA_WINDOWINGSYSTEM}" != "x11"; then + TK_INCLUDES="${TK_INCLUDES} -I\"${TK_XLIB_DIR_NATIVE}\"" + fi + if test "${TEA_WINDOWINGSYSTEM}" = "aqua"; then + TK_INCLUDES="${TK_INCLUDES} -I\"${TK_SRC_DIR_NATIVE}/macosx\"" + fi + if test "`uname -s`" = "Darwin"; then + # If Tk was built as a framework, attempt to use + # the framework's Headers and PrivateHeaders directories + case ${TK_DEFS} in + *TK_FRAMEWORK*) + if test -d "${TK_BIN_DIR}/Headers" -a \ + -d "${TK_BIN_DIR}/PrivateHeaders"; then + TK_INCLUDES="-I\"${TK_BIN_DIR}/Headers\" -I\"${TK_BIN_DIR}/PrivateHeaders\" ${TK_INCLUDES}" + else + TK_INCLUDES="${TK_INCLUDES} ${TK_INCLUDE_SPEC} `echo "${TK_INCLUDE_SPEC}" | sed -e 's/Headers/PrivateHeaders/'`" + fi + ;; + esac + result="Using ${TK_INCLUDES}" + else + if test ! -f "${TK_SRC_DIR}/generic/tkInt.h" ; then + AC_MSG_ERROR([Cannot find private header tkInt.h in ${TK_SRC_DIR}]) + fi + result="Using srcdir found in tkConfig.sh: ${TK_SRC_DIR}" + fi + fi + + AC_SUBST(TK_TOP_DIR_NATIVE) + AC_SUBST(TK_XLIB_DIR_NATIVE) + + AC_SUBST(TK_INCLUDES) + AC_MSG_RESULT([${result}]) +]) + +#------------------------------------------------------------------------ +# TEA_PUBLIC_TK_HEADERS -- +# +# Locate the installed public Tk header files +# +# Arguments: +# None. +# +# Requires: +# CYGPATH must be set +# +# Results: +# +# Adds a --with-tkinclude switch to configure. +# Result is cached. +# +# Substitutes the following vars: +# TK_INCLUDES +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_PUBLIC_TK_HEADERS], [ + AC_MSG_CHECKING([for Tk public headers]) + + AC_ARG_WITH(tkinclude, [ --with-tkinclude directory containing the public Tk header files], with_tkinclude=${withval}) + + AC_CACHE_VAL(ac_cv_c_tkh, [ + # Use the value from --with-tkinclude, if it was given + + if test x"${with_tkinclude}" != x ; then + if test -f "${with_tkinclude}/tk.h" ; then + ac_cv_c_tkh=${with_tkinclude} + else + AC_MSG_ERROR([${with_tkinclude} directory does not contain tk.h]) + fi + else + list="" + if test "`uname -s`" = "Darwin"; then + # If Tk was built as a framework, attempt to use + # the framework's Headers directory. + case ${TK_DEFS} in + *TK_FRAMEWORK*) + list="`ls -d ${TK_BIN_DIR}/Headers 2>/dev/null`" + ;; + esac + fi + + # Look in the source dir only if Tk is not installed, + # and in that situation, look there before installed locations. + if test -f "${TK_BIN_DIR}/Makefile" ; then + list="$list `ls -d ${TK_SRC_DIR}/generic 2>/dev/null`" + fi + + # Check order: pkg --prefix location, Tk's --prefix location, + # relative to directory of tkConfig.sh, Tcl's --prefix location, + # relative to directory of tclConfig.sh. + + eval "temp_includedir=${includedir}" + list="$list \ + `ls -d ${temp_includedir} 2>/dev/null` \ + `ls -d ${TK_PREFIX}/include 2>/dev/null` \ + `ls -d ${TK_BIN_DIR}/../include 2>/dev/null` \ + `ls -d ${TCL_PREFIX}/include 2>/dev/null` \ + `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null`" + if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then + list="$list /usr/local/include /usr/include" + if test x"${TK_INCLUDE_SPEC}" != x ; then + d=`echo "${TK_INCLUDE_SPEC}" | sed -e 's/^-I//'` + list="$list `ls -d ${d} 2>/dev/null`" + fi + fi + for i in $list ; do + if test -f "$i/tk.h" ; then + ac_cv_c_tkh=$i + break + fi + done + fi + ]) + + # Print a message based on how we determined the include path + + if test x"${ac_cv_c_tkh}" = x ; then + AC_MSG_ERROR([tk.h not found. Please specify its location with --with-tkinclude]) + else + AC_MSG_RESULT([${ac_cv_c_tkh}]) + fi + + # Convert to a native path and substitute into the output files. + + INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tkh}` + + TK_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\" + + AC_SUBST(TK_INCLUDES) + + if test "${TEA_WINDOWINGSYSTEM}" != "x11"; then + # On Windows and Aqua, we need the X compat headers + AC_MSG_CHECKING([for X11 header files]) + if test ! -r "${INCLUDE_DIR_NATIVE}/X11/Xlib.h"; then + INCLUDE_DIR_NATIVE="`${CYGPATH} ${TK_SRC_DIR}/xlib`" + TK_XINCLUDES=-I\"${INCLUDE_DIR_NATIVE}\" + AC_SUBST(TK_XINCLUDES) + fi + AC_MSG_RESULT([${INCLUDE_DIR_NATIVE}]) + fi +]) + +#------------------------------------------------------------------------ +# TEA_PATH_CONFIG -- +# +# Locate the ${1}Config.sh file and perform a sanity check on +# the ${1} compile flags. These are used by packages like +# [incr Tk] that load *Config.sh files from more than Tcl and Tk. +# +# Arguments: +# none +# +# Results: +# +# Adds the following arguments to configure: +# --with-$1=... +# +# Defines the following vars: +# $1_BIN_DIR Full path to the directory containing +# the $1Config.sh file +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_PATH_CONFIG], [ + # + # Ok, lets find the $1 configuration + # First, look for one uninstalled. + # the alternative search directory is invoked by --with-$1 + # + + if test x"${no_$1}" = x ; then + # we reset no_$1 in case something fails here + no_$1=true + AC_ARG_WITH($1, [ --with-$1 directory containing $1 configuration ($1Config.sh)], with_$1config=${withval}) + AC_MSG_CHECKING([for $1 configuration]) + AC_CACHE_VAL(ac_cv_c_$1config,[ + + # First check to see if --with-$1 was specified. + if test x"${with_$1config}" != x ; then + case ${with_$1config} in + */$1Config.sh ) + if test -f ${with_$1config}; then + AC_MSG_WARN([--with-$1 argument should refer to directory containing $1Config.sh, not to $1Config.sh itself]) + with_$1config=`echo ${with_$1config} | sed 's!/$1Config\.sh$!!'` + fi;; + esac + if test -f "${with_$1config}/$1Config.sh" ; then + ac_cv_c_$1config=`(cd ${with_$1config}; pwd)` + else + AC_MSG_ERROR([${with_$1config} directory doesn't contain $1Config.sh]) + fi + fi + + # then check for a private $1 installation + if test x"${ac_cv_c_$1config}" = x ; then + for i in \ + ../$1 \ + `ls -dr ../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \ + `ls -dr ../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \ + `ls -dr ../$1*[[0-9]].[[0-9]] 2>/dev/null` \ + `ls -dr ../$1*[[0-9]].[[0-9]]* 2>/dev/null` \ + ../../$1 \ + `ls -dr ../../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \ + `ls -dr ../../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \ + `ls -dr ../../$1*[[0-9]].[[0-9]] 2>/dev/null` \ + `ls -dr ../../$1*[[0-9]].[[0-9]]* 2>/dev/null` \ + ../../../$1 \ + `ls -dr ../../../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \ + `ls -dr ../../../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \ + `ls -dr ../../../$1*[[0-9]].[[0-9]] 2>/dev/null` \ + `ls -dr ../../../$1*[[0-9]].[[0-9]]* 2>/dev/null` \ + ${srcdir}/../$1 \ + `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \ + `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \ + `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]] 2>/dev/null` \ + `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]]* 2>/dev/null` \ + ; do + if test -f "$i/$1Config.sh" ; then + ac_cv_c_$1config=`(cd $i; pwd)` + break + fi + if test -f "$i/unix/$1Config.sh" ; then + ac_cv_c_$1config=`(cd $i/unix; pwd)` + break + fi + done + fi + + # check in a few common install locations + if test x"${ac_cv_c_$1config}" = x ; then + for i in `ls -d ${libdir} 2>/dev/null` \ + `ls -d ${exec_prefix}/lib 2>/dev/null` \ + `ls -d ${prefix}/lib 2>/dev/null` \ + `ls -d /usr/local/lib 2>/dev/null` \ + `ls -d /usr/contrib/lib 2>/dev/null` \ + `ls -d /usr/lib 2>/dev/null` \ + `ls -d /usr/lib64 2>/dev/null` \ + ; do + if test -f "$i/$1Config.sh" ; then + ac_cv_c_$1config=`(cd $i; pwd)` + break + fi + done + fi + ]) + + if test x"${ac_cv_c_$1config}" = x ; then + $1_BIN_DIR="# no $1 configs found" + AC_MSG_WARN([Cannot find $1 configuration definitions]) + exit 0 + else + no_$1= + $1_BIN_DIR=${ac_cv_c_$1config} + AC_MSG_RESULT([found $$1_BIN_DIR/$1Config.sh]) + fi + fi +]) + +#------------------------------------------------------------------------ +# TEA_LOAD_CONFIG -- +# +# Load the $1Config.sh file +# +# Arguments: +# +# Requires the following vars to be set: +# $1_BIN_DIR +# +# Results: +# +# Substitutes the following vars: +# $1_SRC_DIR +# $1_LIB_FILE +# $1_LIB_SPEC +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_LOAD_CONFIG], [ + AC_MSG_CHECKING([for existence of ${$1_BIN_DIR}/$1Config.sh]) + + if test -f "${$1_BIN_DIR}/$1Config.sh" ; then + AC_MSG_RESULT([loading]) + . "${$1_BIN_DIR}/$1Config.sh" + else + AC_MSG_RESULT([file not found]) + fi + + # + # If the $1_BIN_DIR is the build directory (not the install directory), + # then set the common variable name to the value of the build variables. + # For example, the variable $1_LIB_SPEC will be set to the value + # of $1_BUILD_LIB_SPEC. An extension should make use of $1_LIB_SPEC + # instead of $1_BUILD_LIB_SPEC since it will work with both an + # installed and uninstalled version of Tcl. + # + + if test -f "${$1_BIN_DIR}/Makefile" ; then + AC_MSG_WARN([Found Makefile - using build library specs for $1]) + $1_LIB_SPEC=${$1_BUILD_LIB_SPEC} + $1_STUB_LIB_SPEC=${$1_BUILD_STUB_LIB_SPEC} + $1_STUB_LIB_PATH=${$1_BUILD_STUB_LIB_PATH} + $1_INCLUDE_SPEC=${$1_BUILD_INCLUDE_SPEC} + $1_LIBRARY_PATH=${$1_LIBRARY_PATH} + fi + + AC_SUBST($1_VERSION) + AC_SUBST($1_BIN_DIR) + AC_SUBST($1_SRC_DIR) + + AC_SUBST($1_LIB_FILE) + AC_SUBST($1_LIB_SPEC) + + AC_SUBST($1_STUB_LIB_FILE) + AC_SUBST($1_STUB_LIB_SPEC) + AC_SUBST($1_STUB_LIB_PATH) + + # Allow the caller to prevent this auto-check by specifying any 2nd arg + AS_IF([test "x$2" = x], [ + # Check both upper and lower-case variants + # If a dev wanted non-stubs libs, this function could take an option + # to not use _STUB in the paths below + AS_IF([test "x${$1_STUB_LIB_SPEC}" = x], + [TEA_LOAD_CONFIG_LIB(translit($1,[a-z],[A-Z])_STUB)], + [TEA_LOAD_CONFIG_LIB($1_STUB)]) + ]) +]) + +#------------------------------------------------------------------------ +# TEA_LOAD_CONFIG_LIB -- +# +# Helper function to load correct library from another extension's +# ${PACKAGE}Config.sh. +# +# Results: +# Adds to LIBS the appropriate extension library +#------------------------------------------------------------------------ +AC_DEFUN([TEA_LOAD_CONFIG_LIB], [ + AC_MSG_CHECKING([For $1 library for LIBS]) + # This simplifies the use of stub libraries by automatically adding + # the stub lib to your path. Normally this would add to SHLIB_LD_LIBS, + # but this is called before CONFIG_CFLAGS. More importantly, this adds + # to PKG_LIBS, which becomes LIBS, and that is only used by SHLIB_LD. + if test "x${$1_LIB_SPEC}" != "x" ; then + if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes" ; then + TEA_ADD_LIBS([\"`${CYGPATH} ${$1_LIB_PATH}`\"]) + AC_MSG_RESULT([using $1_LIB_PATH ${$1_LIB_PATH}]) + else + TEA_ADD_LIBS([${$1_LIB_SPEC}]) + AC_MSG_RESULT([using $1_LIB_SPEC ${$1_LIB_SPEC}]) + fi + else + AC_MSG_RESULT([file not found]) + fi +]) + +#------------------------------------------------------------------------ +# TEA_EXPORT_CONFIG -- +# +# Define the data to insert into the ${PACKAGE}Config.sh file +# +# Arguments: +# +# Requires the following vars to be set: +# $1 +# +# Results: +# Substitutes the following vars: +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_EXPORT_CONFIG], [ + #-------------------------------------------------------------------- + # These are for $1Config.sh + #-------------------------------------------------------------------- + + # pkglibdir must be a fully qualified path and (not ${exec_prefix}/lib) + eval pkglibdir="[$]{libdir}/$1${PACKAGE_VERSION}" + if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then + eval $1_LIB_FLAG="-l$1${PACKAGE_VERSION}${DBGX}" + eval $1_STUB_LIB_FLAG="-l$1stub${PACKAGE_VERSION}${DBGX}" + else + eval $1_LIB_FLAG="-l$1`echo ${PACKAGE_VERSION} | tr -d .`${DBGX}" + eval $1_STUB_LIB_FLAG="-l$1stub`echo ${PACKAGE_VERSION} | tr -d .`${DBGX}" + fi + $1_BUILD_LIB_SPEC="-L`pwd` ${$1_LIB_FLAG}" + $1_LIB_SPEC="-L${pkglibdir} ${$1_LIB_FLAG}" + $1_BUILD_STUB_LIB_SPEC="-L`pwd` [$]{$1_STUB_LIB_FLAG}" + $1_STUB_LIB_SPEC="-L${pkglibdir} [$]{$1_STUB_LIB_FLAG}" + $1_BUILD_STUB_LIB_PATH="`pwd`/[$]{PKG_STUB_LIB_FILE}" + $1_STUB_LIB_PATH="${pkglibdir}/[$]{PKG_STUB_LIB_FILE}" + + AC_SUBST($1_BUILD_LIB_SPEC) + AC_SUBST($1_LIB_SPEC) + AC_SUBST($1_BUILD_STUB_LIB_SPEC) + AC_SUBST($1_STUB_LIB_SPEC) + AC_SUBST($1_BUILD_STUB_LIB_PATH) + AC_SUBST($1_STUB_LIB_PATH) + + AC_SUBST(MAJOR_VERSION) + AC_SUBST(MINOR_VERSION) + AC_SUBST(PATCHLEVEL) +]) + + +#------------------------------------------------------------------------ +# TEA_PATH_CELIB -- +# +# Locate Keuchel's celib emulation layer for targeting Win/CE +# +# Arguments: +# none +# +# Results: +# +# Adds the following arguments to configure: +# --with-celib=... +# +# Defines the following vars: +# CELIB_DIR Full path to the directory containing +# the include and platform lib files +#------------------------------------------------------------------------ + +AC_DEFUN([TEA_PATH_CELIB], [ + # First, look for one uninstalled. + # the alternative search directory is invoked by --with-celib + + if test x"${no_celib}" = x ; then + # we reset no_celib in case something fails here + no_celib=true + AC_ARG_WITH(celib,[ --with-celib=DIR use Windows/CE support library from DIR], with_celibconfig=${withval}) + AC_MSG_CHECKING([for Windows/CE celib directory]) + AC_CACHE_VAL(ac_cv_c_celibconfig,[ + # First check to see if --with-celibconfig was specified. + if test x"${with_celibconfig}" != x ; then + if test -d "${with_celibconfig}/inc" ; then + ac_cv_c_celibconfig=`(cd ${with_celibconfig}; pwd)` + else + AC_MSG_ERROR([${with_celibconfig} directory doesn't contain inc directory]) + fi + fi + + # then check for a celib library + if test x"${ac_cv_c_celibconfig}" = x ; then + for i in \ + ../celib-palm-3.0 \ + ../celib \ + ../../celib-palm-3.0 \ + ../../celib \ + `ls -dr ../celib-*3.[[0-9]]* 2>/dev/null` \ + ${srcdir}/../celib-palm-3.0 \ + ${srcdir}/../celib \ + `ls -dr ${srcdir}/../celib-*3.[[0-9]]* 2>/dev/null` \ + ; do + if test -d "$i/inc" ; then + ac_cv_c_celibconfig=`(cd $i; pwd)` + break + fi + done + fi + ]) + if test x"${ac_cv_c_celibconfig}" = x ; then + AC_MSG_ERROR([Cannot find celib support library directory]) + else + no_celib= + CELIB_DIR=${ac_cv_c_celibconfig} + CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'` + AC_MSG_RESULT([found $CELIB_DIR]) + fi + fi +]) + + +# Local Variables: +# mode: autoconf +# End: diff --git a/tksao/util/FlexLexer.h b/tksao/util/FlexLexer.h new file mode 100644 index 0000000..1d783f1 --- /dev/null +++ b/tksao/util/FlexLexer.h @@ -0,0 +1,208 @@ +// -*-C++-*- +// FlexLexer.h -- define interfaces for lexical analyzer classes generated +// by flex + +// Copyright (c) 1993 The Regents of the University of California. +// All rights reserved. +// +// This code is derived from software contributed to Berkeley by +// Kent Williams and Tom Epperly. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: + +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. + +// Neither the name of the University nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. + +// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE. + +// This file defines FlexLexer, an abstract class which specifies the +// external interface provided to flex C++ lexer objects, and yyFlexLexer, +// which defines a particular lexer class. +// +// If you want to create multiple lexer classes, you use the -P flag +// to rename each yyFlexLexer to some other xxFlexLexer. You then +// include in your other sources once per lexer class: +// +// #undef yyFlexLexer +// #define yyFlexLexer xxFlexLexer +// #include +// +// #undef yyFlexLexer +// #define yyFlexLexer zzFlexLexer +// #include +// ... + +#ifndef __FLEX_LEXER_H +// Never included before - need to define base class. +#define __FLEX_LEXER_H + +#include +# ifndef FLEX_STD +# define FLEX_STD std:: +# endif + +extern "C++" { + +struct yy_buffer_state; +typedef int yy_state_type; + +class FlexLexer { +public: + virtual ~FlexLexer() { } + + const char* YYText() const { return yytext; } + size_t YYLeng() const { return yyleng; } + + virtual void + yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0; + virtual struct yy_buffer_state* + yy_create_buffer( FLEX_STD istream* s, int size ) = 0; + virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0; + virtual void yyrestart( FLEX_STD istream* s ) = 0; + + virtual int yylex() = 0; + + // Call yylex with new input/output sources. + int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ) + { + switch_streams( new_in, new_out ); + return yylex(); + } + + // Switch to new input/output streams. A nil stream pointer + // indicates "keep the current one". + virtual void switch_streams( FLEX_STD istream* new_in = 0, + FLEX_STD ostream* new_out = 0 ) = 0; + + int lineno() const { return yylineno; } + + int debug() const { return yy_flex_debug; } + void set_debug( int flag ) { yy_flex_debug = flag; } + +protected: + char* yytext; + size_t yyleng; + int yylineno; // only maintained if you use %option yylineno + int yy_flex_debug; // only has effect with -d or "%option debug" +}; + +} +#endif // FLEXLEXER_H + +#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce) +// Either this is the first time through (yyFlexLexerOnce not defined), +// or this is a repeated include to define a different flavor of +// yyFlexLexer, as discussed in the flex manual. +#define yyFlexLexerOnce + +extern "C++" { + +class yyFlexLexer : public FlexLexer { +public: + // arg_yyin and arg_yyout default to the cin and cout, but we + // only make that assignment when initializing in yylex(). + yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 ); + + virtual ~yyFlexLexer(); + + void yy_switch_to_buffer( struct yy_buffer_state* new_buffer ); + struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size ); + void yy_delete_buffer( struct yy_buffer_state* b ); + void yyrestart( FLEX_STD istream* s ); + + void yypush_buffer_state( struct yy_buffer_state* new_buffer ); + void yypop_buffer_state(); + + virtual int yylex(); + virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ); + virtual int yywrap(); + + void begin(int,int); + +protected: + virtual size_t LexerInput( char* buf, size_t max_size ); + virtual void LexerOutput( const char* buf, size_t size ); + virtual void LexerError( const char* msg ); + + void yyunput( int c, char* buf_ptr ); + int yyinput(); + + void yy_load_buffer_state(); + void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s ); + void yy_flush_buffer( struct yy_buffer_state* b ); + + int yy_start_stack_ptr; + int yy_start_stack_depth; + int* yy_start_stack; + + void yy_push_state( int new_state ); + void yy_pop_state(); + int yy_top_state(); + + yy_state_type yy_get_previous_state(); + yy_state_type yy_try_NUL_trans( yy_state_type current_state ); + int yy_get_next_buffer(); + + FLEX_STD istream* yyin; // input source for default LexerInput + FLEX_STD ostream* yyout; // output sink for default LexerOutput + + // yy_hold_char holds the character lost when yytext is formed. + char yy_hold_char; + + // Number of characters read into yy_ch_buf. + size_t yy_n_chars; + + // Points to current character in buffer. + char* yy_c_buf_p; + + int yy_init; // whether we need to initialize + int yy_start; // start state number + + // Flag which is used to allow yywrap()'s to do buffer switches + // instead of setting up a fresh yyin. A bit of a hack ... + int yy_did_buffer_switch_on_eof; + + + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */ + void yyensure_buffer_stack(void); + + // The following are not always needed, but may be depending + // on use of certain flex features (like REJECT or yymore()). + + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + yy_state_type* yy_state_buf; + yy_state_type* yy_state_ptr; + + char* yy_full_match; + int* yy_full_state; + int yy_full_lp; + + int yy_lp; + int yy_looking_for_trail_begin; + + int yy_more_flag; + int yy_more_len; + int yy_more_offset; + int yy_prev_more_offset; +}; + +} + +#endif // yyFlexLexer || ! yyFlexLexerOnce + diff --git a/tksao/util/attribute.C b/tksao/util/attribute.C new file mode 100644 index 0000000..23e49d4 --- /dev/null +++ b/tksao/util/attribute.C @@ -0,0 +1,193 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "attribute.h" +#include "util.h" +#include "widget.h" + +Attribute::Attribute(Widget* p) : parent(p) +{ + style_ = SOLID; + width_ = 1; + + font_ = 2; // helvetica normal roman + size_ = 10; + tkfont_ = NULL; + psfont_ = NULL; + initFonts(); + + colour_ = 0xffffff; // white + colorName_ = dupstr("white"); + color_ = parent->getColor("white"); +} + +Attribute::~Attribute() +{ + if (tkfont_) + Tk_FreeFont(tkfont_); + if (psfont_) + Tk_FreeFont(psfont_); + + if (colorName_) + delete [] colorName_; +} + +void Attribute::setStyle(double v) +{ + switch ((int)v) { + case SOLID: + case DASH: + break; + default: + return; + } + + style_ = (Style)((int)v); +} + +void Attribute::setWidth(double v) +{ + if (v>0) + width_ = v; + else + width_ = 1; +} + +void Attribute::setSize(double v) +{ + if (v >= 1) { +#ifdef MAC_OSX_TK + size_ = int(v*parent->getDisplayRatio()); +#else + size_ = (int)v; +#endif + initFonts(); + } +} + +void Attribute::setFont(double v) +{ + font_ = (int)v; + initFonts(); +} + +void Attribute::initFonts() +{ + if (tkfont_) + Tk_FreeFont(tkfont_); + tkfont_ = NULL; + if (psfont_) + Tk_FreeFont(psfont_); + psfont_ = NULL; + + WidgetOptions* opts = parent->options; + + ostringstream fstr; + ostringstream pstr; + switch (font_) { + case 0: + case 2: + case 3: + fstr << '{' << opts->helvetica << '}' << ' ' << size_ << " normal roman" << ends; + pstr << "helvetica " << size_ << " normal roman" << ends; + break; + case 1: + fstr << '{' << opts->times << '}' << ' ' << size_ << " normal roman" << ends; + pstr << "times " << size_ << " normal roman" << ends; + break; + case 4: + fstr << '{' << opts->courier << '}' << ' ' << size_ << " normal roman" << ends; + pstr << "courier " << size_ << " normal roman" << ends; + break; + + case 10: + case 12: + case 13: + fstr << '{' << opts->helvetica << '}' << ' ' << size_ << " bold roman" << ends; + pstr << "helvetica " << size_ << " bold roman" << ends; + break; + case 11: + fstr << '{' << opts->times << '}' << ' ' << size_ << " bold roman" << ends; + pstr << "times " << size_ << " bold roman" << ends; + break; + case 14: + fstr << '{' << opts->courier << '}' << ' ' << size_ << " bold roman" << ends; + pstr << "courier " << size_ << " bold roman" << ends; + break; + + case 20: + case 22: + case 23: + fstr << '{' << opts->helvetica << '}' << ' ' << size_ << " normal italic" << ends; + pstr << "helvetica " << size_ << " normal italic" << ends; + break; + case 21: + fstr << '{' << opts->times << '}' << ' ' << size_ << " normal italic" << ends; + pstr << "times " << size_ << " normal italic" << ends; + break; + case 24: + fstr << '{' << opts->courier << '}' << ' ' << size_ << " normal italic" << ends; + pstr << "courier " << size_ << " normal italic" << ends; + break; + + case 30: + case 32: + case 33: + fstr << '{' << opts->helvetica << '}' << ' ' << size_ << " bold italic" << ends; + pstr << "helvetica " << size_ << " bold italic" << ends; + break; + case 31: + fstr << '{' << opts->times << '}' << ' ' << size_ << " bold italic" << ends; + pstr << "times " << size_ << " bold italic" << ends; + break; + case 34: + fstr << '{' << opts->courier << '}' << ' ' << size_ << " bold italic" << ends; + pstr << "courier " << size_ << " bold italic" << ends; + break; + + default: + fstr << '{' << opts->helvetica << '}' << ' ' << size_ << " normal roman" << ends; + pstr << "helvetica " << size_ << " normal roman" << ends; + font_ = 2; + break; + } + + tkfont_ = Tk_GetFont(parent->getInterp(), parent->getTkwin(), + fstr.str().c_str()); + psfont_ = Tk_GetFont(parent->getInterp(), parent->getTkwin(), + pstr.str().c_str()); +} + +void Attribute::setColour(double v) +{ + if (v == colour_) + return; + + if (colorName_) + delete [] colorName_; + colorName_ = NULL; + + // still provide backward compatibility for old color scheme + if (v==1) + colour_ = (int)0xffffff; // white + else if (v==2) + colour_ = (int)0xff0000; // red + else if (v==3) + colour_ = (int)0x00ff00; // green + else if (v==4) + colour_ = (int)0x0000ff; // blue + else if (v==5) + colour_ = (int)0x00ffff; // cyan + else if (v==6) + colour_ = (int)0xff00ff; // magneta + else if (v==7) + colour_ = (int)0xffff00; // yellow + else + colour_ = (int)v; + + ostringstream str; + str << '#' << setw(6) << setfill('0') << hex << colour_ << ends; + colorName_ = dupstr(str.str().c_str()); + color_ = parent->getColor(str.str().c_str()); + } diff --git a/tksao/util/attribute.h b/tksao/util/attribute.h new file mode 100644 index 0000000..e32efde --- /dev/null +++ b/tksao/util/attribute.h @@ -0,0 +1,62 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __attribute_h__ +#define __attribute_h__ + +#include + +#include "vector.h" + +class Widget; + +class Attribute { + public: + enum Style {SOLID,DASH}; + enum Colour {BLACK,WHITE,RED,GREEN,BLUE,CYAN,MAGENTA,YELLOW}; + + private: + Widget* parent; + + Style style_; + float width_; + + int font_; + int size_; + Tk_Font tkfont_; + Tk_Font psfont_; + + unsigned long colour_; + char* colorName_; + unsigned long color_; + + private: + void initFonts(); + + public: + Attribute(Widget*); + ~Attribute(); + + void setStyle(double); + void setWidth(double); + + void setSize(double); + void setFont(double); + + void setColour(double); + + Style style() {return style_;} + float width() {return width_;} + + int size() {return size_;} + int font() {return font_;} + Tk_Font tkfont() {return tkfont_;} + Tk_Font psfont() {return psfont_;} + + unsigned long colour() {return colour_;} + char* colorName() {return colorName_;} + unsigned long color() {return color_;} +}; + +#endif diff --git a/tksao/util/fdstream.hpp b/tksao/util/fdstream.hpp new file mode 100644 index 0000000..585e03d --- /dev/null +++ b/tksao/util/fdstream.hpp @@ -0,0 +1,184 @@ +/* The following code declares classes to read from and write to + * file descriptore or file handles. + * + * See + * http://www.josuttis.com/cppcode + * for details and the latest version. + * + * - open: + * - integrating BUFSIZ on some systems? + * - optimized reading of multiple characters + * - stream for reading AND writing + * - i18n + * + * (C) Copyright Nicolai M. Josuttis 2001. + * Permission to copy, use, modify, sell and distribute this software + * is granted provided this copyright notice appears in all copies. + * This software is provided "as is" without express or implied + * warranty, and with no claim as to its suitability for any purpose. + * + * Version: Jul 28, 2002 + * History: + * Jul 28, 2002: bugfix memcpy() => memmove() + * fdinbuf::underflow(): cast for return statements + * Aug 05, 2001: first public version + */ +#ifndef BOOST_FDSTREAM_HPP +#define BOOST_FDSTREAM_HPP + +#include +#include +#include +// for EOF: +#include +// for memmove(): +#include + + +// low-level read and write functions +#ifdef _MSC_VER +# include +#else +# include +//extern "C" { +// int write (int fd, const char* buf, int num); +// int read (int fd, char* buf, int num); +//} +#endif + + +// BEGIN namespace BOOST +namespace boost { + + +/************************************************************ + * fdostream + * - a stream that writes on a file descriptor + ************************************************************/ + + +class fdoutbuf : public std::streambuf { + protected: + int fd; // file descriptor + public: + // constructor + fdoutbuf (int _fd) : fd(_fd) { + } + protected: + // write one character + virtual int_type overflow (int_type c) { + if (c != EOF) { + char z = c; + if (write (fd, &z, 1) != 1) { + return EOF; + } + } + return c; + } + // write multiple characters + virtual + std::streamsize xsputn (const char* s, + std::streamsize num) { + return write(fd,s,num); + } +}; + +class fdostream : public std::ostream { + protected: + fdoutbuf buf; + public: + fdostream (int fd) : std::ostream(0), buf(fd) { + rdbuf(&buf); + } +}; + + +/************************************************************ + * fdistream + * - a stream that reads on a file descriptor + ************************************************************/ + +class fdinbuf : public std::streambuf { + protected: + int fd; // file descriptor + protected: + /* data buffer: + * - at most, pbSize characters in putback area plus + * - at most, bufSize characters in ordinary read buffer + */ + static const int pbSize = 4; // size of putback area + static const int bufSize = 1024; // size of the data buffer + char buffer[bufSize+pbSize]; // data buffer + + public: + /* constructor + * - initialize file descriptor + * - initialize empty data buffer + * - no putback area + * => force underflow() + */ + fdinbuf (int _fd) : fd(_fd) { + setg (buffer+pbSize, // beginning of putback area + buffer+pbSize, // read position + buffer+pbSize); // end position + } + + protected: + // insert new characters into the buffer + virtual int_type underflow () { +#ifndef _MSC_VER + using std::memmove; +#endif + + // is read position before end of buffer? + if (gptr() < egptr()) { + return traits_type::to_int_type(*gptr()); + } + + /* process size of putback area + * - use number of characters read + * - but at most size of putback area + */ + int numPutback; + numPutback = gptr() - eback(); + if (numPutback > pbSize) { + numPutback = pbSize; + } + + /* copy up to pbSize characters previously read into + * the putback area + */ + memmove (buffer+(pbSize-numPutback), gptr()-numPutback, + numPutback); + + // read at most bufSize new characters + int num; + num = read (fd, buffer+pbSize, bufSize); + if (num <= 0) { + // ERROR or EOF + return EOF; + } + + // reset buffer pointers + setg (buffer+(pbSize-numPutback), // beginning of putback area + buffer+pbSize, // read position + buffer+pbSize+num); // end of buffer + + // return next character + return traits_type::to_int_type(*gptr()); + } +}; + +class fdistream : public std::istream { + protected: + fdinbuf buf; + public: + fdistream (int fd) : std::istream(0), buf(fd) { + rdbuf(&buf); + } +}; + + +} // END namespace boost + +#endif /*BOOST_FDSTREAM_HPP*/ diff --git a/tksao/util/fuzzy.h b/tksao/util/fuzzy.h new file mode 100644 index 0000000..512e079 --- /dev/null +++ b/tksao/util/fuzzy.h @@ -0,0 +1,38 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __fuzzy_h__ +#define __fuzzy_h__ + +#include +#include +#include +using namespace std; + +#include + +inline void tzero(double* ff, const double epsilon= DBL_EPSILON) +{if (*ff>=-epsilon && *ff<=epsilon) *ff = 0;} + +inline bool teq(const double f1, const double f2, + const double epsilon= DBL_EPSILON) +{return f1-f2 >= -epsilon && f1-f2 <= epsilon;} + +inline bool tlt(const double f1, const double f2, + const double epsilon= DBL_EPSILON) +{return f1-f2 < -epsilon;} + +inline bool tle(const double f1, const double f2, + const double epsilon= DBL_EPSILON) +{return f1-f2 <= -epsilon; } + +inline bool tgt(const double f1, const double f2, + const double epsilon= DBL_EPSILON) +{return f1-f2 > epsilon;} + +inline bool tge(const double f1, const double f2, + const double epsilon= DBL_EPSILON) +{return f1-f2 >= epsilon;} + +#endif diff --git a/tksao/util/grf.C b/tksao/util/grf.C new file mode 100644 index 0000000..f4f98d7 --- /dev/null +++ b/tksao/util/grf.C @@ -0,0 +1,642 @@ +extern "C" { +#include "grf.h" +} + +#include "grid2dbase.h" +#include "grid25dbase.h" + +extern Grid2dBase* astGrid2dPtr; +extern Grid25dBase* astGrid25dPtr; + +/* + * Name: + * astGFlush + * + * Purpose: + * Flush all pending graphics to the output device + * + * Synopsis: + * #include "grf.h" + * int astGFlush( void ) + * + * Description: + * This function ensures that the display device is up-to-date, + * by flushing any pending graphics to the output device. + * + * Parameters: + * None + * + * Returned Value: + * A value of 0 is returned if an error occurrs, and 1 is returned + * otherwise + */ + +int astGFlush(void) +{ + if (astGrid2dPtr) + return astGrid2dPtr->gFlush(); + else if (astGrid25dPtr) + return astGrid25dPtr->gFlush(); + return 0; +} + +/* + * Name: + * astGLine + * + * Purpose: + * Draw a polyline (i.e. a set of connected lines) + * + * Synopsis: + * #include "grf.h" + * int astGLine( int n, const float *x, const float *y ) + * + * Description: + * This function displays lines joining the given positions + * + * Parameters: + * n + * The number of positions to be joined together + * x + * A pointer to an array holding the "n" x values + * y + * A pointer to an array holding the "n" y values + * + * Returned Value: + * A value of 0 is returned if an error occurrs, and 1 is returned + * otherwise + * + * Notes: + * - Nothing is done if "n" is less than 2, or if a NULL pointer is + * given for either "x" or "y" + */ + +int astGLine(int n, const float *x, const float *y) +{ + if (astGrid2dPtr) + return astGrid2dPtr->gLine(n, (float*)x, (float*)y); + else if (astGrid25dPtr) + return astGrid25dPtr->gLine(n, (float*)x, (float*)y); + return 0; +} + +/* + * Name: + * astGQch + * + * Purpose: + * Return the character height in world cooridnates + * + * Synopsis: + * #include "grf.h" + * int astGQch( float *chv, float *chh ) + * + * Description: + * This function returns the heights of characters drawn vertically and + * horizontally in world coordinates + * + * Parameters: + * chv + * A pointer to the double which is to receive the height of + * characters drawn vertically. This will be an increment in the X + * axis + * chh + * A pointer to the double which is to receive the height of + * characters drawn vertically. This will be an increment in the Y + * axis + * + * Returned Value: + * A value of 0 is returned if an error occurrs, and 1 is returned + * otherwise + */ + +int astGQch(float *chv, float *chh) +{ + if (astGrid2dPtr) + return astGrid2dPtr->gQch(chv, chh); + else if (astGrid25dPtr) + return astGrid25dPtr->gQch(chv, chh); + return 0; +} + +/* + * Name: + * astGMark + * + * Purpose: + * Draw a set of markers + * + * Synopsis: + * #include "grf.h" + * int astGMark( int n, const float *x, const float *y, int type ) + * + * Description: + * This function displays markers at the given positions + * + * Parameters: + * n + * The number of markers to draw + * x + * A pointer to an array holding the "n" x values + * y + * A pointer to an array holding the "n" y values + * type + * An integer which can be used to indicate the type of marker symbol + * required + * + * Returned Value: + * A value of 0 is returned if an error occurrs, and 1 is returned + * otherwise + * + * Notes: + * - Nothing is done if "n" is less than 1, or if a NULL pointer is + * given for either "x" or "y" + * + */ + +int astGMark(int n, const float *x, const float *y, int type) +{ + if (astGrid2dPtr) + return astGrid2dPtr->gMark(n, x, y, type); + else if (astGrid25dPtr) + return astGrid25dPtr->gMark(n, x, y, type); + return 0; +} + +/* + * Name: + * astGText + * + * Purpose: + * Draw a character string + * + * Synopsis: + * #include "grf.h" + * int astGText( const char *text, float x, float y, const char *just, + * float upx, float upy ) + * + * Description: + * This function displays a character string at a given position + * using a specified justification and up-vector + * + * Parameters: + * text + * Pointer to a null-terminated character string to be displayed + * x + * The reference x coordinate + * y + * The reference y coordinate + * just + * A character string which specifies the location within the + * text string which is to be placed at the reference position + * given by x and y. The first character may be 'T' for "top", + * 'C' for "centre", or 'B' for "bottom", and specifies the + * vertical location of the reference position. Note, "bottom" + * corresponds to the base-line of normal text. Some characters + * (eg "y", "g", "p", etc) descend below the base-line. The second + * character may be 'L' for "left", 'C' for "centre", or 'R' + * for "right", and specifies the horizontal location of the + * reference position. If the string has less than 2 characters + * then 'C' is used for the missing characters + * upx + * The x component of the up-vector for the text, in graphics world + * coordinates. If necessary the supplied value should be negated + * to ensure that positive values always refer to displacements from + * left to right on the screen + * upy + * The y component of the up-vector for the text, in graphics world + * coordinates. If necessary the supplied value should be negated + * to ensure that positive values always refer to displacements from + * bottom to top on the screen + * + * Returned Value: + * A value of 0 is returned if an error occurrs, and 1 is returned + * otherwise + * + * Notes: + * - Any graphics within the rotated box enclosing the text are erased + * - A NULL value for "just" causes a value of "CC" to be used + * - Both "upx" and "upy" being zero causes an error + * - Any unrecognised character in "just" causes an error + */ + +int astGText(const char *text, float x, float y, const char *just, + float upx, float upy) +{ + if (astGrid2dPtr) + return astGrid2dPtr->gText(text, x ,y, just, upx, upy); + else if (astGrid25dPtr) + return astGrid25dPtr->gText(text, x ,y, just, upx, upy); + return 0; +} + +/* +* Name: +* astGTxExt +* +* Purpose: +* Get the extent of a character string +* +* Synopsis: +* #include "grf.h" +* int astGTxExt( const char *text, float x, float y, const char *just, +* float upx, float upy, float *xb, float *yb ) +* +* Description: +* This function returns the corners of a box which would enclose the +* supplied character string if it were displayed using astGText +* +* The returned box INCLUDES any leading or trailing spaces +* +* Parameters: +* text +* Pointer to a null-terminated character string to be displayed +* x +* The reference x coordinate +* y +* The reference y coordinate +* just +* A character string which specifies the location within the +* text string which is to be placed at the reference position +* given by x and y. The first character may be 'T' for "top", +* 'C' for "centre", or 'B' for "bottom", and specifies the +* vertical location of the reference position. Note, "bottom" +* corresponds to the base-line of normal text. Some characters +* (eg "y", "g", "p", etc) descend below the base-line. The second +* character may be 'L' for "left", 'C' for "centre", or 'R' +* for "right", and specifies the horizontal location of the +* reference position. If the string has less than 2 characters +* then 'C' is used for the missing characters +* upx +* The x component of the up-vector for the text, in graphics world +* coordinates. If necessary the supplied value should be negated +* to ensure that positive values always refer to displacements from +* left to right on the screen +* upy +* The y component of the up-vector for the text, in graphics world +* coordinates. If necessary the supplied value should be negated +* to ensure that positive values always refer to displacements from +* bottom to top on the screen +* xb +* An array of 4 elements in which to return the x coordinate of +* each corner of the bounding box +* yb +* An array of 4 elements in which to return the y coordinate of +* each corner of the bounding box +* +* Returned Value: +* A value of 0 is returned if an error occurrs, and 1 is returned +* otherwise +* +* Notes: +* - The order of the corners is anti-clockwise (in world coordinates) +* starting at the bottom left +* - A NULL value for "just" causes a value of "CC" to be used +* - Both "upx" and "upy" being zero causes an error +* - Any unrecognised character in "just" causes an error +* - Zero is returned for all bounds of the box if an error occurs +*/ + +int astGTxExt(const char *text, float x, float y, const char *just, + float upx, float upy, float *xb, float *yb) +{ + if (astGrid2dPtr) + return astGrid2dPtr->gTxExt(text, x, y, just, upx, upy, xb, yb); + else if (astGrid25dPtr) + return astGrid25dPtr->gTxExt(text, x, y, just, upx, upy, xb, yb); + return 0; +} + +/* + * Name: + * astGAttr + * + * Purpose: + * Enquire or set a graphics attribute value + * + * Synopsis: + * #include "grf.h" + * int int astGAttr( int attr, double value, double *old_value, int prim ) + * + * Description: + * This function returns the current value of a specified graphics + * attribute, and optionally establishes a new value. The supplied + * value is converted to an integer value if necessary before use + * + * Parameters: + * attr + * An integer value identifying the required attribute. The + * following symbolic values are defined in grf.h: + * + * GRF__STYLE - Line style + * GRF__WIDTH - Line width + * GRF__SIZE - Character and marker size scale factor + * GRF__FONT - Character font + * GRF__COLOUR - Colour index + * value + * A new value to store for the attribute. If this is AST__BAD + * no value is stored + * old_value + * A pointer to a double in which to return the attribute value + * If this is NULL, no value is returned + * prim + * The sort of graphics primative to be drawn with the new attribute + * Identified by the following values defined in grf.h: + * GRF__LINE + * GRF__MARK + * GRF__TEXT + * + * Returned Value: + * A value of 0 is returned if an error occurrs, and 1 is returned + * otherwise + * + * Notes: + */ + +int astGAttr(int attr, double value, double *old, int prim) +{ + if (astGrid2dPtr) + return astGrid2dPtr->gAttr(attr, value, old, prim); + else if (astGrid25dPtr) + return astGrid25dPtr->gAttr(attr, value, old, prim); + return 0; +} + +/* +* Name: +* astGScales +* +* Purpose: +* Get the axis scales. +* +* Synopsis: +* #include "grf.h" +* int astGScales( float *alpha, float *beta ) +* +* Description: +* This function returns two values (one for each axis) which scale +* increments on the corresponding axis into a "normal" coordinate +* system in which: +* 1 - The axes have equal scale in terms of (for instance) +* millimetres per unit distance. +* 2 - X values increase from left to right. +* 3 - Y values increase from bottom to top. +* +* Parameters: +* alpha +* A pointer to the location at which to return the scale for the +* X axis (i.e. Xnorm = alpha*Xworld). +* beta +* A pointer to the location at which to return the scale for the +* Y axis (i.e. Ynorm = beta*Yworld). +* +* Returned Value: +* A value of 0 is returned if an error occurs, and 1 is returned +* otherwise. +*/ + +int astGScales(float *alpha, float *beta) +{ + if (astGrid2dPtr) + return astGrid2dPtr->gScales(alpha,beta); + else if (astGrid25dPtr) + return astGrid25dPtr->gScales(alpha,beta); + return 0; +} + +/* +* Name: +* astGCap +* +* Purpose: +* Indicate if this grf module has a given capability. +* +* Synopsis: +* #include "grf.h" +* int astGCap( int cap, int value ) +* +* Description: +* This function is called by the AST Plot class to determine if the +* grf module has a given capability, as indicated by the "cap" +* argument. +* +* Parameters: +* cap +* The capability being inquired about. This will be one of the +* following constants defined in grf.h: +* +* GRF__SCALES: This function should return a non-zero value if +* it implements the astGScales function, and zero otherwise. The +* supplied "value" argument should be ignored. +* +* GRF__MJUST: This function should return a non-zero value if +* the astGText and astGTxExt functions recognise "M" as a +* character in the justification string. If the first character of +* a justification string is "M", then the text should be justified +* with the given reference point at the bottom of the bounding box. +* This is different to "B" justification, which requests that the +* reference point be put on the baseline of the text, since some +* characters hang down below the baseline. If the astGText or +* astGTxExt function cannot differentiate between "M" and "B", +* then this function should return zero, in which case "M" +* justification will never be requested by Plot. The supplied +* "value" argument should be ignored. +* +* GRF__ESC: This function should return a non-zero value if the +* astGText and astGTxExt functions can recognise and interpret +* graphics escape sequences within the supplied string. These +* escape sequences are described below. Zero should be returned +* if escape sequences cannot be interpreted (in which case the +* Plot class will interpret them itself if needed). The supplied +* "value" argument should be ignored only if escape sequences cannot +* be interpreted by astGText and astGTxExt. Otherwise, "value" +* indicates whether astGText and astGTxExt should interpret escape +* sequences in subsequent calls. If "value" is non-zero then +* escape sequences should be interpreted by astGText and +* astGTxExt. Otherwise, they should be drawn as literal text. +* +* Returned Value: +* The return value, as described above. Zero should be returned if +* the supplied capability is not recognised. +* +* Escape Sequences: +* Escape sequences are introduced into the text string by a percent +* "%" character. The following escape sequences are currently recognised +* ("..." represents a string of one or more decimal digits): +* +* %% - Print a literal "%" character (type GRF__ESPER ). +* +* %^...+ - Draw subsequent characters as super-scripts. The digits +* "..." give the distance from the base-line of "normal" +* text to the base-line of the super-script text, scaled +* so that a value of "100" corresponds to the height of +* "normal" text (type GRF__ESSUP ). +* %^+ - Draw subsequent characters with the normal base-line. +* +* %v...+ - Draw subsequent characters as sub-scripts. The digits +* "..." give the distance from the base-line of "normal" +* text to the base-line of the sub-script text, scaled +* so that a value of "100" corresponds to the height of +* "normal" text (type GRF__ESSUB ). +* +* %v+ - Draw subsequent characters with the normal base-line +* (equivalent to %^+). +* +* %>...+ - Leave a gap before drawing subsequent characters. +* The digits "..." give the size of the gap, scaled +* so that a value of "100" corresponds to the height of +* "normal" text (type GRF__ESGAP ). +* +* %<...+ - Move backwards before drawing subsequent characters. +* The digits "..." give the size of the movement, scaled +* so that a value of "100" corresponds to the height of +* "normal" text (type GRF_ESBAC). +* +* %s...+ - Change the Size attribute for subsequent characters. The +* digits "..." give the new Size as a fraction of the +* "normal" Size, scaled so that a value of "100" corresponds +* to 1.0 (type GRF__ESSIZ ). +* +* %s+ - Reset the Size attribute to its "normal" value. +* +* %w...+ - Change the Width attribute for subsequent characters. The +* digits "..." give the new width as a fraction of the +* "normal" Width, scaled so that a value of "100" corresponds +* to 1.0 (type GRF__ESWID ). +* +* %w+ - Reset the Size attribute to its "normal" value. +* +* %f...+ - Change the Font attribute for subsequent characters. The +* digits "..." give the new Font value (type GRF__ESFON ). +* +* %f+ - Reset the Font attribute to its "normal" value. +* +* %c...+ - Change the Colour attribute for subsequent characters. The +* digits "..." give the new Colour value (type GRF__ESCOL ). +* +* %c+ - Reset the Colour attribute to its "normal" value. +* +* %t...+ - Change the Style attribute for subsequent characters. The +* digits "..." give the new Style value (type GRF__ESSTY ). +* +* %t+ - Reset the Style attribute to its "normal" value. +* +* %- - Push the current graphics attribute values onto the top of +* the stack - see "%+" (type GRF__ESPSH). +* +* %+ - Pop attributes values of the top the stack - see "%-". If +* the stack is empty, "normal" attribute values are restored +* (type GRF__ESPOP). +* +* The astFindEscape function (in libast.a) can be used to locate escape +* sequences within a text string. It has the following signature: +* +* #include "plot.h" +* int astFindEscape( const char *text, int *type, int *value, int *nc ) +* +* Parameters: +* text +* Pointer to the string to be checked. +* type +* Pointer to a location at which to return the type of escape +* sequence. Each type is identified by a symbolic constant defined +* in grf.h and is indicated in the above section. The returned value +* is undefined if the supplied text does not begin with an escape +* sequence. +* value +* Pointer to a lcation at which to return the integer value +* associated with the escape sequence. All usable values will be +* positive. Zero is returned if the escape sequence has no associated +* integer. A value of -1 indicates that the attribute identified by +* "type" should be reset to its "normal" value (as established using +* the astGAttr function, etc). The returned value is undefined if +* the supplied text does not begin with an escape sequence. +* nc +* Pointer to a location at which to return the number of +* characters read by this call. If the text starts with an escape +* sequence, the returned value will be the number of characters in +* the escape sequence. Otherwise, the returned value will be the +* number of characters prior to the first escape sequence, or the +* length of the supplied text if no escape sequence is found. +* +* Returned Value: +* A non-zero value is returned if the supplied text starts with a +* graphics escape sequence, and zero is returned otherwise. +*/ + +int astGCap(int cap, int value) +{ + if (astGrid2dPtr) + return astGrid2dPtr->gCap(cap,value); + else if (astGrid25dPtr) + return astGrid25dPtr->gCap(cap,value); + return 0; +} + +/* +* Name: +* astGBBuf +* +* Purpose: +* Start a new graphics buffering context. +* +* Synopsis: +* #include "grf.h" +* int astGBBuf( void ) +* +* Description: +* This function begins saving graphical output commands in an +* internal buffer; the commands are held until a matching astGEBuf +* call (or until the buffer is emptied by astGFlush). This can +* greatly improve the efficiency of some graphics systems. astGBBuf +* increments an internal counter, while astGEBuf decrements this +* counter and flushes the buffer to the output device when the +* counter drops to zero. astGBBuf and astGEBuf calls should always +* be paired. +* +* Parameters: +* None. +* +* Returned Value: +* A value of 0 is returned if an error occurs, and 1 is returned +* otherwise. +* +*/ + +int astGBBuf(void) +{ + return 1; +} + +/* +* Name: +* astGEBuf +* +* Purpose: +* End a graphics buffering context. +* +* Synopsis: +* #include "grf.h" +* int astGEBuf( void ) +* +* Description: +* This function marks the end of a batch of graphical output begun +* with the last call of astGBBuf. astGBBuf and astGEBUF calls should +* always be paired. Each call to astGBBuf increments a counter, while +* each call to astGEBuf decrements the counter. When the counter +* reaches 0, the batch of output is written on the output device. +* +* Parameters: +* None. +* +* Returned Value: +* A value of 0 is returned if an error occurs, and 1 is returned +* otherwise. +* +*/ + +int astGEBuf(void) +{ + return 1; +} + diff --git a/tksao/util/grf3d.C b/tksao/util/grf3d.C new file mode 100644 index 0000000..c6381a7 --- /dev/null +++ b/tksao/util/grf3d.C @@ -0,0 +1,516 @@ +extern "C" { +#include "grf3d.h" +} + +#include "grid3dbase.h" + +extern Grid3dBase* astGrid3dPtr; + +/* +* Name: +* astG3DCap +* +* Purpose: +* Indicate if this grf3d module has a given capability. +* +* Synopsis: +* #include "grf3d.h" +* int astG3DCap( int cap, int value ) +* +* Description: +* This function is called by the AST Plot class to determine if the +* grf3d module has a given capability, as indicated by the "cap" +* argument. +* +* Parameters: +* cap +* The capability being inquired about. This will be one of the +* following constants defined in grf3d.h: +* +* GRF3D__ESC: This function should return a non-zero value if the +* astG3DText and astG3DTxExt functions can recognise and interpret +* graphics escape sequences within the supplied string. These +* escape sequences are described below. Zero should be returned +* if escape sequences cannot be interpreted (in which case the +* Plot class will interpret them itself if needed). The supplied +* "value" argument should be ignored only if escape sequences cannot +* be interpreted by astG3DText and astG3DTxExt. Otherwise, "value" +* indicates whether astG3DText and astG3DTxExt should interpret escape +* sequences in subsequent calls. If "value" is non-zero then +* escape sequences should be interpreted by astG3DText and +* astG3DTxExt. Otherwise, they should be drawn as literal text. +* +* Returned Value: +* The return value, as described above. Zero should be returned if +* the supplied capability is not recognised. +* +* Escape Sequences: +* Escape sequences are introduced into the text string by a percent +* "%" character. The following escape sequences are currently recognised +* ("..." represents a string of one or more decimal digits): +* +* %% - Print a literal "%" character (type GRF__ESPER ). +* +* %^...+ - Draw subsequent characters as super-scripts. The digits +* "..." give the distance from the base-line of "normal" +* text to the base-line of the super-script text, scaled +* so that a value of "100" corresponds to the height of +* "normal" text (type GRF__ESSUP ). +* %^+ - Draw subsequent characters with the normal base-line. +* +* %v...+ - Draw subsequent characters as sub-scripts. The digits +* "..." give the distance from the base-line of "normal" +* text to the base-line of the sub-script text, scaled +* so that a value of "100" corresponds to the height of +* "normal" text (type GRF__ESSUB ). +* +* %v+ - Draw subsequent characters with the normal base-line +* (equivalent to %^+). +* +* %>...+ - Leave a gap before drawing subsequent characters. +* The digits "..." give the size of the gap, scaled +* so that a value of "100" corresponds to the height of +* "normal" text (type GRF__ESGAP ). +* +* %<...+ - Move backwards before drawing subsequent characters. +* The digits "..." give the size of the movement, scaled +* so that a value of "100" corresponds to the height of +* "normal" text (type GRF_ESBAC). +* +* %s...+ - Change the Size attribute for subsequent characters. The +* digits "..." give the new Size as a fraction of the +* "normal" Size, scaled so that a value of "100" corresponds +* to 1.0 (type GRF__ESSIZ ). +* +* %s+ - Reset the Size attribute to its "normal" value. +* +* %w...+ - Change the Width attribute for subsequent characters. The +* digits "..." give the new width as a fraction of the +* "normal" Width, scaled so that a value of "100" corresponds +* to 1.0 (type GRF__ESWID ). +* +* %w+ - Reset the Size attribute to its "normal" value. +* +* %f...+ - Change the Font attribute for subsequent characters. The +* digits "..." give the new Font value (type GRF__ESFON ). +* +* %f+ - Reset the Font attribute to its "normal" value. +* +* %c...+ - Change the Colour attribute for subsequent characters. The +* digits "..." give the new Colour value (type GRF__ESCOL ). +* +* %c+ - Reset the Colour attribute to its "normal" value. +* +* %t...+ - Change the Style attribute for subsequent characters. The +* digits "..." give the new Style value (type GRF__ESSTY ). +* +* %t+ - Reset the Style attribute to its "normal" value. +* +* %- - Push the current graphics attribute values onto the top of +* the stack - see "%+" (type GRF__ESPSH). +* +* %+ - Pop attributes values of the top the stack - see "%-". If +* the stack is empty, "normal" attribute values are restored +* (type GRF__ESPOP). +* +* The astFindEscape function (in libast.a) can be used to locate escape +* sequences within a text string. It has the following signature: +* +* #include "plot.h" +* int astFindEscape( const char *text, int *type, int *value, int *nc ) +* +* Parameters: +* text +* Pointer to the string to be checked. +* type +* Pointer to a location at which to return the type of escape +* sequence. Each type is identified by a symbolic constant defined +* in grf.h and is indicated in the above section. The returned value +* is undefined if the supplied text does not begin with an escape +* sequence. +* value +* Pointer to a lcation at which to return the integer value +* associated with the escape sequence. All usable values will be +* positive. Zero is returned if the escape sequence has no associated +* integer. A value of -1 indicates that the attribute identified by +* "type" should be reset to its "normal" value (as established using +* the astG3DAttr function, etc). The returned value is undefined if +* the supplied text does not begin with an escape sequence. +* nc +* Pointer to a location at which to return the number of +* characters read by this call. If the text starts with an escape +* sequence, the returned value will be the number of characters in +* the escape sequence. Otherwise, the returned value will be the +* number of characters prior to the first escape sequence, or the +* length of the supplied text if no escape sequence is found. +* +* Returned Value: +* A non-zero value is returned if the supplied text starts with a +* graphics escape sequence, and zero is returned otherwise. +* +*/ + +int astG3DCap(int cap, int value) +{ + if (astGrid3dPtr) + return astGrid3dPtr->gCap(cap, value); + return 0; +} + +/* +* Name: +* astG3DFlush +* +* Purpose: +* Flush all pending graphics to the output device. +* +* Synopsis: +* #include "grf3d.h" +* int astG3DFlush( void ) +* +* Description: +* This function ensures that the display device is up-to-date, +* by flushing any pending graphics to the output device. +* +* Parameters: +* None. +* +* Returned Value: +* A value of 0 is returned if an error occurs, and 1 is returned +* otherwise. +* +*/ + +int astG3DFlush(void) +{ + if (astGrid3dPtr) + return astGrid3dPtr->gFlush(); + return 0; +} + +/* +* Name: +* astG3DLine +* +* Purpose: +* Draw a polyline (i.e. a set of connected lines). +* +* Synopsis: +* #include "grf3d.h" +* int astG3DLine( int n, float *x, float *y, float *z ) +* +* Description: +* This function displays lines joining the given positions. +* +* Parameters: +* n +* The number of positions to be joined together. +* x +* A pointer to an array holding the "n" x values. +* y +* A pointer to an array holding the "n" y values. +* z +* A pointer to an array holding the "n" z values. +* +* Returned Value: +* A value of 0 is returned if an error occurs, and 1 is returned +* otherwise. +* +* Notes: +* - A camera must have been established prior to calling this +* function using either astG3DSetCamera or astG3DAutoCamera. +* - Nothing is done if "n" is less than 2, or if a NULL pointer is +* given for either "x", "y" or "z". +* +*/ + +int astG3DLine(int n, float *x, float *y, float *z) +{ + if (astGrid3dPtr) + return astGrid3dPtr->gLine(n, x, y, z); + return 0; +} + +/* +* Name: +* astG3DQch +* +* Purpose: +* Return the character height in world coordinates. +* +* Synopsis: +* #include "grf3d.h" +* int astG3DQch( float *ch ) +* +* Description: +* This function returns the height of characters drawn using astG3DText. +* +* Parameters: +* ch +* A pointer to the double which is to receive the height of +* characters drawn with astG3DText. +* +* Returned Value: +* A value of 0 is returned if an error occurs, and 1 is returned +* otherwise. +* +* Notes: +* - Since the 3D world coordinate axes are assumed to be equally +* scaled, the height of text in world coordinate units is independent +* of the orientation of the text. Therefore, this function returns +* only one height value, unlike the equivalent 2D astGQch function +* that returns two heights. +*/ + +int astG3DQch(float *ch) +{ + if (astGrid3dPtr) + return astGrid3dPtr->gQch(ch); + return 0; +} + +/* +* Name: +* astG3DMark +* +* Purpose: +* Draw a set of markers. +* +* Synopsis: +* #include "grf.h" +* int astG3DMark( int n, float *x, float *y, float *z, int type, +* float norm[3] ) +* +* Description: +* This function draws markers centred at the given positions, on a +* plane with a specified normal vector. +* +* Parameters: +* n +* The number of markers to draw. +* x +* A pointer to an array holding the "n" x values. +* y +* A pointer to an array holding the "n" y values. +* z +* A pointer to an array holding the "n" z values. +* type +* An integer which can be used to indicate the type of marker symbol +* required. See the description of routine PGPT in the PGPLOT manual. +* norm +* The (x,y,z) components of a vector that is normal to the plane +* containing the marker. The given vector passes through the marker +* from the back to the front. If all components of this vector are +* zero, then a normal vector pointing from the position of the +* first marker towards the camera eye is used. +* +* Returned Value: +* A value of 0 is returned if an error occurs, and 1 is returned +* otherwise. +* +* Notes: +* - Nothing is done if "n" is less than 1, or if a NULL pointer is +* given for "x", "y" or "z". +* +*/ + +int astG3DMark(int n, float *x, float *y, float *z, int type, float norm[3]) +{ + if (astGrid3dPtr) + return astGrid3dPtr->gMark(n, x, y, z, type, norm); + return 0; +} + +/* +* Name: +* astG3DText +* +* Purpose: +* Draw a character string. +* +* Synopsis: +* #include "grf3d.h" +* int astG3DText( const char *text, float ref[3], const char *just, +* float up[3], float norm[3] ) +* +* Description: +* This function displays a character string at a given position +* on a given plane in 3D world coords, using a specified +* justification and up-vector. +* +* Parameters: +* text +* Pointer to a null-terminated character string to be displayed. +* ref +* The reference (x,y,z) coordinates. +* just +* A character string which specifies the location within the +* text string which is to be placed at the reference position +* given by x and y. The first character may be 'T' for "top", +* 'C' for "centre", or 'B' for "bottom", and specifies the +* vertical location of the reference position. Note, "bottom" +* corresponds to the base-line of normal text. Some characters +* (eg "y", "g", "p", etc) descend below the base-line. The second +* character may be 'L' for "left", 'C' for "centre", or 'R' +* for "right", and specifies the horizontal location of the +* reference position. If the string has less than 2 characters +* then 'C' is used for the missing characters. +* up +* The (x,y,z) up-vector for the text. The actual up vector used is +* the projection of the supplied vector onto the plane specified by +* "norm". +* norm +* The (x,y,z) components of a vector that is normal to the plane +* containing the text. The given vector passes through the text +* from the back to the front. If all components of this vector are +* zero, then a normal vector pointing towards the camera eye is used. +* +* Returned Value: +* A value of 0 is returned if an error occurs, and 1 is returned +* otherwise. +* +* Notes: +* - This routine does not recognise PGPLOT escape sequences. +* - A NULL value for "just" causes a value of "CC" to be used. +*/ + +int astG3DText(const char *text, float ref[3], const char *just, + float up[3], float norm[3] ) +{ + if (astGrid3dPtr) + return astGrid3dPtr->gText(text, ref, just, up, norm); + return 0; +} + +/* +* Name: +* astG3DTxExt +* +* Purpose: +* Get the extent of a character string. +* +* Synopsis: +* #include "grf3d.h" +* int astG3DTxExt( const char *text, float ref[3], const char *just, +* float up[3], float norm[3], float *xb, float *yb, +* float *zb, float bl[3] ) +* +* Description: +* This function returns the corners of a box which would enclose the +* supplied character string if it were displayed using astG3DText. +* +* The returned box INCLUDES any leading or trailing spaces. +* +* Parameters: +* text +* Pointer to a null-terminated character string to be displayed. +* ref +* The reference (x,y,z) coordinates. +* just +* A character string which specifies the location within the +* text string which is to be placed at the reference position +* given by x and y. The first character may be 'T' for "top", +* 'C' for "centre", 'B' for "baseline", or "M" for "bottom", and +* specifies the vertical location of the reference position. Note, +* "baseline" corresponds to the base-line of normal text. Some +* characters (eg "y", "g", "p", etc) descend below the base-line, +* and so "M" and "B" will produce different effects for such +* characters. The second character may be 'L' for "left", 'C' for +* "centre", or 'R' for "right", and specifies the horizontal +* location of the reference position. If the string has less than +* 2 characters then 'C' is used for the missing characters. +* up +* The (x,y,z) up-vector for the text. The actual up vector used is +* the projection of the supplied vector onto the plane specified by +* "norm". +* norm +* The (x,y,z) components of a vector that is normal to the plane +* containing the text. The given vector passes through the text +* from the back to the front. If all components of this vector are +* zero, then a normal vector pointing towards the camera eye is used. +* xb +* An array of 4 elements in which to return the x coordinate of +* each corner of the bounding box. +* yb +* An array of 4 elements in which to return the y coordinate of +* each corner of the bounding box. +* zb +* An array of 4 elements in which to return the z coordinate of +* each corner of the bounding box. +* bl +* The 3D world coordinates at the left hand end of the text +* baseline. +* +* Returned Value: +* A value of 0 is returned if an error occurs, and 1 is returned +* otherwise. +* +* Notes: +* - The order of the corners is anti-clockwise starting at the +* bottom left when viewing the text normally (i.e. face on). +* - This routine does not recognise PGPLOT escape sequences. +* - A NULL value for "just" causes a value of "CC" to be used. +*/ + +int astG3DTxExt(const char *text, float ref[3], const char *just, + float up[3], float norm[3], float *xb, float *yb, + float *zb, float bl[3]) +{ + if (astGrid3dPtr) + return astGrid3dPtr->gTxExt(text, ref, just, up, norm, xb, yb, zb, bl); + return 0; +} + +/* +* Name: +* astG3DAttr +* +* Purpose: +* Enquire or set a 3D graphics attribute value. +* +* Synopsis: +* #include "grf3d.h" +* int int astG3DAttr( int attr, double value, double *old_value, int prim ) +* +* Description: +* This function returns the current value of a specified 3D graphics +* attribute, and optionally establishes a new value. The supplied +* value is converted to an integer value if necessary before use. +* +* Parameters: +* attr +* An integer value identifying the required attribute. The +* following symbolic values are defined in grf3d.h: +* +* GRF__STYLE - Line style. +* GRF__WIDTH - Line width. +* GRF__SIZE - Character and marker size scale factor. +* GRF__FONT - Character font. +* GRF__COLOUR - Colour index. +* value +* A new value to store for the attribute. If this is AST__BAD +* no value is stored. +* old_value +* A pointer to a double in which to return the attribute value. +* If this is NULL, no value is returned. +* prim +* The sort of graphics primitive to be drawn with the new attribute. +* Identified by the following values defined in grf.h: +* GRF__LINE +* GRF__MARK +* GRF__TEXT +* +* Returned Value: +* A value of 0 is returned if an error occurs, and 1 is returned +* otherwise. +* +* Notes: +* +*/ + +int astG3DAttr(int attr, double value, double *old_value, int prim) +{ + if (astGrid3dPtr) + return astGrid3dPtr->gAttr(attr, value, old_value, prim); + return 0; +} diff --git a/tksao/util/grid25dbase.C b/tksao/util/grid25dbase.C new file mode 100644 index 0000000..95faf7f --- /dev/null +++ b/tksao/util/grid25dbase.C @@ -0,0 +1,191 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "grid25dbase.h" +#include "attribute.h" +#include "widget.h" +#include "frame3dbase.h" + +extern "C" { + #include "ast.h" + #include "grf.h" +} + +Grid25dBase* astGrid25dPtr = NULL; + +Grid25dBase::Grid25dBase(Widget* p) : GridBase(p) +{} + +Grid25dBase::Grid25dBase(Widget* p, const char* o) : GridBase(p,o) +{} + +Grid25dBase::~Grid25dBase() +{} + +int Grid25dBase::gLine(int n, float* x, float* y) +{ + Frame3dBase* pp = (Frame3dBase*)parent_; + float xx[n]; + float yy[n]; + + for (int ii=0; iimapFromRef(Vector(x[ii],y[ii]),Coord::WIDGET); + xx[ii] = vv[0]; + yy[ii] = vv[1]; + } + + switch (renderMode_) { + case X11: + x11Line(n,xx,yy); + break; + case PS: + psLine(n,xx,yy); + break; + case MACOSX: +#ifdef MAC_OSX_TK + macosxLine(n,xx,yy); +#endif + break; + case GWIN32: +#ifdef __WIN32 + win32Line(n,xx,yy); +#endif + break; + } + + return 1; +} + +int Grid25dBase::gQch(float* chv, float* chh) +{ + Tk_Font font =NULL; + switch (renderMode_) { + case X11: + font = text_->tkfont(); + break; + case PS: + font = text_->psfont(); + break; + case MACOSX: +#ifdef MAC_OSX_TK + font = text_->tkfont(); +#endif + break; + case GWIN32: +#ifdef __WIN32 + font = text_->tkfont(); +#endif + break; + } + + if (font) { + Tk_FontMetrics metrics; + Tk_GetFontMetrics(font, &metrics); + + *chv = (float)metrics.linespace; + *chh = (float)metrics.linespace; + return 1; + } + else { + *chv = *chh = 0; + return 0; + } +} + +int Grid25dBase::gText(const char* txt, float x, float y, const char* just, + float upx, float upy) +{ + if (!(txt && txt[0] && just && just[0] && just[1])) + return 0; + + Frame3dBase* pp = (Frame3dBase*)parent_; + Vector vv = pp->mapFromRef(Vector(x,y),Coord::WIDGET); + + switch (renderMode_) { + case X11: + return x11Text(txt,vv[0],vv[1],just,Vector(0,1)); + case PS: + return psText(txt,vv[0],vv[1],just,Vector(0,1)); + case MACOSX: +#ifdef MAC_OSX_TK + return macosxText(txt,vv[0],vv[1],just,Vector(0,1)); +#endif + break; + case GWIN32: +#ifdef __WIN32 + return win32Text(txt,vv[0],vv[1],just,Vector(0,1)); +#endif + break; + } + + return 0; +} + +int Grid25dBase::gTxExt(const char* txt, float x, float y, const char* just, + float upx, float upy, float* xb, float* yb) +{ + if (!(txt && txt[0] && just)) { + xb[0] = xb[1] = xb[2] = xb[3] = 0; + yb[0] = yb[1] = yb[2] = yb[3] = 0; + + return 0; + } + + Tk_Font font =NULL; + + switch (renderMode_) { + case X11: + font = text_->tkfont(); + break; + case PS: + font = text_->psfont(); + break; + case MACOSX: +#ifdef MAC_OSX_TK + font = text_->tkfont(); +#endif + break; + case GWIN32: +#ifdef __WIN32 + font = text_->tkfont(); +#endif + break; + } + + if (!font) + return 0; + + Frame3dBase* pp = (Frame3dBase*)parent_; + Vector vv = pp->mapFromRef(Vector(x,y),Coord::WIDGET); + + double angle = 0; + Vector cc = vv * calcTextPos(vv, angle, txt, just, Vector(0, 1), font); + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(font, &metrics); + int width = Tk_TextWidth(font, txt, strlen(txt)); + + BBox nn = BBox(Vector(0,-metrics.descent), Vector(width,metrics.ascent)); + BBox bb = nn * Rotate(angle) * Translate(cc); + + xb[0] = bb.ll[0]; + yb[0] = bb.ll[1]; + + xb[1] = bb.ur[0]; + yb[1] = bb.ll[1]; + + xb[2] = bb.ur[0]; + yb[2] = bb.ur[1]; + + xb[3] = bb.ll[0]; + yb[3] = bb.ur[1]; + + return 1; +} + +int Grid25dBase::gScales(float* alpha, float* beta) +{ + return 1; +} + diff --git a/tksao/util/grid25dbase.h b/tksao/util/grid25dbase.h new file mode 100644 index 0000000..adfe844 --- /dev/null +++ b/tksao/util/grid25dbase.h @@ -0,0 +1,26 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __grid25dbase_h__ +#define __grid25dbase_h__ + +#include "gridbase.h" + +class Grid25dBase : public GridBase { + public: + Grid25dBase(Widget*); + Grid25dBase(Widget*, const char*); + virtual ~Grid25dBase(); + + int gLine(int n, float* x, float* y); + int gQch(float*, float*); + int gMark(int, const float*, const float*, int) {return 1;} + int gText(const char* txt, float x, float y, const char* just, + float upx, float upy); + int gTxExt(const char*, float, float, const char*, + float, float, float*, float*); + int gScales(float *alpha, float *beta); +}; + +#endif diff --git a/tksao/util/grid2dbase.C b/tksao/util/grid2dbase.C new file mode 100644 index 0000000..606b592 --- /dev/null +++ b/tksao/util/grid2dbase.C @@ -0,0 +1,175 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "grid2dbase.h" +#include "attribute.h" +#include "widget.h" + +extern "C" { + #include "ast.h" + #include "grf.h" +} + +Grid2dBase* astGrid2dPtr = NULL; + +Grid2dBase::Grid2dBase(Widget* p) : GridBase(p) +{} + +Grid2dBase::Grid2dBase(Widget* p, const char* o) : GridBase(p,o) +{} + +Grid2dBase::~Grid2dBase() +{} + +int Grid2dBase::gLine(int n, float* x, float* y) +{ + switch (renderMode_) { + case X11: + x11Line(n,x,y); + break; + case PS: + psLine(n,x,y); + break; + case MACOSX: +#ifdef MAC_OSX_TK + macosxLine(n,x,y); +#endif + break; + case GWIN32: +#ifdef __WIN32 + win32Line(n,x,y); +#endif + break; + } + + return 1; +} + +int Grid2dBase::gQch(float* chv, float* chh) +{ + Tk_Font font =NULL; + switch (renderMode_) { + case X11: + font = text_->tkfont(); + break; + case PS: + font = text_->psfont(); + break; + case MACOSX: +#ifdef MAC_OSX_TK + font = text_->tkfont(); +#endif + break; + case GWIN32: +#ifdef __WIN32 + font = text_->tkfont(); +#endif + break; + } + + if (font) { + Tk_FontMetrics metrics; + Tk_GetFontMetrics(font, &metrics); + + *chv = (float)metrics.linespace; + *chh = (float)metrics.linespace; + return 1; + } + else { + *chv = *chh = 0; + return 0; + } +} + +int Grid2dBase::gText(const char* txt, float x, float y, const char* just, + float upx, float upy) +{ + if (!(txt && txt[0] && just && just[0] && just[1])) + return 0; + + switch (renderMode_) { + case X11: + return x11Text(txt,x,y,just,Vector(upx,upy)); + case PS: + return psText(txt,x,y,just,Vector(upx,upy)); + case MACOSX: +#ifdef MAC_OSX_TK + return macosxText(txt,x,y,just,Vector(upx,upy)); +#endif + break; + case GWIN32: +#ifdef __WIN32 + return win32Text(txt,x,y,just,Vector(upx,upy)); +#endif + break; + } + + return 0; +} + +int Grid2dBase::gTxExt(const char* txt, float x, float y, const char* just, + float upx, float upy, float* xb, float* yb) +{ + if (!(txt && txt[0] && just)) { + xb[0] = xb[1] = xb[2] = xb[3] = 0; + yb[0] = yb[1] = yb[2] = yb[3] = 0; + + return 0; + } + + Tk_Font font =NULL; + + switch (renderMode_) { + case X11: + font = text_->tkfont(); + break; + case PS: + font = text_->psfont(); + break; + case MACOSX: +#ifdef MAC_OSX_TK + font = text_->tkfont(); +#endif + break; + case GWIN32: +#ifdef __WIN32 + font = text_->tkfont(); +#endif + break; + } + + if (!font) + return 0; + + Vector vv = Vector(x,y); + double angle = calcTextAngle(just, Vector(upx, upy)); + Vector cc = vv * calcTextPos(vv, angle, txt, just, Vector(upx, upy), font); + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(font, &metrics); + int width = Tk_TextWidth(font, txt, strlen(txt)); + + BBox nn = BBox(Vector(0,-metrics.descent), Vector(width,metrics.ascent)); + BBox bb = nn * Rotate(angle) * Translate(cc); + + xb[0] = bb.ll[0]; + yb[0] = bb.ll[1]; + + xb[1] = bb.ur[0]; + yb[1] = bb.ll[1]; + + xb[2] = bb.ur[0]; + yb[2] = bb.ur[1]; + + xb[3] = bb.ll[0]; + yb[3] = bb.ur[1]; + + return 1; +} + +int Grid2dBase::gScales(float* alpha, float* beta) +{ + return 1; +} + diff --git a/tksao/util/grid2dbase.h b/tksao/util/grid2dbase.h new file mode 100644 index 0000000..ae4c1ac --- /dev/null +++ b/tksao/util/grid2dbase.h @@ -0,0 +1,26 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __grid2dbase_h__ +#define __grid2dbase_h__ + +#include "gridbase.h" + +class Grid2dBase : public GridBase { + public: + Grid2dBase(Widget*); + Grid2dBase(Widget*, const char*); + virtual ~Grid2dBase(); + + int gLine(int n, float* x, float* y); + int gQch(float*, float*); + int gMark(int, const float*, const float*, int) {return 1;} + int gText(const char* txt, float x, float y, const char* just, + float upx, float upy); + int gTxExt(const char*, float, float, const char*, + float, float, float*, float*); + int gScales(float *alpha, float *beta); +}; + +#endif diff --git a/tksao/util/grid3dbase.C b/tksao/util/grid3dbase.C new file mode 100644 index 0000000..9463d73 --- /dev/null +++ b/tksao/util/grid3dbase.C @@ -0,0 +1,241 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "grid3dbase.h" +#include "attribute.h" +#include "widget.h" + +extern "C" { + #include "ast.h" + #include "grf.h" +} + +Grid3dBase* astGrid3dPtr = NULL; + +Grid3dBase::Grid3dBase(Widget* p) : GridBase(p) +{} + +Grid3dBase::Grid3dBase(Widget* p, const char* o) : GridBase(p,o) +{} + +Grid3dBase::~Grid3dBase() +{} + +int Grid3dBase::gLine(int n, float* x, float* y, float* z) +{ + float xx[n]; + float yy[n]; + + for (int ii=0; iitkfont(); + break; + case PS: + font = text_->psfont(); + break; + case MACOSX: +#ifdef MAC_OSX_TK + font = text_->tkfont(); +#endif + break; + case GWIN32: +#ifdef __WIN32 + font = text_->tkfont(); +#endif + break; + } + + if (font) { + Tk_FontMetrics metrics; + Tk_GetFontMetrics(font, &metrics); + + *ch = (float)metrics.linespace; + return 1; + } + else { + *ch = 0; + return 0; + } +} + +int Grid3dBase::gText(const char* txt, float* ref, const char* just, + float* up, float* norm) +{ + if (!(txt && txt[0] && just && just[0] && just[1])) + return 0; + + Vector3d vv = Vector3d(ref[0],ref[1],ref[2])*mx_; + + switch (renderMode_) { + case X11: + return x11Text(txt,vv[0],vv[1],just,Vector(0,1)); + case PS: + return psText(txt,vv[0],vv[1],just,Vector(0,1)); + case MACOSX: +#ifdef MAC_OSX_TK + return macosxText(txt,vv[0],vv[1],just,Vector(0,1)); +#endif + break; + case GWIN32: +#ifdef __WIN32 + return win32Text(txt,vv[0],vv[1],just,Vector(0,1)); +#endif + break; + } + + return 0; +} + +int Grid3dBase::gTxExt(const char* txt, float* ref, const char* just, + float* up, float* norm, float* xb, float* yb, + float* zb, float* bl) +{ + if (!(txt && txt[0] && just)) { + xb[0] = xb[1] = xb[2] = xb[3] = 0; + yb[0] = yb[1] = yb[2] = yb[3] = 0; + zb[0] = zb[1] = zb[2] = zb[3] = 0; + + return 0; + } + + /* + cerr << txt + << Vector3d(ref[0],ref[1],ref[2]) << ' ' + << just[0] << just[1] + << Vector3d(up[0],up[1],up[2]) + << Vector3d(norm[0],norm[1],norm[2]) + << endl; + */ + + Tk_Font font =NULL; + + switch (renderMode_) { + case X11: + font = text_->tkfont(); + break; + case PS: + font = text_->psfont(); + break; + case MACOSX: +#ifdef MAC_OSX_TK + font = text_->tkfont(); +#endif + break; + case GWIN32: +#ifdef __WIN32 + font = text_->tkfont(); +#endif + break; + } + + if (!font) + return 0; + + Vector3d vv = Vector3d(ref[0],ref[1],ref[2])*mx_; + // cerr << " vv: " << vv << endl; + Vector3d cc = vv * calcTextPos(vv, txt, just, font); + // cerr << " cc: " << cc << endl; + + Tk_FontMetrics metrics; + Tk_GetFontMetrics(font, &metrics); + int width = Tk_TextWidth(font, txt, strlen(txt)); + + BBox3d nn(Vector3d(0,-metrics.descent,0), Vector3d(width,metrics.ascent,0)); + // cerr << " nn: " << nn << endl; + Matrix3d mm = Translate3d(-nn.center()) * rx_ * Translate3d(nn.center()); + // cerr << mm << endl; + BBox3d bb = nn * mm * Translate3d(cc); + // cerr << " bb: " << bb << endl; + Vector3d ll = cc * mm; + + xb[0] = bb.ll[0]; + yb[0] = bb.ll[1]; + zb[0] = bb.ll[2]; + + xb[1] = bb.ur[0]; + yb[1] = bb.ll[1]; + zb[1] = bb.ll[2]; + + xb[2] = bb.ur[0]; + yb[2] = bb.ur[1]; + zb[2] = bb.ll[2]; + + xb[3] = bb.ll[0]; + yb[3] = bb.ur[1]; + zb[3] = bb.ll[2]; + + bl[0] = ll[0]; + bl[1] = ll[1]; + bl[2] = ll[2]; + + return 1; +} + +Matrix3d Grid3dBase::calcTextPos(const Vector3d& vv, const char* txt, + const char* just, Tk_Font font) +{ + Tk_FontMetrics metrics; + Tk_GetFontMetrics(font, &metrics); + int width = Tk_TextWidth(font, txt, strlen(txt)); + + Matrix3d m1,m2; + switch (just[0]) { + case 'T': + break; + case 'C': + m1 = Translate3d(0,metrics.linespace/2,0); + break; + case 'B': + m1 = Translate3d(0,metrics.ascent,0); + break; + case 'M': + m1 = Translate3d(0,metrics.linespace,0); + break; + } + + switch (just[1]) { + case 'L': + break; + case 'C': + m2 = Translate3d(-width/2.,0,0); + break; + case 'R': + m2 = Translate3d(-width,0,0); + break; + } + + return Translate3d(-vv) * + m1 * m2 * + Translate3d(vv); +} diff --git a/tksao/util/grid3dbase.h b/tksao/util/grid3dbase.h new file mode 100644 index 0000000..b81d17f --- /dev/null +++ b/tksao/util/grid3dbase.h @@ -0,0 +1,35 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __grid3dbase_h__ +#define __grid3dbase_h__ + +#include + +#include "gridbase.h" +#include "vector3d.h" + +class Grid3dBase : public GridBase { + protected: + Matrix3d mx_; + Matrix3d rx_; + + Matrix3d calcTextPos(const Vector3d&, const char*, const char*, Tk_Font); + + public: + Grid3dBase(Widget*); + Grid3dBase(Widget*, const char*); + virtual ~Grid3dBase(); + + int gLine(int n, float* x, float* y, float* z); + int gQch(float* ch); + int gMark(int n, float* x, float* y, float* z, int type, float* norm) + {return 1;} + int gText(const char* txt, float* ref, const char* just, float* up, + float* norm); + int gTxExt(const char* txt, float* ref, const char* just, float* up, + float* norm, float* xb, float* yb, float* zb, float* bl); +}; + +#endif diff --git a/tksao/util/gridbase.C b/tksao/util/gridbase.C new file mode 100644 index 0000000..a941755 --- /dev/null +++ b/tksao/util/gridbase.C @@ -0,0 +1,461 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "gridbase.h" +#include "attribute.h" +#include "widget.h" +#include "util.h" + +EXTERN void TkDrawAngledChars(Display *display, + Drawable drawable, GC gc, Tk_Font tkfont, + const char *source, int numBytes, double x, + double y, double angle); +extern "C" { + #include "ast.h" + #include "grf.h" +} + +GridBase::GridBase(Widget* pp) : parent_(pp) +{ + option_ = NULL; + + renderMode_ = X11; + line_ = new Attribute(parent_); + text_ = new Attribute(parent_); + + gridGC_ = XCreateGC(parent_->getDisplay(), Tk_WindowId(parent_->getTkwin()), + 0, NULL); + pixmap_ = 0; + + mode_ = Widget::RGB; +} + +GridBase::GridBase(Widget* pp, const char* op) : parent_(pp) +{ + option_ = dupstr(op); + + renderMode_ = X11; + line_ = new Attribute(parent_); + text_ = new Attribute(parent_); + + gridGC_ = XCreateGC(parent_->getDisplay(), Tk_WindowId(parent_->getTkwin()), + 0, NULL); + pixmap_ = 0; + + mode_ = Widget::RGB; +} + +GridBase::~GridBase() +{ + if (option_) + delete [] option_; + + if (gridGC_) + XFreeGC(parent_->getDisplay(), gridGC_); + + if (line_) + delete line_; + if (text_) + delete text_; +} + +int GridBase::gAttr(int which, double value, double* old, int prim) +{ + Attribute* attr; + switch (prim) { + case GRF__TEXT: + attr = text_; + + switch (which) { + case GRF__STYLE: + break; + case GRF__WIDTH: + break; + case GRF__SIZE: + if (old) + *old = attr->size(); + if (value != AST__BAD) + attr->setSize(value); + break; + case GRF__FONT: + if (old) + *old = attr->font(); + if (value != AST__BAD) + attr->setFont(value); + break; + case GRF__COLOUR: + if (old) + *old = attr->colour(); + if (value != AST__BAD) + attr->setColour(value); + break; + } + + break; + case GRF__LINE: + attr = line_; + + switch (which) { + case GRF__STYLE: + if (old) + *old = attr->style(); + if (value != AST__BAD) + attr->setStyle(value); + break; + case GRF__WIDTH: + if (old) + *old = attr->width(); + if (value != AST__BAD) + attr->setWidth(value); + break; + case GRF__SIZE: + break; + case GRF__FONT: + break; + case GRF__COLOUR: + if (old) + *old = attr->colour(); + if (value != AST__BAD) + attr->setColour(value); + break; + } + + break; + } + + return 1; +} + +int GridBase::gCap(int cap, int value) +{ + switch (cap) { + case GRF__SCALES: + return 0; + case GRF__MJUST: + return 1; + case GRF__ESC: + return 0; + } + return 0; +} + +// X11 Render functions + +int GridBase::x11Line(int n, float* x, float* y) +{ + if (n<2 || !x || !y) + return 1; + + XSetForeground(parent_->getDisplay(), gridGC_, line_->color()); + int w = (int)line_->width(); + if (w<1) + w = 1; + switch (line_->style()) { + case Attribute::SOLID: + XSetLineAttributes(parent_->getDisplay(), gridGC_, w, + LineSolid, CapButt, JoinMiter); + break; + case Attribute::DASH: + XSetLineAttributes(parent_->getDisplay(), gridGC_, w, + LineOnOffDash, CapButt, JoinMiter); + char dlist[] = {8,3}; + XSetDashes(parent_->getDisplay(), gridGC_, 0, dlist, 2); + break; + } + + for (int i=0; igetDisplay(), pixmap_, gridGC_, + (int)s[0],(int)s[1],(int)e[0],(int)e[1]); + } + + return 1; +} + +int GridBase::x11Text(const char* txt, float x, float y, + const char* just, Vector up) +{ + XSetFont(parent_->getDisplay(), gridGC_, Tk_FontId(text_->tkfont())); + XSetForeground(parent_->getDisplay(), gridGC_, text_->color()); + + Vector vv = Vector(x,y); + double angle = calcTextAngle(just, up); + Vector cc = vv * calcTextPos(vv, angle, txt, just, up, text_->tkfont()); + + TkDrawAngledChars(parent_->getDisplay(), pixmap_, gridGC_, text_->tkfont(), + txt, strlen(txt), + cc[0], cc[1], radToDeg(angle)); + return 1; +} + +// PS Render functions + +int GridBase::psLine(int n, float* x, float* y) +{ + if (n<2 || !x || !y) + return 1; + + psColor(line_); + { + ostringstream str; + str << line_->width() << " setlinewidth" << endl << ends; + Tcl_AppendResult(parent_->getInterp(), str.str().c_str(), NULL); + } + { + ostringstream str; + switch (line_->style()) { + case Attribute::SOLID: + str << "[] 0 setdash" << endl << ends; + break; + case Attribute::DASH: + str << "[8 3] 0 setdash" << endl << ends; + break; + } + Tcl_AppendResult(parent_->getInterp(), str.str().c_str(), NULL); + } + + for (int i=0; igetCanvas()) << " moveto" << endl << ends; + } + else + str << v.TkCanvasPs(parent_->getCanvas()) << " lineto" << endl << ends; + + Tcl_AppendResult(parent_->getInterp(), str.str().c_str(), NULL); + } + + ostringstream str; + str << "stroke" << endl << ends; + Tcl_AppendResult(parent_->getInterp(), str.str().c_str(), NULL); + + return 1; +} + +int GridBase::psText(const char* txt, float x, float y, + const char* just, Vector up) +{ + Tcl_DString psdstr; + Tcl_DStringInit(&psdstr); + + Vector vv = Vector(x,y) * matrix_; + double angle = calcTextAngle(just, up); + Vector cc = vv * calcTextPos(vv, angle, txt, just, up, text_->psfont()); + + ostringstream str; + const char* ff = Tk_NameOfFont(text_->psfont()); + str << '/' << psFontName(ff) + << " findfont " << int(psFontSize(ff)*parent_->getDisplayRatio()) + << " scalefont setfont" << endl; + + psColor(text_); + + str << "gsave " + << cc.TkCanvasPs(parent_->getCanvas()) << " moveto" << endl + << radToDeg(angle) << " rotate " + << '(' << psQuote(txt) << ')' << " show" + << " grestore" << endl << ends; + Tcl_AppendResult(parent_->getInterp(), str.str().c_str(), NULL); + + return 1; +} + +void GridBase::psColor(Attribute* attr) +{ + ostringstream str; + switch ((Widget::PSColorSpace)mode_) { + case Widget::BW: + case Widget::GRAY: + psColorGray(parent_->getXColor(attr->colorName()), str); + str << " setgray"; + break; + case Widget::RGB: + psColorRGB(parent_->getXColor(attr->colorName()), str); + str << " setrgbcolor"; + break; + case Widget::CMYK: + psColorCMYK(parent_->getXColor(attr->colorName()), str); + str << " setcmykcolor"; + break; + } + str << endl << ends; + Tcl_AppendResult(parent_->getInterp(), str.str().c_str(), NULL); +} + +#ifdef MAC_OSX_TK +int GridBase::macosxLine(int n, float* x, float* y) +{ + if (n<2 || !x || !y) + return 1; + + macosxColor(parent_->getXColor(line_->colorName())); + macosxWidth(line_->width()); + switch (line_->style()) { + case Attribute::SOLID: + macosxDash(NULL,0); + break; + case Attribute::DASH: + float dlist[] = {8,3}; + macosxDash(dlist,2); + break; + } + + Vector* v = new Vector[n]; + for (int i=0; itkfont(), &psdstr); + + macosxFont(Tcl_DStringValue(&psdstr),psSize); + Tcl_DStringFree(&psdstr); + + Vector vv = Vector(x,y) * matrix_; + double angle = calcTextAngle(just, up); + Vector cc = vv * calcTextPos(vv, angle, txt, just, up, text_->tkfont()); + + macosxColor(parent_->getXColor(text_->colorName())); + macosxDrawText(cc, angle, txt); + + return 1; +} +#endif + +#ifdef __WIN32 +int GridBase::win32Line(int n, float* x, float* y) +{ + if (n<2 || !x || !y) + return 1; + + win32Color(parent_->getXColor(line_->colorName())); + win32Width(line_->width()); + switch (line_->style()) { + case Attribute::SOLID: + win32Dash(NULL,0); + break; + case Attribute::DASH: + float dlist[] = {8,3}; + win32Dash(dlist,2); + break; + } + + Vector v[n]; + for (int i=0; itkfont()); + win32Color(parent_->getXColor(text_->colorName())); + + Vector vv = Vector(x,y) * matrix_; + double angle = calcTextAngle(just, up);; + Vector cc = vv * calcTextPos(vv, angle, txt, just, up, text_->tkfont()); + + win32DrawText(cc, angle, txt); + + return 1; +} +#endif + +// Support + +double GridBase::calcTextAngle(const char* just, Vector up) +{ + double a = up.angle(); + + // our angle is 90 off from ast's, and the other direction + double rr = -(a - M_PI_2); + + // special case for text rotated exactly 90 + if (up[0]==-1 && up[1]==0) + rr += M_PI; + + // normalize + if (rr>0) + while (rr>M_TWOPI) + rr -= M_TWOPI; + else + while (rr<0) + rr += M_TWOPI; + + return rr; +} + +Matrix GridBase::calcTextPos(const Vector& vv, double angle, const char* txt, + const char* just, Vector up, Tk_Font font) +{ + Tk_FontMetrics metrics; + Tk_GetFontMetrics(font, &metrics); + int width = Tk_TextWidth(font, txt, strlen(txt)); + + Matrix m1,m2; + switch (just[0]) { + case 'T': + break; + case 'C': + m1 = Translate(0,metrics.linespace/2); + break; + case 'B': + m1 = Translate(0,metrics.ascent); + break; + case 'M': + m1 = Translate(0,metrics.linespace); + break; + } + + switch (just[1]) { + case 'L': + break; + case 'C': + m2 = Translate(-width/2.,0); + break; + case 'R': + m2 = Translate(-width,0); + break; + } + + Matrix rr = Translate(-vv) * + Rotate(-angle) * + m1 * m2 * + Rotate(angle) * + Translate(vv); + + // special case for text rotated exactly 90 + Matrix mm; + if (up[0] == -1 && up[1] == 0) { + Vector cc = vv*rr; + mm = Translate(-cc) * + Rotate(-angle) * + Translate(-width/2.,metrics.linespace/2.) * + FlipY() * + Translate(width/2.,-metrics.linespace/2.) * + Rotate(angle) * + Translate(cc); + } + + return rr*mm; +} + diff --git a/tksao/util/gridbase.h b/tksao/util/gridbase.h new file mode 100644 index 0000000..fec7705 --- /dev/null +++ b/tksao/util/gridbase.h @@ -0,0 +1,67 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __gridbase_h__ +#define __gridbase_h__ + +#include + +#include "vector.h" + +class Widget; +class Attribute; + +class GridBase { + public: + enum RenderMode {X11, PS, MACOSX, GWIN32}; + + protected: + Widget* parent_; + char* option_; + + RenderMode renderMode_; + Attribute* line_; + Attribute* text_; + + GC gridGC_; + Pixmap pixmap_; + + Matrix matrix_; + int mode_; + + protected: + int x11Line(int n, float* x, float* y); + int x11Text(const char*, float, float, const char*, Vector); + + int psLine(int n, float* x, float* y); + int psText(const char*, float, float, const char*, Vector); + void psColor(Attribute*); + +#ifdef MAC_OSX_TK + int macosxLine(int n, float* x, float* y); + int macosxText(const char*, float, float, const char*, Vector); +#endif + +#ifdef __WIN32 + int win32Line(int n, float* x, float* y); + int win32Text(const char*, float, float, const char*, Vector); +#endif + + double calcTextAngle(const char*, Vector); + Matrix calcTextPos(const Vector&, double, const char*, + const char*, Vector, Tk_Font); + + public: + GridBase(Widget*); + GridBase(Widget*, const char*); + virtual ~GridBase(); + + int gAttr(int attr, double value, double* old, int prim); + int gCap(int, int); + int gFlush() {return 1;} + + const char* option() {return option_;} +}; + +#endif diff --git a/tksao/util/ps.C b/tksao/util/ps.C new file mode 100644 index 0000000..b3a5b1e --- /dev/null +++ b/tksao/util/ps.C @@ -0,0 +1,377 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "ps.h" +#include "util.h" + +Filter::Filter() +{ + buf_ = new unsigned char[BUFSIZE]; + ptr_ = buf_; +} + +Filter::~Filter() +{ + if (buf_) + delete [] buf_; +} + +void Filter::flush(ostream& str) +{ + cflush(); + eflush(str); +} + +// Compress + +void NoCompress::in(unsigned char c) +{ + *ptr_++ = c; +} + +// RLE + +RLE::RLE() +{ + state = 0; + num = 0; +} + +void RLE::in(unsigned char c) +{ + current = c; + switch (state) { + case 0: // start state + if (num == 0) // not enough info yet + rle[num++] = current; + else { + if (current != rle[num-1]) { // looks like non repeating + rle[num++] = current; + state = 1; + } + else { // looks like repeating + num++; + state = 2; + } + } + break; + + case 1: // non repeat state + if (current != rle[num-1]) { + rle[num++] = current; + + if (num >= RLESIZE) { // time to dump the rlefer + dumpNonRepeat(); // dump the buffer + num = 0; // and reset counter + state = 0; + } + } + else { + num--; // decr + dumpNonRepeat(); // dump the buffer + + state = 2; // repeat state + rle[0] = current; // save repeat char + num = 2; // we aready have two now + } + break; + + case 2: // repeat state + if (current == rle[0]) { + if (++num >= RLESIZE) { + dumpRepeat(); // dump the repeat count + state = 0; + num = 0; + } + } + else { + dumpRepeat(); // dump the repeat count + state = 1; // back to non repeat state + rle[0] = current; // save first char + num = 1; // we have one now + } + break; + } +} + +void RLE::dumpNonRepeat() +{ + if (num) { + *ptr_++ = (unsigned char)(num-1); + for (int i=0; inext_in = NULL; + stream_->avail_in = 0; + stream_->next_out = NULL; + stream_->avail_out = 0; + + stream_->zalloc = NULL; + stream_->zfree = NULL; + stream_->opaque = NULL; + + if (deflateInit(stream_, Z_DEFAULT_COMPRESSION) != Z_OK) { + if (DebugGZ) + cerr << "deflateInit error" << endl; + return; + } + + stream_->next_out = gzip_; + stream_->avail_out = GZIPSIZE; +} + +GZIP::~GZIP() +{ + if (deflateEnd(stream_) != Z_OK) + if (DebugGZ) + cerr << "deflateEnd error" << endl; + + if (gzip_) + delete [] gzip_; + + if (stream_) + delete stream_; +} + +void GZIP::in(unsigned char c) +{ + stream_->next_in = &c; + stream_->avail_in = 1; + + while (stream_->avail_in > 0 && deflategz(Z_NO_FLUSH) == Z_OK); +} + +void GZIP::cflush() +{ + // flush any pending output + while (deflategz(Z_FINISH) == Z_OK); +} + +int GZIP::deflategz(int flush) +{ + int result = deflate(stream_, flush); + + switch (result) { + case Z_OK: + if (DebugGZ) + cerr << "deflate OK: avail_in " << stream_->avail_in + << " avail_out " << stream_->avail_out << endl; + break; + case Z_STREAM_END: + if (DebugGZ) + cerr << "deflate STRM_END: avail_in " << stream_->avail_in + << " avail_out " << stream_->avail_out << endl; + break; + default: + if (DebugGZ) + cerr << "deflate Error " << result << endl; + return result; + } + + if (stream_->avail_out == 0 || result != Z_OK) { + int s = GZIPSIZE - stream_->avail_out; + unsigned char* d = gzip_; + + if (s>0) { + if (ptr_+s > buf_+BUFSIZE) { + cerr << "deflate buffer overflow " + << stream_->avail_out << ' ' << result << endl; + return result; + } + + memcpy(ptr_,d,s); + ptr_ += s; + + if (DebugGZ) + cerr << "deflate send " << s << ' ' << result << endl; + } + + stream_->next_out = gzip_; + stream_->avail_out = GZIPSIZE; + } + + return result; +} + +// Encode + +Encode::Encode(int l) +{ + level = l; + lineCount = 0; +} + +// AsciiHex + +AsciiHex::AsciiHex(int l) : Encode(l) {} + +void AsciiHex::out(ostream& str) +{ + unsigned char* p = buf_; + while (p < ptr_) { + unsigned short c = *p++; + str << hex << setfill('0') << setw(2) << c; + + lineCount += 2; + if (lineCount >= LINELIMIT) { + str << endl; + lineCount = 0; + } + } + ptr_ = buf_; // reset buffer +} + +void AsciiHex::eflush(ostream& str) +{ + out(str); + switch (level) { + case 1: + str << endl; + break; + case 2: + case 3: + str << endl << '>' << endl; + break; + } +} + +// Ascii85 + +Ascii85::Ascii85(int l) : Encode(l) +{ + byteswap = (*(short *)"\001\000" & 0x0001); + + buf85.c = 0; + index = 0; +} + +int32_t Ascii85::swap(uint32_t* p) +{ + int32_t r; + swap4((char*)p, (char*)&r); + return r; +} + +void Ascii85::out(ostream& str) +{ + unsigned char* p = buf_; + while (p < ptr_) { + buf85.b[index++] = *p++; + if (index==4) { + dump(str); + } + } + + ptr_ = buf_; // reset buffer +} + +void Ascii85::dump(ostream& str) +{ + // all zeros? + if (buf85.c == 0) { + str << 'z'; + if (++lineCount >= LINELIMIT) { + str << endl; + lineCount = 0; + } + } + else { + uint32_t b; + if (!byteswap) + b = buf85.c; + else + b = swap(&buf85.c); + + for (int ii=4; ii>=0 ; ii--) { + uint32_t base = 1; + for (int jj=0; jj= LINELIMIT) { + str << endl; + lineCount = 0; + } + } + } + index = 0; + buf85.c = 0; +} + +void Ascii85::eflush(ostream& str) +{ + // dump the remainder + out(str); + + // we can't have any z's here + // also, only write index+1 chars + if (index) { + uint32_t b; + if (!byteswap) + b = buf85.c; + else + b = swap(&buf85.c); + + for (int ii=4; ii>=(4-index); ii--) { + uint32_t base = 1; + for (int jj=0; jj= LINELIMIT) { + str << endl; + lineCount = 0; + } + } + } + index = 0; + buf85.c = 0; + + switch (level) { + case 1: + str << endl; + break; + case 2: + case 3: + str << endl << "~>" << endl; + break; + } +} + diff --git a/tksao/util/ps.h b/tksao/util/ps.h new file mode 100644 index 0000000..83c6e70 --- /dev/null +++ b/tksao/util/ps.h @@ -0,0 +1,171 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __ps_h__ +#define __ps_h__ + +#include + +#include +#include +#include +using namespace std; + +#include "zlib.h" +extern int DebugGZ; + +// we need this large for gzip +#define GZIPSIZE 8192 +#define BUFSIZE GZIPSIZE*8 +#define RLESIZE 128 +#define LINELIMIT 80 + +// Filter Base Class +class Filter { +protected: + unsigned char* buf_; + unsigned char* ptr_; + + virtual void cflush() =0; + virtual void eflush(ostream&) =0; + +public: + Filter(); + virtual ~Filter(); + + virtual void in(unsigned char) =0; + virtual void out(ostream&) =0; + void flush(ostream&); + + friend Filter& operator<<(Filter& f, unsigned char c) {f.in(c); return f;} + friend ostream& operator<<(ostream& s, Filter& f) {f.out(s); return s;} +}; + +// Compress Base Class +class Compress : public virtual Filter { +public: + virtual void in(unsigned char) =0; + virtual void cflush() =0; +}; + +class NoCompress : public virtual Filter, public Compress { +public: + void in(unsigned char); + void cflush() {} +}; + +// RLE +class RLE : public virtual Filter, public Compress { +private: + int state; + unsigned char current; + unsigned char rle[RLESIZE]; + int num; + + void dumpNonRepeat(); + void dumpRepeat(); + +public: + RLE(); + + void in(unsigned char); + void cflush(); +}; + +// GZIP +class GZIP : public virtual Filter, public Compress { +private: + z_stream* stream_; + unsigned char* gzip_; + + int deflategz(int); + +public: + GZIP(); + ~GZIP(); + + void in(unsigned char); + void cflush(); +}; + +// Encode Base Class +class Encode : public virtual Filter { +protected: + int level; + int lineCount; + +public: + Encode(int); + + virtual void out(ostream&) =0; + virtual void eflush(ostream&) =0; +}; + +// AsciiHex +class AsciiHex : public virtual Filter, public Encode { +public: + AsciiHex(int); + + void out(ostream&); + void eflush(ostream&); +}; + +// Ascii85 +class Ascii85 : public virtual Filter, public Encode { +private: + int index; + int byteswap; + union { + unsigned char b[4]; + uint32_t c; + } buf85; + + void dump(ostream&); + int32_t swap(uint32_t* ptr); + +public: + Ascii85(int); + + void out(ostream&); + void eflush(ostream&); +}; + +// PS Filters +class NoCompressAsciiHex : +public virtual Filter, public NoCompress, public AsciiHex { + public: + NoCompressAsciiHex(int l) : AsciiHex(l) {}; +}; + +class NoCompressAscii85 : +public virtual Filter, public NoCompress, public Ascii85 { + public: + NoCompressAscii85(int l) : Ascii85(l) {}; +}; + +class RLEAsciiHex : +public virtual Filter, public RLE, public AsciiHex { + public: + RLEAsciiHex(int l) : AsciiHex(l) {}; +}; + +class RLEAscii85 : +public virtual Filter, public RLE, public Ascii85 { + public: + RLEAscii85(int l) : Ascii85(l) {}; +}; + +class GZIPAsciiHex : +public virtual Filter, public GZIP, public AsciiHex { + public: + GZIPAsciiHex(int l) : AsciiHex(l) {}; +}; + +class GZIPAscii85 : +public virtual Filter, public GZIP, public Ascii85 { + public: + GZIPAscii85(int l) : Ascii85(l) {}; +}; + +#endif diff --git a/tksao/util/smooth.C b/tksao/util/smooth.C new file mode 100644 index 0000000..db70981 --- /dev/null +++ b/tksao/util/smooth.C @@ -0,0 +1,67 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include +#include +#include +using namespace std; + +#include + +#include "smooth.h" + +void boxcar(double* kernel, int r) +{ + int rr = 2*r+1; + int ksz = rr*rr; + + double* ptr = kernel; + for (int jj=0; jj + +#include "util.h" + +// Error in mapping +int maperr= 0; + +static char tobuf[1024]; + +int sexSign; // used by parser and lex to indicate sign of dms or hms + +void swap2(char* src, char* dest) { + *(dest ) = *(src+1); + *(dest+1) = *(src ); +} + +void swap4(char* src, char* dest) { + *(dest ) = *(src+3); + *(dest+1) = *(src+2); + *(dest+2) = *(src+1); + *(dest+3) = *(src ); +} + +void swap8(char* src, char* dest) { + *(dest ) = *(src+7); + *(dest+1) = *(src+6); + *(dest+2) = *(src+5); + *(dest+3) = *(src+4); + *(dest+4) = *(src+3); + *(dest+5) = *(src+2); + *(dest+6) = *(src+1); + *(dest+7) = *(src ); +} + +int lsb() +{ + return (*(short *)"\001\000" & 0x0001); +} + +char* dupstr(const char* str) +{ + char* copy; + if (str) { + copy=new char[strlen(str)+1]; + strcpy(copy,str); + } + else + copy=NULL; + + return copy; +} + +char* trim(const char* str) +{ + char* rr = dupstr(str); + char* ptr = rr; + while (ptr && *ptr) + ptr++; + ptr--; + while (ptr && (*ptr == ' ')) + ptr--; + ptr++; + *ptr = '\0'; + + return rr; +} + +char* toLower(const char* str) +{ + char* rr = dupstr(str); + char* ptr = rr; + while (*ptr) { + *ptr = (char)(tolower(((int)(*ptr)))); + ptr++; + } + return rr; +} + +char* toUpper(const char* str) +{ + char* rr = dupstr(str); + char* ptr = rr; + while (*ptr) { + *ptr = (char)(toupper(((int)(*ptr)))); + ptr++; + } + return rr; +} + +char* toConstLower(const char* str) +{ + strncpy(tobuf,str,1024); + char* ptr = tobuf; + while (*ptr) { + *ptr = (char)(tolower(((int)(*ptr)))); + ptr++; + } + return tobuf; +} + +char* toConstUpper(const char* str) +{ + strncpy(tobuf,str,1024); + char* ptr = tobuf; + while (*ptr) { + *ptr = (char)(toupper(((int)(*ptr)))); + ptr++; + } + return tobuf; +} + +double zeroTWOPI(double aa) +{ + double rr = aa; + if (rr>0) + while (rr>=M_TWOPI) + rr -= M_TWOPI; + else + while (rr<0) + rr += M_TWOPI; + return rr; +} + +double zero360(double aa) +{ + double rr = aa; + if (rr>=0) + while (rr>360) + rr -= 360; + else + while (rr<0) + rr += 360; + return rr; +} + +double m180To180(double aa) +{ + // incoming 0-360 + double rr = aa; + if (rr>180) + rr -= 360; + return rr; +} + +double degToRad(double dd) +{ + double rr = M_PI*dd/180.; + return zeroTWOPI(rr); +} + +double radToDeg(double rr) +{ + double dd = 180.*rr/M_PI; + return zero360(dd); +} + +double dmsToDegree(int sign, int degree, int min, double sec) +{ + // sign is needed because of -00 vs +00 + return double(sign) * (abs(degree) + (min/60.) + (sec/60./60.)); +} + +int parseSection(char* lbuf, Vector* v1, Vector* v2) +{ + double x1, y1, x2, y2; + char d1,d2,d3,d4,d5; // dummy char + string x(lbuf); + istringstream str(x); + str >> d1 >> x1 >> d2 >> x2 >> d3 >> y1 >> d4 >> y2 >> d5; + + // verify input + if (!(d1=='[' && d2==':' && d3==',' && d4==':' && d5==']')) + return 0; + + // it looks ok + *v1 = Vector(x1,y1); + *v2 = Vector(x2,y2); + + return 1; +} + +double parseSEXStr(const char* d) +{ + char* dms = dupstr(d); // its going to get clobbered + char* ptr = dms; + + int sign = 1; + int degree = atoi(strtok(ptr,":")); + int minute = atoi(strtok(NULL,":")); + float sec = atof(strtok(NULL,":")); + + // assumes the minus sign is the first char + if (degree != 0) + sign = degree>0 ? 1 : -1; + else + sign = d[0] == '-' ? -1 : 1; + + delete [] dms; + + return dmsToDegree(sign,abs(degree),minute,sec); +} + +double parseHMSStr(const char* str) +{ + char* hms = dupstr(str); // its going to get clobbered + char* ptr = hms; + + int sign = 1; + int hour = atoi(strtok(ptr,"h")); + int minute = atoi(strtok(NULL,"m")); + float second = atof(strtok(NULL,"s")); + + // assumes the minus sign is the first char + if (hour != 0) + sign = hour>0 ? 1 : -1; + else + sign = str[0] == '-' ? -1 : 1; + + delete [] hms; + + return dmsToDegree(sign,abs(hour),minute,second)/24.*360.; +} + +double parseDMSStr(const char* str) +{ + char* dms = dupstr(str); // its going to get clobbered + char* ptr = dms; + + int sign = 1; + int degree = atoi(strtok(ptr,"d")); + int minute = atoi(strtok(NULL,"m")); + float sec = atof(strtok(NULL,"s")); + + // assumes the minus sign is the first char + if (degree != 0) + sign = degree>0 ? 1 : -1; + else + sign = str[0] == '-' ? -1 : 1; + + delete [] dms; + + return dmsToDegree(sign,abs(degree),minute,sec); +} + +double RGB2Gray(double red, double green, double blue) +{ + return 0.30*red + 0.59*green + 0.11*blue; +} + +unsigned char RGB2Gray(unsigned char red, unsigned char green, + unsigned char blue) +{ + // we have a round off problem here, add FLT_EPSILON to kick it over + return (unsigned char)(0.30*red + 0.59*green + 0.11*blue + FLT_EPSILON); +} + +void RGB2CMYK(unsigned char red, unsigned char green, unsigned char blue, + unsigned char* cyan, unsigned char* magenta, + unsigned char* yellow, unsigned char* black) +{ + // convert To CMY + + *cyan = UCHAR_MAX-red; + *magenta = UCHAR_MAX-green; + *yellow = UCHAR_MAX-blue; + *black =0; + + // determine black + + *black = UCHAR_MAX; + if (*cyan < *black) + *black = *cyan; + if (*magenta < *black) + *black = *magenta; + if (*yellow < *black) + *black = *yellow; + + // substract out black + + *cyan -= *black; + *magenta -= *black; + *yellow -= *black; +} + +void RGB2CMYK(unsigned short red, unsigned short green, unsigned short blue, + unsigned short* cyan, unsigned short* magenta, + unsigned short* yellow, unsigned short* black) +{ + // convert To CMY + + *cyan = USHRT_MAX-red; + *magenta = USHRT_MAX-green; + *yellow = USHRT_MAX-blue; + *black =0; + + // determine black + + *black = USHRT_MAX; + if (*cyan < *black) + *black = *cyan; + if (*magenta < *black) + *black = *magenta; + if (*yellow < *black) + *black = *yellow; + + // substract out black + + *cyan -= *black; + *magenta -= *black; + *yellow -= *black; +} + +ostream& psColorGray(XColor* clr, ostream& str) +{ + if (clr) { + float red = clr->red/float(USHRT_MAX); + float green = clr->green/float(USHRT_MAX); + float blue = clr->blue/float(USHRT_MAX); + str << dec << RGB2Gray(red,green,blue); + } + + return str; +} + +ostream& psColorRGB(XColor* clr, ostream& str) +{ + if (clr) { + float red = clr->red/float(USHRT_MAX); + float green = clr->green/float(USHRT_MAX); + float blue = clr->blue/float(USHRT_MAX); + str << dec << red << ' ' << green << ' ' << blue; + } + + return str; +} + +ostream& psColorCMYK(XColor* clr, ostream& str) +{ + if (clr) { + unsigned short cyan; + unsigned short magenta; + unsigned short yellow; + unsigned short black; + + RGB2CMYK(clr->red, clr->green, clr->blue, &cyan, &magenta, &yellow, &black); + + str << dec + << cyan/float(USHRT_MAX) << ' ' + << magenta/float(USHRT_MAX) << ' ' + << yellow/float(USHRT_MAX) << ' ' + << black/float(USHRT_MAX); + } + return str; +} + +char* psStr = NULL; // psQuote returned string +char* psQuote(const char* str) +{ + // we must must quote '(', ')', and '\' + if (psStr) + delete [] psStr; + + psStr = new char[strlen(str)*2+1]; // worst case size + + char* out = psStr; + const char* in = str; + while (in && *in) { + if (*in == '(' || *in == ')' || *in == '\\') + *out++ = '\\'; + *out++ = *in++; + } + + *out++ = '\0'; // terminating char + return psStr; +} + +const char* psFontName(const char* font) +{ + char* str = (char*)font; + char* ff = str; + while (*str && *str++ != ' '); + // char* zz = str; + while (*str && *str++ != ' '); + char* ww = str; + while (*str && *str++ != ' '); + char* ss = str; + + if (ff && ww && ss) + return psFontName(ff,ww,ss); + else + return psFonts[0]; +} + +int psFontSize(const char* font) +{ + char* str = (char*)font; + while (*str && *str++ != ' '); + return atoi(str); +} + +const char* psFontName(const char* font, const char* weight, const char* slant) +{ + int ptr = 0; + if (!strncmp(font,"helvetica",4)) + ptr = 0; + else if (!strncmp(font,"times",4)) + ptr = 4; + else if (!strncmp(font,"courier",4)) + ptr = 8; + + if (!strncmp(weight,"normal",4)) + ; + else if (!strncmp(weight,"bold",4)) + ptr +=2; + + if (!strncmp(slant,"roman",4)) + ; + else if (!strncmp(slant,"italic",4)) + ptr++; + + return psFonts[ptr]; +} + +int fCompare(const void* a, const void* b) +{ + float* aa = (float*)a; + float* bb = (float*)b; + + if (*aa < *bb) + return -1; + if (*aa > *bb) + return 1; + return 0; +} + +int dCompare(const void* a, const void* b) +{ + double* aa = (double*)a; + double* bb = (double*)b; + + if (*aa < *bb) + return -1; + if (*aa > *bb) + return 1; + return 0; +} + +Vector mapLen(const Vector& v, const Matrix& mx) +{ + // remove translation + Vector t = Vector() * mx; + Matrix sr = mx * Translate(-t); + + // remove rotation + Vector r = Vector(1,0) * sr; + Matrix s = sr * Rotate(r.angle()); + + // all that is left is Scaling + return (v*s).abs(); +} + +#if defined (MAC_OSX_TK) || (_WIN32) + +int XSetClipRectangles(Display *d, GC gc, int clip_x_origin, int clip_y_origin, + XRectangle* rectangles, int n, int ordering) +{ + TkRegion clipRgn = TkCreateRegion(); + + while (n--) { + XRectangle rect = *rectangles; + + rect.x += clip_x_origin; + rect.y += clip_y_origin; + TkUnionRectWithRegion(&rect, clipRgn, clipRgn); + rectangles++; + } + TkSetRegion(d, gc, clipRgn); + TkDestroyRegion(clipRgn); + return 1; +} + +#endif diff --git a/tksao/util/util.h b/tksao/util/util.h new file mode 100644 index 0000000..383095a --- /dev/null +++ b/tksao/util/util.h @@ -0,0 +1,125 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __util_h__ +#define __util_h__ + +#include +#include +#include +#include +#include + +#include +#include +#include +using namespace std; + +#include +#include + +#include "fuzzy.h" +#include "vector.h" + +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +#ifdef _WIN32 +#include +#endif + +#ifdef MAC_OSX_TK +#include +void XXWarpPointer(Display* display, Window src_w, Window dest_w, + int src_x, int src_y, + unsigned int src_width, unsigned int src_height, + int dest_x, int dest_y); +#endif + +#if defined (MAC_OSX_TK) || (_WIN32) +int XSetClipRectangles(Display *d, GC gc, int clip_x_origin, int clip_y_origin, + XRectangle* rectangles, int n, int ordering); +#endif + +#define STRCMP(which,str,cnt) (!strncmp(toConstLower(which), str, cnt) && strlen(which)==cnt) + +static const char psFonts[12][32] = { + {"Helvetica"}, + {"Helvetica-Oblique"}, + {"Helvetica-Bold"}, + {"Helvetica-BoldOblique"}, + + {"Times-Roman"}, + {"Times-Italic"}, + {"Times-Bold"}, + {"Times-BoldItalic"}, + + {"Courier"}, + {"Courier-Oblique"}, + {"Courier-Bold"}, + {"Courier-BoldOblique"} +}; + +#ifndef __CYGWIN__ +static const double M_TWOPI = 2*M_PI; +#endif +static const double M_THREEPI = 3*M_PI; +static const double M_FOURPI = 4*M_PI; + +extern int maperr; + +extern int lsb(); + +extern void swap2(char* src, char* dest); +extern void swap4(char* src, char* dest); +extern void swap8(char* src, char* dest); + +// defined in ds9.C +extern void internalError(const char*); + +extern char* dupstr(const char*); +extern char* trim(const char*); +extern char* toLower(const char*); +extern char* toUpper(const char*); +extern char* toConstLower(const char*); +extern char* toConstUpper(const char*); + +extern double zeroTWOPI(double); +extern double zero360(double); +extern double m180To180(double); +extern double degToRad(double); +extern double radToDeg(double); + +extern int parseSection(char*, Vector*, Vector*); + +extern double dmsToDegree(int, int, int, double); +extern double parseSEXStr(const char*); +extern double parseHMSStr(const char*); +extern double parseDMSStr(const char*); + +extern double RGB2Gray(double, double, double); +extern unsigned char RGB2Gray(unsigned char, unsigned char, unsigned char); +extern void RGB2CMYK(unsigned char, unsigned char, unsigned char, + unsigned char*, unsigned char*, unsigned char*, + unsigned char*); +extern void RGB2CMYK(unsigned short, unsigned short, unsigned short, + unsigned short*, unsigned short*, unsigned short*, + unsigned short*); +extern ostream& psColorGray(XColor*, ostream&); +extern ostream& psColorRGB(XColor*, ostream&); +extern ostream& psColorCMYK(XColor*, ostream&); + +extern char* psQuote(const char*); + +extern const char* psFontName(const char*); +extern int psFontSize(const char*); +extern const char* psFontName(const char*, const char*, const char*); + +extern int fCompare(const void*, const void*); +extern int dCompare(const void*, const void*); + +extern Vector mapLen(const Vector& v, const Matrix& mx); + +#endif diff --git a/tksao/vector/vector.C b/tksao/vector/vector.C new file mode 100644 index 0000000..b7c3340 --- /dev/null +++ b/tksao/vector/vector.C @@ -0,0 +1,413 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "vector.h" +#include "vector3d.h" +#include "fuzzy.h" + +// Vector::manip + +int Vector::separator = ios_base::xalloc(); +int Vector::unit = ios_base::xalloc(); + +Vector::Vector(const Vector3d& a) +{ + v[0]=a.v[0]; + v[1]=a.v[1]; + v[2]=1; +} + +Vector& Vector::operator=(const Vector3d& a) +{ + v[0]=a.v[0]; + v[1]=a.v[1]; + v[2]=1; + return *this; +} + +Vector& Vector::clip(const BBox& bb) +{ + // restrict vector by bbox + Vector ll(bb.ll); + Vector ur(bb.ur); + if (v[0]ur[0]) + v[0]=ur[0]; + if (v[1]ur[1]) + v[1]=ur[1]; + return *this; +} + +Vector Vector::TkCanvasPs(void* canvas) +{ + return Vector(v[0], Tk_CanvasPsY((Tk_Canvas)canvas, v[1])); +} + +ostream& operator<<(ostream& os, const Vector& v) +{ + unsigned char sep = (unsigned char)os.iword(Vector::separator); + if (!sep) + sep = ' '; + + unsigned char unit = (unsigned char)os.iword(Vector::unit); + if (!unit) + os << v.v[0] << sep << v.v[1]; + else + os << v.v[0] << unit << sep << v.v[1] << unit; + + // reset unit + os.iword(Vector::unit) = '\0'; + + return os; +} + +istream& operator>>(istream& s, Vector& v) +{ + s >> v.v[0] >> v.v[1]; + return s; +} + +// Vertex + +ostream& operator<<(ostream& os, const Vertex& v) +{ + os << v.vector; + return os; +} + +// Matrix + +Matrix& Matrix::operator*=(const Matrix& a) +{ + Matrix r; + for (int i=0; i<3; i++) + for (int j=0; j<3; j++) + r.m[i][j] = + m[i][0]*a.m[0][j] + + m[i][1]*a.m[1][j] + + m[i][2]*a.m[2][j]; + + return *this=r; +} + +Matrix Matrix::invert() +{ + Matrix cc = this->cofactor(); + Matrix aa = cc.adjoint(); + double dd = m[0][0]*aa.m[0][0] + m[0][1]*aa.m[1][0] + m[0][2]*aa.m[2][0]; + + Matrix rr; + for (int ii=0; ii<3; ii++ ) + for (int jj=0; jj<3; jj++) + rr.m[ii][jj] = aa.m[ii][jj]/dd; + + return rr; +} + +Matrix Matrix::cofactor() +{ + Matrix rr; + + rr.m[0][0] = +(m[1][1]*m[2][2]-m[1][2]*m[2][1]); + rr.m[0][1] = -(m[1][0]*m[2][2]-m[1][2]*m[2][0]); + rr.m[0][2] = +(m[1][0]*m[2][1]-m[1][1]*m[2][0]); + + rr.m[1][0] = -(m[0][1]*m[2][2]-m[0][2]*m[2][1]); + rr.m[1][1] = +(m[0][0]*m[2][2]-m[0][2]*m[2][0]); + rr.m[1][2] = -(m[0][0]*m[2][1]-m[0][1]*m[2][0]); + + rr.m[2][0] = +(m[0][1]*m[1][2]-m[0][2]*m[1][1]); + rr.m[2][1] = -(m[0][0]*m[1][2]-m[0][2]*m[1][0]); + rr.m[2][2] = +(m[0][0]*m[1][1]-m[0][1]*m[1][0]); + + return rr; +} + +double Matrix::det() +{ + return + + m[0][0]*(m[1][1]*m[2][2]-m[1][2]*m[2][1]) + - m[0][1]*(m[1][0]*m[2][2]-m[1][2]*m[2][0]) + + m[0][2]*(m[1][0]*m[2][1]-m[1][1]*m[2][0]); +} + +Matrix Matrix::adjoint() +{ + Matrix rr; + for (int ii=0; ii<3; ii++) + for (int jj=0; jj<3; jj++) + rr.m[jj][ii] = m[ii][jj]; + + return rr; +} + +ostream& operator<<(ostream& os, const Matrix& m) +{ + os << ' '; + for (int i=0; i<3; i++) + for (int j=0; j<2; j++) + os << m.m[i][j] << ' '; + + return os; +} + +istream& operator>>(istream& s, Matrix& m) +{ + for (int i=0; i<3; i++ ) + for (int j=0; j<2; j++) + s >> m.m[i][j]; + + return s; +} + +// Translate + +ostream& operator<<(ostream& os, const Translate& m) +{ + os << ' ' << m.m[2][0] << ' ' << m.m[2][1] << ' '; + return os; +} + +istream& operator>>(istream& s, Translate& m) +{ + s >> m.m[2][0] >> m.m[2][1]; + return s; +} + +// Scale + +ostream& operator<<(ostream& os, const Scale& m) +{ + os << ' ' << m.m[0][0] << ' ' << m.m[1][1] << ' '; + return os; +} + +istream& operator>>(istream& s, Scale& m) +{ + s >> m.m[0][0] >> m.m[1][1]; + return s; +} + +// Rotate + +Rotate::Rotate(double a) : Matrix() +{ + // note: signs reverse for X-Windows (origin is upper left) + m[0][0] = cos(a); + m[0][1] = -sin(a); + m[1][0] = sin(a); + m[1][1] = cos(a); + + // this fixes a problem with numbers too small and tring to invert the matrix + tzero(&m[0][0]); + tzero(&m[0][1]); + tzero(&m[1][0]); + tzero(&m[1][1]); +} + +ostream& operator<<(ostream& os, const Rotate& m) +{ + os << ' ' << m.m[0][0] << ' ' << m.m[0][1] + << ' ' << m.m[1][0] << ' ' << m.m[1][1] << ' '; + return os; +} + +istream& operator>>(istream& s, Rotate& m) +{ + s >> m.m[0][0] >> m.m[0][1] >> m.m[1][0] >> m.m[1][1]; + return s; +} + +// BBox + +BBox::BBox(double a, double b, double c, double d) +{ + // we want a 'positive' box + ll.v[0] = a < c ? a : c; + ll.v[1] = b < d ? b : d; + ur.v[0] = a < c ? c : a; + ur.v[1] = b < d ? d : b; +} + +BBox::BBox(const Vector& l, const Vector& h) +{ + // we want a 'positive' box + ll.v[0] = l.v[0] < h.v[0] ? l.v[0] : h.v[0]; + ll.v[1] = l.v[1] < h.v[1] ? l.v[1] : h.v[1]; + ur.v[0] = l.v[0] < h.v[0] ? h.v[0] : l.v[0]; + ur.v[1] = l.v[1] < h.v[1] ? h.v[1] : l.v[1]; +} + +int BBox::isIn(const Vector& v) const +{ + return !(v.v[0] < ll.v[0] || v.v[1] < ll.v[1] || + v.v[0] > ur.v[0] || v.v[1] > ur.v[1]); +} + +int BBox::isIn(const BBox& bb) const +{ + // return 0 if outside, > 0 if intersection + // = 4 if inside + BBox b = bb; + return isIn(b.ll) + isIn(b.ur) + isIn(b.ul()) + isIn(b.lr()); +} + +BBox& BBox::bound(const Vector& v) +{ + if (v.v[0] < ll[0]) + ll[0] = v.v[0]; + if (v.v[1] < ll[1]) + ll[1] = v.v[1]; + + if (v.v[0] > ur[0]) + ur[0] = v.v[0]; + if (v.v[1] > ur[1]) + ur[1] = v.v[1]; + + return *this; +} + +BBox& BBox::bound(BBox b) +{ + this->bound(b.ll); + this->bound(b.lr()); + this->bound(b.ur); + this->bound(b.ul()); + + return *this; +} + +BBox intersect(const BBox& a, const BBox& b) +{ + // test for obvious + int ab = a.isIn(b); + int ba = b.isIn(a); + + // no intersection? + if (ab==0 && ba == 0) { + // maybe they are just crossed, check the centers + int abc = a.isIn(((BBox&)b).center()); + int bac = b.isIn(((BBox&)a).center()); + if (abc==0 && bac==0) + return BBox(); + } + + if (ab == 4) // b is inside a + return b; + if (ba == 4) // a is inside b + return a; + + // else, there seems to be some overlap + BBox r; + r.ll.v[0] = (a.ll.v[0] > b.ll.v[0]) ? a.ll.v[0] : b.ll.v[0]; + r.ll.v[1] = (a.ll.v[1] > b.ll.v[1]) ? a.ll.v[1] : b.ll.v[1]; + r.ur.v[0] = (a.ur.v[0] < b.ur.v[0]) ? a.ur.v[0] : b.ur.v[0]; + r.ur.v[1] = (a.ur.v[1] < b.ur.v[1]) ? a.ur.v[1] : b.ur.v[1]; + + return r; +} + +ostream& operator<<(ostream& os, const BBox& b) +{ + os << b.ll << ' ' << b.ur; + return os; +} + +// Cohen–Sutherland clipping algorithm +// bounded diagonally by (0,0), and (width, height) + +const int INSIDE = 0; // 0000 +const int LEFT = 1; // 0001 +const int RIGHT = 2; // 0010 +const int BOTTOM = 4; // 0100 +const int TOP = 8; // 1000 + +static int calcOutCode(Vector vv, int width, int height) +{ + int code = INSIDE; + + if (vv[0] < 0) // to the left of clip window + code |= LEFT; + else if (vv[0] > width) // to the right of clip window + code |= RIGHT; + if (vv[1] < 0) // below the clip window + code |= BOTTOM; + else if (vv[1] > height) // above the clip window + code |= TOP; + + return code; +} + +int clip(Vector* v0, Vector* v1, int width, int height) +{ + int outcode0 = calcOutCode(*v0, width, height); + int outcode1 = calcOutCode(*v1, width, height); + int accept = false; + + while (true) { + if (!(outcode0 | outcode1)) { + // Bitwise OR is 0. Trivially accept and get out of loop + accept = true; + break; + } + else if (outcode0 & outcode1) { + // Bitwise AND is not 0. Trivially reject and get out of loop + break; + } + else { + // At least one endpoint is outside the clip rectangle; pick it. + int outcodeOut = outcode0 ? outcode0 : outcode1; + + // Now find the intersection point + // y = y0 + slope * (x - x0) + // x = x0 + (1 / slope) * (y - y0) + double x, y; + if (outcodeOut & TOP) { + // point is above the clip rectangle + x = (*v0)[0] + ((*v1)[0]-(*v0)[0]) * + (height-(*v0)[1]) / ((*v1)[1]-(*v0)[1]); + y = height; + } + else if (outcodeOut & BOTTOM) { + // point is below the clip rectangle + x = (*v0)[0] + ((*v1)[0]-(*v0)[0]) * + (0-(*v0)[1]) / ((*v1)[1]-(*v0)[1]); + y = 0; + } + else if (outcodeOut & RIGHT) { + // point is to the right of clip rectangle + y = (*v0)[1] + ((*v1)[1]-(*v0)[1]) * + (width-(*v0)[0]) / ((*v1)[0]-(*v0)[0]); + x = width; + } + else if (outcodeOut & LEFT) { + // point is to the left of clip rectangle + y = (*v0)[1] + ((*v1)[1]-(*v0)[1]) * + (0-(*v0)[0]) / ((*v1)[0]-(*v0)[0]); + x = 0; + } + + // Now we move outside point to intersection point to clip + // and get ready for next pass. + if (outcodeOut == outcode0) { + (*v0)[0] = x; + (*v0)[1] = y; + outcode0 = calcOutCode(*v0, width, height); + } + else { + (*v1)[0] = x; + (*v1)[1] = y; + outcode1 = calcOutCode(*v1, width, height); + } + } + } + + return accept; +} + diff --git a/tksao/vector/vector.h b/tksao/vector/vector.h new file mode 100644 index 0000000..da0932b --- /dev/null +++ b/tksao/vector/vector.h @@ -0,0 +1,372 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __vector_h__ +#define __vector_h__ + +#include +#include + +#include +using namespace std; + +class Vector3d; +class Matrix; +class BBox; + +class Vector { + public: + static int separator; + static int unit; + + double v[3]; + + public: + Vector() + {v[0]=0; v[1]=0; v[2]=1;} + Vector(double* f) + {v[0]=f[0]; v[1]=f[1]; v[2]=1;} + Vector(double x, double y) + {v[0]=x; v[1]=y; v[2]=1;} + + Vector(const Vector& a) + {v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2];} + Vector& operator=(const Vector& a) + {v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2]; return *this;} + + Vector(const Vector3d&); + Vector& operator=(const Vector3d&); + + double& operator[](int i) + {return v[i];} // return element + double* vv() + {return v;} // return vector + + Vector& origin() + {v[0]=0; v[1]=0; v[2]=1; return *this;} + + Vector& operator+=(const Vector& a) // addition + {v[0]+=a.v[0]; v[1]+=a.v[1]; return *this;} + Vector& operator-=(const Vector& a) // subtraction + {v[0]-=a.v[0]; v[1]-=a.v[1]; return *this;} + Vector& operator*=(double f) // scalar multipy + {v[0]*=f; v[1]*=f; return *this;} + Vector& operator/=(double f) // scalar division + {v[0]/=f; v[1]/=f; return *this;} + Vector& operator*=(const Matrix& m); // vector multipy + + Vector abs() + {return Vector(fabs(v[0]),fabs(v[1]));} + double angle() + {return atan2(v[1],v[0]);} + Vector ceil() + {return Vector(::ceil(v[0]),::ceil(v[1]));} + Vector floor() + {return Vector(::floor(v[0]),::floor(v[1]));} + Vector invert() + {return Vector(1/v[0],1/v[1]);} + double length() + {return sqrt(v[0]*v[0]+v[1]*v[1]);} + double area() + {return v[0]*v[1];} + Vector round() + {return Vector((int)(v[0]+.5),(int)(v[1]+.5));} + Vector normalize() + {double d = sqrt(v[0]*v[0]+v[1]*v[1]); + return d ? Vector(v[0]/d,v[1]/d) : Vector();} + // restrict vector by bbox + Vector& clip(const BBox&); + + Vector TkCanvasPs(void* canvas); +}; + +// This I/O manipulator flips the number stored in iword between 0 and 1 +/* +inline ios_base& setfoo(ios_base& os) +{ + os.iword(Vector::foo) = !os.iword(Vector::foo); + return os; +} +*/ + +// Vector separator(int) + +struct _Setseparator {int _M_n;}; +inline _Setseparator setseparator(int __n) +{ + _Setseparator __x; + __x._M_n = __n; + return __x; +} + +template + inline basic_ostream<_CharT,_Traits>& + operator<<(basic_ostream<_CharT,_Traits>& __os, _Setseparator __f) +{ + __os.iword(Vector::separator) = __f._M_n; + return __os; +} + +// Vector unit(int) + +struct _Setunit {int _M_n;}; +inline _Setunit setunit(int __n) +{ + _Setunit __x; + __x._M_n = __n; + return __x; +} + +template + inline basic_ostream<_CharT,_Traits>& + operator<<(basic_ostream<_CharT,_Traits>& __os, _Setunit __f) +{ + __os.iword(Vector::unit) = __f._M_n; + return __os; +} + +ostream& operator<<(ostream&, const Vector&); +istream& operator>>(istream&, Vector&); + +inline Vector operator-(const Vector& a) +{return Vector(-a.v[0],-a.v[1]);} +inline Vector operator+(const Vector& a, const Vector& b) +{return Vector(a) +=b;} +inline Vector operator-(const Vector& a, const Vector& b) +{return Vector(a) -=b;} +inline Vector operator*(const Vector& a, double b) +{return Vector(a) *=b;} +inline Vector operator/(const Vector& a, double b) +{return Vector(a) /=b;} +inline Vector operator*(const Vector& v, const Matrix& m) +{return Vector(v) *=m;} +inline double operator*(const Vector& a, const Vector& b) // dot product +{double r =0; r+=a.v[0]*b.v[0]; r+=a.v[1]*b.v[1]; return r;} + +class Vertex { +public: + Vector vector; + +private: + Vertex* next_; + Vertex* previous_; + +public: + Vertex() + {next_=NULL; previous_=NULL;} + Vertex(double x, double y) + {vector=Vector(x,y); next_=NULL; previous_=NULL;} + Vertex(const Vector& a) + {vector=a; next_=NULL; previous_=NULL;} + + Vertex(const Vertex& a) + {vector=a.vector; next_=a.next_; previous_=a.previous_;} + Vertex& operator=(const Vertex& a) + {vector=a.vector; next_=a.next_; previous_=a.previous_; return *this;} + + Vertex* next() + {return next_;} + Vertex* previous() + {return previous_;} + void setNext(Vertex* v) + {next_=v;} + void setPrevious(Vertex* v) + {previous_=v;} +}; +ostream& operator<<(ostream&, const Vertex&); + +class Matrix { + public: + double m[3][3]; + + public: + Matrix() + { m[0][0]=1; m[0][1]=0; m[0][2]=0; + m[1][0]=0; m[1][1]=1; m[1][2]=0; + m[2][0]=0; m[2][1]=0; m[2][2]=1;} + Matrix(double a, double b, + double c, double d, + double e, double f) + { m[0][0]=a; m[0][1]=b; m[0][2]=0; + m[1][0]=c; m[1][1]=d; m[1][2]=0; + m[2][0]=e; m[2][1]=f; m[2][2]=1;} + Matrix(double a, double b, double c, + double d, double e, double f, + double g, double h, double i) + { m[0][0]=a; m[0][1]=b; m[0][2]=c; + m[1][0]=d; m[1][1]=e; m[1][2]=f; + m[2][0]=g; m[2][1]=h; m[2][2]=i;} + + Matrix(const Matrix& a) + { m[0][0]=a.m[0][0]; m[0][1]=a.m[0][1]; m[0][2]=a.m[0][2]; + m[1][0]=a.m[1][0]; m[1][1]=a.m[1][1]; m[1][2]=a.m[1][2]; + m[2][0]=a.m[2][0]; m[2][1]=a.m[2][1]; m[2][2]=a.m[2][2];} + Matrix& operator=(const Matrix& a) + { m[0][0]=a.m[0][0]; m[0][1]=a.m[0][1]; m[0][2]=a.m[0][2]; + m[1][0]=a.m[1][0]; m[1][1]=a.m[1][1]; m[1][2]=a.m[1][2]; + m[2][0]=a.m[2][0]; m[2][1]=a.m[2][1]; m[2][2]=a.m[2][2]; return *this;} + + double matrix(int i, int j) // return element + {return m[i][j];} + Vector operator[](int i) // return row + {return Vector(m[i]);} + double* mm() const // return matrix + {return (double*)m;} + + Matrix& identity() + { m[0][0]=1; m[0][1]=0; m[0][2]=0; + m[1][0]=0; m[1][1]=1; m[1][2]=0; + m[2][0]=0; m[2][1]=0; m[2][2]=1; return *this;} + Matrix& operator*=(const Matrix&); // matrix multiply + + Matrix invert(); + Matrix cofactor(); + Matrix adjoint(); + double det(); +}; +ostream& operator<<(ostream&, const Matrix&); +istream& operator>>(istream&, Matrix&); + +inline Matrix operator*(const Matrix& a, const Matrix& b) +{return Matrix(a) *= b;} +inline Vector& Vector::operator*=(const Matrix& m) +{ + double vv[3]; + double* mm = (double*)(m.m); + vv[0] = v[0]*mm[0] + v[1]*mm[3] + v[2]*mm[6]; + vv[1] = v[0]*mm[1] + v[1]*mm[4] + v[2]*mm[7]; + vv[2] = v[0]*mm[2] + v[1]*mm[5] + v[2]*mm[8]; + v[0] = vv[0]; + v[1] = vv[1]; + v[2] = vv[2]; + return *this; +} + +class Translate : public Matrix { +public: + Translate() + {}; + Translate(double x, double y) + {m[2][0]=x; m[2][1]=y;} + Translate(const Vector& v) + {m[2][0]=v.v[0]; m[2][1]=v.v[1];} + Translate(const Matrix& a) + {m[2][0] = a.m[2][0]; m[2][1] = a.m[2][1];} +}; +ostream& operator<<(ostream&, const Translate&); +istream& operator>>(istream&, Translate&); + +class Scale : public Matrix { +public: + Scale() + {}; + Scale(double a) + {m[0][0]=a; m[1][1]=a;} + Scale(double a, double b) + {m[0][0]=a; m[1][1]=b;} + Scale(const Vector& v) + {m[0][0]=v.v[0]; m[1][1]=v.v[1];} + Scale(const Matrix& a) + {m[0][0] = a.m[0][0]; m[1][1] = a.m[1][1];} +}; +ostream& operator<<(ostream&, const Scale&); +istream& operator>>(istream&, Scale&); + +class FlipX : public Matrix { +public: + FlipX() + {m[0][0] = -1;} +}; + +class FlipY : public Matrix { +public: + FlipY() + {m[1][1] = -1;} +}; + +class FlipXY : public Matrix { +public: + FlipXY() + {m[0][0] = -1; m[1][1] = -1;} +}; + +class Rotate : public Matrix { +public: + Rotate() + {}; + Rotate(double); + Rotate(double a, double b, double c, double d) + {m[0][0] = a; m[0][1] = b; m[1][0] = c; m[1][1] = d;} + Rotate(const Matrix& a) + { m[0][0]=a.m[0][0]; m[0][1]=a.m[0][1]; + m[1][0]=a.m[1][0]; m[1][1]=a.m[1][1];} +}; +ostream& operator<<(ostream&, const Rotate&); +istream& operator>>(istream&, Rotate&); + +class BBox { +public: + Vector ll; + Vector ur; + +public: + BBox() + {} + BBox(double w, double h) + {ll.v[0] = 0; ll.v[1] = 0; ur.v[0] = w; ur.v[1] = h;} + BBox(const Vector& v) + {ll=v; ur=v;} + BBox(double, double, double, double); + BBox(const Vector&, const Vector&); + + BBox(const BBox& a) + {ll=a.ll; ur=a.ur;} + BBox& operator=(const BBox& a) + {ll=a.ll; ur=a.ur; return *this;} + + Vector lr() {return Vector(ur[0],ll[1]);} + Vector ul() {return Vector(ll[0],ur[1]);} + + BBox& operator+=(const Vector& v) // addition + {ll+=v; ur+=v; return *this;} + BBox& operator-=(const Vector& a) // subtraction + {ll-=a; ur-=a; return *this;} + BBox& operator*=(const Matrix& m) // multiply + {ll*=m; ur*=m; return *this;} + + Vector center() + {return (ur-ll)/2 + ll;} + Vector size() + {return ur - ll;} + int isEmpty() const + {Vector v = ur-ll; return (v[0]==0 && v[1]==0);} + int isIn(const Vector&) const; + int isIn(const BBox&) const; + + BBox& expand(double a) + {ll-=Vector(a,a); ur+=Vector(a,a); return *this;} + BBox& expand(const Vector& v) + {ll-=v; ur+=v; return *this;} + BBox& shrink(double a) + {ll+=Vector(a,a); ur-=Vector(a,a); return *this;} + BBox& shrink(const Vector& v) + {ll+=v; ur-=v; return *this;} + BBox& bound(BBox); + BBox& bound(const Vector&); +}; +ostream& operator<<(ostream&, const BBox&); + +inline BBox operator+(const BBox& b, const Vector& v) {return BBox(b) += v;} +inline BBox operator-(const BBox& b, const Vector& v) {return BBox(b) -= v;} +inline BBox operator*(const BBox& b, const Matrix& m) {return BBox(b) *= m;} + +BBox intersect(const BBox&, const BBox&); + +// clip line to box from origin to width,height +int clip(Vector*, Vector*, int, int); +#endif + + + + diff --git a/tksao/vector/vector3d.C b/tksao/vector/vector3d.C new file mode 100644 index 0000000..f0ed8d0 --- /dev/null +++ b/tksao/vector/vector3d.C @@ -0,0 +1,473 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include + +#include "vector3d.h" +#include "vector.h" +#include "fuzzy.h" + +// Vector3d + +Vector3d::Vector3d(const Vector& a) +{ + v[0]=a.v[0]; + v[1]=a.v[1]; + v[2]=0; + v[3]=1; +} + +Vector3d::Vector3d(const Vector& a, double z) +{ + v[0]=a.v[0]; + v[1]=a.v[1]; + v[2]=z; + v[3]=1; +} + +Vector3d& Vector3d::operator=(const Vector& a) +{ + v[0]=a.v[0]; + v[1]=a.v[1]; + v[2]=0; + v[3]=1; + return *this; +} + +Vector Vector3d::TkCanvasPs(void* canvas) +{ + return Vector(v[0], Tk_CanvasPsY((Tk_Canvas)canvas, v[1])); +} + +ostream& operator<<(ostream& os, const Vector3d& v) +{ + unsigned char sep = (unsigned char)os.iword(Vector::separator); + if (!sep) + sep = ' '; + + unsigned char unit = (unsigned char)os.iword(Vector::unit); + if (!unit) + os << v.v[0] << sep << v.v[1] << sep << v.v[2]; + else + os << v.v[0] << unit << v.v[1] << unit << v.v[2] << unit; + + // reset unit + os.iword(Vector::unit) = '\0'; + + return os; +} + +istream& operator>>(istream& s, Vector3d& v) +{ + s >> v.v[0] >> v.v[1] >> v.v[2]; + return s; +} + +// Vertex3d + +ostream& operator<<(ostream& os, const Vertex3d& v) +{ + os << v.vector; + return os; +} + +// Matrix3d + +Matrix3d& Matrix3d::operator*=(const Matrix3d& a) +{ + Matrix3d r; + for (int ii=0; ii<4; ii++) + for (int jj=0; jj<4; jj++) + r.m[ii][jj] = + m[ii][0]*a.m[0][jj] + + m[ii][1]*a.m[1][jj] + + m[ii][2]*a.m[2][jj] + + m[ii][3]*a.m[3][jj]; + + return *this=r; +} + +Matrix3d::Matrix3d(const Matrix& a) +{ + m[0][0]=a.m[0][0]; + m[0][1]=a.m[0][1]; + m[0][2]=0; + m[0][3]=0; + + m[1][0]=a.m[1][0]; + m[1][1]=a.m[1][1]; + m[1][2]=0; + m[1][3]=0; + + m[2][0]=0; + m[2][1]=0; + m[2][2]=1; + m[2][3]=0; + + m[3][0]=a.m[2][0]; + m[3][1]=a.m[2][1]; + m[3][2]=0; + m[3][3]=1; +} + +Matrix3d Matrix3d::invert() +{ + Matrix3d cc = this->cofactor(); + Matrix3d aa = cc.adjoint(); + double dd = m[0][0]*aa.m[0][0] + m[0][1]*aa.m[1][0] + + m[0][2]*aa.m[2][0] + m[0][3]*aa.m[3][0]; + + Matrix3d rr; + for (int ii=0; ii<4; ii++ ) + for (int jj=0; jj<4; jj++) + rr.m[ii][jj] = aa.m[ii][jj]/dd; + + return rr; +} + +Matrix3d Matrix3d::cofactor() +{ + Matrix3d rr; + + rr.m[0][0] = +det2d(m[1][1],m[1][2],m[1][3], + m[2][1],m[2][2],m[2][3], + m[3][1],m[3][2],m[3][3]); + rr.m[0][1] = -det2d(m[1][0],m[1][2],m[1][3], + m[2][0],m[2][2],m[2][3], + m[3][0],m[3][2],m[3][3]); + rr.m[0][2] = +det2d(m[1][0],m[1][1],m[1][3], + m[2][0],m[2][1],m[2][3], + m[3][0],m[3][1],m[3][3]); + rr.m[0][3] = -det2d(m[1][0],m[1][1],m[1][2], + m[2][0],m[2][1],m[2][2], + m[3][0],m[3][1],m[3][2]); + + rr.m[1][0] = -det2d(m[0][1],m[0][2],m[0][3], + m[2][1],m[2][2],m[2][3], + m[3][1],m[3][2],m[3][3]); + rr.m[1][1] = +det2d(m[0][0],m[0][2],m[0][3], + m[2][0],m[2][2],m[2][3], + m[3][0],m[3][2],m[3][3]); + rr.m[1][2] = -det2d(m[0][0],m[0][1],m[0][3], + m[2][0],m[2][1],m[2][3], + m[3][0],m[3][1],m[3][3]); + rr.m[1][3] = +det2d(m[0][0],m[0][1],m[0][2], + m[2][0],m[2][1],m[2][2], + m[3][0],m[3][1],m[3][2]); + + rr.m[2][0] = +det2d(m[0][1],m[0][2],m[0][3], + m[1][1],m[1][2],m[1][3], + m[3][1],m[3][2],m[3][3]); + rr.m[2][1] = -det2d(m[0][0],m[0][2],m[0][3], + m[1][0],m[1][2],m[1][3], + m[3][0],m[3][2],m[3][3]); + rr.m[2][2] = +det2d(m[0][0],m[0][1],m[0][3], + m[1][0],m[1][1],m[1][3], + m[3][0],m[3][1],m[3][3]); + rr.m[2][3] = -det2d(m[0][0],m[0][1],m[0][2], + m[1][0],m[1][1],m[1][2], + m[3][0],m[3][1],m[3][2]); + + rr.m[3][0] = -det2d(m[0][1],m[0][2],m[0][3], + m[1][1],m[1][2],m[1][3], + m[2][1],m[2][2],m[2][3]); + rr.m[3][1] = +det2d(m[0][0],m[0][2],m[0][3], + m[1][0],m[1][2],m[1][3], + m[2][0],m[2][2],m[2][3]); + rr.m[3][2] = -det2d(m[0][0],m[0][1],m[0][3], + m[1][0],m[1][1],m[1][3], + m[2][0],m[2][1],m[2][3]); + rr.m[3][3] = +det2d(m[0][0],m[0][1],m[0][2], + m[1][0],m[1][1],m[1][2], + m[2][0],m[2][1],m[2][2]); + + return rr; +} + +Matrix3d Matrix3d::adjoint() +{ + Matrix3d rr; + for (int ii=0; ii<4; ii++) + for (int jj=0; jj<4; jj++) + rr.m[jj][ii] = m[ii][jj]; + + return rr; +} + +double Matrix3d::det() +{ + Matrix3d cc = this->cofactor(); + Matrix3d aa = cc.adjoint(); + return m[0][0]*aa.m[0][0] + m[0][1]*aa.m[1][0] + + m[0][2]*aa.m[2][0] + m[0][3]*aa.m[3][0]; +} + +void Matrix3d::dump() +{ + for (int ii=0; ii<4; ii++) { + for (int jj=0; jj<4; jj++) + cerr << m[ii][jj] << ' '; + cerr << endl; + } + cerr << endl; +} + +ostream& operator<<(ostream& os, const Matrix3d& m) +{ + os << ' '; + for (int ii=0; ii<4; ii++) + for (int jj=0; jj<3; jj++) + os << m.m[ii][jj] << ' '; + + return os; +} + +istream& operator>>(istream& s, Matrix3d& m) +{ + for (int ii=0; ii<4; ii++ ) + for (int jj=0; jj<3; jj++) + s >> m.m[ii][jj]; + + return s; +} + +// Translate3d + +Translate3d::Translate3d(const Vector& v) +{ + m[3][0]=v.v[0]; + m[3][1]=v.v[1]; + m[3][2]=0; +} + +Translate3d::Translate3d(const Vector& v, double z) +{ + m[3][0]=v.v[0]; + m[3][1]=v.v[1]; + m[3][2]=z; +} + +ostream& operator<<(ostream& os, const Translate3d& m) +{ + os << ' ' << m.m[3][0] << ' ' << m.m[3][1] << ' ' << m.m[3][2] << ' '; + return os; +} + +istream& operator>>(istream& s, Translate3d& m) +{ + s >> m.m[3][0] >> m.m[3][1] >> m.m[3][2]; + return s; +} + +// Scale3d + +Scale3d::Scale3d(const Vector& v) +{ + m[0][0]=v.v[0]; m[1][1]=v.v[1]; m[2][2]=1; +} + +Scale3d::Scale3d(const Vector& v, double c) +{ + m[0][0]=v.v[0]; m[1][1]=v.v[1]; m[2][2]=c; +} + +ostream& operator<<(ostream& os, const Scale3d& m) +{ + os << ' ' << m.m[0][0] << ' ' << m.m[1][1] << ' ' << m.m[2][2] << ' '; + return os; +} + +istream& operator>>(istream& s, Scale3d& m) +{ + s >> m.m[0][0] >> m.m[1][1] >> m.m[2][2]; + return s; +} + +// RotateX3d + +RotateX3d::RotateX3d(double a) : Matrix3d() +{ + m[1][1] = cos(a); + m[1][2] = sin(a); + m[2][1] = -sin(a); + m[2][2] = cos(a); + + // this fixes a problem with numbers too small and tring to invert the matrix + tzero(&m[1][1]); + tzero(&m[1][2]); + tzero(&m[2][1]); + tzero(&m[2][2]); +} + +ostream& operator<<(ostream& os, const RotateX3d& m) +{ + os << ' ' << m.m[1][1] << ' ' << m.m[1][2] + << ' ' << m.m[2][1] << ' ' << m.m[2][2] << ' '; + return os; +} + +istream& operator>>(istream& s, RotateX3d& m) +{ + s >> m.m[1][1] >> m.m[1][2] >> m.m[2][1] >> m.m[2][2]; + return s; +} + +// RotateY3d + +RotateY3d::RotateY3d(double a) : Matrix3d() +{ + m[0][0] = cos(a); + m[0][2] = -sin(a); + m[2][0] = sin(a); + m[2][2] = cos(a); + + // this fixes a problem with numbers too small and tring to invert the matrix + tzero(&m[0][0]); + tzero(&m[0][2]); + tzero(&m[2][0]); + tzero(&m[2][2]); +} + +ostream& operator<<(ostream& os, const RotateY3d& m) +{ + os << ' ' << m.m[0][0] << ' ' << m.m[0][2] + << ' ' << m.m[2][0] << ' ' << m.m[2][2] << ' '; + return os; +} + +istream& operator>>(istream& s, RotateY3d& m) +{ + s >> m.m[0][0] >> m.m[0][2] >> m.m[2][0] >> m.m[2][2]; + return s; +} + +// RotateZ3d + +RotateZ3d::RotateZ3d(double a) : Matrix3d() +{ + m[0][0] = cos(a); + m[0][1] = sin(a); + m[1][0] = -sin(a); + m[1][1] = cos(a); + + // this fixes a problem with numbers too small and tring to invert the matrix + tzero(&m[0][0]); + tzero(&m[0][1]); + tzero(&m[1][0]); + tzero(&m[1][1]); +} + +ostream& operator<<(ostream& os, const RotateZ3d& m) +{ + os << ' ' << m.m[0][0] << ' ' << m.m[0][1] + << ' ' << m.m[1][0] << ' ' << m.m[1][1] << ' '; + return os; +} + +istream& operator>>(istream& s, RotateZ3d& m) +{ + s >> m.m[0][0] >> m.m[0][1] >> m.m[1][0] >> m.m[1][1]; + return s; +} + +// BBox3d + +BBox3d::BBox3d(double a, double b, double c, double d, double e, double f) +{ + // we want a 'positive' cube + ll.v[0] = a < d ? a : d; + ll.v[1] = b < e ? b : e; + ll.v[2] = c < f ? c : f; + ur.v[0] = a < d ? d : a; + ur.v[1] = b < e ? e : b; + ur.v[2] = c < f ? f : c; +} + +BBox3d::BBox3d(const Vector3d& l, const Vector3d& h) +{ + // we want a 'positive' cube + ll.v[0] = l.v[0] < h.v[0] ? l.v[0] : h.v[0]; + ll.v[1] = l.v[1] < h.v[1] ? l.v[1] : h.v[1]; + ll.v[2] = l.v[2] < h.v[2] ? l.v[2] : h.v[2]; + ur.v[0] = l.v[0] < h.v[0] ? h.v[0] : l.v[0]; + ur.v[1] = l.v[1] < h.v[1] ? h.v[1] : l.v[1]; + ur.v[2] = l.v[2] < h.v[2] ? h.v[2] : l.v[2]; +} + +int BBox3d::isIn(const Vector3d& v) const +{ + return !(v.v[0] < ll.v[0] || v.v[1] < ll.v[1] || v.v[2] < ll.v[2] || + v.v[0] > ur.v[0] || v.v[1] > ur.v[1] || v.v[2] > ur.v[2]); +} + +double BBox3d::volume() +{ + Vector3d aa =ur-ll; + return aa[0]*aa[1]*aa[2]; +} + +BBox3d& BBox3d::bound(const Vector3d& vv) +{ + // expand bbox3d to include vector3d + if (vv.v[0] < ll[0]) + ll[0] = vv.v[0]; + if (vv.v[1] < ll[1]) + ll[1] = vv.v[1]; + if (vv.v[2] < ll[2]) + ll[2] = vv.v[2]; + + if (vv.v[0] > ur[0]) + ur[0] = vv.v[0]; + if (vv.v[1] > ur[1]) + ur[1] = vv.v[1]; + if (vv.v[2] > ur[2]) + ur[2] = vv.v[2]; + + return *this; +} + +ostream& operator<<(ostream& os, const BBox3d& b) +{ + os << b.ll << ' ' << b.ur; + return os; +} + +// WorldToView + +Matrix3d WorldToView3d(const Vector3d& cop, + const Vector3d& vpn, + const Vector3d& vup) +{ + Vector3d zv = ((Vector3d)vpn).normalize(); + Vector3d xv = cross(zv,(Vector3d&)vup).normalize(); + Vector3d yv = cross(xv,zv).normalize(); + + return Translate3d(-cop) * + Matrix3d(xv[0],yv[0],zv[0], + xv[1],yv[1],zv[1], + xv[2],yv[2],zv[2], + 0, 0, 0); +} + +Matrix3d WorldToView3d(const Vector3d& cop, + double head, double pitch, double bank) +{ + return Translate3d(-cop) * + RotateY3d(head) * + RotateX3d(pitch) * + RotateZ3d(bank) * + Scale3d(1,1,-1); +} + +Matrix3d WorldToView3d(const Vector3d& cop, const Vector3d& vpn, double bank) +{ + Vector3d zv = -((Vector3d)vpn).normalize(); + double l=sqrt(zv[0]*zv[0]+zv[2]*zv[2]); + + return Translate3d(-cop) * + RotateY3d(zv[2]/l,zv[0]/l,-zv[0]/l,zv[2]/l) * + RotateX3d(l,zv[1],-zv[1],l) * + RotateZ3d(bank) * + Scale3d(1,1,-1); +} diff --git a/tksao/vector/vector3d.h b/tksao/vector/vector3d.h new file mode 100644 index 0000000..03aeb58 --- /dev/null +++ b/tksao/vector/vector3d.h @@ -0,0 +1,395 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __vector3d_h__ +#define __vector3d_h__ + +#include +#include + +#include +using namespace std; + +class Vector; +class Matrix; +class Matrix3d; + +class Vector3d { + public: + double v[4]; + + public: + Vector3d() + {v[0]=0;v[1]=0;v[2]=0;v[3]=1;} + Vector3d(double* f) + {v[0]=f[0]; v[1]=f[1]; v[2]=f[2]; v[3]=1;} + Vector3d(double x, double y) + {v[0]=x;v[1]=y;v[2]=0;v[3]=1;} + Vector3d(double x, double y, double z) + {v[0]=x;v[1]=y;v[2]=z;v[3]=1;} + + Vector3d(const Vector&); + Vector3d(const Vector&, double); + Vector3d& operator=(const Vector&); + + Vector3d(const Vector3d& a) + {v[0]=a.v[0];v[1]=a.v[1];v[2]=a.v[2];v[3]=a.v[3];} + Vector3d& operator=(const Vector3d& a) + {v[0]=a.v[0];v[1]=a.v[1];v[2]=a.v[2];v[3]=a.v[3]; return *this;} + + double& operator[](int i) {return v[i];} // return element + double* vv() {return v;} // return vector + + Vector3d& operator+=(const Vector3d& a) // addition + {v[0]+=a.v[0]; v[1]+=a.v[1]; v[2]+=a.v[2]; return *this;} + Vector3d& operator-=(const Vector3d& a) // subtraction + {v[0]-=a.v[0]; v[1]-=a.v[1]; v[2]-=a.v[2]; return *this;} + Vector3d& operator*=(double f) // scalar multiply + {v[0]*=f; v[1]*=f; v[2]*=f; return *this;} + Vector3d& operator/=(double f) // scalar division + {v[0]/=f; v[1]/=f; v[2]/=f; return *this;} + Vector3d& operator*=(const Matrix3d&); // vector multiply + + Vector3d abs() + {return Vector3d(fabs(v[0]),fabs(v[1]),fabs(v[2]));} + double angleX() + {return atan2(v[2],v[1]);} + double angleY() + {return atan2(v[0],v[2]);} + double angleZ() + {return atan2(v[1],v[0]);} + Vector3d ceil() + {return Vector3d(::ceil(v[0]),::ceil(v[1]),::ceil(v[2]));} + Vector3d floor() + {return Vector3d(::floor(v[0]),::floor(v[1]),::floor(v[2]));} + Vector3d invert() + {return Vector3d(1/v[0],1/v[1],1/v[2]);} + double length() + {return sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);} + Vector3d round() + {return Vector3d((int)(v[0]+.5),(int)(v[1]+.5),(int)(v[2]+.5));} + Vector3d normalize() + {double d = sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]); + return d ? Vector3d(v[0]/d,v[1]/d,v[2]/d) : Vector3d();} + Vector3d project() + {return (v[3]!=1) ? Vector3d(v[0]/v[3],v[1]/v[3],v[2]/v[3]) : *this;} + Vector TkCanvasPs(void* canvas); +}; +ostream& operator<<(ostream&, const Vector3d&); +istream& operator>>(istream&, Vector3d&); + +inline Vector3d operator-(const Vector3d& a) +{return Vector3d(-a.v[0],-a.v[1],-a.v[2]);} +inline Vector3d operator+(const Vector3d& a, const Vector3d& b) +{return Vector3d(a) +=b;} +inline Vector3d operator-(const Vector3d& a, const Vector3d& b) +{return Vector3d(a) -=b;} +inline Vector3d operator*(const Vector3d& a, double b) +{return Vector3d(a) *=b;} +inline Vector3d operator/(const Vector3d& a, double b) +{return Vector3d(a) /=b;} +inline Vector3d operator*(const Vector3d& v, const Matrix3d& m) +{return Vector3d(v) *=m;} +inline double operator*(const Vector3d& a, const Vector3d& b) // dot product +{double r=0; r+=a.v[0]*b.v[0]; r+=a.v[1]*b.v[1]; r+=a.v[2]*b.v[2]; return r;} +inline Vector3d cross(Vector3d& a, Vector3d& b) // cross product +{return Vector3d(a[1]*b[2]-b[1]*a[2],a[2]*b[0]-b[2]*a[0],a[0]*b[1]-b[0]*a[1]);} + +class Vertex3d { +public: + Vector3d vector; + +private: + Vertex3d* next_; + Vertex3d* previous_; + +public: + Vertex3d() + {next_=NULL; previous_=NULL;} + Vertex3d(double x, double y, double z) + {vector=Vector3d(x,y,z); next_=NULL; previous_=NULL;} + Vertex3d(const Vector3d& a) + {vector=a; next_=NULL; previous_=NULL;} + + Vertex3d(const Vertex3d& a) + {vector=a.vector; next_=a.next_; previous_=a.previous_;} + Vertex3d& operator=(const Vertex3d& a) + {vector=a.vector; next_=a.next_; previous_=a.previous_; return *this;} + + Vertex3d* next() + {return next_;} + Vertex3d* previous() + {return previous_;} + void setNext(Vertex3d* v) + {next_ = v;} + void setPrevious(Vertex3d* v) + {previous_ = v;} +}; +ostream& operator<<(ostream&, const Vertex3d&); + +class Matrix3d { + public: + double m[4][4]; + + public: + Matrix3d() + { m[0][0]=1; m[0][1]=0; m[0][2]=0; m[0][3]=0; + m[1][0]=0; m[1][1]=1; m[1][2]=0; m[1][3]=0; + m[2][0]=0; m[2][1]=0; m[2][2]=1; m[2][3]=0; + m[3][0]=0; m[3][1]=0; m[3][2]=0; m[3][3]=1; } + + Matrix3d(double a, double b, double c, + double d, double e, double f, + double g, double h, double i, + double j, double k, double l) + { m[0][0]=a; m[0][1]=b; m[0][2]=c; m[0][3]=0; + m[1][0]=d; m[1][1]=e; m[1][2]=f; m[1][3]=0; + m[2][0]=g; m[2][1]=h; m[2][2]=i; m[2][3]=0; + m[3][0]=j; m[3][1]=k; m[3][2]=l; m[3][3]=1; } + + Matrix3d(Vector3d& x, Vector3d& y, Vector3d& z) + { m[0][0]=x[0]; m[0][1]=y[0]; m[0][2]=z[0]; m[0][3]=0; + m[1][0]=x[1]; m[1][1]=y[1]; m[1][2]=z[1]; m[1][3]=0; + m[2][0]=x[2]; m[2][1]=y[2]; m[2][2]=z[2]; m[2][3]=0; + m[3][0]=0; m[3][1]=0; m[3][2]=0; m[3][3]=1; } + + Matrix3d(const Matrix3d& a) + { m[0][0]=a.m[0][0];m[0][1]=a.m[0][1];m[0][2]=a.m[0][2];m[0][3]=a.m[0][3]; + m[1][0]=a.m[1][0];m[1][1]=a.m[1][1];m[1][2]=a.m[1][2];m[1][3]=a.m[1][3]; + m[2][0]=a.m[2][0];m[2][1]=a.m[2][1];m[2][2]=a.m[2][2];m[2][3]=a.m[2][3]; + m[3][0]=a.m[3][0];m[3][1]=a.m[3][1];m[3][2]=a.m[3][2];m[3][3]=a.m[3][3]; } + + Matrix3d& operator=(const Matrix3d& a) + { m[0][0]=a.m[0][0];m[0][1]=a.m[0][1];m[0][2]=a.m[0][2];m[0][3]=a.m[0][3]; + m[1][0]=a.m[1][0];m[1][1]=a.m[1][1];m[1][2]=a.m[1][2];m[1][3]=a.m[1][3]; + m[2][0]=a.m[2][0];m[2][1]=a.m[2][1];m[2][2]=a.m[2][2];m[2][3]=a.m[2][3]; + m[3][0]=a.m[3][0];m[3][1]=a.m[3][1];m[3][2]=a.m[3][2];m[3][3]=a.m[3][3]; + return *this;} + + Matrix3d(const Matrix& a); + double matrix(int i, int j) + {return m[i][j];} // return element + Vector3d operator[](int i) + {return Vector3d(m[i]);} // return row + double* mm() + {return (double*)m;} // return matrix + + Matrix3d& identity() + { m[0][0]=1; m[0][1]=0; m[0][2]=0; m[0][3]=0; + m[1][0]=0; m[1][1]=1; m[1][2]=0; m[1][3]=0; + m[2][0]=0; m[2][1]=0; m[2][2]=1; m[2][3]=0; + m[3][0]=0; m[3][1]=0; m[3][2]=0; m[3][3]=1; return *this;} + Matrix3d& operator*=(const Matrix3d&); // matrix multiply + + Matrix3d invert(); + Matrix3d cofactor(); + Matrix3d adjoint(); + double det(); + double det2d(double& a, double& b, double& c, + double& d, double& e, double& f, + double& g, double& h, double& i) + {return a*(e*i-f*h) - b*(d*i-f*g) + c*(d*h-e*g);} + + void dump(); +}; +ostream& operator<<(ostream&, const Matrix3d&); +istream& operator>>(istream&, Matrix3d&); + +inline Matrix3d operator*(const Matrix3d& a, const Matrix3d& b) +{return Matrix3d(a) *= b;} +inline Vector3d& Vector3d::operator*=(const Matrix3d& m) +{ + double vv[4]; + double* mm = (double*)(m.m); + vv[0] = v[0]*mm[0] + v[1]*mm[4] + v[2]*mm[8] + v[3]*mm[12]; + vv[1] = v[0]*mm[1] + v[1]*mm[5] + v[2]*mm[9] + v[3]*mm[13]; + vv[2] = v[0]*mm[2] + v[1]*mm[6] + v[2]*mm[10] + v[3]*mm[14]; + vv[3] = v[0]*mm[3] + v[1]*mm[7] + v[2]*mm[11] + v[3]*mm[15]; + v[0] = vv[0]; + v[1] = vv[1]; + v[2] = vv[2]; + v[3] = vv[3]; + return *this; +} + +class Translate3d : public Matrix3d { +public: + Translate3d() {}; + Translate3d(double x, double y, double z) + {m[3][0]=x; m[3][1]=y; m[3][2]=z;} + Translate3d(const Vector3d& v) + {m[3][0]=v.v[0]; m[3][1]=v.v[1]; m[3][2]=v.v[2];} + Translate3d(const Vector& v); + Translate3d(const Vector& v, double z); + Translate3d(const Matrix3d& a) + {m[3][0] = a.m[3][0]; m[3][1] = a.m[3][1]; m[3][2] = a.m[3][2];} +}; +ostream& operator<<(ostream&, const Translate3d&); +istream& operator>>(istream&, Translate3d&); + +class Scale3d : public Matrix3d { +public: + Scale3d() {}; + Scale3d(double a) + {m[0][0]=a; m[1][1]=a; m[2][2]=a;} + Scale3d(double a, double b) + {m[0][0]=a; m[1][1]=a; m[2][2]=b;} + Scale3d(double a, double b, double c) + {m[0][0]=a; m[1][1]=b; m[2][2]=c;} + Scale3d(const Vector& v); + Scale3d(const Vector& v, double c); + Scale3d(const Vector3d& v) + {m[0][0]=v.v[0]; m[1][1]=v.v[1]; m[2][2]=v.v[2];} + Scale3d(const Matrix3d& a) + {m[0][0] = a.m[0][0]; m[1][1] = a.m[1][1]; m[2][2] = a.m[2][2];} +}; +ostream& operator<<(ostream&, const Scale3d&); +istream& operator>>(istream&, Scale3d&); + +class FlipX3d : public Matrix3d { +public: + FlipX3d() + {m[0][0] = -1;} +}; + +class FlipY3d : public Matrix3d { +public: + FlipY3d() + {m[1][1] = -1;} +}; + +class FlipZ3d : public Matrix3d { +public: + FlipZ3d() + {m[2][2] = -1;} +}; + +class FlipXY3d : public Matrix3d { +public: + FlipXY3d() + {m[0][0] = -1; m[1][1] = -1;} +}; + +class FlipXYZ3d : public Matrix3d { +public: + FlipXYZ3d() + {m[0][0] = -1; m[1][1] = -1; m[2][2] = -1;} +}; + +class RotateX3d : public Matrix3d { +public: + RotateX3d() + {}; + RotateX3d(double); + RotateX3d(double a, double b, double c, double d) + {m[1][1] = a; m[1][2] = b; m[2][1] = c; m[2][2] = d;} +}; +ostream& operator<<(ostream&, const RotateX3d&); +istream& operator>>(istream&, RotateX3d&); + +class RotateY3d : public Matrix3d { +public: + RotateY3d() + {}; + RotateY3d(double); + RotateY3d(double a, double b, double c, double d) + {m[0][0] = a; m[0][2] = b; m[2][0] = c; m[2][2] = d;} +}; +ostream& operator<<(ostream&, const RotateY3d&); +istream& operator>>(istream&, RotateY3d&); + +class RotateZ3d : public Matrix3d { +public: + RotateZ3d() + {}; + RotateZ3d(double); + RotateZ3d(double a, double b, double c, double d) + {m[0][0] = a; m[0][1] = b; m[1][0] = c; m[1][1] = d;} +}; +ostream& operator<<(ostream&, const RotateZ3d&); +istream& operator>>(istream&, RotateZ3d&); + +class Shear3d : public Matrix3d { + public: + Shear3d(double x, double y, double dist) + {m[2][0] = -x/dist; m[2][1] = -y/dist;} +}; + +class Perspective3d : public Matrix3d { + public: + Perspective3d(double front, double back, double dist) + { m[2][2] = back/(back-front); m[2][3] = 1; + m[3][2] = -front*back/(dist*(back-front)); m[3][3] = 0;} +}; + +class BBox3d { + public: + Vector3d ll; + Vector3d ur; + + public: + BBox3d() + {} + BBox3d(double w, double h, double d) + {ll.v[0]=0; ll.v[1]=0; ll.v[2]=0; ur.v[0]=w; ur.v[1]=h; ur.v[2]=d;} + BBox3d(const Vector3d& v) + {ll=v; ur=v;} + BBox3d(double, double, double, double, double, double); + BBox3d(const Vector3d&, const Vector3d&); + + BBox3d(const BBox3d& a) + {ll=a.ll; ur=a.ur;} + BBox3d& operator=(const BBox3d& a) + {ll=a.ll; ur=a.ur; return *this;} + + BBox3d& operator+=(const Vector3d& v) // addition + {ll+=v; ur+=v; return *this;} + BBox3d& operator-=(const Vector3d& a) // subtraction + {ll-=a; ur-=a; return *this;} + BBox3d& operator*=(const Matrix3d& m) // multiplication + {ll*=m; ur*=m; return *this;} + + double volume(); + Vector3d center() + {return (ur-ll)/2 + ll;} + Vector3d size() + {return ur - ll;} + int isEmpty() const + {Vector3d v = ur-ll; return (v[0]==0 && v[1]==0 && v[2]==0);} + int isIn(const Vector3d&) const; + + BBox3d& expand(double a) + {ll-=Vector3d(a,a,a); ur+=Vector3d(a,a,a); return *this;} + BBox3d& expand(const Vector3d& v) + {ll-=v; ur+=v; return *this;} + BBox3d& shrink(double a) + {ll+=Vector3d(a,a,a); ur-=Vector3d(a,a,a); return *this;} + BBox3d& shrink(const Vector3d& v) + {ll+=v; ur-=v; return *this;} + // expand bbox3d to include vector3d + BBox3d& bound(const Vector3d&); +}; +ostream& operator<<(ostream&, const BBox3d&); + +inline BBox3d operator+(const BBox3d& b, const Vector3d& v) +{return BBox3d(b) += v;} +inline BBox3d operator-(const BBox3d& b, const Vector3d& v) +{return BBox3d(b) -= v;} +inline BBox3d operator*(const BBox3d& b, const Matrix3d& m) +{return BBox3d(b) *= m;} + +// WorldToView + +Matrix3d WorldToView3d(const Vector3d& cop, + const Vector3d& vpn, + const Vector3d& vup); +Matrix3d WorldToView3d(const Vector3d& cop, + double head, double pitch, double bank); +Matrix3d WorldToView3d(const Vector3d& cop, const Vector3d& vpn, double bank); + +#endif + + + + diff --git a/tksao/vector/vectorold.C b/tksao/vector/vectorold.C new file mode 100644 index 0000000..a0d9e4a --- /dev/null +++ b/tksao/vector/vectorold.C @@ -0,0 +1,884 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include "vector.h" + +// Vector + +Vector operator-(const Vector& a) +{ + return Vector(-a.v[0], -a.v[1]); +} + +Vector& Vector::operator+=(const Vector& a) +{ + v[0]+=a.v[0]; + v[1]+=a.v[1]; + return *this; +} + +Vector operator+(const Vector& a, const Vector& b) +{ + Vector r=a; + r+=b; + return r; +} + +Vector& Vector::operator-=(const Vector& a) +{ + v[0]-=a.v[0]; + v[1]-=a.v[1]; + return *this; +} + +Vector operator-(const Vector& a, const Vector& b) +{ + Vector r=a; + r-=b; + return r; +} + +Vector& Vector::operator*=(double f) +{ + v[0]*=f; + v[1]*=f; + return *this; +} + +Vector operator*(const Vector& a, double b) +{ + Vector r=a; + r*=b; + return r; +} + +Vector& Vector::operator/=(double f) +{ + v[0]/=f; + v[1]/=f; + return *this; +} + +Vector operator/(const Vector& a, double b) +{ + Vector r=a; + r/=b; + return r; +} + +double operator*(const Vector& a, const Vector& b) // 2D dot product +{ + double r = 0; + for (int i=0; i<2; i++) + r += a.v[i]*b.v[i]; + return r; +} + +Vector Vector::normalize() // 2D normalize +{ + Vector r = *this; + double d = sqrt(v[0]*v[0]+v[1]*v[1]); + if (d) { + r[0] /= d; + r[1] /= d; + } + else { + r[0] = 0; + r[1] = 0; + } + + return r; +} + +Vector Vector::abs() // absolute value +{ + Vector r; + r[0] = fabs(v[0]); + r[1] = fabs(v[1]); + r[2] = 1; + return r; +} + +double Vector::length() +{ + return sqrt(v[0]*v[0] + v[1]*v[1]); +} + +double Vector::angle() +{ + return atan2(v[1],v[0]); +} + +double Vector::avg() +{ + return (v[0]+v[1])/2; +} + +double Vector::max() +{ + return v[0]>v[1]?v[0]:v[1]; +} + +double Vector::min() +{ + return v[0]>(istream& s, Vector& v) +{ + s >> v.v[0] >> v.v[1]; + return s; +} + +Vector cross(Vector& a, Vector& b) +{ + return Vector(a[1]*b[2]-b[1]*a[2], a[2]*b[0]-b[2]*a[0], a[0]*b[1]-b[0]*a[1]); +} + +// the following are not valid for 2D graphics: + +Vector& Vector::div(double f) +{ + v[0]/=f; + v[1]/=f; + v[2]/=f; + return *this; +} + +Vector& Vector::minus(const Vector& a) +{ + v[0]-=a.v[0]; + v[1]-=a.v[1]; + v[2]-=a.v[2]; + return *this; +} + +Vector mult(const Vector& a, double f) +{ + Vector r = a; + r.v[0]*= f; + r.v[1]*= f; + r.v[2]*= f; + return r; +} + +Vector& Vector::operator*=(const Vector& b) +{ + v[0]*=b.v[0]; + v[1]*=b.v[1]; + v[2]=1; + return *this; +} + +Vector& Vector::operator/=(const Vector& b) +{ + v[0]/=b.v[0]; + v[1]/=b.v[1]; + v[2]=1; + return *this; +} + +// Vertex + +Vertex::Vertex() +{ + next_ = NULL; + previous_ = NULL; +} + +Vertex::Vertex(double x, double y) +{ + vector = Vector(x,y); + next_ = NULL; + previous_ = NULL; +} + +Vertex::Vertex(const Vector& a) +{ + vector = a; + next_ = NULL; + previous_ = NULL; +} + +ostream& operator<<(ostream& s, const Vertex& v) +{ + s << v.vector; + return s; +} + +// Matrix + +Matrix::Matrix() +{ + for (int i=0; i<3; i++) + for (int j=0; j<3; j++) + m[i][j] = (i==j ? 1 : 0); +} + +Matrix::Matrix(const Matrix& a) +{ + for (int i=0; i<3; i++) + for (int j=0; j<3; j++) + m[i][j] = a.m[i][j]; +} + +Matrix& Matrix::operator=(const Matrix& a) +{ + for (int i=0; i<3; i++) + for (int j=0; j<3; j++) + m[i][j] = a.m[i][j]; + + return *this; +} + +Matrix::Matrix(const Vector& v0, const Vector& v1, const Vector& v2) +{ + int i; + for (i=0; i<3; i++) + m[0][i] = v0.v[i]; + for (i=0; i<3; i++) + m[1][i] = v1.v[i]; + for (i=0; i<3; i++) + m[2][i] = v2.v[i]; +} + +Matrix::Matrix(double a, double b, double c, double d, double e, double f) +{ + m[0][0]=a; + m[0][1]=b; + m[0][2]=0; + m[1][0]=c; + m[1][1]=d; + m[1][2]=0; + m[2][0]=e; + m[2][1]=f; + m[2][2]=1; +} + +Matrix& Matrix::identity() +{ + for (int i=0; i<3; i++) + for (int j=0; j<3; j++) + m[i][j] = (i==j ? 1 : 0); + + return *this; +} + +int Matrix::isIdentity() +{ + return ((m[0][0]==1) && (m[0][1]==0) && (m[0][2]==0) && + (m[1][0]==0) && (m[1][1]==1) && (m[1][2]==0) && + (m[2][0]==0) && (m[2][1]==0) && (m[2][2]==1)); +} + +Matrix Matrix::abs() +{ + Matrix r; + r.m[0][0] = fabs(m[0][0]); + r.m[1][1] = fabs(m[1][1]); + return r; +} + +Matrix& Matrix::operator*=(double a) +{ + for (int i=0; i<3; i++) + for (int j=0; j<3; j++) + m[i][j] *= a; + + return *this; +} + +Matrix& Matrix::operator/=(double a) +{ + for (int i=0; i<3; i++) + for (int j=0; j<3; j++) + m[i][j] /= a; + + return *this; +} + +Matrix& Matrix::operator*=(const Matrix& a) +{ + Matrix r; + for (int i=0; i<3; i++) + for (int j=0; j<3; j++) + r.m[i][j] = m[i][0]*a.m[0][j] + m[i][1]*a.m[1][j] + m[i][2]*a.m[2][j]; + + return *this=r; +} + +Matrix Matrix::invert() +{ + // Method of Row Reduction-- Calculus and Analylic Geometry, A-13 + + Matrix r; // identy matrix + + Vector m0 = m[0]; + Vector m1 = m[1]; + Vector m2 = m[2]; + + Vector r0 = r[0]; + Vector r1 = r[1]; + Vector r2 = r[2]; + + // check for 0 in m[0], swap rows 0 and 1 if so. + // this seems to be a problem only in the case of rotation of 90/270 degress + + if ((m0[0]==0) || + (m0[0]>0 && m0[0]-DBL_EPSILON)) { + + Vector tm0 = m0; + Vector tr0 = r0; + m0 = m1; + r0 = r1; + m1 = tm0; + r1 = tr0; + } + + // scale first row by 1/m0[0] + + r0.div(m0[0]); + m0.div(m0[0]); + + // zero out m1[0] and m2[0] + + r1.minus(mult(r0,m1[0])); + m1.minus(mult(m0,m1[0])); + r2.minus(mult(r0,m2[0])); + m2.minus(mult(m0,m2[0])); + + // scale second row by 1/m1[1] + + r1.div(m1[1]); + m1.div(m1[1]); + + // zero out m0[1] and m2[1] + + r0.minus(mult(r1,m0[1])); + m0.minus(mult(m1,m0[1])); + r2.minus(mult(r1,m2[1])); + m2.minus(mult(m1,m2[1])); + + // scale third row by 1/m[2] + + r2.div(m2[2]); + m2.div(m2[2]); + + // and zero out m0[2] and m1[2] + + r0.minus(mult(r2,m0[2])); + m0.minus(mult(m2,m0[2])); + r1.minus(mult(r2,m1[2])); + m2.minus(mult(m2,m1[2])); + + return Matrix(r0,r1,r2); +} + +Matrix Matrix::invert2() +{ + Matrix cc = this->cofactor(); + Matrix aa = cc.adjoint(); + double det = m[0][0]*aa.m[0][0] + m[0][1]*aa.m[1][0] + m[0][2]*aa.m[2][0]; + + Matrix rr; + for (int ii=0; ii<3; ii++ ) + for (int jj=0; jj<3; jj++) + rr.m[ii][jj] = aa.m[ii][jj]/det; + + return rr; +} + +Matrix Matrix::cofactor() +{ + Matrix rr; + + rr.m[0][0] = +(m[1][1]*m[2][2]-m[1][2]*m[2][1]); + rr.m[0][1] = -(m[1][0]*m[2][2]-m[1][2]*m[2][0]); + rr.m[0][2] = +(m[1][0]*m[2][1]-m[1][1]*m[2][0]); + + rr.m[1][0] = -(m[0][1]*m[2][2]-m[0][2]*m[2][1]); + rr.m[1][1] = +(m[0][0]*m[2][2]-m[0][2]*m[2][0]); + rr.m[1][2] = -(m[0][0]*m[2][1]-m[0][1]*m[2][0]); + + rr.m[2][0] = +(m[0][1]*m[1][2]-m[0][2]*m[1][1]); + rr.m[2][1] = -(m[0][0]*m[1][2]-m[0][2]*m[1][0]); + rr.m[2][2] = +(m[0][0]*m[1][1]-m[0][1]*m[1][0]); + + return rr; +} + +Matrix Matrix::adjoint() +{ + Matrix rr; + for (int ii=0; ii<3; ii++) + for (int jj=0; jj<3; jj++) + rr.m[jj][ii] = m[ii][jj]; + + return rr; +} + +Matrix operator*(const Matrix& a, double b) +{ + Matrix r=a; + return r*=b; +} + +Matrix operator/(const Matrix& a, double b) +{ + Matrix r=a; + return r/=b; +} + +Matrix operator*(const Matrix& a, const Matrix& b) +{ + Matrix r=a; + return r*=b; +} + +Vector Matrix::operator[](int i) +{ + return Vector(m[i]); +} + +ostream& operator<<(ostream& s, const Matrix& m) +{ + s << ' '; + for (int i=0; i<3; i++) + for (int j=0; j<2; j++) + s << m.m[i][j] << ' '; + + return s; +} + +istream& operator>>(istream& s, Matrix& m) +{ + for (int i=0; i<3; i++ ) + for (int j=0; j<2; j++) + s >> m.m[i][j]; + + return s; +} + +// Translate + +Translate::Translate(double x, double y) : Matrix() +{ + m[2][0]=x; + m[2][1]=y; +} + +Translate::Translate(const Vector& v) : Matrix() +{ + m[2][0]=v.v[0]; + m[2][1]=v.v[1]; +} + +Translate::Translate(const Matrix& a) : Matrix() +{ + m[2][0] = a.m[2][0]; + m[2][1] = a.m[2][1]; +} + +Translate& Translate::operator=(const Matrix& a) +{ + m[2][0] = a.m[2][0]; + m[2][1] = a.m[2][1]; + return *this; +} + +ostream& operator<<(ostream& s, const Translate& m) +{ + s << ' ' << m.m[2][0] << ' ' << m.m[2][1] << ' '; + return s; +} + +istream& operator>>(istream& s, Translate& m) +{ + s >> m.m[2][0] >> m.m[2][1]; + return s; +} + +// Rotate + +Rotate::Rotate(double a) : Matrix() +{ + // note: signs reverse for X-Windows (origin is upper left) + + m[0][0] = cos(a); + m[0][1] = -sin(a); + m[1][0] = sin(a); + m[1][1] = cos(a); + + // this fixes a problem with numbers too small and tring to invert the matrix + + if ((m[0][0]>0 && m[0][0]-DBL_EPSILON)) + m[0][0] = 0; + + if ((m[0][1]>0 && m[0][1]-DBL_EPSILON)) + m[0][1] = 0; + + if ((m[1][0]>0 && m[1][0]-DBL_EPSILON)) + m[1][0] = 0; + + if ((m[1][1]>0 && m[1][1]-DBL_EPSILON)) + m[1][1] = 0; + +} + +Rotate::Rotate(double a, double b, double c, double d) : Matrix() +{ + m[0][0] = a; + m[0][1] = b; + m[1][0] = c; + m[1][1] = d; +} + +Rotate::Rotate(const Matrix& a) : Matrix() +{ + for (int i=0; i<2; i++) + for (int j=0; j<2; j++) + m[i][j] = a.m[i][j]; +} + +Rotate& Rotate::operator=(const Matrix& a) +{ + for (int i=0; i<2; i++) + for (int j=0; j<2; j++) + m[i][j] = a.m[i][j]; + + return *this; +} + +ostream& operator<<(ostream& s, const Rotate& m) +{ + s << ' ' << m.m[0][0] << ' ' << m.m[0][1] + << ' ' << m.m[1][0] << ' ' << m.m[1][1] << ' '; + return s; +} + +istream& operator>>(istream& s, Rotate& m) +{ + s >> m.m[0][0] >> m.m[0][1] >> m.m[1][0] >> m.m[1][1]; + return s; +} + +// Scale + +Scale::Scale(double a) : Matrix() +{ + m[0][0]=a; + m[1][1]=a; +} + +Scale::Scale(double a, double b) : Matrix() +{ + m[0][0]=a; + m[1][1]=b; +} + +Scale::Scale(const Vector& v) : Matrix() +{ + m[0][0]=v.v[0]; + m[1][1]=v.v[1]; +} + +Scale::Scale(const Matrix& a) : Matrix() +{ + m[0][0] = a.m[0][0]; + m[1][1] = a.m[1][1]; +} + +Scale& Scale::operator=(const Matrix& a) +{ + m[0][0] = a.m[0][0]; + m[1][1] = a.m[1][1]; + return *this; +} + +ostream& operator<<(ostream& s, const Scale& m) +{ + s << ' ' << m.m[0][0] << ' ' << m.m[1][1] << ' '; + return s; +} + +istream& operator>>(istream& s, Scale& m) +{ + s >> m.m[0][0] >> m.m[1][1]; + return s; +} + +// Flip + +FlipX::FlipX() : Matrix() +{ + m[0][0] = -1; +} + +FlipY::FlipY() : Matrix() +{ + m[1][1] = -1; +} + +FlipXY::FlipXY() : Matrix() +{ + m[0][0] = -1; + m[1][1] = -1; +} + +// BBox + +BBox::BBox(double a, double b, double c, double d) +{ + // we want a 'positive' box + + ll.v[0] = a < c ? a : c; + ll.v[1] = b < d ? b : d; + ur.v[0] = a < c ? c : a; + ur.v[1] = b < d ? d : b; +} + +BBox::BBox(double w, double h) +{ + ll.v[0] = 0; + ll.v[1] = 0; + ur.v[0] = w; + ur.v[1] = h; +} + +BBox::BBox(const Vector& l, const Vector& h) +{ + // we want a 'positive' box + + ll.v[0] = l.v[0] < h.v[0] ? l.v[0] : h.v[0]; + ll.v[1] = l.v[1] < h.v[1] ? l.v[1] : h.v[1]; + ur.v[0] = l.v[0] < h.v[0] ? h.v[0] : l.v[0]; + ur.v[1] = l.v[1] < h.v[1] ? h.v[1] : l.v[1]; +} + +BBox::BBox(const Vector& v) +{ + ll = v; + ur = v; +} + +BBox& BBox::operator+=(const Vector& v) +{ + ll+=v; + ur+=v; + return *this; +} + +BBox operator+(const BBox& b, const Vector& v) +{ + BBox r=b; + r+=v; + return r; +} + +BBox& BBox::operator-=(const Vector& a) +{ + ll-=a; + ur-=a; + return *this; +} + +BBox operator-(const BBox& b, const Vector& v) +{ + BBox r=b; + r-=v; + return r; +} + +int BBox::isIn(const Vector& v) const +{ + if (v.v[0] < ll.v[0] || v.v[1] < ll.v[1] || v.v[0] > ur.v[0] || v.v[1] > ur.v[1]) + return 0; + else + return 1; +} + +int BBox::isIn(const BBox& bb) const +{ + // return 0 if outside, > 0 if intersection + // = 4 if inside + BBox b = bb; + return isIn(b.ll) + isIn(b.ur) + isIn(b.ul()) + isIn(b.lr()); +} + +int BBox::isEmpty() const +{ + Vector v = ur-ll; + return (v[0]==0 && v[1]==0); +} + +Vector BBox::center() +{ + return (ur-ll)/2 + ll; +} + +Vector BBox::size() +{ + return ur - ll; +} + +BBox& BBox::operator*=(const Matrix& m) +{ + ll *= m; + ur *= m; + return *this; +} + +BBox operator*(const BBox& bb, const Matrix& m) +{ + BBox r = bb; + r*=m; + return r; +} + +BBox& BBox::expand(double a) +{ + ll -= Vector(a,a); + ur += Vector(a,a); + return *this; +} + +BBox& BBox::expand(const Vector& v) +{ + ll -= v; + ur += v; + return *this; +} + +BBox& BBox::shrink(double a) +{ + ll += Vector(a,a); + ur -= Vector(a,a); + return *this; +} + +BBox& BBox::shrink(const Vector& v) +{ + ll += v; + ur -= v; + return *this; +} + +BBox& BBox::bound(const Vector& v) +{ + if (v.v[0] < ll[0]) + ll[0] = v.v[0]; + if (v.v[1] < ll[1]) + ll[1] = v.v[1]; + + if (v.v[0] > ur[0]) + ur[0] = v.v[0]; + if (v.v[1] > ur[1]) + ur[1] = v.v[1]; + + return *this; +} + +BBox& BBox::bound(BBox b) +{ + this->bound(b.ll); + this->bound(b.lr()); + this->bound(b.ur); + this->bound(b.ul()); + + return *this; +} + +BBox intersect(const BBox& a, const BBox& b) +{ + // test for obvious + + int ab = a.isIn(b); + int ba = b.isIn(a); + + // we are missing a case here! two bbox's that cross + + if (ab==0 && ba == 0) // outside each other + return BBox(); + + if (ab == 4) // b is inside a + return b; + if (ba == 4) // a is inside b + return a; + + // else, there seems to be some overlap + + BBox r; + r.ll.v[0] = (a.ll.v[0] > b.ll.v[0]) ? a.ll.v[0] : b.ll.v[0]; + r.ll.v[1] = (a.ll.v[1] > b.ll.v[1]) ? a.ll.v[1] : b.ll.v[1]; + r.ur.v[0] = (a.ur.v[0] < b.ur.v[0]) ? a.ur.v[0] : b.ur.v[0]; + r.ur.v[1] = (a.ur.v[1] < b.ur.v[1]) ? a.ur.v[1] : b.ur.v[1]; + + return r; +} + +ostream& operator<<(ostream& s, const BBox& b) +{ + s << b.ll << b.ur; + return s; +} + + diff --git a/tksao/vector/vectorold.h b/tksao/vector/vectorold.h new file mode 100644 index 0000000..f41efa5 --- /dev/null +++ b/tksao/vector/vectorold.h @@ -0,0 +1,248 @@ +// Copyright (C) 1999-2016 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#ifndef __vector_h__ +#define __vector_h__ + +#include +#include + +#include +using namespace std; + +#include + +class Vector; +class Vertex; +class Matrix; +class Translate; +class Rotate; +class Scale; +class FlipX; +class FlipY; +class FlipXY; +class BBox; + +class Vector { + friend class Matrix; + friend class Translate; + friend class Scale; + friend class BBox; + + public: + double v[3]; + + public: + Vector() {v[0]=0;v[1]=0;v[2]=1;} // constructor + Vector(double* f) {v[0]=f[0];v[1]=f[1];v[2]=f[2];} // constructor + Vector(double x, double y) {v[0]=x;v[1]=y;v[2]=1;} // constructor + Vector(double x, double y, double z) {v[0]=x;v[1]=y;v[2]=z;} // constructor + Vector(const Vector& a) {v[0]=a.v[0];v[1]=a.v[1];v[2]=a.v[2];} // copy + Vector& operator=(const Vector& a) + {v[0]=a.v[0];v[1]=a.v[1];v[2]=a.v[2];return *this;} + + double& operator[](int i) {return v[i];} + Vector abs(); + double length(); + double angle(); + double avg(); + double max(); + double min(); + Vector round(); + Vector floor(); + Vector ceil(); + Vector invert(); + Vector normalize(); + Vector TkCanvasPs(Tk_Canvas); + + friend Vector operator-(const Vector&); // unary minus + friend Vector operator*(const Vector&, const Matrix&); // vector/matrix mult + friend double operator*(const Vector&, const Vector&); // dot product + + friend ostream& operator<<(ostream&, const Vector&); + friend istream& operator>>(istream&, Vector&); + + Vector& operator+=(const Vector&); // addition + Vector& operator-=(const Vector&); // subtraction + Vector& operator*=(double); // scalar multipy + Vector& operator/=(double); // scalar division + Vector& operator*=(const Matrix&); // vector multiply + + friend BBox intersect(const BBox&, const BBox&); + + // the following are not valid for 2D graphics: + Vector& div(double); + Vector& minus(const Vector&); + friend Vector mult(const Vector&, double); + Vector& operator*=(const Vector&); + Vector& operator/=(const Vector&); +}; + +Vector operator+(const Vector&, const Vector&); // addition +Vector operator-(const Vector&, const Vector&); // subtration +Vector operator*(const Vector&, double); // scalar multiply +Vector operator/(const Vector&, double); // scalar division + +Vector cross(Vector&, Vector&); + +class Vertex { +public: + Vector vector; + +private: + Vertex* next_; + Vertex* previous_; + +public: + Vertex(); + Vertex(double, double); + Vertex(const Vector&); + + Vertex* next() {return next_;} + Vertex* previous() {return previous_;} + + void setNext(Vertex* v) {next_ = v;} + void setPrevious(Vertex* v) {previous_ = v;} + + friend ostream& operator<<(ostream&, const Vertex&); +}; + +class Matrix { + friend class Vector; + friend class Translate; + friend class Rotate; + friend class Scale; + +protected: + double m[3][3]; + +public: + Matrix(); // constructor + Matrix(const Vector&, const Vector&, const Vector&); // constructor + Matrix(double, double, double, double, double, double); + Matrix(const Matrix&); // copy constructor + Matrix& operator=(const Matrix&); // assignment + + Vector operator[](int); // return row + double matrix(int i, int j) {return m[i][j];} // return element + Matrix& operator*=(double); // scalar multiply + Matrix& operator/=(double); // scalar division + Matrix& operator*=(const Matrix&); // matrix multiply + + Matrix invert(); // matrix inverse + + Matrix invert2(); + Matrix cofactor(); + Matrix adjoint(); + + Matrix abs(); // returns abs with no translation + Matrix& identity(); // sets to identity matrix; + int isIdentity(); + + double* mm() {return (double*)m;} + + friend Vector operator*(const Vector&, const Matrix&); // vector/matrix mult + friend ostream& operator<<(ostream&, const Matrix&); + friend istream& operator>>(istream&, Matrix&); +}; + +Matrix operator*(const Matrix&, double); // scalar multiply +Matrix operator/(const Matrix&, double); // scalar division +Matrix operator*(const Matrix&, const Matrix&); // matrix multiply + +class Translate : public Matrix { +public: + Translate() {}; // constructor + Translate(double, double); // constructor + Translate(const Vector&); // constructor + Translate(const Matrix&); // copy constructor + Translate& operator=(const Matrix&); // assignment + + friend ostream& operator<<(ostream&, const Translate&); + friend istream& operator>>(istream&, Translate&); +}; + +class Rotate : public Matrix { +public: + Rotate() {}; // constructor + Rotate(double); // constructor + Rotate(double, double, double, double); // constructor + Rotate(const Matrix&); // copy constructor + Rotate& operator=(const Matrix&); // assignment + + friend ostream& operator<<(ostream&, const Rotate&); + friend istream& operator>>(istream&, Rotate&); +}; + +class Scale : public Matrix { +public: + Scale() {}; // constructor + Scale(double); // constructor + Scale(double, double); // constructor + Scale(const Vector&); // constructor + Scale(const Matrix&); // copy constructor + Scale& operator=(const Matrix&); // assignment + + friend ostream& operator<<(ostream&, const Scale&); + friend istream& operator>>(istream&, Scale&); +}; + +class FlipX : public Matrix { +public: + FlipX(); // constructor +}; + +class FlipY : public Matrix { +public: + FlipY(); // constructor +}; + +class FlipXY : public Matrix { +public: + FlipXY(); // constructor +}; + +class BBox { +public: + Vector ll; + Vector ur; + +public: + BBox() {} + BBox(const Vector&, const Vector&); + BBox(const Vector&); + BBox(double, double); + BBox(double, double, double, double); + + BBox& operator+=(const Vector&); // addition + BBox& operator-=(const Vector&); // subtraction + BBox& operator*=(const Matrix&); // multiplication + + int isIn(const Vector&) const; + int isIn(const BBox&) const; + int isEmpty() const; + Vector center(); + Vector size(); + Vector lr() {return Vector(ur[0],ll[1]);} + Vector ul() {return Vector(ll[0],ur[1]);} + BBox& expand(double); + BBox& expand(const Vector&); + BBox& shrink(double); + BBox& shrink(const Vector&); + BBox& bound(const Vector&); + BBox& bound(BBox); + + friend ostream& operator<<(ostream&, const BBox&); +}; + +BBox operator+(const BBox&, const Vector&); // addition +BBox operator-(const BBox&, const Vector&); // subtraction +BBox operator*(const BBox&, const Matrix&); +BBox intersect(const BBox&, const BBox&); + +#endif + + + + diff --git a/tksao/wcssubs/COPYING b/tksao/wcssubs/COPYING new file mode 100644 index 0000000..6320024 --- /dev/null +++ b/tksao/wcssubs/COPYING @@ -0,0 +1,460 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + diff --git a/tksao/wcssubs/Files b/tksao/wcssubs/Files new file mode 100644 index 0000000..94d18da --- /dev/null +++ b/tksao/wcssubs/Files @@ -0,0 +1,179 @@ +WCSTools libwcs Subroutines (3.9.0, March 11, 2011) + +actread.c + Return stars from the USNO ACT Reference Catalog +binread.c + Return stars from catalog files in the TDC binary catalog format +catread.c + Return stars from catalog files in the TDC ASCII catalog format +catutil.c + Subroutines for catalog identification and number range decoding +cel.c + WCSLIB spherical coordinate transformation drivers +daoread.c + Read x, y, and magnitude from DAOFIND output file and return x, y, and + flux for use by IMSTAR or IMWCS. +dateutil.c + Subroutines for conversions between various date and time formats +distort.c + Subroutines for conversions between image pixel and focal plane coordinates +dsspos.c + dsspos() uses the WCS structure to compute sky coordinates given + image pixel X and Y for images with Digitized Sky Survey plate solutions + in their headers. dsspix() uses the WCS structure to compute image + pixel X and Y given sky coordinates for DSS images. Algorithms from + StSCI CASB. +fileutil.c + Subroutines for finding size and contents of ASCII files +findstar.c + findStars() gets the location and brightest pixel of stars in the given + image. Included are subroutines to find and reject bright pixels and + compute a star centroid. +fitsfile.c + FITS header and image reading and writing subroutines, including FITS + table support. +fitswcs.c + GetWCSFITS() returns a WCS structure used by wcs.c subroutines from a FITS + or IRAF .imh image, reading only the header. + GetFITShead() returns a FITS header from a FITS or IRAF .imh image. + DelWCS() delete the WCS keywords in a FITS header. +fortcat.c + Fortran wrapper subroutines for catalog reading subroutines ctgread() and ctgrnum() +fortwcs.c + Fortran wrapper subroutines for all useful subroutines in wcs.c and wcsinit.c +gscread.c + Return HST Guide Stars from standard CDROM format FITS table files for + a given RA, Dec, and magnitude range or list of star numbers. +gsc2read.c + Return GSC II Stars using an HTTP query over the web for + a given RA, Dec, and magnitude range or list of star numbers. +hget.c + Subroutines to extract values from FITS headers by keyword. + Subroutines for parsing RA and Dec strings are included. +hput.c + Subroutines to implant values into FITS headers by keyword (and to + delete headers). +iget.c + Subroutines to extract values from IRAF multi-keyword header parameters +imhfile.c + IRAF header and image reading and writing subroutines. IRAF headers + are converted to FITS headers for use by other programs and can be + derived from FITS headers for writing. +imio.c + Subroutines to get, put, and move pixels of various data types between images + im memory and a program. +imrotate.c + RotFITS() rotates an image by 90, 180, or 270 degrees, with an optional + left-right reflection before the rotation. +imgetwcs.c + GetWCSFITS() reads world coordinate system header information and returns + the image center coordinates and size as well as the wcs data structure. +imsetwcs.c + SetWCSFITS() uses findStars to find the stars in an image, gscread to + find the Guide Stars in the nominal image region, and findRegisration or + findCoords to fit plate-tangent WCS to the image. +lin.c + WCSLIB linear transformation subroutines +matchstar.c + StarMatch() takes a list of reference star positions and a list + of object coordinates from an image and finds the image pixels + which correspond to each of the reference stars. It then uses these + matches to get an image center, plate scale, and rotation. The actual + fit is based on the amoeba subroutine in Numerical Recipes, and all + necessary subroutines are included. +platepos.c + platepos() uses the WCS structure to compute sky coordinates given + image pixel X and Y for images with polynomial plate solutions + in their headers. platepix() uses the WCS structure to compute image + pixel X and Y given sky coordinates for such images. Algorithms are based + on those in dsspos.c, but go straight from pixels to angles without an + intermediate plate coordinate. +poly.c + Polynomial evaluation for SCAMP distortion correction +proj.c + WCSLIB spherical map projection subroutines +sdssread.c + Return Sloan Digital Sky Survey Photometry Catalog sources using an + HTTP query over the web for a given RA, Dec, and magnitude range. +sortstars.c + Subroutines to sort lists of stars by right ascension, magnitude, or flux +sph.c + WCSLIB spherical coordinate transformation subroutines +tabread.c + Return stars from a tab table format catalog file for a given RA, Dec, + and magnitude range or list of star numbers. Based on John Roll's + Starbase format. +tmcread.c + Return 2MASS Point Source Catalog stars from the catalog as ungzipped from + the DVD into (or linked from) a common root directory for a given RA, Dec, + and magnitude range or list of star numbers. Both IDR2 and All-Sky release + formats are supported. +tnxpos.c + tnxpos() uses the WCS keywords set up for IRAF's TNX projection to compute + sky coordinates given image pixel X and Y. tnxpix() uses the WCS structure + to compute image pixel X and Y given sky coordinates for such images. The + projection is a tangent plane with corrections between the rotation and + scaling and the actual projection. +uacread.c + Return USNO A and SA Catalog stars from their standard CDROM format + files for a given RA, Dec, and magnitude range or list of star numbers. +ubcread.c + Return USNO B Catalog stars from their standard format files for a + given RA, Dec, and magnitude range or list of star numbers. +ucacread.c + Return USNO UCAC1, UCAC2, or UCAC3 Catalog stars from their standard format + files for a given RA, Dec, and magnitude range or list of star numbers. +ujcread.c + Return USNO UJ Catalog stars from its standard CDROM format files for + a given RA, Dec, and magnitude range or list of star numbers. +wcs.c + Subroutines for using FITS or IRAF header spatial world coordinate + system information. +wcsinit.c + Subroutines to initialize WCS structure from a FITS header +wcscon.c + Subroutines for converting between B1950, J2000, and galactic + coordinates, mostly based on Starlink SLA_LIB subroutines. +webread.c + Open Starbase files across the Internet using HTTP queries +worldpos.c + worldpos() uses the WCS structure to compute sky coordinates given + image pixel X and Y for images with header information for any of 8 + standard world coordinate systems. worldpix() uses the WCS structure + to compute image pixel X and Y given sky coordinates for the same images. + Mostly from NRAO. +zpxpos.c + zpxpos() uses the WCS keywords set up for IRAF's ZPX projection to + compute sky coordinates given image pixel X and Y. zpxpix() uses + the WCS structure to compute image pixel X and Y given sky coordinates + for such images. The projection is a tangent plane with corrections + between the rotation and scaling and the actual projection. + +fitshead.h + Declarations of FITS header access subroutines +fitsfile.h + Declarations of image access subroutines and FITS table data structure. +imio.h + Declarations of subroutines to convert binary formats of numbers +lwcs.h + Constants used by star-finding and WCS-setting subroutines +wcscat.h + Declarations for star catalog data structures +wcs.h + Declaration of WCS data structure and useful conversions. +wcslib.h + Declarations for WCSLIB high level driver subroutines, trig and inverse + trig functions, spherical map projection subroutines, spherical coordinate + transformation drivers, and linear transformation subroutines + +* Notes: + WCSLIB subroutines were written by Mark Calabretta of CSIRO and have + been modified in several ways: + 1) His distributed wcs.h has been changed to wcslib.h, and + 2) wcstrig.c subroutine names have been changed from d() + to deg() to avoid name conflicts on some operating + systems. + 3) ifndef's at start of headers files have been named to reflect + the names of the header files, i.e. wcslib_h_ in wcslib.h. + 4) All header files have been combined into wcslib.h + 5) Emmanuel Bertin's SCAMP distortion has been added to proj.c:1 diff --git a/tksao/wcssubs/Makefile b/tksao/wcssubs/Makefile new file mode 100644 index 0000000..9caa507 --- /dev/null +++ b/tksao/wcssubs/Makefile @@ -0,0 +1,36 @@ +OBJS = wcsinit.o wcs.o wcscon.o fitsfile.o imhfile.o \ + hget.o hput.o iget.o imio.o worldpos.o platepos.o \ + tnxpos.o zpxpos.o dsspos.o poly.o \ + wcslib.o lin.o cel.o proj.o sph.o wcstrig.o dateutil.o distort.o + +libwcs.a: $(OBJS) + ar rv $@ $? + ranlib $@ + +cel.o: wcslib.h +distort.o: wcs.h fitshead.h wcslib.h +fitsfile.o: fitsfile.h fitshead.h +hget.o: fitshead.h +hput.o: fitshead.h +iget.o: fitshead.h +imhfile.o: fitsfile.h fitshead.h +imio.o: fitshead.h +lin.o: wcslib.h +platepos.o: wcs.h fitshead.h wcslib.h +poly.o: wcslib.h +proj.o: wcslib.h +sph.o: wcslib.h +tnxpos.o: wcs.h fitshead.h wcslib.h +zpxpos.o: wcs.h fitshead.h wcslib.h +wcs.o: wcs.h fitshead.h wcslib.h +wcsinit.o: wcs.h fitshead.h wcslib.h +wcscon.o: wcs.h fitshead.h wcslib.h +wcslib.o: wcslib.h +wcstrig.o: wcslib.h +worldpos.o: wcs.h fitshead.h wcslib.h +dateutil.o: fitsfile.h fitshead.h +fileutil.o: fitsfile.h + +clean: + rm -f *.a *.o + diff --git a/tksao/wcssubs/NEWS b/tksao/wcssubs/NEWS new file mode 100644 index 0000000..963ccc6 --- /dev/null +++ b/tksao/wcssubs/NEWS @@ -0,0 +1,478 @@ +WCSTools WCS subroutine library release history + +Version 3.9.0 (July 25, 2014) +fileutil.c: Add next_line() to return one line of file +fitfile.c: fix buffer reallocation bug in fitsrhead() + +Version 3.8.7 (October 31, 2012) +dateutil.c: Unused l0 dropped from jd2lst(); ts2ss from jd2mst() +imio.c: Fix errors with short and character images in minvec(), maxvec() +wcs.c: Drop d1 and d2 from wcsdist(); diffi from wcsdist1() +wcs.c: Drop depwcs; it's in main wcs structure +wcsinit.c: Drop unused variable iszpx; fix bug in latmin assignment +zpxpos.c: Fix code for quadratic near pole + +catutil.c: Skip trailing right bracket in aget*() + +Version 3.8.6 (August 10, 2012) +All: Update author name +imio.c: Fix 8-bit variables to be unsigned char + +Version 3.8.5 (April 12, 2012) +imio.c: Change 8-bit pixel values from char to unsigned char +fitsfile.c: Always check first 8 characters of FITS files for "SIMPLE" + +Version 3.8.4 (September 1, 2011) +imgetwcs.c, wcsinit.c, wcs.c, wcs.h, worldpos.c: Add TPV WCS for TAN with PV terms + +Version 3.8.3 (May 20, 2011) +hget.c: Free allocated memory in strnsrch() to eliminate memory leak (2011-05-19) +imhfile.c: Free *newpixname* not pixname. (2011-05-20) +wcsinit.c: Change error() calls to setwcserr() +wcslib.h: Declare undeclared SCAMP subroutine raw-to-pv() +wcs.c: Fix wcsfree() so it frees depended-on WCS structures (2011-05-09) + +March 18, 2011 - Release 3.8.2 +zpxpos.c, wcs.c, wcsinit.c: Add support for NOAO ZPX protection (Frank Valdes) +imsetwcs.c: Allocate NMAXMAG instead of number of magnitudes, nmag +wcsinit.c,wcs.c,proj.c: Support SCAMP TAN distortion correction (Ed Los) +wcsinit.c: ARSEC and DEG constants used by SCAMP replaced by S2D and D2S +proj.c: If no PV coefficients in ZPN projection, make it ARC +wcs.c: Fix bug involving dependent WCS's (Ed Los) + +April 30, 2010 - Release 3.8.1 +scat,imcat: Set GSC2 magnitudes > 90 to 99.99 +gethead: Fix buffer reallocation bug which crashed reading very large + headers +gethead: Fix trailing spaces on ASCII file quoted string values +gethead: Fix problems with string value extraction changing ASCII files +skycoor: Use number of decimal places from -n for -r difference if set +wcscon.c: Fix bug in fk524() e-term computation; fix J<->B conversions +fitsfile.c: In fitswhead(), always pad blocks to 2880 bytes with spaces + and fix bug dealing with large primary headers +wcscon.c: Fix bug in computing the magnitude of the e-terms in fk524() + and drop ep1 assignment after line 178 in wcsconp() + + +November 13, 2009 - Release 3.8.0 +dateutil.c: Fix possible bug in nutation subroutine +fitsfile.c: Add subroutine moveb() and fix binary table calls to it + Fix lengths for ASCII numeric table entries in fitsrthead() +fitsfile.h: Add moveb() which is used by binary FITS table code in fitsfile.c +hget.c: In strfix(), if parentheses enclose a number, drop them + +November 21, 2008 - Release 3.7.6 +fitsfile.c: In fitswhead() do not print write error if nw = nbytes +dateutil.c: Use IAU 2006 nutation for sidereal time computations +dateutil.c: Add ang2hr(), ang2deg(), deg2ang(), and ang2hr() to + convert betweem decimal floating point degrees and + vigesimal hours or degrees +tnxpos.c: Fix image to world coordinate system transformation and + WCS to image transformation + +July 1, 2008 - Release 3.7.5 +wcsinit.c: Initialize TNX projection when projection types first set and + check for IMAGEW and IMAGEH if NAXIS1 and NAXIS2 not present, +fitsfile.c: Drop comma from name when reading file in isfits() and + do not append primary data header if it is the only header + +May 9, 2008 - Release 3.7.4 +fitsfile.c: In isfits(), allow extensions in FITS files without .fit or .fts +wcsinit.c: Call tnxinit() before any projection calls are made + +March 20, 2008 - Release 3.7.3 +wcs.c: Compute angular separation in wcsdist() using arcos + +December 31, 2007 - Release 3.7.2 +wcscon.c: In wcsconp, make it clear that proper motion is in spherical coordinates +fitsfile.c: Add support to BINTABLE in ftget*() and fitsrthead() +fitsfile.c: Add data heap numerated by PCOUNT when skipping HDU in fitsrhead() +fitsfile.c: Return NULL pointer if fitsrhead() cannot find requested HDU +fitswcs.c: Print error message set by fitsrhead() + +November 9, 2007 - Release 3.7.1 +wcsinit.c: Fix bug which tested &mchar instead of mchar in if statement + +August 24, 2007 - Release 3.7.0 +hget.c: If a closing quote isn't found in a string value, make one up +hput.c: Fix bug in comment insertion and deal correctly with missing quotes + +June 11, 2007 - Release 3.6.9 +imio.c: Add minvec() and speed up maxvec() + +April 3, 2007 - Release 3.6.8 +hget.c: Initial header length to zero in hlength() if lhead argument <= 0 +wcs.c: In wcstype(), set to WCS_PIX if CTYPEi starts with "DET" +wcs.c: In wcspset(), use correct cdelts when converting PC matrix to CD matrix +wcsinit.c: Fix bug so RA, DEC, SECPIX can be used to set a WCS +tnxpos.c: Fix bug so it doesn't crash + +January 16, 2007 - Release 3.6.7 +wcs.h: Fix and add ANSI C prototypes +imio.h: Drop as it has been included in fitsfile.h for several releases now +fitsfile.h, fitshead.h: Add ANSI C prototypes +wcsinitc(),wcsninitc(),hgeti4c(),hgetr8c(),hgetsc(): Change WCS letter argument + from char to char* +hget.c: Declare header and keyword const char in most subroutines +hput.c: Declare keyword and value const in most subroutines +hput.c: Fix bug in ra2str() and dec2str() so ndec=0 works +imio.c: Include fitsfile.h instead of imio.h +wcslib.h: Drop semicolon at end of c++ ifdef +wcslib.h: Drop second declaration of SZP subroutines + +November 2, 2006 - Release 3.6.6 +fitsfile.c: Use calloc() when reallocating header as it is read +wcsinit.c: Limit naxes to 2 everywhere; RA and DEC should always be 1st +wcsinit.c: If either CUNITi is "pixel" set projection to WCS_XY +wcscon.c: In wcscsys, set system to WCS_XY if PIXEL projection +wcscon.c: In wcscsys, set system to WCS_LINEAR if LINEAR coordinate system +dateutil.c, fitshead.h: Add sidereal time to UT and vice versa + +June 30, 2006 - Release 3.6.5 +wcsinit.c: Deal with up to 9x9 PC matrix +wcs.c: Limit WCSLIB dimensions to two (this will change in 4.0) +hput.c: Fix comment placement and replacement +hget.c: Add strfix(), a utility to clean up strings + +May 3, 2006 - Release 3.6.4 +fileutil.c: Add istiff(), isjpeg(), isgif() to check TIFF, JPEG, GIF files +fitsfile.c: Add fitsrtail() to read appended FITS headers +fitsfile.c: Add file name to header-reading error messages +fitswcs.c: Add code to read FITS header appended to TIFF file +imio.c: Fix bug of occasional double application of bscale in getvec() + Clean up arithmetic and increment in addpix() and multpix() +imsetwcs.c: Allow number of decimal places in image coordinates to be set +wcsinit.c: Get Epoch of observation from MJD-OBS or DATE-OBS/UT unless DSS +wcsinit.c: Set wcs->naxes to actual number of image WCS axes, usually 2 +wcscon.c,dateutil.c,fitsfile.c: Drop declarations of unused variables +wcs.c: Fix calls to avoid type conflicts in Linux + + +January 5, 2006 - Release 3.6.3 +wcs.h: Add WCS_ICRS to list of coordinate systems +wcsinit.c: Initialize sys to WCS_ICRS if appropriate +wcscon.c: Avoid precesssing ICRS coordinates +wcscon.c: Fix precession which broke in 3.6.1 + +July 21, 2005 - Release 3.6.2 +wcs.c: Fix wcsrange() to return correct range around RA=0 +Clean up accumulated unused and misdeclared variables using lint + +April 13, 2005 - Release 3.6.1 +Remove all sla_lib subroutines and calls thereto from wcscon.c, replacing +them with local code. + +March 17, 2005 - Release 3.6.0 +In wcs.c, fix bug in wcsrotset() so angles > 360 are set to angle - 360, not 360 +Use unbuffered read() in isfits() in fitsfile.c + +------------------------ + +November 01, 2004 - Release 3.5.8 +In wcs.c, keep wcs->rot between 0 and 360 degrees (360.0 -> 0.0) + +September 21, 2004 - Release 3.5.7 +In pix2wcs(), if spherical coordinate output, keep 0 < long/RA < 360 +Fix bug in wcsfull() when wrapping around RA=0:00 +In hput.c, add fixnegzero() to avoid putting -0.000 in header + +September 3, 2004 - Release 3.5.6 +Modify FITS file reading software to get image size from file size if +SIMPLE is F, so FITS headers with WCS can be used on arbitrary files. +In hget.c, fix bug so comment is not pushed onto the next line if character +value string lengthens (off by one bug). + +July 13, 2004 - Release 3.5.5 +Add headshrink to hput.c to optionally keep blank lines after +keywords are deleted. +Read D, d, E, and e as exponent delimiters in floating point values in hget.c + + +May 6, 2004 - Release 3.5.4 +Add fitswexhead() to fitsfile.c to overwrite FITS extension headers + +April 16, 2004 - Release 3.5.3 +Use strncsrch() in hget.c to get differently-cased keywords. + +February 3, 2004 - Release 3.5.2 +In worldpix() in worldpos.c, allow ra/long. to exceed 180 if reference +pixel is more than 180 degrees from image (1,1). + +December 12, 2003 - Release 3.5.1 +Change p[0,1,2] initializations to p[1,2,3] in wcsinit.c to match proj.c +(This affects constants for AZP,SIN,COP,COE,COD,COO,SZP,CEA,CYP,AIR,BON) +Add wcs->naxes back into wcs structure for backward compatibility; it +should always be equal to wcs->naxis. +Fix bug in numdec() to return 0 if no digits after decimal point +Fix call to setwcserr() with format in it + +November 17, 2003 - Release 3.5.0 +Rename mgets() to mgetstr() in iget.c, wcsinit.c and fitshead.h +Add numdec() to hget.c to return number of decimal places in numeric string +Change wcs->naxes to wcs->naxis to prepare for WCSLIB 3.* +In iraf2fits() and irafrimage(), use image, not physical, dimensions. +In iraf2fits(), set NAXISi to image dimensions, NPAXISi to physical dimensions. +Fix bugs in wcsfull() in wcs.c +Move all distortion-related code to distort.c; include unistd.h +Include stdlib.h instead of malloc.h in lin.c and drop malloc.h from matchstar.c + +------------------------ + +August 22, 2003 - Release 3.4.2 +Add fitsrfull() subroutine to read FITS files with more than 2 dimensions +Modify fitswimage() to write FITS files with more than 2 dimensions + +July 11, 2003 - Release 3.4.1 +Use strncmp to check for both stdin and stdout in fitsfile.c + +May 30, 2003 - Release 3.4.0 +Add partial support for ZPX projection +Fix bug reading COE and other projections when PROJPn coefficients +were accidently reinitialized + +------------------------ + +May 8, 2003 - Release 3.3.4 +Add two missing semicolons in C++ declarations in wcs.h +Read prj.p[0] from PROJP0 for ZPN projections, instead of ignoring it + +April 3, 2003 - Release 3.3.2 +Add distortion conversion for SIRTF images + +March 27, 2003 - Release 3.3.1 +Add conversions to and from Heliocentric Julian Dates to dateutil.c +Open FITS and IMH files "rb" instead of "r" for Linux compatibility +Add isimlistd() to fileutil.c to check for list of images in a specified directory +Fix default center pixel computation in GetFITSWCS(); it was off by half a pixel + +January 30, 2003 - Release 3.3.0 +Fix bug in dateutil.c ts2gst() sidereal time conversion. + +------------------------ + +January 3, 2003 - Release 3.2.1 +Fix bug in wcsinit() which failed to read PVi_0, and now initialize +PVi_j in only once place. + +December 6, 2002 - Release 3.2.0 +Add ET/TDT/TT and sidereal time conversion to dateutil.c +Fix subroutine calls for radvel and latpole and correctly compute pixel +at center of image for default CRPIX in wcsinit.c +Add fitsrsect() to fitsfile.c to read a section of an image + +------------------------ + +August 30, 2002 - Release 3.1.3 +Fix bug in imio.c getvec() dealing with scaled images +Add case-insensitive string search subroutines strcsrch() and strncsrch() +Accept stdin as file in isfile() +Add Ephemeris time conversions to dateutil() + +July 8, 2002 - Release 3.1.2 +Fix bug in date utilities which always rounded to integer seconds of UT +Fix bugs in date utilities to handle BC (negative) dates to JD 0. + +June 26, 2002 - Release 3.1.1 +Fix bugs which caused TNX projection to fail +Fix two bugs in wcsinit() which caused setting RADECSYS when + an EQUINOX keyword is present. +Write FITS error messages to string accessible by fitserr() +Put SAO-written software under Gnu Lesser Public License + +April 12, 2002 - Release 3.1.0 +Implement WCSLIB 2.9 +Support PV entry of constants and PCi_j rotation matrices in wcsinit.c +Support inversion (WCS->pix) of multiple dependent WCSs +Add hgetri4c(), hgetr8c(), and hgetsc() for multiple WCS handling +Fix bug in TNX projection software which caused an infinite loop during +coefficient parsing. + +------------------------ + +February 13, 2002 - Release 3.0.7 +Fix bug in ecliptic coordinate conversion in wcscon.c +Allow "stdin" to include extension and/or WCS selection in fitsfile.c +Add a global switch to turn off scaling in imio.c +Add ifdef to lin.c so it will compile under Mac OS/X + +December 4, 2001 - Release 3.0.6 +In movepix(), add char to char move +Always include stdlib.h in lin.c + +September 25, 2001 - Release 3.0.5 +Implement WCSLIB version 2.7 +Fix Makefile to include header files appropriately +Accept FITS dates as yyyy/mm/dd +Fix bug in str2dec() which misinterpreting strings with leading spaces +Fix bug in isnum() which caused bad answer if trailing spaces +Add fileutil.c, which includes various file info utilities + +September 7, 2001 - Release 3.0.3 +Disallow files with = in their name in isfits() and isiraf() +Set coordinate system from CTYPE if not equatorial + +July 12, 2001 - Release 3.0 +Read PROJPn projection constants in wcsinit() + +------------------------ + +March 30, 2001 - Release 2.9.4 +Fix possible header length problem in hget.c + +March 22, 2001 - Release 2.9.3 +Fix minor bugs in wcs.h, wcs.c, and wcsinit.c, wcslib.c, fitsfile.c, and +cel.c found by gcc on Linux and possible memory leak in wcs.c + +March 9, 2001 - Release 2.9.2 +In fitsfile.c, change multiple WCS separator in FITS file names from : to % +and fix bug which failed to read multi-extension files if END was not preceded +by a blank line in the extension's header. + +February 28, 2001 - Release 2.9.1 +Fix major bug in wcsinit() which always set CRPIX2 the same as CRPIX1 + +February 23, 2001 - Release 2.9.0 +FITS reading subroutines are fixed to ignore WCS name or character specified +as :name or :character at end of filename. +wcsinit() has new APIs which specify either a WCSNAME, wcsinitn(), or +a WCS character, wcsinitc(), to allow use of multiple WCS's in a single +FITS header. The WCSDEPx keyword has been added to indicate dependence +on another WCS, though this feature has not been thoroughly debugged. +fitscimage() is fixed so it doesn't overwrite data when overwriting a file +An off-by-one bug was fixed for some polynomial types in tnxpos(). +The WCSLIB subroutines were brought up to release 2.6 with very minor changes + +------------------------ + +December 29, 2000 - Release 2.8.6 +Fix handling of embedded + or - in isnum() in hget.c +Default to 2000 for EQUINOX and EPOCH and FK5 for RADECSYS, if keywords not present. +In wcscon.c, fk425() and fk524() algorithms were updated to include parallax and rv, +proper motion is added by wcscon*() after fk425() or fk524() from system epoch, and +proper motion units in fk524p() and fk425p() were fixed. +In wcsinit.c, a bug initializing CD matrix was fixed. +In cel.c, include string.h for strcmp(). + +September 29, 2000 - Release 2.8.5 +wcsinit will now use a CD matrix if ANY CD keywords are present in header +In getvec() in imio.c, move scaling outside of loop and make it conditional. +Read .pix files in same directory as .imh file, if not otherwise found. + +August 1, 2000 - Release 2.8.3 +Improve handling of 1-D WCS data. Fix numerous warning-generating bugs. +Fix bug in ep2jd()/jd2ep() so both start year at 1/1 0:00 + +June 13, 2000 - Release 2.8.2 +If imh pixel file has no directory, *always* use same as header file + +June 9, 2000 - Release 2.8.1 +Read keyword values in hget.c even if no equal sign is present. + +June 2, 2000 - Release 2.8.0 +Only a few minor changes due to running lint on everything + +------------------------ + +May 10, 2000 - Release 2.7.4 +In wcstype(), default to WCS_LIN, not error (after Bill Joye) + +May 1, 2000 - Release 2.7.3 +Bug in hadd() fixed so new line is not overwritten. +Pixel files whcih are in subdirectories of files where IRAF .imh header +files reside are now dealt with correctly. +All dates in the old FITS format (dd/mm/yy) where the year ranges from + 0 to 999 have 1900 added to them: 01/05/100 becomes 2000-05-01. + +March 27, 2000 - Release 2.7.2 +In hputs(), do not add quotes if writing COMMENT or HISTORY +In fits2iraf(), in imhfile.c, minimize length of path in pixel file name +Fix code to deal with .imh file paths longer than 67 characters. +In platepix(), use inverse CD matrix to get better initial x,y value +Change the maximum header string length in the hget header reading + subroutines from 57600 to 256000 +Replace oldsys with wcsproj in the WCS data structure so that more options + are available, such as forcing use of AIPS or WCSLIB projection subroutines +Add setdatedec() to set the number of decimal places in FITS date strings + returned by dateutil subroutines +Fix precession code to deal correctly with equinoxes other than J2000 and + B1950. +Move all date operations to dateutil.c, including current time used in imhfile.c + +February 23, 2000 - Release 2.7.0 +Upgrade WCSLIB subroutines to WCSLIB 2.5 from 2.4 +Add MJD and Besselian and Julian epoch conversion to dateutil.c +Use WCSLIB CAR, COE, NCP projections if oldsys is 1, else use worldpos() +Set CD matrix when using DSS projection +Change oldwcs in wcs.h from switch to multi-value flag wcsproj, default is same +Fix minor bug in fitsfile.c fitscimage error returns. + +------------------------ + +January 11, 2000 - Release 2.6.12 +Fix bug in dateutil() to get fractional year to date conversion right + +December 20, 1999 - Release 2.6.11 +Fix bug in hgetdate() to get ISO minutes and seconds right +Upgrade dateutil() to do many date conversions + +December 10, 1999 - Release 2.6.10 +Fix bug which caused strings starting with d and e followed by numbers +to be declared numeric even though they're not really numbers +Fix bug in dateutil.c ts2jd() which does not affect SAOimage +Fix bugs dealing with NOAO TNX projection + +November 17, 1999 - Release 2.6.9 +Fix bug which caused loss of NCP projection + +November 5, 1999 - Release 2.6.8 +Change release number to match WCSTools +Clean up code in all subroutines using lint +Add DATE-MOD to FITS header in iraf2fits() +Added dateutil.c file for conversions between date formats (used by iraf2fits()) +Return error code from hput*() subroutines if header buffer length exceeded. + +------------------------ + +May 5, 1999 - Release 1.26 +hget.c, iget.c Use POSIX-compliant limits.h instead of values.h + +April 7, 1999 - Release 1.26 +wcs.c Fix bug in dealing with EPOCHless non-equatorial coordinates +wcsinit.c Add optional filename to printed error messages + +April 5, 1999 - Release 1.26 +hget.c Check all string lengths before copying; ignore ^M at 80th character + +February 22, 1999 - Release 1.26 +wcs.c Fix bug dealing with SPA and NPA coordinates + Use faaces 0-5, not 1-6 for quad cube projections +wcsinit.c Fix computed rotation angle for DSS projection + +February 9, 1999 - Release 1.26 +fitsfile.c: Allow BITPIX=0 dataless images +wcsinit.c: Fix bug initializing DSS image rotation +wcs.c: Free lin.imgpix and lin.piximg in wcsfree() +hput.c: Fix bug to avoid writing HISTORY or COMMENT lines past 80 chars + +------------------------ + +December 8, 1998 - Release 1.25 +fitsfile.c: Fix bug in fitsrhead() reading FITS table files caused by fix below + +November 30, 1998 - Release 1.25 +fitsfile.c: Fix bug dealing with very large headers in fitsrhead() + +November 12, 1998 - Release 1.25 +dsspos.c: Fix possible divide by zero problems +fitsfile.c: Add isfits() which checks filename or first line of header +imhfile.c: Add isiraf() which checks filename for .imh +hget.c: Assume 2-digit year in hyphen-separated date means FITS, not ISO +tnxpos.c: Fix multiple bugs +wcscon.c: Add wcscstr() to get coordinate system as a character string +wcscon.c: Add subroutine wcsconp() to convert coordinates + proper motions +wcs.c: Add North and South Polar Angle coordinate systems +wcs.c: Build WCS command initialization by getenv() into wcs*init() +wcs.c: Fix bug in wcssize(); fix bug with rotated mirrored images +wcslib.h: Add cel.h, lin.h, proj.h, and wcstrig.h to wcslib.h +worldpos.c: Fix bug in inverse (sky to pixel) COE projection +cel.c, lin.c, proj.c, sph.c, wcstrig.c: Include only wcslib.h diff --git a/tksao/wcssubs/Readme b/tksao/wcssubs/Readme new file mode 100644 index 0000000..61107cf --- /dev/null +++ b/tksao/wcssubs/Readme @@ -0,0 +1,36 @@ +WCSsubs Subroutines + +These subroutines, developed as part of the WCSTools software package, +constitute a self-contained package for accessing the world coordinate +systems of FITS or IRAF(.imh) images, with image header I/O contained +in fitsfile.c and imhfile.c, and WCS initialization and use through the +subroutines in wcs.c. WCS information for an image is kept in a single +data structure defined in wcs.h. Pixel to WCS translations are done by +calls to pix2wcst() or pix2wcs(). WCS to pixel translations are done +by calls to wcs2pix() or wcsc2pix(). The contents of the files are +briefly described in Files. Dependencies between these files are given +in Makefile. Documentation, to some extent, is online at + +http://tdc-www.harvard.edu/software/wcstools/libwcs.wcs.html + +Documentation for the entire open-source WCSTools package is online at + +http://tdc-www.harvard.edu/software/wcstools/ + +Projection code in wcspos.c is by Bill Cotton of NRAO and is +protected by the Gnu Lesser General Public License, which is stated +in the file COPYING. Projection code in wcslib.c, +cel.c, lin.c, proj.c, wcstrig.c, and sph.c is by Mark Calabretta +of CSIRO and is also protected by the Gnu Lesser General Public +License. Code in slasubs.c is by Pat Wallace of the Starlink +project at Cambridge University. Doug Mink is responsible for +the rest of the code, unless otherwise noted in the source file. +Unless otherwise noted, this code is Copyright 2003 by the +Smithsonian Astrophysical Observatory and protected by the Gnu +Lesser General Public License. + +-Jessica Mink (jmink@cfa.harvard.edu) + Telescope Data Center + Harvard-Smithsonian Center for Astrophysics + Cambridge, Massachusetts + http://tdc-www.harvard.edu/mink diff --git a/tksao/wcssubs/cel.c b/tksao/wcssubs/cel.c new file mode 100644 index 0000000..744bb5f --- /dev/null +++ b/tksao/wcssubs/cel.c @@ -0,0 +1,474 @@ +/*============================================================================= +* +* WCSLIB - an implementation of the FITS WCS proposal. +* Copyright (C) 1995-2002, Mark Calabretta +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* Correspondence concerning WCSLIB may be directed to: +* Internet email: mcalabre@atnf.csiro.au +* Postal address: Dr. Mark Calabretta, +* Australia Telescope National Facility, +* P.O. Box 76, +* Epping, NSW, 2121, +* AUSTRALIA +* +*============================================================================= +* +* C routines which implement the FITS World Coordinate System (WCS) +* convention. +* +* Summary of routines +* ------------------- +* These routines are provided as drivers for the lower level spherical +* coordinate transformation and projection routines. There are separate +* driver routines for the forward, celfwd(), and reverse, celrev(), +* transformations. +* +* An initialization routine, celset(), computes intermediate values from +* the transformation parameters but need not be called explicitly - see the +* explanation of cel.flag below. +* +* +* Initialization routine; celset() +* -------------------------------- +* Initializes members of a celprm data structure which hold intermediate +* values. Note that this routine need not be called directly; it will be +* invoked by celfwd() and celrev() if the "flag" structure member is +* anything other than a predefined magic value. +* +* Given: +* pcode[4] const char +* WCS projection code (see below). +* +* Given and returned: +* cel celprm* Spherical coordinate transformation parameters +* (see below). +* prj prjprm* Projection parameters (usage is described in the +* prologue to "proj.c"). +* +* Function return value: +* int Error status +* 0: Success. +* 1: Invalid coordinate transformation parameters. +* 2: Ill-conditioned coordinate transformation +* parameters. +* +* Forward transformation; celfwd() +* -------------------------------- +* Compute (x,y) coordinates in the plane of projection from celestial +* coordinates (lng,lat). +* +* Given: +* pcode[4] const char +* WCS projection code (see below). +* lng,lat const double +* Celestial longitude and latitude of the projected +* point, in degrees. +* +* Given and returned: +* cel celprm* Spherical coordinate transformation parameters +* (see below). +* +* Returned: +* phi, double* Longitude and latitude in the native coordinate +* theta system of the projection, in degrees. +* +* Given and returned: +* prj prjprm* Projection parameters (usage is described in the +* prologue to "proj.c"). +* +* Returned: +* x,y double* Projected coordinates, "degrees". +* +* Function return value: +* int Error status +* 0: Success. +* 1: Invalid coordinate transformation parameters. +* 2: Invalid projection parameters. +* 3: Invalid value of (lng,lat). +* +* Reverse transformation; celrev() +* -------------------------------- +* Compute the celestial coordinates (lng,lat) of the point with projected +* coordinates (x,y). +* +* Given: +* pcode[4] const char +* WCS projection code (see below). +* x,y const double +* Projected coordinates, "degrees". +* +* Given and returned: +* prj prjprm* Projection parameters (usage is described in the +* prologue to "proj.c"). +* +* Returned: +* phi, double* Longitude and latitude in the native coordinate +* theta system of the projection, in degrees. +* +* Given and returned: +* cel celprm* Spherical coordinate transformation parameters +* (see below). +* +* Returned: +* lng,lat double* Celestial longitude and latitude of the projected +* point, in degrees. +* +* Function return value: +* int Error status +* 0: Success. +* 1: Invalid coordinate transformation parameters. +* 2: Invalid projection parameters. +* 3: Invalid value of (x,y). +* +* Coordinate transformation parameters +* ------------------------------------ +* The celprm struct consists of the following: +* +* int flag +* The celprm struct contains pointers to the forward and reverse +* projection routines as well as intermediaries computed from the +* reference coordinates (see below). Whenever the projection code +* (pcode) or any of ref[4] are set or changed then this flag must be +* set to zero to signal the initialization routine, celset(), to +* redetermine the function pointers and recompute intermediaries. +* Once this has been done pcode itself is ignored. +* +* double ref[4] +* The first pair of values should be set to the celestial longitude +* and latitude (usually right ascension and declination) of the +* reference point of the projection. These are given by the CRVALn +* keywords in FITS. +* +* The second pair of values are the native longitude of the celestial +* pole and the celestial latitude of the native pole and correspond to +* FITS keywords LONPOLE and LATPOLE. +* +* LONPOLE defaults to 0 degrees if the celestial latitude of the +* reference point of the projection is greater than the native +* latitude, otherwise 180 degrees. (This is the condition for the +* celestial latitude to increase in the same direction as the native +* latitude at the reference point.) ref[2] may be set to 999.0 to +* indicate that the correct default should be substituted. +* +* In some circumstances the celestial latitude of the native pole may +* be determined by the first three values only to within a sign and +* LATPOLE is used to choose between the two solutions. LATPOLE is +* set in ref[3] and the solution closest to this value is used to +* reset ref[3]. It is therefore legitimate, for example, to set +* ref[3] to 999.0 to choose the more northerly solution - the default +* if the LATPOLE card is omitted from the FITS header. For the +* special case where the reference point of the projection is at +* native latitude zero, its celestial latitude is zero, and +* LONPOLE = +/- 90 then the celestial latitude of the pole is not +* determined by the first three reference values and LATPOLE +* specifies it completely. +* +* The remaining members of the celprm struct are maintained by the +* initialization routines and should not be modified. This is done for the +* sake of efficiency and to allow an arbitrary number of contexts to be +* maintained simultaneously. +* +* double euler[5] +* Euler angles and associated intermediaries derived from the +* coordinate reference values. +* +* +* WCS projection codes +* -------------------- +* Zenithals/azimuthals: +* AZP: zenithal/azimuthal perspective +* TAN: gnomonic +* STG: stereographic +* SIN: synthesis (generalized orthographic) +* ARC: zenithal/azimuthal equidistant +* ZPN: zenithal/azimuthal polynomial +* ZEA: zenithal/azimuthal equal area +* AIR: Airy +* +* Cylindricals: +* CYP: cylindrical perspective +* CEA: cylindrical equal area +* CAR: Cartesian +* MER: Mercator +* +* Pseudo-cylindricals: +* SFL: Sanson-Flamsteed +* PAR: parabolic +* MOL: Mollweide +* +* Conventional: +* AIT: Hammer-Aitoff +* +* Conics: +* COP: conic perspective +* COD: conic equidistant +* COE: conic equal area +* COO: conic orthomorphic +* +* Polyconics: +* BON: Bonne +* PCO: polyconic +* +* Quad-cubes: +* TSC: tangential spherical cube +* CSC: COBE quadrilateralized spherical cube +* QSC: quadrilateralized spherical cube +* +* Author: Mark Calabretta, Australia Telescope National Facility +* $Id: cel.c,v 1.1.1.1 2016/03/30 20:00:02 joye Exp $ +*===========================================================================*/ + +#include +#include +#include "wcslib.h" + +/* Map error number to error message for each function. */ +const char *celset_errmsg[] = { + 0, + "Invalid coordinate transformation parameters", + "Ill-conditioned coordinate transformation parameters"}; + +const char *celfwd_errmsg[] = { + 0, + "Invalid coordinate transformation parameters", + "Invalid projection parameters", + "Invalid value of (lng,lat)"}; + +const char *celrev_errmsg[] = { + 0, + "Invalid coordinate transformation parameters", + "Invalid projection parameters", + "Invalid value of (x,y)"}; + + +int +celset(pcode, cel, prj) + +const char pcode[4]; +struct celprm *cel; +struct prjprm *prj; + +{ + int dophip; + const double tol = 1.0e-10; + double clat0, cphip, cthe0, slat0, sphip, sthe0; + double latp, latp1, latp2; + double u, v, x, y, z; + + /* Initialize the projection driver routines. */ + if (prjset(pcode, prj)) { + return 1; + } + + /* Set default for native longitude of the celestial pole? */ + dophip = (cel->ref[2] == 999.0); + + /* Compute celestial coordinates of the native pole. */ + if (prj->theta0 == 90.0) { + /* Reference point is at the native pole. */ + + if (dophip) { + /* Set default for longitude of the celestial pole. */ + cel->ref[2] = 180.0; + } + + latp = cel->ref[1]; + cel->ref[3] = latp; + + cel->euler[0] = cel->ref[0]; + cel->euler[1] = 90.0 - latp; + } else { + /* Reference point away from the native pole. */ + + /* Set default for longitude of the celestial pole. */ + if (dophip) { + cel->ref[2] = (cel->ref[1] < prj->theta0) ? 180.0 : 0.0; + } + + clat0 = cosdeg (cel->ref[1]); + slat0 = sindeg (cel->ref[1]); + cphip = cosdeg (cel->ref[2]); + sphip = sindeg (cel->ref[2]); + cthe0 = cosdeg (prj->theta0); + sthe0 = sindeg (prj->theta0); + + x = cthe0*cphip; + y = sthe0; + z = sqrt(x*x + y*y); + if (z == 0.0) { + if (slat0 != 0.0) { + return 1; + } + + /* latp determined by LATPOLE in this case. */ + latp = cel->ref[3]; + } else { + if (fabs(slat0/z) > 1.0) { + return 1; + } + + u = atan2deg (y,x); + v = acosdeg (slat0/z); + + latp1 = u + v; + if (latp1 > 180.0) { + latp1 -= 360.0; + } else if (latp1 < -180.0) { + latp1 += 360.0; + } + + latp2 = u - v; + if (latp2 > 180.0) { + latp2 -= 360.0; + } else if (latp2 < -180.0) { + latp2 += 360.0; + } + + if (fabs(cel->ref[3]-latp1) < fabs(cel->ref[3]-latp2)) { + if (fabs(latp1) < 90.0+tol) { + latp = latp1; + } else { + latp = latp2; + } + } else { + if (fabs(latp2) < 90.0+tol) { + latp = latp2; + } else { + latp = latp1; + } + } + + cel->ref[3] = latp; + } + + cel->euler[1] = 90.0 - latp; + + z = cosdeg (latp)*clat0; + if (fabs(z) < tol) { + if (fabs(clat0) < tol) { + /* Celestial pole at the reference point. */ + cel->euler[0] = cel->ref[0]; + cel->euler[1] = 90.0 - prj->theta0; + } else if (latp > 0.0) { + /* Celestial pole at the native north pole.*/ + cel->euler[0] = cel->ref[0] + cel->ref[2] - 180.0; + cel->euler[1] = 0.0; + } else if (latp < 0.0) { + /* Celestial pole at the native south pole. */ + cel->euler[0] = cel->ref[0] - cel->ref[2]; + cel->euler[1] = 180.0; + } + } else { + x = (sthe0 - sindeg (latp)*slat0)/z; + y = sphip*cthe0/clat0; + if (x == 0.0 && y == 0.0) { + return 1; + } + cel->euler[0] = cel->ref[0] - atan2deg (y,x); + } + + /* Make euler[0] the same sign as ref[0]. */ + if (cel->ref[0] >= 0.0) { + if (cel->euler[0] < 0.0) cel->euler[0] += 360.0; + } else { + if (cel->euler[0] > 0.0) cel->euler[0] -= 360.0; + } + } + + cel->euler[2] = cel->ref[2]; + cel->euler[3] = cosdeg (cel->euler[1]); + cel->euler[4] = sindeg (cel->euler[1]); + cel->flag = CELSET; + + /* Check for ill-conditioned parameters. */ + if (fabs(latp) > 90.0+tol) { + return 2; + } + + return 0; +} + +/*--------------------------------------------------------------------------*/ + +int +celfwd(pcode, lng, lat, cel, phi, theta, prj, x, y) + +const char pcode[4]; +const double lng, lat; +struct celprm *cel; +double *phi, *theta; +struct prjprm *prj; +double *x, *y; + +{ + int err; + + if (cel->flag != CELSET) { + if (celset(pcode, cel, prj)) return 1; + } + + /* Compute native coordinates. */ + sphfwd(lng, lat, cel->euler, phi, theta); + + /* Apply forward projection. */ + if ((err = prj->prjfwd(*phi, *theta, prj, x, y))) { + return err == 1 ? 2 : 3; + } + + return 0; +} + +/*--------------------------------------------------------------------------*/ + +int +celrev(pcode, x, y, prj, phi, theta, cel, lng, lat) + +const char pcode[4]; +const double x, y; +struct prjprm *prj; +double *phi, *theta; +struct celprm *cel; +double *lng, *lat; + +{ + int err; + + if (cel->flag != CELSET) { + if(celset(pcode, cel, prj)) return 1; + } + + /* Apply reverse projection. */ + if ((err = prj->prjrev(x, y, prj, phi, theta))) { + return err == 1 ? 2 : 3; + } + + /* Compute native coordinates. */ + sphrev(*phi, *theta, cel->euler, lng, lat); + + return 0; +} + +/* Dec 20 1999 Doug Mink - Change cosd() and sind() to cosdeg() and sindeg() + * Dec 20 1999 Doug Mink - Include wcslib.h, which includes wcsmath.h and cel.h + * + * Dec 18 2000 Doug Mink - Include string.h for strcmp() + * + * Mar 20 2001 Doug Mink - Add () around err assignments in if statements + * Sep 19 2001 Doug Mink - Add above changes to WCSLIB-2.7 cel.c + * + * Mar 12 2002 Doug Mink - Add changes to WCSLIB-2.8.2 cel.c + */ diff --git a/tksao/wcssubs/dateutil.c b/tksao/wcssubs/dateutil.c new file mode 100644 index 0000000..ada0c95 --- /dev/null +++ b/tksao/wcssubs/dateutil.c @@ -0,0 +1,4554 @@ +/*** File libwcs/dateutil.c + *** October 19, 2012 + *** By Jessica Mink, jmink@cfa.harvard.edu + *** Harvard-Smithsonian Center for Astrophysics + *** Copyright (C) 1999-2012 + *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Correspondence concerning WCSTools should be addressed as follows: + Internet email: jmink@cfa.harvard.edu + Postal address: Jessica Mink + Smithsonian Astrophysical Observatory + 60 Garden St. + Cambridge, MA 02138 USA + */ + +/* Date and time conversion routines using the following conventions: + ang = Angle in fractional degrees + deg = Angle in degrees as dd:mm:ss.ss + doy = 2 floating point numbers: year and day, including fraction, of year + *** First day of year is 1, not zero. + dt = 2 floating point numbers: yyyy.mmdd, hh.mmssssss + ep = fractional year, often epoch of a position including proper motion + epb = Besselian epoch = 365.242198781-day years based on 1900.0 + epj = Julian epoch = 365.25-day years based on 2000.0 + fd = FITS date string which may be any of the following: + yyyy.ffff (fractional year) + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard FITS use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) + hr = Sexigesimal hours as hh:mm:dd.ss + jd = Julian Date + lt = Local time + mjd = modified Julian Date = JD - 2400000.5 + ofd = FITS date string (dd/mm/yy before 2000, else no return) + time = use fd2* with no date to convert time as hh:mm:ss.ss to sec, day, year + ts = UT seconds since 1950-01-01T00:00 (used for ephemeris computations) + tsi = local seconds since 1980-01-01T00:00 (used by IRAF as a time tag) + tsu = UT seconds since 1970-01-01T00:00 (used as Unix system time) + tsd = UT seconds of current day + ut = Universal Time (UTC) + et = Ephemeris Time (or TDB or TT) = TAI + 32.184 seconds + tai = International Atomic Time (Temps Atomique International) = ET - 32.184 seconds + gps = GPS time = TAI - 19 seconds + mst = Mean Greenwich Sidereal Time + gst = Greenwich Sidereal Time (includes nutation) + lst = Local Sidereal Time (includes nutation) (longitude must be set) + hjd = Heliocentric Julian Date + mhjd = modified Heliocentric Julian Date = HJD - 2400000.5 + + * ang2hr (angle) + * Convert angle in decimal floating point degrees to hours as hh:mm:ss.ss + * ang2deg (angle) + * Convert angle in decimal floating point degrees to degrees as dd:mm:ss.ss + * deg2ang (angle as dd:mm:ss.ss) + * Convert angle in degrees as dd:mm:ss.ss to decimal floating point degrees + * ang2hr (angle) + * Convert angle in hours as hh:mm:ss.ss to decimal floating point degrees + * + * doy2dt (year, doy, date, time) + * Convert year and day of year to date as yyyy.ddmm and time as hh.mmsss + * doy2ep, doy2epb, doy2epj (date, time) + * Convert year and day of year to fractional year + * doy2fd (year, doy) + * Convert year and day of year to FITS date string + * doy2mjd (year, doy) + * Convert year and day of year to modified Julian date + * + * dt2doy (date, time, year, doy) + * Convert date as yyyy.ddmm and time as hh.mmsss to year and day of year + * dt2ep, dt2epb, dt2epj (date, time) + * Convert date as yyyy.ddmm and time as hh.mmsss to fractional year + * dt2fd (date, time) + * Convert date as yyyy.ddmm and time as hh.mmsss to FITS date string + * dt2i (date,time,iyr,imon,iday,ihr,imn,sec, ndsec) + * Convert yyyy.mmdd hh.mmssss to year month day hours minutes seconds + * dt2jd (date,time) + * Convert date as yyyy.ddmm and time as hh.mmsss to Julian date + * dt2mjd (date,time) + * Convert date as yyyy.ddmm and time as hh.mmsss to modified Julian date + * dt2ts (date,time) + * Convert date (yyyy.ddmm) and time (hh.mmsss) to seconds since 1950-01-01 + * dt2tsi (date,time) + * Convert date (yyyy.ddmm) and time (hh.mmsss) to seconds since 1980-01-01 + * dt2tsu (date,time) + * Convert date (yyyy.ddmm) and time (hh.mmsss) to seconds since 1970-01-01 + * + * ep2dt, epb2dt, epj2dt (epoch,date, time) + * Convert fractional year to date as yyyy.ddmm and time as hh.mmsss + * ep2fd, epb2fd, epj2fd (epoch) + * Convert epoch to FITS ISO date string + * ep2i, epb2i, epj2i (epoch,iyr,imon,iday,ihr,imn,sec, ndsec) + * Convert fractional year to year month day hours minutes seconds + * ep2jd, epb2jd, epj2jd (epoch) + * Convert fractional year as used in epoch to Julian date + * ep2mjd, epb2mjd, epj2mjd (epoch) + * Convert fractional year as used in epoch to modified Julian date + * ep2ts, epb2ts, epj2ts (epoch) + * Convert fractional year to seconds since 1950.0 + * + * et2fd (string) + * Convert from ET (or TDT or TT) in FITS format to UT in FITS format + * fd2et (string) + * Convert from UT in FITS format to ET (or TDT or TT) in FITS format + * jd2jed (dj) + * Convert from Julian Date to Julian Ephemeris Date + * jed2jd (dj) + * Convert from Julian Ephemeris Date to Julian Date + * dt2et (date, time) + * Convert date (yyyy.ddmm) and time (hh.mmsss) to ephemeris time + * edt2dt (date, time) + * Convert ephemeris date (yyyy.ddmm) and time (hh.mmsss) to UT + * dt2tai (date, time) + * Convert date (yyyy.ddmm) and time (hh.mmsss) to TAI date and time + * tai2dt (date, time) + * Convert TAI date (yyyy.ddmm) and time (hh.mmsss) to UT + * ts2ets (tsec) + * Convert from UT in seconds since 1950-01-01 to ET in same format + * ets2ts (tsec) + * Convert from ET in seconds since 1950-01-01 to UT in same format + * + * fd2ep, fd2epb, fd2epj (string) + * Convert FITS date string to fractional year + * Convert time alone to fraction of Besselian year + * fd2doy (string, year, doy) + * Convert FITS standard date string to year and day of year + * fd2dt (string, date, time) + * Convert FITS date string to date as yyyy.ddmm and time as hh.mmsss + * Convert time alone to hh.mmssss with date set to 0.0 + * fd2i (string,iyr,imon,iday,ihr,imn,sec, ndsec) + * Convert FITS standard date string to year month day hours min sec + * Convert time alone to hours min sec, year month day are zero + * fd2jd (string) + * Convert FITS standard date string to Julian date + * Convert time alone to fraction of day + * fd2mjd (string) + * Convert FITS standard date string to modified Julian date + * fd2ts (string) + * Convert FITS standard date string to seconds since 1950.0 + * Convert time alone to seconds of day + * fd2fd (string) + * Convert FITS standard date string to ISO FITS date string + * fd2of (string) + * Convert FITS standard date string to old-format FITS date and time + * fd2ofd (string) + * Convert FITS standard date string to old-format FITS date string + * fd2oft (string) + * Convert time part of FITS standard date string to FITS date string + * + * jd2doy (dj, year, doy) + * Convert Julian date to year and day of year + * jd2dt (dj,date,time) + * Convert Julian date to date as yyyy.mmdd and time as hh.mmssss + * jd2ep, jd2epb, jd2epj (dj) + * Convert Julian date to fractional year as used in epoch + * jd2fd (dj) + * Convert Julian date to FITS ISO date string + * jd2i (dj,iyr,imon,iday,ihr,imn,sec, ndsec) + * Convert Julian date to year month day hours min sec + * jd2mjd (dj) + * Convert Julian date to modified Julian date + * jd2ts (dj) + * Convert Julian day to seconds since 1950.0 + * + * lt2dt() + * Return local time as yyyy.mmdd and time as hh.mmssss + * lt2fd() + * Return local time as FITS ISO date string + * lt2tsi() + * Return local time as IRAF seconds since 1980-01-01 00:00 + * lt2tsu() + * Return local time as Unix seconds since 1970-01-01 00:00 + * lt2ts() + * Return local time as Unix seconds since 1950-01-01 00:00 + * + * mjd2doy (dj,year,doy) + * Convert modified Julian date to date as year and day of year + * mjd2dt (dj,date,time) + * Convert modified Julian date to date as yyyy.mmdd and time as hh.mmssss + * mjd2ep, mjd2epb, mjd2epj (dj) + * Convert modified Julian date to fractional year as used in epoch + * mjd2fd (dj) + * Convert modified Julian date to FITS ISO date string + * mjd2i (dj,iyr,imon,iday,ihr,imn,sec, ndsec) + * Convert modified Julian date to year month day hours min sec + * mjd2jd (dj) + * Convert modified Julian date to Julian date + * mjd2ts (dj) + * Convert modified Julian day to seconds since 1950.0 + * + * ts2dt (tsec,date,time) + * Convert seconds since 1950.0 to date as yyyy.ddmm and time as hh.mmsss + * ts2ep, ts2epb, ts2epj (tsec) + * Convert seconds since 1950.0 to fractional year + * ts2fd (tsec) + * Convert seconds since 1950.0 to FITS standard date string + * ts2i (tsec,iyr,imon,iday,ihr,imn,sec, ndsec) + * Convert sec since 1950.0 to year month day hours minutes seconds + * ts2jd (tsec) + * Convert seconds since 1950.0 to Julian date + * ts2mjd (tsec) + * Convert seconds since 1950.0 to modified Julian date + * tsi2fd (tsec) + * Convert seconds since 1980-01-01 to FITS standard date string + * tsi2dt (tsec,date,time) + * Convert seconds since 1980-01-01 to date as yyyy.ddmm, time as hh.mmsss + * tsu2fd (tsec) + * Convert seconds since 1970-01-01 to FITS standard date string + * tsu2tsi (tsec) + * Convert UT seconds since 1970-01-01 to local seconds since 1980-01-01 + * tsu2dt (tsec,date,time) + * Convert seconds since 1970-01-01 to date as yyyy.ddmm, time as hh.mmsss + * + * tsd2fd (tsec) + * Convert seconds since start of day to FITS time, hh:mm:ss.ss + * tsd2dt (tsec) + * Convert seconds since start of day to hh.mmssss + * + * fd2gst (string) + * convert from FITS date Greenwich Sidereal Time + * dt2gst (date, time) + * convert from UT as yyyy.mmdd hh.mmssss to Greenwich Sidereal Time + * ts2gst (tsec) + * Calculate Greenwich Sidereal Time given Universal Time + * in seconds since 1951-01-01T0:00:00 + * fd2mst (string) + * convert from FITS UT date to Mean Sidereal Time + * dt2gmt (date, time) + * convert from UT as yyyy.mmdd hh.mmssss to Mean Sidereal Time + * ts2mst (tsec) + * Calculate Mean Sidereal Time given Universal Time + * in seconds since 1951-01-01T0:00:00 + * jd2mst (string) + * convert from Julian Date to Mean Sidereal Time + * mst2fd (string) + * convert to current UT in FITS format given Greenwich Mean Sidereal Time + * mst2jd (dj) + * convert to current UT as Julian Date given Greenwich Mean Sidereal Time + * jd2lst (dj) + * Calculate Local Sidereal Time from Julian Date + * ts2lst (tsec) + * Calculate Local Sidereal Time given UT in seconds since 1951-01-01T0:00 + * fd2lst (string) + * Calculate Local Sidereal Time given Universal Time as FITS ISO date + * lst2jd (dj, lst) + * Calculate Julian Date given current Julian date and Local Sidereal Time + * lst2fd (string, lst) + * Calculate Julian Date given current UT date and Local Sidereal Time + * gst2fd (string) + * Calculate current UT given UT date and Greenwich Sidereal Time + * gst2jd (dj) + * Calculate current UT given UT date and Greenwich Sidereal Time as JD + * + * compnut (dj, dpsi, deps, eps0) + * Compute the longitude and obliquity components of nutation and + * mean obliquity from the IAU 1980 theory + * + * utdt (dj) + * Compute difference between UT and dynamical time (ET-UT) + * ut2dt (year, doy) + * Current Universal Time to year and day of year + * ut2dt (date, time) + * Current Universal Time to date (yyyy.mmdd) and time (hh.mmsss) + * ut2ep(), ut2epb(), ut2epj() + * Current Universal Time to fractional year, Besselian, Julian epoch + * ut2fd() + * Current Universal Time to FITS ISO date string + * ut2jd() + * Current Universal Time to Julian Date + * ut2mjd() + * Current Universal Time to Modified Julian Date + * ut2tsi() + * Current Universal Time to IRAF seconds since 1980-01-01T00:00 + * ut2tsu() + * Current Universal Time to Unix seconds since 1970-01-01T00:00 + * ut2ts() + * Current Universal Time to seconds since 1950-01-01T00:00 + * isdate (string) + * Return 1 if string is a FITS date (old or ISO) + * + * Internally-used subroutines + * + * fixdate (iyr, imon, iday, ihr, imn, sec, ndsec) + * Round seconds and make sure date and time numbers are within limits + * caldays (year, month) + * Calculate days in month 1-12 given year (Gregorian calendar only + * dint (dnum) + * Return integer part of floating point number + * dmod (dnum) + * Return Mod of floating point number + */ + +#include +#include +#include +#include +#include +#include +#include "wcs.h" +#include "fitsfile.h" + +static double suntl(); +static void fixdate(); +static int caldays(); +static double dint(); +static double dmod(); + +static double longitude = 0.0; /* longitude of observatory in degrees (+=west) */ +void +setlongitude (longitude0) +double longitude0; +{ longitude = longitude0; return; } + +static int ndec = 3; +void +setdatedec (nd) +int nd; +{ ndec = nd; return; } + +/* ANG2HR -- Convert angle in fraction degrees to hours as hh:mm:ss.ss */ + +void +ang2hr (angle, lstr, string) + +double angle; /* Angle in fractional degrees */ +int lstr; /* Maximum number of characters in string */ +char *string; /* Character string (hh:mm:ss.ss returned) */ + +{ + angle = angle / 15.0; + dec2str (string, lstr, angle, ndec); + return; +} + + +/* ANG2DEG -- Convert angle in fraction degrees to degrees as dd:mm:ss.ss */ + +void +ang2deg (angle, lstr, string) + +double angle; /* Angle in fractional degrees */ +int lstr; /* Maximum number of characters in string */ +char *string; /* Character string (dd:mm:ss.ss returned) */ +{ + dec2str (string, lstr, angle, ndec); + return; +} + + +/* DEG2ANG -- Convert angle in degrees as dd:mm:ss.ss to fractional degrees */ + +double +deg2ang (angle) + +char *angle; /* Angle as dd:mm:ss.ss */ +{ + double deg; + + deg = str2dec (angle); + return (deg); +} + +/* HR2ANG -- Convert angle in hours as hh:mm:ss.ss to fractional degrees */ + +double +hr2ang (angle) + +char *angle; /* Angle in sexigesimal hours (hh:mm:ss.sss) */ + +{ + double deg; + + deg = str2dec (angle); + deg = deg * 15.0; + return (deg); +} + + +/* DT2FD-- convert vigesimal date and time to FITS date, yyyy-mm-ddThh:mm:ss.ss */ + +char * +dt2fd (date, time) + +double date; /* Date as yyyy.mmdd + yyyy = calendar year (e.g. 1973) + mm = calendar month (e.g. 04 = april) + dd = calendar day (e.g. 15) */ +double time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) + hh = hour of day (0 .le. hh .le. 23) + nn = minutes (0 .le. nn .le. 59) + ss = seconds (0 .le. ss .le. 59) + xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ +{ + int iyr,imon,iday,ihr,imn; + double sec; + int nf; + char *string; + char tstring[32], dstring[32]; + char outform[64]; + + dt2i (date, time, &iyr,&imon,&iday,&ihr,&imn,&sec, ndec); + + /* Convert to ISO date format */ + string = (char *) calloc (32, sizeof (char)); + + /* Make time string */ + if (time != 0.0 || ndec > 0) { + if (ndec == 0) + nf = 2; + else + nf = 3 + ndec; + if (ndec > 0) { + sprintf (outform, "%%02d:%%02d:%%0%d.%df", nf, ndec); + sprintf (tstring, outform, ihr, imn, sec); + } + else { + sprintf (outform, "%%02d:%%02d:%%0%dd", nf); + sprintf (tstring, outform, ihr, imn, (int)(sec+0.5)); + } + } + + /* Make date string */ + if (date != 0.0) + sprintf (dstring, "%4d-%02d-%02d", iyr, imon, iday); + + /* Make FITS (ISO) date string */ + if (date == 0.0) + strcpy (string, tstring); + else if (time == 0.0 && ndec < 1) + strcpy (string, dstring); + else + sprintf (string, "%sT%s", dstring, tstring); + + return (string); +} + + +/* DT2JD-- convert from date as yyyy.mmdd and time as hh.mmsss to Julian Date + * Return fractional days if date is zero */ + +double +dt2jd (date,time) + +double date; /* Date as yyyy.mmdd + yyyy = calendar year (e.g. 1973) + mm = calendar month (e.g. 04 = april) + dd = calendar day (e.g. 15) */ +double time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) + hh = hour of day (0 .le. hh .le. 23) + nn = minutes (0 .le. nn .le. 59) + ss = seconds (0 .le. ss .le. 59) + xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ +{ + double dj; /* Julian date (returned) */ + double tsec; /* seconds since 1950.0 */ + + tsec = dt2ts (date, time); + if (date == 0.0) + dj = tsec / 86400.0; + else + dj = ts2jd (tsec); + + return (dj); +} + + +/* DT2MJD-- convert from date yyyy.mmdd time hh.mmsss to modified Julian Date + * Return fractional days if date is zero */ + +double +dt2mjd (date,time) + +double date; /* Date as yyyy.mmdd + yyyy = calendar year (e.g. 1973) + mm = calendar month (e.g. 04 = april) + dd = calendar day (e.g. 15) */ +double time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) + hh = hour of day (0 .le. hh .le. 23) + nn = minutes (0 .le. nn .le. 59) + ss = seconds (0 .le. ss .le. 59) + xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ +{ + double dj; /* Modified Julian date (returned) */ + double tsec; /* seconds since 1950.0 */ + + tsec = dt2ts (date, time); + if (date == 0.0) + dj = tsec / 86400.0; + else + dj = ts2jd (tsec); + + return (dj - 2400000.5); +} + + +/* HJD2JD-- convert Heliocentric Julian Date to (geocentric) Julian date */ + +double +hjd2jd (dj, ra, dec, sys) + +double dj; /* Heliocentric Julian date */ +double ra; /* Right ascension (degrees) */ +double dec; /* Declination (degrees) */ +int sys; /* J2000, B1950, GALACTIC, ECLIPTIC */ +{ + double lt; /* Light travel difference to the Sun (days) */ + + lt = suntl (dj, ra, dec, sys); + + /* Return Heliocentric Julian Date */ + return (dj - lt); +} + + +/* JD2HJD-- convert (geocentric) Julian date to Heliocentric Julian Date */ + +double +jd2hjd (dj, ra, dec, sys) + +double dj; /* Julian date (geocentric) */ +double ra; /* Right ascension (degrees) */ +double dec; /* Declination (degrees) */ +int sys; /* J2000, B1950, GALACTIC, ECLIPTIC */ +{ + double lt; /* Light travel difference to the Sun (days) */ + + lt = suntl (dj, ra, dec, sys); + + /* Return Heliocentric Julian Date */ + return (dj + lt); +} + + +/* MHJD2MJD-- convert modified Heliocentric Julian Date to + modified geocentric Julian date */ + +double +mhjd2mjd (mhjd, ra, dec, sys) + +double mhjd; /* Modified Heliocentric Julian date */ +double ra; /* Right ascension (degrees) */ +double dec; /* Declination (degrees) */ +int sys; /* J2000, B1950, GALACTIC, ECLIPTIC */ +{ + double lt; /* Light travel difference to the Sun (days) */ + double hjd; /* Heliocentric Julian date */ + + hjd = mjd2jd (mhjd); + + lt = suntl (hjd, ra, dec, sys); + + /* Return Heliocentric Julian Date */ + return (jd2mjd (hjd - lt)); +} + + +/* MJD2MHJD-- convert modified geocentric Julian date tp + modified Heliocentric Julian Date */ + +double +mjd2mhjd (mjd, ra, dec, sys) + +double mjd; /* Julian date (geocentric) */ +double ra; /* Right ascension (degrees) */ +double dec; /* Declination (degrees) */ +int sys; /* J2000, B1950, GALACTIC, ECLIPTIC */ +{ + double lt; /* Light travel difference to the Sun (days) */ + double dj; /* Julian date (geocentric) */ + + dj = mjd2jd (mjd); + + lt = suntl (dj, ra, dec, sys); + + /* Return Heliocentric Julian Date */ + return (jd2mjd (dj + lt)); +} + + +/* SUNTL-- compute light travel time to heliocentric correction in days */ +/* Translated into C from IRAF SPP noao.astutils.asttools.asthjd.x */ + +static double +suntl (dj, ra, dec, sys) + +double dj; /* Julian date (geocentric) */ +double ra; /* Right ascension (degrees) */ +double dec; /* Declination (degrees) */ +int sys; /* J2000, B1950, GALACTIC, ECLIPTIC */ +{ + double t; /* Number of Julian centuries since J1900 */ + double manom; /* Mean anomaly of the Earth's orbit (degrees) */ + double lperi; /* Mean longitude of perihelion (degrees) */ + double oblq; /* Mean obliquity of the ecliptic (degrees) */ + double eccen; /* Eccentricity of the Earth's orbit (dimensionless) */ + double eccen2, eccen3; + double tanom; /* True anomaly (approximate formula) (radians) */ + double slong; /* True longitude of the Sun from the Earth (radians) */ + double rs; /* Distance to the sun (AU) */ + double lt; /* Light travel difference to the Sun (days) */ + double l; /* Longitude of star in orbital plane of Earth (radians) */ + double b; /* Latitude of star in orbital plane of Earth (radians) */ + double epoch; /* Epoch of obervation */ + double rs1,rs2; + + t = (dj - 2415020.0) / 36525.0; + + /* Compute earth orbital parameters */ + manom = 358.47583 + (t * (35999.04975 - t * (0.000150 + t * 0.000003))); + lperi = 101.22083 + (t * (1.7191733 + t * (0.000453 + t * 0.000003))); + oblq = 23.452294 - (t * (0.0130125 + t * (0.00000164 - t * 0.000000503))); + eccen = 0.01675104 - (t * (0.00004180 + t * 0.000000126)); + eccen2 = eccen * eccen; + eccen3 = eccen * eccen2; + + /* Convert to principle angles */ + manom = manom - (360.0 * (dint) (manom / 360.0)); + lperi = lperi - (360.0 * (dint) (lperi / 360.0)); + + /* Convert to radians */ + manom = degrad (manom); + lperi = degrad (lperi); + oblq = degrad (oblq); + + /* True anomaly */ + tanom = manom + (2 * eccen - 0.25 * eccen3) * sin (manom) + + 1.25 * eccen2 * sin (2 * manom) + + 13./12. * eccen3 * sin (3 * manom); + + /* Distance to the Sun */ + rs1 = 1.0 - eccen2; + rs2 = 1.0 + (eccen * cos (tanom)); + rs = rs1 / rs2; + + /* True longitude of the Sun seen from the Earth */ + slong = lperi + tanom + PI; + + /* Longitude and latitude of star in orbital plane of the Earth */ + epoch = jd2ep (dj); + wcscon (sys, WCS_ECLIPTIC, 0.0, 0.0, &ra, &dec, epoch); + l = degrad (ra); + b = degrad (dec); + + /* Light travel difference to the Sun */ + lt = -0.005770 * rs * cos (b) * cos (l - slong); + + /* Return light travel difference */ + return (lt); +} + + +/* JD2DT-- convert Julian date to date as yyyy.mmdd and time as hh.mmssss */ + +void +jd2dt (dj,date,time) + +double dj; /* Julian date */ +double *date; /* Date as yyyy.mmdd (returned) */ +double *time; /* Time as hh.mmssxxxx (returned) */ +{ + int iyr,imon,iday,ihr,imn; + double sec; + + /* Convert Julian Date to date and time */ + jd2i (dj, &iyr, &imon, &iday, &ihr, &imn, &sec, 4); + + /* Convert date to yyyy.mmdd */ + if (iyr < 0) { + *date = (double) (-iyr) + 0.01 * (double) imon + 0.0001 * (double) iday; + *date = -(*date); + } + else + *date = (double) iyr + 0.01 * (double) imon + 0.0001 * (double) iday; + + /* Convert time to hh.mmssssss */ + *time = (double) ihr + 0.01 * (double) imn + 0.0001 * sec; + + return; +} + + +/* JD2I-- convert Julian date to date as year, month, and day, and time hours, + minutes, and seconds */ +/* after Fliegel and Van Flander, CACM 11, 657 (1968) */ + + +void +jd2i (dj, iyr, imon, iday, ihr, imn, sec, ndsec) + +double dj; /* Julian date */ +int *iyr; /* year (returned) */ +int *imon; /* month (returned) */ +int *iday; /* day (returned) */ +int *ihr; /* hours (returned) */ +int *imn; /* minutes (returned) */ +double *sec; /* seconds (returned) */ +int ndsec; /* Number of decimal places in seconds (0=int) */ + +{ + double tsec; + double frac, dts, ts, sday; + int jd, l, n, i, j; + + tsec = jd2ts (dj); + /* ts2i (tsec, iyr, imon, iday, ihr, imn, sec, ndsec); */ + + /* Round seconds to 0 - 4 decimal places */ + if (tsec < 0.0) + dts = -0.5; + else + dts = 0.5; + if (ndsec < 1) + ts = dint (tsec + dts); + else if (ndsec < 2) + ts = dint (tsec * 10.0 + dts) / 10.0; + else if (ndsec < 3) + ts = dint (tsec * 100.0 + dts) / 100.0; + else if (ndsec < 4) + ts = dint (tsec * 1000.0 + dts) / 1000.0; + else + ts = dint (tsec * 10000.0 + dts) / 10000.0; + + /* Convert back to Julian Date */ + dj = ts2jd (ts); + + /* Compute time from fraction of a day */ + frac = dmod (dj, 1.0); + if (frac < 0.5) { + jd = (int) (dj - frac); + sday = (frac + 0.5) * 86400.0; + } + else { + jd = (int) (dj - frac) + 1; + sday = (frac - 0.5) * 86400.0; + } + + *ihr = (int) (sday / 3600.0); + sday = sday - (double) (*ihr * 3600); + *imn = (int) (sday / 60.0); + *sec = sday - (double) (*imn * 60); + + /* Compute day, month, year */ + l = jd + 68569; + n = (4 * l) / 146097; + l = l - (146097 * n + 3) / 4; + i = (4000 * (l + 1)) / 1461001; + l = l - (1461 * i) / 4 + 31; + j = (80 * l) / 2447; + *iday = l - (2447 * j) / 80; + l = j / 11; + *imon = j + 2 - (12 * l); + *iyr = 100 * (n - 49) + i + l; + + return; +} + + +/* JD2MJD-- convert Julian Date to Modified Julian Date */ + +double +jd2mjd (dj) + +double dj; /* Julian Date */ + +{ + return (dj - 2400000.5); +} + + +/* JD2EP-- convert Julian date to fractional year as used in epoch */ + +double +jd2ep (dj) + +double dj; /* Julian date */ + +{ + double date, time; + jd2dt (dj, &date, &time); + return (dt2ep (date, time)); +} + + +/* JD2EPB-- convert Julian date to Besselian epoch */ + +double +jd2epb (dj) + +double dj; /* Julian date */ + +{ + return (1900.0 + (dj - 2415020.31352) / 365.242198781); +} + + +/* JD2EPJ-- convert Julian date to Julian epoch */ + +double +jd2epj (dj) + +double dj; /* Julian date */ + +{ + return (2000.0 + (dj - 2451545.0) / 365.25); +} + + +/* LT2DT-- Return local time as yyyy.mmdd and time as hh.mmssss */ + +void +lt2dt(date, time) + +double *date; /* Date as yyyy.mmdd (returned) */ +double *time; /* Time as hh.mmssxxxx (returned) */ + +{ + time_t tsec; + struct timeval tp; + struct timezone tzp; + struct tm *ts; + + gettimeofday (&tp,&tzp); + + tsec = tp.tv_sec; + ts = localtime (&tsec); + + if (ts->tm_year < 1000) + *date = (double) (ts->tm_year + 1900); + else + *date = (double) ts->tm_year; + *date = *date + (0.01 * (double) (ts->tm_mon + 1)); + *date = *date + (0.0001 * (double) ts->tm_mday); + *time = (double) ts->tm_hour; + *time = *time + (0.01 * (double) ts->tm_min); + *time = *time + (0.0001 * (double) ts->tm_sec); + + return; +} + + +/* LT2FD-- Return current local time as FITS ISO date string */ + +char * +lt2fd() +{ + time_t tsec; + struct tm *ts; + struct timeval tp; + struct timezone tzp; + int month, day, year, hour, minute, second; + char *isotime; + + gettimeofday (&tp,&tzp); + tsec = tp.tv_sec; + + ts = localtime (&tsec); + + year = ts->tm_year; + if (year < 1000) + year = year + 1900; + month = ts->tm_mon + 1; + day = ts->tm_mday; + hour = ts->tm_hour; + minute = ts->tm_min; + second = ts->tm_sec; + + isotime = (char *) calloc (32, sizeof (char)); + sprintf (isotime, "%04d-%02d-%02dT%02d:%02d:%02d", + year, month, day, hour, minute, second); + return (isotime); +} + + +/* LT2TSI-- Return local time as IRAF seconds since 1980-01-01 00:00 */ + +int +lt2tsi() +{ + return ((int)(lt2ts() - 946684800.0)); +} + + +/* LT2TSU-- Return local time as Unix seconds since 1970-01-01 00:00 */ + +time_t +lt2tsu() +{ + return ((time_t)(lt2ts() - 631152000.0)); +} + +/* LT2TS-- Return local time as Unix seconds since 1950-01-01 00:00 */ + +double +lt2ts() +{ + double tsec; + char *datestring; + datestring = lt2fd(); + tsec = fd2ts (datestring); + free (datestring); + return (tsec); +} + + +/* MJD2DT-- convert Modified Julian Date to date (yyyy.mmdd) time (hh.mmssss) */ + +void +mjd2dt (dj,date,time) + +double dj; /* Modified Julian Date */ +double *date; /* Date as yyyy.mmdd (returned) + yyyy = calendar year (e.g. 1973) + mm = calendar month (e.g. 04 = april) + dd = calendar day (e.g. 15) */ +double *time; /* Time as hh.mmssxxxx (returned) + *if time<0, it is time as -(fraction of a day) + hh = hour of day (0 .le. hh .le. 23) + nn = minutes (0 .le. nn .le. 59) + ss = seconds (0 .le. ss .le. 59) + xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ +{ + double tsec; + + tsec = jd2ts (dj + 2400000.5); + ts2dt (tsec, date, time); + + return; +} + + +/* MJD2I-- convert Modified Julian Date to date as year, month, day and + time as hours, minutes, seconds */ + +void +mjd2i (dj, iyr, imon, iday, ihr, imn, sec, ndsec) + +double dj; /* Modified Julian Date */ +int *iyr; /* year (returned) */ +int *imon; /* month (returned) */ +int *iday; /* day (returned) */ +int *ihr; /* hours (returned) */ +int *imn; /* minutes (returned) */ +double *sec; /* seconds (returned) */ +int ndsec; /* Number of decimal places in seconds (0=int) */ + +{ + double tsec; + + tsec = jd2ts (dj + 2400000.5); + ts2i (tsec, iyr, imon, iday, ihr, imn, sec, ndsec); + return; +} + + +/* MJD2DOY-- convert Modified Julian Date to Year,Day-of-Year */ + +void +mjd2doy (dj, year, doy) + +double dj; /* Modified Julian Date */ +int *year; /* Year (returned) */ +double *doy; /* Day of year with fraction (returned) */ + +{ + jd2doy (dj + 2400000.5, year, doy); + return; +} + + +/* MJD2JD-- convert Modified Julian Date to Julian Date */ + +double +mjd2jd (dj) + +double dj; /* Modified Julian Date */ + +{ + return (dj + 2400000.5); +} + + +/* MJD2EP-- convert Modified Julian Date to fractional year */ + +double +mjd2ep (dj) + +double dj; /* Modified Julian Date */ + +{ + double date, time; + jd2dt (dj + 2400000.5, &date, &time); + return (dt2ep (date, time)); +} + + +/* MJD2EPB-- convert Modified Julian Date to Besselian epoch */ + +double +mjd2epb (dj) + +double dj; /* Modified Julian Date */ + +{ + return (1900.0 + (dj - 15019.81352) / 365.242198781); +} + + +/* MJD2EPJ-- convert Modified Julian Date to Julian epoch */ + +double +mjd2epj (dj) + +double dj; /* Modified Julian Date */ + +{ + return (2000.0 + (dj - 51544.5) / 365.25); +} + + +/* MJD2FD-- convert modified Julian date to FITS date, yyyy-mm-ddThh:mm:ss.ss */ + +char * +mjd2fd (dj) + +double dj; /* Modified Julian date */ +{ + return (jd2fd (dj + 2400000.5)); +} + + +/* MJD2TS-- convert modified Julian date to seconds since 1950.0 */ + +double +mjd2ts (dj) + +double dj; /* Modified Julian date */ +{ + return ((dj - 33282.0) * 86400.0); +} + + +/* EP2FD-- convert fractional year to FITS date, yyyy-mm-ddThh:mm:ss.ss */ + +char * +ep2fd (epoch) + +double epoch; /* Date as fractional year */ +{ + double tsec; /* seconds since 1950.0 (returned) */ + tsec = ep2ts (epoch); + return (ts2fd (tsec)); +} + + +/* EPB2FD-- convert Besselian epoch to FITS date, yyyy-mm-ddThh:mm:ss.ss */ + +char * +epb2fd (epoch) + +double epoch; /* Besselian epoch (fractional 365.242198781-day years) */ +{ + double dj; /* Julian Date */ + dj = epb2jd (epoch); + return (jd2fd (dj)); +} + + +/* EPJ2FD-- convert Julian epoch to FITS date, yyyy-mm-ddThh:mm:ss.ss */ + +char * +epj2fd (epoch) + +double epoch; /* Julian epoch (fractional 365.25-day years) */ +{ + double dj; /* Julian Date */ + dj = epj2jd (epoch); + return (jd2fd (dj)); +} + + +/* EP2TS-- convert fractional year to seconds since 1950.0 */ + +double +ep2ts (epoch) + +double epoch; /* Date as fractional year */ +{ + double dj; + dj = ep2jd (epoch); + return ((dj - 2433282.5) * 86400.0); +} + + +/* EPB2TS-- convert Besselian epoch to seconds since 1950.0 */ + +double +epb2ts (epoch) + +double epoch; /* Besselian epoch (fractional 365.242198781-day years) */ +{ + double dj; + dj = epb2jd (epoch); + return ((dj - 2433282.5) * 86400.0); +} + + +/* EPJ2TS-- convert Julian epoch to seconds since 1950.0 */ + +double +epj2ts (epoch) + +double epoch; /* Julian epoch (fractional 365.25-day years) */ +{ + double dj; + dj = epj2jd (epoch); + return ((dj - 2433282.5) * 86400.0); +} + + +/* EPB2EP-- convert Besselian epoch to fractional years */ + +double +epb2ep (epoch) + +double epoch; /* Besselian epoch (fractional 365.242198781-day years) */ +{ + double dj; + dj = epb2jd (epoch); + return (jd2ep (dj)); +} + + +/* EP2EPB-- convert fractional year to Besselian epoch */ + +double +ep2epb (epoch) + +double epoch; /* Fractional year */ +{ + double dj; + dj = ep2jd (epoch); + return (jd2epb (dj)); +} + + +/* EPJ2EP-- convert Julian epoch to fractional year */ + +double +epj2ep (epoch) + +double epoch; /* Julian epoch (fractional 365.25-day years) */ +{ + double dj; + dj = epj2jd (epoch); + return (jd2ep (dj)); +} + + +/* EP2EPJ-- convert fractional year to Julian epoch */ + +double +ep2epj (epoch) + +double epoch; /* Fractional year */ +{ + double dj; + dj = ep2jd (epoch); + return (jd2epj (dj)); +} + + +/* EP2I-- convert fractional year to year month day hours min sec */ + +void +ep2i (epoch, iyr, imon, iday, ihr, imn, sec, ndsec) + +double epoch; /* Date as fractional year */ +int *iyr; /* year (returned) */ +int *imon; /* month (returned) */ +int *iday; /* day (returned) */ +int *ihr; /* hours (returned) */ +int *imn; /* minutes (returned) */ +double *sec; /* seconds (returned) */ +int ndsec; /* Number of decimal places in seconds (0=int) */ +{ + double date, time; + + ep2dt (epoch, &date, &time); + dt2i (date, time, iyr,imon,iday,ihr,imn,sec, ndsec); + return; +} + + +/* EPB2I-- convert Besselian epoch to year month day hours min sec */ + +void +epb2i (epoch, iyr, imon, iday, ihr, imn, sec, ndsec) + +double epoch; /* Besselian epoch (fractional 365.242198781-day years) */ +int *iyr; /* year (returned) */ +int *imon; /* month (returned) */ +int *iday; /* day (returned) */ +int *ihr; /* hours (returned) */ +int *imn; /* minutes (returned) */ +double *sec; /* seconds (returned) */ +int ndsec; /* Number of decimal places in seconds (0=int) */ +{ + double date, time; + + epb2dt (epoch, &date, &time); + dt2i (date, time, iyr,imon,iday,ihr,imn,sec, ndsec); + return; +} + + +/* EPJ2I-- convert Julian epoch to year month day hours min sec */ + +void +epj2i (epoch, iyr, imon, iday, ihr, imn, sec, ndsec) + +double epoch; /* Julian epoch (fractional 365.25-day years) */ +int *iyr; /* year (returned) */ +int *imon; /* month (returned) */ +int *iday; /* day (returned) */ +int *ihr; /* hours (returned) */ +int *imn; /* minutes (returned) */ +double *sec; /* seconds (returned) */ +int ndsec; /* Number of decimal places in seconds (0=int) */ +{ + double date, time; + + epj2dt (epoch, &date, &time); + dt2i (date, time, iyr,imon,iday,ihr,imn,sec, ndsec); + return; +} + + +/* EP2JD-- convert fractional year as used in epoch to Julian date */ + +double +ep2jd (epoch) + +double epoch; /* Date as fractional year */ + +{ + double dj; /* Julian date (returned)*/ + double date, time; + + ep2dt (epoch, &date, &time); + dj = dt2jd (date, time); + return (dj); +} + + +/* EPB2JD-- convert Besselian epoch to Julian Date */ + +double +epb2jd (epoch) + +double epoch; /* Besselian epoch (fractional 365.242198781-day years) */ + +{ + return (2415020.31352 + ((epoch - 1900.0) * 365.242198781)); +} + + +/* EPJ2JD-- convert Julian epoch to Julian Date */ + +double +epj2jd (epoch) + +double epoch; /* Julian epoch (fractional 365.25-day years) */ + +{ + return (2451545.0 + ((epoch - 2000.0) * 365.25)); +} + + +/* EP2MJD-- convert fractional year as used in epoch to modified Julian date */ + +double +ep2mjd (epoch) + +double epoch; /* Date as fractional year */ + +{ + double dj; /* Julian date (returned)*/ + double date, time; + + ep2dt (epoch, &date, &time); + dj = dt2jd (date, time); + return (dj - 2400000.5); +} + + +/* EPB2MJD-- convert Besselian epoch to modified Julian Date */ + +double +epb2mjd (epoch) + +double epoch; /* Besselian epoch (fractional 365.242198781-day years) */ + +{ + return (15019.81352 + ((epoch - 1900.0) * 365.242198781)); +} + + +/* EPJ2MJD-- convert Julian epoch to modified Julian Date */ + +double +epj2mjd (epoch) + +double epoch; /* Julian epoch (fractional 365.25-day years) */ + +{ + return (51544.5 + ((epoch - 2000.0) * 365.25)); +} + + + +/* EPB2EPJ-- convert Besselian epoch to Julian epoch */ + +double +epb2epj (epoch) + +double epoch; /* Besselian epoch (fractional 365.242198781-day years) */ +{ + double dj; /* Julian date */ + dj = epb2jd (epoch); + return (jd2epj (dj)); +} + + +/* EPJ2EPB-- convert Julian epoch to Besselian epoch */ + +double +epj2epb (epoch) + +double epoch; /* Julian epoch (fractional 365.25-day years) */ +{ + double dj; /* Julian date */ + dj = epj2jd (epoch); + return (jd2epb (dj)); +} + + +/* JD2FD-- convert Julian date to FITS date, yyyy-mm-ddThh:mm:ss.ss */ + +char * +jd2fd (dj) + +double dj; /* Julian date */ +{ + double tsec; /* seconds since 1950.0 (returned) */ + tsec = (dj - 2433282.5) * 86400.0; + return (ts2fd (tsec)); +} + + +/* JD2TS-- convert Julian date to seconds since 1950.0 */ + +double +jd2ts (dj) + +double dj; /* Julian date */ +{ + return ((dj - 2433282.5) * 86400.0); +} + + +/* JD2TSI-- convert Julian date to IRAF seconds since 1980-01-01T0:00 */ + +int +jd2tsi (dj) + +double dj; /* Julian date */ +{ + double ts; + ts = (dj - 2444239.5) * 86400.0; + return ((int) ts); +} + + +/* JD2TSU-- convert Julian date to Unix seconds since 1970-01-01T0:00 */ + +time_t +jd2tsu (dj) + +double dj; /* Julian date */ +{ + return ((time_t)((dj - 2440587.5) * 86400.0)); +} + + +/* DT2DOY-- convert yyyy.mmdd hh.mmss to year and day of year */ + +void +dt2doy (date, time, year, doy) + +double date; /* Date as yyyy.mmdd */ +double time; /* Time as hh.mmssxxxx */ +int *year; /* Year (returned) */ +double *doy; /* Day of year with fraction (returned) */ +{ + double dj; /* Julian date */ + double dj0; /* Julian date on January 1 0:00 */ + double date0; /* January first of date's year */ + double dyear; + + dyear = floor (date); + date0 = dyear + 0.0101; + dj0 = dt2jd (date0, 0.0); + dj = dt2jd (date, time); + *year = (int) (dyear + 0.00000001); + *doy = dj - dj0 + 1.0; + return; +} + + +/* DOY2DT-- convert year and day of year to yyyy.mmdd hh.mmss */ + +void +doy2dt (year, doy, date, time) + +int year; /* Year */ +double doy; /* Day of year with fraction */ +double *date; /* Date as yyyy.mmdd (returned) */ +double *time; /* Time as hh.mmssxxxx (returned) */ +{ + double dj; /* Julian date */ + double dj0; /* Julian date on January 1 0:00 */ + double date0; /* January first of date's year */ + + date0 = year + 0.0101; + dj0 = dt2jd (date0, 0.0); + dj = dj0 + doy - 1.0; + jd2dt (dj, date, time); + return; +} + + +/* DOY2EP-- convert year and day of year to fractional year as used in epoch */ + +double +doy2ep (year, doy) + +int year; /* Year */ +double doy; /* Day of year with fraction */ +{ + double date, time; + doy2dt (year, doy, &date, &time); + return (dt2ep (date, time)); +} + + + +/* DOY2EPB-- convert year and day of year to Besellian epoch */ + +double +doy2epb (year, doy) + +int year; /* Year */ +double doy; /* Day of year with fraction */ +{ + double dj; + dj = doy2jd (year, doy); + return (jd2epb (dj)); +} + + +/* DOY2EPJ-- convert year and day of year to Julian epoch */ + +double +doy2epj (year, doy) + +int year; /* Year */ +double doy; /* Day of year with fraction */ +{ + double dj; + dj = doy2jd (year, doy); + return (jd2epj (dj)); +} + + +/* DOY2FD-- convert year and day of year to FITS date */ + +char * +doy2fd (year, doy) + +int year; /* Year */ +double doy; /* Day of year with fraction */ +{ + double dj; /* Julian date */ + + dj = doy2jd (year, doy); + return (jd2fd (dj)); +} + + +/* DOY2JD-- convert year and day of year to Julian date */ + +double +doy2jd (year, doy) + +int year; /* Year */ +double doy; /* Day of year with fraction */ +{ + double dj0; /* Julian date */ + double date; /* Date as yyyy.mmdd (returned) */ + double time; /* Time as hh.mmssxxxx (returned) */ + + date = (double) year + 0.0101; + time = 0.0; + dj0 = dt2jd (date, time); + return (dj0 + doy - 1.0); +} + + +/* DOY2MJD-- convert year and day of year to Julian date */ + +double +doy2mjd (year, doy) + +int year; /* Year */ +double doy; /* Day of year with fraction */ +{ + double dj0; /* Julian date */ + double date; /* Date as yyyy.mmdd (returned) */ + double time; /* Time as hh.mmssxxxx (returned) */ + + date = (double) year + 0.0101; + time = 0.0; + dj0 = dt2jd (date, time); + return (dj0 + doy - 1.0 - 2400000.5); +} + + +/* DOY2TSU-- convert from FITS date to Unix seconds since 1970-01-01T0:00 */ + +time_t +doy2tsu (year, doy) + +int year; /* Year */ +double doy; /* Day of year with fraction */ +{ + double dj; + dj = doy2jd (year, doy); + return ((time_t)jd2ts (dj)); +} + + +/* DOY2TSI-- convert from FITS date to IRAF seconds since 1980-01-01T0:00 */ + +int +doy2tsi (year, doy) + +int year; /* Year */ +double doy; /* Day of year with fraction */ +{ + double dj; + dj = doy2jd (year, doy); + return ((int)jd2tsi (dj)); +} + + +/* DOY2TS-- convert year, day of year to seconds since 1950 */ + +double +doy2ts (year, doy) + +int year; /* Year */ +double doy; /* Day of year with fraction */ +{ + double dj; + dj = doy2jd (year, doy); + return (jd2ts (dj)); +} + + +/* FD2DOY-- convert FITS date to year and day of year */ + +void +fd2doy (string, year, doy) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +int *year; /* Year (returned) */ +double *doy; /* Day of year with fraction (returned) */ +{ + double dj; /* Julian date */ + + dj = fd2jd (string); + jd2doy (dj, year, doy); + return; +} + + +/* JD2DOY-- convert Julian date to year and day of year */ + +void +jd2doy (dj, year, doy) + +double dj; /* Julian date */ +int *year; /* Year (returned) */ +double *doy; /* Day of year with fraction (returned) */ +{ + double date; /* Date as yyyy.mmdd (returned) */ + double time; /* Time as hh.mmssxxxx (returned) */ + double dj0; /* Julian date at 0:00 on 1/1 */ + double dyear; + + jd2dt (dj, &date, &time); + *year = (int) date; + dyear = (double) *year; + dj0 = dt2jd (dyear+0.0101, 0.0); + *doy = dj - dj0 + 1.0; + return; +} + + +/* TS2JD-- convert seconds since 1950.0 to Julian date */ + +double +ts2jd (tsec) + +double tsec; /* seconds since 1950.0 */ +{ + return (2433282.5 + (tsec / 86400.0)); +} + + +/* TS2MJD-- convert seconds since 1950.0 to modified Julian date */ + +double +ts2mjd (tsec) + +double tsec; /* seconds since 1950.0 */ +{ + return (33282.0 + (tsec / 86400.0)); +} + + +/* TS2EP-- convert seconds since 1950.0 to fractional year as used in epoch */ + +double +ts2ep (tsec) + +double tsec; /* Seconds since 1950.0 */ + +{ + double date, time; + ts2dt (tsec, &date, &time); + return (dt2ep (date, time)); +} + + +/* TS2EPB-- convert seconds since 1950.0 to Besselian epoch */ + +double +ts2epb (tsec) + +double tsec; /* Seconds since 1950.0 */ + +{ + double dj; /* Julian Date */ + dj = ts2jd (tsec); + return (jd2epb (dj)); +} + + +/* TS2EPB-- convert seconds since 1950.0 to Julian epoch */ + +double +ts2epj (tsec) + +double tsec; /* Seconds since 1950.0 */ + +{ + double dj; /* Julian Date */ + dj = ts2jd (tsec); + return (jd2epj (dj)); +} + + +/* DT2EP-- convert from date, time as yyyy.mmdd hh.mmsss to fractional year */ + +double +dt2ep (date, time) + +double date; /* Date as yyyy.mmdd + yyyy = calendar year (e.g. 1973) + mm = calendar month (e.g. 04 = april) + dd = calendar day (e.g. 15) */ +double time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) + hh = hour of day (0 .le. hh .le. 23) + nn = minutes (0 .le. nn .le. 59) + ss = seconds (0 .le. ss .le. 59) + xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ +{ + double epoch; /* Date as fractional year (returned) */ + double dj, dj0, dj1, date0, time0, date1; + + dj = dt2jd (date, time); + if (date == 0.0) + epoch = dj / 365.2422; + else { + time0 = 0.0; + date0 = dint (date) + 0.0101; + date1 = dint (date) + 1.0101; + dj0 = dt2jd (date0, time0); + dj1 = dt2jd (date1, time0); + epoch = dint (date) + ((dj - dj0) / (dj1 - dj0)); + } + return (epoch); +} + + +/* DT2EPB-- convert from date, time as yyyy.mmdd hh.mmsss to Besselian epoch */ + +double +dt2epb (date, time) + +double date; /* Date as yyyy.mmdd + yyyy = calendar year (e.g. 1973) + mm = calendar month (e.g. 04 = april) + dd = calendar day (e.g. 15) */ +double time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) + hh = hour of day (0 .le. hh .le. 23) + nn = minutes (0 .le. nn .le. 59) + ss = seconds (0 .le. ss .le. 59) + xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ +{ + double dj; /* Julian date */ + double epoch; /* Date as fractional year (returned) */ + dj = dt2jd (date, time); + if (date == 0.0) + epoch = dj / 365.242198781; + else + epoch = jd2epb (dj); + return (epoch); +} + + +/* DT2EPJ-- convert from date, time as yyyy.mmdd hh.mmsss to Julian epoch */ + +double +dt2epj (date, time) + +double date; /* Date as yyyy.mmdd + yyyy = calendar year (e.g. 1973) + mm = calendar month (e.g. 04 = april) + dd = calendar day (e.g. 15) */ +double time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) + hh = hour of day (0 .le. hh .le. 23) + nn = minutes (0 .le. nn .le. 59) + ss = seconds (0 .le. ss .le. 59) + xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ +{ + double dj; /* Julian date */ + double epoch; /* Date as fractional year (returned) */ + dj = dt2jd (date, time); + if (date == 0.0) + epoch = dj / 365.25; + else + epoch = jd2epj (dj); + return (epoch); +} + + +/* EP2DT-- convert from fractional year to date, time as yyyy.mmdd hh.mmsss */ + +void +ep2dt (epoch, date, time) + +double epoch; /* Date as fractional year */ +double *date; /* Date as yyyy.mmdd (returned) + yyyy = calendar year (e.g. 1973) + mm = calendar month (e.g. 04 = april) + dd = calendar day (e.g. 15) */ +double *time; /* Time as hh.mmssxxxx (returned) + *if time<0, it is time as -(fraction of a day) + hh = hour of day (0 .le. hh .le. 23) + nn = minutes (0 .le. nn .le. 59) + ss = seconds (0 .le. ss .le. 59) + xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ +{ + double dj, dj0, dj1, date0, time0, date1, epochi, epochf; + + time0 = 0.0; + epochi = dint (epoch); + epochf = epoch - epochi; + date0 = epochi + 0.0101; + date1 = epochi + 1.0101; + dj0 = dt2jd (date0, time0); + dj1 = dt2jd (date1, time0); + dj = dj0 + epochf * (dj1 - dj0); + jd2dt (dj, date, time); + return; +} + + +/* EPB2DT-- convert from Besselian epoch to date, time as yyyy.mmdd hh.mmsss */ + +void +epb2dt (epoch, date, time) + +double epoch; /* Besselian epoch (fractional 365.242198781-day years) */ +double *date; /* Date as yyyy.mmdd (returned) + yyyy = calendar year (e.g. 1973) + mm = calendar month (e.g. 04 = april) + dd = calendar day (e.g. 15) */ +double *time; /* Time as hh.mmssxxxx (returned) + *if time<0, it is time as -(fraction of a day) + hh = hour of day (0 .le. hh .le. 23) + nn = minutes (0 .le. nn .le. 59) + ss = seconds (0 .le. ss .le. 59) + xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ +{ + double dj; /* Julian date */ + dj = epb2jd (epoch); + jd2dt (dj, date, time); +} + + +/* EPJ2DT-- convert from Julian epoch to date, time as yyyy.mmdd hh.mmsss */ + +void +epj2dt (epoch, date, time) + +double epoch; /* Julian epoch (fractional 365.25-day years) */ +double *date; /* Date as yyyy.mmdd (returned) + yyyy = calendar year (e.g. 1973) + mm = calendar month (e.g. 04 = april) + dd = calendar day (e.g. 15) */ +double *time; /* Time as hh.mmssxxxx (returned) + *if time<0, it is time as -(fraction of a day) + hh = hour of day (0 .le. hh .le. 23) + nn = minutes (0 .le. nn .le. 59) + ss = seconds (0 .le. ss .le. 59) + xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ +{ + double dj; /* Julian date */ + dj = epj2jd (epoch); + jd2dt (dj, date, time); +} + + +/* FD2JD-- convert FITS standard date to Julian date */ + +double +fd2jd (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + double date, time; + + fd2dt (string, &date, &time); + return (dt2jd (date, time)); +} + + +/* FD2MJD-- convert FITS standard date to modified Julian date */ + +double +fd2mjd (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + return (fd2jd (string) - 2400000.5); +} + + +/* FD2TSU-- convert from FITS date to Unix seconds since 1970-01-01T0:00 */ + +time_t +fd2tsu (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + double date, time; + fd2dt (string, &date, &time); + return (dt2tsu (date, time)); +} + + +/* FD2TSI-- convert from FITS date to IRAF seconds since 1980-01-01T0:00 */ + +int +fd2tsi (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + double date, time; + fd2dt (string, &date, &time); + return (dt2tsi (date, time)); +} + + +/* FD2TS-- convert FITS standard date to seconds since 1950 */ + +double +fd2ts (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + double date, time; + fd2dt (string, &date, &time); + return (dt2ts (date, time)); +} + + +/* FD2FD-- convert any FITS standard date to ISO FITS standard date */ + +char * +fd2fd (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + double date, time; + fd2dt (string, &date, &time); + return (dt2fd (date, time)); +} + + +/* FD2OF-- convert any FITS standard date to old FITS standard date time */ + +char * +fd2of (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + int iyr,imon,iday,ihr,imn; + double sec; + + fd2i (string,&iyr,&imon,&iday,&ihr,&imn,&sec, 3); + + /* Convert to old FITS date format */ + string = (char *) calloc (32, sizeof (char)); + if (iyr < 1900) + sprintf (string, "*** date out of range ***"); + else if (iyr < 2000) + sprintf (string, "%02d/%02d/%02d %02d:%02d:%06.3f", + iday, imon, iyr-1900, ihr, imn, sec); + else if (iyr < 2900.0) + sprintf (string, "%02d/%02d/%3d %02d:%02d:%6.3f", + iday, imon, iyr-1900, ihr, imn, sec); + else + sprintf (string, "*** date out of range ***"); + return (string); +} + + +/* TAI-UTC from the U.S. Naval Observatory */ +/* ftp://maia.usno.navy.mil/ser7/tai-utc.dat */ +static double taijd[26]={2441317.5, 2441499.5, 2441683.5, 2442048.5, 2442413.5, + 2442778.5, 2443144.5, 2443509.5, 2443874.5, 2444239.5, 2444786.5, + 2445151.5, 2445516.5, 2446247.5, 2447161.5, 2447892.5, 2448257.5, + 2448804.5, 2449169.5, 2449534.5, 2450083.5, 2450630.5, 2451179.5, + 2453736.5, 2454832.5, 2456293.5}; +static double taidt[26]={10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0, + 20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,32.0, + 33.0,34.0,35.0}; +static double dttab[173]={13.7,13.4,13.1,12.9,12.7,12.6,12.5,12.5,12.5,12.5, + 12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.4,12.3,12.2,12.0,11.7,11.4, + 11.1,10.6,10.2, 9.6, 9.1, 8.6, 8.0, 7.5, 7.0, 6.6, 6.3, 6.0, 5.8, + 5.7, 5.6, 5.6, 5.6, 5.7, 5.8, 5.9, 6.1, 6.2, 6.3, 6.5, 6.6, 6.8, + 6.9, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.7, 7.8, 7.8,7.88,7.82, + 7.54, 6.97, 6.40, 6.02, 5.41, 4.10, 2.92, 1.82, 1.61, 0.10,-1.02, + -1.28,-2.69,-3.24,-3.64,-4.54,-4.71,-5.11,-5.40,-5.42,-5.20,-5.46, + -5.46,-5.79,-5.63,-5.64,-5.80,-5.66,-5.87,-6.01,-6.19,-6.64,-6.44, + -6.47,-6.09,-5.76,-4.66,-3.74,-2.72,-1.54,-0.02, 1.24, 2.64, 3.86, + 5.37, 6.14, 7.75, 9.13,10.46,11.53,13.36,14.65,16.01,17.20,18.24, + 19.06,20.25,20.95,21.16,22.25,22.41,23.03,23.49,23.62,23.86,24.49, + 24.34,24.08,24.02,24.00,23.87,23.95,23.86,23.93,23.73,23.92,23.96, + 24.02,24.33,24.83,25.30,25.70,26.24,26.77,27.28,27.78,28.25,28.71, + 29.15,29.57,29.97,30.36,30.72,31.07,31.35,31.68,32.18,32.68,33.15, + 33.59,34.00,34.47,35.03,35.73,36.54,37.43,38.29,39.20,40.18,41.17, + 42.23}; + + +/* TAI2FD-- convert from TAI in FITS format to UT in FITS format */ + +char * +tai2fd (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + double dj0, dj, tsec, dt; + + dj0 = fd2jd (string); + dt = utdt (dj0); + dj = dj0 - (dt / 86400.0); + dt = utdt (dj); + tsec = fd2ts (string); + tsec = tsec - dt + 32.184; + return (ts2fd (tsec)); +} + + +/* FD2TAI-- convert from UT in FITS format to TAI in FITS format */ + +char * +fd2tai (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + double dj, tsec, dt; + + dj = fd2jd (string); + dt = utdt (dj); + tsec = fd2ts (string); + tsec = tsec + dt - 32.184; + return (ts2fd (tsec)); +} + + +/* DT2TAI-- convert from UT as yyyy.mmdd hh.mmssss to TAI in same format */ + +void +dt2tai (date, time) +double *date; /* Date as yyyy.mmdd */ +double *time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) */ +{ + double dj, dt, tsec; + + dj = dt2jd (*date, *time); + dt = utdt (dj); + tsec = dt2ts (*date, *time); + tsec = tsec + dt - 32.184; + ts2dt (tsec, date, time); + return; +} + + +/* TAI2DT-- convert from TAI as yyyy.mmdd hh.mmssss to UT in same format */ + +void +tai2dt (date, time) +double *date; /* Date as yyyy.mmdd */ +double *time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) */ +{ + double dj, dt, tsec, tsec0; + + dj = dt2jd (*date, *time); + dt = utdt (dj); + tsec0 = dt2ts (*date, *time); + tsec = tsec0 + dt; + dj = ts2jd (tsec); + dt = utdt (dj); + tsec = tsec0 + dt + 32.184; + ts2dt (tsec, date, time); + return; +} + + +/* ET2FD-- convert from ET (or TDT or TT) in FITS format to UT in FITS format */ + +char * +et2fd (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + double dj0, dj, tsec, dt; + + dj0 = fd2jd (string); + dt = utdt (dj0); + dj = dj0 - (dt / 86400.0); + dt = utdt (dj); + tsec = fd2ts (string); + tsec = tsec - dt; + return (ts2fd (tsec)); +} + + +/* FD2ET-- convert from UT in FITS format to ET (or TDT or TT) in FITS format */ + +char * +fd2et (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + double dj, tsec, dt; + + dj = fd2jd (string); + dt = utdt (dj); + tsec = fd2ts (string); + tsec = tsec + dt; + return (ts2fd (tsec)); +} + + +/* DT2ET-- convert from UT as yyyy.mmdd hh.mmssss to ET in same format */ + +void +dt2et (date, time) +double *date; /* Date as yyyy.mmdd */ +double *time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) */ +{ + double dj, dt, tsec; + + dj = dt2jd (*date, *time); + dt = utdt (dj); + tsec = dt2ts (*date, *time); + tsec = tsec + dt; + ts2dt (tsec, date, time); + return; +} + + +/* EDT2DT-- convert from ET as yyyy.mmdd hh.mmssss to UT in same format */ + +void +edt2dt (date, time) +double *date; /* Date as yyyy.mmdd */ +double *time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) */ +{ + double dj, dt, tsec, tsec0; + + dj = dt2jd (*date, *time); + dt = utdt (dj); + tsec0 = dt2ts (*date, *time); + tsec = tsec0 + dt; + dj = ts2jd (tsec); + dt = utdt (dj); + tsec = tsec0 + dt; + ts2dt (tsec, date, time); + return; +} + + +/* JD2JED-- convert from Julian Date to Julian Ephemeris Date */ + +double +jd2jed (dj) + +double dj; /* Julian Date */ +{ + double dt; + + dt = utdt (dj); + return (dj + (dt / 86400.0)); +} + + +/* JED2JD-- convert from Julian Ephemeris Date to Julian Date */ + +double +jed2jd (dj) + +double dj; /* Julian Ephemeris Date */ +{ + double dj0, dt; + + dj0 = dj; + dt = utdt (dj); + dj = dj0 - (dt / 86400.0); + dt = utdt (dj); + return (dj - (dt / 86400.0)); +} + + +/* TS2ETS-- convert from UT in seconds since 1950-01-01 to ET in same format */ + +double +ts2ets (tsec) + +double tsec; +{ + double dj, dt; + + dj = ts2jd (tsec); + dt = utdt (dj); + return (tsec + dt); +} + + +/* ETS2TS-- convert from ET in seconds since 1950-01-01 to UT in same format */ + +double +ets2ts (tsec) + +double tsec; +{ + double dj, dj0, dt; + + dj0 = ts2jd (tsec); + dt = utdt (dj0); + dj = dj0 - (dt / 86400.0); + dt = utdt (dj); + return (tsec - dt); +} + + +/* UTDT-- Compute difference between UT and dynamical time (ET-UT) */ + +double +utdt (dj) + +double dj; /* Julian Date (UT) */ +{ + double dt, date, time, ts, ts1, ts0, date0, yfrac, diff, cj; + int i, iyr, iyear; + + /* If after 1972-01-01, use tabulated TAI-UT */ + if (dj >= 2441317.5) { + dt = 0.0; + for (i = 22; i > 0; i--) { + if (dj >= taijd[i]) + dt = taidt[i]; + } + dt = dt + 32.184; + } + + /* For 1800-01-01 to 1972-01-01, use table of ET-UT from AE */ + else if (dj >= 2378496.5) { + jd2dt (dj, &date, &time); + ts = jd2ts (dj); + iyear = (int) date; + iyr = iyear - 1800; + date0 = (double) iyear + 0.0101; + ts0 = dt2ts (date0, 0.0); + date0 = (double) (iyear + 1) + 0.0101; + ts1 = dt2ts (date0, 0.0); + yfrac = (ts - ts0) / (ts1 - ts0); + diff = dttab[iyr+1] - dttab[iyr]; + dt = dttab[iyr] + (diff * yfrac); + } + + /* Compute back to 1600 using formula from McCarthy and Babcock (1986) */ + else if (dj >= 2305447.5) { + cj = (dj - 2378496.5) / 36525.0; + dt = 5.156 + 13.3066 * (cj - 0.19) * (cj - 0.19); + } + + /* Compute back to 948 using formula from Stephenson and Morrison (1984) */ + else if (dj >= 2067309.5) { + cj = (dj - 2378496.5) / 36525.0; + dt = 25.5 * cj * cj; + } + + /*Compute back to 390 BC using formula from Stephenson and Morrison (1984)*/ + else if (dj >= 0.0) { + cj = (dj = 2378496.5) / 36525.0; + dt = 1360.0 + (320.0 * cj) + (44.3 * cj * cj); + } + + else + dt = 0.0; + return (dt); +} + + +/* FD2OFD-- convert any FITS standard date to old FITS standard date */ + +char * +fd2ofd (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + int iyr,imon,iday,ihr,imn; + double sec; + + fd2i (string,&iyr,&imon,&iday,&ihr,&imn,&sec, 3); + + /* Convert to old FITS date format */ + string = (char *) calloc (32, sizeof (char)); + if (iyr < 1900) + sprintf (string, "*** date out of range ***"); + else if (iyr < 2000) + sprintf (string, "%02d/%02d/%02d", iday, imon, iyr-1900); + else if (iyr < 2900.0) + sprintf (string, "%02d/%02d/%3d", iday, imon, iyr-1900); + else + sprintf (string, "*** date out of range ***"); + return (string); +} + + +/* FD2OFT-- convert any FITS standard date to old FITS standard time */ + +char * +fd2oft (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + int iyr,imon,iday,ihr,imn; + double sec; + + fd2i (string,&iyr,&imon,&iday,&ihr,&imn,&sec, 3); + + /* Convert to old FITS date format */ + string = (char *) calloc (32, sizeof (char)); + sprintf (string, "%02d:%02d:%06.3f", ihr, imn, sec); + return (string); +} + + +/* FD2DT-- convert FITS standard date to date, time as yyyy.mmdd hh.mmsss */ + +void +fd2dt (string, date, time) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +double *date; /* Date as yyyy.mmdd (returned) + yyyy = calendar year (e.g. 1973) + mm = calendar month (e.g. 04 = april) + dd = calendar day (e.g. 15) */ +double *time; /* Time as hh.mmssxxxx (returned) + *if time<0, it is time as -(fraction of a day) + hh = hour of day (0 .le. hh .le. 23) + nn = minutes (0 .le. nn .le. 59) + ss = seconds (0 .le. ss .le. 59) + xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ +{ + int iyr,imon,iday,ihr,imn; + double sec; + + fd2i (string,&iyr,&imon,&iday,&ihr,&imn,&sec, 4); + + /* Convert date to yyyy.mmdd */ + if (iyr < 0) { + *date = (double) (-iyr) + 0.01 * (double) imon + 0.0001 * (double) iday; + *date = -(*date); + } + else + *date = (double) iyr + 0.01 * (double) imon + 0.0001 * (double) iday; + + /* Convert time to hh.mmssssss */ + *time = (double) ihr + 0.01 * (double) imn + 0.0001 * sec; + + return; +} + + +/* FD2EP-- convert from FITS standard date to fractional year */ + +double +fd2ep (string) + +char *string; /* FITS date string, which may be: + yyyy.ffff (fractional year) + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard FITS use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ + +{ + double dj; /* Julian date */ + dj = fd2jd (string); + if (dj < 1.0) + return (dj / 365.2422); + else + return (jd2ep (dj)); +} + + +/* FD2EPB-- convert from FITS standard date to Besselian epoch */ + +double +fd2epb (string) + +char *string; /* FITS date string, which may be: + yyyy.ffff (fractional year) + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard FITS use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ + +{ + double dj; /* Julian date */ + dj = fd2jd (string); + if (dj < 1.0) + return (dj / 365.242198781); + else + return (jd2epb (dj)); +} + + +/* FD2EPJ-- convert from FITS standard date to Julian epoch */ + +double +fd2epj (string) + +char *string; /* FITS date string, which may be: + yyyy.ffff (fractional year) + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard FITS use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ + +{ + double dj; /* Julian date */ + dj = fd2jd (string); + if (dj < 1.0) + return (dj / 365.25); + else + return (jd2epj (dj)); +} + + +/* DT2TSU-- convert from date and time to Unix seconds since 1970-01-01T0:00 */ + +time_t +dt2tsu (date,time) + +double date; /* Date as yyyy.mmdd */ +double time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) */ +{ + return ((time_t)(dt2ts (date, time) - 631152000.0)); +} + + +/* DT2TSI-- convert from date and time to IRAF seconds since 1980-01-01T0:00 */ + +int +dt2tsi (date,time) + +double date; /* Date as yyyy.mmdd */ +double time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) */ +{ + return ((int)(dt2ts (date, time) - 946684800.0)); +} + + + +/* DT2TS-- convert from date, time as yyyy.mmdd hh.mmsss to sec since 1950.0 */ + +double +dt2ts (date,time) + +double date; /* Date as yyyy.mmdd + yyyy = calendar year (e.g. 1973) + mm = calendar month (e.g. 04 = april) + dd = calendar day (e.g. 15) */ +double time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) + hh = hour of day (0 .le. hh .le. 23) + nn = minutes (0 .le. nn .le. 59) + ss = seconds (0 .le. ss .le. 59) + xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ +{ + double tsec; /* Seconds past 1950.0 (returned) */ + + double dh,dm,dd; + int iy,im,id; + +/* Calculate the number of full years, months, and days already + * elapsed since 0h, March 1, -1 (up to most recent midnight). */ + + /* convert time of day to elapsed seconds */ + + /* If time is < 0, it is assumed to be a fractional day */ + if (time < 0.0) + tsec = time * -86400.0; + else { + dh = (int) (time + 0.0000000001); + dm = (int) (((time - dh) * 100.0) + 0.0000000001); + tsec = (time * 10000.0) - (dh * 10000.0) - (dm * 100.0); + tsec = (int) (tsec * 100000.0 + 0.0001) / 100000.0; + tsec = tsec + (dm * 60.0) + (dh * 3600.0); + } + + + /* Calculate the number of full months elapsed since + * the current or most recent March */ + if (date >= 0.0301) { + iy = (int) (date + 0.0000000001); + im = (int) (((date - (double) (iy)) * 10000.0) + 0.00000001); + id = im % 100; + im = (im / 100) + 9; + if (im < 12) iy = iy - 1; + im = im % 12; + id = id - 1; + + /* starting with March as month 0 and ending with the following + * February as month 11, the calculation of the number of days + * per month reduces to a simple formula. the following statement + * determines the number of whole days elapsed since 3/1/-1 and then + * subtracts the 712163 days between then and 1/1/1950. it converts + * the result to seconds and adds the accumulated seconds above. */ + id = id + ((im+1+im/6+im/11)/2 * 31) + ((im-im/6-im/11)/2 * 30) + + (iy / 4) - (iy / 100) + (iy / 400); + dd = (double) id + (365.0 * (double) iy) - 712163.0; + tsec = tsec + (dd * 86400.0); + } + + return (tsec); +} + + +/* TS2DT-- convert seconds since 1950.0 to date, time as yyyy.mmdd hh.mmssss */ + +void +ts2dt (tsec,date,time) + +double tsec; /* Seconds past 1950.0 */ +double *date; /* Date as yyyy.mmdd (returned) + yyyy = calendar year (e.g. 1973) + mm = calendar month (e.g. 04 = april) + dd = calendar day (e.g. 15) */ +double *time; /* Time as hh.mmssxxxx (returned) + *if time<0, it is time as -(fraction of a day) + hh = hour of day (0 .le. hh .le. 23) + nn = minutes (0 .le. nn .le. 59) + ss = seconds (0 .le. ss .le. 59) + xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ +{ + int iyr,imon,iday,ihr,imn; + double sec; + + ts2i (tsec,&iyr,&imon,&iday,&ihr,&imn,&sec, 4); + + /* Convert date to yyyy.mmdd */ + if (iyr < 0) { + *date = (double) (-iyr) + 0.01 * (double) imon + 0.0001 * (double) iday; + *date = -(*date); + } + else + *date = (double) iyr + 0.01 * (double) imon + 0.0001 * (double) iday; + + /* Convert time to hh.mmssssss */ + *time = (double) ihr + 0.01 * (double) imn + 0.0001 * sec; + + return; +} + + +/* TSI2DT-- Convert seconds since 1980-01-01 to date yyyy.ddmm, time hh.mmsss */ + +void +tsi2dt (isec,date,time) + +int isec; /* Seconds past 1980-01-01 */ +double *date; /* Date as yyyy.mmdd (returned) */ +double *time; /* Time as hh.mmssxxxx (returned) */ +{ + ts2dt (tsi2ts (isec), date, time); +} + + +/* TSI2FD-- Convert seconds since 1980-01-01 to FITS standard date string */ + +char * +tsi2fd (isec) + +int isec; /* Seconds past 1980-01-01 */ +{ + return (ts2fd (tsi2ts (isec))); +} + + +/* TSI2TS-- Convert seconds since 1980-01-01 to seconds since 1950-01-01 */ + +double +tsi2ts (isec) +int isec; /* Seconds past 1980-01-01 */ +{ + return ((double) isec + 946684800.0); +} + + +/* TSU2FD-- Convert seconds since 1970-01-01 to FITS standard date string */ + +char * +tsu2fd (isec) +time_t isec; /* Seconds past 1970-01-01 */ +{ + return (ts2fd (tsu2ts (isec))); +} + + +/* TSU2DT-- Convert seconds since 1970-01-01 to date yyyy.ddmm, time hh.mmsss */ + +void +tsu2dt (isec,date,time) +time_t isec; /* Seconds past 1970-01-01 */ +double *date; /* Date as yyyy.mmdd (returned) */ +double *time; /* Time as hh.mmssxxxx (returned) */ +{ + ts2dt (tsu2ts (isec), date, time); +} + + +/* TSU2TS-- Convert seconds since 1970-01-01 to seconds since 1950-01-01 */ + +double +tsu2ts (isec) +time_t isec; /* Seconds past 1970-01-01 */ +{ + return ((double) isec + 631152000.0); +} + +/* TSU2TSI-- UT seconds since 1970-01-01 to local seconds since 1980-01-01 */ + +int +tsu2tsi (isec) +time_t isec; /* Seconds past 1970-01-01 */ +{ + double date, time; + struct tm *ts; + + /* Get local time from UT seconds */ + ts = localtime (&isec); + if (ts->tm_year < 1000) + date = (double) (ts->tm_year + 1900); + else + date = (double) ts->tm_year; + date = date + (0.01 * (double) (ts->tm_mon + 1)); + date = date + (0.0001 * (double) ts->tm_mday); + time = (double) ts->tm_hour; + time = time + (0.01 * (double) ts->tm_min); + time = time + (0.0001 * (double) ts->tm_sec); + return ((int)(dt2ts (date, time) - 631152000.0)); +} + + +/* TS2FD-- convert seconds since 1950.0 to FITS date, yyyy-mm-ddThh:mm:ss.ss */ + +char * +ts2fd (tsec) + +double tsec; /* Seconds past 1950.0 */ +{ + double date, time; + + ts2dt (tsec, &date, &time); + return (dt2fd (date, time)); +} + + +/* TSD2FD-- convert seconds since start of day to FITS time, hh:mm:ss.ss */ + +char * +tsd2fd (tsec) + +double tsec; /* Seconds since start of day */ +{ + double date, time; + char *thms, *fdate; + int lfd, nbc; + + ts2dt (tsec, &date, &time); + fdate = dt2fd (date, time); + thms = (char *) calloc (16, 1); + lfd = strlen (fdate); + nbc = lfd - 11; + strncpy (thms, fdate+11, nbc); + return (thms); +} + + +/* TSD2DT-- convert seconds since start of day to hh.mmssss */ + +double +tsd2dt (tsec) + +double tsec; /* Seconds since start of day */ +{ + double date, time; + + ts2dt (tsec, &date, &time); + return (time); +} + + + +/* DT2I-- convert vigesimal date and time to year month day hours min sec */ + +void +dt2i (date, time, iyr, imon, iday, ihr, imn, sec, ndsec) + +double date; /* Date as yyyy.mmdd (returned) + yyyy = calendar year (e.g. 1973) + mm = calendar month (e.g. 04 = april) + dd = calendar day (e.g. 15) */ +double time; /* Time as hh.mmssxxxx (returned) + *if time<0, it is time as -(fraction of a day) + hh = hour of day (0 .le. hh .le. 23) + nn = minutes (0 .le. nn .le. 59) + ss = seconds (0 .le. ss .le. 59) + xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ +int *iyr; /* year (returned) */ +int *imon; /* month (returned) */ +int *iday; /* day (returned) */ +int *ihr; /* hours (returned) */ +int *imn; /* minutes (returned) */ +double *sec; /* seconds (returned) */ +int ndsec; /* Number of decimal places in seconds (0=int) */ + +{ + double t,d; + + t = time; + if (date < 0.0) + d = -date; + else + d = date; + + /* Extract components of time */ + *ihr = dint (t + 0.000000001); + t = 100.0 * (t - (double) *ihr); + *imn = dint (t + 0.0000001); + *sec = 100.0 * (t - (double) *imn); + + /* Extract components of date */ + *iyr = dint (d + 0.00001); + d = 100.0 * (d - (double) *iyr); + if (date < 0.0) + *iyr = - *iyr; + *imon = dint (d + 0.001); + d = 100.0 * (d - (double) *imon); + *iday = dint (d + 0.1); + + /* Make sure date and time are legal */ + fixdate (iyr, imon, iday, ihr, imn, sec, ndsec); + + return; +} + + +/* FD2I-- convert from FITS standard date to year, mon, day, hours, min, sec */ + +void +fd2i (string, iyr, imon, iday, ihr, imn, sec, ndsec) + +char *string; /* FITS date string, which may be: + yyyy.ffff (fractional year) + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard FITS use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +int *iyr; /* year (returned) */ +int *imon; /* month (returned) */ +int *iday; /* day (returned) */ +int *ihr; /* hours (returned) */ +int *imn; /* minutes (returned) */ +double *sec; /* seconds (returned) */ +int ndsec; /* Number of decimal places in seconds (0=int) */ + +{ + double tsec, fday, hr, mn; + int i; + char *sstr, *dstr, *tstr, *cstr, *nval, *fstr; + + /* Initialize all returned data to zero */ + *iyr = 0; + *imon = 0; + *iday = 0; + *ihr = 0; + *imn = 0; + *sec = 0.0; + + /* Return if no input string */ + if (string == NULL) + return; + + /* Check for various non-numeric characters */ + sstr = strchr (string,'/'); + dstr = strchr (string,'-'); + if (dstr == string) + dstr = strchr (string+1, '-'); + fstr = strchr (string, '.'); + tstr = strchr (string,'T'); + if (tstr == NULL) + tstr = strchr (string, 'Z'); + if (tstr == NULL) + tstr = strchr (string, 'S'); + if (fstr != NULL && tstr != NULL && fstr > tstr) + fstr = NULL; + cstr = strchr (string,':'); + + /* Original FITS date format: dd/mm/yy */ + if (sstr > string) { + *sstr = '\0'; + *iday = (int) atof (string); + if (*iday > 31) { + *iyr = *iday; + if (*iyr >= 0 && *iyr <= 49) + *iyr = *iyr + 2000; + else if (*iyr < 1000) + *iyr = *iyr + 1900; + *sstr = '/'; + nval = sstr + 1; + sstr = strchr (nval,'/'); + if (sstr > string) { + *sstr = '\0'; + *imon = (int) atof (nval); + *sstr = '/'; + nval = sstr + 1; + *iday = (int) atof (nval); + } + } + else { + *sstr = '/'; + nval = sstr + 1; + sstr = strchr (nval,'/'); + if (sstr == NULL) + sstr = strchr (nval,'-'); + if (sstr > string) { + *sstr = '\0'; + *imon = (int) atof (nval); + *sstr = '/'; + nval = sstr + 1; + *iyr = (int) atof (nval); + if (*iyr >= 0 && *iyr <= 49) + *iyr = *iyr + 2000; + else if (*iyr < 1000) + *iyr = *iyr + 1900; + } + } + tstr = strchr (string,'_'); + if (tstr == NULL) + return; + } + + /* New FITS date format: yyyy-mm-ddThh:mm:ss[.sss] */ + else if (dstr > string) { + *dstr = '\0'; + *iyr = (int) atof (string); + *dstr = '-'; + nval = dstr + 1; + dstr = strchr (nval,'-'); + *imon = 1; + *iday = 1; + + /* Decode year, month, and day */ + if (dstr > string) { + *dstr = '\0'; + *imon = (int) atof (nval); + *dstr = '-'; + nval = dstr + 1; + if (tstr > string) + *tstr = '\0'; + *iday = (int) atof (nval); + + /* If fraction of a day is present, turn it into a time */ + if (fstr != NULL) { + fday = atof (fstr); + hr = fday * 24.0; + *ihr = (int) hr; + mn = 60.0 * (hr - (double) *ihr); + *imn = (int) mn; + *sec = 60.0 * (mn - (double) *imn); + } + + if (tstr > string) + *tstr = 'T'; + } + + /* If date is > 31, it is really year in old format */ + if (*iday > 31) { + i = *iyr; + if (*iday < 100) + *iyr = *iday + 1900; + else + *iyr = *iday; + *iday = i; + } + } + + /* In rare cases, a FITS time is entered as an epoch */ + else if (tstr == NULL && cstr == NULL && isnum (string)) { + tsec = ep2ts (atof (string)); + ts2i (tsec,iyr,imon,iday,ihr,imn,sec, ndsec); + return; + } + + /* Extract time, if it is present */ + if (tstr > string || cstr > string) { + if (tstr > string) + nval = tstr + 1; + else + nval = string; + cstr = strchr (nval,':'); + if (cstr > string) { + *cstr = '\0'; + *ihr = (int) atof (nval); + *cstr = ':'; + nval = cstr + 1; + cstr = strchr (nval,':'); + if (cstr > string) { + *cstr = '\0'; + *imn = (int) atof (nval); + *cstr = ':'; + nval = cstr + 1; + *sec = atof (nval); + } + else + *imn = (int) atof (nval); + } + else + *ihr = (int) atof (nval); + } + else + ndsec = -1; + + /* Make sure date and time are legal */ + fixdate (iyr, imon, iday, ihr, imn, sec, ndsec); + + return; +} + + +/* TS2I-- convert sec since 1950.0 to year month day hours minutes seconds */ + +void +ts2i (tsec,iyr,imon,iday,ihr,imn,sec, ndsec) + +double tsec; /* seconds since 1/1/1950 0:00 */ +int *iyr; /* year (returned) */ +int *imon; /* month (returned) */ +int *iday; /* day (returned) */ +int *ihr; /* hours (returned) */ +int *imn; /* minutes (returned) */ +double *sec; /* seconds (returned) */ +int ndsec; /* Number of decimal places in seconds (0=int) */ + +{ + double t,days, ts, dts; + int nc,nc4,nly,ny,m,im; + + /* Round seconds to 0 - 4 decimal places */ + ts = tsec + 61530883200.0; + if (ts < 0.0) + dts = -0.5; + else + dts = 0.5; + if (ndsec < 1) + t = dint (ts + dts) * 10000.0; + else if (ndsec < 2) + t = dint (ts * 10.0 + dts) * 1000.0; + else if (ndsec < 3) + t = dint (ts * 100.0 + dts) * 100.0; + else if (ndsec < 4) + t = dint (ts * 1000.0 + dts) * 10.0; + else + t = dint (ts * 10000.0 + dts); + ts = t / 10000.0; + + /* Time of day (hours, minutes, seconds */ + *ihr = (int) (dmod (ts/3600.0, 24.0)); + *imn = (int) (dmod (ts/60.0, 60.0)); + *sec = dmod (ts, 60.0); + + /* Number of days since 0 hr 0/0/0000 */ + days = dint ((t / 864000000.0) + 0.000001); + + /* Number of leap centuries (400 years) */ + nc4 = (int) ((days / 146097.0) + 0.00001); + + /* Number of centuries since last /400 */ + days = days - (146097.0 * (double) (nc4)); + nc = (int) ((days / 36524.0) + 0.000001); + if (nc > 3) nc = 3; + + /* Number of leap years since last century */ + days = days - (36524.0 * nc); + nly = (int) ((days / 1461.0) + 0.0000000001); + + /* Number of years since last leap year */ + days = days - (1461.0 * (double) nly); + ny = (int) ((days / 365.0) + 0.00000001); + if (ny > 3) ny = 3; + + /* Day of month */ + days = days - (365.0 * (double) ny); + if (days < 0) { + m = 0; + *iday = 29; + } + else { + *iday = (int) (days + 0.00000001) + 1; + for (m = 1; m <= 12; m++) { + im = (m + ((m - 1) / 5)) % 2; + /* fprintf (stderr,"%d %d %d %d\n", m, im, *iday, nc); */ + if (*iday-1 < im+30) break; + *iday = *iday - im - 30; + } + } + + /* Month */ + *imon = ((m+1) % 12) + 1; + + /* Year */ + *iyr = nc4*400 + nc*100 + nly*4 + ny + m/11; + + /* Make sure date and time are legal */ + fixdate (iyr, imon, iday, ihr, imn, sec, ndsec); + + return; +} + + +/* UT2DOY-- Current Universal Time as year, day of year */ + +void +ut2doy (year, doy) + +int *year; /* Year (returned) */ +double *doy; /* Day of year (returned) */ +{ + double date, time; + ut2dt (&date, &time); + dt2doy (date, time, year, doy); + return; +} + + +/* UT2DT-- Current Universal Time as date (yyyy.mmdd) and time (hh.mmsss) */ + +void +ut2dt(date, time) + +double *date; /* Date as yyyy.mmdd (returned) */ +double *time; /* Time as hh.mmssxxxx (returned) */ +{ + time_t tsec; + struct timeval tp; + struct timezone tzp; + struct tm *ts; + + gettimeofday (&tp,&tzp); + + tsec = tp.tv_sec; + ts = gmtime (&tsec); + + if (ts->tm_year < 1000) + *date = (double) (ts->tm_year + 1900); + else + *date = (double) ts->tm_year; + *date = *date + (0.01 * (double) (ts->tm_mon + 1)); + *date = *date + (0.0001 * (double) ts->tm_mday); + *time = (double) ts->tm_hour; + *time = *time + (0.01 * (double) ts->tm_min); + *time = *time + (0.0001 * (double) ts->tm_sec); + + return; +} + + +/* UT2EP-- Return current Universal Time as fractional year */ + +double +ut2ep() +{ + return (jd2ep (ut2jd())); +} + + +/* UT2EPB-- Return current Universal Time as Besselian epoch */ + +double +ut2epb() +{ + return (jd2epb (ut2jd())); +} + + +/* UT2EPJ-- Return current Universal Time as Julian epoch */ + +double +ut2epj() +{ + return (jd2epj (ut2jd())); +} + + +/* UT2FD-- Return current Universal Time as FITS ISO date string */ + +char * +ut2fd() +{ + int year, month, day, hour, minute, second; + time_t tsec; + struct timeval tp; + struct timezone tzp; + struct tm *ts; + char *isotime; + + gettimeofday (&tp,&tzp); + tsec = tp.tv_sec; + ts = gmtime (&tsec); + + year = ts->tm_year; + if (year < 1000) + year = year + 1900; + month = ts->tm_mon + 1; + day = ts->tm_mday; + hour = ts->tm_hour; + minute = ts->tm_min; + second = ts->tm_sec; + + isotime = (char *) calloc (32, sizeof (char)); + sprintf (isotime, "%04d-%02d-%02dT%02d:%02d:%02d", + year, month, day, hour, minute, second); + return (isotime); +} + + +/* UT2JD-- Return current Universal Time as Julian Date */ + +double +ut2jd() +{ + return (fd2jd (ut2fd())); +} + + +/* UT2MJD-- convert current UT to Modified Julian Date */ + +double +ut2mjd () + +{ + return (ut2jd() - 2400000.5); +} + +/* UT2TS-- current Universal Time as IRAF seconds since 1950-01-01T00:00 */ + +double +ut2ts() +{ + double tsec; + char *datestring; + datestring = ut2fd(); + tsec = fd2ts (datestring); + free (datestring); + return (tsec); +} + + +/* UT2TSI-- current Universal Time as IRAF seconds since 1980-01-01T00:00 */ + +int +ut2tsi() +{ + return ((int)(ut2ts() - 946684800.0)); +} + + +/* UT2TSU-- current Universal Time as IRAF seconds since 1970-01-01T00:00 */ + +time_t +ut2tsu() +{ + return ((time_t)(ut2ts () - 631152000.0)); +} + + +/* FD2GST-- convert from FITS date to Greenwich Sidereal Time */ + +char * +fd2gst (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + double dj, gsec, date, time; + + dj = fd2jd (string); + gsec = jd2gst (dj); + ts2dt (gsec, &date, &time); + date = 0.0; + return (dt2fd (date, time)); +} + + +/* DT2GST-- convert from UT as yyyy.mmdd hh.mmssss to Greenwich Sidereal Time*/ + +void +dt2gst (date, time) +double *date; /* Date as yyyy.mmdd */ +double *time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) */ +{ + double dj, gsec; + + dj = dt2ts (*date, *time); + gsec = jd2gst (dj); + ts2dt (gsec, date, time); + *date = 0.0; + return; +} + + +/* JD2LST - Local Sidereal Time in seconds from Julian Date */ + +double +jd2lst (dj) + +double dj; /* Julian Date */ +{ + double gst, lst; + + /* Compute Greenwich Sidereal Time at this epoch */ + gst = jd2gst (dj); + + /* Subtract longitude (degrees to seconds of time) */ + lst = gst - (240.0 * longitude); + if (lst < 0.0) + lst = lst + 86400.0; + else if (lst > 86400.0) + lst = lst - 86400.0; + return (lst); +} + + +/* FD2LST - Local Sidereal Time as hh:mm:ss.ss + from Universal Time as FITS ISO date */ + +char * +fd2lst (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) */ +{ + double dj, date, time, lst; + + dj = fd2jd (string); + lst = jd2lst (dj); + ts2dt (lst, &date, &time); + date = 0.0; + return (dt2fd (date, time)); +} + + +/* DT2LST - Local Sidereal Time as hh.mmssss + from Universal Time as yyyy.mmdd hh.mmssss */ + +void +dt2lst (date, time) + +double *date; /* Date as yyyy.mmdd */ +double *time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) */ +{ + double dj, lst, date0; + + dj = dt2jd (*date, *time); + lst = jd2lst (dj); + date0 = 0.0; + ts2dt (lst, &date0, time); + return; +} + + +/* TS2LST - Local Sidereal Time in seconds of day + * from Universal Time in seconds since 1951-01-01T0:00:00 + */ + +double +ts2lst (tsec) + +double tsec; /* time since 1950.0 in UT seconds */ +{ + double gst; /* Greenwich Sidereal Time in seconds since 0:00 */ + double lst; /* Local Sidereal Time in seconds since 0:00 */ + double gsec, date; + + /* Greenwich Sidereal Time */ + gsec = ts2gst (tsec); + date = 0.0; + ts2dt (gsec, &date, &gst); + + lst = gst - (longitude / 15.0); + if (lst < 0.0) + lst = lst + 86400.0; + else if (lst > 86400.0) + lst = lst - 86400.0; + return (lst); +} + + +/* LST2FD - calculate current UT given Local Sidereal Time + * plus date in FITS ISO format (yyyy-mm-dd) + * Return UT date and time in FITS ISO format + */ + +char * +lst2fd (string) + +char *string; /* UT Date, LST as yyyy-mm-ddShh:mm:ss.ss */ +{ + double sdj, dj; + + sdj = fd2jd (string); + + dj = lst2jd (sdj); + + return (jd2fd (dj)); +} + + +/* LST2JD - calculate current Julian Date given Local Sidereal Time + * plus current Julian Date (0.5 at 0:00 UT) + * Return UT date and time as Julian Date + */ + +double +lst2jd (sdj) + +double sdj; /* Julian Date of desired day at 0:00 UT + sidereal time */ +{ + double gst; /* Greenwich Sidereal Time in seconds since 0:00 */ + double lsd; /* Local Sidereal Time in seconds since 0:00 */ + double gst0, tsd, dj1, dj0, eqnx; + int idj; + + /* Julian date at 0:00 UT */ + idj = (int) sdj; + dj0 = (double) idj + 0.5; + if (dj0 > sdj) dj0 = dj0 - 1.0; + + /* Greenwich Sidereal Time at 0:00 UT in seconds */ + gst0 = jd2gst (dj0); + + /* Sidereal seconds since 0:00 */ + lsd = (sdj - dj0) * 86400.0; + + /* Remove longitude for current Greenwich Sidereal Time in seconds */ + /* (convert longitude from degrees to seconds of time) */ + gst = lsd + (longitude * 240.0); + + /* Time since 0:00 UT */ + tsd = (gst - gst0) / 1.0027379093; + + /* Julian Date (UT) */ + dj1 = dj0 + (tsd / 86400.0); + + /* Equation of the equinoxes converted to UT seconds */ + eqnx = eqeqnx (dj1) / 1.002739093; + + /* Remove equation of equinoxes */ + dj1 = dj1 - (eqnx / 86400.0); + if (dj1 < dj0) + dj1 = dj1 + 1.0; + + return (dj1); +} + + +/* MST2FD - calculate current UT given Greenwich Mean Sidereal Time + * plus date in FITS ISO format (yyyy-mm-ddShh:mm:ss.ss) + * Return UT date and time in FITS ISO format + */ + +char * +mst2fd (string) + +char *string; /* UT Date, MST as yyyy-mm-ddShh:mm:ss.ss */ +{ + double sdj, dj; + + sdj = fd2jd (string); + + dj = mst2jd (sdj); + + return (jd2fd (dj)); +} + + +/* MST2JD - calculate current UT given Greenwich Mean Sidereal Time + * plus date in Julian Date (0:00 UT + Mean Sidereal Time) + * Return UT date and time as Julian Date + */ + +double +mst2jd (sdj) + +double sdj; /* UT Date, MST as Julian Date */ +{ + double tsd, djd, st0, dj0, dj; + + dj0 = (double) ((int) sdj) + 0.5; + + /* Greenwich Mean Sidereal Time at 0:00 UT in seconds */ + st0 = jd2mst (dj0); + + /* Mean Sidereal Time in seconds */ + tsd = (sdj - dj0) * 86400.0; + if (tsd < 0.0) + tsd = tsd + 86400.0; + + /* Convert to fraction of a day since 0:00 UT */ + djd = ((tsd - st0) / 1.0027379093) / 86400.0; + + /* Julian Date */ + dj = dj0 + djd; + if (dj < dj0) + dj = dj + (1.0 / 1.0027379093); + + return (dj); +} + + + +/* GST2FD - calculate current UT given Greenwich Sidereal Time + * plus date in FITS ISO format (yyyy-mm-ddShh:mm:ss.ss) + * Return UT date and time in FITS ISO format + */ + +char * +gst2fd (string) + +char *string; /* UT Date, GST as yyyy-mm-ddShh:mm:ss.ss */ +{ + double sdj, dj; + + sdj = fd2jd (string); + + dj = gst2jd (sdj); + + return (jd2fd (dj)); +} + + +/* GST2JD - calculate current UT given Greenwich Sidereal Time + * plus date as Julian Date (JD at 0:00 UT + sidereal time) + * Return UT date and time as Julian Date + */ + +double +gst2jd (sdj) + +double sdj; /* UT Date, GST as Julian Date */ +{ + double dj, tsd, djd, st0, dj0, eqnx; + + dj0 = (double) ((int) sdj) + 0.5; + + /* Greenwich Mean Sidereal Time at 0:00 UT in seconds */ + st0 = jd2mst (dj0); + + /* Mean Sidereal Time in seconds */ + tsd = (sdj - dj0) * 86400.0; + if (tsd < 0.0) + tsd = tsd + 86400.0; + + /* Convert to fraction of a day since 0:00 UT */ + djd = ((tsd - st0) / 1.0027379093) / 86400.0; + + /* Julian Date */ + dj = dj0 + djd; + + /* Equation of the equinoxes (converted to UT seconds) */ + eqnx = eqeqnx (dj) / 1.002737909; + + dj = dj - eqnx / 86400.0; + if (dj < dj0) + dj = dj + 1.0; + + return (dj); +} + + +/* LST2DT - calculate current UT given Local Sidereal Time as hh.mmsss + * plus date as yyyy.mmdd + * Return UT time as hh.mmssss + */ + +double +lst2dt (date0, time0) + +double date0; /* UT date as yyyy.mmdd */ +double time0; /* LST as hh.mmssss */ +{ + double gst; /* Greenwich Sidereal Time in seconds since 0:00 */ + double lst; /* Local Sidereal Time in seconds since 0:00 */ + double date1; /* UT date as yyyy.mmdd */ + double time1; /* UT as hh.mmssss */ + double tsec0, gst0, tsd, tsec; + + /* Greenwich Sidereal Time at 0:00 UT */ + tsec0 = dt2ts (date0, 0.0); + gst0 = ts2gst (tsec0); + + /* Current Greenwich Sidereal Time in seconds */ + /* (convert longitude from degrees to seconds of time) */ + lst = dt2ts (0.0, time0); + gst = lst + (longitude * 240.0); + + /* Time since 0:00 UT */ + tsd = (gst - gst0) / 1.0027379093; + + /* UT date and time */ + tsec = tsec0 + tsd; + ts2dt (tsec, &date1, &time1); + + return (time1); +} + + +/* TS2GST - calculate Greenwich Sidereal Time given Universal Time + * in seconds since 1951-01-01T0:00:00 + * Return sidereal time of day in seconds + */ + +double +ts2gst (tsec) + +double tsec; /* time since 1950.0 in UT seconds */ +{ + double gst; /* Greenwich Sidereal Time in seconds since 0:00 */ + double tsd, eqnx, dj; + int its; + + /* Elapsed time as of 0:00 UT */ + if (tsec >= 0.0) { + its = (int) (tsec + 0.5); + tsd = (double) (its % 86400); + } + else { + its = (int) (-tsec + 0.5); + tsd = (double) (86400 - (its % 86400)); + } + + /* Mean sidereal time */ + gst = ts2mst (tsec); + + /* Equation of the equinoxes */ + dj = ts2jd (tsec); + eqnx = eqeqnx (dj); + + /* Apparent sidereal time at 0:00 ut */ + gst = gst + eqnx; + + /* Current sidereal time */ + gst = gst + (tsd * 1.0027379093); + gst = dmod (gst,86400.0); + + return (gst); +} + + +/* FD2MST-- convert from FITS date Mean Sidereal Time */ + +char * +fd2mst (string) + +char *string; /* FITS date string, which may be: + fractional year + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ +{ + double gsec, date, time, dj; + + dj = fd2jd (string); + gsec = jd2mst (dj); + ts2dt (gsec, &date, &time); + date = 0.0; + return (dt2fd (date, time)); +} + + +/* DT2MST-- convert from UT as yyyy.mmdd hh.mmssss to Mean Sidereal Time + in the same format */ + +void +dt2mst (date, time) +double *date; /* Date as yyyy.mmdd */ +double *time; /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) */ +{ + double date0, gsec, dj; + date0 = *date; + dj = dt2jd (*date, *time); + gsec = jd2mst (dj); + ts2dt (gsec, date, time); + *date = date0; + return; +} + + +/* TS2MST - calculate Greenwich Mean Sidereal Time given Universal Time + * in seconds since 1951-01-01T0:00:00 + */ + +double +ts2mst (tsec) + +double tsec; /* time since 1950.0 in UT seconds */ +{ + double dj; + + dj = ts2jd (tsec); + return (jd2mst (dj)); +} + + +/* JD2MST - Julian Date to Greenwich Mean Sidereal Time using IAU 2000 + * Return sideral time in seconds of time + * (from USNO NOVAS package + * http://aa.usno.navy.mil/software/novas/novas_info.html + */ + +double +jd2mst2 (dj) + +double dj; /* Julian Date */ +{ + double dt, t, t2, t3, mst, st; + + dt = dj - 2451545.0; + t = dt / 36525.0; + t2 = t * t; + t3 = t2 * t; + + /* Compute Greenwich Mean Sidereal Time in seconds */ + st = (8640184.812866 * t) + (3155760000.0 * t) - (0.0000062 * t3) + + (0.093104 * t2) + 67310.54841; + + mst = dmod (st, 86400.0); + if (mst < 0.0) + mst = mst + 86400.0; + return (mst); +} + + +/* MJD2MST - Modified Julian Date to Greenwich Mean Sidereal Time using IAU 2000 + * Return sideral time in seconds of time + * (from USNO NOVAS package + * http://aa.usno.navy.mil/software/novas/novas_info.html + */ + +double +mjd2mst (dj) + +double dj; /* Modified Julian Date */ +{ + double dt, t, t2, t3, mst, st; + + dt = dj - 51544.5; + t = dt / 36525.0; + t2 = t * t; + t3 = t2 * t; + + /* Compute Greenwich Mean Sidereal Time in seconds */ + st = (8640184.812866 * t) + (3155760000.0 * t) - (0.0000062 * t3) + + (0.093104 * t2) + 67310.54841; + + mst = dmod (st, 86400.0); + if (mst < 0.0) + mst = mst + 86400.0; + return (mst); +} + + +/* JD2GST - Julian Date to Greenwich Sideral Time + * Return sideral time in seconds of time + * (Jean Meeus, Astronomical Algorithms, Willmann-Bell, 1991, pp 83-84) + */ + +double +jd2gst (dj) + +double dj; /* Julian Date */ +{ + double dj0, gmt, gst, tsd, eqnx, ssd, l0; + double ts2ss = 1.00273790935; + int ijd; + + /* Julian date at 0:00 UT */ + ijd = (int) dj; + dj0 = (double) ijd + 0.5; + if (dj0 > dj) dj0 = dj0 - 1.0; + + /* Greenwich mean sidereal time at 0:00 UT in seconds */ + l0 = longitude; + longitude = 0.0; + gmt = jd2mst (dj0); + longitude = l0; + + /* Equation of the equinoxes */ + eqnx = eqeqnx (dj); + + /* Apparent sidereal time at 0:00 ut */ + gst = gmt + eqnx; + + /* UT seconds since 0:00 */ + tsd = (dj - dj0) * 86400.0; + ssd = tsd * ts2ss; + + /* Current sidereal time */ + gst = gst + ssd; + gst = dmod (gst, 86400.0); + + return (gst); +} + + +/* EQEQNX - Compute equation of the equinoxes for apparent sidereal time */ + +double +eqeqnx (dj) + +double dj; /* Julian Date */ + +{ + double dt, edj, dpsi, deps, obl, eqnx; + double rad2tsec = 13750.98708; + + /* Convert UT to Ephemeris Time (TDB or TT)*/ + dt = utdt (dj); + edj = dj + dt / 86400.0; + + /* Nutation and obliquity */ + compnut (edj, &dpsi, &deps, &obl); + + /* Correct obliquity for nutation */ + obl = obl + deps; + + /* Equation of the equinoxes in seconds */ + eqnx = (dpsi * cos (obl)) * rad2tsec; + + return (eqnx); +} + + + +/* JD2MST - Julian Date to Mean Sideral Time + * Return sideral time in seconds of time + * (Jean Meeus, Astronomical Algorithms, Willmann-Bell, 1991, pp 83-84) + */ + +double +jd2mst (dj) + +double dj; /* Julian Date */ +{ + double dt, t, mst; + + dt = dj - 2451545.0; + t = dt / 36525.0; + + /* Compute Greenwich mean sidereal time in degrees (Meeus, page 84) */ + mst = 280.46061837 + (360.98564736629 * dt) + (0.000387933 * t * t) - + (t * t * t / 38710000.0); + + /* Keep degrees between 0 and 360 */ + while (mst > 360.0) + mst = mst - 360.0; + while (mst < 0.0) + mst = mst + 360.0; + + /* Convert to time in seconds (3600 / 15) */ + mst = mst * 240.0; + + /* Subtract longitude (degrees to seconds of time) */ + mst = mst - (240.0 * longitude); + if (mst < 0.0) + mst = mst + 86400.0; + else if (mst > 86400.0) + mst = mst - 86400.0; + + return (mst); +} + + +/* COMPNUT - Compute nutation using the IAU 2000b model */ +/* Translated from Pat Wallace's Fortran subroutine iau_nut00b (June 26 2007) + into C by Jessica Mink on September 5, 2008 */ + +#define NLS 77 /* number of terms in the luni-solar nutation model */ + +void +compnut (dj, dpsi, deps, eps0) + +double dj; /* Julian Date */ +double *dpsi; /* Nutation in longitude in radians (returned) */ +double *deps; /* Nutation in obliquity in radians (returned) */ +double *eps0; /* Mean obliquity in radians (returned) */ + +/* This routine is translated from the International Astronomical Union's + * Fortran SOFA (Standards Of Fundamental Astronomy) software collection. + * + * notes: + * + * 1) the nutation components in longitude and obliquity are in radians + * and with respect to the equinox and ecliptic of date. the + * obliquity at j2000 is assumed to be the lieske et al. (1977) value + * of 84381.448 arcsec. (the errors that result from using this + * routine with the iau 2006 value of 84381.406 arcsec can be + * neglected.) + * + * the nutation model consists only of luni-solar terms, but includes + * also a fixed offset which compensates for certain long-period + * planetary terms (note 7). + * + * 2) this routine is an implementation of the iau 2000b abridged + * nutation model formally adopted by the iau general assembly in + * 2000. the routine computes the mhb_2000_short luni-solar nutation + * series (luzum 2001), but without the associated corrections for + * the precession rate adjustments and the offset between the gcrs + * and j2000 mean poles. + * + * 3) the full IAU 2000a (mhb2000) nutation model contains nearly 1400 + * terms. the IAU 2000b model (mccarthy & luzum 2003) contains only + * 77 terms, plus additional simplifications, yet still delivers + * results of 1 mas accuracy at present epochs. this combination of + * accuracy and size makes the IAU 2000b abridged nutation model + * suitable for most practical applications. + * + * the routine delivers a pole accurate to 1 mas from 1900 to 2100 + * (usually better than 1 mas, very occasionally just outside 1 mas). + * the full IAU 2000a model, which is implemented in the routine + * iau_nut00a (q.v.), delivers considerably greater accuracy at + * current epochs; however, to realize this improved accuracy, + * corrections for the essentially unpredictable free-core-nutation + * (fcn) must also be included. + * + * 4) the present routine provides classical nutation. the + * mhb_2000_short algorithm, from which it is adapted, deals also + * with (i) the offsets between the gcrs and mean poles and (ii) the + * adjustments in longitude and obliquity due to the changed + * precession rates. these additional functions, namely frame bias + * and precession adjustments, are supported by the sofa routines + * iau_bi00 and iau_pr00. + * + * 6) the mhb_2000_short algorithm also provides "total" nutations, + * comprising the arithmetic sum of the frame bias, precession + * adjustments, and nutation (luni-solar + planetary). these total + * nutations can be used in combination with an existing IAU 1976 + * precession implementation, such as iau_pmat76, to deliver gcrs-to- + * true predictions of mas accuracy at current epochs. however, for + * symmetry with the iau_nut00a routine (q.v. for the reasons), the + * sofa routines do not generate the "total nutations" directly. + * should they be required, they could of course easily be generated + * by calling iau_bi00, iau_pr00 and the present routine and adding + * the results. + * + * 7) the IAU 2000b model includes "planetary bias" terms that are fixed + * in size but compensate for long-period nutations. the amplitudes + * quoted in mccarthy & luzum (2003), namely dpsi = -1.5835 mas and + * depsilon = +1.6339 mas, are optimized for the "total nutations" + * method described in note 6. the luzum (2001) values used in this + * sofa implementation, namely -0.135 mas and +0.388 mas, are + * optimized for the "rigorous" method, where frame bias, precession + * and nutation are applied separately and in that order. during the + * interval 1995-2050, the sofa implementation delivers a maximum + * error of 1.001 mas (not including fcn). + * + * References from original Fortran subroutines: + * + * Hilton, J. et al., 2006, Celest.Mech.Dyn.Astron. 94, 351 + * + * Lieske, J.H., Lederle, T., Fricke, W., Morando, B., "Expressions + * for the precession quantities based upon the IAU 1976 system of + * astronomical constants", Astron.Astrophys. 58, 1-2, 1-16. (1977) + * + * Luzum, B., private communication, 2001 (Fortran code + * mhb_2000_short) + * + * McCarthy, D.D. & Luzum, B.J., "An abridged model of the + * precession-nutation of the celestial pole", Cel.Mech.Dyn.Astron. + * 85, 37-49 (2003) + * + * Simon, J.-L., Bretagnon, P., Chapront, J., Chapront-Touze, M., + * Francou, G., Laskar, J., Astron.Astrophys. 282, 663-683 (1994) + * + */ + +{ + double as2r = 0.000004848136811095359935899141; /* arcseconds to radians */ + + double dmas2r = as2r / 1000.0; /* milliarcseconds to radians */ + + double as2pi = 1296000.0; /* arc seconds in a full circle */ + + double d2pi = 6.283185307179586476925287; /* 2pi */ + + double u2r = as2r / 10000000.0; /* units of 0.1 microarcsecond to radians */ + + double dj0 = 2451545.0; /* reference epoch (j2000), jd */ + + double djc = 36525.0; /* Days per julian century */ + + /* Miscellaneous */ + double t, el, elp, f, d, om, arg, dp, de, sarg, carg; + double dpsils, depsls, dpsipl, depspl; + int i, j; + + int nls = NLS; /* number of terms in the luni-solar nutation model */ + + /* Fixed offset in lieu of planetary terms (radians) */ + double dpplan = - 0.135 * dmas2r; + double deplan = + 0.388 * dmas2r; + +/* Tables of argument and term coefficients */ + + /* Coefficients for fundamental arguments */ + /* Luni-solar argument multipliers: */ + /* l l' f d om */ +static int nals[5*NLS]= + {0, 0, 0, 0, 1, + 0, 0, 2, -2, 2, + 0, 0, 2, 0, 2, + 0, 0, 0, 0, 2, + 0, 1, 0, 0, 0, + 0, 1, 2, -2, 2, + 1, 0, 0, 0, 0, + 0, 0, 2, 0, 1, + 1, 0, 2, 0, 2, + 0, -1, 2, -2, 2, + 0, 0, 2, -2, 1, + -1, 0, 2, 0, 2, + -1, 0, 0, 2, 0, + 1, 0, 0, 0, 1, + -1, 0, 0, 0, 1, + -1, 0, 2, 2, 2, + 1, 0, 2, 0, 1, + -2, 0, 2, 0, 1, + 0, 0, 0, 2, 0, + 0, 0, 2, 2, 2, + 0, -2, 2, -2, 2, + -2, 0, 0, 2, 0, + 2, 0, 2, 0, 2, + 1, 0, 2, -2, 2, + -1, 0, 2, 0, 1, + 2, 0, 0, 0, 0, + 0, 0, 2, 0, 0, + 0, 1, 0, 0, 1, + -1, 0, 0, 2, 1, + 0, 2, 2, -2, 2, + 0, 0, -2, 2, 0, + 1, 0, 0, -2, 1, + 0, -1, 0, 0, 1, + -1, 0, 2, 2, 1, + 0, 2, 0, 0, 0, + 1, 0, 2, 2, 2, + -2, 0, 2, 0, 0, + 0, 1, 2, 0, 2, + 0, 0, 2, 2, 1, + 0, -1, 2, 0, 2, + 0, 0, 0, 2, 1, + 1, 0, 2, -2, 1, + 2, 0, 2, -2, 2, + -2, 0, 0, 2, 1, + 2, 0, 2, 0, 1, + 0, -1, 2, -2, 1, + 0, 0, 0, -2, 1, + -1, -1, 0, 2, 0, + 2, 0, 0, -2, 1, + 1, 0, 0, 2, 0, + 0, 1, 2, -2, 1, + 1, -1, 0, 0, 0, + -2, 0, 2, 0, 2, + 3, 0, 2, 0, 2, + 0, -1, 0, 2, 0, + 1, -1, 2, 0, 2, + 0, 0, 0, 1, 0, + -1, -1, 2, 2, 2, + -1, 0, 2, 0, 0, + 0, -1, 2, 2, 2, + -2, 0, 0, 0, 1, + 1, 1, 2, 0, 2, + 2, 0, 0, 0, 1, + -1, 1, 0, 1, 0, + 1, 1, 0, 0, 0, + 1, 0, 2, 0, 0, + -1, 0, 2, -2, 1, + 1, 0, 0, 0, 2, + -1, 0, 0, 1, 0, + 0, 0, 2, 1, 2, + -1, 0, 2, 4, 2, + -1, 1, 0, 1, 1, + 0, -2, 2, -2, 1, + 1, 0, 2, 2, 1, + -2, 0, 2, 2, 2, + -1, 0, 0, 0, 2, + 1, 1, 2, -2, 2}; + + /* Luni-solar nutation coefficients, in 1e-7 arcsec */ + /* longitude (sin, t*sin, cos), obliquity (cos, t*cos, sin) */ +static double cls[6*NLS]= + {-172064161.0, -174666.0, 33386.0, 92052331.0, 9086.0, 15377.0, + -13170906.0, -1675.0, -13696.0, 5730336.0, -3015.0, -4587.0, + -2276413.0, -234.0, 2796.0, 978459.0, -485.0, 1374.0, + 2074554.0, 207.0, -698.0, -897492.0, 470.0, -291.0, + 1475877.0, -3633.0, 11817.0, 73871.0, -184.0, -1924.0, + -516821.0, 1226.0, -524.0, 224386.0, -677.0, -174.0, + 711159.0, 73.0, -872.0, -6750.0, 0.0, 358.0, + -387298.0, -367.0, 380.0, 200728.0, 18.0, 318.0, + -301461.0, -36.0, 816.0, 129025.0, -63.0, 367.0, + 215829.0, -494.0, 111.0, -95929.0, 299.0, 132.0, + 128227.0, 137.0, 181.0, -68982.0, -9.0, 39.0, + 123457.0, 11.0, 19.0, -53311.0, 32.0, -4.0, + 156994.0, 10.0, -168.0, -1235.0, 0.0, 82.0, + 63110.0, 63.0, 27.0, -33228.0, 0.0, -9.0, + -57976.0, -63.0, -189.0, 31429.0, 0.0, -75.0, + -59641.0, -11.0, 149.0, 25543.0, -11.0, 66.0, + -51613.0, -42.0, 129.0, 26366.0, 0.0, 78.0, + 45893.0, 50.0, 31.0, -24236.0, -10.0, 20.0, + 63384.0, 11.0, -150.0, -1220.0, 0.0, 29.0, + -38571.0, -1.0, 158.0, 16452.0, -11.0, 68.0, + 32481.0, 0.0, 0.0, -13870.0, 0.0, 0.0, + -47722.0, 0.0, -18.0, 477.0, 0.0, -25.0, + -31046.0, -1.0, 131.0, 13238.0, -11.0, 59.0, + 28593.0, 0.0, -1.0, -12338.0, 10.0, -3.0, + 20441.0, 21.0, 10.0, -10758.0, 0.0, -3.0, + 29243.0, 0.0, -74.0, -609.0, 0.0, 13.0, + 25887.0, 0.0, -66.0, -550.0, 0.0, 11.0, + -14053.0, -25.0, 79.0, 8551.0, -2.0, -45.0, + 15164.0, 10.0, 11.0, -8001.0, 0.0, -1.0, + -15794.0, 72.0, -16.0, 6850.0, -42.0, -5.0, + 21783.0, 0.0, 13.0, -167.0, 0.0, 13.0, + -12873.0, -10.0, -37.0, 6953.0, 0.0, -14.0, + -12654.0, 11.0, 63.0, 6415.0, 0.0, 26.0, + -10204.0, 0.0, 25.0, 5222.0, 0.0, 15.0, + 16707.0, -85.0, -10.0, 168.0, -1.0, 10.0, + -7691.0, 0.0, 44.0, 3268.0, 0.0, 19.0, + -11024.0, 0.0, -14.0, 104.0, 0.0, 2.0, + 7566.0, -21.0, -11.0, -3250.0, 0.0, -5.0, + -6637.0, -11.0, 25.0, 3353.0, 0.0, 14.0, + -7141.0, 21.0, 8.0, 3070.0, 0.0, 4.0, + -6302.0, -11.0, 2.0, 3272.0, 0.0, 4.0, + 5800.0, 10.0, 2.0, -3045.0, 0.0, -1.0, + 6443.0, 0.0, -7.0, -2768.0, 0.0, -4.0, + -5774.0, -11.0, -15.0, 3041.0, 0.0, -5.0, + -5350.0, 0.0, 21.0, 2695.0, 0.0, 12.0, + -4752.0, -11.0, -3.0, 2719.0, 0.0, -3.0, + -4940.0, -11.0, -21.0, 2720.0, 0.0, -9.0, + 7350.0, 0.0, -8.0, -51.0, 0.0, 4.0, + 4065.0, 0.0, 6.0, -2206.0, 0.0, 1.0, + 6579.0, 0.0, -24.0, -199.0, 0.0, 2.0, + 3579.0, 0.0, 5.0, -1900.0, 0.0, 1.0, + 4725.0, 0.0, -6.0, -41.0, 0.0, 3.0, + -3075.0, 0.0, -2.0, 1313.0, 0.0, -1.0, + -2904.0, 0.0, 15.0, 1233.0, 0.0, 7.0, + 4348.0, 0.0, -10.0, -81.0, 0.0, 2.0, + -2878.0, 0.0, 8.0, 1232.0, 0.0, 4.0, + -4230.0, 0.0, 5.0, -20.0, 0.0, -2.0, + -2819.0, 0.0, 7.0, 1207.0, 0.0, 3.0, + -4056.0, 0.0, 5.0, 40.0, 0.0, -2.0, + -2647.0, 0.0, 11.0, 1129.0, 0.0, 5.0, + -2294.0, 0.0, -10.0, 1266.0, 0.0, -4.0, + 2481.0, 0.0, -7.0, -1062.0, 0.0, -3.0, + 2179.0, 0.0, -2.0, -1129.0, 0.0, -2.0, + 3276.0, 0.0, 1.0, -9.0, 0.0, 0.0, + -3389.0, 0.0, 5.0, 35.0, 0.0, -2.0, + 3339.0, 0.0, -13.0, -107.0, 0.0, 1.0, + -1987.0, 0.0, -6.0, 1073.0, 0.0, -2.0, + -1981.0, 0.0, 0.0, 854.0, 0.0, 0.0, + 4026.0, 0.0, -353.0, -553.0, 0.0, -139.0, + 1660.0, 0.0, -5.0, -710.0, 0.0, -2.0, + -1521.0, 0.0, 9.0, 647.0, 0.0, 4.0, + 1314.0, 0.0, 0.0, -700.0, 0.0, 0.0, + -1283.0, 0.0, 0.0, 672.0, 0.0, 0.0, + -1331.0, 0.0, 8.0, 663.0, 0.0, 4.0, + 1383.0, 0.0, -2.0, -594.0, 0.0, -2.0, + 1405.0, 0.0, 4.0, -610.0, 0.0, 2.0, + 1290.0, 0.0, 0.0, -556.0, 0.0, 0.0}; + + /* Interval between fundamental epoch J2000.0 and given date (JC) */ + t = (dj - dj0) / djc; + +/* Luni-solar nutation */ + +/* Fundamental (delaunay) arguments from Simon et al. (1994) */ + + /* Mean anomaly of the moon */ + el = fmod (485868.249036 + (1717915923.2178 * t), as2pi) * as2r; + + /* Mean anomaly of the sun */ + elp = fmod (1287104.79305 + (129596581.0481 * t), as2pi) * as2r; + + /* Mean argument of the latitude of the moon */ + f = fmod (335779.526232 + (1739527262.8478 * t), as2pi) * as2r; + + /* Mean elongation of the moon from the sun */ + d = fmod (1072260.70369 + (1602961601.2090 * t), as2pi ) * as2r; + + /* Mean longitude of the ascending node of the moon */ + om = fmod (450160.398036 - (6962890.5431 * t), as2pi ) * as2r; + + /* Initialize the nutation values */ + dp = 0.0; + de = 0.0; + + /* Summation of luni-solar nutation series (in reverse order) */ + for (i = nls; i > 0; i=i-1) { + j = i - 1; + + /* Argument and functions */ + arg = fmod ( (double) (nals[5*j]) * el + + (double) (nals[1+5*j]) * elp + + (double) (nals[2+5*j]) * f + + (double) (nals[3+5*j]) * d + + (double) (nals[4+5*j]) * om, d2pi); + sarg = sin (arg); + carg = cos (arg); + + /* Terms */ + dp = dp + (cls[6*j] + cls[1+6*j] * t) * sarg + cls[2+6*j] * carg; + de = de + (cls[3+6*j] + cls[4+6*j] * t) * carg + cls[5+6*j] * sarg; + } + + /* Convert from 0.1 microarcsec units to radians */ + dpsils = dp * u2r; + depsls = de * u2r; + +/* In lieu of planetary nutation */ + + /* Fixed offset to correct for missing terms in truncated series */ + dpsipl = dpplan; + depspl = deplan; + +/* Results */ + + /* Add luni-solar and planetary components */ + *dpsi = dpsils + dpsipl; + *deps = depsls + depspl; + + /* Mean Obliquity in radians (IAU 2006, Hilton, et al.) */ + *eps0 = ( 84381.406 + + ( -46.836769 + + ( -0.0001831 + + ( 0.00200340 + + ( -0.000000576 + + ( -0.0000000434 ) * t ) * t ) * t ) * t ) * t ) * as2r; +} + + +/* ISDATE - Return 1 if string is an old or ISO FITS standard date */ + +int +isdate (string) + +char *string; /* Possible FITS date string, which may be: + dd/mm/yy (FITS standard before 2000) + dd-mm-yy (nonstandard FITS use before 2000) + yyyy-mm-dd (FITS standard after 1999) + yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ + +{ + int iyr = 0; /* year (returned) */ + int imon = 0; /* month (returned) */ + int iday = 0; /* day (returned) */ + int i; + char *sstr, *dstr, *tstr, *nval; + + /* Translate string from ASCII to binary */ + if (string == NULL) + return (0); + + sstr = strchr (string,'/'); + dstr = strchr (string,'-'); + if (dstr == string) + dstr = strchr (string+1,'-'); + tstr = strchr (string,'T'); + + /* Original FITS date format: dd/mm/yy */ + if (sstr > string) { + *sstr = '\0'; + iday = (int) atof (string); + *sstr = '/'; + nval = sstr + 1; + sstr = strchr (nval,'/'); + if (sstr == NULL) + sstr = strchr (nval,'-'); + if (sstr > string) { + *sstr = '\0'; + imon = (int) atof (nval); + *sstr = '/'; + nval = sstr + 1; + iyr = (int) atof (nval); + if (iyr < 1000) + iyr = iyr + 1900; + } + if (imon > 0 && iday > 0) + return (1); + else + return (0); + } + + /* New FITS date format: yyyy-mm-ddThh:mm:ss[.sss] */ + else if (dstr > string) { + *dstr = '\0'; + iyr = (int) atof (string); + nval = dstr + 1; + *dstr = '-'; + dstr = strchr (nval,'-'); + imon = 0; + iday = 0; + + /* Decode year, month, and day */ + if (dstr > string) { + *dstr = '\0'; + imon = (int) atof (nval); + *dstr = '-'; + nval = dstr + 1; + if (tstr > string) + *tstr = '\0'; + iday = (int) atof (nval); + if (tstr > string) + *tstr = 'T'; + } + + /* If day is > 31, it is really year in old format */ + if (iday > 31) { + i = iyr; + if (iday < 100) + iyr = iday + 1900; + else + iyr = iday; + iday = i; + } + if (imon > 0 && iday > 0) + return (1); + else + return (0); + } + + /* If FITS date is entered as an epoch, return 0 anyway */ + else + return (0); +} + + +/* Round seconds and make sure date and time numbers are within limits */ + +static void +fixdate (iyr, imon, iday, ihr, imn, sec, ndsec) + +int *iyr; /* year (returned) */ +int *imon; /* month (returned) */ +int *iday; /* day (returned) */ +int *ihr; /* hours (returned) */ +int *imn; /* minutes (returned) */ +double *sec; /* seconds (returned) */ +int ndsec; /* Number of decimal places in seconds (0=int) */ +{ + double days; + + /* Round seconds to 0 - 4 decimal places (no rounding if <0, >4) */ + if (ndsec == 0) + *sec = dint (*sec + 0.5); + else if (ndsec < 2) + *sec = dint (*sec * 10.0 + 0.5) / 10.0; + else if (ndsec < 3) + *sec = dint (*sec * 100.0 + 0.5) / 100.0; + else if (ndsec < 4) + *sec = dint (*sec * 1000.0 + 0.5) / 1000.0; + else if (ndsec < 5) + *sec = dint (*sec * 10000.0 + 0.5) / 10000.0; + + /* Adjust minutes and hours */ + if (*sec > 60.0) { + *sec = *sec - 60.0; + *imn = *imn + 1; + } + if (*imn > 60) { + *imn = *imn - 60; + *ihr = *ihr + 1; + } + + /* Return if no date */ + if (*iyr == 0 && *imon == 0 && *iday == 0) + return; + + /* Adjust date */ + if (*ihr > 23) { + *ihr = *ihr - 24; + *iday = *iday + 1; + } + days = caldays (*iyr, *imon); + if (*iday > days) { + *iday = *iday - days; + *imon = *imon + 1; + } + if (*iday < 1) { + *imon = *imon - 1; + if (*imon < 1) { + *imon = *imon + 12; + *iyr = *iyr - 1; + } + days = caldays (*iyr, *imon); + *iday = *iday + days; + } + if (*imon < 1) { + *imon = *imon + 12; + *iyr = *iyr - 1; + days = caldays (*iyr, *imon); + if (*iday > days) { + *iday = *iday - days; + *imon = *imon + 1; + } + } + if (*imon > 12) { + *imon = *imon - 12; + *iyr = *iyr + 1; + } + return; +} + + +/* Calculate days in month 1-12 given year (Gregorian calendar only) */ + +static int +caldays (year, month) + +int year; /* 4-digit year */ +int month; /* Month (1=January, 2=February, etc.) */ +{ + if (month < 1) { + month = month + 12; + year = year + 1; + } + if (month > 12) { + month = month - 12; + year = year + 1; + } + switch (month) { + case 1: + return (31); + case 2: + if (year%400 == 0) + return (29); + else if (year%100 == 0) + return (28); + else if (year%4 == 0) + return (29); + else + return (28); + case 3: + return (31); + case 4: + return (30); + case 5: + return (31); + case 6: + return (30); + case 7: + return (31); + case 8: + return (31); + case 9: + return (30); + case 10: + return (31); + case 11: + return (30); + case 12: + return (31); + default: + return (0); + } +} + + +static double +dint (dnum) + +double dnum; +{ + double dn; + + if (dnum < 0.0) + dn = -floor (-dnum); + else + dn = floor (dnum); + return (dn); +} + + +static double +dmod (dnum, dm) + +double dnum, dm; +{ + double dnumx, dnumi, dnumf; + if (dnum < 0.0) + dnumx = -dnum; + else + dnumx = dnum; + dnumi = dint (dnumx / dm); + if (dnum < 0.0) + dnumf = dnum + (dnumi * dm); + else if (dnum > 0.0) + dnumf = dnum - (dnumi * dm); + else + dnumf = 0.0; + return (dnumf); +} + +/* Jul 1 1999 New file, based on iolib/jcon.f and iolib/vcon.f and hgetdate() + * Oct 21 1999 Fix declarations after lint + * Oct 27 1999 Fix bug to return epoch if fractional year input + * Dec 9 1999 Fix bug in ts2jd() found by Pete Ratzlaff (SAO) + * Dec 17 1999 Add all unimplemented conversions + * Dec 20 1999 Add isdate(); leave date, time strings unchanged in fd2i() + * Dec 20 1999 Make all fd2*() subroutines deal with time alone + * + * Jan 3 2000 In old FITS format, year 100 is assumed to be 2000 + * Jan 11 2000 Fix epoch to date conversion so .0 is 0:00, not 12:00 + * Jan 21 2000 Add separate Besselian and Julian epoch computations + * Jan 28 2000 Add Modified Julian Date conversions + * Mar 2 2000 Implement decimal places for FITS date string + * Mar 14 2000 Fix bug in dealing with 2000-02-29 in ts2i() + * Mar 22 2000 Add lt2* and ut2* to get current time as local and UT + * Mar 24 2000 Fix calloc() calls + * Mar 24 2000 Add tsi2* and tsu2* to convert IRAF and Unix seconds + * May 1 2000 In old FITS format, all years < 1000 get 1900 added to them + * Aug 1 2000 Make ep2jd and jd2ep consistently starting at 1/1 0:00 + * + * Jan 11 2001 Print all messages to stderr + * May 21 2001 Add day of year conversions + * May 25 2001 Allow fraction of day in FITS date instead of time + * + * Apr 8 2002 Change all long declaration to time_t + * May 13 2002 Fix bugs found by lint + * Jul 5 2002 Fix bug in fixdate() so fractional seconds come out + * Jul 8 2002 Fix rounding bug in t2i() + * Jul 8 2002 Try Fliegel and Van Flandern's algorithm for JD to UT date + * Jul 8 2002 If first character of string is -, check for other -'s in isdate + * Sep 10 2002 Add ET/TDT/TT conversion from UT subroutines + * Sep 10 2002 Add sidereal time conversions + * + * Jan 30 2003 Fix typo in ts2gst() + * Mar 7 2003 Add conversions for heliocentric julian dates + * May 20 2003 Declare nd in setdatedec() + * Jul 18 2003 Add code to parse Las Campanas dates + * + * Mar 24 2004 If ndec > 0, add UT to FITS date even if it is 0:00:00 + * + * Oct 14 2005 Add tsd2fd() and tsd2dt() + * + * May 3 2006 Drop declaration of unused variables + * Jun 20 2006 Initialized uninitialized variables + * Aug 2 2006 Add local sidereal time + * Sep 13 2006 Add more local sidereal time subroutines + * Oct 2 2006 Add UT to old FITS date conversions + * Oct 6 2006 Add eqeqnx() to compute equation of the equinoxes + * + * Jan 8 2007 Remove unused variables + * + * Sep 5 2008 Replace nutation with IAU 2006 model translated from SOFA + * Sep 9 2008 Add ang2hr(), ang2deg(), hr2ang(), deg2ang() + * Sep 10 2008 Add longitude to mean standard time (default = Greenwich) + * Oct 8 2008 Clean up sidereal time computations + * + * Sep 24 2009 Add end to comment "Coefficients for fundamental arguments" + * + * Jan 11 2012 Add TAI, TT, GPS time + * Oct 19 2012 Unused l0 dropped from jd2lst(); ts2ss from jd2mst() + */ diff --git a/tksao/wcssubs/distort.c b/tksao/wcssubs/distort.c new file mode 100644 index 0000000..d903dfe --- /dev/null +++ b/tksao/wcssubs/distort.c @@ -0,0 +1,407 @@ +/*** File libwcs/distort.c + *** January 4, 2007 + *** By Jessica Mink, jmink@cfa.harvard.edu, + *** Based on code written by Jing Li, IPAC + *** Harvard-Smithsonian Center for Astrophysics + *** Copyright (C) 2004-2007 + *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Correspondence concerning WCSTools should be addressed as follows: + Internet email: jmink@cfa.harvard.edu + Postal address: Jessica Mink + Smithsonian Astrophysical Observatory + 60 Garden St. + Cambridge, MA 02138 USA + + * Module: distort.c (World Coordinate Systems) + * Purpose: Convert focal plane coordinates to pixels and vice versa: + * Subroutine: distortinit (wcs, hstring) set distortion coefficients from FITS header + * Subroutine: DelDistort (header, verbose) delete distortion coefficients in FITS header + * Subroutine: pix2foc (wcs, x, y, u, v) pixel coordinates -> focal plane coordinates + * Subroutine: foc2pix (wcs, u, v, x, y) focal plane coordinates -> pixel coordinates + * Subroutine: setdistcode (wcs,ctype) sets distortion code from CTYPEi + * Subroutine: getdistcode (wcs) returns distortion code string for CTYPEi + */ + +#include +#include +#include +#include +#include "wcs.h" + +void +distortinit (wcs, hstring) +struct WorldCoor *wcs; /* World coordinate system structure */ +const char *hstring; /* character string containing FITS header information + in the format = [/ ] */ +{ + int i, j, m; + char keyword[12]; + + /* Read distortion coefficients, if present */ + if (wcs->distcode == DISTORT_SIRTF) { + if (wcs->wcsproj == WCS_OLD) { + wcs->wcsproj = WCS_NEW; + wcs->distort.a_order = 0; + wcs->distort.b_order = 0; + wcs->distort.ap_order = 0; + wcs->distort.bp_order = 0; + } + else { + if (!hgeti4 (hstring, "A_ORDER", &wcs->distort.a_order)) { + setwcserr ("DISTINIT: Missing A_ORDER keyword for Spitzer distortion"); + } + else { + m = wcs->distort.a_order; + for (i = 0; i <= m; i++) { + for (j = 0; j <= m; j++) { + wcs->distort.a[i][j] = 0.0; + } + } + for (i = 0; i <= m; i++) { + for (j = 0; j <= m-i; j++) { + sprintf (keyword, "A_%d_%d", i, j); + hgetr8 (hstring, keyword, &wcs->distort.a[i][j]); + } + } + } + if (!hgeti4 (hstring, "B_ORDER", &wcs->distort.b_order)) { + setwcserr ("DISTINIT: Missing B_ORDER keyword for Spitzer distortion"); + } + else { + m = wcs->distort.b_order; + for (i = 0; i <= m; i++) { + for (j = 0; j <= m; j++) { + wcs->distort.b[i][j] = 0.0; + } + } + for (i = 0; i <= m; i++) { + for (j = 0; j <= m-i; j++) { + sprintf (keyword, "B_%d_%d", i, j); + hgetr8 (hstring, keyword, &wcs->distort.b[i][j]); + } + } + } + if (!hgeti4 (hstring, "AP_ORDER", &wcs->distort.ap_order)) { + setwcserr ("DISTINIT: Missing AP_ORDER keyword for Spitzer distortion"); + } + else { + m = wcs->distort.ap_order; + for (i = 0; i <= m; i++) { + for (j = 0; j <= m; j++) { + wcs->distort.ap[i][j] = 0.0; + } + } + for (i = 0; i <= m; i++) { + for (j = 0; j <= m-i; j++) { + sprintf (keyword, "AP_%d_%d", i, j); + hgetr8 (hstring, keyword, &wcs->distort.ap[i][j]); + } + } + } + if (!hgeti4 (hstring, "BP_ORDER", &wcs->distort.bp_order)) { + setwcserr ("DISTINIT: Missing BP_ORDER keyword for Spitzer distortion"); + } + else { + m = wcs->distort.bp_order; + for (i = 0; i <= m; i++) { + for (j = 0; j <= m; j++) { + wcs->distort.bp[i][j] = 0.0; + } + } + for (i = 0; i <= m; i++) { + for (j = 0; j <= m-i; j++) { + sprintf (keyword, "BP_%d_%d", i, j); + hgetr8 (hstring, keyword, &wcs->distort.bp[i][j]); + } + } + } + } + } + return; +} + + +/* Delete all distortion-related fields. + * return 0 if at least one such field is found, else -1. */ + +int +DelDistort (header, verbose) + +char *header; +int verbose; + +{ + char keyword[16]; + char str[32]; + int i, j, m; + int lctype; + int n; + + n = 0; + + if (hgeti4 (header, "A_ORDER", &m)) { + for (i = 0; i <= m; i++) { + for (j = 0; j <= m-i; j++) { + sprintf (keyword, "A_%d_%d", i, j); + hdel (header, keyword); + n++; + } + } + hdel (header, "A_ORDER"); + n++; + } + + if (hgeti4 (header, "AP_ORDER", &m)) { + for (i = 0; i <= m; i++) { + for (j = 0; j <= m-i; j++) { + sprintf (keyword, "AP_%d_%d", i, j); + hdel (header, keyword); + n++; + } + } + hdel (header, "AP_ORDER"); + n++; + } + + if (hgeti4 (header, "B_ORDER", &m)) { + for (i = 0; i <= m; i++) { + for (j = 0; j <= m-i; j++) { + sprintf (keyword, "B_%d_%d", i, j); + hdel (header, keyword); + n++; + } + } + hdel (header, "B_ORDER"); + n++; + } + + if (hgeti4 (header, "BP_ORDER", &m)) { + for (i = 0; i <= m; i++) { + for (j = 0; j <= m-i; j++) { + sprintf (keyword, "BP_%d_%d", i, j); + hdel (header, keyword); + n++; + } + } + hdel (header, "BP_ORDER"); + n++; + } + + if (n > 0 && verbose) + fprintf (stderr,"%d keywords deleted\n", n); + + /* Remove WCS distortion code from CTYPEi in FITS header */ + if (hgets (header, "CTYPE1", 31, str)) { + lctype = strlen (str); + if (lctype > 8) { + str[8] = (char) 0; + hputs (header, "CTYPE1", str); + } + } + if (hgets (header, "CTYPE2", 31, str)) { + lctype = strlen (str); + if (lctype > 8) { + str[8] = (char) 0; + hputs (header, "CTYPE2", str); + } + } + + return (n); +} + +void +foc2pix (wcs, x, y, u, v) + +struct WorldCoor *wcs; /* World coordinate system structure */ +double x, y; /* Focal plane coordinates */ +double *u, *v; /* Image pixel coordinates (returned) */ +{ + int m, n, i, j, k; + double s[DISTMAX], sum; + double temp_x, temp_y; + + /* Spitzer distortion */ + if (wcs->distcode == DISTORT_SIRTF) { + m = wcs->distort.ap_order; + n = wcs->distort.bp_order; + + temp_x = x - wcs->xrefpix; + temp_y = y - wcs->yrefpix; + + /* compute u */ + for (j = 0; j <= m; j++) { + s[j] = wcs->distort.ap[m-j][j]; + for (k = j-1; k >= 0; k--) { + s[j] = (temp_y * s[j]) + wcs->distort.ap[m-j][k]; + } + } + + sum = s[0]; + for (i=m; i>=1; i--){ + sum = (temp_x * sum) + s[m-i+1]; + } + *u = sum; + + /* compute v*/ + for (j = 0; j <= n; j++) { + s[j] = wcs->distort.bp[n-j][j]; + for (k = j-1; k >= 0; k--) { + s[j] = temp_y*s[j] + wcs->distort.bp[n-j][k]; + } + } + + sum = s[0]; + for (i = n; i >= 1; i--) + sum = temp_x * sum + s[n-i+1]; + + *v = sum; + + *u = x + *u; + *v = y + *v; + } + + /* If no distortion, return pixel positions unchanged */ + else { + *u = x; + *v = y; + } + + return; +} + + +void +pix2foc (wcs, u, v, x, y) + +struct WorldCoor *wcs; /* World coordinate system structure */ +double u, v; /* Image pixel coordinates */ +double *x, *y; /* Focal plane coordinates (returned) */ +{ + int m, n, i, j, k; + double s[DISTMAX], sum; + double temp_u, temp_v; + + /* Spitzer distortion */ + if (wcs->distcode == DISTORT_SIRTF) { + m = wcs->distort.a_order; + n = wcs->distort.b_order; + + temp_u = u - wcs->xrefpix; + temp_v = v - wcs->yrefpix; + + /* compute u */ + for (j = 0; j <= m; j++) { + s[j] = wcs->distort.a[m-j][j]; + for (k = j-1; k >= 0; k--) { + s[j] = (temp_v * s[j]) + wcs->distort.a[m-j][k]; + } + } + + sum = s[0]; + for (i=m; i>=1; i--){ + sum = temp_u*sum + s[m-i+1]; + } + *x = sum; + + /* compute v*/ + for (j=0; j<=n; j++) { + s[j] = wcs->distort.b[n-j][j]; + for (k=j-1; k>=0; k--) { + s[j] =temp_v*s[j] + wcs->distort.b[n-j][k]; + } + } + + sum = s[0]; + for (i=n; i>=1; i--) + sum = temp_u*sum + s[n-i+1]; + + *y = sum; + + *x = u + *x; + *y = v + *y; + +/* *x = u + *x + coeff.crpix1; */ +/* *y = v + *y + coeff.crpix2; */ + } + + /* If no distortion, return pixel positions unchanged */ + else { + *x = u; + *y = v; + } + + return; +} + + +/* SETDISTCODE -- Set WCS distortion code from CTYPEi in FITS header */ + +void +setdistcode (wcs, ctype) + +struct WorldCoor *wcs; /* World coordinate system structure */ +char *ctype; /* Value of CTYPEi from FITS header */ + +{ + char *extension; + int lctype; + + lctype = strlen (ctype); + if (lctype < 9) + wcs->distcode = DISTORT_NONE; + else { + extension = ctype + 8; + if (!strncmp (extension, "-SIP", 4)) + wcs->distcode = DISTORT_SIRTF; + else + wcs->distcode = DISTORT_NONE; + } + return; +} + + +/* GETDISTCODE -- Return NULL if no distortion or code from wcs.h */ + +char * +getdistcode (wcs) + +struct WorldCoor *wcs; /* World coordinate system structure */ + +{ + char *dcode; /* Distortion string for CTYPEi */ + + if (wcs->distcode == DISTORT_SIRTF) { + dcode = (char *) calloc (8, sizeof (char)); + strcpy (dcode, "-SIP"); + } + else + dcode = NULL; + return (dcode); +} + +/* Apr 2 2003 New subroutines + * Nov 3 2003 Add getdistcode to return distortion code string + * Nov 10 2003 Include unistd.h to get definition of NULL + * Nov 18 2003 Include string.h to get strlen() + * + * Jan 9 2004 Add DelDistort() to delete distortion keywords + * + * Jan 4 2007 Declare header const char* + * + * Feb 25 2011 Change SIRTF to Spitzer (long overdue!) + */ diff --git a/tksao/wcssubs/dsspos.c b/tksao/wcssubs/dsspos.c new file mode 100644 index 0000000..3bbd5a0 --- /dev/null +++ b/tksao/wcssubs/dsspos.c @@ -0,0 +1,318 @@ +/*** File saoimage/wcslib/dsspos.c + *** October 21, 1999 + *** By Jessica Mink, jmink@cfa.harvard.edu + *** Harvard-Smithsonian Center for Astrophysics + *** Copyright (C) 1995-2002 + *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Correspondence concerning WCSTools should be addressed as follows: + Internet email: jmink@cfa.harvard.edu + Postal address: Jessica Mink + Smithsonian Astrophysical Observatory + 60 Garden St. + Cambridge, MA 02138 USA + + * Module: dsspos.c (Plate solution WCS conversion) + * Purpose: Compute WCS from Digital Sky Survey plate fit + * Subroutine: dsspos() converts from pixel location to RA,Dec + * Subroutine: dsspix() converts from RA,Dec to pixel location + + These functions are based on the astrmcal.c portion of GETIMAGE by + J. Doggett and the documentation distributed with the Digital Sky Survey. + +*/ + +#include +#include +#include +#include "wcs.h" + +int +dsspos (xpix, ypix, wcs, xpos, ypos) + +/* Routine to determine accurate position for pixel coordinates */ +/* returns 0 if successful otherwise 1 = angle too large for projection; */ +/* based on amdpos() from getimage */ + +/* Input: */ +double xpix; /* x pixel number (RA or long without rotation) */ +double ypix; /* y pixel number (dec or lat without rotation) */ +struct WorldCoor *wcs; /* WCS parameter structure */ + +/* Output: */ +double *xpos; /* Right ascension or longitude in degrees */ +double *ypos; /* Declination or latitude in degrees */ + +{ + double x, y, xmm, ymm, xmm2, ymm2, xmm3, ymm3, x2y2; + double xi, xir, eta, etar, raoff, ra, dec; + double cond2r = 1.745329252e-2; + double cons2r = 206264.8062470964; + double twopi = 6.28318530717959; + double ctan, ccos; + +/* Ignore magnitude and color terms + double mag = 0.0; + double color = 0.0; */ + +/* Convert from image pixels to plate pixels */ + x = xpix + wcs->x_pixel_offset - 1.0 + 0.5; + y = ypix + wcs->y_pixel_offset - 1.0 + 0.5; + +/* Convert from pixels to millimeters */ + xmm = (wcs->ppo_coeff[2] - x * wcs->x_pixel_size) / 1000.0; + ymm = (y * wcs->y_pixel_size - wcs->ppo_coeff[5]) / 1000.0; + xmm2 = xmm * xmm; + ymm2 = ymm * ymm; + xmm3 = xmm * xmm2; + ymm3 = ymm * ymm2; + x2y2 = xmm2 + ymm2; + +/* Compute coordinates from x,y and plate model */ + + xi = wcs->x_coeff[ 0]*xmm + wcs->x_coeff[ 1]*ymm + + wcs->x_coeff[ 2] + wcs->x_coeff[ 3]*xmm2 + + wcs->x_coeff[ 4]*xmm*ymm + wcs->x_coeff[ 5]*ymm2 + + wcs->x_coeff[ 6]*(x2y2) + wcs->x_coeff[ 7]*xmm3 + + wcs->x_coeff[ 8]*xmm2*ymm + wcs->x_coeff[ 9]*xmm*ymm2 + + wcs->x_coeff[10]*ymm3 + wcs->x_coeff[11]*xmm*(x2y2) + + wcs->x_coeff[12]*xmm*x2y2*x2y2; + +/* Ignore magnitude and color terms + + wcs->x_coeff[13]*mag + wcs->x_coeff[14]*mag*mag + + wcs->x_coeff[15]*mag*mag*mag + wcs->x_coeff[16]*mag*xmm + + wcs->x_coeff[17]*mag*x2y2 + wcs->x_coeff[18]*mag*xmm*x2y2 + + wcs->x_coeff[19]*color; */ + + eta = wcs->y_coeff[ 0]*ymm + wcs->y_coeff[ 1]*xmm + + wcs->y_coeff[ 2] + wcs->y_coeff[ 3]*ymm2 + + wcs->y_coeff[ 4]*xmm*ymm + wcs->y_coeff[ 5]*xmm2 + + wcs->y_coeff[ 6]*(x2y2) + wcs->y_coeff[ 7]*ymm3 + + wcs->y_coeff[ 8]*ymm2*xmm + wcs->y_coeff[ 9]*ymm*xmm2 + + wcs->y_coeff[10]*xmm3 + wcs->y_coeff[11]*ymm*(x2y2) + + wcs->y_coeff[12]*ymm*x2y2*x2y2; + +/* Ignore magnitude and color terms + + wcs->y_coeff[13]*mag + wcs->y_coeff[14]*mag*mag + + wcs->y_coeff[15]*mag*mag*mag + wcs->y_coeff[16]*mag*ymm + + wcs->y_coeff[17]*mag*x2y2) + wcs->y_coeff[18]*mag*ymm*x2y2 + + wcs->y_coeff[19]*color; */ + +/* Convert to radians */ + + xir = xi / cons2r; + etar = eta / cons2r; + +/* Convert to RA and Dec */ + + ctan = tan (wcs->plate_dec); + ccos = cos (wcs->plate_dec); + raoff = atan2 (xir / ccos, 1.0 - etar * ctan); + ra = raoff + wcs->plate_ra; + if (ra < 0.0) ra = ra + twopi; + *xpos = ra / cond2r; + + dec = atan (cos (raoff) * ((etar + ctan) / (1.0 - (etar * ctan)))); + *ypos = dec / cond2r; + return 0; +} + + +int +dsspix (xpos, ypos, wcs, xpix, ypix) + +/* Routine to determine pixel coordinates for sky position */ +/* returns 0 if successful otherwise 1 = angle too large for projection; */ +/* based on amdinv() from getimage */ + +/* Input: */ +double xpos; /* Right ascension or longitude in degrees */ +double ypos; /* Declination or latitude in degrees */ +struct WorldCoor *wcs; /* WCS parameter structure */ + +/* Output: */ +double *xpix; /* x pixel number (RA or long without rotation) */ +double *ypix; /* y pixel number (dec or lat without rotation) */ + +{ + double div,xi,eta,x,y,xy,x2,y2,x2y,y2x,x3,y3,x4,y4,x2y2,cjunk,dx,dy; + double sypos,cypos,syplate,cyplate,sxdiff,cxdiff; + double f,fx,fy,g,gx,gy, xmm, ymm; + double conr2s = 206264.8062470964; + double tolerance = 0.0000005; + int max_iterations = 50; + int i; + double xr, yr; /* position in radians */ + + *xpix = 0.0; + *ypix = 0.0; + +/* Convert RA and Dec in radians to standard coordinates on a plate */ + xr = degrad (xpos); + yr = degrad (ypos); + sypos = sin (yr); + cypos = cos (yr); + if (wcs->plate_dec == 0.0) + wcs->plate_dec = degrad (wcs->yref); + syplate = sin (wcs->plate_dec); + cyplate = cos (wcs->plate_dec); + if (wcs->plate_ra == 0.0) + wcs->plate_ra = degrad (wcs->yref); + sxdiff = sin (xr - wcs->plate_ra); + cxdiff = cos (xr - wcs->plate_ra); + div = (sypos * syplate) + (cypos * cyplate * cxdiff); + if (div == 0.0) + return (1); + xi = cypos * sxdiff * conr2s / div; + eta = ((sypos * cyplate) - (cypos * syplate * cxdiff)) * conr2s / div; + +/* Set initial value for x,y */ + if (wcs->plate_scale == 0.0) + return (1); + xmm = xi / wcs->plate_scale; + ymm = eta / wcs->plate_scale; + +/* Iterate by Newton's method */ + for (i = 0; i < max_iterations; i++) { + + /* X plate model */ + xy = xmm * ymm; + x2 = xmm * xmm; + y2 = ymm * ymm; + x2y = x2 * ymm; + y2x = y2 * xmm; + x2y2 = x2 + y2; + cjunk = x2y2 * x2y2; + x3 = x2 * xmm; + y3 = y2 * ymm; + x4 = x2 * x2; + y4 = y2 * y2; + f = wcs->x_coeff[0]*xmm + wcs->x_coeff[1]*ymm + + wcs->x_coeff[2] + wcs->x_coeff[3]*x2 + + wcs->x_coeff[4]*xy + wcs->x_coeff[5]*y2 + + wcs->x_coeff[6]*x2y2 + wcs->x_coeff[7]*x3 + + wcs->x_coeff[8]*x2y + wcs->x_coeff[9]*y2x + + wcs->x_coeff[10]*y3 + wcs->x_coeff[11]*xmm*x2y2 + + wcs->x_coeff[12]*xmm*cjunk; + /* magnitude and color terms ignored + + wcs->x_coeff[13]*mag + + wcs->x_coeff[14]*mag*mag + wcs->x_coeff[15]*mag*mag*mag + + wcs->x_coeff[16]*mag*xmm + wcs->x_coeff[17]*mag*(x2+y2) + + wcs->x_coeff[18]*mag*xmm*(x2+y2) + wcs->x_coeff[19]*color; + */ + + /* Derivative of X model wrt x */ + fx = wcs->x_coeff[0] + wcs->x_coeff[3]*2.0*xmm + + wcs->x_coeff[4]*ymm + wcs->x_coeff[6]*2.0*xmm + + wcs->x_coeff[7]*3.0*x2 + wcs->x_coeff[8]*2.0*xy + + wcs->x_coeff[9]*y2 + wcs->x_coeff[11]*(3.0*x2+y2) + + wcs->x_coeff[12]*(5.0*x4 +6.0*x2*y2+y4); + /* magnitude and color terms ignored + wcs->x_coeff[16]*mag + wcs->x_coeff[17]*mag*2.0*xmm + + wcs->x_coeff[18]*mag*(3.0*x2+y2); + */ + + /* Derivative of X model wrt y */ + fy = wcs->x_coeff[1] + wcs->x_coeff[4]*xmm + + wcs->x_coeff[5]*2.0*ymm + wcs->x_coeff[6]*2.0*ymm + + wcs->x_coeff[8]*x2 + wcs->x_coeff[9]*2.0*xy + + wcs->x_coeff[10]*3.0*y2 + wcs->x_coeff[11]*2.0*xy + + wcs->x_coeff[12]*4.0*xy*x2y2; + /* magnitude and color terms ignored + wcs->x_coeff[17]*mag*2.0*ymm + + wcs->x_coeff[18]*mag*2.0*xy; + */ + + /* Y plate model */ + g = wcs->y_coeff[0]*ymm + wcs->y_coeff[1]*xmm + + wcs->y_coeff[2] + wcs->y_coeff[3]*y2 + + wcs->y_coeff[4]*xy + wcs->y_coeff[5]*x2 + + wcs->y_coeff[6]*x2y2 + wcs->y_coeff[7]*y3 + + wcs->y_coeff[8]*y2x + wcs->y_coeff[9]*x2y + + wcs->y_coeff[10]*x3 + wcs->y_coeff[11]*ymm*x2y2 + + wcs->y_coeff[12]*ymm*cjunk; + /* magnitude and color terms ignored + wcs->y_coeff[13]*mag + wcs->y_coeff[14]*mag*mag + + wcs->y_coeff[15]*mag*mag*mag + wcs->y_coeff[16]*mag*ymm + + wcs->y_coeff[17]*mag*x2y2 + + wcs->y_coeff[18]*mag*ymm*x2y2 + wcs->y_coeff[19]*color; + */ + + /* Derivative of Y model wrt x */ + gx = wcs->y_coeff[1] + wcs->y_coeff[4]*ymm + + wcs->y_coeff[5]*2.0*xmm + wcs->y_coeff[6]*2.0*xmm + + wcs->y_coeff[8]*y2 + wcs->y_coeff[9]*2.0*xy + + wcs->y_coeff[10]*3.0*x2 + wcs->y_coeff[11]*2.0*xy + + wcs->y_coeff[12]*4.0*xy*x2y2; + /* magnitude and color terms ignored + wcs->y_coeff[17]*mag*2.0*xmm + + wcs->y_coeff[18]*mag*ymm*2.0*xmm; + */ + + /* Derivative of Y model wrt y */ + gy = wcs->y_coeff[0] + wcs->y_coeff[3]*2.0*ymm + + wcs->y_coeff[4]*xmm + wcs->y_coeff[6]*2.0*ymm + + wcs->y_coeff[7]*3.0*y2 + wcs->y_coeff[8]*2.0*xy + + wcs->y_coeff[9]*x2 + wcs->y_coeff[11]*(x2+3.0*y2) + + wcs->y_coeff[12]*(5.0*y4 + 6.0*x2*y2 + x4); + /* magnitude and color terms ignored + wcs->y_coeff[16]*mag + wcs->y_coeff[17]*mag*2.0*ymm + + wcs->y_coeff[18]*mag*(x2+3.0*y2); + */ + + f = f - xi; + g = g - eta; + dx = ((-f * gy) + (g * fy)) / ((fx * gy) - (fy * gx)); + dy = ((-g * fx) + (f * gx)) / ((fx * gy) - (fy * gx)); + xmm = xmm + dx; + ymm = ymm + dy; + if ((fabs(dx) < tolerance) && (fabs(dy) < tolerance)) break; + } + +/* Convert mm from plate center to plate pixels */ + if (wcs->x_pixel_size == 0.0 || wcs->y_pixel_size == 0.0) + return (1); + x = (wcs->ppo_coeff[2] - xmm*1000.0) / wcs->x_pixel_size; + y = (wcs->ppo_coeff[5] + ymm*1000.0) / wcs->y_pixel_size; + +/* Convert from plate pixels to image pixels */ + *xpix = x - wcs->x_pixel_offset + 1.0 - 0.5; + *ypix = y - wcs->y_pixel_offset + 1.0 - 0.5; + +/* If position is off of the image, return offscale code */ + if (*xpix < 0.5 || *xpix > wcs->nxpix+0.5) + return -1; + if (*ypix < 0.5 || *ypix > wcs->nypix+0.5) + return -1; + + return 0; +} +/* Mar 6 1995 Original version of this code + * May 4 1995 Fix eta cross terms which were all in y + * Jun 21 1995 Add inverse routine + * Oct 17 1995 Fix inverse routine (degrees -> radians) + * Nov 7 1995 Add half pixel to image coordinates to get astrometric + * plate coordinates + * Feb 26 1996 Fix plate to image pixel conversion error + * + * Mar 23 1998 Change names from plate*() to dss*() + * Apr 7 1998 Change amd_i_coeff to i_coeff + * Sep 4 1998 Fix possible divide by zero in dsspos() from Allen Harris, SAO + * Sep 10 1998 Fix possible divide by zero in dsspix() from Allen Harris, SAO + * + * Oct 21 1999 Drop declaration of cond2r in dsspix() + */ diff --git a/tksao/wcssubs/fileutil.c b/tksao/wcssubs/fileutil.c new file mode 100644 index 0000000..cf52903 --- /dev/null +++ b/tksao/wcssubs/fileutil.c @@ -0,0 +1,867 @@ +/*** File libwcs/fileutil.c + *** August 28, 2014 + *** By Jessica Mink, jmink@cfa.harvard.edu + *** Harvard-Smithsonian Center for Astrophysics + *** Copyright (C) 1999-2014 + *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Correspondence concerning WCSTools should be addressed as follows: + Internet email: jmink@cfa.harvard.edu + Postal address: Jessica Mink + Smithsonian Astrophysical Observatory + 60 Garden St. + Cambridge, MA 02138 USA + + * Module: fileutil.c (ASCII file utilities) + * Purpose: Find out things about ASCII files + * Subroutine: getfilelines (filename) + * Return number of lines in an ASCII file + * Subroutine: getfilebuff (filename) + * Return entire file contents in a character string + * Subroutine: getfilesize (filename) + * Return size of a binary or ASCII file + * Subroutine: isimlist (filename) + * Return 1 if file is list of FITS or IRAF image files, else 0 + * Subroutine: isimlistd (filename, rootdir) + * Return 1 if file is list of FITS or IRAF image files, else 0 + * Subroutine: isfilelist (filename, rootdir) + * Return 1 if file is list of readable files, else 0 + * Subroutine: isfile (filename) + * Return 1 if file is a readable file, else 0 + * Subroutine: first_token (diskfile, ncmax, token) + * Return the first token from the next line of an ASCII file + * Subroutine: next_line (diskfile, ncmax, line) + * Read the next line of an ASCII file and return its length + * Subroutine: stc2s (spchar, string) + * Replace character in string with space + * Subroutine: sts2c (spchar, string) + * Replace spaces in string with character + * Subroutine: istiff (filename) + * Return 1 if file is a readable TIFF graphics file, else 0 + * Subroutine: isjpeg (filename) + * Return 1 if file is a readable JPEG graphics file, else 0 + * int setoken (tokens, string, cwhite) + * Tokenize a string for easy decoding + * int nextoken (tokens, token, maxchars) + * Get next token from tokenized string + * int getoken (tokens, itok, token, maxchars) + * Get specified token from tokenized string + */ + +#include +#ifndef VMS +#include +#endif +#include +#include +#include +#include +#include +#include "fitsfile.h" +#include +#include + + +/* GETFILELINES -- return number of lines in one file */ + +int +getfilelines (filename) + +char *filename; /* Name of file for which to find number of lines */ +{ + + char *buffer, *bufline; + int nlines = 0; + char newline = 10; + + /* Read file */ + buffer = getfilebuff (filename); + + /* Count lines in file */ + if (buffer != NULL) { + bufline = buffer; + nlines = 0; + while ((bufline = strchr (bufline, newline)) != NULL) { + bufline = bufline + 1; + nlines++; + } + free (buffer); + return (nlines); + } + else { + return (0); + } +} + + +/* GETFILEBUFF -- return entire file contents in one character string */ + +char * +getfilebuff (filename) + +char *filename; /* Name of file for which to find number of lines */ +{ + + FILE *diskfile; + int lfile, nr, lbuff, ipt, ibuff; + char *buffer, *newbuff, *nextbuff; + + /* Treat stdin differently */ + if (!strcmp (filename, "stdin")) { + lbuff = 5000; + lfile = lbuff; + buffer = NULL; + ipt = 0; + for (ibuff = 0; ibuff < 10; ibuff++) { + if ((newbuff = realloc (buffer, lfile+1)) != NULL) { + buffer = newbuff; + nextbuff = buffer + ipt; + nr = fread (nextbuff, 1, lbuff, stdin); + if (nr == lbuff) + break; + else { + ipt = ipt + lbuff; + lfile = lfile + lbuff; + } + } + else { + fprintf (stderr,"GETFILEBUFF: No room for %d-byte buffer\n", + lfile); + break; + } + } + return (buffer); + } + + /* Open file */ + if ((diskfile = fopen (filename, "rb")) == NULL) + return (NULL); + + /* Find length of file */ + if (fseek (diskfile, 0, 2) == 0) + lfile = ftell (diskfile); + else + lfile = 0; + if (lfile < 1) { + fprintf (stderr,"GETFILEBUFF: File %s is empty\n", filename); + fclose (diskfile); + return (NULL); + } + + /* Allocate buffer to hold entire file and read it */ + if ((buffer = calloc (1, lfile+1)) != NULL) { + fseek (diskfile, 0, 0); + nr = fread (buffer, 1, lfile, diskfile); + if (nr < lfile) { + fprintf (stderr,"GETFILEBUFF: File %s: read %d / %d bytes\n", + filename, nr, lfile); + free (buffer); + fclose (diskfile); + return (NULL); + } + buffer[lfile] = (char) 0; + fclose (diskfile); + return (buffer); + } + else { + fprintf (stderr,"GETFILEBUFF: File %s: no room for %d-byte buffer\n", + filename, lfile); + fclose (diskfile); + return (NULL); + } +} + + +/* GETFILESIZE -- return size of one file in bytes */ + +int +getfilesize (filename) + +char *filename; /* Name of file for which to find size */ +{ + struct stat statbuff; + + if (stat (filename, &statbuff)) + return (0); + else + return ((int) statbuff.st_size); +} + +int +getfilesize0 (filename) + +char *filename; /* Name of file for which to find size */ +{ + FILE *diskfile; + long filesize; + + /* Open file */ + if ((diskfile = fopen (filename, "rb")) == NULL) + return (-1); + + /* Move to end of the file */ + if (fseek (diskfile, 0, 2) == 0) + + /* Position is the size of the file */ + filesize = ftell (diskfile); + + else + filesize = -1; + + fclose (diskfile); + + return ((int) filesize); +} + + +/* ISIMLIST -- Return 1 if list of FITS or IRAF files, else 0 */ +int +isimlist (filename) + +char *filename; /* Name of possible list file */ +{ + FILE *diskfile; + char token[256]; + int ncmax = 254; + + if ((diskfile = fopen (filename, "r")) == NULL) + return (0); + else { + first_token (diskfile, ncmax, token); + fclose (diskfile); + if (isfits (token) | isiraf (token)) + return (1); + else + return (0); + } +} + + +/* ISIMLISTD -- Return 1 if list of FITS or IRAF files, else 0 */ +int +isimlistd (filename, rootdir) + +char *filename; /* Name of possible list file */ +char *rootdir; /* Name of root directory for files in list */ +{ + FILE *diskfile; + char token[256]; + char filepath[256]; + int ncmax = 254; + + if ((diskfile = fopen (filename, "r")) == NULL) + return (0); + else { + first_token (diskfile, ncmax, token); + fclose (diskfile); + if (rootdir != NULL) { + strcpy (filepath, rootdir); + strcat (filepath, "/"); + strcat (filepath, token); + } + else + strcpy (filepath, token); + if (isfits (filepath) | isiraf (filepath)) + return (1); + else + return (0); + } +} + + +/* ISFILELIST -- Return 1 if list of readable files, else 0 */ +int +isfilelist (filename, rootdir) + +char *filename; /* Name of possible list file */ +char *rootdir; /* Name of root directory for files in list */ +{ + FILE *diskfile; + char token[256]; + char filepath[256]; + int ncmax = 254; + + if ((diskfile = fopen (filename, "r")) == NULL) + return (0); + else { + first_token (diskfile, ncmax, token); + fclose (diskfile); + if (rootdir != NULL) { + strcpy (filepath, rootdir); + strcat (filepath, "/"); + strcat (filepath, token); + } + else + strcpy (filepath, token); + if (isfile (filepath)) + return (1); + else + return (0); + } +} + + +/* ISFILE -- Return 1 if file is a readable file, else 0 */ + +int +isfile (filename) + +char *filename; /* Name of file to check */ +{ + struct stat statbuff; + + if (!strcasecmp (filename, "stdin")) + return (1); + else if (access (filename, R_OK)) + return (0); + else if (stat (filename, &statbuff)) + return (0); + else { + if (S_ISDIR(statbuff.st_mode) && S_IFDIR) + return (2); + else + return (1); + } +} + + +/* NEXT_LINE -- Read the next line of an ASCII file, returning length */ +/* Lines beginning with # are ignored*/ + +int +next_line (diskfile, ncmax, line) + +FILE *diskfile; /* File descriptor for ASCII file */ +int ncmax; /* Maximum number of characters returned */ +char *line; /* Next line (returned) */ +{ + char *lastchar; + + /* If line can be read, add null at the end of the first token */ + if (fgets (line, ncmax, diskfile) != NULL) { + while (line[0] == '#') { + (void) fgets (line, ncmax, diskfile); + } + + /* If only character is a control character, return a NULL string */ + if ((strlen(line)==1) && (line[0]<32)){ + line[0] = (char)0; + return (1); + } + lastchar = line + strlen (line) - 1; + + /* Remove trailing spaces or control characters */ + while (*lastchar <= 32) + *lastchar-- = 0; + + return (strlen (line)); + } + else + return (0); +} + + +/* FIRST_TOKEN -- Return first token from the next line of an ASCII file */ +/* Lines beginning with # are ignored */ + +int +first_token (diskfile, ncmax, token) + +FILE *diskfile; /* File descriptor for ASCII file */ +int ncmax; /* Maximum number of characters returned */ +char *token; /* First token on next line (returned) */ +{ + char *lastchar, *lspace; + + /* If line can be read, add null at the end of the first token */ + if (fgets (token, ncmax, diskfile) != NULL) { + while (token[0] == '#') { + (void) fgets (token, ncmax, diskfile); + } + + /* If only character is a control character, return a NULL */ + if ((strlen(token)==1) && (token[0]<32)){ + token[0]=0; + return (1); + } + lastchar = token + strlen (token) - 1; + + /* Remove trailing spaces or control characters */ + while (*lastchar <= 32) + *lastchar-- = 0; + + if ((lspace = strchr (token, ' ')) != NULL) { + *lspace = (char) 0; + } + return (1); + } + else + return (0); +} + + +/* Replace character in string with space */ + +int +stc2s (spchar, string) + +char *spchar; /* Character to replace with spaces */ +char *string; +{ + int i, lstr, n; + lstr = strlen (string); + n = 0; + for (i = 0; i < lstr; i++) { + if (string[i] == spchar[0]) { + n++; + string[i] = ' '; + } + } + return (n); +} + + +/* Replace spaces in string with character */ + +int +sts2c (spchar, string) + +char *spchar; /* Character with which to replace spaces */ +char *string; +{ + int i, lstr, n; + lstr = strlen (string); + n = 0; + for (i = 0; i < lstr; i++) { + if (string[i] == ' ') { + n++; + string[i] = spchar[0]; + } + } + return (n); +} + + +/* ISTIFF -- Return 1 if TIFF file, else 0 */ +int +istiff (filename) + +char *filename; /* Name of file to check */ +{ + int diskfile; + char keyword[16]; + int nbr; + + /* First check to see if this is an assignment */ + if (strchr (filename, '=')) + return (0); + + /* Check file extension */ + if (strsrch (filename, ".tif") || + strsrch (filename, ".tiff") || + strsrch (filename, ".TIFF") || + strsrch (filename, ".TIF")) + return (1); + + /* If no TIFF file suffix, try opening the file */ + else { + if ((diskfile = open (filename, O_RDONLY)) < 0) + return (0); + else { + nbr = read (diskfile, keyword, 4); + close (diskfile); + if (nbr < 4) + return (0); + else if (!strncmp (keyword, "II", 2)) + return (1); + else if (!strncmp (keyword, "MM", 2)) + return (1); + else + return (0); + } + } +} + + +/* ISJPEG -- Return 1 if JPEG file, else 0 */ +int +isjpeg (filename) + +char *filename; /* Name of file to check */ +{ + int diskfile; + char keyword[16]; + int nbr; + + /* First check to see if this is an assignment */ + if (strchr (filename, '=')) + return (0); + + /* Check file extension */ + if (strsrch (filename, ".jpg") || + strsrch (filename, ".jpeg") || + strsrch (filename, ".JPEG") || + strsrch (filename, ".jfif") || + strsrch (filename, ".jfi") || + strsrch (filename, ".JFIF") || + strsrch (filename, ".JFI") || + strsrch (filename, ".JPG")) + return (1); + + /* If no JPEG file suffix, try opening the file */ + else { + if ((diskfile = open (filename, O_RDONLY)) < 0) + return (0); + else { + nbr = read (diskfile, keyword, 2); + close (diskfile); + if (nbr < 4) + return (0); + else if (keyword[0] == (char) 0xFF && + keyword[1] == (char) 0xD8) + return (1); + else + return (0); + } + } +} + + +/* ISGIF -- Return 1 if GIF file, else 0 */ +int +isgif (filename) + +char *filename; /* Name of file to check */ +{ + int diskfile; + char keyword[16]; + int nbr; + + /* First check to see if this is an assignment */ + if (strchr (filename, '=')) + return (0); + + /* Check file extension */ + if (strsrch (filename, ".gif") || + strsrch (filename, ".GIF")) + return (1); + + /* If no GIF file suffix, try opening the file */ + else { + if ((diskfile = open (filename, O_RDONLY)) < 0) + return (0); + else { + nbr = read (diskfile, keyword, 6); + close (diskfile); + if (nbr < 4) + return (0); + else if (!strncmp (keyword, "GIF", 3)) + return (1); + else + return (0); + } + } +} + + +static int maxtokens = MAXTOKENS; /* Set maximum number of tokens from wcscat.h*/ + +/* -- SETOKEN -- tokenize a string for easy decoding */ + +int +setoken (tokens, string, cwhite) + +struct Tokens *tokens; /* Token structure returned */ +char *string; /* character string to tokenize */ +char *cwhite; /* additional whitespace characters + * if = tab, disallow spaces and commas */ +{ + char squote, dquote, jch, newline; + char *iq, *stri, *wtype, *str0, *inew; + int i,j,naddw, ltok; + + newline = (char) 10; + squote = (char) 39; + dquote = (char) 34; + if (string == NULL) + return (0); + + /* Line is terminated by newline or NULL */ + inew = strchr (string, newline); + if (inew != NULL) + tokens->lline = inew - string - 1; + else + tokens->lline = strlen (string); + + /* Save current line in structure */ + tokens->line = string; + + /* Add extra whitespace characters */ + if (cwhite == NULL) + naddw = 0; + else + naddw = strlen (cwhite); + + /* if character is tab, allow only tabs and nulls as separators */ + if (naddw > 0 && !strncmp (cwhite, "tab", 3)) { + tokens->white[0] = (char) 9; /* Tab */ + tokens->white[1] = (char) 0; /* NULL (end of string) */ + tokens->nwhite = 2; + } + + /* if character is bar, allow only bars and nulls as separators */ + else if (naddw > 0 && !strncmp (cwhite, "bar", 3)) { + tokens->white[0] = '|'; /* Bar */ + tokens->white[1] = (char) 0; /* NULL (end of string) */ + tokens->nwhite = 2; + } + + /* otherwise, allow spaces, tabs, commas, nulls, and cwhite */ + else { + tokens->nwhite = 4 + naddw;; + tokens->white[0] = ' '; /* Space */ + tokens->white[1] = (char) 9; /* Tab */ + tokens->white[2] = ','; /* Comma */ + tokens->white[3] = (char) 124; /* Vertical bar */ + tokens->white[4] = (char) 0; /* Null (end of string) */ + if (tokens->nwhite > 20) + tokens->nwhite = 20; + if (naddw > 0) { + i = 0; + for (j = 4; j < tokens->nwhite; j++) { + tokens->white[j] = cwhite[i]; + i++; + } + } + } + tokens->white[tokens->nwhite] = (char) 0; + + tokens->ntok = 0; + tokens->itok = 0; + iq = string - 1; + for (i = 0; i < maxtokens; i++) { + tokens->tok1[i] = NULL; + tokens->ltok[i] = 0; + } + + /* Process string one character at a time */ + stri = string; + str0 = string; + while (stri < string+tokens->lline) { + + /* Keep stuff between quotes in one token */ + if (stri <= iq) + continue; + jch = *stri; + + /* Handle quoted strings */ + if (jch == squote) + iq = strchr (stri+1, squote); + else if (jch == dquote) + iq = strchr (stri+1, dquote); + else + iq = stri; + if (iq > stri) { + tokens->ntok = tokens->ntok + 1; + if (tokens->ntok > maxtokens) return (maxtokens); + tokens->tok1[tokens->ntok] = stri + 1; + tokens->ltok[tokens->ntok] = (iq - stri) - 1; + stri = iq + 1; + str0 = iq + 1; + continue; + } + + /* Search for unquoted tokens */ + wtype = strchr (tokens->white, jch); + + /* If this is one of the additional whitespace characters, + * pass as a separate token */ + if (wtype > tokens->white + 3) { + + /* Terminate token before whitespace */ + if (stri > str0) { + tokens->ntok = tokens->ntok + 1; + if (tokens->ntok > maxtokens) return (maxtokens); + tokens->tok1[tokens->ntok] = str0; + tokens->ltok[tokens->ntok] = stri - str0; + } + + /* Make whitespace character next token; start new one */ + tokens->ntok = tokens->ntok + 1; + if (tokens->ntok > maxtokens) return (maxtokens); + tokens->tok1[tokens->ntok] = stri; + tokens->ltok[tokens->ntok] = 1; + stri++; + str0 = stri; + } + + /* Pass previous token if regular whitespace or NULL */ + else if (wtype != NULL || jch == (char) 0) { + + /* Ignore leading whitespace */ + if (stri == str0) { + stri++; + str0 = stri; + } + + /* terminate token before whitespace; start new one */ + else { + tokens->ntok = tokens->ntok + 1; + if (tokens->ntok > maxtokens) return (maxtokens); + tokens->tok1[tokens->ntok] = str0; + tokens->ltok[tokens->ntok] = stri - str0; + stri++; + str0 = stri; + } + } + + /* Keep going if not whitespace */ + else + stri++; + } + + /* Add token terminated by end of line */ + if (str0 < stri) { + tokens->ntok = tokens->ntok + 1; + if (tokens->ntok > maxtokens) + return (maxtokens); + tokens->tok1[tokens->ntok] = str0; + ltok = stri - str0 + 1; + tokens->ltok[tokens->ntok] = ltok; + + /* Deal with white space just before end of line */ + jch = str0[ltok-1]; + if (strchr (tokens->white, jch)) { + ltok = ltok - 1; + tokens->ltok[tokens->ntok] = ltok; + tokens->ntok = tokens->ntok + 1; + tokens->tok1[tokens->ntok] = str0 + ltok; + tokens->ltok[tokens->ntok] = 0; + } + } + + tokens->itok = 0; + + return (tokens->ntok); +} + + +/* NEXTOKEN -- get next token from tokenized string */ + +int +nextoken (tokens, token, maxchars) + +struct Tokens *tokens; /* Token structure returned */ +char *token; /* token (returned) */ +int maxchars; /* Maximum length of token */ +{ + int ltok; /* length of token string (returned) */ + int it, i; + int maxc = maxchars - 1; + + tokens->itok = tokens->itok + 1; + it = tokens->itok; + if (it > tokens->ntok) + it = tokens->ntok; + else if (it < 1) + it = 1; + ltok = tokens->ltok[it]; + if (ltok > maxc) + ltok = maxc; + strncpy (token, tokens->tok1[it], ltok); + for (i = ltok; i < maxc; i++) + token[i] = (char) 0; + return (ltok); +} + + +/* GETOKEN -- get specified token from tokenized string */ + +int +getoken (tokens, itok, token, maxchars) + +struct Tokens *tokens; /* Token structure returned */ +int itok; /* token sequence number of token + * if <0, get whole string after token -itok + * if =0, get whole string */ +char *token; /* token (returned) */ +int maxchars; /* Maximum length of token */ +{ + int ltok; /* length of token string (returned) */ + int it, i; + int maxc = maxchars - 1; + + it = itok; + if (it > 0 ) { + if (it > tokens->ntok) + it = tokens->ntok; + ltok = tokens->ltok[it]; + if (ltok > maxc) + ltok = maxc; + strncpy (token, tokens->tok1[it], ltok); + } + else if (it < 0) { + if (it < -tokens->ntok) + it = -tokens->ntok; + ltok = tokens->line + tokens->lline - tokens->tok1[-it]; + if (ltok > maxc) + ltok = maxc; + strncpy (token, tokens->tok1[-it], ltok); + } + else { + ltok = tokens->lline; + if (ltok > maxc) + ltok = maxc; + strncpy (token, tokens->tok1[1], ltok); + } + for (i = ltok; i < maxc; i++) + token[i] = (char) 0; + + return (ltok); +} + +/* + * Jul 14 1999 New subroutines + * Jul 15 1999 Add getfilebuff() + * Oct 15 1999 Fix format eror in error message + * Oct 21 1999 Fix declarations after lint + * Dec 9 1999 Add next_token(); set pointer to next token in first_token + * + * Sep 25 2001 Add isfilelist(); move isfile() from catutil.c + * + * Jan 4 2002 Allow getfilebuffer() to read from stdin + * Jan 8 2002 Add sts2c() and stc2s() for space-replaced strings + * Mar 22 2002 Clean up isfilelist() + * Aug 1 2002 Return 1 if file is stdin in isfile() + * + * Feb 4 2003 Open catalog file rb instead of r (Martin Ploner, Bern) + * Mar 5 2003 Add isimlistd() to check image lists with root directory + * May 27 2003 Use file stat call in getfilesize() instead of opening file + * Jul 17 2003 Add root directory argument to isfilelist() + * + * Sep 29 2004 Drop next_token() to avoid conflict with subroutine in catutil.c + * + * Sep 26 2005 In first_token, return NULL if token is only control character + * + * Feb 23 2006 Add istiff(), isjpeg(), isgif() to check TIFF, JPEG, GIF files + * Jun 20 2006 Cast call to fgets() void + * + * Jan 5 2007 Change stc2s() and sts2c() to pass single character as pointer + * Jan 11 2007 Move token access subroutines from catutil.c + * + * Aug 28 2014 Return length from next_line(): 0=unsuccessful + */ diff --git a/tksao/wcssubs/fitsfile.c b/tksao/wcssubs/fitsfile.c new file mode 100644 index 0000000..c832687 --- /dev/null +++ b/tksao/wcssubs/fitsfile.c @@ -0,0 +1,2325 @@ +/*** File libwcs/fitsfile.c + *** July 25, 2014 + *** By Jessica Mink, jmink@cfa.harvard.edu + *** Harvard-Smithsonian Center for Astrophysics + *** Copyright (C) 1996-2014 + *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Correspondence concerning WCSTools should be addressed as follows: + Internet email: jmink@cfa.harvard.edu + Postal address: Jessica Mink + Smithsonian Astrophysical Observatory + 60 Garden St. + Cambridge, MA 02138 USA + + * Module: fitsfile.c (FITS file reading and writing) + * Purpose: Read and write FITS image and table files + * fitsropen (inpath) + * Open a FITS file for reading, returning a FILE pointer + * fitsrhead (filename, lhead, nbhead) + * Read FITS header and return it + * fitsrtail (filename, lhead, nbhead) + * Read appended FITS header and return it + * fitsrsect (filename, nbhead, header, fd, x0, y0, nx, ny) + * Read section of a FITS image, having already read the header + * fitsrimage (filename, nbhead, header) + * Read FITS image, having already ready the header + * fitsrfull (filename, nbhead, header) + * Read a FITS image of any dimension + * fitsrtopen (inpath, nk, kw, nrows, nchar, nbhead) + * Open a FITS table file for reading; return header information + * fitsrthead (header, nk, kw, nrows, nchar, nbhead) + * Extract FITS table information from a FITS header + * fitsrtline (fd, nbhead, lbuff, tbuff, irow, nbline, line) + * Read next line of FITS table file + * ftgetr8 (entry, kw) + * Extract column from FITS table line as double + * ftgetr4 (entry, kw) + * Extract column from FITS table line as float + * ftgeti4 (entry, kw) + * Extract column from FITS table line as int + * ftgeti2 (entry, kw) + * Extract column from FITS table line as short + * ftgetc (entry, kw, string, maxchar) + * Extract column from FITS table line as a character string + * fitswimage (filename, header, image) + * Write FITS header and image + * fitswext (filename, header, image) + * Write FITS header and image as extension to existing FITS file + * fitswhdu (fd, filename, header, image) + * Write FITS header and image as extension to file descriptor + * fitscimage (filename, header, filename0) + * Write FITS header and copy FITS image + * fitswhead (filename, header) + * Write FITS header and keep file open for further writing + * fitswexhead (filename, header) + * Write FITS header only to FITS extension without writing data + * isfits (filename) + * Return 1 if file is a FITS file, else 0 + * fitsheadsize (header) + * Return size of FITS header in bytes + */ + +#include +#ifndef VMS +#include +#endif +#include +#include +#include +#include +#include +#include "fitsfile.h" + +static int verbose=0; /* Print diagnostics */ +static char fitserrmsg[80]; +static int fitsinherit = 1; /* Append primary header to extension header */ +void +setfitsinherit (inh) +int inh; +{fitsinherit = inh; return;} + +static off_t ibhead = 0; /* Number of bytes read before header starts */ + +off_t +getfitsskip() +{return (ibhead);} + +/* FITSRHEAD -- Read a FITS header */ + +char * +fitsrhead (filename, lhead, nbhead) + +char *filename; /* Name of FITS image file */ +int *lhead; /* Allocated length of FITS header in bytes (returned) */ +int *nbhead; /* Number of bytes before start of data (returned) */ + /* This includes all skipped image extensions */ + +{ + int fd; + char *header; /* FITS image header (filled) */ + int extend; + int nbytes,naxis, i; + int ntry,nbr,irec,nrec, nbh, ipos, npos, nbprim, lprim, lext; + int nax1, nax2, nax3, nax4, nbpix, ibpix, nblock, nbskip; + char fitsbuf[2884]; + char *headend; /* Pointer to last line of header */ + char *headnext; /* Pointer to next line of header to be added */ + int hdu; /* header/data unit counter */ + int extnum; /* desired header data number + (0=primary -1=first with data -2=use EXTNAME) */ + char extname[32]; /* FITS extension name */ + char extnam[32]; /* Desired FITS extension name */ + char *ext; /* FITS extension name or number in header, if any */ + char *pheader; /* Primary header (naxis is 0) */ + char cext = 0; + char *rbrac; /* Pointer to right bracket if present in file name */ + char *mwcs; /* Pointer to WCS name separated by % */ + char *newhead; /* New larger header */ + int nbh0; /* Length of old too small header */ + char *pheadend; + int inherit = 1; /* Value of INHERIT keyword in FITS extension header */ + int extfound = 0; /* Set to one if desired FITS extension is found */ + int npcount; + + pheader = NULL; + lprim = 0; + header = NULL; + + /* Check for FITS WCS specification and ignore for file opening */ + mwcs = strchr (filename, '%'); + if (mwcs != NULL) + *mwcs = (char) 0; + + /* Check for FITS extension and ignore for file opening */ + rbrac = NULL; + ext = strchr (filename, ','); + if (ext == NULL) { + ext = strchr (filename, '['); + if (ext != NULL) { + rbrac = strchr (filename, ']'); + if (rbrac != NULL) + *rbrac = (char) 0; + } + } + if (ext != NULL) { + cext = *ext; + *ext = (char) 0; + } + + /* Open the image file and read the header */ + if (strncasecmp (filename,"stdin",5)) { + fd = -1; + fd = fitsropen (filename); + } +#ifndef VMS + else { + fd = STDIN_FILENO; + extnum = -1; + } +#endif + + if (ext != NULL) { + if (isnum (ext+1)) + extnum = atoi (ext+1); + else { + extnum = -2; + strcpy (extnam, ext+1); + } + } + else + extnum = -1; + + /* Repair the damage done to the file-name string during parsing */ + if (ext != NULL) + *ext = cext; + if (rbrac != NULL) + *rbrac = ']'; + if (mwcs != NULL) + *mwcs = '%'; + + if (fd < 0) { + fprintf (stderr,"FITSRHEAD: cannot read file %s\n", filename); + return (NULL); + } + + nbytes = FITSBLOCK; + *nbhead = 0; + headend = NULL; + nbh = FITSBLOCK * 20 + 4; + header = (char *) calloc ((unsigned int) nbh, 1); + (void) hlength (header, nbh); + headnext = header; + nrec = 1; + hdu = 0; + ibhead = 0; + + /* Read FITS header from input file one FITS block at a time */ + irec = 0; + ibhead = 0; + while (irec < 500) { + nbytes = FITSBLOCK; + for (ntry = 0; ntry < 10; ntry++) { + for (i = 0; i < 2884; i++) fitsbuf[i] = 0; + nbr = read (fd, fitsbuf, nbytes); + if (verbose) + fprintf (stderr,"FITSRHEAD: %d header bytes read\n",nbr); + + /* Short records allowed only if they have the last header line */ + if (nbr < nbytes) { + headend = ksearch (fitsbuf,"END"); + if (headend == NULL) { + if (ntry < 9) { + if (verbose) + fprintf (stderr,"FITSRHEAD: %d / %d bytes read %d\n", + nbr,nbytes,ntry); + } + else { + snprintf(fitserrmsg,79,"FITSRHEAD: '%d / %d bytes of header read from %s\n" + ,nbr,nbytes,filename); +#ifndef VMS + if (fd != STDIN_FILENO) +#endif + (void)close (fd); + free (header); + /* if (pheader != NULL) + return (pheader); */ + if (extnum != -1 && !extfound) { + *ext = (char) 0; + if (extnum < 0) { + snprintf (fitserrmsg,79, + "FITSRHEAD: Extension %s not found in file %s", + extnam, filename); + } + else { + snprintf (fitserrmsg,79, + "FITSRHEAD: Extension %d not found in file %s", + extnum, filename); + } + *ext = cext; + } + else if (hdu > 0) { + snprintf (fitserrmsg,79, + "FITSRHEAD: No extensions found in file %s", filename); + hdu = 0; + if (pheader != NULL) { + *lhead = nbprim; + *nbhead = nbprim; + return (pheader); + } + break; + } + else { + snprintf (fitserrmsg,79, + "FITSRHEAD: No header found in file %s", filename); + } + return (NULL); + } + } + else + break; + } + else + break; + } + + /* Replace control characters and nulls with spaces */ + for (i = 0; i < 2880; i++) + if (fitsbuf[i] < 32 || i > nbr) fitsbuf[i] = 32; + if (nbr < 2880) + nbr = 2880; + + /* Move current FITS record into header string */ + strncpy (headnext, fitsbuf, nbr); + *nbhead = *nbhead + nbr; + nrec = nrec + 1; + *(headnext+nbr+1) = 0; + ibhead = ibhead + 2880; + if (verbose) + fprintf (stderr,"FITSRHEAD: %d bytes in header\n",ibhead); + + /* Check to see if this is the final record in this header */ + headend = ksearch (fitsbuf,"END"); + if (headend == NULL) { + + /* Double size of header buffer if too small */ + if (nrec * FITSBLOCK > nbh) { + nbh0 = nbh - 4; + nbh = (nrec * 2 * FITSBLOCK) + 4; + newhead = (char *) calloc (1,(unsigned int) nbh); + if (newhead) { + for (i = 0; i < nbh0; i++) + newhead[i] = header[i]; + free (header); + newhead[nbh-3] = (char) 0; + header = newhead; + (void) hlength (header, nbh); + headnext = header + ((nrec-1) * FITSBLOCK); + } + else { + fprintf (stderr,"FITSRHEAD: %d bytes cannot be allocated for header\n",nbh); + exit (1); + } + } + else + headnext = headnext + FITSBLOCK; + } + + else { + naxis = 0; + hgeti4 (header,"NAXIS",&naxis); + + /* If header has no data, save it for appending to desired header */ + if (naxis < 1) { + nbprim = nrec * FITSBLOCK; + headend = ksearch (header,"END"); + lprim = headend + 80 - header; + pheader = (char *) calloc ((unsigned int) nbprim, 1); + for (i = 0; i < lprim; i++) + pheader[i] = header[i]; + for (i = lprim; i < nbprim; i++) + pheader[i] = ' '; + } + + /* If header has no data, start with the next record */ + if (naxis < 1 && extnum == -1) { + extend = 0; + hgetl (header,"EXTEND",&extend); + if (naxis == 0 && extend) { + headnext = header; + *headend = ' '; + headend = NULL; + nrec = 1; + hdu = hdu + 1; + } + else { + break; + } + } + + /* If this is the desired header data unit, keep it */ + else if (extnum != -1) { + if (extnum > -1 && hdu == extnum) { + extfound = 1; + break; + } + else if (extnum < 0) { + extname[0] = 0; + hgets (header, "EXTNAME", 32, extname); + if (!strcmp (extnam,extname)) { + extfound = 1; + break; + } + } + + /* If this is not desired header data unit, skip over data */ + hdu = hdu + 1; + nblock = 0; + ibhead = 0; + if (naxis > 0) { + ibpix = 0; + hgeti4 (header,"BITPIX",&ibpix); + if (ibpix < 0) { + nbpix = -ibpix / 8; + } + else { + nbpix = ibpix / 8; + } + nax1 = 1; + hgeti4 (header,"NAXIS1",&nax1); + nax2 = 1; + if (naxis > 1) { + hgeti4 (header,"NAXIS2",&nax2); + } + nax3 = 1; + if (naxis > 2) { + hgeti4 (header,"NAXIS3",&nax3); + } + nax4 = 1; + if (naxis > 3) { + hgeti4 (header,"NAXIS4",&nax4); + } + nbskip = nax1 * nax2 * nax3 * nax4 * nbpix; + nblock = nbskip / 2880; + if (nblock*2880 < nbskip) { + nblock = nblock + 1; + } + npcount = 0; + hgeti4 (header,"PCOUNT", &npcount); + if (npcount > 0) { + nbskip = nbskip + npcount; + nblock = nbskip / 2880; + if (nblock*2880 < nbskip) + nblock = nblock + 1; + } + } + else { + nblock = 0; + } + *nbhead = *nbhead + (nblock * 2880); + + /* Set file pointer to beginning of next header/data unit */ + if (nblock > 0) { +#ifndef VMS + if (fd != STDIN_FILENO) { + ipos = lseek (fd, *nbhead, SEEK_SET); + npos = *nbhead; + } + else { +#else + { +#endif + ipos = 0; + for (i = 0; i < nblock; i++) { + nbytes = FITSBLOCK; + nbr = read (fd, fitsbuf, nbytes); + if (nbr < nbytes) { + ipos = ipos + nbr; + break; + } + else { + ipos = ipos + nbytes; + } + } + npos = nblock * 2880; + } + if (ipos < npos) { + snprintf (fitserrmsg,79,"FITSRHEAD: %d / %d bytes skipped\n", + ipos,npos); + extfound = 0; + break; + } + } + headnext = header; + headend = NULL; + nrec = 1; + } + else { + break; + } + } + } + +#ifndef VMS + if (fd != STDIN_FILENO) + (void)close (fd); +#endif + +/* Print error message and return null if extension not found */ + if (extnum != -1 && !extfound) { + if (extnum < 0) + fprintf (stderr, "FITSRHEAD: Extension %s not found in file %s\n",extnam, filename); + else + fprintf (stderr, "FITSRHEAD: Extension %d not found in file %s\n",extnum, filename); + if (pheader != NULL) { + free (pheader); + pheader = NULL; + } + return (NULL); + } + + /* Allocate an extra block for good measure */ + *lhead = (nrec + 1) * FITSBLOCK; + if (*lhead > nbh) { + newhead = (char *) calloc (1,(unsigned int) *lhead); + for (i = 0; i < nbh; i++) + newhead[i] = header[i]; + free (header); + header = newhead; + (void) hlength (header, *lhead); + } + else + *lhead = nbh; + + /* If INHERIT keyword is FALSE, never append primary header */ + if (hgetl (header, "INHERIT", &inherit)) { + if (!inherit && fitsinherit) + fitsinherit = 0; + } + + /* Append primary data header to extension header */ + if (pheader != NULL && extnum != 0 && fitsinherit && hdu > 0) { + extname[0] = 0; + hgets (header, "XTENSION", 32, extname); + if (!strcmp (extname,"IMAGE")) { + strncpy (header, "SIMPLE ", 8); + hputl (header, "SIMPLE", 1); + } + headend = blsearch (header,"END"); + if (headend == NULL) + headend = ksearch (header, "END"); + lext = headend - header; + + /* Update primary header for inclusion at end of extension header */ + hchange (pheader, "SIMPLE", "ROOTHEAD"); + hchange (pheader, "NEXTEND", "NUMEXT"); + hdel (pheader, "BITPIX"); + hdel (pheader, "NAXIS"); + hdel (pheader, "EXTEND"); + hputl (pheader, "ROOTEND",1); + pheadend = ksearch (pheader,"END"); + lprim = pheadend + 320 - pheader; + if (lext + lprim > nbh) { + nrec = (lext + lprim) / FITSBLOCK; + if (FITSBLOCK*nrec < lext+lprim) + nrec = nrec + 1; + *lhead = (nrec+1) * FITSBLOCK; + newhead = (char *) calloc (1,(unsigned int) *lhead); + for (i = 0; i < nbh; i++) + newhead[i] = header[i]; + free (header); + header = newhead; + headend = header + lext; + (void) hlength (header, *lhead); + } + hputs (header,"COMMENT","-------------------------------------------"); + hputs (header,"COMMENT","Information from Primary Header"); + hputs (header,"COMMENT","-------------------------------------------"); + headend = blsearch (header,"END"); + if (headend == NULL) + headend = ksearch (header, "END"); + pheader[lprim] = 0; + strncpy (headend, pheader, lprim); + if (pheader != NULL) { + free (pheader); + pheader = NULL; + } + } + + ibhead = *nbhead - ibhead; + + return (header); +} + + +/* FITSRTAIL -- Read FITS header appended to graphics file */ + +char * +fitsrtail (filename, lhead, nbhead) + +char *filename; /* Name of image file */ +int *lhead; /* Allocated length of FITS header in bytes (returned) */ +int *nbhead; /* Number of bytes before start of data (returned) */ + /* This includes all skipped image extensions */ + +{ + int fd; + char *header; /* FITS image header (filled) */ + int nbytes, i, ndiff; + int nbr, irec; + off_t offset; + char *mwcs; /* Pointer to WCS name separated by % */ + char *headstart; + char *newhead; + + header = NULL; + + /* Check for FITS WCS specification and ignore for file opening */ + mwcs = strchr (filename, '%'); + if (mwcs != NULL) + *mwcs = (char) 0; + + /* Open the image file and read the header */ + if (strncasecmp (filename,"stdin",5)) { + fd = -1; + fd = fitsropen (filename); + } +#ifndef VMS + else { + fd = STDIN_FILENO; + } +#endif + + /* Repair the damage done to the file-name string during parsing */ + if (mwcs != NULL) + *mwcs = '%'; + + if (fd < 0) { + fprintf (stderr,"FITSRTAIL: cannot read file %s\n", filename); + return (NULL); + } + + nbytes = FITSBLOCK; + *nbhead = 0; + *lhead = 0; + + /* Read FITS header from end of input file one FITS block at a time */ + irec = 0; + while (irec < 100) { + nbytes = FITSBLOCK * (irec + 2); + header = (char *) calloc ((unsigned int) nbytes, 1); + offset = lseek (fd, -nbytes, SEEK_END); + if (offset < 0) { + free (header); + header = NULL; + nbytes = 0; + break; + } + for (i = 0; i < nbytes; i++) header[i] = 0; + nbr = read (fd, header, nbytes); + + /* Check for SIMPLE at start of header */ + for (i = 0; i < nbr; i++) + if (header[i] < 32) header[i] = 32; + if ((headstart = ksearch (header,"SIMPLE"))) { + if (headstart != header) { + ndiff = headstart - header; + newhead = (char *) calloc ((unsigned int) nbytes, 1); + for (i = 0; i < nbytes-ndiff; i++) + newhead[i] = headstart[i]; + free (header); + header = newhead; + } + *lhead = nbytes; + *nbhead = nbytes; + break; + } + free (header); + } + (void) hlength (header, nbytes); + +#ifndef VMS + if (fd != STDIN_FILENO) + (void)close (fd); +#endif + + return (header); +} + + +/* FITSRSECT -- Read a piece of a FITS image, having already read the header */ + +char * +fitsrsect (filename, header, nbhead, x0, y0, nx, ny, nlog) + +char *filename; /* Name of FITS image file */ +char *header; /* FITS header for image (previously read) */ +int nbhead; /* Actual length of image header(s) in bytes */ +int x0, y0; /* FITS image coordinate of first pixel */ +int nx; /* Number of columns to read (less than NAXIS1) */ +int ny; /* Number of rows to read (less than NAXIS2) */ +int nlog; /* Note progress mod this rows */ +{ + int fd; /* File descriptor */ + int nbimage, naxis1, naxis2, bytepix, nbread; + int bitpix, naxis, nblocks, nbytes, nbr; + int x1, y1, nbline, nyleft; + off_t impos, nblin; + char *image, *imline, *imlast; + int ilog = 0; + int row; + + /* Open the image file and read the header */ + if (strncasecmp (filename,"stdin", 5)) { + fd = -1; + + fd = fitsropen (filename); + if (fd < 0) { + snprintf (fitserrmsg,79, "FITSRSECT: cannot read file %s\n", filename); + return (NULL); + } + + /* Skip over FITS header and whatever else needs to be skipped */ + if (lseek (fd, nbhead, SEEK_SET) < 0) { + (void)close (fd); + snprintf (fitserrmsg,79, "FITSRSECT: cannot skip header of file %s\n", + filename); + return (NULL); + } + } +#ifndef VMS + else + fd = STDIN_FILENO; +#endif + + /* Compute size of image in bytes using relevant header parameters */ + naxis = 1; + hgeti4 (header,"NAXIS",&naxis); + naxis1 = 1; + hgeti4 (header,"NAXIS1",&naxis1); + naxis2 = 1; + hgeti4 (header,"NAXIS2",&naxis2); + bitpix = 0; + hgeti4 (header,"BITPIX",&bitpix); + if (bitpix == 0) { + /* snprintf (fitserrmsg,79, "FITSRSECT: BITPIX is 0; image not read\n"); */ + (void)close (fd); + return (NULL); + } + bytepix = bitpix / 8; + if (bytepix < 0) bytepix = -bytepix; + + /* Keep X coordinates within image limits */ + if (x0 < 1) + x0 = 1; + else if (x0 > naxis1) + x0 = naxis1; + x1 = x0 + nx - 1; + if (x1 < 1) + x1 = 1; + else if (x1 > naxis1) + x1 = naxis1; + nx = x1 - x0 + 1; + + /* Keep Y coordinates within image limits */ + if (y0 < 1) + y0 = 1; + else if (y0 > naxis2) + y0 = naxis2; + y1 = y0 + ny - 1; + if (y1 < 1) + y1 = 1; + else if (y1 > naxis2) + y1 = naxis2; + ny = y1 - y0 + 1; + + /* Number of bytes in output image */ + nbline = nx * bytepix; + nbimage = nbline * ny; + + /* Set number of bytes to integral number of 2880-byte blocks */ + nblocks = nbimage / FITSBLOCK; + if (nblocks * FITSBLOCK < nbimage) + nblocks = nblocks + 1; + nbytes = nblocks * FITSBLOCK; + + /* Allocate image section to be read */ + image = (char *) malloc (nbytes); + nyleft = ny; + imline = image; + nbr = 0; + + /* Computer pointer to first byte of input image to read */ + nblin = naxis1 * bytepix; + impos = ((y0 - 1) * nblin) + ((x0 - 1) * bytepix); + row = y0 - 1; + + /* Read image section one line at a time */ + while (nyleft-- > 0) { + if (lseek (fd, impos, SEEK_CUR) >= 0) { + nbread = read (fd, imline, nbline); + nbr = nbr + nbread; + impos = nblin - nbread; + imline = imline + nbline; + row++; + if (++ilog == nlog) { + ilog = 0; + fprintf (stderr, "Row %5d extracted ", row); + (void) putc (13,stderr); + } + } + } + if (nlog) + fprintf (stderr, "\n"); + + /* Fill rest of image with zeroes */ + imline = image + nbimage; + imlast = image + nbytes; + while (imline++ < imlast) + *imline = (char) 0; + + /* Byte-reverse image, if necessary */ + if (imswapped ()) + imswap (bitpix, image, nbytes); + + return (image); +} + + +/* FITSRIMAGE -- Read a FITS image */ + +char * +fitsrimage (filename, nbhead, header) + +char *filename; /* Name of FITS image file */ +int nbhead; /* Actual length of image header(s) in bytes */ +char *header; /* FITS header for image (previously read) */ +{ + int fd; + int nbimage, naxis1, naxis2, bytepix, nbread; + int bitpix, naxis, nblocks, nbytes, nbleft, nbr; + int simple; + char *image, *imleft; + + /* Open the image file and read the header */ + if (strncasecmp (filename,"stdin", 5)) { + fd = -1; + + fd = fitsropen (filename); + if (fd < 0) { + snprintf (fitserrmsg,79, "FITSRIMAGE: cannot read file %s\n", filename); + return (NULL); + } + + /* Skip over FITS header and whatever else needs to be skipped */ + if (lseek (fd, nbhead, SEEK_SET) < 0) { + (void)close (fd); + snprintf (fitserrmsg,79, "FITSRIMAGE: cannot skip header of file %s\n", + filename); + return (NULL); + } + } +#ifndef VMS + else + fd = STDIN_FILENO; +#endif + + /* If SIMPLE=F in header, simply put post-header part of file in buffer */ + hgetl (header, "SIMPLE", &simple); + if (!simple) { + nbytes = getfilesize (filename) - nbhead; + if ((image = (char *) malloc (nbytes + 1)) == NULL) { + /* snprintf (fitserrmsg,79, "FITSRIMAGE: %d-byte image buffer cannot be allocated\n"); */ + (void)close (fd); + return (NULL); + } + hputi4 (header, "NBDATA", nbytes); + nbread = read (fd, image, nbytes); + return (image); + } + + /* Compute size of image in bytes using relevant header parameters */ + naxis = 1; + hgeti4 (header,"NAXIS",&naxis); + naxis1 = 1; + hgeti4 (header,"NAXIS1",&naxis1); + naxis2 = 1; + hgeti4 (header,"NAXIS2",&naxis2); + bitpix = 0; + hgeti4 (header,"BITPIX",&bitpix); + if (bitpix == 0) { + /* snprintf (fitserrmsg,79, "FITSRIMAGE: BITPIX is 0; image not read\n"); */ + (void)close (fd); + return (NULL); + } + bytepix = bitpix / 8; + if (bytepix < 0) bytepix = -bytepix; + + /* If either dimension is one and image is 3-D, read all three dimensions */ + if (naxis == 3 && (naxis1 ==1 || naxis2 == 1)) { + int naxis3; + hgeti4 (header,"NAXIS3",&naxis3); + nbimage = naxis1 * naxis2 * naxis3 * bytepix; + } + else + nbimage = naxis1 * naxis2 * bytepix; + + /* Set number of bytes to integral number of 2880-byte blocks */ + nblocks = nbimage / FITSBLOCK; + if (nblocks * FITSBLOCK < nbimage) + nblocks = nblocks + 1; + nbytes = nblocks * FITSBLOCK; + + /* Allocate and read image */ + image = (char *) malloc (nbytes); + nbleft = nbytes; + imleft = image; + nbr = 0; + while (nbleft > 0) { + nbread = read (fd, imleft, nbleft); + nbr = nbr + nbread; +#ifndef VMS + if (fd == STDIN_FILENO && nbread < nbleft && nbread > 0) { + nbleft = nbleft - nbread; + imleft = imleft + nbread; + } + else +#endif + nbleft = 0; + } +#ifndef VMS + if (fd != STDIN_FILENO) + (void)close (fd); +#endif + if (nbr < nbimage) { + snprintf (fitserrmsg,79, "FITSRIMAGE: %d of %d bytes read from file %s\n", + nbr, nbimage, filename); + return (NULL); + } + + /* Byte-reverse image, if necessary */ + if (imswapped ()) + imswap (bitpix, image, nbytes); + + return (image); +} + + +/* FITSRFULL -- Read a FITS image of any dimension */ + +char * +fitsrfull (filename, nbhead, header) + +char *filename; /* Name of FITS image file */ +int nbhead; /* Actual length of image header(s) in bytes */ +char *header; /* FITS header for image (previously read) */ +{ + int fd; + int nbimage, naxisi, iaxis, bytepix, nbread; + int bitpix, naxis, nblocks, nbytes, nbleft, nbr, simple; + char keyword[16]; + char *image, *imleft; + + /* Open the image file and read the header */ + if (strncasecmp (filename,"stdin", 5)) { + fd = -1; + + fd = fitsropen (filename); + if (fd < 0) { + snprintf (fitserrmsg,79, "FITSRFULL: cannot read file %s\n", filename); + return (NULL); + } + + /* Skip over FITS header and whatever else needs to be skipped */ + if (lseek (fd, nbhead, SEEK_SET) < 0) { + (void)close (fd); + snprintf (fitserrmsg,79, "FITSRFULL: cannot skip header of file %s\n", + filename); + return (NULL); + } + } +#ifndef VMS + else + fd = STDIN_FILENO; +#endif + + /* If SIMPLE=F in header, simply put post-header part of file in buffer */ + hgetl (header, "SIMPLE", &simple); + if (!simple) { + nbytes = getfilesize (filename) - nbhead; + if ((image = (char *) malloc (nbytes + 1)) == NULL) { + snprintf (fitserrmsg,79, "FITSRFULL: %d-byte image buffer cannot be allocated\n",nbytes+1); + (void)close (fd); + return (NULL); + } + hputi4 (header, "NBDATA", nbytes); + nbread = read (fd, image, nbytes); + return (image); + } + + /* Find number of bytes per pixel */ + bitpix = 0; + hgeti4 (header,"BITPIX",&bitpix); + if (bitpix == 0) { + snprintf (fitserrmsg,79, "FITSRFULL: BITPIX is 0; image not read\n"); + (void)close (fd); + return (NULL); + } + bytepix = bitpix / 8; + if (bytepix < 0) bytepix = -bytepix; + nbimage = bytepix; + + /* Compute size of image in bytes using relevant header parameters */ + naxis = 1; + hgeti4 (header,"NAXIS",&naxis); + for (iaxis = 1; iaxis <= naxis; iaxis++) { + sprintf (keyword, "NAXIS%d", iaxis); + naxisi = 1; + hgeti4 (header,keyword,&naxisi); + nbimage = nbimage * naxisi; + } + + /* Set number of bytes to integral number of 2880-byte blocks */ + nblocks = nbimage / FITSBLOCK; + if (nblocks * FITSBLOCK < nbimage) + nblocks = nblocks + 1; + nbytes = nblocks * FITSBLOCK; + + /* Allocate and read image */ + image = (char *) malloc (nbytes); + nbleft = nbytes; + imleft = image; + nbr = 0; + while (nbleft > 0) { + nbread = read (fd, imleft, nbleft); + nbr = nbr + nbread; +#ifndef VMS + if (fd == STDIN_FILENO && nbread < nbleft && nbread > 0) { + nbleft = nbleft - nbread; + imleft = imleft + nbread; + } + else +#endif + nbleft = 0; + } +#ifndef VMS + if (fd != STDIN_FILENO) + (void)close (fd); +#endif + if (nbr < nbimage) { + snprintf (fitserrmsg,79, "FITSRFULL: %d of %d image bytes read from file %s\n", + nbr, nbimage, filename); + return (NULL); + } + + /* Byte-reverse image, if necessary */ + if (imswapped ()) + imswap (bitpix, image, nbytes); + + return (image); +} + + +/* FITSROPEN -- Open a FITS file, returning the file descriptor */ + +int +fitsropen (inpath) + +char *inpath; /* Pathname for FITS tables file to read */ + +{ + int ntry; + int fd; /* file descriptor for FITS tables file (returned) */ + char *ext; /* extension name or number */ + char cext = 0; + char *rbrac; + char *mwcs; /* Pointer to WCS name separated by % */ + +/* Check for FITS WCS specification and ignore for file opening */ + mwcs = strchr (inpath, '%'); + +/* Check for FITS extension and ignore for file opening */ + ext = strchr (inpath, ','); + rbrac = NULL; + if (ext == NULL) { + ext = strchr (inpath, '['); + if (ext != NULL) { + rbrac = strchr (inpath, ']'); + } + } + +/* Open input file */ + for (ntry = 0; ntry < 3; ntry++) { + if (ext != NULL) { + cext = *ext; + *ext = 0; + } + if (rbrac != NULL) + *rbrac = (char) 0; + if (mwcs != NULL) + *mwcs = (char) 0; + fd = open (inpath, O_RDONLY); + if (ext != NULL) + *ext = cext; + if (rbrac != NULL) + *rbrac = ']'; + if (mwcs != NULL) + *mwcs = '%'; + if (fd >= 0) + break; + else if (ntry == 2) { + snprintf (fitserrmsg,79, "FITSROPEN: cannot read file %s\n", inpath); + return (-1); + } + } + + if (verbose) + fprintf (stderr,"FITSROPEN: input file %s opened\n",inpath); + + return (fd); +} + + +static int offset1=0; +static int offset2=0; + +/* FITSRTOPEN -- Open FITS table file and fill structure with + * pointers to selected keywords + * Return file descriptor (-1 if unsuccessful) + */ + +int +fitsrtopen (inpath, nk, kw, nrows, nchar, nbhead) + +char *inpath; /* Pathname for FITS tables file to read */ +int *nk; /* Number of keywords to use */ +struct Keyword **kw; /* Structure for desired entries */ +int *nrows; /* Number of rows in table (returned) */ +int *nchar; /* Number of characters in one table row (returned) */ +int *nbhead; /* Number of characters before table starts */ + +{ + char temp[16]; + int fd; + int lhead; /* Maximum length in bytes of FITS header */ + char *header; /* Header for FITS tables file to read */ + +/* Read FITS header from input file */ + header = fitsrhead (inpath, &lhead, nbhead); + if (!header) { + snprintf (fitserrmsg,79,"FITSRTOPEN: %s is not a FITS file\n",inpath); + return (0); + } + +/* Make sure this file is really a FITS table file */ + temp[0] = 0; + (void) hgets (header,"XTENSION",16,temp); + if (strlen (temp) == 0) { + snprintf (fitserrmsg,79, + "FITSRTOPEN: %s is not a FITS table file\n",inpath); + free ((void *) header); + return (0); + } + +/* If it is a FITS file, get table information from the header */ + else if (!strcmp (temp, "TABLE") || !strcmp (temp, "BINTABLE")) { + if (fitsrthead (header, nk, kw, nrows, nchar)) { + snprintf (fitserrmsg,79, + "FITSRTOPEN: Cannot read FITS table from %s\n",inpath); + free ((void *) header); + return (-1); + } + else { + fd = fitsropen (inpath); + offset1 = 0; + offset2 = 0; + free ((void *) header); + return (fd); + } + } + +/* If it is another FITS extension note it and return */ + else { + snprintf (fitserrmsg,79, + "FITSRTOPEN: %s is a %s extension, not table\n", + inpath, temp); + free ((void *) header); + return (0); + } +} + +static struct Keyword *pw; /* Structure for all entries */ +static int *lpnam; /* length of name for each field */ +static int bfields = 0; + +/* FITSRTHEAD -- From FITS table header, read pointers to selected keywords */ + +int +fitsrthead (header, nk, kw, nrows, nchar) + +char *header; /* Header for FITS tables file to read */ +int *nk; /* Number of keywords to use */ +struct Keyword **kw; /* Structure for desired entries */ +int *nrows; /* Number of rows in table (returned) */ +int *nchar; /* Number of characters in one table row (returned) */ + +{ + struct Keyword *rw; /* Structure for desired entries */ + int nfields; + int ifield, ik, i, ikf, ltform, kl; + char *h0, *h1, *tf1, *tf2; + char tname[12]; + char temp[16]; + char tform[16]; + int tverb; + int bintable = 0; + + h0 = header; + +/* Make sure this is really a FITS table file header */ + temp[0] = 0; + hgets (header,"XTENSION",16,temp); + if (strlen (temp) == 0) { + snprintf (fitserrmsg,79, "FITSRTHEAD: Not a FITS table header\n"); + return (-1); + } + else if (!strcmp (temp, "BINTABLE")) { + bintable = 1; + } + else if (strcmp (temp, "TABLE")) { + snprintf (fitserrmsg,79, "FITSRTHEAD: %s extension, not TABLE\n",temp); + return (-1); + } + +/* Get table size from FITS header */ + *nchar = 0; + hgeti4 (header,"NAXIS1",nchar); + *nrows = 0; + hgeti4 (header,"NAXIS2", nrows); + if (*nrows <= 0 || *nchar <= 0) { + snprintf (fitserrmsg,79, "FITSRTHEAD: cannot read %d x %d table\n", + *nrows,*nchar); + return (-1); + } + +/* Set up table for access to individual fields */ + nfields = 0; + hgeti4 (header,"TFIELDS",&nfields); + if (verbose) + fprintf (stderr, "FITSRTHEAD: %d fields per table entry\n", nfields); + if (nfields > bfields) { + if (bfields > 0) + free ((void *)pw); + pw = (struct Keyword *) calloc (nfields, sizeof(struct Keyword)); + if (pw == NULL) { + snprintf (fitserrmsg,79,"FITSRTHEAD: cannot allocate table structure\n"); + return (-1); + } + if (bfields > 0) + free ((void *)lpnam); + lpnam = (int *) calloc (nfields, sizeof(int)); + if (lpnam == NULL) { + snprintf (fitserrmsg,79,"FITSRTHEAD: cannot allocate length structure\n"); + return (-1); + } + bfields = nfields; + } + + tverb = verbose; + verbose = 0; + ikf = 0; + + for (ifield = 0; ifield < nfields; ifield++) { + + /* Name of field */ + for (i = 0; i < 12; i++) tname[i] = 0; + sprintf (tname, "TTYPE%d", ifield+1);; + temp[0] = 0; + h1 = ksearch (h0,tname); + h0 = h1; + hgets (h0,tname,16,temp); + strcpy (pw[ifield].kname,temp); + pw[ifield].lname = strlen (pw[ifield].kname); + + /* Sequence of field on line */ + pw[ifield].kn = ifield + 1; + + /* First column of field */ + if (bintable) + pw[ifield].kf = ikf; + else { + for (i = 0; i < 12; i++) tname[i] = 0; + sprintf (tname, "TBCOL%d", ifield+1); + pw[ifield].kf = 0; + hgeti4 (h0,tname, &pw[ifield].kf); + } + + /* Length of field */ + for (i = 0; i < 12; i++) tname[i] = 0; + sprintf (tname, "TFORM%d", ifield+1);; + tform[0] = 0; + hgets (h0,tname,16,tform); + strcpy (pw[ifield].kform, tform); + ltform = strlen (tform); + if (tform[ltform-1] == 'A') { + pw[ifield].kform[0] = 'A'; + for (i = 0; i < ltform-1; i++) + pw[ifield].kform[i+1] = tform[i]; + pw[ifield].kform[ltform] = (char) 0; + tf1 = pw[ifield].kform + 1; + kl = atof (tf1); + } + else if (!strcmp (tform,"I")) + kl = 2; + else if (!strcmp (tform, "J")) + kl = 4; + else if (!strcmp (tform, "E")) + kl = 4; + else if (!strcmp (tform, "D")) + kl = 8; + else { + tf1 = tform + 1; + tf2 = strchr (tform,'.'); + if (tf2 != NULL) + *tf2 = ' '; + kl = atoi (tf1); + } + pw[ifield].kl = kl; + ikf = ikf + kl; + } + +/* Set up table for access to desired fields */ + verbose = tverb; + if (verbose) + fprintf (stderr, "FITSRTHEAD: %d keywords read\n", *nk); + +/* If nk = 0, allocate and return structures for all table fields */ + if (*nk <= 0) { + *kw = pw; + *nk = nfields; + return (0); + } + else + rw = *kw; + +/* Find each desired keyword in the header */ + for (ik = 0; ik < *nk; ik++) { + if (rw[ik].kn <= 0) { + for (ifield = 0; ifield < nfields; ifield++) { + if (rw[ik].lname != pw[ifield].lname) + continue; + if (strcmp (pw[ifield].kname, rw[ik].kname) == 0) { + break; + } + } + } + else + ifield = rw[ik].kn - 1; + +/* Set pointer, lentth, and name in returned array of structures */ + rw[ik].kn = ifield + 1; + rw[ik].kf = pw[ifield].kf - 1; + rw[ik].kl = pw[ifield].kl; + strcpy (rw[ik].kform, pw[ifield].kform); + strcpy (rw[ik].kname, pw[ifield].kname); + } + + return (0); +} + + +int +fitsrtline (fd, nbhead, lbuff, tbuff, irow, nbline, line) + +int fd; /* File descriptor for FITS file */ +int nbhead; /* Number of bytes in FITS header */ +int lbuff; /* Number of bytes in table buffer */ +char *tbuff; /* FITS table buffer */ +int irow; /* Number of table row to read */ +int nbline; /* Number of bytes to read for this line */ +char *line; /* One line of FITS table (returned) */ + +{ + int nbuff, nlbuff; + int nbr = 0; + int offset, offend, ntry, ioff; + char *tbuff1; + + offset = nbhead + (nbline * irow); + offend = offset + nbline - 1; + +/* Read a new buffer of the FITS table into memory if needed */ + if (offset < offset1 || offend > offset2) { + nlbuff = lbuff / nbline; + nbuff = nlbuff * nbline; + for (ntry = 0; ntry < 3; ntry++) { + ioff = lseek (fd, offset, SEEK_SET); + if (ioff < offset) { + if (ntry == 2) + return (0); + else + continue; + } + nbr = read (fd, tbuff, nbuff); + if (nbr < nbline) { + if (verbose) + fprintf (stderr, "FITSRTLINE: %d / %d bytes read %d\n", + nbr,nbuff,ntry); + if (ntry == 2) + return (nbr); + } + else + break; + } + offset1 = offset; + offset2 = offset + nbr - 1; + strncpy (line, tbuff, nbline); + return (nbline); + } + else { + tbuff1 = tbuff + (offset - offset1); + strncpy (line, tbuff1, nbline); + return (nbline); + } +} + + +void +fitsrtlset () +{ + offset1 = 0; + offset2 = 0; + return; +} + + +/* FTGETI2 -- Extract n'th column from FITS table line as short */ + +short +ftgeti2 (entry, kw) + +char *entry; /* Row or entry from table */ +struct Keyword *kw; /* Table column information from FITS header */ +{ + char temp[30]; + short i; + int j; + float r; + double d; + + if (ftgetc (entry, kw, temp, 30)) { + if (!strcmp (kw->kform, "I")) + moveb (temp, (char *) &i, 2, 0, 0); + else if (!strcmp (kw->kform, "J")) { + moveb (temp, (char *) &j, 4, 0, 0); + i = (short) j; + } + else if (!strcmp (kw->kform, "E")) { + moveb (temp, (char *) &r, 4, 0, 0); + i = (short) r; + } + else if (!strcmp (kw->kform, "D")) { + moveb (temp, (char *) &d, 8, 0, 0); + i = (short) d; + } + else + i = (short) atof (temp); + return (i); + } + else + return ((short) 0); +} + + +/* FTGETI4 -- Extract n'th column from FITS table line as int */ + +int +ftgeti4 (entry, kw) + +char *entry; /* Row or entry from table */ +struct Keyword *kw; /* Table column information from FITS header */ +{ + char temp[30]; + short i; + int j; + float r; + double d; + + if (ftgetc (entry, kw, temp, 30)) { + if (!strcmp (kw->kform, "I")) { + moveb (temp, (char *) &i, 2, 0, 0); + j = (int) i; + } + else if (!strcmp (kw->kform, "J")) + moveb (temp, (char *) &j, 4, 0, 0); + else if (!strcmp (kw->kform, "E")) { + moveb (temp, (char *) &r, 4, 0, 0); + j = (int) r; + } + else if (!strcmp (kw->kform, "D")) { + moveb (temp, (char *) &d, 8, 0, 0); + j = (int) d; + } + else + j = (int) atof (temp); + return (j); + } + else + return (0); +} + + +/* FTGETR4 -- Extract n'th column from FITS table line as float */ + +float +ftgetr4 (entry, kw) + +char *entry; /* Row or entry from table */ +struct Keyword *kw; /* Table column information from FITS header */ +{ + char temp[30]; + short i; + int j; + float r; + double d; + + if (ftgetc (entry, kw, temp, 30)) { + if (!strcmp (kw->kform, "I")) { + moveb (temp, (char *) &i, 2, 0, 0); + r = (float) i; + } + else if (!strcmp (kw->kform, "J")) { + moveb (temp, (char *) &j, 4, 0, 0); + r = (float) j; + } + else if (!strcmp (kw->kform, "E")) + moveb (temp, (char *) &r, 4, 0, 0); + else if (!strcmp (kw->kform, "D")) { + moveb (temp, (char *) &d, 8, 0, 0); + r = (float) d; + } + else + r = (float) atof (temp); + return (r); + } + else + return ((float) 0.0); +} + + +/* FTGETR8 -- Extract n'th column from FITS table line as double */ + +double +ftgetr8 (entry, kw) + +char *entry; /* Row or entry from table */ +struct Keyword *kw; /* Table column information from FITS header */ +{ + char temp[30]; + short i; + int j; + float r; + double d; + + if (ftgetc (entry, kw, temp, 30)) { + if (!strcmp (kw->kform, "I")) { + moveb (temp, (char *) &i, 2, 0, 0); + d = (double) i; + } + else if (!strcmp (kw->kform, "J")) { + moveb (temp, (char *) &j, 4, 0, 0); + d = (double) j; + } + else if (!strcmp (kw->kform, "E")) { + moveb (temp, (char *) &r, 4, 0, 0); + d = (double) r; + } + else if (!strcmp (kw->kform, "D")) + moveb (temp, (char *) &d, 8, 0, 0); + else + d = atof (temp); + return (d); + } + else + return ((double) 0.0); +} + + +/* FTGETC -- Extract n'th column from FITS table line as character string */ + +int +ftgetc (entry, kw, string, maxchar) + +char *entry; /* Row or entry from table */ +struct Keyword *kw; /* Table column information from FITS header */ +char *string; /* Returned string */ +int maxchar; /* Maximum number of characters in returned string */ +{ + int length = maxchar; + + if (kw->kl < length) + length = kw->kl; + if (length > 0) { + strncpy (string, entry+kw->kf, length); + string[length] = 0; + return ( 1 ); + } + else + return ( 0 ); +} + +extern int errno; + + +/*FITSWIMAGE -- Write FITS header and image */ + +int +fitswimage (filename, header, image) + +char *filename; /* Name of FITS image file */ +char *header; /* FITS image header */ +char *image; /* FITS image pixels */ + +{ + int fd; + + /* Open the output file */ + if (strcasecmp (filename,"stdout") ) { + + if (!access (filename, 0)) { + fd = open (filename, O_WRONLY); + if (fd < 3) { + snprintf (fitserrmsg,79, "FITSWIMAGE: file %s not writeable\n", filename); + return (0); + } + } + else { + fd = open (filename, O_RDWR+O_CREAT, 0666); + if (fd < 3) { + snprintf (fitserrmsg,79, "FITSWIMAGE: cannot create file %s\n", filename); + return (0); + } + } + } +#ifndef VMS + else + fd = STDOUT_FILENO; +#endif + + return (fitswhdu (fd, filename, header, image)); +} + + +/*FITSWEXT -- Write FITS header and image as extension to a file */ + +int +fitswext (filename, header, image) + +char *filename; /* Name of IFTS image file */ +char *header; /* FITS image header */ +char *image; /* FITS image pixels */ + +{ + int fd; + + /* Open the output file */ + if (strcasecmp (filename,"stdout") ) { + + if (!access (filename, 0)) { + fd = open (filename, O_WRONLY); + if (fd < 3) { + snprintf (fitserrmsg,79, "FITSWEXT: file %s not writeable\n", + filename); + return (0); + } + } + else { + fd = open (filename, O_APPEND, 0666); + if (fd < 3) { + snprintf (fitserrmsg,79, "FITSWEXT: cannot append to file %s\n", + filename); + return (0); + } + } + } +#ifndef VMS + else + fd = STDOUT_FILENO; +#endif + + return (fitswhdu (fd, filename, header, image)); +} + + +/* FITSWHDU -- Write FITS head and image as extension */ + +int +fitswhdu (fd, filename, header, image) + +int fd; /* File descriptor */ +char *filename; /* Name of IFTS image file */ +char *header; /* FITS image header */ +char *image; /* FITS image pixels */ +{ + int nbhead, nbimage, nblocks, bytepix, i, nbhw; + int bitpix, naxis, iaxis, naxisi, nbytes, nbw, nbpad, nbwp, simple; + char *endhead, *padding; + double bzero, bscale; + char keyword[32]; + + /* Change BITPIX=-16 files to BITPIX=16 with BZERO and BSCALE */ + bitpix = 0; + hgeti4 (header,"BITPIX",&bitpix); + if (bitpix == -16) { + if (!hgetr8 (header, "BZERO", &bzero) && + !hgetr8 (header, "BSCALE", &bscale)) { + bitpix = 16; + hputi4 (header, "BITPIX", bitpix); + hputr8 (header, "BZERO", 32768.0); + hputr8 (header, "BSCALE", 1.0); + } + } + + /* Write header to file */ + endhead = ksearch (header,"END") + 80; + nbhead = endhead - header; + nbhw = write (fd, header, nbhead); + if (nbhw < nbhead) { + snprintf (fitserrmsg,79, "FITSWHDU: wrote %d / %d bytes of header to file %s\n", + nbhw, nbhead, filename); + (void)close (fd); + return (0); + } + + /* Write extra spaces to make an integral number of 2880-byte blocks */ + nblocks = nbhead / FITSBLOCK; + if (nblocks * FITSBLOCK < nbhead) + nblocks = nblocks + 1; + nbytes = nblocks * FITSBLOCK; + nbpad = nbytes - nbhead; + padding = (char *)calloc (1, nbpad); + for (i = 0; i < nbpad; i++) + padding[i] = ' '; + nbwp = write (fd, padding, nbpad); + if (nbwp < nbpad) { + snprintf (fitserrmsg,79, "FITSWHDU: wrote %d / %d bytes of header padding to file %s\n", + nbwp, nbpad, filename); + (void)close (fd); + return (0); + } + nbhw = nbhw + nbwp; + free (padding); + + /* Return if file has no data */ + if (bitpix == 0 || image == NULL) { + /* snprintf (fitserrmsg,79, "FITSWHDU: BITPIX is 0; image not written\n"); */ + (void)close (fd); + return (0); + } + + /* If SIMPLE=F in header, just write whatever is in the buffer */ + hgetl (header, "SIMPLE", &simple); + if (!simple) { + hgeti4 (header, "NBDATA", &nbytes); + nbimage = nbytes; + } + + else { + + /* Compute size of pixel in bytes */ + bytepix = bitpix / 8; + if (bytepix < 0) bytepix = -bytepix; + nbimage = bytepix; + + /* Compute size of image in bytes using relevant header parameters */ + naxis = 1; + hgeti4 (header,"NAXIS",&naxis); + for (iaxis = 1; iaxis <= naxis; iaxis++) { + sprintf (keyword, "NAXIS%d", iaxis); + naxisi = 1; + hgeti4 (header,keyword,&naxisi); + nbimage = nbimage * naxisi; + } + + /* Number of bytes to write is an integral number of FITS blocks */ + nblocks = nbimage / FITSBLOCK; + if (nblocks * FITSBLOCK < nbimage) + nblocks = nblocks + 1; + nbytes = nblocks * FITSBLOCK; + + /* Byte-reverse image before writing, if necessary */ + if (imswapped ()) + imswap (bitpix, image, nbimage); + } + + /* Write image to file */ + nbw = write (fd, image, nbimage); + if (nbw < nbimage) { + snprintf (fitserrmsg,79, "FITSWHDU: wrote %d / %d bytes of image to file %s\n", + nbw, nbimage, filename); + return (0); + } + + /* Write extra zeroes to make an integral number of 2880-byte blocks */ + nbpad = nbytes - nbimage; + if (nbpad > 0) { + padding = (char *)calloc (1, nbpad); + nbwp = write (fd, padding, nbpad); + if (nbwp < nbpad) { + snprintf (fitserrmsg,79, "FITSWHDU: wrote %d / %d bytes of image padding to file %s\n", + nbwp, nbpad, filename); + (void)close (fd); + return (0); + } + free (padding); + } + else + nbwp = 0; + + (void)close (fd); + + /* Byte-reverse image after writing, if necessary */ + if (imswapped ()) + imswap (bitpix, image, nbimage); + + nbw = nbw + nbwp + nbhw; + return (nbw); +} + + +/*FITSCIMAGE -- Write FITS header and copy FITS image + Return number of bytes in output image, 0 if failure */ + +int +fitscimage (filename, header, filename0) + +char *filename; /* Name of output FITS image file */ +char *header; /* FITS image header */ +char *filename0; /* Name of input FITS image file */ + +{ + int fdout, fdin; + int nbhead, nbimage, nblocks, bytepix; + int bitpix, naxis, naxis1, naxis2, nbytes, nbw, nbpad, nbwp; + char *endhead, *lasthead, *padding; + char *image; /* FITS image pixels */ + char *oldhead; /* Input file image header */ + int nbhead0; /* Length of input file image header */ + int lhead0; + int nbbuff, nbuff, ibuff, nbr, nbdata; + + /* Compute size of image in bytes using relevant header parameters */ + naxis = 1; + hgeti4 (header, "NAXIS", &naxis); + naxis1 = 1; + hgeti4 (header, "NAXIS1", &naxis1); + naxis2 = 1; + hgeti4 (header, "NAXIS2", &naxis2); + hgeti4 (header, "BITPIX", &bitpix); + bytepix = bitpix / 8; + if (bytepix < 0) bytepix = -bytepix; + + /* If either dimension is one and image is 3-D, read all three dimensions */ + if (naxis == 3 && (naxis1 ==1 || naxis2 == 1)) { + int naxis3; + hgeti4 (header,"NAXIS3",&naxis3); + nbimage = naxis1 * naxis2 * naxis3 * bytepix; + } + else + nbimage = naxis1 * naxis2 * bytepix; + + nblocks = nbimage / FITSBLOCK; + if (nblocks * FITSBLOCK < nbimage) + nblocks = nblocks + 1; + nbytes = nblocks * FITSBLOCK; + + /* Allocate image buffer */ + nbbuff = FITSBLOCK * 100; + if (nbytes < nbbuff) + nbbuff = nbytes; + image = (char *) calloc (1, nbbuff); + nbuff = nbytes / nbbuff; + if (nbytes > nbuff * nbbuff) + nbuff = nbuff + 1; + + /* Read input file header */ + if ((oldhead = fitsrhead (filename0, &lhead0, &nbhead0)) == NULL) { + snprintf (fitserrmsg, 79,"FITSCIMAGE: header of input file %s cannot be read\n", + filename0); + return (0); + } + + /* Find size of output header */ + nbhead = fitsheadsize (header); + + /* If overwriting, be more careful if new header is longer than old */ + if (!strcmp (filename, filename0) && nbhead > nbhead0) { + if ((image = fitsrimage (filename0, nbhead0, oldhead)) == NULL) { + snprintf (fitserrmsg,79, "FITSCIMAGE: cannot read image from file %s\n", + filename0); + free (oldhead); + return (0); + } + return (fitswimage (filename, header, image)); + } + free (oldhead); + + /* Open the input file and skip over the header */ + if (strcasecmp (filename0,"stdin")) { + fdin = -1; + fdin = fitsropen (filename0); + if (fdin < 0) { + snprintf (fitserrmsg, 79,"FITSCIMAGE: cannot read file %s\n", filename0); + return (0); + } + + /* Skip over FITS header */ + if (lseek (fdin, nbhead0, SEEK_SET) < 0) { + (void)close (fdin); + snprintf (fitserrmsg,79, "FITSCIMAGE: cannot skip header of file %s\n", + filename0); + return (0); + } + } +#ifndef VMS + else + fdin = STDIN_FILENO; +#endif + + /* Open the output file */ + if (!access (filename, 0)) { + fdout = open (filename, O_WRONLY); + if (fdout < 3) { + snprintf (fitserrmsg,79, "FITSCIMAGE: file %s not writeable\n", filename); + return (0); + } + } + else { + fdout = open (filename, O_RDWR+O_CREAT, 0666); + if (fdout < 3) { + snprintf (fitserrmsg,79, "FITSCHEAD: cannot create file %s\n", filename); + return (0); + } + } + + /* Pad header with spaces */ + endhead = ksearch (header,"END") + 80; + lasthead = header + nbhead; + while (endhead < lasthead) + *(endhead++) = ' '; + + /* Write header to file */ + nbw = write (fdout, header, nbhead); + if (nbw < nbhead) { + snprintf (fitserrmsg, 79,"FITSCIMAGE: wrote %d / %d bytes of header to file %s\n", + nbw, nbytes, filename); + (void)close (fdout); + (void)close (fdin); + return (0); + } + + /* Return if no data */ + if (bitpix == 0) { + (void)close (fdout); + (void)close (fdin); + return (nbhead); + } + + nbdata = 0; + for (ibuff = 0; ibuff < nbuff; ibuff++) { + nbr = read (fdin, image, nbbuff); + if (nbr > 0) { + nbw = write (fdout, image, nbr); + nbdata = nbdata + nbw; + } + } + + /* Write extra to make integral number of 2880-byte blocks */ + nblocks = nbdata / FITSBLOCK; + if (nblocks * FITSBLOCK < nbdata) + nblocks = nblocks + 1; + nbytes = nblocks * FITSBLOCK; + nbpad = nbytes - nbdata; + padding = (char *)calloc (1,nbpad); + nbwp = write (fdout, padding, nbpad); + nbw = nbdata + nbwp; + free (padding); + + (void)close (fdout); + (void)close (fdin); + + if (nbw < nbimage) { + snprintf (fitserrmsg, 79, "FITSWIMAGE: wrote %d / %d bytes of image to file %s\n", + nbw, nbimage, filename); + return (0); + } + else + return (nbw); +} + + +/* FITSWHEAD -- Write FITS header and keep file open for further writing */ + +int +fitswhead (filename, header) + +char *filename; /* Name of IFTS image file */ +char *header; /* FITS image header */ + +{ + int fd; + int nbhead, nblocks; + int nbytes, nbw; + char *endhead, *lasthead; + + /* Open the output file */ + if (!access (filename, 0)) { + fd = open (filename, O_WRONLY); + if (fd < 3) { + snprintf (fitserrmsg, 79, "FITSWHEAD: file %s not writeable\n", filename); + return (0); + } + } + else { + fd = open (filename, O_RDWR+O_CREAT, 0666); + if (fd < 3) { + snprintf (fitserrmsg, 79, "FITSWHEAD: cannot create file %s\n", filename); + return (0); + } + } + + /* Write header to file */ + endhead = ksearch (header,"END") + 80; + nbhead = endhead - header; + nblocks = nbhead / FITSBLOCK; + if (nblocks * FITSBLOCK < nbhead) + nblocks = nblocks + 1; + nbytes = nblocks * FITSBLOCK; + + /* Pad header with spaces */ + lasthead = header + nbytes; + while (endhead < lasthead) + *(endhead++) = ' '; + + nbw = write (fd, header, nbytes); + if (nbw < nbytes) { + fprintf (stderr, "FITSWHEAD: wrote %d / %d bytes of header to file %s\n", + nbw, nbytes, filename); + (void)close (fd); + return (0); + } + return (fd); +} + + +/* FITSWEXHEAD -- Write FITS header in place */ + +int +fitswexhead (filename, header) + +char *filename; /* Name of FITS image file with ,extension */ +char *header; /* FITS image header */ + +{ + int fd; + int nbhead, lhead; + int nbw, nbnew, nbold; + char *endhead, *lasthead, *oldheader; + char *ext, cext; + + /* Compare size of existing header to size of new header */ + fitsinherit = 0; + oldheader = fitsrhead (filename, &lhead, &nbhead); + if (oldheader == NULL) { + snprintf (fitserrmsg, 79, "FITSWEXHEAD: file %s cannot be read\n", filename); + return (-1); + } + nbold = fitsheadsize (oldheader); + nbnew = fitsheadsize (header); + + /* Return if the new header is bigger than the old header */ + if (nbnew > nbold) { + snprintf (fitserrmsg, 79, "FITSWEXHEAD: old header %d bytes, new header %d bytes\n", nbold,nbnew); + free (oldheader); + oldheader = NULL; + return (-1); + } + + /* Add blank lines if new header is smaller than the old header */ + else if (nbnew < nbold) { + strcpy (oldheader, header); + endhead = ksearch (oldheader,"END"); + lasthead = oldheader + nbold; + while (endhead < lasthead) + *(endhead++) = ' '; + strncpy (lasthead-80, "END", 3); + } + + /* Pad header with spaces */ + else { + endhead = ksearch (header,"END") + 80; + lasthead = header + nbnew; + while (endhead < lasthead) + *(endhead++) = ' '; + strncpy (oldheader, header, nbnew); + } + + /* Check for FITS extension and ignore for file opening */ + ext = strchr (filename, ','); + if (ext == NULL) + ext = strchr (filename, '['); + if (ext != NULL) { + cext = *ext; + *ext = (char) 0; + } + + /* Open the output file */ + fd = open (filename, O_WRONLY); + if (ext != NULL) + *ext = cext; + if (fd < 3) { + snprintf (fitserrmsg, 79, "FITSWEXHEAD: file %s not writeable\n", filename); + return (-1); + } + + /* Skip to appropriate place in file */ + (void) lseek (fd, ibhead, SEEK_SET); + + /* Write header to file */ + nbw = write (fd, oldheader, nbold); + (void)close (fd); + free (oldheader); + oldheader = NULL; + if (nbw < nbold) { + fprintf (stderr, "FITSWHEAD: wrote %d / %d bytes of header to file %s\n", + nbw, nbold, filename); + return (-1); + } + return (0); +} + + +/* ISFITS -- Return 1 if FITS file, else 0 */ +int +isfits (filename) + +char *filename; /* Name of file for which to find size */ +{ + int diskfile; + char keyword[16]; + char *comma; + int nbr; + + /* First check to see if this is an assignment */ + if (strchr (filename, '=')) + return (0); + + /* Check for stdin (input from pipe) */ + else if (!strcasecmp (filename,"stdin")) + return (1); + + /* Then check file extension + else if (strsrch (filename, ".fit") || + strsrch (filename, ".fits") || + strsrch (filename, ".fts")) + return (1); */ + + /* If no FITS file extension, try opening the file */ + else { + if ((comma = strchr (filename,','))) + *comma = (char) 0; + if ((diskfile = open (filename, O_RDONLY)) < 0) { + if (comma) + *comma = ','; + return (0); + } + else { + nbr = read (diskfile, keyword, 8); + if (comma) + *comma = ','; + close (diskfile); + if (nbr < 8) + return (0); + else if (!strncmp (keyword, "SIMPLE", 6)) + return (1); + else + return (0); + } + } +} + + +/* FITSHEADSIZE -- Find size of FITS header */ + +int +fitsheadsize (header) + +char *header; /* FITS header */ +{ + char *endhead; + int nbhead, nblocks; + + endhead = ksearch (header,"END") + 80; + nbhead = endhead - header; + nblocks = nbhead / FITSBLOCK; + if (nblocks * FITSBLOCK < nbhead) + nblocks = nblocks + 1; + return (nblocks * FITSBLOCK); +} + + +/* Print error message */ +void +fitserr () +{ fprintf (stderr, "%s\n",fitserrmsg); + return; } + + +/* MOVEB -- Copy nbytes bytes from source+offs to dest+offd (any data type) */ + +void +moveb (source, dest, nbytes, offs, offd) + +char *source; /* Pointer to source */ +char *dest; /* Pointer to destination */ +int nbytes; /* Number of bytes to move */ +int offs; /* Offset in bytes in source from which to start copying */ +int offd; /* Offset in bytes in destination to which to start copying */ +{ +char *from, *last, *to; + from = source + offs; + to = dest + offd; + last = from + nbytes; + while (from < last) *(to++) = *(from++); + return; +} + +/* + * Feb 8 1996 New subroutines + * Apr 10 1996 Add subroutine list at start of file + * Apr 17 1996 Print error message to stderr + * May 2 1996 Write using stream IO + * May 14 1996 If FITSRTOPEN NK is zero, return all keywords in header + * May 17 1996 Make header internal to FITSRTOPEN + * Jun 3 1996 Use stream I/O for input as well as output + * Jun 10 1996 Remove unused variables after running lint + * Jun 12 1996 Deal with byte-swapped images + * Jul 11 1996 Rewrite code to separate header and data reading + * Aug 6 1996 Fixed small defects after lint + * Aug 6 1996 Drop unused NBHEAD argument from FITSRTHEAD + * Aug 13 1996 If filename is stdin, read from standard input instead of file + * Aug 30 1996 Use write for output, not fwrite + * Sep 4 1996 Fix mode when file is created + * Oct 15 1996 Drop column argument from FGET* subroutines + * Oct 15 1996 Drop unused variable + * Dec 17 1996 Add option to skip bytes in file before reading the header + * Dec 27 1996 Turn nonprinting header characters into spaces + * + * Oct 9 1997 Add FITS extension support as filename,extension + * Dec 15 1997 Fix minor bugs after lint + * + * Feb 23 1998 Do not append primary header if getting header for ext. 0 + * Feb 23 1998 Accept either bracketed or comma extension + * Feb 24 1998 Add SIMPLE keyword to start of extracted extension + * Apr 30 1998 Fix error return if not table file after Allan Brighton + * May 4 1998 Fix error in argument sequence in HGETS call + * May 27 1998 Include fitsio.h and imio.h + * Jun 1 1998 Add VMS fixes from Harry Payne at STScI + * Jun 3 1998 Fix bug reading EXTNAME + * Jun 11 1998 Initialize all header parameters before reading them + * Jul 13 1998 Clarify argument definitions + * Aug 6 1998 Rename fitsio.c to fitsfile.c to avoid conflict with CFITSIO + * Aug 13 1998 Add FITSWHEAD to write only header + * Sep 25 1998 Allow STDIN or stdin for standard input reading + * Oct 5 1998 Add isfits() to decide whether a file is FITS + * Oct 9 1998 Assume stdin and STDIN to be FITS files in isfits() + * Nov 30 1998 Fix bug found by Andreas Wicenec when reading large headers + * Dec 8 1998 Fix bug introduced by previous bug fix + * + * Jan 4 1999 Do not print error message if BITPIX is 0 + * Jan 27 1999 Read and write all of 3D images if one dimension is 1 + * Jan 27 1999 Pad out data to integral number of 2880-byte blocks + * Apr 29 1999 Write BITPIX=-16 files as BITPIX=16 with BSCALE and BZERO + * Apr 30 1999 Add % as alternative to , to denote sub-images + * May 25 1999 Set buffer offsets to 0 when FITS table file is opened + * Jul 14 1999 Do not try to write image data if BITPIX is 0 + * Sep 27 1999 Add STDOUT as output filename option in fitswimage() + * Oct 6 1999 Set header length global variable hget.lhead0 in fitsrhead() + * Oct 14 1999 Update header length as it is changed in fitsrhead() + * Oct 20 1999 Change | in if statements to || + * Oct 25 1999 Change most malloc() calls to calloc() + * Nov 24 1999 Add fitscimage() + * + * Feb 23 2000 Fix problem with some error returns in fitscimage() + * Mar 17 2000 Drop unused variables after lint + * Jul 20 2000 Drop BITPIX and NAXIS from primary header if extension printerd + * Jul 20 2000 Start primary part of header with ROOTHEAD keyword + * Jul 28 2000 Add loop to deal with buffered stdin + * + * Jan 11 2001 Print all messages to stderr + * Jan 12 2001 Add extension back onto filename after fitsropen() (Guy Rixon) + * Jan 18 2001 Drop EXTEND keyword when extracting an extension + * Jan 18 2001 Add fitswext() to append HDU and fitswhdu() to do actual writing + * Jan 22 2001 Ignore WCS name or letter following a : in file name in fitsrhead() + * Jan 30 2001 Fix FITSCIMAGE so it doesn't overwrite data when overwriting a file + * Feb 20 2001 Ignore WCS name or letter following a : in file name in fitsropen() + * Feb 23 2001 Initialize rbrac in fitsropen() + * Mar 8 2001 Use % instead of : for WCS specification in file name + * Mar 9 2001 Fix bug so primary header is always appended to secondary header + * Mar 9 2001 Change NEXTEND to NUMEXT in appended primary header + * Mar 20 2001 Declare fitsheadsize() in fitschead() + * Apr 24 2001 When matching column names, use longest length + * Jun 27 2001 In fitsrthead(), allocate pw and lpnam only if more space needed + * Aug 24 2001 In isfits(), return 0 if argument contains an equal sign + * + * Jan 28 2002 In fitsrhead(), allow stdin to include extension and/or WCS selection + * Jun 18 2002 Save error messages as fitserrmsg and use fitserr() to print them + * Oct 21 2002 Add fitsrsect() to read a section of an image + * + * Feb 4 2003 Open catalog file rb instead of r (Martin Ploner, Bern) + * Apr 2 2003 Drop unused variable in fitsrsect() + * Jul 11 2003 Use strcasecmp() to check for stdout and stdin + * Aug 1 2003 If no other header, return root header from fitsrhead() + * Aug 20 2003 Add fitsrfull() to read n-dimensional FITS images + * Aug 21 2003 Modify fitswimage() to always write n-dimensional FITS images + * Nov 18 2003 Fix minor bug in fitswhdu() + * Dec 3 2003 Remove unused variable lasthead in fitswhdu() + * + * May 3 2004 Do not always append primary header to extension header + * May 3 2004 Add ibhead as position of header read in file + * May 19 2004 Do not reset ext if NULL in fitswexhead() + * Jul 1 2004 Initialize INHERIT to 1 + * Aug 30 2004 Move fitsheadsize() declaration to fitsfile.h + * Aug 31 2004 If SIMPLE=F, put whatever is in file after header in image + * + * Mar 17 2005 Use unbuffered I/O in isfits() for robustness + * Jun 27 2005 Drop unused variable nblocks in fitswexhead() + * Aug 8 2005 Fix space-padding bug in fitswexhead() found by Armin Rest + * Sep 30 2005 Fix fitsrsect() to position relatively, not absolutely + * Oct 28 2005 Add error message if desired FITS extension is not found + * Oct 28 2005 Fix initialization problem found by Sergey Koposov + * + * Feb 23 2006 Add fitsrtail() to read appended FITS headers + * Feb 27 2006 Add file name to header-reading error messages + * May 3 2006 Remove declarations of unused variables + * Jun 20 2006 Initialize uninitialized variables + * Nov 2 2006 Change all realloc() calls to calloc() + * + * Jan 5 2007 In fitsrtail(), change control characters in header to spaces + * Apr 30 2007 Improve error reporting in FITSRFULL + * Nov 28 2007 Add support to BINTABLE in ftget*() and fitsrthead() + * Dec 20 2007 Add data heap numerated by PCOUNT when skipping HDU in fitsrhead() + * Dec 20 2007 Return NULL pointer if fitsrhead() cannot find requested HDU + * + * Apr 7 2008 Drop comma from name when reading file in isfits() + * Jun 27 2008 Do not append primary data header if it is the only header + * Nov 21 2008 In fitswhead(), print message if too few bytes written + * + * Sep 18 2009 In fitswexhead() write to error string instead of stderr + * Sep 22 2009 In fitsrthead(), fix lengths for ASCII numeric table entries + * Sep 25 2009 Add subroutine moveb() and fix calls to it + * Sep 25 2009 Fix several small errors found by Jessicalas Burke + * + * Mar 29 2010 In fitswhead(), always pad blocks to 2880 bytes with spaces + * Mar 31 2010 In fitsrhead(), fix bug reading long primary headers + * + * Sep 15 2011 In fitsrsect() declare impos and nblin off_t + * Sep 15 2011 In fitsrtail() declare offset off_t + * Sep 15 2011 Declare global variable ibhead off_t + * + * Jul 25 2014 Fix bug when reallocating buffer for long headers + */ diff --git a/tksao/wcssubs/fitsfile.h b/tksao/wcssubs/fitsfile.h new file mode 100644 index 0000000..cd67f37 --- /dev/null +++ b/tksao/wcssubs/fitsfile.h @@ -0,0 +1,1293 @@ +/*** File fitsfile.h FITS and IRAF file access subroutines + *** June 20, 2014 + *** By Jessica Mink, jmink@cfa.harvard.edu + *** Harvard-Smithsonian Center for Astrophysics + *** Copyright (C) 1996-2014 + *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Correspondence concerning WCSTools should be addressed as follows: + Internet email: jmink@cfa.harvard.edu + Postal address: Jessica Mink + Smithsonian Astrophysical Observatory + 60 Garden St. + Cambridge, MA 02138 USA + */ + +#ifndef fitsfile_h_ +#define fitsfile_h_ +#include "fitshead.h" + +/* Declarations for subroutines in fitsfile.c, imhfile.c, imio.c, + * fileutil.c, and dateutil.c */ + +#define FITSBLOCK 2880 + +/* FITS table keyword structure */ +struct Keyword { + char kname[10]; /* Keyword for table entry */ + int lname; /* Length of keyword name */ + int kn; /* Index of entry on line */ + int kf; /* Index in line of first character of entry */ + int kl; /* Length of entry value */ + char kform[8]; /* Format for this value */ +}; + +/* Structure for access to tokens within a string */ +#define MAXTOKENS 1000 /* Maximum number of tokens to parse */ +#define MAXWHITE 20 /* Maximum number of different whitespace characters */ +struct Tokens { + char *line; /* Line which has been parsed */ + int lline; /* Number of characters in line */ + int ntok; /* Number of tokens on line */ + int nwhite; /* Number of whitespace characters */ + char white[MAXWHITE]; /* Whitespace (separator) characters */ + char *tok1[MAXTOKENS]; /* Pointers to start of tokens */ + int ltok[MAXTOKENS]; /* Lengths of tokens */ + int itok; /* Current token number */ +}; + +#ifdef __cplusplus /* C++ prototypes */ +extern "C" { +#endif + + +#ifdef __STDC__ /* Full ANSI prototypes */ + +/* Declarations for subroutines in fitsfile.c, imhfile.c, imio.c, + * fileutil.c, and dateutil.c */ + +/* FITS file access subroutines in fitsfile.c */ + int fitsropen( /* Open a FITS file for reading, returning a FILE pointer */ + char *inpath); /* Pathname for FITS tables file to read */ + char *fitsrhead( /* Read a FITS header */ + char *filename, /* Name of FITS image file */ + int *lhead, /* Allocated length of FITS header in bytes (returned) */ + int *nbhead); /* Number of bytes before start of data (returned) */ + char *fitsrtail( /* Read FITS header appended to graphics file */ + char *filename, /* Name of FITS image file */ + int *lhead, /* Allocated length of FITS header in bytes (returned) */ + int *nbhead); /* Number of bytes before start of data (returned) */ + char *fitsrimage( /* Read a FITS image */ + char *filename, /* Name of FITS image file */ + int nbhead, /* Actual length of image header(s) in bytes */ + char *header); /* FITS header for image (previously read) */ + char *fitsrfull( /* Read a FITS image of any dimension */ + char *filename, /* Name of FITS image file */ + int nbhead, /* Actual length of image header(s) in bytes */ + char *header); /* FITS header for image (previously read) */ + char *fitsrsect( /* Read a piece of a FITS image, header */ + char *filename, /* Name of FITS image file */ + char *header, /* FITS header for image (previously read) */ + int nbhead, /* Actual length of image header(s) in bytes */ + int x0, /* FITS image X coordinate of first pixel */ + int y0, /* FITS image Y coordinate of first pixel */ + int nx, /* Number of columns to read (less than NAXIS1) */ + int ny, /* Number of rows to read (less than NAXIS2) */ + int nlog); /* Note progress mod this rows */ + int fitswhead( /* Write FITS header; keep file open for further writing */ + char *filename, /* Name of FITS image file */ + char *header); /* FITS header for image (previously read) */ + int fitswexhead( /* Write FITS header in place */ + char *filename, /* Name of FITS image file */ + char *header); /* FITS header for image */ + int fitswext( /* Write FITS header and image as extension to a file */ + char *filename, /* Name of FITS image file */ + char *header, /* FITS image header */ + char *image); /* FITS image pixels */ + int fitswhdu( /* Write FITS head and image as extension */ + int fd, /* File descriptor */ + char *filename, /* Name of FITS image file */ + char *header, /* FITS image header */ + char *image); /* FITS image pixels */ + int fitswimage( /* Write FITS header and image */ + char *filename, /* Name of FITS image file */ + char *header, /* FITS image header */ + char *image); /* FITS image pixels */ + int fitscimage( /* Write FITS header and copy FITS image */ + char *filename, /* Name of output FITS image file */ + char *header, /* FITS image header */ + char *filename0); /* Name of input FITS image file */ + int isfits( /* Return 1 if file is a FITS file */ + char *filename); /* Name of file to check */ + void fitserr(); /* Print FITS error message to stderr */ + void setfitsinherit( /* Set flag to append primary data header */ + int inh); /* 1 to inherit primary data header, else 0 */ + int fitsheadsize( /* Return size of fitsheader in bytes */ + char *header); /* FITS image header */ + +/* FITS table file access subroutines in fitsfile.c */ + + int fitsrtopen( /* Open FITS table file and fill structure with + * pointers to selected keywords + * Return file descriptor (-1 if unsuccessful) */ + char *inpath, /* Pathname for FITS tables file to read */ + int *nk, /* Number of keywords to use */ + struct Keyword **kw, /* Structure for desired entries */ + int *nrows, /* Number of rows in table (returned) */ + int *nchar, /* Number of characters in one table row (returned) */ + int *nbhead); /* Number of characters before table starts */ + int fitsrthead( /* Read pointers to selected keywords + * from FITS table header */ + char *header, /* Header for FITS tables file */ + int *nk, /* Number of keywords to use */ + struct Keyword **kw, /* Structure for desired entries */ + int *nrows, /* Number of rows in table (returned) */ + int *nchar); /* Number of characters in one table row (returned) */ + void fitsrtlset(void); /* Reset FITS Table buffer limits from start of data */ + int fitsrtline( /* Return specified line of FITS table */ + int fd, /* File descriptor for FITS file */ + int nbhead, /* Number of bytes in FITS header */ + int lbuff, /* Number of bytes in table buffer */ + char *tbuff, /* FITS table buffer */ + int irow, /* Number of table row to read */ + int nbline, /* Number of bytes to read for this line */ + char *line); /* One line of FITS table (returned) */ +short ftgeti2( /* Extract column for keyword from FITS table line + * as short */ + char *entry, /* Row or entry from table */ + struct Keyword *kw); /* Table column information from FITS header */ + int ftgeti4( /* Extract column for keyword from FITS table line + * as int */ + char *entry, /* Row or entry from table */ + struct Keyword *kw); /* Table column information from FITS header */ +float ftgetr4( /* Extract column for keyword from FITS table line + * as float */ + char *entry, /* Row or entry from table */ + struct Keyword *kw); /* Table column information from FITS header */ + double ftgetr8( /* Extract column for keyword from FITS table line + * as double */ + char *entry, /* Row or entry from table */ + struct Keyword *kw); /* Table column information from FITS header */ + int ftgetc( /* Extract column for keyword from FITS table line + * as char string */ + char *entry, /* Row or entry from table */ + struct Keyword *kw, /* Table column information from FITS header */ + char *string, /* Returned string */ + int maxchar); /* Maximum number of characters in returned string */ + + void moveb ( /* Copy nbytes bytes from source+offs to dest+offd */ + char *source, /* Pointer to source */ + char *dest, /* Pointer to destination */ + int nbytes, /* Number of bytes to move */ + int offs, /* Offset in bytes in source from which to start copying */ + int offd); /* Offset in bytes in destination to which to start copying */ + + +/* IRAF file access subroutines in imhfile.c */ + + char *irafrhead( /* Read IRAF .imh header file and translate to FITS header */ + char *filename, /* Name of IRAF header file */ + int *lihead); /* Length of IRAF image header in bytes (returned) */ + char *irafrimage( /* Read IRAF image pixels (call after irafrhead) */ + char *fitsheader); /* FITS image header (filled) */ + int irafwhead( /* Write IRAF .imh header file */ + char *hdrname, /* Name of IRAF header file */ + int lhead, /* Length of IRAF header */ + char *irafheader, /* IRAF header */ + char *fitsheader); /* FITS image header */ + int irafwimage( /* Write IRAF .imh header file and .pix image file */ + char *hdrname, /* Name of IRAF header file */ + int lhead, /* Length of IRAF header */ + char *irafheader, /* IRAF header */ + char *fitsheader, /* FITS image header */ + char *image); /* IRAF image */ + int isiraf( /* return 1 if IRAF imh file, else 0 */ + char *filename); /* Name of file to check */ + char *iraf2fits( /* Convert IRAF image header to FITS image header, + * returning FITS header */ + char *hdrname, /* IRAF header file name (may be path) */ + char *irafheader, /* IRAF image header */ + int nbiraf, /* Number of bytes in IRAF header */ + int *nbfits); /* Number of bytes in FITS header (returned) */ + + char *fits2iraf( /* Convert FITS image header to IRAF image header, + * returning IRAF header */ + char *fitsheader, /* FITS image header */ + char *irafheader, /* IRAF image header (returned updated) */ + int nbhead, /* Length of IRAF header */ + int *nbiraf); /* Length of returned IRAF header */ + +/* Image pixel access subroutines in imio.c */ + + double getpix( /* Read one pixel from any data type 2-D array (0,0)*/ + char *image, /* Image array as 1-D vector */ + int bitpix, /* FITS bits per pixel + * 16 = short, -16 = unsigned short, 32 = int + * -32 = float, -64 = double */ + int w, /* Image width in pixels */ + int h, /* Image height in pixels */ + double bzero, /* Zero point for pixel scaling */ + double bscale, /* Scale factor for pixel scaling */ + int x, /* Zero-based horizontal pixel number */ + int y); /* Zero-based vertical pixel number */ + double getpix1( /* Read one pixel from any data type 2-D array (1,1)*/ + char *image, /* Image array as 1-D vector */ + int bitpix, /* FITS bits per pixel */ + int w, /* Image width in pixels */ + int h, /* Image height in pixels */ + double bzero, /* Zero point for pixel scaling */ + double bscale, /* Scale factor for pixel scaling */ + int x, /* One-based horizontal pixel number */ + int y); /* One-based vertical pixel number */ + double maxvec( /* Get maximum value in vector from a image */ + char *image, /* Image array from which to extract vector */ + int bitpix, /* Number of bits per pixel in image */ + double bzero, /* Zero point for pixel scaling */ + double bscale, /* Scale factor for pixel scaling */ + int pix1, /* Offset of first pixel to extract */ + int npix); /* Number of pixels to extract */ + double minvec( /* Get minimum value in vector from a image */ + char *image, /* Image array from which to extract vector */ + int bitpix, /* Number of bits per pixel in image */ + double bzero, /* Zero point for pixel scaling */ + double bscale, /* Scale factor for pixel scaling */ + int pix1, /* Offset of first pixel to extract */ + int npix); /* Number of pixels to extract */ + void putpix( /* Write one pixel to any data type 2-D array (0,0)*/ + char *image, /* Image array as 1-D vector */ + int bitpix, /* FITS bits per pixel */ + int w, /* Image width in pixels */ + int h, /* Image height in pixels */ + double bzero, /* Zero point for pixel scaling */ + double bscale, /* Scale factor for pixel scaling */ + int x, /* Zero-based horizontal pixel number */ + int y, /* Zero-based vertical pixel number */ + double dpix); /* Value to put into image pixel */ + void putpix1( /* Write one pixel to any data type 2-D array (1,1) */ + char *image, /* Image array as 1-D vector */ + int bitpix, /* FITS bits per pixel */ + int w, /* Image width in pixels */ + int h, /* Image height in pixels */ + double bzero, /* Zero point for pixel scaling */ + double bscale, /* Scale factor for pixel scaling */ + int x, /* One-based horizontal pixel number */ + int y, /* One-based vertical pixel number */ + double dpix); /* Value to put into image pixel */ + void addpix( /* Add to one pixel in any data type 2-D array (0,0)*/ + char *image, /* Image array as 1-D vector */ + int bitpix, /* FITS bits per pixel */ + int w, /* Image width in pixels */ + int h, /* Image height in pixels */ + double bzero, /* Zero point for pixel scaling */ + double bscale, /* Scale factor for pixel scaling */ + int x, /* Zero-based horizontal pixel number */ + int y, /* Zero-based vertical pixel number */ + double dpix); /* Value to add to image pixel */ + void addpix1( /* Add to one pixel in any data type 2-D array (1,1)*/ + char *image, /* Image array as 1-D vector */ + int bitpix, /* FITS bits per pixel */ + int w, /* Image width in pixels */ + int h, /* Image height in pixels */ + double bzero, /* Zero point for pixel scaling */ + double bscale, /* Scale factor for pixel scaling */ + int x, /* One-based horizontal pixel number */ + int y, /* One-based vertical pixel number */ + double dpix); /* Value to add to image pixel */ + void movepix( /* Move one pixel value between two 2-D arrays (0,0) */ + char *image1, /* Pointer to first pixel in input image */ + int bitpix1, /* Bits per input pixel (FITS codes) */ + int w1, /* Number of horizontal pixels in input image */ + int x1, /* Zero-based row for input pixel */ + int y1, /* Zero-based column for input pixel */ + char *image2, /* Pointer to first pixel in output image */ + int bitpix2, /* Bits per output pixel (FITS codes) */ + int w2, /* Number of horizontal pixels in output image */ + int x2, /* Zero-based row for output pixel */ + int y2); /* Zero-based column for output pixel */ + void movepix1( /* Move one pixel value between two 2-D arrays (1,1) */ + char *image1, /* Pointer to first pixel in input image */ + int bitpix1, /* Bits per input pixel (FITS codes) */ + int w1, /* Number of horizontal pixels in input image */ + int x1, /* One-based row for input pixel */ + int y1, /* One-based column for input pixel */ + char *image2, /* Pointer to first pixel in output image */ + int bitpix2, /* Bits per output pixel (FITS codes) */ + int w2, /* Number of horizontal pixels in output image */ + int x2, /* One-based row for output pixel */ + int y2); /* One-based column for output pixel */ + +/* Image vector processing subroutines in imio.c */ + + void addvec( /* Add constant to vector from 2-D array */ + char *image, /* Image array as 1-D vector */ + int bitpix, /* FITS bits per pixel */ + double bzero, /* Zero point for pixel scaling */ + double bscale, /* Scale factor for pixel scaling */ + int pix1, /* Offset of first pixel to which to add */ + int npix, /* Number of pixels to which to add */ + double dpix); /* Value to add to pixels */ + void multvec( /* Multiply vector from 2-D array by a constant */ + char *image, /* Image array as 1-D vector */ + int bitpix, /* FITS bits per pixel */ + double bzero, /* Zero point for pixel scaling */ + double bscale, /* Scale factor for pixel scaling */ + int pix1, /* Offset of first pixel to multiply */ + int npix, /* Number of pixels to multiply */ + double dpix); /* Value to add to pixels */ + void getvec( /* Read vector from 2-D array */ + char *image, /* Image array as 1-D vector */ + int bitpix, /* FITS bits per pixel */ + double bzero, /* Zero point for pixel scaling */ + double bscale, /* Scale factor for pixel scaling */ + int pix1, /* Offset of first pixel to extract */ + int npix, /* Number of pixels to extract */ + double *dvec0); /* Vector of pixels (returned) */ + void putvec( /* Write vector into 2-D array */ + char *image, /* Image array as 1-D vector */ + int bitpix, /* FITS bits per pixel */ + double bzero, /* Zero point for pixel scaling */ + double bscale, /* Scale factor for pixel scaling */ + int pix1, /* Offset of first pixel to insert */ + int npix, /* Number of pixels to insert */ + double *dvec0); /* Vector of pixels to insert */ + void fillvec( /* Write constant into a vector */ + char *image, /* Image array as 1-D vector */ + int bitpix, /* FITS bits per pixel */ + double bzero, /* Zero point for pixel scaling */ + double bscale, /* Scale factor for pixel scaling */ + int pix1, /* Zero-based offset of first pixel to multiply */ + int npix, /* Number of pixels to multiply */ + double dpix); /* Value to which to set pixels */ + void fillvec1( /* Write constant into a vector */ + char *image, /* Image array as 1-D vector */ + int bitpix, /* FITS bits per pixel */ + double bzero, /* Zero point for pixel scaling */ + double bscale, /* Scale factor for pixel scaling */ + int pix1, /* One-based offset of first pixel to multiply */ + int npix, /* Number of pixels to multiply */ + double dpix); /* Value to which to set pixels */ + +/* Image pixel byte-swapping subroutines in imio.c */ + + void imswap( /* Swap alternating bytes in a vector */ + int bitpix, /* Number of bits per pixel */ + char *string, /* Address of starting point of bytes to swap */ + int nbytes); /* Number of bytes to swap */ + void imswap2( /* Swap bytes in a vector of 2-byte (short) integers */ + char *string, /* Address of starting point of bytes to swap */ + int nbytes); /* Number of bytes to swap */ + void imswap4( /* Reverse bytes in a vector of 4-byte numbers */ + char *string, /* Address of starting point of bytes to swap */ + int nbytes); /* Number of bytes to swap */ + void imswap8( /* Reverse bytes in a vector of 8-byte numbers */ + char *string, /* Address of starting point of bytes to swap */ + int nbytes); /* Number of bytes to swap */ + int imswapped(void); /* Return 1 if machine byte order is not FITS order */ + +/* File utilities from fileutil.c */ + + int getfilelines( /* Return number of lines in an ASCII file */ + char *filename); /* Name of file to check */ + char *getfilebuff( /* Return entire file contents in a character string */ + char *filename); /* Name of file to read */ + int getfilesize( /* Return size of a binary or ASCII file */ + char *filename); /* Name of file to check */ + int isimlist( /* Return 1 if file is list of FITS or IRAF image files, else 0 */ + char *filename); /* Name of file to check */ + int isimlistd( /* Return 1 if file is list of FITS or IRAF image files, else 0 */ + char *filename, /* Name of file to check */ + char *rootdir); /* Name of root directory for files in list */ + int isfilelist( /* Return 1 if list of readable files, else 0 */ + char *filename, /* Name of file to check */ + char *rootdir); /* Name of root directory for files in list */ + int isfile( /* Return 1 if file is a readable file, else 0 */ + char *filename); /* Name of file to check */ + int istiff( /* Return 1 if TIFF image file, else 0 */ + char *filename); /* Name of file to check */ + int isjpeg( /* Return 1 if JPEG image file, else 0 */ + char *filename); /* Name of file to check */ + int isgif( /* Return 1 if GIF image file, else 0 */ + char *filename); /* Name of file to check */ + int next_line ( /* Return the next line of an ASCII file */ + FILE *diskfile, /* File descriptor for ASCII file */ + int ncmax, /* Maximum number of characters returned */ + char *line); /* Next line (returned) */ + int first_token( /* Return first token from the next line of an ASCII file */ + FILE *diskfile, /* File descriptor for ASCII file */ + int ncmax, /* Maximum number of characters returned */ + char *token); /* First token on next line (returned) */ + int stc2s ( /* Replace character in string with space */ + char *spchar, /* Character to replace with spaces */ + char *string); /* Character string to process */ + int sts2c ( /* Replace spaces in string with character */ + char *spchar, /* Character with which to replace spaces */ + char *string); /* Character string to process */ + +/* Subroutines for access to tokens within a string from fileutil.c */ + int setoken( /* Tokenize a string for easy decoding */ + struct Tokens *tokens, /* Token structure returned */ + char *string, /* character string to tokenize */ + char *cwhite); /* additional whitespace characters + * if = tab, disallow spaces and commas */ + int nextoken( /* Get next token from tokenized string */ + struct Tokens *tokens, /* Token structure returned */ + char *token, /* token (returned) */ + int maxchars); /* Maximum length of token */ + int getoken( /* Get specified token from tokenized string */ + struct Tokens *tokens, /* Token structure returned */ + int itok, /* token sequence number of token + * if <0, get whole string after token -itok + * if =0, get whole string */ + char *token, /* token (returned) */ + int maxchars); /* Maximum length of token */ + +/* Subroutines for translating dates and times in dateutil.c */ + + /* Subroutines to convert between floating point and vigesimal angles */ + + void ang2hr ( /* Fractional degrees to hours as hh:mm:ss.ss */ + double angle, /* Angle in fractional degrees */ + int lstr, /* Maximum number of characters in string */ + char *string); /* Character string (hh:mm:ss.ss returned) */ + void ang2deg ( /* Fractional degrees to degrees as dd:mm:ss.ss */ + double angle, /* Angle in fractional degrees */ + int lstr, /* Maximum number of characters in string */ + char *string); /* Character string (dd:mm:ss.ss returned) */ + double deg2ang ( /* Degrees as dd:mm:ss.ss to fractional degrees */ + char *angle); /* Angle as dd:mm:ss.ss */ + double hr2ang ( /* Hours as hh:mm:ss.ss to fractional degrees */ + char *angle); /* Angle in sexigesimal hours (hh:mm:ss.sss) */ + + /* Subroutines to convert from year and day of year */ + + void doy2dt( /* Year and day of year to yyyy.mmdd hh.mmss */ + int year, /* Year */ + double doy, /* Day of year with fraction */ + double *date, /* Date as yyyy.mmdd (returned) */ + double *time); /* Time as hh.mmssxxxx (returned) */ + double doy2ep( /* Year and day of year to fractional year (epoch) */ + int year, /* Year */ + double doy); /* Day of year with fraction */ + double doy2epb( /* year and day of year to Besselian epoch */ + int year, /* Year */ + double doy); /* Day of year with fraction */ + double doy2epj( /* year and day of year to Julian epoch */ + int year, /* Year */ + double doy); /* Day of year with fraction */ + char *doy2fd( /* year and day of year to FITS date */ + int year, /* Year */ + double doy); /* Day of year with fraction */ + double doy2jd( /* year and day of year to Julian Day */ + int year, /* Year */ + double doy); /* Day of year with fraction */ + double doy2mjd( /* year and day of year to Modified Julian Day */ + int year, /* Year */ + double doy); /* Day of year with fraction */ + double doy2ts( /* year and day of year to seconds since 1950.0 */ + int year, /* Year */ + double doy); /* Day of year with fraction */ + int doy2tsi( /* year and day of year to IRAF seconds since 1980-01-01 */ + int year, /* Year */ + double doy); /* Day of year with fraction */ + time_t doy2tsu( /* year and day of year to Unix seconds since 1970-01-01 */ + int year, /* Year */ + double doy); /* Day of year with fraction */ + + /* Subroutines to convert from date and time */ + + void dt2doy( /* yyyy.mmdd hh.mmss to year and day of year */ + double date, /* Date as yyyy.mmdd + * yyyy = calendar year (e.g. 1973) + * mm = calendar month (e.g. 04 = april) + * dd = calendar day (e.g. 15) */ + double time, /* Time as hh.mmssxxxx + * if time<0, it is time as -(fraction of a day) + * hh = hour of day (0 .le. hh .le. 23) + * nn = minutes (0 .le. nn .le. 59) + * ss = seconds (0 .le. ss .le. 59) + * xxxx = tenths of milliseconds (0 .le. xxxx .le. 9999) */ + int *year, /* Year (returned) */ + double *doy); /* Day of year with fraction (returned) */ + double dt2ep( /* yyyy.ddmm and hh.mmsss to fractional year (epoch) */ + double date, /* Date as yyyy.mmdd */ + double time); /* Time as hh.mmssxxxx */ + double dt2epb( /* yyyy.ddmm and hh.mmsss to Besselian epoch */ + double date, /* Date as yyyy.mmdd */ + double time); /* Time as hh.mmssxxxx */ + double dt2epj( /* yyyy.ddmm and hh.mmsss to Julian epoch */ + double date, /* Date as yyyy.mmdd */ + double time); /* Time as hh.mmssxxxx */ + char *dt2fd( /* yyyy.ddmm and hh.mmsss to FITS date string */ + double date, /* Date as yyyy.mmdd */ + double time); /* Time as hh.mmssxxxx */ + void dt2i( /* yyyy.ddmm and hh.mmsss to year, month, day, hrs, min, sec */ + double date, /* Date as yyyy.mmdd */ + double time, /* Time as hh.mmssxxxx */ + int *iyr, /* year (returned) */ + int *imon, /* month (returned) */ + int *iday, /* day (returned) */ + int *ihr, /* hours (returned) */ + int *imn, /* minutes (returned) */ + double *sec, /* seconds (returned) */ + int ndsec); /* Number of decimal places in seconds (0=int) */ + double dt2jd( /* yyyy.ddmm and hh.mmsss to Julian Day */ + double date, /* Date as yyyy.mmdd */ + double time); /* Time as hh.mmssxxxx */ + double dt2mjd( /* yyyy.ddmm and hh.mmsss to Modified Julian Day */ + double date, /* Date as yyyy.mmdd */ + double time); /* Time as hh.mmssxxxx */ + double dt2ts( /* yyyy.ddmm and hh.mmsss to seconds since 1950.0 */ + double date, /* Date as yyyy.mmdd */ + double time); /* Time as hh.mmssxxxx */ + int dt2tsi( /* yyyy.ddmm and hh.mmsss to IRAF seconds since 1980-01-01 */ + double date, /* Date as yyyy.mmdd */ + double time); /* Time as hh.mmssxxxx */ + time_t dt2tsu( /* yyyy.ddmm and hh.mmsss to Unix seconds since 1970-01-01 */ + double date, /* Date as yyyy.mmdd */ + double time); /* Time as hh.mmssxxxx */ + + /* Subroutines to convert from epoch (various types of fractional year) */ + + void ep2dt( /* Fractional year to yyyy.mmdd hh.mmssss */ + double epoch, /* Date as fractional year */ + double *date, /* Date as yyyy.mmdd (returned) */ + double *time); /* Time as hh.mmssxxxx (returned) */ + void epb2dt( /* Besselian epoch to yyyy.mmdd hh.mmssss */ + double epoch, /* Besselian epoch (fractional 365.242198781-day years) */ + double *date, /* Date as yyyy.mmdd (returned) */ + double *time); /* Time as hh.mmssxxxx (returned) */ + void epj2dt( /* Julian epoch to yyyy.mmdd hh.mmssss */ + double epoch, /* Julian epoch (fractional 365.25-day years) */ + double *date, /* Date as yyyy.mmdd (returned)*/ + double *time); /* Time as hh.mmssxxxx (returned) */ + char *ep2fd( /* Fractional year to FITS date string yyyy-mm-ddThh:mm:ss.ss */ + double epoch); /* Date as fractional year */ + char *epb2fd( /* Besselian epoch to FITS date string yyyy-mm-ddThh:mm:ss.ss */ + double epoch); /* Besselian epoch (fractional 365.242198781-day years) */ + char *epj2fd( /* Julian epoch to FITS date string yyyy-mm-ddThh:mm:ss.ss */ + double epoch); /* Julian epoch (fractional 365.25-day years) */ + void ep2i( /* Fractional year to year, month, day, hours, min., sec. */ + double epoch, /* Date as fractional year */ + int *iyr, /* year (returned) */ + int *imon, /* month (returned) */ + int *iday, /* day (returned) */ + int *ihr, /* hours (returned) */ + int *imn, /* minutes (returned) */ + double *sec, /* seconds (returned) */ + int ndsec); /* Number of decimal places in seconds (0=int) */ + void epb2i( /* Besselian epoch to year, month, day, hours, min., sec. */ + double epoch, /* Besselian epoch (fractional 365.242198781-day years) */ + int *iyr, /* year (returned) */ + int *imon, /* month (returned) */ + int *iday, /* day (returned) */ + int *ihr, /* hours (returned) */ + int *imn, /* minutes (returned) */ + double *sec, /* seconds (returned) */ + int ndsec); /* Number of decimal places in seconds (0=int) */ + void epj2i( /* Julian epoch to year, month, day, hours, min., sec. */ + double epoch, /* Julian epoch (fractional 365.25-day years) */ + int *iyr, /* year (returned) */ + int *imon, /* month (returned) */ + int *iday, /* day (returned) */ + int *ihr, /* hours (returned) */ + int *imn, /* minutes (returned) */ + double *sec, /* seconds (returned) */ + int ndsec); /* Number of decimal places in seconds (0=int) */ + double ep2jd( /* Fractional year to Julian Date */ + double epoch); /* Date as fractional year */ + double epb2jd( /* Besselian epoch to Julian Date */ + double epoch); /* Besselian epoch (fractional 365.242198781-day years) */ + double epj2jd( /* Julian epoch to Julian Date */ + double epoch); /* Julian epoch (fractional 365.25-day years) */ + double ep2mjd( /* Fractional year to Modified Julian Date */ + double epoch); /* Date as fractional year */ + double epb2mjd( /* Besselian epoch to Modified Julian Date */ + double epoch); /* Besselian epoch (fractional 365.242198781-day years) */ + double epj2mjd( /* Julian epoch to Modified Julian Date */ + double epoch); /* Julian epoch (fractional 365.25-day years) */ + double ep2epb( /* Fractional year to Besselian epoch */ + double epoch); /* Date as fractional year */ + double ep2epj( /* Fractional year to Julian epoch */ + double epoch); /* Date as fractional year */ + double epb2epj( /* Besselian epoch to Julian epoch */ + double epoch); /* Besselian epoch (fractional 365.242198781-day years) */ + double epj2epb( /* Julian epoch to Besselian epoch */ + double epoch); /* Julian epoch (fractional 365.25-day years) */ + double epb2ep( /* Besselian epoch to fractional year */ + double epoch); /* Besselian epoch (fractional 365.242198781-day years) */ + double epj2ep( /* Julian epoch to fractional year */ + double epoch); /* Julian epoch (fractional 365.25-day years) */ + double ep2ts( /* Fractional year to seconds since 1950.0 */ + double epoch); /* Date as fractional year */ + double epb2ts( /* Besselian epoch to seconds since 1950.0 */ + double epoch); /* Besselian epoch (fractional 365.242198781-day years) */ + double epj2ts( /* Julian epoch to seconds since 1950.0 */ + double epoch); /* Julian epoch (fractional 365.25-day years) */ + + /* Convert from FITS standard date string */ + + void fd2dt( /* FITS standard date string to date and time */ + char *string, /* FITS date string, which may be: + * fractional year + * dd/mm/yy (FITS standard before 2000) + * dd-mm-yy (nonstandard use before 2000) + * yyyy-mm-dd (FITS standard after 1999) + * yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ + double *date, /* Date as yyyy.mmdd (returned)*/ + double *time); /* Time as hh.mmssxxxx (returned) */ + void fd2doy( /* FITS standard date string to year, day of year */ + char *string, /* FITS date string */ + int *year, /* Year (returned) */ + double *doy); /* Day of year with fraction (returned) */ + double fd2ep( /* FITS standard date string to fractional year (epoch) */ + char *string); /* FITS date string */ + double fd2epb( /* FITS standard date string to Besselian epoch */ + char *string); /* FITS date string */ + double fd2epj( /* FITS standard date string to Julian epoch */ + char *string); /* FITS date string */ + char *fd2fd( /* Any FITS standard date string to ISO FITS date string */ + char *string); /* FITS date string */ + char *fd2of( /* Any FITS standard date string to old FITS date and time */ + char *string); /* FITS date string */ + char *fd2ofd( /* Any FITS standard date string to old FITS date string */ + char *string); /* FITS date string */ + char *fd2oft( /* Any FITS standard date string to old FITS time string */ + char *string); /* FITS date string */ + void fd2i( /* FITS standard date string to year, mon, day, hrs, min, sec */ + char *string, /* FITS date string */ + int *iyr, /* year (returned) */ + int *imon, /* month (returned) */ + int *iday, /* day (returned) */ + int *ihr, /* hours (returned) */ + int *imn, /* minutes (returned) */ + double *sec, /* seconds (returned) */ + int ndsec); /* Number of decimal places in seconds (0=int) */ + double fd2jd( /* FITS standard date string to Julian Day */ + char *string); /* FITS date string */ + double fd2mjd( /* FITS standard date string to Modified Julian Day */ + char *string); /* FITS date string */ + double fd2ts( /* FITS standard date to seconds since 1950-01-01 */ + char *string); /* FITS date string */ + int fd2tsi( /* FITS standard date to IRAF seconds since 1980-01-01 */ + char *string); /* FITS date string */ + time_t fd2tsu( /* FITS standard date to Unix seconds since 1970-01-01 */ + char *string); /* FITS date string */ + + /* Convert from Julian Day */ + + void jd2doy( /* Julian Day to year and day of year */ + double dj, /* Julian Day */ + int *year, /* Year (returned) */ + double *doy); /* Day of year with fraction (returned) */ + void jd2dt( /* Julian Day to yyyy.mmdd hh.mmssss */ + double dj, /* Julian Day */ + double *date, /* Date as yyyy.mmdd (returned)*/ + double *time); /* Time as hh.mmssxxxx (returned) */ + double jd2ep( /* Julian Day to fractional year */ + double dj); /* Julian Day */ + double jd2epb( /* Julian Day to Besselian epoch */ + double dj); /* Julian Day */ + double jd2epj( /* Julian Day to Julian epoch */ + double dj); /* Julian Day */ + char *jd2fd( /* Julian Day to FITS date string yyyy-mm-ddThh:mm:ss.ss */ + double dj); /* Julian Day */ + void jd2i( /* Julian Day to year, month, day, hours, min., sec. */ + double dj, /* Julian Day */ + int *iyr, /* year (returned) */ + int *imon, /* month (returned) */ + int *iday, /* day (returned) */ + int *ihr, /* hours (returned) */ + int *imn, /* minutes (returned) */ + double *sec, /* seconds (returned) */ + int ndsec); /* Number of decimal places in seconds (0=int) */ + double jd2mjd( /* Julian Day to Modified Julian day */ + double dj); /* Julian Day */ + double jd2ts( /* Julian Day to seconds since 1950.0 */ + double dj); /* Julian Day */ + time_t jd2tsu( /* Julian Day to Unix seconds since 1970-01-01T00:00 */ + double dj); /* Julian Day */ + int jd2tsi( /* Julian Day to IRAF seconds since 1980-01-01T00:00 */ + double dj); /* Julian Day */ + + /* Convert current local time to various formats */ + + void lt2dt( /* Current local time to date (yyyy.mmdd), time (hh.mmsss) */ + double *date, /* Date as yyyy.mmdd (returned) */ + double *time); /* Time as hh.mmssxxxx (returned) */ + char *lt2fd(void); /* Current local time to FITS ISO date string */ + int lt2tsi(void); /* Current local time to IRAF seconds since 1980-01-01T00:00 */ + time_t lt2tsu(void); /* Current local time to Unix seconds since 1970-01-01T00:00 */ + double lt2ts(void); /* Current local time to IRAF seconds since 1950-01-01T00:00 */ + + /* Convert from Modified Julian Day (JD - 2400000.5) */ + + void mjd2doy( /* Modified Julian Day to year and day of year */ + double dj, /* Modified Julian Day */ + int *year, /* Year (returned) */ + double *doy); /* Day of year with fraction (returned) */ + void mjd2dt( /* Modified Julian Day to yyyy.mmdd hh.mmssss */ + double dj, /* Modified Julian Date */ + double *date, /* Date as yyyy.mmdd (returned)*/ + double *time); /* Time as hh.mmssxxxx (returned) */ + double mjd2ep( /* Modified Julian Day to fractional year */ + double dj); /* Modified Julian Date */ + double mjd2epb( /* Modified Julian Day to Besselian epoch */ + double dj); /* Modified Julian Date */ + double mjd2epj( /* Modified Julian Day to Julian epoch */ + double dj); /* Modified Julian Date */ + char *mjd2fd( /* Modified Julian Day to FITS date yyyy-mm-ddThh:mm:ss.ss */ + double dj); /* Modified Julian Date */ + void mjd2i( /* Modified Julian Day to year, month, day, hours, min, sec */ + double dj, /* Modified Julian Date */ + int *iyr, /* year (returned) */ + int *imon, /* month (returned) */ + int *iday, /* day (returned) */ + int *ihr, /* hours (returned) */ + int *imn, /* minutes (returned) */ + double *sec, /* seconds (returned) */ + int ndsec); /* Number of decimal places in seconds (0=int) */ + double mjd2jd( /* Modified Julian Day to Julian day */ + double dj); /* Modified Julian Date */ + double mjd2ts( /* Modified Julian Day to seconds since 1950.0 */ + double dj); /* Modified Julian Date */ + + /* Convert from seconds since 1950-01-01 0:00 (JPL Ephemeris time) */ + + void ts2dt( /* Seconds since 1950.0 to yyyy.mmdd hh.mmssss */ + double tsec, /* seconds since 1950.0 */ + double *date, /* Date as yyyy.mmdd (returned)*/ + double *time); /* Time as hh.mmssxxxx (returned) */ + double ts2ep( /* Seconds since 1950.0 to fractional year */ + double tsec); /* seconds since 1950.0 */ + double ts2epb( /* Seconds since 1950.0 to Besselian epoch */ + double tsec); /* seconds since 1950.0 */ + double ts2epj( /* Seconds since 1950.0 to Julian epoch */ + double tsec); /* seconds since 1950.0 */ + char *ts2fd( /* Seconds since 1950.0 to FITS date, yyyy-mm-ddT00:00:00.000 */ + double tsec); /* seconds since 1950.0 */ + void ts2i( /* Seconds since 1950.0 to year, month, day, hours, min, sec */ + double tsec, /* seconds since 1950.0 */ + int *iyr, /* year (returned) */ + int *imon, /* month (returned) */ + int *iday, /* day (returned) */ + int *ihr, /* hours (returned) */ + int *imn, /* minutes (returned) */ + double *sec, /* seconds (returned) */ + int ndsec); /* Number of decimal places in seconds (0=int) */ + double ts2jd( /* Seconds since 1950.0 to Julian Day */ + double tsec); /* seconds since 1950.0 */ + double ts2mjd( /* Seconds since 1950.0 to Modified Julian Day */ + double tsec); /* seconds since 1950.0 */ + + /* Convert from IRAF time (seconds since 1980-01-01 0:00 UT) */ + + char *tsi2fd( /* Seconds since 1980-01-01 to FITS standard date string */ + int isec); /* Seconds past 1980-01-01 */ + double tsi2ts( /* Seconds since 1980-01-01 to seconds since 1950-01-01 */ + int isec); /* Seconds past 1980-01-01 */ + void tsi2dt( /* Seconds since 1980-01-01 to date yyyy.mmdd, time hh.mmssss */ + int isec, /* Seconds past 1980-01-01 */ + double *date, /* Date as yyyy.mmdd (returned) */ + double *time); /* Time as hh.mmssxxxx (returned) */ + + /* Convert from Unix time (seconds since 1970-01-01 0:00 UT) */ + + void tsu2dt( /* Seconds since 1970-01-01 to date yyyy.ddmm, time hh.mmsss */ + time_t isec, /* Seconds past 1970-01-01 */ + double *date, /* Date as yyyy.mmdd (returned) */ + double *time); /* Time as hh.mmssxxxx (returned) */ + char *tsu2fd( /* Seconds since 1970-01-01 to FITS standard date string */ + time_t isec); /* Seconds past 1970-01-01 */ + double tsu2ts( /* Seconds since 1970-01-01 to seconds since 1950-01-01 */ + time_t isec); /* Seconds past 1970-01-01 */ + int tsu2tsi( /* Seconds since 1970-01-01 to local seconds since 1980-01-01 */ + time_t isec); /* Seconds past 1970-01-01 */ + + /* Convert times within a day */ + + char *tsd2fd( /* Seconds since start of day to FITS standard time string */ + double tsec); /* Seconds since start of day */ + double tsd2dt( /* Seconds since start of day to hh.mmsssss */ + double tsec); /* Seconds since start of day */ + + /* Convert from current Universal Time */ + + void ut2dt( /* Current Universal Time to date (yyyy.mmdd), time (hh.mmsss) */ + double *date, /* Date as yyyy.mmdd (returned) */ + double *time); /* Time as hh.mmssxxxx (returned) */ + void ut2doy( /* Current Universal Time to year, day of year */ + int *year, /* Year (returned) */ + double *doy); /* Day of year (returned) */ + double ut2ep(void); /* Current Universal Time to fractional year */ + double ut2epb(void); /* Current Universal Time to Besselian Epoch */ + double ut2epj(void); /* Current Universal Time to Julian Epoch */ + char *ut2fd(void); /* Current Universal Time to FITS ISO date string */ + double ut2jd(void); /* Current Universal Time to Julian Date */ + double ut2mjd(void); /* Current Universal Time to Modified Julian Date */ + int ut2tsi(void); /* Current UT to IRAF seconds since 1980-01-01T00:00 */ + time_t ut2tsu(void); /* Current UT to Unix seconds since 1970-01-01T00:00 */ + double ut2ts(void); /* Current UT to seconds since 1950-01-01T00:00 */ + + int isdate( /* Return 1 if string is FITS old or ISO date */ + char *string); /* Possible FITS date string, which may be: + * dd/mm/yy (FITS standard before 2000) + * dd-mm-yy (nonstandard FITS use before 2000) + * yyyy-mm-dd (FITS standard after 1999) + * yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */ + + /* Ephemeris time conversions (ET, TT, and TDT) */ + + char *et2fd( /* ET (or TDT or TT) in FITS format to UT in FITS format */ + char *string); /* Ephemeris Time as FITS date string (E not T) */ + char *fd2et( /* UT in FITS format to ET (or TDT or TT) in FITS format */ + char *string); /* FITS date string */ + void dt2et( /* yyyy.ddmm and hh.mmsss to Ephemeris Time */ + double *date, /* Date as yyyy.mmdd */ + double *time); /* Time as hh.mmssxxxx + *if time<0, it is time as -(fraction of a day) */ + double jd2jed( /* Convert from Julian Date to Julian Ephemeris Date */ + double dj); /* Julian Date */ + double jed2jd( /* Convert from Julian Ephemeris Date to Julian Date */ + double dj); /* Julian Ephemeris Date */ + double ets2ts( /* ET in seconds since 1950-01-01 to UT in same format */ + double tsec); /* ET in seconds since 1950-01-01 */ + double ts2ets( /* UT in seconds since 1950-01-01 to ET in same format */ + double tsec); /* UT in seconds since 1950-01-01 */ + void edt2dt( /* yyyy.ddmm and hh.mmsss Ephemeris Time to UT */ + double *date, /* Date as yyyy.mmdd */ + double *time); /* Time as hh.mmssxxxx + * If time<0, it is time as -(fraction of a day) */ + double utdt( /* Compute difference between UT and dynamical time (ET-UT) */ + double dj); /* Julian Date (UT) */ + + /* Sidereal Time conversions */ + + char *fd2gst( /* Convert from FITS UT date to Greenwich Sidereal Time */ + char *string); /* FITS date string */ + void dt2gst( /* Convert from UT as yyyy.mmdd hh.mmssss to Greenwich Sidereal Time */ + double *date, /* Date as yyyy.mmdd */ + double *time); /* Time as hh.mmssxxxx + * If time<0, it is time as -(fraction of a day) */ + double jd2gst( /* Calculate Greenwich Sidereal Time given Julian Date */ + double dj); /* Julian Date (UT) */ + double ts2gst( /* Calculate Greenwich Sidereal Time given Universal Time */ + double tsec); /* Time since 1950.0 in UT seconds */ + char *fd2lst( /* Convert from FITS UT date to Local Sidereal Time */ + char *string); /* FITS date string */ + void dt2lst( /* Convert from UT as yyyy.mmdd hh.mmssss to Local Sidereal Time */ + double *date, /* Date as yyyy.mmdd */ + double *time); /* Time as hh.mmssxxxx + * If time<0, it is time as -(fraction of a day) */ + double ts2lst( /* Calculate Local Sidereal Time given Universal Time */ + double tsec); /* Time since 1950.0 in UT seconds */ + double jd2lst( /* Calculate Local Sidereal Time given Julian Date */ + double dj); /* Julian Date (UT) */ + double eqeqnx( /* Compute equation of eqinoxes from Julian Date */ + double dj); /* Julian Date (UT) */ + char *fd2mst( /* Convert from FITS UT date to Mean Sidereal Time */ + char *string); /* FITS date string */ + double jd2mst( /* Convert from Julian Date to Mean Sidereal Time */ + double dj); /* Julian Date (UT) */ + double jd2mst2( /* Convert from Julian Date to Mean Sidereal Time */ + double dj); /* Julian Date (UT) */ + void dt2mst( /* Convert from UT as yyyy.mmdd hh.mmssss to Mean Sidereal Time */ + double *date, /* Date as yyyy.mmdd */ + double *time); /* Time as hh.mmssxxxx + * If time<0, it is time as -(fraction of a day) */ + double lst2dt( /* Calculate UT as hh.mmsss given UT date and + * Local Sidereal Time */ + double date0, /* UT date as yyyy.mmdd */ + double time0); /* LST as hh.mmssss */ + double lst2jd( /* Calculate UT as Julian Date given UT date and + * Local Sidereal Time */ + double sdj); /* Julian Date of desired day at 0:00 UT + sidereal time */ + char *lst2fd( /* Calculate FITS UT date and time given UT date and + * Local Sidereal Time */ + char *string); /* UT Date, LST as yyyy-mm-ddShh:mm:ss.ss */ + char *gst2fd( /* Calculate FITS UT date and time given Greenwich Sidereal Time */ + char *string); /* UT Date, GST as yyyy-mm-ddShh:mm:ss.ss */ + double gst2jd( /* Calculate FITS UT Julian Date given Greenwich Sidereal Time */ + double sdj); /* UT Date, GST as Julian Date */ + char *mst2fd( /* Calculate FITS UT date and time given Mean Sidereal Time */ + char *string); /* UT Date, MST as yyyy-mm-ddShh:mm:ss.ss */ + double mst2jd( /* Calculate FITS UT Julian Date given Mean Sidereal Time */ + double sdj); /* UT Date, MST as Julian Date */ + double ts2mst( /* Calculate Mean Sidereal Time given Universal Time */ + double tsec); /* time since 1950.0 in UT seconds */ + void setlongitude( /* Longitude for sidereal time in or out */ + double longitude); /* longitude of observatory in degrees (+=west) */ + void compnut( /* Compute nutation in longitude and obliquity and mean obliquity*/ + double dj, /* TDB (loosely ET or TT) as Julian Date */ + double *dpsi, /* Nutation in longitude in radians (returned) */ + double *deps, /* Nutation in obliquity in radians (returned) */ + double *eps0); /* Mean obliquity in radians (returned) */ + + /* Heliocentric Julian Date conversions */ + + double mjd2mhjd( /* Convert from Modified Julian Date to Heliocentric MJD */ + double mjd, /* Julian date (geocentric) */ + double ra, /* Right ascension (degrees) */ + double dec, /* Declination (degrees) */ + int sys); /* J2000, B1950, GALACTIC, ECLIPTIC */ + double mjd2hjd( /* Convert from Modified Julian Date to Heliocentric JD */ + double mjd, /* Julian date (geocentric) */ + double ra, /* Right ascension (degrees) */ + double dec, /* Declination (degrees) */ + int sys); /* J2000, B1950, GALACTIC, ECLIPTIC */ + double mhjd2mjd( /* Convert from Heliocentric Modified Julian Date to MJD */ + double mhjd, /* Modified Heliocentric Julian date */ + double ra, /* Right ascension (degrees) */ + double dec, /* Declination (degrees) */ + int sys); /* J2000, B1950, GALACTIC, ECLIPTIC */ + double jd2hjd( /* Convert from Julian Date to Heliocentric Julian Date */ + double dj, /* Julian date (geocentric) */ + double ra, /* Right ascension (degrees) */ + double dec, /* Declination (degrees) */ + int sys); /* J2000, B1950, GALACTIC, ECLIPTIC */ + double hjd2jd( /* Convert from Heliocentric Julian Date to Julian Date */ + double dj, /* Heliocentric Julian date */ + double ra, /* Right ascension (degrees) */ + double dec, /* Declination (degrees) */ + int sys); /* J2000, B1950, GALACTIC, ECLIPTIC */ + + void setdatedec( /* Set number of decimal places in FITS dates */ + int nd); /* Number of decimal places in FITS dates */ + +#else /* K&R prototypes */ + +/* FITS file access subroutines in fitsfile.c */ +extern int fitsropen(); +extern char *fitsrhead(); +extern char *fitsrtail(); +extern char *fitsrimage(); +extern char *fitsrfull(); +extern char *fitsrsect(); +extern int fitswhead(); +extern int fitswexhead(); +extern int fitswext(); +extern int fitswhdu(); +extern int fitswimage(); +extern int fitscimage(); +extern int isfits(); /* Return 1 if file is a FITS file */ +extern void fitserr(); /* Print FITS error message to stderr */ +extern void setfitsinherit(); /* Set flag to append primary data header */ +extern int fitsheadsize(); /* Return size of fitsheader in bytes */ + +/* FITS table file access subroutines in fitsfile.c */ +extern int fitsrtopen(); +extern int fitsrthead(); +extern void fitsrtlset(); +extern int fitsrtline(); +extern short ftgeti2(); +extern int ftgeti4(); +extern float ftgetr4(); +extern double ftgetr8(); +extern int ftgetc(); +extern void moveb(); /* Copy nbytes bytes from source+offs to dest+offd */ + +/* IRAF file access subroutines in imhfile.c */ +extern char *irafrhead(); +extern char *irafrimage(); +extern int irafwhead(); +extern int irafwimage(); +extern int isiraf(); +extern char *iraf2fits(); +extern char *fits2iraf(); + +/* Image pixel access subroutines in imio.c */ +extern double getpix(); /* Read one pixel from any data type 2-D array (0,0)*/ +extern double getpix1(); /* Read one pixel from any data type 2-D array (1,1)*/ +extern double maxvec(); /* Get maximum value in vector from a image */ +extern double minvec(); /* Get minimum value in vector from a image */ +extern void putpix(); /* Write one pixel to any data type 2-D array (0,0)*/ +extern void putpix1(); /* Write one pixel to any data type 2-D array (1,1) */ +extern void addpix(); /* Add to one pixel in any data type 2-D array (0,0)*/ +extern void addpix1(); /* Add to one pixel in any data type 2-D array (1,1)*/ +extern void movepix(); /* Move one pixel value between two 2-D arrays (0,0) */ +extern void movepix1(); /* Move one pixel value between two 2-D arrays (1,1) */ +extern void addvec(); /* Add constant to vector from 2-D array */ +extern void multvec(); /* Multiply vector from 2-D array by a constant */ +extern void getvec(); /* Read vector from 2-D array */ +extern void putvec(); /* Write vector into 2-D array */ +extern void fillvec(); /* Write constant into a vector */ +extern void fillvec1(); /* Write constant into a vector */ +extern void imswap(); /* Swap alternating bytes in a vector */ +extern void imswap2(); /* Swap bytes in a vector of 2-byte (short) integers */ +extern void imswap4(); /* Reverse bytes in a vector of 4-byte numbers */ +extern void imswap8(); /* Reverse bytes in a vector of 8-byte numbers */ +extern int imswapped(); /* Return 1 if machine byte order is not FITS order */ + +/* File utilities from fileutil.c */ +extern int getfilelines(); +extern char *getfilebuff(); +extern int getfilesize(); +extern int isimlist(); +extern int isimlistd(); +extern int isfilelist(); +extern int isfile(); +extern int istiff(); +extern int isjpeg(); +extern int isgif(); +extern int next_line(); +extern int first_token(); + +/* Subroutines for access to tokens within a string from fileutil.c */ +int setoken(); /* Tokenize a string for easy decoding */ +int nextoken(); /* Get next token from tokenized string */ +int getoken(); /* Get specified token from tokenized string */ + +/* Subroutines for translating dates and times in dateutil.c */ + +void ang2hr(); /* Fractional degrees to hours as hh:mm:ss.ss */ +void ang2deg(); /* Fractional degrees to degrees as dd:mm:ss.ss */ +double deg2ang(); /* Degrees as dd:mm:ss.ss to fractional degrees */ +double hr2ang(); /* Hours as hh:mm:ss.ss to fractional degrees */ + +void doy2dt(); /* year and day of year to yyyy.mmdd hh.mmss */ +double doy2ep(); /* year and day of year to fractional year (epoch) */ +double doy2epb(); /* year and day of year to Besselian epoch */ +double doy2epj(); /* year and day of year to Julian epoch */ +char *doy2fd(); /* year and day of year to FITS date */ +double doy2jd(); /* year and day of year to Julian date */ +double doy2mjd(); /* year and day of year to modified Julian date */ +double doy2ts(); /* year and day of year to seconds since 1950.0 */ +int doy2tsi(); /* year and day of year to IRAF seconds since 1980-01-01 */ + +time_t doy2tsu(); /* year and day of year to Unix seconds since 1970-01-01 */ +void dt2doy(); /* yyyy.mmdd hh.mmss to year and day of year */ +double dt2ep(); /* yyyy.ddmm and hh.mmsss to fractional year (epoch) */ +double dt2epb(); /* yyyy.ddmm and hh.mmsss to Besselian epoch */ +double dt2epj(); /* yyyy.ddmm and hh.mmsss to Julian epoch */ +char *dt2fd(); /* yyyy.ddmm and hh.mmsss to FITS date string */ +void dt2i(); /* yyyy.ddmm and hh.mmsss to year, month, day, hrs, min, sec */ +double dt2jd(); /* yyyy.ddmm and hh.mmsss to Julian date */ +double dt2mjd(); /* yyyy.ddmm and hh.mmsss to modified Julian date */ +double dt2ts(); /* yyyy.ddmm and hh.mmsss to seconds since 1950.0 */ +int dt2tsi(); /* yyyy.ddmm and hh.mmsss to IRAF seconds since 1980-01-01 */ +time_t dt2tsu(); /* yyyy.ddmm and hh.mmsss to Unix seconds since 1970-01-01 */ + +void ep2dt(); /* Fractional year to yyyy.mmdd hh.mmssss */ +void epb2dt(); /* Besselian epoch to yyyy.mmdd hh.mmssss */ +void epj2dt(); /* Julian epoch to yyyy.mmdd hh.mmssss */ +char *ep2fd(); /* Fractional year to FITS date string yyyy-mm-ddThh:mm:ss.ss */ +char *epb2fd(); /* Besselian epoch to FITS date string yyyy-mm-ddThh:mm:ss.ss */ +char *epj2fd(); /* Julian epoch to FITS date string yyyy-mm-ddThh:mm:ss.ss */ +void ep2i(); /* Fractional year to year, month, day, hours, min., sec. */ +void epb2i(); /* Besselian epoch to year, month, day, hours, min., sec. */ +void epj2i(); /* Julian epoch to year, month, day, hours, min., sec. */ +double ep2jd(); /* Fractional year to Julian Date */ +double epb2jd(); /* Besselian epoch to Julian Date */ +double epj2jd(); /* Julian epoch to Julian Date */ +double ep2mjd(); /* Fractional year to modified Julian Date */ +double epb2mjd(); /* Besselian epoch to modified Julian Date */ +double epj2mjd(); /* Julian epoch to modified Julian Date */ +double ep2epb(); /* Fractional year to Besselian epoch */ +double ep2epj(); /* Fractional year to Julian epoch */ +double epb2epj(); /* Besselian epoch to Julian epoch */ +double epj2epb(); /* Julian epoch to Besselian epoch */ +double epb2ep(); /* Besselian epoch to fractional year */ +double epj2ep(); /* Julian epoch to fractional year */ +double ep2ts(); /* Fractional year to seconds since 1950.0 */ +double epb2ts(); /* Besselian epoch to seconds since 1950.0 */ +double epj2ts(); /* Julian epoch to seconds since 1950.0 */ + +void fd2dt(); /* FITS standard date string to Julian date */ +void fd2doy(); /* FITS standard date string to year, day of year */ +double fd2ep(); /* FITS standard date string to fractional year (epoch) */ +double fd2epb(); /* FITS standard date string to Besselian epoch */ +double fd2epj(); /* FITS standard date string to Julian epoch */ +char *fd2fd(); /* Any FITS standard date string to ISO FITS date string */ +char *fd2of(); /* Any FITS standard date string to old FITS date and time */ +char *fd2ofd(); /* Any FITS standard date string to old FITS date string */ +char *fd2oft(); /* Any FITS standard date string to old FITS time string */ +void fd2i(); /* FITS standard date string to year, mon, day, hrs, min, sec */ +double fd2jd(); /* FITS standard date string to Julian date */ +double fd2mjd(); /* FITS standard date string to modified Julian date */ +double fd2ts(); /* FITS standard date to seconds since 1950-01-01 */ +int fd2tsi(); /* FITS standard date to IRAF seconds since 1980-01-01 */ +time_t fd2tsu(); /* FITS standard date to Unix seconds since 1970-01-01 */ +void jd2doy(); /* Julian date to year and day of year */ +void jd2dt(); /* Julian date to yyyy.mmdd hh.mmssss */ +double jd2ep(); /* Julian date to fractional year */ +double jd2epb(); /* Julian date to Besselian epoch */ +double jd2epj(); /* Julian date to Julian epoch */ +char *jd2fd(); /* Julian date to FITS date string yyyy-mm-ddThh:mm:ss.ss */ +void jd2i(); /* Julian date to year, month, day, hours, min., sec. */ +double jd2mjd(); /* Julian date to modified Julian date */ +double jd2ts(); /* Julian date to seconds since 1950.0 */ +time_t jd2tsu(); /* Julian date to Unix seconds since 1970-01-01T00:00 */ +int jd2tsi(); /* Julian date to IRAF seconds since 1980-01-01T00:00 */ + +void lt2dt(); /* Current local time to date (yyyy.mmdd), time (hh.mmsss) */ +char *lt2fd(); /* Current local time to FITS ISO date string */ +int lt2tsi(); /* Current local time to IRAF seconds since 1980-01-01T00:00 */ +time_t lt2tsu(); /* Current local time to Unix seconds since 1970-01-01T00:00 */ +double lt2ts(); /* Current local time to IRAF seconds since 1950-01-01T00:00 */ + +void mjd2doy(); /* Convert from Modified Julian Date to Day of Year */ +void mjd2dt(); /* Modified Julian date to yyyy.mmdd hh.mmssss */ +double mjd2ep(); /* Modified Julian date to fractional year */ +double mjd2epb(); /* Modified Julian date to Besselian epoch */ +double mjd2epj(); /* Modified Julian date to Julian epoch */ +char *mjd2fd(); /* Modified Julian date to FITS date yyyy-mm-ddThh:mm:ss.ss */ +void mjd2i(); /* Modified Julian date to year, month, day, hours, min, sec */ +double mjd2jd(); /* Modified Julian date to Julian date */ +double mjd2ts(); /* Modified Julian date to seconds since 1950.0 */ + +void ts2dt(); /* Seconds since 1950.0 to yyyy.mmdd hh.mmssss */ +double ts2ep(); /* Seconds since 1950.0 to fractional year */ +double ts2epb(); /* Seconds since 1950.0 to Besselian epoch */ +double ts2epj(); /* Seconds since 1950.0 to Julian epoch */ +char *ts2fd(); /* Seconds since 1950.0 to FITS date, yyyy-mm-ddT00:00:00.000 */ +void ts2i(); /* Seconds since 1950.0 to year, month, day, hours, min, sec */ +double ts2jd(); /* Seconds since 1950.0 to Julian date */ +double ts2mjd(); /* Seconds since 1950.0 to modified Julian date */ +char *tsi2fd(); /* Seconds since 1980-01-01 to FITS standard date string */ +double tsi2ts(); /* Seconds since 1980-01-01 to seconds since 1950-01-01 */ +double tsi2ts(); /* Seconds since 1980-01-01 to seconds since 1950-01-01 */ +void tsi2dt(); /* Seconds since 1980-01-01 to date yyyy.mmdd, time hh.mmssss */ +void tsu2dt(); /* Seconds since 1970-01-01 to date yyyy.ddmm, time hh.mmsss */ +char *tsu2fd(); /* Seconds since 1970-01-01 to FITS standard date string */ +char *tsd2fd(); /* Seconds since start of day to FITS standard time string */ +double tsd2dt(); /* Seconds since start of day to hh.mmsssss */ +double tsu2ts(); /* Seconds since 1970-01-01 to seconds since 1950-01-01 */ +int tsu2tsi(); /* Seconds since 1970-01-01 to local seconds since 1980-01-01 */ +int isdate(); /* Return 1 if string is FITS old or ISO date */ +void ut2dt(); /* Current Universal Time to date (yyyy.mmdd), time (hh.mmsss) */ +void ut2doy(); /* Current Universal Time to year, day of year */ +double ut2ep(); /* Current Universal Time to fractional year */ +double ut2epb(); /* Current Universal Time to Besselian Epoch */ +double ut2epj(); /* Current Universal Time to Julian Epoch */ +char *ut2fd(); /* Current Universal Time to FITS ISO date string */ +double ut2jd(); /* Current Universal Time to Julian Date */ +double ut2mjd(); /* Current Universal Time to Modified Julian Date */ +int ut2tsi(); /* Current UT to IRAF seconds since 1980-01-01T00:00 */ +time_t ut2tsu(); /* Current UT to Unix seconds since 1970-01-01T00:00 */ +double ut2ts(); /* Current UT to IRAF seconds since 1950-01-01T00:00 */ +int sts2c(); /* Replaces spaces in a string with a specified character */ +int stc2s(); /* Replaces a specified character in a string with spaces */ +char *et2fd(); /* ET (or TDT or TT) in FITS format to UT in FITS format */ +char *fd2et(); /* UT in FITS format to ET (or TDT or TT) in FITS format */ +double jd2jed(); /* Convert from Julian Date to Julian Ephemeris Date */ +double jed2jd(); /* Convert from Julian Ephemeris Date to Julian Date */ +double ets2ts(); /* ET in seconds since 1950-01-01 to UT in same format */ +double ts2ets(); /* UT in seconds since 1950-01-01 to ET in same format */ +void dt2et(); /* yyyy.ddmm and hh.mmsss to Ephemeris Time */ +void edt2dt(); /* yyyy.ddmm and hh.mmsss Ephemeris Time to UT */ +double utdt(); /* Compute difference between UT and dynamical time (ET-UT) */ +char *fd2gst(); /* Convert from FITS UT date to Greenwich Sidereal Time */ +void dt2gst(); /* Convert from UT as yyyy.mmdd hh.mmssss to Greenwich Sidereal Time */ +double jd2gst(); /* Calculate Greenwich Sidereal Time given Julian Date */ +double ts2gst(); /* Calculate Greenwich Sidereal Time given Universal Time */ +char *fd2lst(); /* Convert from FITS UT date to Local Sidereal Time */ +void dt2lst(); /* Convert from UT as yyyy.mmdd hh.mmssss to Local Sidereal Time */ +double ts2lst(); /* Calculate Local Sidereal Time given Universal Time */ +double jd2lst(); /* Calculate Local Sidereal Time given Julian Date */ +double eqeqnx(); /* Compute equation of eqinoxes from Julian Date */ +char *fd2mst(); /* Convert from FITS UT date to Mean Sidereal Time */ +double jd2mst(); /* Convert from Julian Date to Mean Sidereal Time */ +double jd2mst2(); /* Convert from Julian Date to Mean Sidereal Time */ +void dt2mst(); /* Convert from UT as yyyy.mmdd hh.mmssss to Mean Sidereal Time */ +double lst2ts(); /* Calculate Universal Time given Local Sidereal Time */ +double lst2dt(); /* Calculate UT as yyyy.mmdd hh.mmsss given UT date and Local Sidereal Time */ +double lst2jd(); /* Calculate UT as Julian Date given UT date and Local Sidereal Time */ +char *lst2fd(); /* Calculate FITS UT date and time given UT date and Local Sidereal Time */ +char *gst2fd(); /* Calculate FITS UT date and time given Greenwich Sidereal Time */ +double gst2jd(); /* Calculate FITS UT Julian Date given Greenwich Sidereal Time */ +char *mst2fd(); /* Calculate FITS UT date and time given Mean Sidereal Time */ +double mst2jd(); /* Calculate FITS UT Julian Date given Mean Sidereal Time */ +char *fd2mst(); /* Convert from FITS UT date to Mean Sidereal Time */ +void dt2mst(); /* Convert from UT as yyyy.mmdd hh.mmssss to Mean Sidereal Time */ +double ts2mst(); /* Calculate Mean Sidereal Time given Universal Time */ +double mjd2mhjd(); /* Convert from Modified Julian Date to Heliocentric MJD */ +double mjd2hjd(); /* Convert from Modified Julian Date to Heliocentric JD */ +double mhjd2mjd(); /* Convert from Heliocentric Modified Julian Date to MJD */ +double jd2hjd(); /* Convert from Julian Date to Heliocentric Julian Date */ +double jd2mhjd(); /* Convert from Julian Date to Modified Heliocentric JD */ +double hjd2jd(); /* Convert from Heliocentric Julian Date to Julian Date */ +double hjd2mjd(); /* Convert from Heliocentric Julian Date to Modified JD */ +double hjd2mhjd(); /* Convert from Heliocentric Julian Date to Modified HJD */ +void setdatedec(); /* Set number of decimal places in FITS dates */ +void setlongitude(); /* Longitude for sidereal time in or out */ + +void compnut(); /* Compute nutation in longitude and obliquity and mean obliquity*/ + +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* fitsfile_h_ */ + +/* May 31 1996 Use stream I/O for reading as well as writing + * Jun 12 1996 Add byte-swapping subroutines + * Jul 10 1996 FITS header now allocated in subroutines + * Jul 17 1996 Add FITS table column extraction subroutines + * Aug 6 1996 Add MOVEPIX, HDEL and HCHANGE declarations + * + * Oct 10 1997 FITS file opening subroutines now return int instead of FILE * + * + * May 27 1998 Split off fitsio and imhio subroutines to fitsio.h + * Jun 4 1998 Change fits2iraf from int to int * + * Jul 24 1998 Make IRAF header char instead of int + * Aug 18 1998 Change name to fitsfile.h from fitsio.h + * Oct 5 1998 Add isiraf() and isfits() + * Oct 7 1998 Note separation of imhfile.c into two files + * + * Jul 15 1999 Add fileutil.c subroutines + * Sep 28 1999 Add (1,1)-based image access subroutines + * Oct 21 1999 Add fitswhead() + * Nov 2 1999 Add date utilities from wcscat.h + * Nov 23 1999 Add fitscimage() + * Dec 15 1999 Fix misdeclaration of *2fd() subroutines, add fd2i(), dt2i() + * Dec 20 1999 Add isdate() + * + * Jan 20 2000 Add conversions to and from Besselian and Julian epochs + * Jan 21 2000 Add conversions to old FITS date and time + * Jan 26 2000 Add conversion to modified Julian date (JD - 2400000.5 + * Mar 22 2000 Add lt2* and ut2* to get current time as local and UT + * Mar 24 2000 Add tsi2* and tsu2* to convert IRAF and Unix seconds + * Sep 8 2000 Improve comments + * + * Apr 24 2001 Add length of column name to column data structure + * May 22 2001 Add day of year date conversion subroutines + * Sep 25 2001 Add isfilelist() and isfile() + * + * Jan 8 2002 Add sts2c() and stc2s() + * Apr 8 2002 Change all long declarations to time_t for compatibility + * Jun 18 2002 Add fitserr() to print error messages + * Aug 30 2002 Add Ephemeris Time date conversions + * Sep 10 2002 Add Sidereal Time conversions + * Oct 21 2002 Add fitsrsect() to read sections of FITS images + * + * Mar 5 2003 Add isimlistd() to check image lists with root directory + * Aug 20 2003 Add fitsrfull() to read n-dimensional simple FITS images + * + * Feb 27 2004 Add fillvec() and fillvec1() + * May 3 2004 Add setfitsinherit() + * May 6 2004 Add fitswexhead() + * Aug 27 2004 Add fitsheadsize() + * + * Oct 14 2005 Add tsd2fd(), tsd2dt(), epj2ep(), epb2ep(), tsi2dt() + * + * Feb 23 2006 Add fitsrtail() to read appended FITS header + * Feb 23 2006 Add istiff(), isjpeg(), isgif() to check TIFF, JPEG, GIF files + * Sep 6 2006 Add heliocentric time conversions + * Oct 5 2006 Add local sidereal time conversions + * + * Jan 9 2007 Add ANSI prototypes + * Jan 11 2007 Add token subroutines from catutil.c/wcscat.h to fileutil.c + * Jun 11 2007 Add minvec() subroutine in imio.c + * Nov 28 2007 Add kform format to FITS table keyword data structure + * + * Sep 8 2008 Add ag2hr(), ang2deg(), deg2ang(), and hr2ang() + * + * Sep 25 2009 Add moveb() + * + * Jun 20 2014 Add next_line() + */ diff --git a/tksao/wcssubs/fitshead.h b/tksao/wcssubs/fitshead.h new file mode 100644 index 0000000..1212709 --- /dev/null +++ b/tksao/wcssubs/fitshead.h @@ -0,0 +1,438 @@ +/*** File fitshead.h FITS header access subroutines + *** January 9, 2007 + *** By Jessica Mink, jmink@cfa.harvard.edu + *** Harvard-Smithsonian Center for Astrophysics + *** Copyright (C) 1996-2007 + *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Correspondence concerning WCSTools should be addressed as follows: + Internet email: jmink@cfa.harvard.edu + Postal address: Jessica Mink + Smithsonian Astrophysical Observatory + 60 Garden St. + Cambridge, MA 02138 USA + */ + +/* Declarations for subroutines in hget.c, hput.c, and iget.c */ + +#ifndef _fitshead_h_ +#define _fitshead_h_ + +#include + +#ifdef __cplusplus /* C++ prototypes */ +extern "C" { +#endif + + +#ifdef __STDC__ /* Full ANSI prototypes */ + +/* Subroutines in hget.c */ + int hgeti2( /* Extract short value from FITS header */ + const char* hstring, /* FITS header string */ + const char* keyword, /* FITS keyword */ + short* val); /* short integer value (returned) */ + int hgeti4c( /* Extract int value from FITS header */ + const char* hstring, /* FITS header string */ + const char* keyword, /* FITS keyword */ + const char* wchar, /* WCS to use (A-Z or null) */ + int* val); /* integer value (returned) */ + int hgeti4( /* Extract int value from FITS header */ + const char* hstring, /* FITS header string */ + const char* keyword, /* FITS keyword */ + int* val); /* integer value (returned) */ + int hgetr4( /* Extract float value from FITS header */ + const char* hstring, /* FITS header string */ + const char* keyword, /* FITS keyword */ + float* val); /* float value (returned) */ + int hgetr8c( /* Extract double value from FITS header */ + const char* hstring, /* FITS header string */ + const char* keyword, /* FITS keyword */ + const char* wchar, /* WCS to use (A-Z or null) */ + double* val); /* double value (returned) */ + int hgetr8( /* Extract double value from FITS header */ + const char* hstring, /* FITS header string */ + const char* keyword, /* FITS keyword */ + double* val); /* double value (returned) */ + int hgetra( /* Extract right ascension from FITS header */ + const char* hstring, /* FITS header string */ + const char* keyword, /* FITS keyword */ + double* ra); /* RA in degrees (returned) */ + int hgetdec( /* Extract declination from FITS header */ + const char* hstring, /* FITS header string */ + const char* keyword, /* FITS keyword */ + double* dec); /* Dec in degrees (returned) */ + int hgetdate( /* Extract date from FITS header */ + const char* hstring, /* FITS header string */ + const char* keyword, /* FITS keyword */ + double* date); /* Date in fractional years (returned) */ + int hgetl( /* Extract boolean value from FITS header */ + const char* hstring, /* FITS header string */ + const char* keyword, /* FITS keyword */ + int* lval); /* 1 if T, 0 if F (returned) */ + int hgetsc( /* Extract string value from FITS header */ + const char* hstring, /* FITS header string */ + const char* keyword, /* FITS keyword */ + const char* wchar, /* WCS to use (A-Z or null) */ + const int lstr, /* maximum length of returned string */ + char* string); /* null-terminated string value (returned) */ + int hgets( /* Extract string value from FITS header */ + const char* hstring, /* FITS header string */ + const char* keyword, /* FITS keyword */ + const int lstr, /* maximum length of returned string */ + char* string); /* null-terminated string value (returned) */ + int hgetm ( /* Extract string from multiple keywords */ + const char* hstring, /* FITS header string */ + const char* keyword, /* FITS keyword */ + const int lstr, /* maximum length of returned string */ + char* string); /* null-terminated string value (returned) */ + int hgetndec( /* Find number of decimal places in FITS value*/ + const char* hstring, /* FITS header string */ + const char* keyword, /* FITS keyword */ + int* ndec); /* number of decimal places (returned) */ + + char* hgetc( /* Return pointer to value for FITS keyword */ + const char* hstring, /* FITS header string */ + const char* keyword); /* FITS keyword */ + + char* ksearch( /* Return pointer to keyword in FITS header */ + const char* hstring, /* FITS header string */ + const char* keyword); /* FITS keyword */ + char *blsearch ( + const char* hstring, /* FITS header string */ + const char* keyword); /* FITS keyword */ + + char *strsrch ( /* Find string s2 within string s1 */ + const char* s1, /* String to search */ + const char* s2); /* String to look for */ + char *strnsrch ( /* Find string s2 within string s1 */ + const char* s1, /* String to search */ + const char* s2, /* String to look for */ + const int ls1); /* Length of string being searched */ + + char *strcsrch ( /* Find string s2 within string s1 (no case) */ + const char* s1, /* String to search */ + const char* s2); /* String to look for */ + char *strncsrch ( /* Find string s2 within string s1 (no case) */ + const char* s1, /* String to search */ + const char* s2, /* String to look for */ + const int ls1); /* Length of string being searched */ + + int hlength( /* Set length of unterminated FITS header */ + const char *header, /* FITS header */ + const int lhead); /* Allocated length of FITS header */ + int gethlength( /* Get length of current FITS header */ + char* header); /* FITS header */ + + double str2ra( /* Return RA in degrees from string */ + const char* in); /* Character string (hh:mm:ss.sss or dd.dddd) */ + double str2dec( /* Return Dec in degrees from string */ + const char* in); /* Character string (dd:mm:ss.sss or dd.dddd) */ + + int isnum( /* Return 1 if number, else 0 */ + const char* string); /* Character string which may be a number */ + int notnum( /* Return 0 if number, else 1 */ + const char* string); /* Character string which may be a number */ + int numdec( /* Return number of decimal places in number */ + const char* string); /* Character string which may be a number */ + void strfix( /* Clean up extraneous characters in string */ + char* string, /* Character string which may be a number */ + int fillblank, /* If 1, blanks are replaced by underscores */ + int dropzero); /* If 1, drop trailing zeroes from string */ + + char *getltime(void); /* Return current local time in ISO format */ + char *getutime(void); /* Return current UT as an ISO-format string */ + +/* Subroutines in iget.c */ + int mgetstr( /* Extract string from multiline FITS keyword */ + const char* hstring, /* FITS header string */ + const char* mkey, /* FITS keyword root _n added for extra lines */ + const char* keyword, /* IRAF keyword */ + const int lstr, /* maximum length of returned string */ + char* string); /* null-terminated string value (returned) */ + int mgeti4( /* Extract int from multiline FITS keyword */ + const char* hstring, /* FITS header string */ + const char* mkey, /* FITS keyword root _n added for extra lines */ + const char* keyword, /* IRAF keyword */ + int* ival); /* int keyword value (returned) */ + int mgetr8( /* Extract double from multiline FITS keyword */ + const char* hstring, /* FITS header string */ + const char* mkey, /* FITS keyword root _n added for extra lines */ + const char* keyword, /* IRAF keyword */ + double* dval); /* double keyword value (returned) */ + int igeti4( /* Extract int from IRAF keyword string */ + const char* hstring, /* Multiline IRAF keyword string value */ + const char* keyword, /* IRAF keyword */ + int* val); /* int value (returned) */ + int igetr4( /* Extract float from IRAF keyword string */ + const char* hstring, /* Multiline IRAF keyword string value */ + const char* keyword, /* IRAF keyword */ + float* val); /* float value (returned) */ + int igetr8( /* Extract double from IRAF keyword string */ + const char* hstring, /* Multiline IRAF keyword string value */ + const char* keyword, /* IRAF keyword */ + double* val); /* double value (returned) */ + int igets( /* Extract string from IRAF keyword string */ + const char* hstring, /* Multiline IRAF keyword string value */ + const char* keyword, /* IRAF keyword */ + const int lstr, /* maximum length of returned string */ + char* string); /* null-terminated string value (returned) */ + char *igetc( /* Extract string from IRAF keyword string */ + const char* hstring, /* Multiline IRAF keyword string value */ + const char* keyword); /* IRAF keyword */ + +/* Subroutines in hput.c */ +/* All hput* routines return 0 if successful, else -1 */ + int hputi2( /* Implant short value into FITS header */ + char* hstring, /* FITS header string (modified) */ + const char* keyword, /* FITS keyword */ + short ival); /* short value */ + int hputi4( /* Implant int value into FITS header */ + char* hstring, /* FITS header string (modified) */ + const char* keyword, /* FITS keyword */ + const int ival); /* int value */ + int hputr4( /* Implant float value into FITS header */ + char* hstring, /* FITS header string (modified) */ + const char* keyword, /* FITS keyword */ + const float* rval); /* float (4 byte) value */ + int hputr8( /* Implant short into FITS header */ + char* hstring, /* FITS header string (modified) */ + const char* keyword, /* FITS keyword */ + const double dval); /* double value */ + int hputnr8( /* double with specified number of decimal places */ + char* hstring, /* FITS header string (modified) */ + const char* keyword, /* FITS keyword */ + const int ndec, /* Number of decimal places in keyword value */ + const double dval); /* double value */ + int hputs( /* Quoted character string into FITS header */ + char* hstring, /* FITS header string (modified) */ + const char* keyword, /* FITS keyword */ + const char* cval); /* Character string value */ + int hputm( /* Quoted character string, mutiple keywords */ + char* hstring, /* FITS header string (modified) */ + const char* keyword, /* FITS keyword */ + const char* cval); /* Character string value */ + int hputcom( /* Add comment to keyword line in FITS header */ + char* hstring, /* FITS header string (modified) */ + const char* keyword, /* FITS keyword */ + const char* comment); /* Comment string */ + int hputra( /* Right ascension in degrees into hh:mm:ss.sss */ + char* hstring, /* FITS header string (modified) */ + const char* keyword, /* FITS keyword */ + const double ra); /* Right ascension in degrees */ + int hputdec( /* Declination in degrees into dd:mm:ss.ss */ + char* hstring, /* FITS header string (modified) */ + const char* keyword, /* FITS keyword */ + const double dec); /* Declination in degrees */ + int hputl( /* Implant boolean value into FITS header */ + char* hstring, /* FITS header string (modified) */ + const char* keyword, /* FITS keyword */ + const int lval); /* 0->F, else ->T */ + int hputc( /* Implant character string without quotes */ + char* hstring, /* FITS header string (modified) */ + const char* keyword, /* FITS keyword */ + const char* cval); /* Character string value */ + + int hdel( /* Delete a keyword line from a FITS header */ + char* hstring, /* FITS header string (modified) */ + const char* keyword); /* FITS keyword to delete */ + int hadd( /* Add a keyword line from a FITS header */ + char* hplace, /* Location in FITS header string (modified) */ + const char* keyword); /* FITS keyword to add */ + int hchange( /* Change a keyword name in a FITS header */ + char* hstring, /* FITS header string (modified) */ + const char* keyword1, /* Current FITS keyword name */ + const char* keyword2); /* New FITS keyword name */ + + void ra2str( /* Convert degrees to hh:mm:ss.ss */ + char *string, /* Character string (returned) */ + int lstr, /* Length of string */ + const double ra, /* Right ascension in degrees */ + const int ndec); /* Number of decimal places in seconds */ + void dec2str( /* Convert degrees to dd:mm:ss.ss */ + char *string, /* Character string (returned) */ + int lstr, /* Length of string */ + const double dec, /* Declination in degrees */ + const int ndec); /* Number of decimal places in arcseconds */ + void deg2str( /* Format angle into decimal degrees string */ + char *string, /* Character string (returned) */ + int lstr, /* Length of string */ + const double deg, /* Angle in degrees */ + const int ndec); /* Number of decimal places in degrees */ + void num2str( /* Format number into string */ + char *string, /* Character string (returned) */ + const double num, /* Number */ + const int field, /* Total field size in characters */ + const int ndec); /* Number of decimal places */ + void setheadshrink( /* 0 to keep blank line when keyword deleted */ + const int hsh); /* 1 to shrink header by one line */ + void setleaveblank( /* 1 to keep blank line where keyword deleted */ + const int hsh); /* 0 to shrink header by one line */ + +#else /* K&R prototypes */ + +/* Subroutines in hget.c */ + +/* Extract a value from a FITS header for given keyword */ +extern int hgeti4(); /* int (Multiple WCS) */ +extern int hgeti4c(); /* int */ +extern int hgeti2(); /* short */ +extern int hgetr4(); /* float */ +extern int hgetr8(); /* double */ +extern int hgetr8c(); /* double (Multiple WCS) */ +extern int hgetra(); /* Right ascension in degrees from string */ +extern int hgetdec(); /* Declination in degrees from string */ +extern int hgetdate(); /* Date in years from FITS date string */ +extern int hgetl(); /* T->1, F->0 from FITS logical entry */ +extern int hgets(); /* Previously allocated string */ +extern int hgetsc(); /* Previously allocated string (Multiple WCS) */ +extern int hgetm(); /* Previously allocated string from multiple keywords */ +extern char *hgetc(); /* Return pointer to string */ +extern int hgetndec(); /* Number of decimal places in keyword value */ + +/* Subroutines to convert strings to RA and Dec in degrees */ +extern double str2ra(); +extern double str2dec(); + +/* Check to see whether a string is a number or not */ +extern int isnum(); +extern int notnum(); +extern int decnum(); + +/* Find given keyword entry in FITS header */ +extern char *ksearch(); + +/* Find beginning of fillable blank line before FITS header keyword */ +extern char *blsearch(); + +/* Search for substring s2 within string s1 */ +extern char *strsrch (); /* s1 null-terminated */ +extern char *strnsrch (); /* s1 ls1 characters long */ +extern char *strcsrch (); /* s1 null-terminated (case-insensitive) */ +extern char *strncsrch (); /* s1 ls1 characters long (case-insensitive) */ +extern void strfix(); /* Drop or change extraneous characters in string */ + +/* Set length of header which is not null-terminated */ +extern int hlength(); + +/* Get length of current FITS header */ +extern int gethlength(); + +/* Subroutines in iget.c */ +extern int mgetstr(); /* Previously allocated string from multiline keyword */ +extern int mgetr8(); /* double from multiline keyword */ +extern int mgeti4(); /* int from multiline keyword */ +extern int igeti4(); /* long integer from IRAF compound keyword value */ +extern int igetr4(); /* real from IRAF compound keyword value */ +extern int igetr8(); /* double from IRAF compound keyword value */ +extern int igets(); /* character string from IRAF compound keyword value */ +extern char *igetc(); /* Extract string from IRAF keyword string */ + +/* Subroutines in hput.c */ + +/* Implant a value into a FITS header for given keyword */ +extern int hputi4(); /* int */ +extern int hputi2(); /* short */ +extern int hputr4(); /* float */ +extern int hputr8(); /* double */ +extern int hputnr8(); /* double with specified number of decimal places */ +extern int hputra(); /* Right ascension in degrees into hh:mm:ss.sss */ +extern int hputdec(); /* Declination in degrees into dd:mm:ss.ss */ +extern int hputl(); /* 0 -> F, else T FITS logical entry */ +extern int hputs(); /* Quoted character string */ +extern int hputm(); /* Quoted character string into mutiple keywords */ +extern int hputc(); /* Character string without quotes (returns 0 if OK) */ +extern int hputcom(); /* Comment after keyword=value (returns 0 if OK) */ + +extern int hdel(); /* Delete a keyword line from a FITS header */ +extern int hadd(); /* Add a keyword line to a FITS header */ +extern int hchange(); /* Change a keyword name in a FITS header */ +extern void setheadshrink(); /* Set flag for deleted keyword space disposition*/ +extern void setleaveblank(); /* Set flag for deleted keyword space disposition*/ + +/* Subroutines to convert RA and Dec in degrees to strings */ +extern void ra2str(); +extern void dec2str(); + +extern void deg2str(); +extern void num2str(); +extern int numdec(); /* Return number of decimal places in number */ + +extern char *getltime(); /* Return current local time in ISO format */ +extern char *getutime(); /* Return current UT as an ISO-format string */ + +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* fitshead_h_ */ + +/* Apr 26 1996 Add HGETDATE to get year from date string + * May 22 1996 Return double from STR2RA and STR2DEC + * May 31 1996 Use stream I/O for reading as well as writing + * Jun 12 1996 Add byte-swapping subroutines + * Jul 10 1996 FITS header now allocated in subroutines + * Jul 17 1996 Add FITS table column extraction subroutines + * Jul 19 1996 Add declarations for header implanting subroutines + * Aug 5 1996 Add HLENGTH for FITS headers which are not null-terminated + * Aug 5 1996 Add STRNSRCH for FITS headers which are not null-terminated + * Aug 6 1996 Add HPUTNR8 to save a specified number of decimal places + * Aug 6 1996 Add MOVEPIX, HDEL and HCHANGE declarations + * Nov 1 1996 Add DEG2STR + * Dec 12 1996 Add ISNUM + * + * Oct 10 1997 FITS file opening subroutines now return int instead of FILE * + * + * Mar 12 1998 Add NOTNUM + * Apr 30 1998 Clean up declarations and add more comments + * May 12 1998 Add MGETS, MGETR8, MGETI4 for IRAF multi-line keywords + * May 26 1998 Add HGETNDEC for number of decimal places in keyword value + * May 27 1998 Add BLSEARCH to find usable blank lines in header + * May 27 1998 Split off fitsio and imhio subroutines to fitsio.h + * May 27 1998 Add all subroutines in hget.c, hput.c, and iget.c to C++ dec. + * Jun 24 1998 Add string lengths to ra2str(), dec2str, and deg2str() calls + * Jun 25 1998 Fix other C++ declarations with added string lengths + * Aug 31 1998 Add current date subroutines getltime() and getutime() + * Oct 28 1998 Add missing hgetc() to non c++ declarations + * + * Oct 6 1999 Add gethlength() to return current size of header + * Oct 14 1999 All HPUT subroutines now return an error code, 0 if OK, else -1 + * Oct 15 1999 Add hputcom() declaration + * Oct 21 1999 Add hgetm() declaration + * + * Mar 22 2000 Add int to iget*() declarations + * Mar 27 2000 Add hputm() declaration + * + * Apr 3 2002 Add hgeti4c(), hgetr8c(), and hgetsc() + * Apr 8 2002 Include sys/types.h + * Aug 30 2002 Add strcsrch() and strncsrch() + * + * Sep 23 2003 Change mgets() to mgetstr() to avoid name collision at UCO Lick + * Oct 20 2003 Add numdec() to return the number of decimal places in a string + * + * Feb 26 2004 Add igetc(), formerly internal to iget.c + * Jul 1 2004 Add setheadshrink() for hdel() + * Aug 30 2004 Add numdec() to non-C++ declarations + * + * May 22 2006 Add setleaveblank() to leave blank line where keyword is deleted + * Jun 28 2006 Add strfix() to clean up characters in strings + * Nov 29 2006 Drop semicolon at end of C++ ifdef + * + * Jan 9 2007 Fix declarations so ANSI prototypes are not just for C++ + */ diff --git a/tksao/wcssubs/hget.c b/tksao/wcssubs/hget.c new file mode 100644 index 0000000..866bcec --- /dev/null +++ b/tksao/wcssubs/hget.c @@ -0,0 +1,1921 @@ +/*** File libwcs/hget.c + *** May 19, 2011 + *** By Jessica Mink, jmink@cfa.harvard.edu + *** Harvard-Smithsonian Center for Astrophysics + *** Copyright (C) 1994-2011 + *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Correspondence concerning WCSTools should be addressed as follows: + Internet email: jmink@cfa.harvard.edu + Postal address: Jessica Mink + Smithsonian Astrophysical Observatory + 60 Garden St. + Cambridge, MA 02138 USA + + * Module: hget.c (Get FITS Header parameter values) + * Purpose: Extract values for variables from FITS header string + * Subroutine: hgeti2 (hstring,keyword,ival) returns short integer + * Subroutine: hgeti4c (hstring,keyword,wchar,ival) returns long integer + * Subroutine: hgeti4 (hstring,keyword,ival) returns long integer + * Subroutine: hgetr4 (hstring,keyword,rval) returns real + * Subroutine: hgetra (hstring,keyword,ra) returns double RA in degrees + * Subroutine: hgetdec (hstring,keyword,dec) returns double Dec in degrees + * Subroutine: hgetr8c (hstring,keyword,wchar,dval) returns double + * Subroutine: hgetr8 (hstring,keyword,dval) returns double + * Subroutine: hgetl (hstring,keyword,lval) returns logical int (0=F, 1=T) + * Subroutine: hgetsc (hstring,keyword,wchar,lstr,str) returns character string + * Subroutine: hgets (hstring,keyword, lstr, str) returns character string + * Subroutine: hgetm (hstring,keyword, lstr, str) returns multi-keyword string + * Subroutine: hgetdate (hstring,keyword,date) returns date as fractional year + * Subroutine: hgetndec (hstring, keyword, ndec) returns number of dec. places + * Subroutine: hgetc (hstring,keyword) returns character string + * Subroutine: blsearch (hstring,keyword) returns pointer to blank lines + before keyword + * Subroutine: ksearch (hstring,keyword) returns pointer to header string entry + * Subroutine: str2ra (in) converts string to right ascension in degrees + * Subroutine: str2dec (in) converts string to declination in degrees + * Subroutine: strsrch (s1, s2) finds string s2 in null-terminated string s1 + * Subroutine: strnsrch (s1, s2, ls1) finds string s2 in ls1-byte string s1 + * Subroutine: hlength (header,lhead) sets length of FITS header for searching + * Subroutine: isnum (string) returns 1 if integer, 2 if fp number, else 0 + * Subroutine: notnum (string) returns 0 if number, else 1 + * Subroutine: numdec (string) returns number of decimal places in numeric string + * Subroutine: strfix (string,blankfill,zerodrop) removes extraneous characters + */ + +#include /* NULL, strlen, strstr, strcpy */ +#include +#include "fitshead.h" /* FITS header extraction subroutines */ +#include +#ifndef VMS +#include +#else +#define INT_MAX 2147483647 /* Biggest number that can fit in long */ +#define SHRT_MAX 32767 +#endif +#define VLENGTH 81 + +#ifdef USE_SAOLIB +static int use_saolib=0; +#endif + +char *hgetc (); + +static char val[VLENGTH+1]; +static int multiline = 0; + +static int lhead0 = 0; /* Length of header string */ + +/* Set the length of the header string, if not terminated by NULL */ +int +hlength (header, lhead) +const char *header; /* FITS header */ +int lhead; /* Maximum length of FITS header */ +{ + char *hend; + if (lhead > 0) + lhead0 = lhead; + else { + lhead0 = 0; + hend = ksearch (header,"END"); + lhead0 = hend + 80 - header; + } + return (lhead0); +} + +/* Return the length of the header string, computing it if lhead0 not set */ +int +gethlength (header) +char *header; /* FITS header */ +{ + if (lhead0 > 0) + return (lhead0); + else + return (hlength (header, 0)); +} + + +/* Extract Integer*4 value for variable from FITS header string */ + +int +hgeti4c (hstring,keyword,wchar,ival) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for + a line beginning with this string. if "[n]" is + present, the n'th token in the value is returned. + (the first 8 characters must be unique) */ +const char *wchar; /* Character of multiple WCS header; =0 if unused */ +int *ival; /* Keyword value returned */ +{ + char keyword1[16]; + int lkey; + + if (wchar[0] < (char) 64) + return (hgeti4 (hstring, keyword, ival)); + else { + strcpy (keyword1, keyword); + lkey = strlen (keyword); + keyword1[lkey] = wchar[0]; + keyword1[lkey+1] = (char) 0; + return (hgeti4 (hstring, keyword1, ival)); + } +} + + +/* Extract long value for variable from FITS header string */ + +int +hgeti4 (hstring,keyword,ival) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +int *ival; +{ + char *value; + double dval; + int minint; + int lval; + char *dchar; + + /* Get value and comment from header string */ + value = hgetc (hstring,keyword); + + /* Translate value from ASCII to binary */ + if (value != NULL) { + if (value[0] == '#') value++; + minint = -INT_MAX - 1; + lval = strlen (value); + if (lval > VLENGTH) { + strncpy (val, value, VLENGTH); + val[VLENGTH] = (char) 0; + } + else + strcpy (val, value); + if (isnum (val) == 2) { + if ((dchar = strchr (val, 'D'))) + *dchar = 'e'; + if ((dchar = strchr (val, 'd'))) + *dchar = 'e'; + if ((dchar = strchr (val, 'E'))) + *dchar = 'e'; + } + dval = atof (val); + if (dval+0.001 > INT_MAX) + *ival = INT_MAX; + else if (dval >= 0) + *ival = (int) (dval + 0.001); + else if (dval-0.001 < minint) + *ival = minint; + else + *ival = (int) (dval - 0.001); + return (1); + } + else { + return (0); + } +} + + +/* Extract integer*2 value for variable from fits header string */ + +int +hgeti2 (hstring,keyword,ival) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +short *ival; +{ + char *value; + double dval; + int minshort; + int lval; + char *dchar; + + /* Get value and comment from header string */ + value = hgetc (hstring,keyword); + + /* Translate value from ASCII to binary */ + if (value != NULL) { + if (value[0] == '#') value++; + lval = strlen (value); + if (lval > VLENGTH) { + strncpy (val, value, VLENGTH); + val[VLENGTH] = (char) 0; + } + else + strcpy (val, value); + if (isnum (val) == 2) { + if ((dchar = strchr (val, 'D'))) + *dchar = 'e'; + if ((dchar = strchr (val, 'd'))) + *dchar = 'e'; + if ((dchar = strchr (val, 'E'))) + *dchar = 'e'; + } + dval = atof (val); + minshort = -SHRT_MAX - 1; + if (dval+0.001 > SHRT_MAX) + *ival = SHRT_MAX; + else if (dval >= 0) + *ival = (short) (dval + 0.001); + else if (dval-0.001 < minshort) + *ival = minshort; + else + *ival = (short) (dval - 0.001); + return (1); + } + else { + return (0); + } +} + +/* Extract real value for variable from FITS header string */ + +int +hgetr4 (hstring,keyword,rval) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +float *rval; +{ + char *value; + int lval; + char *dchar; + + /* Get value and comment from header string */ + value = hgetc (hstring,keyword); + + /* translate value from ASCII to binary */ + if (value != NULL) { + if (value[0] == '#') value++; + lval = strlen (value); + if (lval > VLENGTH) { + strncpy (val, value, VLENGTH); + val[VLENGTH] = (char) 0; + } + else + strcpy (val, value); + if (isnum (val) == 2) { + if ((dchar = strchr (val, 'D'))) + *dchar = 'e'; + if ((dchar = strchr (val, 'd'))) + *dchar = 'e'; + if ((dchar = strchr (val, 'E'))) + *dchar = 'e'; + } + *rval = (float) atof (val); + return (1); + } + else { + return (0); + } +} + + +/* Extract real*8 right ascension in degrees from FITS header string */ + +int +hgetra (hstring,keyword,dval) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +double *dval; /* Right ascension in degrees (returned) */ +{ + char *value; + + /* Get value from header string */ + value = hgetc (hstring,keyword); + + /* Translate value from ASCII colon-delimited string to binary */ + if (value != NULL) { + *dval = str2ra (value); + return (1); + } + else + return (0); +} + + +/* Extract real*8 declination in degrees from FITS header string */ + +int +hgetdec (hstring,keyword,dval) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +double *dval; /* Right ascension in degrees (returned) */ +{ + char *value; + + /* Get value from header string */ + value = hgetc (hstring,keyword); + + /* Translate value from ASCII colon-delimited string to binary */ + if (value != NULL) { + *dval = str2dec (value); + return (1); + } + else + return (0); +} + + +/* Extract real*8 value for variable from FITS header string */ + +int +hgetr8c (hstring,keyword,wchar,dval) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for + a line beginning with this string. if "[n]" is + present, the n'th token in the value is returned. + (the first 8 characters must be unique) */ +const char *wchar; /* Character of multiple WCS header; =0 if unused */ +double *dval; /* Keyword value returned */ +{ + char keyword1[16]; + int lkey; + + if (wchar[0] < (char) 64) + return (hgetr8 (hstring, keyword, dval)); + else { + strcpy (keyword1, keyword); + lkey = strlen (keyword); + keyword1[lkey] = wchar[0]; + keyword1[lkey+1] = (char) 0; + return (hgetr8 (hstring, keyword1, dval)); + } +} + + + +/* Extract real*8 value for variable from FITS header string */ + +int +hgetr8 (hstring,keyword,dval) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +double *dval; +{ + char *value; + int lval; + char *dchar; + + /* Get value and comment from header string */ + value = hgetc (hstring,keyword); + + /* Translate value from ASCII to binary */ + if (value != NULL) { + if (value[0] == '#') value++; + lval = strlen (value); + if (lval > VLENGTH) { + strncpy (val, value, VLENGTH); + val[VLENGTH] = (char) 0; + } + else + strcpy (val, value); + if (isnum (val) == 2) { + if ((dchar = strchr (val, 'D'))) + *dchar = 'e'; + if ((dchar = strchr (val, 'd'))) + *dchar = 'e'; + if ((dchar = strchr (val, 'E'))) + *dchar = 'e'; + } + *dval = atof (val); + return (1); + } + else { + return (0); + } +} + + +/* Extract logical value for variable from FITS header string */ + +int +hgetl (hstring,keyword,ival) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +int *ival; +{ + char *value; + char newval; + int lval; + + /* Get value and comment from header string */ + value = hgetc (hstring,keyword); + + /* Translate value from ASCII to binary */ + if (value != NULL) { + lval = strlen (value); + if (lval > VLENGTH) { + strncpy (val, value, VLENGTH); + val[VLENGTH] = (char) 0; + } + else + strcpy (val, value); + newval = val[0]; + if (newval == 't' || newval == 'T') + *ival = 1; + else + *ival = 0; + return (1); + } + else { + return (0); + } +} + + +/* Extract real*8 date from FITS header string (dd/mm/yy or dd-mm-yy) */ + +int +hgetdate (hstring,keyword,dval) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +double *dval; +{ + double yeardays, seconds, fday; + char *value,*sstr, *dstr, *tstr, *cstr, *nval; + int year, month, day, yday, i, hours, minutes; + static int mday[12] = {31,28,31,30,31,30,31,31,30,31,30,31}; + + /* Get value and comment from header string */ + value = hgetc (hstring,keyword); + + /* Translate value from ASCII to binary */ + if (value != NULL) { + sstr = strchr (value,'/'); + dstr = strchr (value,'-'); + + /* Original FITS date format: dd/mm/yy */ + if (sstr > value) { + *sstr = '\0'; + day = (int) atof (value); + *sstr = '/'; + nval = sstr + 1; + sstr = strchr (nval,'/'); + if (sstr == NULL) + sstr = strchr (nval,'-'); + if (sstr > value) { + *sstr = '\0'; + month = (int) atof (nval); + *sstr = '/'; + nval = sstr + 1; + year = (int) atof (nval); + if (day > 31) { + yday = year; + year = day; + day = yday; + } + if (year >= 0 && year <= 49) + year = year + 2000; + else if (year < 100) + year = year + 1900; + if ((year % 4) == 0) + mday[1] = 29; + else + mday[1] = 28; + if ((year % 100) == 0 && (year % 400) != 0) + mday[1] = 28; + if (day > mday[month-1]) + day = mday[month-1]; + else if (day < 1) + day = 1; + if (mday[1] == 28) + yeardays = 365.0; + else + yeardays = 366.0; + yday = day - 1; + for (i = 0; i < month-1; i++) + yday = yday + mday[i]; + *dval = (double) year + ((double)yday / yeardays); + return (1); + } + else + return (0); + } + + /* New FITS date format: yyyy-mm-ddThh:mm:ss[.sss] */ + else if (dstr > value) { + *dstr = '\0'; + year = (int) atof (value); + *dstr = '-'; + nval = dstr + 1; + dstr = strchr (nval,'-'); + month = 1; + day = 1; + tstr = NULL; + if (dstr > value) { + *dstr = '\0'; + month = (int) atof (nval); + *dstr = '-'; + nval = dstr + 1; + tstr = strchr (nval,'T'); + if (tstr > value) + *tstr = '\0'; + day = (int) atof (nval); + if (tstr > value) + *tstr = 'T'; + } + + /* If year is < 32, it is really day of month in old format */ + if (year < 32) { + i = year; + year = day + 1900; + day = i; + } + + if ((year % 4) == 0) + mday[1] = 29; + else + mday[1] = 28; + if ((year % 100) == 0 && (year % 400) != 0) + mday[1] = 28; + if (day > mday[month-1]) + day = mday[month-1]; + else if (day < 1) + day = 1; + if (mday[1] == 28) + yeardays = 365.0; + else + yeardays = 366.0; + yday = day - 1; + for (i = 0; i < month-1; i++) + yday = yday + mday[i]; + *dval = (double) year + ((double)yday / yeardays); + + /* Extract time, if it is present */ + if (tstr > value) { + nval = tstr + 1; + hours = 0.0; + minutes = 0.0; + seconds = 0.0; + cstr = strchr (nval,':'); + if (cstr > value) { + *cstr = '\0'; + hours = (int) atof (nval); + *cstr = ':'; + nval = cstr + 1; + cstr = strchr (nval,':'); + if (cstr > value) { + *cstr = '\0'; + minutes = (int) atof (nval); + *cstr = ':'; + nval = cstr + 1; + seconds = atof (nval); + } + else { + minutes = (int) atof (nval); + seconds = 0.0; + } + } + fday = ((3.6e3 * (double)hours) + (6.e1 * (double)minutes) + + seconds) / 8.64e4; + *dval = *dval + (fday / yeardays); + } + return (1); + } + else + return (0); + } + else + return (0); +} + + +/* Extract IRAF multiple-keyword string value from FITS header string */ + +int +hgetm (hstring, keyword, lstr, str) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the root name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +const int lstr; /* Size of str in characters */ +char *str; /* String (returned) */ +{ + char *value; + char *stri; + char keywordi[16]; + int lval, lstri, ikey; + char keyform[8]; + + stri = str; + lstri = lstr; + + sprintf (keywordi, "%s_1", keyword); + if (ksearch (hstring, keywordi)) + strcpy (keyform, "%s_%d"); + else { + sprintf (keywordi, "%s_01", keyword); + if (ksearch (hstring, keywordi)) + strcpy (keyform, "%s_%02d"); + else { + sprintf (keywordi, "%s_001", keyword); + if (ksearch (hstring, keywordi)) + strcpy (keyform, "%s_%03d"); + else if (ksearch (hstring, keywordi)) + strcpy (keyform, "%s_%03d"); + else + return (0); + } + } + + /* Loop through sequentially-named keywords */ + multiline = 1; + for (ikey = 1; ikey < 500; ikey++) { + sprintf (keywordi, keyform, keyword, ikey); + + /* Get value for this keyword */ + value = hgetc (hstring, keywordi); + if (value != NULL) { + lval = strlen (value); + if (lval < lstri) + strcpy (stri, value); + else if (lstri > 1) { + strncpy (stri, value, lstri-1); + stri[lstri] = (char) 0; + break; + } + else { + str[0] = value[0]; + break; + } + } + else + break; + stri = stri + lval; + lstri = lstri - lval; + } + multiline = 0; + + /* Return 1 if any keyword found, else 0 */ + if (ikey > 1) + return (1); + else + return (0); +} + + +/* Extract string value for variable from FITS header string */ + +int +hgetsc (hstring,keyword,wchar,lstr,str) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for + a line beginning with this string. if "[n]" is + present, the n'th token in the value is returned. + (the first 8 characters must be unique) */ +const char *wchar; /* Character of multiple WCS header; =0 if unused */ +const int lstr; /* Size of str in characters */ +char *str; /* String (returned) */ +{ + char keyword1[16]; + int lkey; + + if (wchar[0] < (char) 64) + return (hgets (hstring, keyword, lstr, str)); + else { + strcpy (keyword1, keyword); + lkey = strlen (keyword); + keyword1[lkey] = wchar[0]; + keyword1[lkey+1] = (char) 0; + return (hgets (hstring, keyword1, lstr, str)); + } +} + + +/* Extract string value for variable from FITS header string */ + +int +hgets (hstring, keyword, lstr, str) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +const int lstr; /* Size of str in characters */ +char *str; /* String (returned) */ +{ + char *value; + int lval; + + /* Get value and comment from header string */ + value = hgetc (hstring,keyword); + + if (value != NULL) { + lval = strlen (value); + if (lval < lstr) + strcpy (str, value); + else if (lstr > 1) + strncpy (str, value, lstr-1); + else + str[0] = value[0]; + return (1); + } + else + return (0); +} + + +/* Extract number of decimal places for value in FITS header string */ + +int +hgetndec (hstring, keyword, ndec) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +int *ndec; /* Number of decimal places in keyword value */ +{ + char *value; + int i, nchar; + + /* Get value and comment from header string */ + value = hgetc (hstring,keyword); + + /* Find end of string and count backward to decimal point */ + *ndec = 0; + if (value != NULL) { + nchar = strlen (value); + for (i = nchar-1; i >= 0; i--) { + if (value[i] == '.') + return (1); + *ndec = *ndec + 1; + } + return (1); + } + else + return (0); +} + + +/* Extract character value for variable from FITS header string */ + +char * +hgetc (hstring,keyword0) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword0; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +{ + static char cval[80]; + char *value; + char cwhite[2]; + char squot[2], dquot[2], lbracket[2], rbracket[2], slash[2], comma[2]; + char space; + char keyword[81]; /* large for ESO hierarchical keywords */ + char line[100]; + char *vpos, *cpar; + char *q1, *q2, *v1, *v2, *c1, *brack1, *brack2; + int ipar, i, lkey; + +#ifdef USE_SAOLIB + int iel=1, ip=1, nel, np, ier; + char *get_fits_head_str(); + + if( !use_saolib ){ +#endif + + squot[0] = (char) 39; + squot[1] = (char) 0; + dquot[0] = (char) 34; + dquot[1] = (char) 0; + lbracket[0] = (char) 91; + lbracket[1] = (char) 0; + comma[0] = (char) 44; + comma[1] = (char) 0; + rbracket[0] = (char) 93; + rbracket[1] = (char) 0; + slash[0] = (char) 47; + slash[1] = (char) 0; + space = (char) 32; + + /* Find length of variable name */ + strncpy (keyword,keyword0, sizeof(keyword)-1); + brack1 = strsrch (keyword,lbracket); + if (brack1 == NULL) + brack1 = strsrch (keyword,comma); + if (brack1 != NULL) { + *brack1 = '\0'; + brack1++; + } + + /* Search header string for variable name */ + vpos = ksearch (hstring,keyword); + + /* Exit if not found */ + if (vpos == NULL) + return (NULL); + + /* Initialize line to nulls */ + for (i = 0; i < 100; i++) + line[i] = 0; + +/* In standard FITS, data lasts until 80th character */ + + /* Extract entry for this variable from the header */ + strncpy (line,vpos,80); + + /* Check for quoted value */ + q1 = strsrch (line,squot); + c1 = strsrch (line,slash); + if (q1 != NULL) { + if (c1 != NULL && q1 < c1) { + q2 = strsrch (q1+1,squot); + if (q2 == NULL) { + q2 = c1 - 1; + while (*q2 == space) + q2--; + q2++; + } + else if (c1 < q2) + c1 = strsrch (q2,slash); + } + else if (c1 == NULL) { + q2 = strsrch (q1+1,squot); + if (q2 == NULL) { + q2 = line + 79; + while (*q2 == space) + q2--; + q2++; + } + } + else + q1 = NULL; + } + else { + q1 = strsrch (line,dquot); + if (q1 != NULL) { + if (c1 != NULL && q1 < c1) { + q2 = strsrch (q1+1,dquot); + if (q2 == NULL) { + q2 = c1 - 1; + while (*q2 == space) + q2--; + q2++; + } + else if (c1 < q2) + c1 = strsrch (q2,slash); + } + else if (c1 == NULL) { + q2 = strsrch (q1+1,dquot); + if (q2 == NULL) { + q2 = line + 79; + while (*q2 == space) + q2--; + q2++; + } + } + else + q1 = NULL; + } + else { + q1 = NULL; + q2 = line + 10; + } + } + + /* Extract value and remove excess spaces */ + if (q1 != NULL) { + v1 = q1 + 1; + v2 = q2; + } + else { + v1 = strsrch (line,"="); + if (v1 == NULL) + v1 = line + 9; + else + v1 = v1 + 1; + c1 = strsrch (line,"/"); + if (c1 != NULL) + v2 = c1; + else + v2 = line + 79; + } + + /* Ignore leading spaces if not multiline */ + if (!multiline) { + while (*v1 == ' ' && v1 < v2) { + v1++; + } + } + + /* Drop trailing spaces */ + *v2 = '\0'; + if (!multiline) { + v2--; + while ((*v2 == ' ' || *v2 == (char) 13) && v2 > v1) { + *v2 = '\0'; + v2--; + } + } + + /* Convert -zero to just plain 0 */ + if (!strcmp (v1, "-0")) + v1++; + strcpy (cval,v1); + value = cval; + + /* If keyword has brackets, extract appropriate token from value */ + if (brack1 != NULL) { + brack2 = strsrch (brack1,rbracket); + if (brack2 != NULL) + *brack2 = '\0'; + if (isnum (brack1)) { + ipar = atoi (brack1); + cwhite[0] = ' '; + cwhite[1] = '\0'; + if (ipar > 0) { + for (i = 1; i <= ipar; i++) { + cpar = strtok (v1,cwhite); + v1 = NULL; + } + if (cpar != NULL) { + strcpy (cval,cpar); + value = cval; + } + else + value = NULL; + } + + /* If token counter is negative, include rest of value */ + else if (ipar < 0) { + for (i = 1; i < -ipar; i++) { + v1 = strchr (v1, ' '); + if (v1 == NULL) + break; + else + v1 = v1 + 1; + } + if (v1 != NULL) { + strcpy (cval, v1); + value = cval; + } + else + value = NULL; + } + } + else { + lkey = strlen (brack1); + for (i = 0; i < lkey; i++) { + if (brack1[i] > 64 && brack1[i] < 91) + brack1[i] = brack1[i] + 32; + } + v1 = igetc (cval, brack1); + if (v1) { + strcpy (cval,v1); + value = cval; + } + else + value = NULL; + } + } + + return (value); +#ifdef USE_SAOLIB + } else { + return(get_fits_head_str(keyword0, iel, ip, &nel, &np, &ier, hstring)); + } +#endif +} + + +/* Find beginning of fillable blank line before FITS header keyword line */ + +char * +blsearch (hstring,keyword) + +/* Find entry for keyword keyword in FITS header string hstring. + (the keyword may have a maximum of eight letters) + NULL is returned if the keyword is not found */ + +const char *hstring; /* character string containing fits-style header + information in the format = {/ } + the default is that each entry is 80 characters long; + however, lines may be of arbitrary length terminated by + nulls, carriage returns or linefeeds, if packed is true. */ +const char *keyword; /* character string containing the name of the variable + to be returned. ksearch searches for a line beginning + with this string. The string may be a character + literal or a character variable terminated by a null + or '$'. it is truncated to 8 characters. */ +{ + const char *headlast; + char *loc, *headnext, *pval, *lc, *line; + char *bval; + int icol, nextchar, lkey, nleft, lhstr; + + pval = 0; + + /* Search header string for variable name */ + if (lhead0) + lhstr = lhead0; + else { + lhstr = 0; + while (lhstr < 256000 && hstring[lhstr] != 0) + lhstr++; + } + headlast = hstring + lhstr; + headnext = (char *) hstring; + pval = NULL; + while (headnext < headlast) { + nleft = headlast - headnext; + loc = strncsrch (headnext, keyword, nleft); + + /* Exit if keyword is not found */ + if (loc == NULL) { + break; + } + + icol = (loc - hstring) % 80; + lkey = strlen (keyword); + nextchar = (int) *(loc + lkey); + + /* If this is not in the first 8 characters of a line, keep searching */ + if (icol > 7) + headnext = loc + 1; + + /* If parameter name in header is longer, keep searching */ + else if (nextchar != 61 && nextchar > 32 && nextchar < 127) + headnext = loc + 1; + + /* If preceeding characters in line are not blanks, keep searching */ + else { + line = loc - icol; + for (lc = line; lc < loc; lc++) { + if (*lc != ' ') + headnext = loc + 1; + } + + /* Return pointer to start of line if match */ + if (loc >= headnext) { + pval = line; + break; + } + } + } + + /* Return NULL to calling program if keyword is not found */ + if (pval == NULL) + return (pval); + + /* Return NULL if keyword is found at start of FITS header string */ + if (pval == hstring) + return (NULL); + + /* Find last nonblank in FITS header string line before requested keyword */ + bval = pval - 80; + while (!strncmp (bval," ",8) && bval >= hstring) + bval = bval - 80; + bval = bval + 80; + + /* Return pointer to calling program if blank lines found */ + if (bval < pval && bval >= hstring) + return (bval); + else + return (NULL); +} + + +/* Find FITS header line containing specified keyword */ + +/*** waj ***/ +extern char* findit(char*,char*); +char* ksearch(const char* hstring, const char* keyword) +{ + return findit((char*)hstring, (char*)keyword); +} + +char * +ksearchh (hstring,keyword) +/*** waj ***/ + +/* Find entry for keyword keyword in FITS header string hstring. + (the keyword may have a maximum of eight letters) + NULL is returned if the keyword is not found */ + +const char *hstring; /* character string containing fits-style header + information in the format = {/ } + the default is that each entry is 80 characters long; + however, lines may be of arbitrary length terminated by + nulls, carriage returns or linefeeds, if packed is true. */ +const char *keyword; /* character string containing the name of the variable + to be returned. ksearch searches for a line beginning + with this string. The string may be a character + literal or a character variable terminated by a null + or '$'. it is truncated to 8 characters. */ +{ + const char *headlast; + char *loc, *headnext, *pval, *lc, *line; + int icol, nextchar, lkey, nleft, lhead, lmax; + +#ifdef USE_SAOLIB + int iel=1, ip=1, nel, np, ier; + char *get_fits_head_str(); + + if( !use_saolib ){ +#endif + + pval = 0; + +/* Find current length of header string */ + if (lhead0) + lmax = lhead0; + else + lmax = 256000; + for (lhead = 0; lhead < lmax; lhead++) { + if (hstring[lhead] <= (char) 0) + break; + } + +/* Search header string for variable name */ + headlast = hstring + lhead; + headnext = (char *) hstring; + pval = NULL; + while (headnext < headlast) { + nleft = headlast - headnext; + loc = strncsrch (headnext, keyword, nleft); + + /* Exit if keyword is not found */ + if (loc == NULL) { + break; + } + + icol = (loc - hstring) % 80; + lkey = strlen (keyword); + nextchar = (int) *(loc + lkey); + + /* If this is not in the first 8 characters of a line, keep searching */ + if (icol > 7) + headnext = loc + 1; + + /* If parameter name in header is longer, keep searching */ + else if (nextchar != 61 && nextchar > 32 && nextchar < 127) + headnext = loc + 1; + + /* If preceeding characters in line are not blanks, keep searching */ + else { + line = loc - icol; + for (lc = line; lc < loc; lc++) { + if (*lc != ' ') + headnext = loc + 1; + } + + /* Return pointer to start of line if match */ + if (loc >= headnext) { + pval = line; + break; + } + } + } + +/* Return pointer to calling program */ + return (pval); + +#ifdef USE_SAOLIB + } + else { + if (get_fits_head_str(keyword,iel,ip,&nel,&np,&ier,hstring) != NULL) + return(hstring); + else + return(NULL); + } +#endif +} + + +/* Return the right ascension in degrees from sexagesimal hours or decimal degrees */ + +double +str2ra (in) + +const char *in; /* Character string of sexigesimal hours or decimal degrees */ + +{ + double ra; /* Right ascension in degrees (returned) */ + + ra = str2dec (in); + if (strsrch (in,":")) + ra = ra * 15.0; + + return (ra); +} + + +/* Return the declination in degrees from sexagesimal or decimal degrees */ + +double +str2dec (in) + +const char *in; /* Character string of sexigesimal or decimal degrees */ + +{ + double dec; /* Declination in degrees (returned) */ + double deg, min, sec, sign; + char *value, *c1, *c2; + int lval; + char *dchar; + + dec = 0.0; + + /* Return 0.0 if string is null */ + if (in == NULL) + return (dec); + + /* Translate value from ASCII colon-delimited string to binary */ + if (in[0]) { + value = (char *) in; + + /* Remove leading spaces */ + while (*value == ' ') + value++; + + /* Save sign */ + if (*value == '-') { + sign = -1.0; + value++; + } + else if (*value == '+') { + sign = 1.0; + value++; + } + else + sign = 1.0; + + /* Turn comma into space */ + if ((c1 = strsrch (value,",")) != NULL) + *c1 = ' '; + + /* Remove trailing spaces */ + lval = strlen (value); + while (value[lval-1] == ' ') + lval--; + + if ((c1 = strsrch (value,":")) == NULL) + c1 = strnsrch (value," ",lval); + if (c1 != NULL) { + *c1 = 0; + deg = (double) atoi (value); + *c1 = ':'; + value = c1 + 1; + if ((c2 = strsrch (value,":")) == NULL) + c2 = strsrch (value," "); + if (c2 != NULL) { + *c2 = 0; + min = (double) atoi (value); + *c2 = ':'; + value = c2 + 1; + sec = atof (value); + } + else { + sec = 0.0; + if ((c1 = strsrch (value,".")) != NULL) + min = atof (value); + if (strlen (value) > 0) + min = (double) atoi (value); + } + dec = sign * (deg + (min / 60.0) + (sec / 3600.0)); + } + else if (isnum (value) == 2) { + if ((dchar = strchr (value, 'D'))) + *dchar = 'e'; + if ((dchar = strchr (value, 'd'))) + *dchar = 'e'; + if ((dchar = strchr (value, 'E'))) + *dchar = 'e'; + dec = sign * atof (value); + } + else + dec = sign * (double) atoi (value); + } + return (dec); +} + + +/* Find string s2 within null-terminated string s1 */ + +char * +strsrch (s1, s2) + +const char *s1; /* String to search */ +const char *s2; /* String to look for */ + +{ + int ls1; + ls1 = strlen (s1); + return (strnsrch (s1, s2, ls1)); +} + + +/* Find string s2 within string s1 */ + +char * +strnsrch (s1, s2, ls1) + +const char *s1; /* String to search */ +const char *s2; /* String to look for */ +const int ls1; /* Length of string being searched */ + +{ + char *s,*s1e; + char cfirst,clast; + int i,ls2; + + /* Return null string if either pointer is NULL */ + if (s1 == NULL || s2 == NULL) + return (NULL); + + /* A zero-length pattern is found in any string */ + ls2 = strlen (s2); + if (ls2 ==0) + return ((char *) s1); + + /* Only a zero-length string can be found in a zero-length string */ + if (ls1 ==0) + return (NULL); + + cfirst = (char) s2[0]; + clast = (char) s2[ls2-1]; + s1e = (char *) s1 + (int) ls1 - ls2 + 1; + s = (char *) s1; + while (s < s1e) { + + /* Search for first character in pattern string */ + if (*s == cfirst) { + + /* If single character search, return */ + if (ls2 == 1) + return (s); + + /* Search for last character in pattern string if first found */ + if (s[ls2-1] == clast) { + + /* If two-character search, return */ + if (ls2 == 2) + return (s); + + /* If 3 or more characters, check for rest of search string */ + i = 1; + while (i < ls2 && s[i] == s2[i]) + i++; + + /* If entire string matches, return */ + if (i >= ls2) + return (s); + } + } + s++; + } + return (NULL); +} + + +/* Find string s2 within null-terminated string s1 (case-free search) */ + +char * +strcsrch (s1, s2) + +const char *s1; /* String to search */ +const char *s2; /* String to look for */ + +{ + int ls1; + ls1 = strlen ((char *) s1); + return (strncsrch (s1, s2, ls1)); +} + + +/* Find string s2 within string s1 (case-free search) */ + +char * +strncsrch (s1, s2, ls1) + +const char *s1; /* String to search */ +const char *s2; /* String to look for */ +const int ls1; /* Length of string being searched */ + +{ + char *s,*s1e, sl, *os2; + char cfirst,ocfirst; + char clast = ' '; + char oclast = ' '; + int i,ls2; + + /* Return null string if either pointer is NULL */ + if (s1 == NULL || s2 == NULL) + return (NULL); + + /* A zero-length pattern is found in any string */ + ls2 = strlen (s2); + if (ls2 ==0) + return ((char *) s1); + + /* Only a zero-length string can be found in a zero-length string */ + os2 = NULL; + if (ls1 ==0) + return (NULL); + + /* For one or two characters, set opposite case first and last letters */ + if (ls2 < 3) { + cfirst = (char) s2[0]; + if (cfirst > 96 && cfirst < 123) + ocfirst = cfirst - 32; + else if (cfirst > 64 && cfirst < 91) + ocfirst = cfirst + 32; + else + ocfirst = cfirst; + if (ls2 > 1) { + clast = s2[1]; + if (clast > 96 && clast < 123) + oclast = clast - 32; + else if (clast > 64 && clast < 91) + oclast = clast + 32; + else + oclast = clast; + } + } + + /* Else duplicate string with opposite case letters for comparison */ + else { + os2 = (char *) calloc (ls2, 1); + for (i = 0; i < ls2; i++) { + if (s2[i] > 96 && s2[i] < 123) + os2[i] = s2[i] - 32; + else if (s2[i] > 64 && s2[i] < 91) + os2[i] = s2[i] + 32; + else + os2[i] = s2[i]; + } + cfirst = s2[0]; + ocfirst = os2[0]; + clast = s2[ls2-1]; + oclast = os2[ls2-1]; + } + + /* Loop through input string, character by character */ + s = (char *) s1; + s1e = s + (int) ls1 - ls2 + 1; + while (s < s1e) { + + /* Search for first character in pattern string */ + if (*s == cfirst || *s == ocfirst) { + + /* If single character search, return */ + if (ls2 == 1) { + if (os2 != NULL) + free (os2); + return (s); + } + + /* Search for last character in pattern string if first found */ + sl = s[ls2-1]; + if (sl == clast || sl == oclast) { + + /* If two-character search, return */ + if (ls2 == 2) { + if (os2 != NULL) + free (os2); + return (s); + } + + /* If 3 or more characters, check for rest of search string */ + i = 1; + while (i < ls2 && (s[i] == (char) s2[i] || s[i] == os2[i])) + i++; + + /* If entire string matches, return */ + if (i >= ls2) { + if (os2 != NULL) + free (os2); + return (s); + } + } + } + s++; + } + if (os2 != NULL) + free (os2); + return (NULL); +} + + +int +notnum (string) + +const char *string; /* Character string */ +{ + if (isnum (string)) + return (0); + else + return (1); +} + + +/* ISNUM-- Return 1 if string is an integer number, + 2 if floating point, + 3 if sexigesimal, with or without decimal point + else 0 + */ + +int +isnum (string) + +const char *string; /* Character string */ +{ + int lstr, i, nd, cl; + char cstr, cstr1; + int fpcode; + + /* Return 0 if string is NULL */ + if (string == NULL) + return (0); + + lstr = strlen (string); + nd = 0; + cl = 0; + fpcode = 1; + + /* Return 0 if string starts with a D or E */ + cstr = string[0]; + if (cstr == 'D' || cstr == 'd' || + cstr == 'E' || cstr == 'e') { + return (0); + } + + /* Remove trailing spaces */ + while (string[lstr-1] == ' ') + lstr--; + + /* Numeric strings contain 0123456789-+ and d or e for exponents */ + for (i = 0; i < lstr; i++) { + cstr = string[i]; + if (cstr == '\n') + break; + + /* Ignore leading spaces */ + if (cstr == ' ' && nd == 0) + continue; + + if ((cstr < 48 || cstr > 57) && + cstr != '+' && cstr != '-' && + cstr != 'D' && cstr != 'd' && + cstr != 'E' && cstr != 'e' && + cstr != ':' && cstr != '.') + return (0); + else if (cstr == '+' || cstr == '-') { + if (string[i+1] == '-' || string[i+1] == '+') + return (0); + else if (i > 0) { + cstr1 = string[i-1]; + if (cstr1 != 'D' && cstr1 != 'd' && + cstr1 != 'E' && cstr1 != 'e' && + cstr1 != ':' && cstr1 != ' ') + return (0); + } + } + else if (cstr >= 47 && cstr <= 57) + nd++; + + /* Check for colon */ + else if (cstr == 58) + cl++; + if (cstr=='.' || cstr=='d' || cstr=='e' || cstr=='d' || cstr=='e') + fpcode = 2; + } + if (nd > 0) { + if (cl) + fpcode = 3; + return (fpcode); + } + else + return (0); +} + + +/* NUMDEC -- Return number of decimal places in numeric string (-1 if not number) */ + +int +numdec (string) + +const char *string; /* Numeric string */ +{ + char *cdot; + int lstr; + + if (notnum (string) && !strchr (string, ':')) + return (-1); + else { + lstr = strlen (string); + if ((cdot = strchr (string, '.')) == NULL) + return (0); + else + return (lstr - (cdot - string) - 1); + } +} + + +#ifdef USE_SAOLIB +int set_saolib(hstring) + void *hstring; +{ + if( *((int *)hstring) == 142857 ) + use_saolib = 1; + else + use_saolib = 0; +} + +#endif + + +/* Remove exponent, leading #, surrounding parentheses, + and/or trailing zeroes, if reasonable */ +void +strfix (string, fillblank, dropzero) + +char *string; /* String to modify */ +int fillblank; /* If nonzero, fill blanks with underscores */ +int dropzero; /* If nonzero, drop trailing zeroes */ +{ + char *sdot, *s, *strend, *str, ctemp, *slast; + int ndek, lstr, i; + + /* If number, ignore leading # and remove trailing non-numeric character */ + if (string[0] == '#') { + strend = string + strlen (string); + str = string + 1; + strend = str + strlen (str) - 1; + ctemp = *strend; + if (!isnum (strend)) + *strend = (char) 0; + if (isnum (str)) { + strend = string + strlen (string); + for (str = string; str < strend; str++) + *str = *(str + 1); + } + else + *strend = ctemp; + } + + /* Remove parentheses if they enclose the string */ + if (string[0] == '(') { + lstr = strlen (string); + if (string[lstr-1] == ')') { + string[lstr-1] = (char) 0; + strend = string + lstr - 1; + for (str = string; str < strend; str++) + *str = *(str+1); + string[lstr-2] = (char) 0; + } + } + + /* Remove positive exponent if there are enough digits given */ + if (isnum (string) > 1 && strsrch (string, "E+") != NULL) { + lstr = strlen (string); + ndek = (int) (string[lstr-1] - 48); + ndek = ndek + (10 * ((int) (string[lstr-2] - 48))); + if (ndek < lstr - 7) { + lstr = lstr - 4; + string[lstr] = (char) 0; + string[lstr+1] = (char) 0; + string[lstr+2] = (char) 0; + string[lstr+3] = (char) 0; + sdot = strchr (string, '.'); + if (ndek > 0 && sdot != NULL) { + for (i = 1; i <= ndek; i++) { + *sdot = *(sdot+1); + sdot++; + *sdot = '.'; + } + } + } + } + + /* Remove trailing zeroes if they are not significant */ + if (dropzero) { + if (isnum (string) > 1 && strchr (string, '.') != NULL && + strsrch (string, "E-") == NULL && + strsrch (string, "E+") == NULL && + strsrch (string, "e-") == NULL && + strsrch (string, "e+") == NULL) { + lstr = strlen (string); + s = string + lstr - 1; + while (*s == '0' && lstr > 1) { + if (*(s - 1) != '.') { + *s = (char) 0; + lstr --; + } + s--; + } + } + } + + /* Remove trailing decimal point */ + lstr = strlen (string); + s = string + lstr - 1; + if (*s == '.') + *s = (char) 0; + + /* Replace embedded blanks with underscores, if requested to */ + if (fillblank) { + lstr = strlen (string); + slast = string + lstr; + for (s = string; s < slast; s++) { + if (*s == ' ') *s = '_'; + } + } + + return; + +} + +/* Oct 28 1994 New program + * + * Mar 1 1995 Search for / after second quote, not first one + * May 2 1995 Initialize line in HGETC; deal with logicals in HGETL better + * May 4 1995 Declare STRSRCH in KSEARCH + * Aug 7 1995 Fix line initialization in HGETC + * Dec 22 1995 Add HGETRA and HGETDEC to get degrees from xx:xx:xx.xxx string + * + * Jan 26 1996 Fix HGETL to not crash when parameter is not present + * Feb 1 1996 Fix HGETC to deal with quotes correctly + * Feb 1 1996 Fix HGETDEG to deal with sign correctly + * Feb 6 1996 Add HGETS to update character strings + * Feb 8 1996 Fix STRSRCH to find final characters in string + * Feb 23 1996 Add string to degree conversions + * Apr 26 1996 Add HGETDATE to get fractional year from date string + * May 22 1996 Fix documentation; return double from STR2RA and STR2DEC + * May 28 1996 Fix string translation of RA and Dec when no seconds + * Jun 10 1996 Remove unused variables after running lint + * Jun 17 1996 Fix bug which failed to return single character strings + * Jul 1 1996 Skip sign when reading declination after testing for it + * Jul 19 1996 Do not divide by 15 if RA header value is already in degrees + * Aug 5 1996 Add STRNSRCH to search strings which are not null-terminated + * Aug 6 1996 Make minor changes after lint + * Aug 8 1996 Fix ksearch bug which finds wrong keywords + * Aug 13 1996 Fix sign bug in STR2DEC for degrees + * Aug 26 1996 Drop unused variables ICOL0, NLINE, PREVCHAR from KSEARCH + * Sep 10 1996 Fix header length setting code + * Oct 15 1996 Clean up loops and fix ICOL assignment + * Nov 13 1996 Handle integer degrees correctly in STR2DEC + * Nov 21 1996 Make changes for Linux thanks to Sidik Isani + * Dec 12 1996 Add ISNUM to check to see whether strings are numbers + * + * Jan 22 1997 Add ifdefs for Eric Mandel (SAOtng) + * Jan 27 1997 Convert to integer through ATOF so exponents are recognized + * Jul 25 1997 Implement FITS version of ISO date format + * + * Feb 24 1998 Implement code to return IRAF multiple-keyword strings + * Mar 12 1998 Add subroutine NOTNUM + * Mar 27 1998 Add changes to match SKYCAT version + * Apr 30 1998 Add BLSEARCH() to find blank lines before END + * May 27 1998 Add HGETNDEC() to get number of decimal places in entry + * Jun 1 1998 Add VMS patch from Harry Payne at StSci + * Jun 18 1998 Fix code which extracts tokens from string values + * Jul 21 1998 Drop minus sign for values of -0 + * Sep 29 1998 Treat hyphen-separated date as old format if 2-digit year + * Oct 7 1998 Clean up search for last blank line + * + * Apr 5 1999 Check lengths of strings before copying them + * May 5 1999 values.h -> POSIX limits.h: MAXINT->INT_MAX, MAXSHORT->SHRT_MAX + * Jul 15 1999 Add hgetm() options of 1- or 2-digit keyword extensions + * Oct 6 1999 Add gethlength() to return header length + * Oct 14 1999 In ksearch(), search only to null not to end of buffer + * Oct 15 1999 Return 1 from hgetndec() if successful + * Oct 20 1999 Drop unused variable after lint (val in hgetndec) + * Dec 3 1999 Fix isnum() to reject strings starting with a d or e + * Dec 20 1999 Update hgetdate() to get minutes and seconds right + * + * Feb 10 2000 Parse RA and Dec with spaces as well as colons as separators + * Feb 11 2000 Add null at end of multi-line keyword value character string + * Feb 25 2000 Change max search string length from 57600 to 256000 + * Mar 15 2000 Deal with missing second quotes in string values + * Mar 17 2000 Return 2 from isnum() if number is floating point (.de) + * Mar 17 2000 Ignore leading # for numeric values in header + * Mar 21 2000 Implement -n to get string value starting with nth token + * Apr 5 2000 Reject +- in isnum() + * Jun 9 2000 Read keyword values even if no equal sign is present + * Sep 20 2000 Ignore linefeed at end of number in isnum() + * Oct 23 2000 Fix handling of embedded + or - in isnum() + * + * Jan 19 2000 Return 0 from isnum(), str2ra(), and str2dec() if string is null + * Mar 30 2001 Fix header length finding algorithm in ksearch() + * Jul 13 2001 Make val[] static int instead of int; drop unused variables + * Sep 12 2001 Read yyyy/mm/dd dates as well as dd/mm/yyyy + * Sep 20 2001 Ignore leading spaces in str2dec() + * Sep 20 2001 Ignore trailing spaces in isnum() + * + * Apr 3 2002 Add hgetr8c(), hgeti4c(), and hgetsc() for multiple WCS handling + * Apr 26 2002 Fix bug in hgetsc(), hgeti4c(), and hgetr8c() found by Bill Joye + * Jun 26 2002 Do not drop leading or trailing spaces in multi-line values + * Aug 6 2002 Add strcsrch() and strncsrch() for case-insensitive searches + * Aug 30 2002 Fix bug so strcsrch() really is case-insensitive + * Oct 20 2003 Add numdec() to return number of decimal places in a string + * Dec 9 2003 Fix numdec() to return 0 if no digits after decimal point + * + * Feb 26 2004 Extract value from keyword=value strings within a keyword value + * Apr 9 2004 Use strncsrch() in ksearch() to find differently-cased keywords + * Apr 28 2004 Free os2 in strncsrch() only if it is allocated + * Jul 13 2004 Accept D, d, E, or e as exponent delimiter in floating points + * Aug 30 2004 Change numdec() to accept sexigesimal numbers (:'s) + * + * Jun 27 2005 Drop unused variables + * Aug 30 2005 Adjust code in hlength() + * + * Jun 20 2006 Initialize uninitialized variables in strnsrch() + * Jun 29 2006 Add new subroutine strfix() to clean strings for other uses + * Jul 13 2006 Increase maximum number of multiline keywords from 20 to 500 + * + * Jan 4 2007 Declare header, keyword to be const + * Jan 4 2007 Change WCS letter from char to char* + * Feb 28 2007 If header length is not set in hlength, set it to 0 + * May 31 2007 Add return value of 3 to isnum() if string has colon(s) + * Aug 22 2007 If closing quote not found, make one up + * + * Nov 12 2009 In strfix(), if drop enclosing parantheses + * + * Apr 19 2011 In str2dec(), change comma to space + * May 19 2011 In strncsrch() always free allocated memory before returning + */ diff --git a/tksao/wcssubs/hput.c b/tksao/wcssubs/hput.c new file mode 100644 index 0000000..7ec81ab --- /dev/null +++ b/tksao/wcssubs/hput.c @@ -0,0 +1,1316 @@ +/*** File libwcs/hput.c + *** September 9, 2011 + *** By Jessica Mink, jmink@cfa.harvard.edu + *** Harvard-Smithsonian Center for Astrophysics + *** Copyright (C) 1995-2011 + *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Correspondence concerning WCSTools should be addressed as follows: + Internet email: jmink@cfa.harvard.edu + Postal address: Jessica Mink + Smithsonian Astrophysical Observatory + 60 Garden St. + Cambridge, MA 02138 USA + + * Module: hput.c (Put FITS Header parameter values) + * Purpose: Implant values for parameters into FITS header string + * Subroutine: hputi4 (hstring,keyword,ival) sets int ival + * Subroutine: hputr4 (hstring,keyword,rval) sets real*4 rval + * Subroutine: hputr8 (hstring,keyword,dval) sets real*8 dval + * Subroutine: hputnr8 (hstring,keyword,ndec,dval) sets real*8 dval + * Subroutine: hputra (hstring,keyword,lval) sets right ascension as string + * Subroutine: hputdec (hstring,keyword,lval) sets declination as string + * Subroutine: hputl (hstring,keyword,lval) sets logical lval + * Subroutine: hputs (hstring,keyword,cval) sets character string adding '' + * Subroutine: hputm (hstring,keyword,cval) sets multi-line character string + * Subroutine: hputc (hstring,keyword,cval) sets character string cval + * Subroutine: hdel (hstring,keyword) deletes entry for keyword keyword + * Subroutine: hadd (hplace,keyword) adds entry for keyword at hplace + * Subroutine: hchange (hstring,keyword1,keyword2) changes keyword for entry + * Subroutine: hputcom (hstring,keyword,comment) sets comment for parameter keyword + * Subroutine: ra2str (out, lstr, ra, ndec) converts RA from degrees to string + * Subroutine: dec2str (out, lstr, dec, ndec) converts Dec from degrees to string + * Subroutine: deg2str (out, lstr, deg, ndec) converts degrees to string + * Subroutine: num2str (out, num, field, ndec) converts number to string + * Subroutine: getltime () returns current local time as ISO-style string + * Subroutine: getutime () returns current UT as ISO-style string + */ +#include +#include /* NULL, strlen, strstr, strcpy */ +#include +#include +#include +#include "fitshead.h" + +static int verbose=0; /* Set to 1 to print error messages and other info */ + +static void fixnegzero(); + + +/* HPUTI4 - Set int keyword = ival in FITS header string */ + +int +hputi4 (hstring,keyword,ival) + +char *hstring; /* FITS-style header information in the format + = {/ } + each entry is padded with spaces to 80 characters */ + +const char *keyword; /* Name of the variable in header to be returned. + If no line begins with this string, one is created. + The first 8 characters of keyword must be unique. */ +int ival; /* int number */ +{ + char value[30]; + + /* Translate value from binary to ASCII */ + sprintf (value,"%d",ival); + + /* Put value into header string */ + return (hputc (hstring,keyword,value)); +} + + +/* HPUTR4 - Set float keyword = rval in FITS header string */ + +int +hputr4 (hstring, keyword, rval) + +char *hstring; /* FITS header string */ +const char *keyword; /* Keyword name */ +const float *rval; /* float number */ + +{ + char value[30]; + + /* Translate value from binary to ASCII */ + sprintf (value, "%f", *rval); + + /* Remove sign if string is -0 or extension thereof */ + fixnegzero (value); + + /* Put value into header string */ + return (hputc (hstring, keyword, value)); +} + + +/* HPUTR8 - Set double keyword = dval in FITS header string */ + +int +hputr8 (hstring, keyword, dval) + +char *hstring; /* FITS header string */ +const char *keyword; /* Keyword name */ +const double dval; /* double number */ +{ + char value[30]; + + /* Translate value from binary to ASCII */ + sprintf (value, "%g", dval); + + /* Remove sign if string is -0 or extension thereof */ + fixnegzero (value); + + /* Put value into header string */ + return (hputc (hstring, keyword, value)); +} + + +/* HPUTNR8 - Set double keyword = dval in FITS header string */ + +int +hputnr8 (hstring, keyword, ndec, dval) + +char *hstring; /* FITS header string */ +const char *keyword; /* Keyword name */ +const int ndec; /* Number of decimal places to print */ +const double dval; /* double number */ +{ + char value[30]; + char format[8]; + int i, lval; + + /* Translate value from binary to ASCII */ + if (ndec < 0) { + sprintf (format, "%%.%dg", -ndec); + sprintf (value, format, dval); + lval = (int) strlen (value); + for (i = 0; i < lval; i++) + if (value[i] == 'e') value[i] = 'E'; + } + else { + sprintf (format, "%%.%df", ndec); + sprintf (value, format, dval); + } + + /* Remove sign if string is -0 or extension thereof */ + fixnegzero (value); + + /* Put value into header string */ + return (hputc (hstring, keyword, value)); +} + + +/* HPUTRA - Set double keyword = hh:mm:ss.sss in FITS header string */ + +int +hputra (hstring, keyword, ra) + +char *hstring; /* FITS header string */ +const char *keyword; /* Keyword name */ +const double ra; /* Right ascension in degrees */ +{ + char value[30]; + + /* Translate value from binary to ASCII */ + ra2str (value, 30, ra, 3); + + /* Remove sign if string is -0 or extension thereof */ + fixnegzero (value); + + /* Put value into header string */ + return (hputs (hstring, keyword, value)); +} + + +/* HPUTDEC - Set double keyword = dd:mm:ss.sss in FITS header string */ + +int +hputdec (hstring, keyword, dec) + +char *hstring; /* FITS header string */ +const char *keyword; /* Keyword name */ +const double dec; /* Declination in degrees */ +{ + char value[30]; + + /* Translate value from binary to ASCII */ + dec2str (value, 30, dec, 2); + + /* Remove sign if string is -0 or extension thereof */ + fixnegzero (value); + + /* Put value into header string */ + return (hputs (hstring, keyword, value)); +} + + +/* FIXNEGZERO -- Drop - sign from beginning of any string which is all zeros */ + +static void +fixnegzero (string) + +char *string; +{ + int i, lstr; + + if (string[0] != '-') + return; + + /* Drop out if any non-zero digits in this string */ + lstr = (int) strlen (string); + for (i = 1; i < lstr; i++) { + if (string[i] > '0' && string[i] <= '9') + return; + if (string[i] == 'd' || string[i] == 'e' || string[i] == ' ') + break; + } + + /* Drop - from start of string; overwrite string in place */ + for (i = 1; i < lstr; i++) + string[i-1] = string[i]; + string[lstr-1] = (char) 0; + + return; +} + + + +/* HPUTL - Set keyword = F if lval=0, else T, in FITS header string */ + +int +hputl (hstring, keyword,lval) + +char *hstring; /* FITS header */ +const char *keyword; /* Keyword name */ +const int lval; /* logical variable (0=false, else true) */ +{ + char value[8]; + + /* Translate value from binary to ASCII */ + if (lval) + strcpy (value, "T"); + else + strcpy (value, "F"); + + /* Put value into header string */ + return (hputc (hstring,keyword,value)); +} + + +/* HPUTM - Set multi-line character string in FITS header string */ +/* return number of keywords written */ + +int +hputm (hstring,keyword,cval) + +char *hstring; /* FITS header */ +const char *keyword; /* Keyword name root (6 characters or less) */ +const char *cval; /* character string containing the value for variable + keyword. trailing and leading blanks are removed. */ +{ + int lroot, lcv, i, ii, nkw, lkw, lval; + int comment = 0; + const char *v; + char keyroot[8], newkey[12], value[80]; + char squot = 39; + + /* If COMMENT or HISTORY, use the same keyword on every line */ + lkw = (int) strlen (keyword); + if (lkw == 7 && (strncmp (keyword,"COMMENT",7) == 0 || + strncmp (keyword,"HISTORY",7) == 0)) { + comment = 1; + lroot = 0; + } + + /* Set up keyword root, shortening it to 6 characters, if necessary */ + else { + comment = 0; + strcpy (keyroot, keyword); + lroot = (int) strlen (keyroot); + if (lroot > 6) { + keyroot[6] = (char) 0; + lroot = 6; + } + } + + /* Write keyword value one line of up to 67 characters at a time */ + ii = '1'; + nkw = 0; + lcv = (int) strlen (cval); + if (!comment) { + strcpy (newkey, keyroot); + strcat (newkey, "_"); + newkey[lroot+2] = (char) 0; + } + v = cval; + while (lcv > 0) { + if (lcv > 67) + lval = 67; + else + lval = lcv; + value[0] = squot; + for (i = 1; i <= lval; i++) + value[i] = *v++; + + /* Pad short strings to 8 characters */ + if (lval < 8) { + for (i = lval+1; i < 9; i++) + value[i] = ' '; + lval = 8; + } + value[lval+1] = squot; + value[lval+2] = (char) 0; + + /* Add this line to the header */ + if (comment) + i = hputc (hstring, keyroot, value); + else { + newkey[lroot+1] = ii; + ii++; + i = hputc (hstring, newkey, value); + } + if (i != 0) return (i); + nkw++; + if (lcv > 67) + lcv = lcv - 67; + else + break; + } + return (nkw); +} + + +/* HPUTS - Set character string keyword = 'cval' in FITS header string */ + +int +hputs (hstring,keyword,cval) + +char *hstring; /* FITS header */ +const char *keyword; /* Keyword name */ +const char *cval; /* character string containing the value for variable + keyword. trailing and leading blanks are removed. */ +{ + char squot = 39; + char value[80]; + int lcval, i, lkeyword; + + /* If COMMENT or HISTORY, just add it as is */ + lkeyword = (int) strlen (keyword); + if (lkeyword == 7 && (strncmp (keyword,"COMMENT",7) == 0 || + strncmp (keyword,"HISTORY",7) == 0)) + return (hputc (hstring,keyword,cval)); + + /* find length of variable string */ + lcval = (int) strlen (cval); + if (lcval > 67) + lcval = 67; + + /* Put single quote at start of string */ + value[0] = squot; + strncpy (&value[1],cval,lcval); + + /* If string is less than eight characters, pad it with spaces */ + if (lcval < 8) { + for (i = lcval; i < 8; i++) { + value[i+1] = ' '; + } + lcval = 8; + } + + /* Add single quote and null to end of string */ + value[lcval+1] = squot; + value[lcval+2] = (char) 0; + + /* Put value into header string */ + return (hputc (hstring,keyword,value)); +} + + +/* HPUTC - Set character string keyword = value in FITS header string */ +/* Return -1 if error, 0 if OK */ + +int +hputc (hstring,keyword,value) + +char *hstring; +const char *keyword; +const char *value; /* character string containing the value for variable + keyword. trailing and leading blanks are removed. */ +{ + char squot = 39; + char line[100]; + char newcom[50]; + char *vp, *v1, *v2, *q1, *q2, *c1, *ve; + int lkeyword, lcom, lval, lc, lv1, lhead, lblank, ln, nc, i; + + /* Find length of keyword, value, and header */ + lkeyword = (int) strlen (keyword); + lval = (int) strlen (value); + lhead = gethlength (hstring); + + /* If COMMENT or HISTORY, always add it just before the END */ + if (lkeyword == 7 && (strncmp (keyword,"COMMENT",7) == 0 || + strncmp (keyword,"HISTORY",7) == 0)) { + + /* First look for blank lines before END */ + v1 = blsearch (hstring, "END"); + + /* Otherwise, create a space for it at the end of the header */ + if (v1 == NULL) { + + /* Find end of header */ + v1 = ksearch (hstring,"END"); + + /* Align pointer at start of 80-character line */ + lc = v1 - hstring; + ln = lc / 80; + nc = ln * 80; + v1 = hstring + nc; + v2 = v1 + 80; + + /* If header length is exceeded, return error code */ + if (v2 - hstring > lhead) { + return (-1); + } + + /* Move END down 80 characters */ + strncpy (v2, v1, 80); + } + else + v2 = v1 + 80; + + /* Insert keyword */ + strncpy (v1,keyword,7); + + /* Pad with spaces */ + for (vp = v1+lkeyword; vp < v2; vp++) + *vp = ' '; + + if (lval > 71) + lv1 = 71; + else + lv1 = lval; + + /* Insert comment */ + strncpy (v1+9,value,lv1); + return (0); + } + + /* Otherwise search for keyword */ + else + v1 = ksearch (hstring,keyword); + + /* If parameter is not found, find a place to put it */ + if (v1 == NULL) { + + /* First look for blank lines before END */ + v1 = blsearch (hstring, "END"); + + /* Otherwise, create a space for it at the end of the header */ + if (v1 == NULL) { + ve = ksearch (hstring,"END"); + v1 = ve; + + /* Align pointer at start of 80-character line */ + lc = v1 - hstring; + ln = lc / 80; + nc = ln * 80; + v1 = hstring + nc; + v2 = v1 + 80; + + /* If header length is exceeded, return error code */ + if (v2 - hstring > lhead) { + return (-1); + } + + strncpy (v2, ve, 80); + } + else + v2 = v1 + 80; + lcom = 0; + newcom[0] = 0; + } + + /* Otherwise, extract the entry for this keyword from the header */ + else { + + /* Align pointer at start of 80-character line */ + lc = v1 - hstring; + ln = lc / 80; + nc = ln * 80; + v1 = hstring + nc; + v2 = v1 + 80; + + strncpy (line, v1, 80); + line[80] = 0; + v2 = v1 + 80; + + /* check for quoted value */ + q1 = strchr (line, squot); + if (q1 != NULL) { + q2 = strchr (q1+1,squot); + if (q2 != NULL) + c1 = strchr (q2,'/'); + else + c1 = strrchr (line+79,'/'); + } + else + c1 = strchr (line,'/'); + + /* extract comment and discount trailing spaces */ + if (c1 != NULL) { + lcom = 80 - (c1 + 2 - line); + strncpy (newcom, c1+2, lcom); + vp = newcom + lcom - 1; + while (vp-- > newcom && *vp == ' ') + lcom--; + } + else { + newcom[0] = 0; + lcom = 0; + } + } + + /* Fill new entry with spaces */ + for (vp = v1; vp < v2; vp++) + *vp = ' '; + + /* Copy keyword to new entry */ + strncpy (v1, keyword, lkeyword); + + /* Add parameter value in the appropriate place */ + vp = v1 + 8; + *vp = '='; + vp = v1 + 9; + *vp = ' '; + vp = vp + 1; + if (*value == squot) { + strncpy (vp, value, lval); + if (lval+12 > 31) + lc = lval + 12; + else + lc = 30; + } + else { + vp = v1 + 30 - lval; + strncpy (vp, value, lval); + lc = 30; + } + + /* Add comment in the appropriate place */ + if (lcom > 0) { + if (lc+2+lcom > 80) + lcom = 77 - lc; + vp = v1 + lc; /* Jul 16 1997: was vp = v1 + lc * 2 */ + *vp++ = ' '; + *vp++ = '/'; + *vp++ = ' '; + lblank = v2 - vp; + for (i = 0; i < lblank; i++) + vp[i] = ' '; + if (lcom > lblank) + lcom = lblank; + strncpy (vp, newcom, lcom); + } + + if (verbose) { + if (lcom > 0) + fprintf (stderr,"HPUT: %s = %s / %s\n",keyword, value, newcom); + else + fprintf (stderr,"HPUT: %s = %s\n",keyword, value); + } + + return (0); +} + + +/* HPUTCOM - Set comment for keyword or on line in FITS header string */ + +int +hputcom (hstring,keyword,comment) + + char *hstring; + const char *keyword; + const char *comment; +{ + char squot, slash, space; + char line[100]; + int lkeyword, lcom, lhead, i, lblank, ln, nc, lc; + char *vp, *v1, *v2, *c0, *c1, *q1, *q2; + + squot = (char) 39; + slash = (char) 47; + space = (char) 32; + + /* Find length of variable name */ + lkeyword = (int) strlen (keyword); + lhead = gethlength (hstring); + lcom = (int) strlen (comment); + + /* If COMMENT or HISTORY, always add it just before the END */ + if (lkeyword == 7 && (strncmp (keyword,"COMMENT",7) == 0 || + strncmp (keyword,"HISTORY",7) == 0)) { + + /* Find end of header */ + v1 = ksearch (hstring,"END"); + + /* Align pointer at start of 80-character line */ + lc = v1 - hstring; + ln = lc / 80; + nc = ln * 80; + v1 = hstring + nc; + v2 = v1 + 80; + + /* If header length is exceeded, return error code */ + if (v2 - hstring > lhead) { + return (-1); + } + + /* Move END down 80 characters */ + strncpy (v2, v1, 80); + + /* blank out new line and insert keyword */ + for (vp = v1; vp < v2; vp++) + *vp = ' '; + strncpy (v1, keyword, lkeyword); + c0 = v1 + lkeyword; + } + + /* Search header string for variable name */ + else { + v1 = ksearch (hstring,keyword); + + /* If parameter is not found, return without doing anything */ + if (v1 == NULL) { + if (verbose) + fprintf (stderr,"HPUTCOM: %s not found\n",keyword); + return (-1); + } + + /* Align pointer at start of 80-character line */ + lc = v1 - hstring; + ln = lc / 80; + nc = ln * 80; + v1 = hstring + nc; + v2 = v1 + 80; + + /* Extract entry for this variable from the header */ + strncpy (line, v1, 80); + line[80] = '\0'; /* Null-terminate line before strchr call */ + + /* check for quoted value */ + q1 = strchr (line,squot); + c1 = strchr (line,slash); + if (q1 != NULL) { + if (c1 != NULL && q1 < c1) { + q2 = strchr (q1+1, squot); + if (q2 == NULL) { + q2 = c1 - 1; + while (*q2 == space) + q2--; + q2++; + } + else if (c1 < q2) + c1 = strchr (q2, slash); + } + else if (c1 == NULL) { + q2 = strchr (q1+1, squot); + if (q2 == NULL) { + q2 = line + 79; + while (*q2 == space) + q2--; + q2++; + } + } + else + q1 = NULL; + q2 = NULL; + } + + else + q2 = NULL; + + if (c1 != NULL) + c0 = v1 + (c1 - line) - 1; + else if (q2 == NULL || q2-line < 30) + c0 = v1 + 30; + else + c0 = v1 + (q2 - line) + 1; /* allan: 1997-09-30, was c0=q2+2 */ + + /* If comment will not fit at all, return */ + if (c0 - v1 > 77) + return (-1); + strncpy (c0, " / ",3); + } + + /* Create new entry */ + if (lcom > 0) { + c1 = c0 + 3; + lblank = v1 + 79 - c1; + if (lcom > lblank) + lcom = lblank; + for (i = 0; i < lblank; i++) + c1[i] = ' '; + strncpy (c1, comment, lcom); + } + + if (verbose) { + fprintf (stderr,"HPUTCOM: %s / %s\n",keyword,comment); + } + return (0); +} + + +static int leaveblank = 0; /* If 1, leave blank line when deleting */ +void +setleaveblank (lb) +int lb; { leaveblank = lb; return; } + +static int headshrink=1; /* Set to 1 to drop line after deleting keyword */ +void +setheadshrink (hsh) +int hsh; +{headshrink = hsh; return;} + +/* HDEL - Set character string keyword = value in FITS header string + * returns 1 if entry deleted, else 0 + */ + +int +hdel (hstring,keyword) + +char *hstring; /* FITS header */ +const char *keyword; /* Keyword of entry to be deleted */ +{ + char *v, *v1, *v2, *ve; + + /* Search for keyword */ + v1 = ksearch (hstring,keyword); + + /* If keyword is not found, return header unchanged */ + if (v1 == NULL) { + return (0); + } + + /* Find end of header */ + ve = ksearch (hstring,"END"); + + /* If headshrink is 0, leave END where it is */ + if (!leaveblank && !headshrink) + ve = ve - 80; + + /* Cover deleted keyword line with spaces */ + if (leaveblank) { + v2 = v1 + 80; + for (v = ve; v < v2; v++) + *v = ' '; + } + + /* Shift rest of header up one line */ + else { + for (v = v1; v < ve; v = v + 80) { + v2 = v + 80; + strncpy (v, v2, 80); + } + + /* Cover former last line with spaces */ + v2 = ve + 80; + for (v = ve; v < v2; v++) + *v = ' '; + } + + return (1); +} + + +/* HADD - Add character string keyword = value to FITS header string + * returns 1 if entry added, else 0 + * Call hputx() to put value into entry + */ + +int +hadd (hplace, keyword) + +char *hplace; /* FITS header position for new keyword */ +const char *keyword; /* Keyword of entry to be deleted */ +{ + char *v, *v1, *v2, *ve; + int i, lkey; + + /* Find end of header */ + ve = ksearch (hplace,"END"); + + /* If END is not found, return header unchanged */ + if (ve == NULL) { + return (0); + } + + v1 = hplace; + + /* Shift rest of header down one line */ + /* limit bug found by Paolo Montegriffo fixed 2000-04-19 */ + for (v = ve; v >= v1; v = v - 80) { + v2 = v + 80; + strncpy (v2, v, 80); + } + + /* Cover former first line with new keyword */ + lkey = (int) strlen (keyword); + strncpy (hplace, keyword, lkey); + if (lkey < 8) { + for (i = lkey; i < 8; i++) + hplace[i] = ' '; + hplace[8] = '='; + } + for (i = 9; i < 80; i++) + hplace[i] = ' '; + + return (1); +} + + +/* HCHANGE - Changes keyword for entry from keyword1 to keyword2 in FITS + header string + * returns 1 if entry changed, else 0 + */ + +int +hchange (hstring, keyword1, keyword2) + +char *hstring; /* FITS header */ +const char *keyword1; /* Keyword to be changed */ +const char *keyword2; /* New keyword name */ +{ + char *v, *v1; + const char *v2; + int lv2, i; + + /* Search for keyword */ + v1 = ksearch (hstring,keyword1); + + /* If keyword is not found, return header unchanged */ + if (!v1) + return (0); + + else { + lv2 = (int) strlen (keyword2); + v = v1; + v2 = keyword2; + for (i = 0; i < 8; i++) { + if (i < lv2) + v[i] = v2[i]; + else + v[i] = ' '; + } + } + + return (1); +} + + +/* Write the right ascension ra in sexagesimal format into string*/ + +void +ra2str (string, lstr, ra, ndec) + +char *string; /* Character string (returned) */ +int lstr; /* Maximum number of characters in string */ +double ra; /* Right ascension in degrees */ +int ndec; /* Number of decimal places in seconds */ + +{ + double a,b; + double seconds; + char tstring[64]; + int hours; + int minutes; + int isec, ltstr; + double dsgn; + + /* Keep RA between 0 and 360 */ + if (ra < 0.0 ) { + ra = -ra; + dsgn = -1.0; + } + else + dsgn = 1.0; + ra = fmod(ra, 360.0); + ra *= dsgn; + if (ra < 0.0) + ra = ra + 360.0; + + a = ra / 15.0; + + /* Convert to hours */ + hours = (int) a; + + /* Compute minutes */ + b = (a - (double)hours) * 60.0; + minutes = (int) b; + + /* Compute seconds */ + seconds = (b - (double)minutes) * 60.0; + + if (ndec > 5) { + if (seconds > 59.999999) { + seconds = 0.0; + minutes = minutes + 1; + } + if (minutes > 59) { + minutes = 0; + hours = hours + 1; + } + hours = hours % 24; + (void) sprintf (tstring,"%02d:%02d:%09.6f",hours,minutes,seconds); + } + else if (ndec > 4) { + if (seconds > 59.99999) { + seconds = 0.0; + minutes = minutes + 1; + } + if (minutes > 59) { + minutes = 0; + hours = hours + 1; + } + hours = hours % 24; + (void) sprintf (tstring,"%02d:%02d:%08.5f",hours,minutes,seconds); + } + else if (ndec > 3) { + if (seconds > 59.9999) { + seconds = 0.0; + minutes = minutes + 1; + } + if (minutes > 59) { + minutes = 0; + hours = hours + 1; + } + hours = hours % 24; + (void) sprintf (tstring,"%02d:%02d:%07.4f",hours,minutes,seconds); + } + else if (ndec > 2) { + if (seconds > 59.999) { + seconds = 0.0; + minutes = minutes + 1; + } + if (minutes > 59) { + minutes = 0; + hours = hours + 1; + } + hours = hours % 24; + (void) sprintf (tstring,"%02d:%02d:%06.3f",hours,minutes,seconds); + } + else if (ndec > 1) { + if (seconds > 59.99) { + seconds = 0.0; + minutes = minutes + 1; + } + if (minutes > 59) { + minutes = 0; + hours = hours + 1; + } + hours = hours % 24; + (void) sprintf (tstring,"%02d:%02d:%05.2f",hours,minutes,seconds); + } + else if (ndec > 0) { + if (seconds > 59.9) { + seconds = 0.0; + minutes = minutes + 1; + } + if (minutes > 59) { + minutes = 0; + hours = hours + 1; + } + hours = hours % 24; + (void) sprintf (tstring,"%02d:%02d:%04.1f",hours,minutes,seconds); + } + else { + isec = (int)(seconds + 0.5); + if (isec > 59) { + isec = 0; + minutes = minutes + 1; + } + if (minutes > 59) { + minutes = 0; + hours = hours + 1; + } + hours = hours % 24; + (void) sprintf (tstring,"%02d:%02d:%02d",hours,minutes,isec); + } + + /* Move formatted string to returned string */ + ltstr = (int) strlen (tstring); + if (ltstr < lstr-1) + strcpy (string, tstring); + else { + strncpy (string, tstring, lstr-1); + string[lstr-1] = 0; + } + return; +} + + +/* Write the variable a in sexagesimal format into string */ + +void +dec2str (string, lstr, dec, ndec) + +char *string; /* Character string (returned) */ +int lstr; /* Maximum number of characters in string */ +double dec; /* Declination in degrees */ +int ndec; /* Number of decimal places in arcseconds */ + +{ + double a, b, dsgn, deg1; + double seconds; + char sign; + int degrees; + int minutes; + int isec, ltstr; + char tstring[64]; + + /* Keep angle between -180 and 360 degrees */ + deg1 = dec; + if (deg1 < 0.0 ) { + deg1 = -deg1; + dsgn = -1.0; + } + else + dsgn = 1.0; + deg1 = fmod(deg1, 360.0); + deg1 *= dsgn; + if (deg1 <= -180.0) + deg1 = deg1 + 360.0; + + a = deg1; + + /* Set sign and do all the rest with a positive */ + if (a < 0) { + sign = '-'; + a = -a; + } + else + sign = '+'; + + /* Convert to degrees */ + degrees = (int) a; + + /* Compute minutes */ + b = (a - (double)degrees) * 60.0; + minutes = (int) b; + + /* Compute seconds */ + seconds = (b - (double)minutes) * 60.0; + + if (ndec > 5) { + if (seconds > 59.999999) { + seconds = 0.0; + minutes = minutes + 1; + } + if (minutes > 59) { + minutes = 0; + degrees = degrees + 1; + } + (void) sprintf (tstring,"%c%02d:%02d:%09.6f",sign,degrees,minutes,seconds); + } + else if (ndec > 4) { + if (seconds > 59.99999) { + seconds = 0.0; + minutes = minutes + 1; + } + if (minutes > 59) { + minutes = 0; + degrees = degrees + 1; + } + (void) sprintf (tstring,"%c%02d:%02d:%08.5f",sign,degrees,minutes,seconds); + } + else if (ndec > 3) { + if (seconds > 59.9999) { + seconds = 0.0; + minutes = minutes + 1; + } + if (minutes > 59) { + minutes = 0; + degrees = degrees + 1; + } + (void) sprintf (tstring,"%c%02d:%02d:%07.4f",sign,degrees,minutes,seconds); + } + else if (ndec > 2) { + if (seconds > 59.999) { + seconds = 0.0; + minutes = minutes + 1; + } + if (minutes > 59) { + minutes = 0; + degrees = degrees + 1; + } + (void) sprintf (tstring,"%c%02d:%02d:%06.3f",sign,degrees,minutes,seconds); + } + else if (ndec > 1) { + if (seconds > 59.99) { + seconds = 0.0; + minutes = minutes + 1; + } + if (minutes > 59) { + minutes = 0; + degrees = degrees + 1; + } + (void) sprintf (tstring,"%c%02d:%02d:%05.2f",sign,degrees,minutes,seconds); + } + else if (ndec > 0) { + if (seconds > 59.9) { + seconds = 0.0; + minutes = minutes + 1; + } + if (minutes > 59) { + minutes = 0; + degrees = degrees + 1; + } + (void) sprintf (tstring,"%c%02d:%02d:%04.1f",sign,degrees,minutes,seconds); + } + else { + isec = (int)(seconds + 0.5); + if (isec > 59) { + isec = 0; + minutes = minutes + 1; + } + if (minutes > 59) { + minutes = 0; + degrees = degrees + 1; + } + (void) sprintf (tstring,"%c%02d:%02d:%02d",sign,degrees,minutes,isec); + } + + /* Move formatted string to returned string */ + ltstr = (int) strlen (tstring); + if (ltstr < lstr-1) + strcpy (string, tstring); + else { + strncpy (string, tstring, lstr-1); + string[lstr-1] = 0; + } + return; +} + + +/* Write the angle a in decimal format into string */ + +void +deg2str (string, lstr, deg, ndec) + +char *string; /* Character string (returned) */ +int lstr; /* Maximum number of characters in string */ +double deg; /* Angle in degrees */ +int ndec; /* Number of decimal places in degree string */ + +{ + char degform[8]; + int field, ltstr; + char tstring[64]; + double deg1; + double dsgn; + + /* Keep angle between -180 and 360 degrees */ + deg1 = deg; + if (deg1 < 0.0 ) { + deg1 = -deg1; + dsgn = -1.0; + } + else + dsgn = 1.0; + deg1 = fmod(deg1, 360.0); + deg1 *= dsgn; + if (deg1 <= -180.0) + deg1 = deg1 + 360.0; + + /* Write angle to string, adding 4 digits to number of decimal places */ + field = ndec + 4; + if (ndec > 0) { + sprintf (degform, "%%%d.%df", field, ndec); + sprintf (tstring, degform, deg1); + } + else { + sprintf (degform, "%%%4d", field); + sprintf (tstring, degform, (int)deg1); + } + + /* Move formatted string to returned string */ + ltstr = (int) strlen (tstring); + if (ltstr < lstr-1) + strcpy (string, tstring); + else { + strncpy (string, tstring, lstr-1); + string[lstr-1] = 0; + } + return; +} + + +/* Write the variable a in decimal format into field-character string */ + +void +num2str (string, num, field, ndec) + +char *string; /* Character string (returned) */ +double num; /* Number */ +int field; /* Number of characters in output field (0=any) */ +int ndec; /* Number of decimal places in degree string */ + +{ + char numform[8]; + + if (field > 0) { + if (ndec > 0) { + sprintf (numform, "%%%d.%df", field, ndec); + sprintf (string, numform, num); + } + else { + sprintf (numform, "%%%dd", field); + sprintf (string, numform, (int)num); + } + } + else { + if (ndec > 0) { + sprintf (numform, "%%.%df", ndec); + sprintf (string, numform, num); + } + else { + sprintf (string, "%d", (int)num); + } + } + return; +} + +/* Dec 14 1995 Original subroutines + + * Feb 5 1996 Added HDEL to delete keyword entry from FITS header + * Feb 7 1996 Add EOS to LINE in HPUTC + * Feb 21 1996 Add RA2STR and DEC2STR string routines + * Jul 19 1996 Add HPUTRA and HPUTDEC + * Jul 22 1996 Add HCHANGE to change keywords + * Aug 5 1996 Add HPUTNR8 to save specific number of decimal places + * Oct 15 1996 Fix spelling + * Nov 1 1996 Add DEG2STR to set specific number of decimal places + * Nov 1 1996 Allow DEC2STR to handle upt to 6 decimal places + * + * Mar 20 1997 Fix format error in DEG2STR + * Jul 7 1997 Fix 2 errors in HPUTCOM found by Allan Brighton + * Jul 16 1997 Fix error in HPUTC found by Allan Brighton + * Jul 17 1997 Fix error in HPUTC found by Allan Brighton + * Sep 30 1997 Fix error in HPUTCOM found by Allan Brighton + * Dec 15 1997 Fix minor bugs after lint + * Dec 31 1997 Always put two hour digits in RA2STR + * + * Feb 25 1998 Add HADD to insert keywords at specific locations + * Mar 27 1998 If n is negative, write g format in HPUTNR8() + * Apr 24 1998 Add NUM2STR() for easy output formatting + * Apr 30 1998 Use BLSEARCH() to overwrite blank lines before END + * May 27 1998 Keep Dec between -90 and +90 in DEC2STR() + * May 28 1998 Keep RA between 0 and 360 in RA2STR() + * Jun 2 1998 Fix bug when filling in blank lines before END + * Jun 24 1998 Add string length to ra2str(), dec2str(), and deg2str() + * Jun 25 1998 Make string converstion subroutines more robust + * Aug 31 1998 Add getltime() and getutime() + * Sep 28 1998 Null-terminate comment in HPUTCOM (Allan Brighton) + * Oct 1 1998 Change clock declaration in getltime() from int (Allan Brighton) + * + * Jan 28 1999 Fix bug to avoid writing HISTORY or COMMENT past 80 characters + * Jul 14 1999 Pad string in hputs() to minimum of 8 characters + * Aug 16 1999 Keep angle between -180 and +360 in dec2str() + * Oct 6 1999 Reallocate header buffer if it is too small in hputc() + * Oct 14 1999 Do not reallocate header; return error if not successful + * + * Mar 2 2000 Do not add quotes if adding HISTORY or COMMENT with hputs() + * Mar 22 2000 Move getutime() and getltime() to dateutil.c + * Mar 27 2000 Add hputm() for muti-line keywords + * Mar 27 2000 Fix bug testing for space to fit comment in hputcom() + * Apr 19 2000 Fix bug in hadd() which overwrote line + * Jun 2 2000 Dropped unused variable lv in hputm() after lint + * Jul 20 2000 Drop unused variables blank and i in hputc() + * + * Jan 11 2001 Print all messages to stderr + * Jan 18 2001 Drop declaration of blsearch(); it is in fitshead.h + * + * Jan 4 2002 Fix placement of comments + * + * Jul 1 2004 Add headshrink to optionally keep blank lines in header + * Sep 3 2004 Fix bug so comments are not pushed onto next line if long value + * Sep 16 2004 Add fixnegzero() to avoid putting signed zero values in header + * + * May 22 2006 Add option to leave blank line when deleting a keyword + * Jun 15 2006 Fix comment alignment in hputc() and hputcom() + * Jun 20 2006 Initialized uninitialized variables in hputm() and hputcom() + * + * Jan 4 2007 Declare keyword to be const + * Jan 4 2007 Drop unused subroutine hputi2() + * Jan 5 2007 Drop ksearch() declarations; it is now in fitshead.h + * Jan 16 2007 Fix bugs in ra2str() and dec2str() so ndec=0 works + * Aug 20 2007 Fix bug so comments after quoted keywords work + * Aug 22 2007 If closing quote not found, make one up + * + * Sep 9 2011 Always initialize q2 and lroot + */ diff --git a/tksao/wcssubs/iget.c b/tksao/wcssubs/iget.c new file mode 100644 index 0000000..58e54f7 --- /dev/null +++ b/tksao/wcssubs/iget.c @@ -0,0 +1,531 @@ +/*** File libwcs/iget.c + *** January 4, 2007 + *** By Jessica Mink, jmink@cfa.harvard.edu + *** Harvard-Smithsonian Center for Astrophysics + *** Copyright (C) 1998-2007 + *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Correspondence concerning WCSTools should be addressed as follows: + Internet email: jmink@cfa.harvard.edu + Postal address: Jessica Mink + Smithsonian Astrophysical Observatory + 60 Garden St. + Cambridge, MA 02138 USA + + * Module: iget.c (Get IRAF FITS Header parameter values) + * Purpose: Extract values for variables from IRAF keyword value string + * Subroutine: mgeti4 (hstring,mkey,keyword,ival) returns long integer + * Subroutine: mgetr8 (hstring,mkey,keyword,dval) returns double + * Subroutine: mgetstr (hstring,mkey,keyword,lstr,str) returns character string + * Subroutine: igeti4 (hstring,keyword,ival) returns long integer + * Subroutine: igetr4 (hstring,keyword,rval) returns real + * Subroutine: igetr8 (hstring,keyword,dval) returns double + * Subroutine: igets (hstring,keyword,lstr,str) returns character string + * Subroutine: igetc (hstring,keyword) returns character string + * Subroutine: isearch (hstring,keyword) returns pointer to header string entry + */ + +#include /* NULL, strlen, strstr, strcpy */ +#include +#include "fitshead.h" /* FITS header extraction subroutines */ +#include +#ifndef VMS +#include +#else +#define INT_MAX 2147483647 /* Biggest number that can fit in long */ +#define SHRT_MAX 32767 +#endif + +#define MAX_LVAL 2000 + +static char *isearch(); +static char val[30]; + +/* Extract long value for variable from IRAF multiline keyword value */ + +int +mgeti4 (hstring, mkey, keyword, ival) + +const char *hstring; /* Character string containing FITS or IRAF header information + in the format = ... */ +const char *mkey; /* Character string containing the name of the multi-line + keyword, the string value of which contains the desired + keyword, the value of which is returned. */ +const char *keyword; /* Character string containing the name of the keyword + within the multiline IRAF keyword */ +int *ival; /* Integer value returned */ +{ + char *mstring; + + mstring = malloc (MAX_LVAL); + + if (hgetm (hstring, mkey, MAX_LVAL, mstring)) { + if (igeti4 (mstring, keyword, ival)) { + free (mstring); + return (1); + } + else { + free (mstring); + return (0); + } + } + else { + free (mstring); + return (0); + } +} + +/* Extract double value for variable from IRAF multiline keyword value */ + +int +mgetr8 (hstring, mkey, keyword, dval) + +const char *hstring; /* Character string containing FITS or IRAF header information + in the format = ... */ +const char *mkey; /* Character string containing the name of the multi-line + keyword, the string value of which contains the desired + keyword, the value of which is returned. */ +const char *keyword; /* Character string containing the name of the keyword + within the multiline IRAF keyword */ +double *dval; /* Integer value returned */ +{ + char *mstring; + mstring = malloc (MAX_LVAL); + + if (hgetm (hstring, mkey, MAX_LVAL, mstring)) { + if (igetr8 (mstring, keyword, dval)) { + free (mstring); + return (1); + } + else { + free (mstring); + return (0); + } + } + else { + free (mstring); + return (0); + } +} + + +/* Extract string value for variable from IRAF keyword value string */ + +int +mgetstr (hstring, mkey, keyword, lstr, str) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *mkey; /* Character string containing the name of the multi-line + keyword, the string value of which contains the desired + keyword, the value of which is returned. */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +const int lstr; /* Size of str in characters */ +char *str; /* String (returned) */ +{ + char *mstring; + mstring = malloc (MAX_LVAL); + + if (hgetm (hstring, mkey, MAX_LVAL, mstring)) { + if (igets (mstring, keyword, lstr, str)) { + free (mstring); + return (1); + } + else { + free (mstring); + return (0); + } + } + else { + free (mstring); + return (0); + } +} + + +/* Extract long value for variable from IRAF keyword value string */ + +int +igeti4 (hstring, keyword, ival) + +const char *hstring; /* character string containing IRAF header information + in the format = ... */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +int *ival; /* Integer value returned */ +{ +char *value; +double dval; +int minint; + +/* Get value from header string */ + value = igetc (hstring,keyword); + +/* Translate value from ASCII to binary */ + if (value != NULL) { + minint = -INT_MAX - 1; + strcpy (val, value); + dval = atof (val); + if (dval+0.001 > INT_MAX) + *ival = INT_MAX; + else if (dval >= 0) + *ival = (int) (dval + 0.001); + else if (dval-0.001 < minint) + *ival = minint; + else + *ival = (int) (dval - 0.001); + return (1); + } + else { + return (0); + } +} + + +/* Extract integer*2 value for variable from IRAF keyword value string */ + +int +igeti2 (hstring,keyword,ival) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +short *ival; +{ +char *value; +double dval; +int minshort; + +/* Get value from header string */ + value = igetc (hstring,keyword); + +/* Translate value from ASCII to binary */ + if (value != NULL) { + strcpy (val, value); + dval = atof (val); + minshort = -SHRT_MAX - 1; + if (dval+0.001 > SHRT_MAX) + *ival = SHRT_MAX; + else if (dval >= 0) + *ival = (short) (dval + 0.001); + else if (dval-0.001 < minshort) + *ival = minshort; + else + *ival = (short) (dval - 0.001); + return (1); + } + else { + return (0); + } +} + +/* Extract real value for variable from IRAF keyword value string */ + +int +igetr4 (hstring,keyword,rval) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +float *rval; +{ + char *value; + +/* Get value from header string */ + value = igetc (hstring,keyword); + +/* Translate value from ASCII to binary */ + if (value != NULL) { + strcpy (val, value); + *rval = (float) atof (val); + return (1); + } + else { + return (0); + } +} + + +/* Extract real*8 value for variable from IRAF keyword value string */ + +int +igetr8 (hstring,keyword,dval) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +double *dval; +{ + char *value,val[30]; + +/* Get value from header string */ + value = igetc (hstring,keyword); + +/* Translate value from ASCII to binary */ + if (value != NULL) { + strcpy (val, value); + *dval = atof (val); + return (1); + } + else { + return (0); + } +} + + +/* Extract string value for variable from IRAF keyword value string */ + +int +igets (hstring, keyword, lstr, str) + +const char *hstring; /* character string containing FITS header information + in the format = {/ } */ +const char *keyword; /* character string containing the name of the keyword + the value of which is returned. hget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +const int lstr; /* Size of str in characters */ +char *str; /* String (returned) */ +{ + char *value; + int lval; + +/* Get value from header string */ + value = igetc (hstring,keyword); + + if (value != NULL) { + lval = strlen (value); + if (lval < lstr) + strcpy (str, value); + else if (lstr > 1) + strncpy (str, value, lstr-1); + else + str[0] = value[0]; + return (1); + } + else + return (0); +} + + +/* Extract character value for variable from IRAF keyword value string */ + +char * +igetc (hstring,keyword0) + +const char *hstring; /* character string containing IRAF keyword value string + in the format = {/ } */ +const char *keyword0; /* character string containing the name of the keyword + the value of which is returned. iget searches for a + line beginning with this string. if "[n]" is present, + the n'th token in the value is returned. + (the first 8 characters must be unique) */ +{ + static char cval[MAX_LVAL]; + char *value; + char cwhite[8]; + char lbracket[2],rbracket[2]; + char keyword[16]; + char line[MAX_LVAL]; + char *vpos,*cpar; + char *c1, *brack1, *brack2; + int ipar, i; + + lbracket[0] = 91; + lbracket[1] = 0; + rbracket[0] = 93; + rbracket[1] = 0; + +/* Find length of variable name */ + strcpy (keyword,keyword0); + brack1 = strsrch (keyword,lbracket); + if (brack1 != NULL) *brack1 = '\0'; + +/* Search header string for variable name */ + vpos = isearch (hstring,keyword); + +/* Exit if not found */ + if (vpos == NULL) { + return (NULL); + } + +/* Initialize returned value to nulls */ + for (i = 0; i < MAX_LVAL; i++) + line[i] = 0; + +/* If quoted value, copy until second quote is reached */ + i = 0; + if (*vpos == '"') { + vpos++; + while (*vpos && *vpos != '"' && i < MAX_LVAL) + line[i++] = *vpos++; + } + +/* Otherwise copy until next space or tab */ + else { + while (*vpos != ' ' && *vpos != (char)9 && + *vpos > 0 && i < MAX_LVAL) + line[i++] = *vpos++; + } + +/* If keyword has brackets, extract appropriate token from value */ + if (brack1 != NULL) { + c1 = (char *) (brack1 + 1); + brack2 = strsrch (c1, rbracket); + if (brack2 != NULL) { + *brack2 = '\0'; + ipar = atoi (c1); + if (ipar > 0) { + cwhite[0] = ' '; + cwhite[1] = ','; + cwhite[2] = '\0'; + cpar = strtok (line, cwhite); + for (i = 1; i < ipar; i++) { + cpar = strtok (NULL, cwhite); + } + if (cpar != NULL) { + strcpy (cval,cpar); + } + else + value = NULL; + } + } + } + else + strcpy (cval, line); + + value = cval; + + return (value); +} + + +/* Find value for specified IRAF keyword */ + +static char * +isearch (hstring,keyword) + +/* Find entry for keyword keyword in IRAF keyword value string hstring. + NULL is returned if the keyword is not found */ + +const char *hstring; /* character string containing fits-style header + information in the format = {/ } + the default is that each entry is 80 characters long; + however, lines may be of arbitrary length terminated by + nulls, carriage returns or linefeeds, if packed is true. */ +const char *keyword; /* character string containing the name of the variable + to be returned. isearch searches for a line beginning + with this string. The string may be a character + literal or a character variable terminated by a null + or '$'. it is truncated to 8 characters. */ +{ + char *loc, *headnext, *headlast, *pval; + int lastchar, nextchar, lkey, nleft, lhstr; + +/* Search header string for variable name */ + lhstr = 0; + while (lhstr < 57600 && hstring[lhstr] != 0) + lhstr++; + headlast = (char *) hstring + lhstr; + headnext = (char *) hstring; + pval = NULL; + lkey = strlen (keyword); + while (headnext < headlast) { + nleft = headlast - headnext; + loc = strnsrch (headnext, keyword, nleft); + + /* Exit if keyword is not found */ + if (loc == NULL) { + break; + } + + nextchar = (int) *(loc + lkey); + lastchar = (int) *(loc - 1); + + /* If parameter name in header is longer, keep searching */ + if (nextchar != 61 && nextchar > 32 && nextchar < 127) + headnext = loc + 1; + + /* If start of string, keep it */ + else if (loc == hstring) { + pval = loc; + break; + } + + /* If preceeded by a blank or tab, keep it */ + else if (lastchar == 32 || lastchar == 9) { + pval = loc; + break; + } + + else + headnext = loc + 1; + } + + /* Find start of value string for this keyword */ + if (pval != NULL) { + pval = pval + lkey; + while (*pval == ' ' || *pval == '=') + pval++; + } + + /* Return pointer to calling program */ + return (pval); + +} + +/* Mar 12 1998 New subroutines + * Apr 15 1998 Set IGET() and ISEARCH() static when defined + * Apr 24 1998 Add MGETI4(), MGETR8(), and MGETS() for single step IRAF ext. + * Jun 1 1998 Add VMS patch from Harry Payne at STScI + * Jul 9 1998 Fix bracket token extraction after Paul Sydney + + * May 5 1999 values.h -> POSIX limits.h: MAXINT->INT_MAX, MAXSHORT->SHRT_MAX + * Oct 21 1999 Fix declarations after lint + * + * Feb 11 2000 Stop search for end of quoted keyword if more than 500 chars + * Jul 20 2000 Drop unused variables squot, dquot, and slash in igetc() + * + * Jun 26 2002 Change maximum string length from 600 to 2000; use MAX_LVAL + * Jun 26 2002 Stop search for end of quoted keyword if > MAX_LVAL chars + * + * Sep 23 2003 Change mgets() to mgetstr() to avoid name collision at UCO Lick + * + * Feb 26 2004 Make igetc() accessible from outside this file + * + * Jan 4 2007 Declare header, keyword to be const + */ diff --git a/tksao/wcssubs/imhfile.c b/tksao/wcssubs/imhfile.c new file mode 100644 index 0000000..b618686 --- /dev/null +++ b/tksao/wcssubs/imhfile.c @@ -0,0 +1,1941 @@ +/*** File imhfile.c + *** March 27, 2012 + *** By Jessica Mink, jmink@cfa.harvard.edu + *** Harvard-Smithsonian Center for Astrophysics + *** Copyright (C) 1996-2012 + *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Correspondence concerning WCSTools should be addressed as follows: + Internet email: jmink@cfa.harvard.edu + Postal address: Jessica Mink + Smithsonian Astrophysical Observatory + 60 Garden St. + Cambridge, MA 02138 USA + + * Module: imhfile.c (IRAF .imh image file reading and writing) + * Purpose: Read and write IRAF image files (and translate headers) + * Subroutine: check_immagic (irafheader, teststring ) + * Verify that file is valid IRAF imhdr or impix + * Subroutine: irafrhead (filename, lfhead, fitsheader, lihead) + * Read IRAF image header + * Subroutine: irafrimage (fitsheader) + * Read IRAF image pixels (call after irafrhead) + * Subroutine: same_path (pixname, hdrname) + * Put filename and header path together + * Subroutine: iraf2fits (hdrname, irafheader, nbiraf, nbfits) + * Convert IRAF image header to FITS image header + * Subroutine: irafwhead (hdrname, irafheader, fitsheader) + * Write IRAF header file + * Subroutine: irafwimage (hdrname, irafheader, fitsheader, image ) + * Write IRAF image and header files + * Subroutine: fits2iraf (fitsheader, irafheader) + * Convert FITS image header to IRAF image header + * Subroutine: irafgeti4 (irafheader, offset) + * Get 4-byte integer from arbitrary part of IRAF header + * Subroutine: irafgetc2 (irafheader, offset) + * Get character string from arbitrary part of IRAF v.1 header + * Subroutine: irafgetc (irafheader, offset) + * Get character string from arbitrary part of IRAF header + * Subroutine: iraf2str (irafstring, nchar) + * Convert 2-byte/char IRAF string to 1-byte/char string + * Subroutine: str2iraf (string, irafstring, nchar) + * Convert 1-byte/char string to IRAF 2-byte/char string + * Subroutine: irafswap (bitpix,string,nbytes) + * Swap bytes in string in place, with FITS bits/pixel code + * Subroutine: irafswap2 (string,nbytes) + * Swap bytes in string in place + * Subroutine irafswap4 (string,nbytes) + * Reverse bytes of Integer*4 or Real*4 vector in place + * Subroutine irafswap8 (string,nbytes) + * Reverse bytes of Real*8 vector in place + * Subroutine irafsize (filename) + * Return length of file in bytes + * Subroutine isiraf (filename) + * Return 1 if IRAF .imh file, else 0 + + + * Copyright: 2000 Smithsonian Astrophysical Observatory + * You may do anything you like with this file except remove + * this copyright. The Smithsonian Astrophysical Observatory + * makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without + * express or implied warranty. + */ + +#include /* define stderr, FD, and NULL */ +#include +#include +#include +#include +#include +#include +#include "fitsfile.h" + +/* Parameters from iraf/lib/imhdr.h for IRAF version 1 images */ +#define SZ_IMPIXFILE 79 /* name of pixel storage file */ +#define SZ_IMHDRFILE 79 /* length of header storage file */ +#define SZ_IMTITLE 79 /* image title string */ +#define LEN_IMHDR 2052 /* length of std header */ + +/* Parameters from iraf/lib/imhdr.h for IRAF version 2 images */ +#define SZ_IM2PIXFILE 255 /* name of pixel storage file */ +#define SZ_IM2HDRFILE 255 /* name of header storage file */ +#define SZ_IM2TITLE 383 /* image title string */ +#define LEN_IM2HDR 2046 /* length of std header */ + +/* Offsets into header in bytes for parameters in IRAF version 1 images */ +#define IM_HDRLEN 12 /* Length of header in 4-byte ints */ +#define IM_PIXTYPE 16 /* Datatype of the pixels */ +#define IM_NDIM 20 /* Number of dimensions */ +#define IM_LEN 24 /* Length (as stored) */ +#define IM_PHYSLEN 52 /* Physical length (as stored) */ +#define IM_PIXOFF 88 /* Offset of the pixels */ +#define IM_CTIME 108 /* Time of image creation */ +#define IM_MTIME 112 /* Time of last modification */ +#define IM_LIMTIME 116 /* Time of min,max computation */ +#define IM_MAX 120 /* Maximum pixel value */ +#define IM_MIN 124 /* Maximum pixel value */ +#define IM_PIXFILE 412 /* Name of pixel storage file */ +#define IM_HDRFILE 572 /* Name of header storage file */ +#define IM_TITLE 732 /* Image name string */ + +/* Offsets into header in bytes for parameters in IRAF version 2 images */ +#define IM2_HDRLEN 6 /* Length of header in 4-byte ints */ +#define IM2_PIXTYPE 10 /* Datatype of the pixels */ +#define IM2_SWAPPED 14 /* Pixels are byte swapped */ +#define IM2_NDIM 18 /* Number of dimensions */ +#define IM2_LEN 22 /* Length (as stored) */ +#define IM2_PHYSLEN 50 /* Physical length (as stored) */ +#define IM2_PIXOFF 86 /* Offset of the pixels */ +#define IM2_CTIME 106 /* Time of image creation */ +#define IM2_MTIME 110 /* Time of last modification */ +#define IM2_LIMTIME 114 /* Time of min,max computation */ +#define IM2_MAX 118 /* Maximum pixel value */ +#define IM2_MIN 122 /* Maximum pixel value */ +#define IM2_PIXFILE 126 /* Name of pixel storage file */ +#define IM2_HDRFILE 382 /* Name of header storage file */ +#define IM2_TITLE 638 /* Image name string */ + +/* Codes from iraf/unix/hlib/iraf.h */ +#define TY_CHAR 2 +#define TY_SHORT 3 +#define TY_INT 4 +#define TY_LONG 5 +#define TY_REAL 6 +#define TY_DOUBLE 7 +#define TY_COMPLEX 8 +#define TY_POINTER 9 +#define TY_STRUCT 10 +#define TY_USHORT 11 +#define TY_UBYTE 12 + +#define LEN_IRAFHDR 25000 +#define LEN_PIXHDR 1024 +#define LEN_FITSHDR 11520 + +int check_immagic(); +int irafgeti4(); +float irafgetr4(); +char *irafgetc2(); +char *irafgetc(); +char *iraf2str(); +static char *same_path(); +static void irafputr4(); +static void irafputi4(); +static void irafputc2(); +static void irafputc(); +static void str2iraf(); +static int headswap=-1; /* =1 to swap data bytes of foreign IRAF file */ +static void irafswap(); +static void irafswap2(); +static void irafswap4(); +static void irafswap8(); +int head_version (); +int pix_version (); +int irafncmp (); +static int machswap(); +static int irafsize(); + +#define SECONDS_1970_TO_1980 315532800L + +/* Subroutine: irafrhead + * Purpose: Open and read the iraf .imh file, translating it to FITS, too. + * Returns: NULL if failure, else pointer to IRAF .imh image header + * Notes: The imhdr format is defined in iraf/lib/imhdr.h, some of + * which defines or mimicked, above. + */ + +char * +irafrhead (filename, lihead) + +char *filename; /* Name of IRAF header file */ +int *lihead; /* Length of IRAF image header in bytes (returned) */ +{ + FILE *fd; + int nbr; + char *irafheader; + int nbhead, nbytes; + int imhver; + + headswap = -1; + *lihead = 0; + + /* open the image header file */ + fd = fopen (filename, "rb"); + if (fd == NULL) { + fprintf (stderr, "IRAFRHEAD: cannot open file %s to read\n", filename); + return (NULL); + } + + /* Find size of image header file */ + if ((nbhead = irafsize (fd)) <= 0) { + fprintf (stderr, "IRAFRHEAD: cannot read file %s, size = %d\n", + filename, nbhead); + return (NULL); + } + + /* allocate initial sized buffer */ + nbytes = nbhead + 5000; + irafheader = (char *) calloc (nbytes/4, 4); + if (irafheader == NULL) { + (void)fprintf(stderr, "IRAFRHEAD Cannot allocate %d-byte header\n", + nbytes); + return (NULL); + } + *lihead = nbytes; + + /* Read IRAF header */ + nbr = fread (irafheader, 1, nbhead, fd); + fclose (fd); + + /* Reject if header less than minimum length */ + if (nbr < LEN_PIXHDR) { + (void)fprintf(stderr, "IRAFRHEAD header file %s: %d / %d bytes read.\n", + filename,nbr,LEN_PIXHDR); + free (irafheader); + return (NULL); + } + + /* Check header magic word */ + imhver = head_version (irafheader); + if (imhver < 1) { + free (irafheader); + (void)fprintf(stderr, "IRAFRHEAD: %s is not a valid IRAF image header\n", + filename); + return(NULL); + } + + /* check number of image dimensions + if (imhver == 2) + ndim = irafgeti4 (irafheader, IM2_NDIM]) + else + ndim = irafgeti4 (irafheader, IM_NDIM]) + if (ndim < 2) { + free (irafheader); + (void)fprintf(stderr, "File %s does not contain 2d image\n", filename); + return (NULL); + } */ + + return (irafheader); +} + + +char * +irafrimage (fitsheader) + +char *fitsheader; /* FITS image header (filled) */ +{ + FILE *fd; + char *bang; + int naxis, naxis1, naxis2, naxis3, npaxis1, npaxis2,bitpix, bytepix, pixswap, i; + char *image; + int nbr, nbimage, nbaxis, nbl, nbdiff, lpname; + char *pixheader; + char *linebuff, *pixchar; + int imhver, lpixhead, len; + char pixname[SZ_IM2PIXFILE+1]; + char newpixname[SZ_IM2HDRFILE+1]; + + /* Convert pixel file name to character string */ + hgetm (fitsheader, "PIXFIL", SZ_IM2PIXFILE, pixname); + + /* Drop trailing spaces */ + lpname = strlen (pixname); + pixchar = pixname + lpname - 1; + while (*pixchar == ' ') + *pixchar = (char) 0; + + hgeti4 (fitsheader, "PIXOFF", &lpixhead); + + /* Open pixel file, ignoring machine name if present */ + if ((bang = strchr (pixname, '!')) != NULL ) + fd = fopen (bang + 1, "rb"); + else + fd = fopen (pixname, "rb"); + + /* If not at pathname in header, try same directory as header file */ + if (!fd) { + hgetm (fitsheader, "IMHFIL", SZ_IM2HDRFILE, newpixname); + len = strlen (newpixname); + newpixname[len-3] = 'p'; + newpixname[len-2] = 'i'; + newpixname[len-1] = 'x'; + fd = fopen (newpixname, "rb"); + } + + /* Print error message and exit if pixel file is not found */ + if (!fd) { + (void)fprintf(stderr, + "IRAFRIMAGE: Cannot open IRAF pixel file %s\n", pixname); + return (NULL); + } + + /* Read pixel header */ + pixheader = (char *) calloc (lpixhead/4, 4); + if (pixheader == NULL) { + (void)fprintf(stderr, "IRAFRIMAGE Cannot allocate %d-byte pixel header\n", + lpixhead); + return (NULL); + } + nbr = fread (pixheader, 1, lpixhead, fd); + + /* Check size of pixel header */ + if (nbr < lpixhead) { + (void)fprintf(stderr, "IRAF pixel file %s: %d / %d bytes read.\n", + pixname,nbr,LEN_PIXHDR); + free (pixheader); + fclose (fd); + return (NULL); + } + + /* check pixel header magic word */ + imhver = pix_version (pixheader); + if (imhver < 1) { + (void)fprintf(stderr, "File %s not valid IRAF pixel file.\n", pixname); + free (pixheader); + fclose (fd); + return(NULL); + } + free (pixheader); + + /* Find number of bytes to read */ + hgeti4 (fitsheader,"NAXIS",&naxis); + hgeti4 (fitsheader,"NAXIS1",&naxis1); + hgeti4 (fitsheader,"NAXIS2",&naxis2); + hgeti4 (fitsheader,"NPAXIS1",&npaxis1); + hgeti4 (fitsheader,"NPAXIS2",&npaxis2); + hgeti4 (fitsheader,"BITPIX",&bitpix); + if (bitpix < 0) + bytepix = -bitpix / 8; + else + bytepix = bitpix / 8; + + /* If either dimension is one and image is 3-D, read all three dimensions */ + if (naxis == 3 && ((naxis1 == 1) | (naxis2 == 1))) { + hgeti4 (fitsheader,"NAXIS3",&naxis3); + nbimage = naxis1 * naxis2 * naxis3 * bytepix; + } + else { + nbimage = naxis1 * naxis2 * bytepix; + naxis3 = 1; + } + + if (bytepix > 4) + image = (char *) calloc (nbimage/8, 8); + else if (bytepix > 2) + image = (char *) calloc (nbimage/4, 4); + else if (bytepix > 1) + image = (char *) calloc (nbimage/2, 2); + else + image = (char *) calloc (nbimage, 1); + if (image == NULL) { + (void)fprintf(stderr, "IRAFRIMAGE Cannot allocate %d-byte image buffer\n", + nbimage); + return (NULL); + } + + /* Read IRAF image all at once if physical and image dimensions are the same */ + if (npaxis1 == naxis1) + nbr = fread (image, 1, nbimage, fd); + + /* Read IRAF image one line at a time if physical and image dimensions differ */ + else { + nbdiff = (npaxis1 - naxis1) * bytepix; + nbaxis = naxis1 * bytepix; + linebuff = image; + nbr = 0; + if (naxis2 == 1 && naxis3 > 1) + naxis2 = naxis3; + for (i = 0; i < naxis2; i++) { + nbl = fread (linebuff, 1, nbaxis, fd); + nbr = nbr + nbl; + (void) fseek (fd, nbdiff, SEEK_CUR); + linebuff = linebuff + nbaxis; + } + } + fclose (fd); + + /* Check size of image */ + if (nbr < nbimage) { + (void)fprintf(stderr, "IRAF pixel file %s: %d / %d bytes read.\n", + pixname,nbr,nbimage); + free (image); + return (NULL); + } + + /* Byte-reverse image, if necessary */ + pixswap = 0; + hgetl (fitsheader, "PIXSWAP", &pixswap); + if (pixswap) + irafswap (bitpix, image, nbimage); + + return (image); +} + + +/* Return IRAF image format version number from magic word in IRAF header*/ + +int +head_version (irafheader) + +char *irafheader; /* IRAF image header from file */ + +{ + + /* Check header file magic word */ + if (irafncmp (irafheader, "imhdr", 5) != 0 ) { + if (strncmp (irafheader, "imhv2", 5) != 0) + return (0); + else + return (2); + } + else + return (1); +} + + +/* Return IRAF image format version number from magic word in IRAF pixel file */ + +int +pix_version (irafheader) + +char *irafheader; /* IRAF image header from file */ + +{ + + /* Check pixel file header magic word */ + if (irafncmp (irafheader, "impix", 5) != 0) { + if (strncmp (irafheader, "impv2", 5) != 0) + return (0); + else + return (2); + } + else + return (1); +} + + +/* Verify that file is valid IRAF imhdr or impix by checking first 5 chars + * Returns: 0 on success, 1 on failure */ + +int +irafncmp (irafheader, teststring, nc) + +char *irafheader; /* IRAF image header from file */ +char *teststring; /* C character string to compare */ +int nc; /* Number of characters to compate */ + +{ + char *line; + + headswap = -1; + if ((line = iraf2str (irafheader, nc)) == NULL) + return (1); + if (strncmp (line, teststring, nc) == 0) { + free (line); + return (0); + } + else { + free (line); + return (1); + } +} + +/* Convert IRAF image header to FITS image header, returning FITS header */ + +char * +iraf2fits (hdrname, irafheader, nbiraf, nbfits) + +char *hdrname; /* IRAF header file name (may be path) */ +char *irafheader; /* IRAF image header */ +int nbiraf; /* Number of bytes in IRAF header */ +int *nbfits; /* Number of bytes in FITS header (returned) */ + +{ + char *objname; /* object name from FITS file */ + int lstr, i, j, k, ib, nax, nbits, nl; + int lname = 0; + char *pixname, *newpixname, *bang, *chead; + char *fitsheader; + int nblock, nlines; + char *fhead, *fhead1, *fp, endline[81]; + char irafchar; + char fitsline[81]; + char *dstring; + int pixtype; + int imhver, n, imu, pixoff, impixoff, immax, immin, imtime; + int imndim, imlen, imphyslen, impixtype, pixswap, hpixswap, mtime; + float rmax, rmin; + + headswap = -1; + + /* Set up last line of FITS header */ + (void)strncpy (endline,"END", 3); + for (i = 3; i < 80; i++) + endline[i] = ' '; + endline[80] = 0; + + /* Check header magic word */ + imhver = head_version (irafheader); + if (imhver < 1) { + (void)fprintf(stderr, "File %s not valid IRAF image header\n", + hdrname); + return(NULL); + } + if (imhver == 2) { + nlines = 24 + ((nbiraf - LEN_IM2HDR) / 81); + imndim = IM2_NDIM; + imlen = IM2_LEN; + imphyslen = IM2_PHYSLEN; + impixtype = IM2_PIXTYPE; + impixoff = IM2_PIXOFF; + imtime = IM2_MTIME; + immax = IM2_MAX; + immin = IM2_MIN; + } + else { + nlines = 24 + ((nbiraf - LEN_IMHDR) / 162); + imndim = IM_NDIM; + imlen = IM_LEN; + imphyslen = IM_PHYSLEN; + impixtype = IM_PIXTYPE; + impixoff = IM_PIXOFF; + imtime = IM_MTIME; + immax = IM_MAX; + immin = IM_MIN; + } + + /* Initialize FITS header */ + nblock = (nlines * 80) / 2880; + *nbfits = (nblock + 5) * 2880 + 4; + fitsheader = (char *) calloc (*nbfits, 1); + if (fitsheader == NULL) { + (void)fprintf(stderr, "IRAF2FITS Cannot allocate %d-byte FITS header\n", + *nbfits); + return (NULL); + } + hlength (fitsheader, *nbfits); + fhead = fitsheader; + (void)strncpy (fitsheader, endline, 80); + hputl (fitsheader, "SIMPLE", 1); + fhead = fhead + 80; + + /* Set pixel size in FITS header */ + pixtype = irafgeti4 (irafheader, impixtype); + switch (pixtype) { + case TY_CHAR: + nbits = 8; + break; + case TY_UBYTE: + nbits = 8; + break; + case TY_SHORT: + nbits = 16; + break; + case TY_USHORT: + nbits = -16; + break; + case TY_INT: + case TY_LONG: + nbits = 32; + break; + case TY_REAL: + nbits = -32; + break; + case TY_DOUBLE: + nbits = -64; + break; + default: + (void)fprintf(stderr,"Unsupported data type: %d\n", pixtype); + return (NULL); + } + hputi4 (fitsheader,"BITPIX",nbits); + hputcom (fitsheader,"BITPIX", "IRAF .imh pixel type"); + fhead = fhead + 80; + + /* Set image dimensions in FITS header */ + nax = irafgeti4 (irafheader, imndim); + hputi4 (fitsheader,"NAXIS",nax); + hputcom (fitsheader,"NAXIS", "IRAF .imh naxis"); + fhead = fhead + 80; + + n = irafgeti4 (irafheader, imlen); + hputi4 (fitsheader, "NAXIS1", n); + hputcom (fitsheader,"NAXIS1", "IRAF .imh image naxis[1]"); + fhead = fhead + 80; + + if (nax > 1) { + n = irafgeti4 (irafheader, imlen+4); + hputi4 (fitsheader, "NAXIS2", n); + hputcom (fitsheader,"NAXIS2", "IRAF .imh image naxis[2]"); + } + else + hputi4 (fitsheader, "NAXIS2", 1); + hputcom (fitsheader,"NAXIS2", "IRAF .imh naxis[2]"); + fhead = fhead + 80; + + if (nax > 2) { + n = irafgeti4 (irafheader, imlen+8); + hputi4 (fitsheader, "NAXIS3", n); + hputcom (fitsheader,"NAXIS3", "IRAF .imh image naxis[3]"); + fhead = fhead + 80; + } + if (nax > 3) { + n = irafgeti4 (irafheader, imlen+12); + hputi4 (fitsheader, "NAXIS4", n); + hputcom (fitsheader,"NAXIS4", "IRAF .imh image naxis[4]"); + fhead = fhead + 80; + } + + /* Set object name in FITS header */ + if (imhver == 2) + objname = irafgetc (irafheader, IM2_TITLE, SZ_IM2TITLE); + else + objname = irafgetc2 (irafheader, IM_TITLE, SZ_IMTITLE); + if ((lstr = strlen (objname)) < 8) { + for (i = lstr; i < 8; i++) + objname[i] = ' '; + objname[8] = 0; + } + hputs (fitsheader,"OBJECT",objname); + hputcom (fitsheader,"OBJECT", "IRAF .imh title"); + free (objname); + fhead = fhead + 80; + + /* Save physical axis lengths so image file can be read */ + n = irafgeti4 (irafheader, imphyslen); + hputi4 (fitsheader, "NPAXIS1", n); + hputcom (fitsheader,"NPAXIS1", "IRAF .imh physical naxis[1]"); + fhead = fhead + 80; + if (nax > 1) { + n = irafgeti4 (irafheader, imphyslen+4); + hputi4 (fitsheader, "NPAXIS2", n); + hputcom (fitsheader,"NPAXIS2", "IRAF .imh physical naxis[2]"); + fhead = fhead + 80; + } + if (nax > 2) { + n = irafgeti4 (irafheader, imphyslen+8); + hputi4 (fitsheader, "NPAXIS3", n); + hputcom (fitsheader,"NPAXIS3", "IRAF .imh physical naxis[3]"); + fhead = fhead + 80; + } + if (nax > 3) { + n = irafgeti4 (irafheader, imphyslen+12); + hputi4 (fitsheader, "NPAXIS4", n); + hputcom (fitsheader,"NPAXIS4", "IRAF .imh physical naxis[4]"); + fhead = fhead + 80; + } + + /* Save image minimum and maximum in header */ + rmax = irafgetr4 (irafheader, immax); + rmin = irafgetr4 (irafheader, immin); + if (rmin != rmax) { + hputr4 (fitsheader, "IRAFMIN", &rmin); + fhead = fhead + 80; + hputcom (fitsheader,"IRAFMIN", "IRAF .imh minimum"); + hputr4 (fitsheader, "IRAFMAX", &rmax); + hputcom (fitsheader,"IRAFMAX", "IRAF .imh maximum"); + fhead = fhead + 80; + } + + /* Save image header filename in header */ + nl = hputm (fitsheader,"IMHFIL",hdrname); + if (nl > 0) { + lname = strlen (hdrname); + strcpy (fitsline, "IRAF header file name"); + if (lname < 43) + hputcom (fitsheader,"IMHFIL_1", fitsline); + else if (lname > 67 && lname < 110) + hputcom (fitsheader,"IMHFIL_2", fitsline); + else if (lname > 134 && lname < 177) + hputcom (fitsheader,"IMHFIL_3", fitsline); + } + if (nl > 0) fhead = fhead + (nl * 80); + + /* Save image pixel file pathname in header */ + if (imhver == 2) + pixname = irafgetc (irafheader, IM2_PIXFILE, SZ_IM2PIXFILE); + else + pixname = irafgetc2 (irafheader, IM_PIXFILE, SZ_IMPIXFILE); + if (strncmp(pixname, "HDR", 3) == 0 ) { + newpixname = same_path (pixname, hdrname); + free (pixname); + pixname = newpixname; + } + if (strchr (pixname, '/') == NULL && strchr (pixname, '$') == NULL) { + newpixname = same_path (pixname, hdrname); + free (pixname); + pixname = newpixname; + } + + if ((bang = strchr (pixname, '!')) != NULL ) + nl = hputm (fitsheader,"PIXFIL",bang+1); + else + nl = hputm (fitsheader,"PIXFIL",pixname); + free (pixname); + if (nl > 0) { + strcpy (fitsline, "IRAF .pix pixel file"); + if (lname < 43) + hputcom (fitsheader,"PIXFIL_1", fitsline); + else if (lname > 67 && lname < 110) + hputcom (fitsheader,"PIXFIL_2", fitsline); + else if (lname > 134 && lname < 177) + hputcom (fitsheader,"PIXFIL_3", fitsline); + } + if (nl > 0) fhead = fhead + (nl * 80); + + /* Save image offset from star of pixel file */ + pixoff = irafgeti4 (irafheader, impixoff); + pixoff = (pixoff - 1) * 2; + hputi4 (fitsheader, "PIXOFF", pixoff); + hputcom (fitsheader,"PIXOFF", "IRAF .pix pixel offset (Do not change!)"); + fhead = fhead + 80; + + /* Save IRAF file format version in header */ + hputi4 (fitsheader,"IMHVER",imhver); + hputcom (fitsheader,"IMHVER", "IRAF .imh format version (1 or 2)"); + fhead = fhead + 80; + + /* Set flag if header numbers are byte-reversed on this machine */ + if (machswap() != headswap) + hputl (fitsheader, "HEADSWAP", 1); + else + hputl (fitsheader, "HEADSWAP", 0); + hputcom (fitsheader,"HEADSWAP", "IRAF header, FITS byte orders differ if T"); + fhead = fhead + 80; + + /* Set flag if image pixels are byte-reversed on this machine */ + if (imhver == 2) { + hpixswap = irafgeti4 (irafheader, IM2_SWAPPED); + if (headswap && !hpixswap) + pixswap = 1; + else if (!headswap && hpixswap) + pixswap = 1; + else + pixswap = 0; + } + else + pixswap = headswap; + if (machswap() != pixswap) + hputl (fitsheader, "PIXSWAP", 1); + else + hputl (fitsheader, "PIXSWAP", 0); + hputcom (fitsheader,"PIXSWAP", "IRAF pixels, FITS byte orders differ if T"); + fhead = fhead + 80; + + /* Read modification time */ + mtime = irafgeti4 (irafheader, imtime); + if (mtime == 0) + dstring = lt2fd (); + else + dstring = tsi2fd (mtime); + hputs (fitsheader, "DATE-MOD", dstring); + hputcom (fitsheader,"DATE-MOD", "Date of latest file modification"); + free (dstring); + fhead = fhead + 80; + + /* Add user portion of IRAF header to FITS header */ + fitsline[80] = 0; + if (imhver == 2) { + imu = LEN_IM2HDR; + chead = irafheader; + j = 0; + for (k = 0; k < 80; k++) + fitsline[k] = ' '; + for (i = imu; i < nbiraf; i++) { + irafchar = chead[i]; + if (irafchar == 0) + break; + else if (irafchar == 10) { + (void)strncpy (fhead, fitsline, 80); + /* fprintf (stderr,"%80s\n",fitsline); */ + if (strncmp (fitsline, "OBJECT ", 7) != 0) { + fhead = fhead + 80; + } + for (k = 0; k < 80; k++) + fitsline[k] = ' '; + j = 0; + } + else { + if (j > 80) { + if (strncmp (fitsline, "OBJECT ", 7) != 0) { + (void)strncpy (fhead, fitsline, 80); + /* fprintf (stderr,"%80s\n",fitsline); */ + j = 9; + fhead = fhead + 80; + } + for (k = 0; k < 80; k++) + fitsline[k] = ' '; + } + if (irafchar > 32 && irafchar < 127) + fitsline[j] = irafchar; + j++; + } + } + } + else { + imu = LEN_IMHDR; + chead = irafheader; + if (headswap == 1) + ib = 0; + else + ib = 1; + for (k = 0; k < 80; k++) + fitsline[k] = ' '; + j = 0; + for (i = imu; i < nbiraf; i=i+2) { + irafchar = chead[i+ib]; + if (irafchar == 0) + break; + else if (irafchar == 10) { + if (strncmp (fitsline, "OBJECT ", 7) != 0) { + (void)strncpy (fhead, fitsline, 80); + fhead = fhead + 80; + } + /* fprintf (stderr,"%80s\n",fitsline); */ + j = 0; + for (k = 0; k < 80; k++) + fitsline[k] = ' '; + } + else { + if (j > 80) { + if (strncmp (fitsline, "OBJECT ", 7) != 0) { + (void)strncpy (fhead, fitsline, 80); + j = 9; + fhead = fhead + 80; + } + /* fprintf (stderr,"%80s\n",fitsline); */ + for (k = 0; k < 80; k++) + fitsline[k] = ' '; + } + if (irafchar > 32 && irafchar < 127) + fitsline[j] = irafchar; + j++; + } + } + } + + /* Add END to last line */ + (void)strncpy (fhead, endline, 80); + + /* Find end of last 2880-byte block of header */ + fhead = ksearch (fitsheader, "END") + 80; + nblock = *nbfits / 2880; + fhead1 = fitsheader + (nblock * 2880); + + /* Pad rest of header with spaces */ + strncpy (endline," ",3); + for (fp = fhead; fp < fhead1; fp = fp + 80) { + (void)strncpy (fp, endline,80); + } + + return (fitsheader); +} + + +int +irafwhead (hdrname, lhead, irafheader, fitsheader) + +char *hdrname; /* Name of IRAF header file */ +int lhead; /* Length of IRAF header */ +char *irafheader; /* IRAF header */ +char *fitsheader; /* FITS image header */ + +{ + int fd; + int nbw, nbhead, lphead, pixswap; + + /* Get rid of redundant header information */ + hgeti4 (fitsheader, "PIXOFF", &lphead); + hgeti4 (fitsheader, "PIXSWAP", &pixswap); + + /* Write IRAF header file */ + + /* Convert FITS header to IRAF header */ + irafheader = fits2iraf (fitsheader, irafheader, lhead, &nbhead); + if (irafheader == NULL) { + fprintf (stderr, "IRAFWIMAGE: file %s header error\n", hdrname); + return (-1); + } + + /* Open the output file */ + if (!access (hdrname, 0)) { + fd = open (hdrname, O_WRONLY); + if (fd < 3) { + fprintf (stderr, "IRAFWIMAGE: file %s not writeable\n", hdrname); + return (0); + } + } + else { + fd = open (hdrname, O_RDWR+O_CREAT, 0666); + if (fd < 3) { + fprintf (stderr, "IRAFWIMAGE: cannot create file %s\n", hdrname); + return (0); + } + } + + /* Write IRAF header to disk file */ + nbw = write (fd, irafheader, nbhead); + (void) ftruncate (fd, nbhead); + close (fd); + if (nbw < nbhead) { + (void)fprintf(stderr, "IRAF header file %s: %d / %d bytes written.\n", + hdrname, nbw, nbhead); + return (-1); + } + + return (nbw); +} + +/* IRAFWIMAGE -- write IRAF .imh header file and .pix image file + * No matter what the input, this always writes in the local byte order */ + +int +irafwimage (hdrname, lhead, irafheader, fitsheader, image ) + +char *hdrname; /* Name of IRAF header file */ +int lhead; /* Length of IRAF header */ +char *irafheader; /* IRAF header */ +char *fitsheader; /* FITS image header */ +char *image; /* IRAF image */ + +{ + int fd; + char *bang; + int nbw, bytepix, bitpix, naxis, naxis1, naxis2, nbimage, lphead; + char *pixn, *newpixname; + char pixname[SZ_IM2PIXFILE+1]; + int imhver, pixswap; + + hgeti4 (fitsheader, "IMHVER", &imhver); + + if (!hgetm (fitsheader, "PIXFIL", SZ_IM2PIXFILE, pixname)) { + if (imhver == 2) + pixn = irafgetc (irafheader, IM2_PIXFILE, SZ_IM2PIXFILE); + else + pixn = irafgetc2 (irafheader, IM_PIXFILE, SZ_IMPIXFILE); + if (strncmp(pixn, "HDR", 3) == 0 ) { + newpixname = same_path (pixn, hdrname); + strcpy (pixname, newpixname); + free (newpixname); + } + else { + if ((bang = strchr (pixn, '!')) != NULL ) + strcpy (pixname, bang+1); + else + strcpy (pixname, pixn); + } + free (pixn); + } + + /* Find number of bytes to write */ + hgeti4 (fitsheader,"NAXIS",&naxis); + hgeti4 (fitsheader,"NAXIS1",&naxis1); + hgeti4 (fitsheader,"NAXIS2",&naxis2); + hgeti4 (fitsheader,"BITPIX",&bitpix); + if (bitpix < 0) + bytepix = -bitpix / 8; + else + bytepix = bitpix / 8; + + /* If either dimension is one and image is 3-D, read all three dimensions */ + if (naxis == 3 && ((naxis1 == 1) | (naxis2 == 1))) { + int naxis3; + hgeti4 (fitsheader,"NAXIS3",&naxis3); + nbimage = naxis1 * naxis2 * naxis3 * bytepix; + } + else + nbimage = naxis1 * naxis2 * bytepix; + + /* Read information about pixel file from header */ + hgeti4 (fitsheader, "PIXOFF", &lphead); + hgeti4 (fitsheader, "PIXSWAP", &pixswap); + + /* Write IRAF header file */ + if (irafwhead (hdrname, lhead, irafheader, fitsheader)) + return (0); + + /* Open the output file */ + if (!access (pixname, 0)) { + fd = open (pixname, O_WRONLY); + if (fd < 3) { + fprintf (stderr, "IRAFWIMAGE: file %s not writeable\n", pixname); + return (0); + } + } + else { + fd = open (pixname, O_RDWR+O_CREAT, 0666); + if (fd < 3) { + fprintf (stderr, "IRAFWIMAGE: cannot create file %s\n", pixname); + return (0); + } + } + + /* Write header to IRAF pixel file */ + if (imhver == 2) + irafputc ("impv2", irafheader, 0, 5); + else + irafputc2 ("impix", irafheader, 0, 5); + nbw = write (fd, irafheader, lphead); + + /* Byte-reverse image, if necessary */ + if (pixswap) + irafswap (bitpix, image, nbimage); + + /* Write data to IRAF pixel file */ + nbw = write (fd, image, nbimage); + close (fd); + + return (nbw); +} + + +/* Put filename and header path together */ + +static char * +same_path (pixname, hdrname) + +char *pixname; /* IRAF pixel file pathname */ +char *hdrname; /* IRAF image header file pathname */ + +{ + int len, plen; + char *newpixname; + + newpixname = (char *) calloc (SZ_IM2PIXFILE, 1); + + /* Pixel file is in same directory as header */ + if (strncmp(pixname, "HDR$", 4) == 0 ) { + (void)strncpy (newpixname, hdrname, SZ_IM2PIXFILE); + + /* find the end of the pathname */ + len = strlen (newpixname); +#ifndef VMS + while( (len > 0) && (newpixname[len-1] != '/') ) +#else + while( (len > 0) && (newpixname[len-1] != ']') && (newpixname[len-1] != ':') ) +#endif + len--; + + /* add name */ + newpixname[len] = '\0'; + plen = strlen (pixname) - 4; + if (len + plen > SZ_IM2PIXFILE) + (void)strncat (newpixname, &pixname[4], SZ_IM2PIXFILE - len); + else + (void)strncat (newpixname, &pixname[4], plen); + } + + /* Bare pixel file with no path is assumed to be same as HDR$filename */ + else if (strchr (pixname, '/') == NULL && strchr (pixname, '$') == NULL) { + (void)strncpy (newpixname, hdrname, SZ_IM2PIXFILE); + + /* find the end of the pathname */ + len = strlen (newpixname); +#ifndef VMS + while( (len > 0) && (newpixname[len-1] != '/') ) +#else + while( (len > 0) && (newpixname[len-1] != ']') && (newpixname[len-1] != ':') ) +#endif + len--; + + /* add name */ + newpixname[len] = '\0'; + (void)strncat (newpixname, pixname, SZ_IM2PIXFILE); + } + + /* Pixel file has same name as header file, but with .pix extension */ + else if (strncmp (pixname, "HDR", 3) == 0) { + + /* load entire header name string into name buffer */ + (void)strncpy (newpixname, hdrname, SZ_IM2PIXFILE); + len = strlen (newpixname); + newpixname[len-3] = 'p'; + newpixname[len-2] = 'i'; + newpixname[len-1] = 'x'; + } + + return (newpixname); +} + +/* Convert FITS image header to IRAF image header, returning IRAF header */ +/* No matter what the input, this always writes in the local byte order */ + +char * +fits2iraf (fitsheader, irafheader, nbhead, nbiraf) + +char *fitsheader; /* FITS image header */ +char *irafheader; /* IRAF image header (returned updated) */ +int nbhead; /* Length of IRAF header */ +int *nbiraf; /* Length of returned IRAF header */ + +{ + int i, n, pixoff, lhdrdir; + short *irafp, *irafs, *irafu; + char *iraf2u, *iraf2p, *filename, *hdrdir; + char *fitsend, *fitsp, pixfile[SZ_IM2PIXFILE], hdrfile[SZ_IM2HDRFILE]; + char title[SZ_IM2TITLE], temp[80]; + int nax, nlfits, imhver, nbits, pixtype, hdrlength, mtime; + int imndim, imlen, imphyslen, impixtype, imhlen, imtime, immax, immin; + float rmax, rmin; + + hgeti4 (fitsheader, "IMHVER", &imhver); + hdel (fitsheader, "IMHVER"); + hdel (fitsheader, "IMHVER"); + hgetl (fitsheader, "HEADSWAP", &headswap); + hdel (fitsheader, "HEADSWAP"); + hdel (fitsheader, "HEADSWAP"); + if (imhver == 2) { + imhlen = IM2_HDRLEN; + imndim = IM2_NDIM; + imlen = IM2_LEN; + imtime = IM2_MTIME; + imphyslen = IM2_PHYSLEN; + impixtype = IM2_PIXTYPE; + immax = IM2_MAX; + immin = IM2_MIN; + } + else { + imhlen = IM_HDRLEN; + imndim = IM_NDIM; + imlen = IM_LEN; + imtime = IM_MTIME; + imphyslen = IM_PHYSLEN; + impixtype = IM_PIXTYPE; + immax = IM_MAX; + immin = IM_MIN; + } + + /* Delete FITS header keyword not needed by IRAF */ + hdel (fitsheader,"SIMPLE"); + + /* Set IRAF image data type */ + hgeti4 (fitsheader,"BITPIX", &nbits); + switch (nbits) { + case 8: + pixtype = TY_CHAR; + break; + case -8: + pixtype = TY_UBYTE; + break; + case 16: + pixtype = TY_SHORT; + break; + case -16: + pixtype = TY_USHORT; + break; + case 32: + pixtype = TY_INT; + break; + case -32: + pixtype = TY_REAL; + break; + case -64: + pixtype = TY_DOUBLE; + break; + default: + (void)fprintf(stderr,"Unsupported data type: %d\n", nbits); + return (NULL); + } + irafputi4 (irafheader, impixtype, pixtype); + hdel (fitsheader,"BITPIX"); + + /* Set IRAF image dimensions */ + hgeti4 (fitsheader,"NAXIS",&nax); + irafputi4 (irafheader, imndim, nax); + hdel (fitsheader,"NAXIS"); + + hgeti4 (fitsheader, "NAXIS1", &n); + irafputi4 (irafheader, imlen, n); + irafputi4 (irafheader, imphyslen, n); + hdel (fitsheader,"NAXIS1"); + + hgeti4 (fitsheader,"NAXIS2",&n); + irafputi4 (irafheader, imlen+4, n); + irafputi4 (irafheader, imphyslen+4, n); + hdel (fitsheader,"NAXIS2"); + + if (nax > 2) { + hgeti4 (fitsheader,"NAXIS3",&n); + irafputi4 (irafheader, imlen+8, n); + irafputi4 (irafheader, imphyslen+8, n); + hdel (fitsheader,"NAXIS3"); + } + + if (nax > 3) { + hgeti4 (fitsheader,"NAXIS4",&n); + irafputi4 (irafheader, imlen+12, n); + irafputi4 (irafheader, imphyslen+12, n); + hdel (fitsheader,"NAXIS4"); + } + + /* Set image pixel value limits */ + rmin = 0.0; + hgetr4 (fitsheader, "IRAFMIN", &rmin); + rmax = 0.0; + hgetr4 (fitsheader, "IRAFMAX", &rmax); + if (rmin != rmax) { + irafputr4 (irafheader, immax, rmax); + irafputr4 (irafheader, immin, rmin); + } + hdel (fitsheader, "IRAFMIN"); + hdel (fitsheader, "IRAFMAX"); + + /* Replace pixel file name, if it is in the FITS header */ + if (hgetm (fitsheader, "PIXFIL", SZ_IM2PIXFILE, pixfile)) { + if (strchr (pixfile, '/')) { + if (hgetm (fitsheader, "IMHFIL", SZ_IM2HDRFILE, hdrfile)) { + hdrdir = strrchr (hdrfile, '/'); + if (hdrdir != NULL) { + lhdrdir = hdrdir - hdrfile + 1; + if (!strncmp (pixfile, hdrfile, lhdrdir)) { + filename = pixfile + lhdrdir; + strcpy (temp, "HDR$"); + strcat (temp,filename); + strcpy (pixfile, temp); + } + } + if (pixfile[0] != '/' && pixfile[0] != 'H') { + strcpy (temp, "HDR$"); + strcat (temp,pixfile); + strcpy (pixfile, temp); + } + } + } + + if (imhver == 2) + irafputc (pixfile, irafheader, IM2_PIXFILE, SZ_IM2PIXFILE); + else + irafputc2 (pixfile, irafheader, IM_PIXFILE, SZ_IMPIXFILE); + hdel (fitsheader,"PIXFIL_1"); + hdel (fitsheader,"PIXFIL_2"); + hdel (fitsheader,"PIXFIL_3"); + hdel (fitsheader,"PIXFIL_4"); + } + + /* Replace header file name, if it is in the FITS header */ + if (hgetm (fitsheader, "IMHFIL", SZ_IM2HDRFILE, pixfile)) { + if (!strchr (pixfile,'/') && !strchr (pixfile,'$')) { + strcpy (temp, "HDR$"); + strcat (temp,pixfile); + strcpy (pixfile, temp); + } + if (imhver == 2) + irafputc (pixfile, irafheader, IM2_HDRFILE, SZ_IM2HDRFILE); + else + irafputc2 (pixfile, irafheader, IM_HDRFILE, SZ_IMHDRFILE); + hdel (fitsheader, "IMHFIL_1"); + hdel (fitsheader, "IMHFIL_2"); + hdel (fitsheader, "IMHFIL_3"); + hdel (fitsheader, "IMHFIL_4"); + } + + /* Replace image title, if it is in the FITS header */ + if (hgets (fitsheader, "OBJECT", SZ_IM2TITLE, title)) { + if (imhver == 2) + irafputc (title, irafheader, IM2_TITLE, SZ_IM2TITLE); + else + irafputc2 (title, irafheader, IM_TITLE, SZ_IMTITLE); + hdel (fitsheader, "OBJECT"); + } + hgeti4 (fitsheader, "PIXOFF", &pixoff); + hdel (fitsheader, "PIXOFF"); + hdel (fitsheader, "PIXOFF"); + hdel (fitsheader, "PIXSWAP"); + hdel (fitsheader, "PIXSWAP"); + hdel (fitsheader, "DATE-MOD"); + hdel (fitsheader, "DATE-MOD"); + fitsend = ksearch (fitsheader,"END"); + + /* Find length of FITS header */ + fitsend = ksearch (fitsheader,"END"); + nlfits = ((fitsend - fitsheader) / 80); + + /* Find new length of IRAF header */ + if (imhver == 2) + *nbiraf = LEN_IM2HDR + (81 * nlfits); + else + *nbiraf = LEN_IMHDR + (162 * nlfits); + if (*nbiraf > nbhead) + irafheader = realloc (irafheader, *nbiraf); + + /* Reset modification time */ + mtime = lt2tsi (); + irafputi4 (irafheader, imtime, mtime); + + /* Replace user portion of IRAF header with remaining FITS header */ + if (imhver == 2) { + iraf2u = irafheader + LEN_IM2HDR; + iraf2p = iraf2u; + for (fitsp = fitsheader; fitsp < fitsend; fitsp = fitsp + 80) { + for (i = 0; i < 80; i++) + *iraf2p++ = fitsp[i]; + *iraf2p++ = 10; + } + *iraf2p++ = 0; + *nbiraf = iraf2p - irafheader; + hdrlength = 1 + *nbiraf / 2; + } + else { + irafs = (short *)irafheader; + irafu = irafs + (LEN_IMHDR / 2); + irafp = irafu; + for (fitsp = fitsheader; fitsp < fitsend; fitsp = fitsp + 80) { + for (i = 0; i < 80; i++) + *irafp++ = (short) fitsp[i]; + *irafp++ = 10; + } + *irafp++ = 0; + *irafp++ = 32; + *nbiraf = 2 * (irafp - irafs); + hdrlength = *nbiraf / 4; + } + + /* Length of header file */ + irafputi4 (irafheader, imhlen, hdrlength); + + /* Offset in .pix file to first pixel data + hputi4 (fitsheader, "PIXOFF", pixoff); */ + + /* Return number of bytes in new IRAF header */ + return (irafheader); +} + + +int +irafgeti4 (irafheader, offset) + +char *irafheader; /* IRAF image header */ +int offset; /* Number of bytes to skip before number */ + +{ + char *ctemp, *cheader; + int temp; + + cheader = irafheader; + ctemp = (char *) &temp; + + /* If header swap flag not set, set it now */ + if (headswap < 0) { + if (cheader[offset] > 0) + headswap = 1; + else + headswap = 0; + } + + if (machswap() != headswap) { + ctemp[3] = cheader[offset]; + ctemp[2] = cheader[offset+1]; + ctemp[1] = cheader[offset+2]; + ctemp[0] = cheader[offset+3]; + } + else { + ctemp[0] = cheader[offset]; + ctemp[1] = cheader[offset+1]; + ctemp[2] = cheader[offset+2]; + ctemp[3] = cheader[offset+3]; + } + return (temp); +} + + +float +irafgetr4 (irafheader, offset) + +char *irafheader; /* IRAF image header */ +int offset; /* Number of bytes to skip before number */ + +{ + char *ctemp, *cheader; + float temp; + + cheader = irafheader; + ctemp = (char *) &temp; + + /* If header swap flag not set, set it now */ + if (headswap < 0) { + if (cheader[offset] > 0) + headswap = 1; + else + headswap = 0; + } + + if (machswap() != headswap) { + ctemp[3] = cheader[offset]; + ctemp[2] = cheader[offset+1]; + ctemp[1] = cheader[offset+2]; + ctemp[0] = cheader[offset+3]; + } + else { + ctemp[0] = cheader[offset]; + ctemp[1] = cheader[offset+1]; + ctemp[2] = cheader[offset+2]; + ctemp[3] = cheader[offset+3]; + } + return (temp); +} + + +/* IRAFGETC2 -- Get character string from arbitrary part of v.1 IRAF header */ + +char * +irafgetc2 (irafheader, offset, nc) + +char *irafheader; /* IRAF image header */ +int offset; /* Number of bytes to skip before string */ +int nc; /* Maximum number of characters in string */ + +{ + char *irafstring, *string; + + irafstring = irafgetc (irafheader, offset, 2*(nc+1)); + string = iraf2str (irafstring, nc); + free (irafstring); + + return (string); +} + + +/* IRAFGETC -- Get character string from arbitrary part of IRAF header */ + +char * +irafgetc (irafheader, offset, nc) + +char *irafheader; /* IRAF image header */ +int offset; /* Number of bytes to skip before string */ +int nc; /* Maximum number of characters in string */ + +{ + char *ctemp, *cheader; + int i; + + cheader = irafheader; + ctemp = (char *) calloc (nc+1, 1); + if (ctemp == NULL) { + (void)fprintf(stderr, "IRAFGETC Cannot allocate %d-byte variable\n", + nc+1); + return (NULL); + } + for (i = 0; i < nc; i++) { + ctemp[i] = cheader[offset+i]; + if (ctemp[i] > 0 && ctemp[i] < 32) + ctemp[i] = ' '; + } + + return (ctemp); +} + + +/* Convert IRAF 2-byte/char string to 1-byte/char string */ + +char * +iraf2str (irafstring, nchar) + +char *irafstring; /* IRAF 2-byte/character string */ +int nchar; /* Number of characters in string */ +{ + char *string; + int i, j; + + /* Set swap flag according to position of nulls in 2-byte characters */ + if (headswap < 0) { + if (irafstring[0] != 0 && irafstring[1] == 0) + headswap = 1; + else if (irafstring[0] == 0 && irafstring[1] != 0) + headswap = 0; + else + return (NULL); + } + + string = (char *) calloc (nchar+1, 1); + if (string == NULL) { + (void)fprintf(stderr, "IRAF2STR Cannot allocate %d-byte variable\n", + nchar+1); + return (NULL); + } + + /* Swap bytes, if requested */ + if (headswap) + j = 0; + else + j = 1; + + /* Convert appropriate byte of input to output character */ + for (i = 0; i < nchar; i++) { + string[i] = irafstring[j]; + j = j + 2; + } + + return (string); +} + + +/* IRAFPUTI4 -- Insert 4-byte integer into arbitrary part of IRAF header */ + +static void +irafputi4 (irafheader, offset, inum) + +char *irafheader; /* IRAF image header */ +int offset; /* Number of bytes to skip before number */ +int inum; /* Number to put into header */ + +{ + char *cn, *chead; + + chead = irafheader; + cn = (char *) &inum; + if (headswap < 0) + headswap = 0; + if (headswap != machswap()) { + chead[offset+3] = cn[0]; + chead[offset+2] = cn[1]; + chead[offset+1] = cn[2]; + chead[offset] = cn[3]; + } + else { + chead[offset] = cn[0]; + chead[offset+1] = cn[1]; + chead[offset+2] = cn[2]; + chead[offset+3] = cn[3]; + } + return; +} + + +/* IRAFPUTR4 -- Insert 4-byte real number into arbitrary part of IRAF header */ + +static void +irafputr4 (irafheader, offset, rnum) + +char *irafheader; /* IRAF image header */ +int offset; /* Number of bytes to skip before number */ +float rnum; /* Number to put into header */ + +{ + char *cn, *chead; + + chead = irafheader; + cn = (char *) &rnum; + if (headswap < 0) + headswap = 0; + if (headswap != machswap()) { + chead[offset+3] = cn[0]; + chead[offset+2] = cn[1]; + chead[offset+1] = cn[2]; + chead[offset] = cn[3]; + } + else { + chead[offset] = cn[0]; + chead[offset+1] = cn[1]; + chead[offset+2] = cn[2]; + chead[offset+3] = cn[3]; + } + return; +} + + +/* IRAFPUTC2 -- Insert character string into arbitrary part of v.1 IRAF header */ + +static void +irafputc2 (string, irafheader, offset, nc) + +char *string; /* String to insert into header */ +char *irafheader; /* IRAF image header */ +int offset; /* Number of bytes to skip before string */ +int nc; /* Maximum number of characters in string */ + +{ + char *irafstring; + + irafstring = (char *) calloc (2 * nc, 1); + if (irafstring == NULL) { + (void)fprintf(stderr, "IRAFPUTC2 Cannot allocate %d-byte variable\n", + 2 * nc); + } + str2iraf (string, irafstring, nc); + irafputc (irafstring, irafheader, offset, 2*nc); + + return; +} + + +/* IRAFPUTC -- Insert character string into arbitrary part of IRAF header */ + +static void +irafputc (string, irafheader, offset, nc) + +char *string; /* String to insert into header */ +char *irafheader; /* IRAF image header */ +int offset; /* Number of bytes to skip before string */ +int nc; /* Maximum number of characters in string */ + +{ + char *chead; + int i; + + chead = irafheader; + for (i = 0; i < nc; i++) + chead[offset+i] = string[i]; + + return; +} + + +/* STR2IRAF -- Convert 1-byte/char string to IRAF 2-byte/char string */ + +static void +str2iraf (string, irafstring, nchar) + +char *string; /* 1-byte/character string */ +char *irafstring; /* IRAF 2-byte/character string */ +int nchar; /* Maximum number of characters in IRAF string */ +{ + int i, j, nc, nbytes; + + nc = strlen (string); + + /* Fill output string with zeroes */ + nbytes = nchar * 2; + for (i = 0; i < nbytes; i++) + irafstring[i] = 0; + + /* If swapped, start with first byte of 2-byte characters */ + if (headswap) + j = 0; + else + j = 1; + + /* Move input characters to appropriate bytes of output */ + for (i = 0; i < nchar; i++) { + if (i > nc) + irafstring[j] = 0; + else + irafstring[j] = string[i]; + j = j + 2; + } + + return; +} + + +/* IRAFSWAP -- Reverse bytes of any type of vector in place */ + +static void +irafswap (bitpix, string, nbytes) + +int bitpix; /* Number of bits per pixel */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +char *string; /* Address of starting point of bytes to swap */ +int nbytes; /* Number of bytes to swap */ + +{ + switch (bitpix) { + + case 16: + if (nbytes < 2) return; + irafswap2 (string,nbytes); + break; + + case 32: + if (nbytes < 4) return; + irafswap4 (string,nbytes); + break; + + case -16: + if (nbytes < 2) return; + irafswap2 (string,nbytes); + break; + + case -32: + if (nbytes < 4) return; + irafswap4 (string,nbytes); + break; + + case -64: + if (nbytes < 8) return; + irafswap8 (string,nbytes); + break; + + } + return; +} + + +/* IRAFSWAP2 -- Swap bytes in string in place */ + +static void +irafswap2 (string,nbytes) + + +char *string; /* Address of starting point of bytes to swap */ +int nbytes; /* Number of bytes to swap */ + +{ + char *sbyte, temp, *slast; + + slast = string + nbytes; + sbyte = string; + while (sbyte < slast) { + temp = sbyte[0]; + sbyte[0] = sbyte[1]; + sbyte[1] = temp; + sbyte= sbyte + 2; + } + return; +} + + +/* IRAFSWAP4 -- Reverse bytes of Integer*4 or Real*4 vector in place */ + +static void +irafswap4 (string,nbytes) + +char *string; /* Address of Integer*4 or Real*4 vector */ +int nbytes; /* Number of bytes to reverse */ + +{ + char *sbyte, *slast; + char temp0, temp1, temp2, temp3; + + slast = string + nbytes; + sbyte = string; + while (sbyte < slast) { + temp3 = sbyte[0]; + temp2 = sbyte[1]; + temp1 = sbyte[2]; + temp0 = sbyte[3]; + sbyte[0] = temp0; + sbyte[1] = temp1; + sbyte[2] = temp2; + sbyte[3] = temp3; + sbyte = sbyte + 4; + } + + return; +} + + +/* IRAFSWAP8 -- Reverse bytes of Real*8 vector in place */ + +static void +irafswap8 (string,nbytes) + +char *string; /* Address of Real*8 vector */ +int nbytes; /* Number of bytes to reverse */ + +{ + char *sbyte, *slast; + char temp[8]; + + slast = string + nbytes; + sbyte = string; + while (sbyte < slast) { + temp[7] = sbyte[0]; + temp[6] = sbyte[1]; + temp[5] = sbyte[2]; + temp[4] = sbyte[3]; + temp[3] = sbyte[4]; + temp[2] = sbyte[5]; + temp[1] = sbyte[6]; + temp[0] = sbyte[7]; + sbyte[0] = temp[0]; + sbyte[1] = temp[1]; + sbyte[2] = temp[2]; + sbyte[3] = temp[3]; + sbyte[4] = temp[4]; + sbyte[5] = temp[5]; + sbyte[6] = temp[6]; + sbyte[7] = temp[7]; + sbyte = sbyte + 8; + } + return; +} + + +/* Set flag if machine on which program is executing is not FITS byte order + * ( i.e., if it is an Alpha or PC instead of a Sun ) */ + +static int +machswap () + +{ + char *ctest; + int itest; + + itest = 1; + ctest = (char *)&itest; + if (*ctest) + return (1); + else + return (0); +} + + +/* ISIRAF -- return 1 if IRAF imh file, else 0 */ + +int +isiraf (filename) + +char *filename; /* Name of file for which to find size */ +{ + if (strchr (filename, '=')) + return (0); + else if (strsrch (filename, ".imh")) + return (1); + else + return (0); +} + + +/* IRAFSIZE -- return size of file in bytes */ + +static int +irafsize (diskfile) + +FILE *diskfile; /* Descriptor of file for which to find size */ +{ + long filesize; + long offset; + + offset = (long) 0; + + /* Move to end of the file */ + if (fseek (diskfile, offset, SEEK_END) == 0) { + + /* Position is the size of the file */ + filesize = ftell (diskfile); + + /* Move file pointer back tot he start of the file */ + fseek (diskfile, offset, SEEK_SET); + } + + else + filesize = -1; + + return (filesize); +} + +/* Feb 15 1996 New file + * Apr 10 1996 Add more documentation + * Apr 17 1996 Print error message on open failure + * Jun 5 1996 Add byte swapping (reversal); use streams + * Jun 10 1996 Make fixes after running lint + * Jun 12 1996 Use IMSWAP subroutines instead of local ones + * Jul 3 1996 Go back to using local IRAFSWAP subroutines + * Jul 3 1996 Write to pixel file from FITS header + * Jul 10 1996 Allocate all headers + * Aug 13 1996 Add unistd.h to include list + * Aug 26 1996 Allow 1-d images; fix comments; fix arguments after lint + * Aug 26 1996 Add IRAF header lingth argument to IRAFWIMAGE and IRAFWHEAD + * Aug 28 1996 Clean up code in IRAF2FITS + * Aug 30 1996 Use write instead of fwrite + * Sep 4 1996 Fix write mode bug + * Oct 15 1996 Drop unused variables + * Oct 17 1996 Minor fix after lint; cast arguments to STR2IRAF + * + * May 15 1997 Fix returned header length in IRAF2FITS + * Dec 19 1997 Add IRAF version 2 .imh files + * + * Jan 2 1998 Allow uneven length of user parameter lines in IRAF headers + * Jan 6 1998 Fix output of imh2 headers; allow newlines in imh1 headers + * Jan 14 1998 Handle byte reversing correctly + * Apr 17 1998 Add new IRAF data types unsigned char and unsigned short + * Apr 30 1998 Fix error return if illegal data type after Allan Brighton + * May 15 1998 Delete header keywords used for IRAF binary values + * May 15 1998 Fix bug so FITS OBJECT is put into IRAF title + * May 26 1998 Fix bug in fits2iraf keeping track of end of header + * May 27 1998 Include fitsio.h instead of fitshead.h + * Jun 4 1998 Write comments into header for converted IRAF binary values + * Jun 4 1998 Pad FITS strings to 8 character minimum + * Jul 24 1998 Write header file length to IRAF header file + * Jul 27 1998 Print error messages to stderr for all failed malloc's + * Jul 27 1998 Fix bug padding FITS header with spaces in iraf2fits + * Jul 27 1998 Write modification time to IRAF header file + * Aug 6 1998 Change fitsio.h to fitsfile.h; imhio.c to imhfile.c + * Oct 1 1998 Set irafswap flag only once per file + * Oct 5 1998 Add subroutines irafsize() and isiraf() + * Nov 16 1998 Fix byte-swap checking + * + * Jan 27 1999 Read and write all of 3D image if one dimension is =1 + * Jul 13 1999 Improve error messages; change irafsize() argument to fd + * Sep 22 1999 Don't copy OBJECT keyword from .imh file; use binary title + * Oct 14 1999 Set FITS header length + * Oct 20 1999 Allocate 5000 extra bytes for IRAF header + * Nov 2 1999 Fix getclocktime() to use only time.h subroutines + * Nov 2 1999 Add modification date and time to FITS header in iraf2fits() + * Nov 24 1999 Delete HEADSWAP, IMHVER, DATE-MOD from header before writing + * Nov 29 1999 Delete PIXSWAP, IRAF-MIN, IRAF-MAX from header before writing + * + * Jan 13 2000 Fix bug which dropped characters in iraf2fits() + * Feb 3 2000 Declare timezone long, not time_t; drop unused variable + * Mar 7 2000 Add more code to keep pixel file path short + * Mar 10 2000 Fix bugs when writing .imh file headers + * Mar 21 2000 Change computation of IRAF time tags to use only data structure + * Mar 22 2000 Move IRAF time tag computation to lt2tsi() in dateutil.c + * Mar 24 2000 Use Unix file update time if none in header + * Mar 27 2000 Use hputm() to save file paths up to 256 characters + * Mar 27 2000 Write filename comments after 1st keyword with short value + * Mar 27 2000 Allocate pixel file name in same_path to imh2 length + * Mar 29 2000 Add space after last linefeed of header in fits2iraf() + * Apr 28 2000 Dimension pixname in irafwimage() + * May 1 2000 Fix code for updating pixel file name with HDR$ in fits2iraf() + * Jun 2 2000 Drop unused variables in fits2iraf() after lint + * Jun 12 2000 If pixel filename has no / or $, use same path as header file + * Sep 6 2000 Use header directory if pixel file not found at its pathname + * + * Jan 11 2001 Print all messages to stderr + * Aug 24 2001 In isiraf(), return 0 if argument contains an equal sign + * + * Apr 8 2002 Fix bug in error message for unidentified nbits in fits2iraf() + * + * Feb 4 2003 Open catalog file rb instead of r (Martin Ploner, Bern) + * Oct 31 2003 Read image only in irafrimage() if physical dimension > image dim. + * Nov 3 2003 Set NAXISi to image, not physical dimensions in iraf2fits() + * + * Jun 13 2005 Drop trailing spaces on pixel file name + * + * Jun 20 2006 Initialize uninitialized variables + * + * Jan 4 2007 Change hputr4() calls to send pointer to value + * Jan 8 2007 Drop unused variable nbx in irafrimage() + * Jan 8 2007 Align header and image buffers properly by 4 and by BITPIX + * + * May 20 2011 Free newpixname, not pixname in irafwimage() + * + * Mar 27 2012 Fix pixname's appending to newpixname to avoid overflow + */ diff --git a/tksao/wcssubs/imio.c b/tksao/wcssubs/imio.c new file mode 100644 index 0000000..3243283 --- /dev/null +++ b/tksao/wcssubs/imio.c @@ -0,0 +1,1544 @@ +/*** File wcslib/imio.c + *** October 30, 2012 + *** By Jessica Mink, jmink@cfa.harvard.edu + *** Harvard-Smithsonian Center for Astrophysics + *** Copyright (C) 1996-2012 + *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Correspondence concerning WCSTools should be addressed as follows: + Internet email: jmink@cfa.harvard.edu + Postal address: Jessica Mink + Smithsonian Astrophysical Observatory + 60 Garden St. + Cambridge, MA 02138 USA + + * Module: imio.c (image pixel manipulation) + * Purpose: Read and write pixels from arbitrary data type 2D arrays + * Subroutine: getpix (image, bitpix, w, h, bz, bs, x, y) + * Read pixel from 2D image of any numeric type (0,0 lower left) + * Subroutine: getpix1 (image, bitpix, w, h, bz, bs, x, y) + * Read pixel from 2D image of any numeric type (1,1 lower left) + * Subroutine: putpix (image, bitpix, w, h, bz, bs, x, y, dpix) + * Write pixel into 2D image of any numeric type (0,0 lower left) + * Subroutine: putpix1 (image, bitpix, w, h, bz, bs, x, y, dpix) + * Write pixel into 2D image of any numeric type (1,1 lower left) + * Subroutine: addpix (image, bitpix, w, h, bz, bs, x, y, dpix) + * Copy pixel into 2D image of any numeric type (0,0 lower left) + * Subroutine: addpix1 (image, bitpix, w, h, bz, bs, x, y, dpix) + * Add pixel into 2D image of any numeric type (1,1 lower left) + * Subroutine: maxvec (image, bitpix, bz, bs, pix1, npix) + * Get maximum of vector from 2D image of any numeric type + * Subroutine: minvec (image, bitpix, bz, bs, pix1, npix) + * Get minimum of vector from 2D image of any numeric type + * Subroutine: getvec (image, bitpix, bz, bs, pix1, npix, dvec) + * Get vector from 2D image of any numeric type + * Subroutine: putvec (image, bitpix, bz, bs, pix1, npix, dvec) + * Copy pixel vector into a vector of any numeric type + * Subroutine: addvec (image, bitpix, bz, bs, pix1, npix, dpix) + * Add constant to pixel values in a vector + * Subroutine: multvec (image, bitpix, bz, bs, pix1, npix, dpix) + * Multiply pixel values in a vector by a constant + * Subroutine: fillvec (image, bitpix, bz, bs, pix1, npix, dpix) + * Copy pixel value in a vector of any numeric type + * Subroutine: fillvec1 (image, bitpix, bz, bs, pix1, npix, dpix) + * Copy pixel value int a vector of any numeric type + * Subroutine: movepix (image1, bitpix, w1, x1, y1, image2, w2, x2, y2) + * Copy pixel from one image location to another + * Subroutine: imswap (bitpix,string,nbytes) + * Swap bytes in string in place, with FITS bits/pixel code + * Subroutine: imswap2 (string,nbytes) + * Swap bytes in string in place + * Subroutine imswap4 (string,nbytes) + * Reverse bytes of Integer*4 or Real*4 vector in place + * Subroutine imswap8 (string,nbytes) + * Reverse bytes of Real*8 vector in place + * Subroutine imswapped () + * Return 1 if PC/DEC byte order, else 0 + */ + +#include +#include +#include "fitsfile.h" + +static int scale = 1; /* If 0, skip scaling step */ +void +setscale (scale0) +int scale0; +{scale = scale0; return;} + +/* GETPIX1 -- Get pixel from 2D FITS image of any numeric type */ + +double +getpix1 (image, bitpix, w, h, bzero, bscale, x, y) + +char *image; /* Image array as 1-D vector */ +int bitpix; /* FITS bits per pixel */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +int w; /* Image width in pixels */ +int h; /* Image height in pixels */ +double bzero; /* Zero point for pixel scaling */ +double bscale; /* Scale factor for pixel scaling */ +int x; /* One-based horizontal pixel number */ +int y; /* One-based vertical pixel number */ + +{ + return (getpix (image, bitpix, w, h, bzero, bscale, x-1, y-1)); +} + + +/* GETPIX -- Get pixel from 2D image of any numeric type */ + +double +getpix (image, bitpix, w, h, bzero, bscale, x, y) + +char *image; /* Image array as 1-D vector */ +int bitpix; /* FITS bits per pixel */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +int w; /* Image width in pixels */ +int h; /* Image height in pixels */ +double bzero; /* Zero point for pixel scaling */ +double bscale; /* Scale factor for pixel scaling */ +int x; /* Zero-based horizontal pixel number */ +int y; /* Zero-based vertical pixel number */ + +{ + short *im2; + int *im4; + unsigned char *im1; + unsigned short *imu; + float *imr; + double *imd; + double dpix; + +/* Return 0 if coordinates are not inside image */ + if (x < 0 || x >= w) + return (0.0); + if (y < 0 || y >= h) + return (0.0); + +/* Extract pixel from appropriate type of array */ + switch (bitpix) { + + case 8: + im1 = (unsigned char *)image; + dpix = (double) im1[(y*w) + x]; + break; + + case 16: + im2 = (short *)image; + dpix = (double) im2[(y*w) + x]; + break; + + case 32: + im4 = (int *)image; + dpix = (double) im4[(y*w) + x]; + break; + + case -16: + imu = (unsigned short *)image; + dpix = (double) imu[(y*w) + x]; + break; + + case -32: + imr = (float *)image; + dpix = (double) imr[(y*w) + x]; + break; + + case -64: + imd = (double *)image; + dpix = imd[(y*w) + x]; + break; + + default: + dpix = 0.0; + } + if (scale) + return (bzero + (bscale * dpix)); + else + return (dpix); +} + + +/* PUTPIX1 -- Copy pixel into 2D FITS image of any numeric type */ + +void +putpix1 (image, bitpix, w, h, bzero, bscale, x, y, dpix) + +char *image; +int bitpix; /* Number of bits per pixel */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +int w; /* Image width in pixels */ +int h; /* Image height in pixels */ +double bzero; /* Zero point for pixel scaling */ +double bscale; /* Scale factor for pixel scaling */ +int x; /* One-based horizontal pixel number */ +int y; /* One-based vertical pixel number */ +double dpix; + +{ + putpix (image, bitpix, w, h, bzero, bscale, x-1, y-1, dpix); + return; +} + + +/* PUTPIX -- Copy pixel into 2D image of any numeric type */ + +void +putpix (image, bitpix, w, h, bzero, bscale, x, y, dpix) + +char *image; +int bitpix; /* Number of bits per pixel */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +int w; /* Image width in pixels */ +int h; /* Image height in pixels */ +double bzero; /* Zero point for pixel scaling */ +double bscale; /* Scale factor for pixel scaling */ +int x; +int y; +double dpix; + +{ + double *imd; + float *imr; + int *im4; + short *im2; + unsigned short *imu; + unsigned char *im1; + +/* Return if coordinates are not inside image */ + if (x < 0 || x >= w) + return; + if (y < 0 || y >= h) + return; + + if (scale) + dpix = (dpix - bzero) / bscale; + + switch (bitpix) { + + case 8: + im1 = (unsigned char *)image; + if (dpix < 0) + im1[(y*w) + x] = (unsigned char) (dpix - 0.5); + else + im1[(y*w) + x] = (unsigned char) (dpix + 0.5); + break; + + case 16: + im2 = (short *)image; + if (dpix < 0) + im2[(y*w) + x] = (short) (dpix - 0.5); + else + im2[(y*w) + x] = (short) (dpix + 0.5); + break; + + case 32: + im4 = (int *)image; + if (dpix < 0) + im4[(y*w) + x] = (int) (dpix - 0.5); + else + im4[(y*w) + x] = (int) (dpix + 0.5); + break; + + case -16: + imu = (unsigned short *)image; + if (dpix < 0) + imu[(y*w) + x] = (unsigned short) 0; + else + imu[(y*w) + x] = (unsigned short) (dpix + 0.5); + break; + + case -32: + imr = (float *)image; + imr[(y*w) + x] = (float) dpix; + break; + + case -64: + imd = (double *)image; + imd[(y*w) + x] = dpix; + break; + + } + return; +} + + +/* ADDPIX1 -- Add pixel value into 2D FITS image of any numeric type */ + +void +addpix1 (image, bitpix, w, h, bzero, bscale, x, y, dpix) + +char *image; +int bitpix; /* Number of bits per pixel */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +int w; /* Image width in pixels */ +int h; /* Image height in pixels */ +double bzero; /* Zero point for pixel scaling */ +double bscale; /* Scale factor for pixel scaling */ +int x; /* One-based horizontal pixel number */ +int y; /* One-based vertical pixel number */ +double dpix; /* Value to add to pixel */ + +{ + addpix (image, bitpix, w, h, bzero, bscale, x-1, y-1, dpix); + return; +} + + +/* ADDPIX -- Add constant to pixel values in 2D image of any numeric type */ + +void +addpix (image, bitpix, w, h, bzero, bscale, x, y, dpix) + +char *image; +int bitpix; /* Number of bits per pixel */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +int w; /* Image width in pixels */ +int h; /* Image height in pixels */ +double bzero; /* Zero point for pixel scaling */ +double bscale; /* Scale factor for pixel scaling */ +int x; /* Zero-based horizontal pixel number */ +int y; /* Zero-based vertical pixel number */ +double dpix; /* Value to add to pixel */ + +{ + double *imd; + float *imr; + int *im4; + short *im2; + unsigned short *imu; + unsigned char *im1; + int ipix; + +/* Return if coordinates are not inside image */ + if (x < 0 || x >= w) + return; + if (y < 0 || y >= h) + return; + + if (scale) + dpix = (dpix - bzero) / bscale; + ipix = (y * w) + x; + + switch (bitpix) { + + case 8: + im1 = (unsigned char *)image; + if (dpix < 0) + image[ipix] = im1[ipix] + (unsigned char) (dpix - 0.5); + else + image[ipix] = im1[ipix] + (unsigned char) (dpix + 0.5); + break; + + case 16: + im2 = (short *)image; + if (dpix < 0) + im2[ipix] = im2[ipix] + (short) (dpix - 0.5); + else + im2[ipix] = im2[ipix] + (short) (dpix + 0.5); + break; + + case 32: + im4 = (int *)image; + if (dpix < 0) + im4[ipix] = im4[ipix] + (int) (dpix - 0.5); + else + im4[ipix] = im4[ipix] + (int) (dpix + 0.5); + break; + + case -16: + imu = (unsigned short *)image; + if (dpix > 0) + imu[ipix] = imu[ipix] + (unsigned short) (dpix + 0.5); + break; + + case -32: + imr = (float *)image; + imr[ipix] = imr[ipix] + (float) dpix; + break; + + case -64: + imd = (double *)image; + imd[ipix] = imd[ipix] + dpix; + break; + + } + return; +} + + +/* MOVEPIX -- Copy pixel between images */ + +void +movepix (image1, bitpix1, w1, x1, y1, image2, bitpix2, w2, x2, y2) + +char *image1; /* Pointer to first pixel in input image */ +int bitpix1; /* Bits per input pixel (FITS codes) */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +int w1; /* Number of horizontal pixels in input image */ +int x1, y1; /* Row and column for input pixel */ + +char *image2; /* Pointer to first pixel in output image */ +int bitpix2; /* Bits per output pixel (FITS codes) */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +int w2; /* Number of horizontal pixels in output image */ +int x2, y2; /* Row and column for output pixel */ + +{ + double dpix, *imd1, *imd2; + float rpix, *imr1, *imr2; + int *imi1, *imi2; + short *ims1, *ims2; + unsigned short *imu1, *imu2; + unsigned char *imc1, *imc2; + + if (x1 < 0 || x2 < 0 || x1 >= w1 || x2 >= w2) + return; + if (y1 < 0 || y2 < 0) + return; + + switch (bitpix1) { + + case 8: + imc1 = (unsigned char *)image1; + switch (bitpix2) { + case 8: + imc2 = (unsigned char *)image2; + imc2[(y2*w2) + x2] = imc1[(y1*w1) + x1]; + break; + case 16: + ims2 = (short *)image2; + ims2[(y2*w2) + x2] = (short) imc1[(y1*w1) + x1]; + break; + case 32: + imi2 = (int *)image2; + imi2[(y2*w2) + x2] = (int) imc1[(y1*w1) + x1]; + break; + case -16: + imu2 = (unsigned short *)image2; + imu2[(y2*w2) + x2] = (unsigned short) imc1[(y1*w1) + x1]; + break; + case -32: + imr2 = (float *)image2; + imr2[(y2*w2) + x2] = (float) imc1[(y1*w1) + x1]; + break; + case -64: + imd2 = (double *)image2; + imd2[(y2*w2) + x2] = (double) imc1[(y1*w1) + x1]; + break; + } + break; + + case 16: + ims1 = (short *)image1; + switch (bitpix2) { + case 8: + imc2 = (unsigned char *)image1; + imc2[(y2*w2) + x2] = (unsigned char) ims1[(y1*w1) + x1]; + break; + case 16: + ims2 = (short *)image2; + ims2[(y2*w2) + x2] = ims1[(y1*w1) + x1]; + break; + case 32: + imi2 = (int *)image2; + imi2[(y2*w2) + x2] = (int) ims1[(y1*w1) + x1]; + break; + case -16: + imu2 = (unsigned short *)image2; + imu2[(y2*w2) + x2] = (unsigned short) ims1[(y1*w1) + x1]; + break; + case -32: + imr2 = (float *)image2; + imr2[(y2*w2) + x2] = (float) ims1[(y1*w1) + x1]; + break; + case -64: + imd2 = (double *)image2; + imd2[(y2*w2) + x2] = (double) ims1[(y1*w1) + x1]; + break; + } + break; + + case 32: + imi1 = (int *)image1; + switch (bitpix2) { + case 8: + imc2 = (unsigned char *)image2; + imc2[(y2*w2) + x2] = (unsigned char) imi1[(y1*w1) + x1]; + break; + case 16: + ims2 = (short *)image2; + ims2[(y2*w2) + x2] = (short) imi1[(y1*w1) + x1]; + break; + case 32: + imi2 = (int *)image2; + imi2[(y2*w2) + x2] = imi1[(y1*w1) + x1]; + break; + case -16: + imu2 = (unsigned short *)image2; + imu2[(y2*w2) + x2] = (unsigned short) imi1[(y1*w1) + x1]; + break; + case -32: + imr2 = (float *)image2; + imr2[(y2*w2) + x2] = (float) imi1[(y1*w1) + x1]; + break; + case -64: + imd2 = (double *)image2; + imd2[(y2*w2) + x2] = (double) imi1[(y1*w1) + x1]; + break; + } + break; + + case -16: + imu1 = (unsigned short *)image1; + switch (bitpix2) { + case 8: + imc2 = (unsigned char *)image2; + imc2[(y2*w2) + x2] = (unsigned char) imu1[(y1*w1) + x1]; + break; + case 16: + ims2 = (short *)image2; + ims2[(y2*w2) + x2] = (short) imu1[(y1*w1) + x1]; + break; + case 32: + imi2 = (int *)image2; + imi2[(y2*w2) + x2] = (int) imu1[(y1*w1) + x1]; + break; + case -16: + imu2 = (unsigned short *)image2; + imu2[(y2*w2) + x2] = imu1[(y1*w1) + x1]; + break; + case -32: + imr2 = (float *)image2; + imr2[(y2*w2) + x2] = (float) imu1[(y1*w1) + x1]; + break; + case -64: + imd2 = (double *)image2; + imd2[(y2*w2) + x2] = (double) imu1[(y1*w1) + x1]; + break; + } + break; + + case -32: + imr1 = (float *)image1; + rpix = imr1[(y1*w1) + x1]; + switch (bitpix2) { + case 8: + imc2 = (unsigned char *)image2; + if (rpix < 0.0) + imc2[(y2*w2) + x2] = (unsigned char) 0; + else + imc2[(y2*w2) + x2] = (unsigned char) (rpix + 0.5); + break; + case 16: + ims2 = (short *)image2; + if (rpix < 0.0) + ims2[(y2*w2) + x2] = (short) (rpix - 0.5); + else + ims2[(y2*w2) + x2] = (short) (rpix + 0.5); + break; + case 32: + imi2 = (int *)image2; + if (rpix < 0.0) + imi2[(y2*w2) + x2] = (int) (rpix - 0.5); + else + imi2[(y2*w2) + x2] = (int) (rpix + 0.5); + break; + case -16: + imu2 = (unsigned short *)image2; + if (rpix < 0.0) + imu2[(y2*w2) + x2] = (unsigned short) 0; + else + imu2[(y2*w2) + x2] = (unsigned short) (rpix + 0.5); + break; + case -32: + imr2 = (float *)image2; + imr2[(y2*w2) + x2] = rpix; + break; + case -64: + imd2 = (double *)image2; + imd2[(y2*w2) + x2] = (double) rpix; + break; + } + break; + + case -64: + imd1 = (double *)image1; + dpix = imd1[(y1*w1) + x1]; + switch (bitpix2) { + case 8: + imc2 = (unsigned char *)image2; + if (dpix < 0.0) + imc2[(y2*w2) + x2] = (unsigned char) 0; + else + imc2[(y2*w2) + x2] = (unsigned char) (dpix + 0.5); + break; + case 16: + ims2 = (short *)image2; + if (dpix < 0.0) + ims2[(y2*w2) + x2] = (short) (dpix - 0.5); + else + ims2[(y2*w2) + x2] = (short) (dpix + 0.5); + break; + case 32: + imi2 = (int *)image2; + if (dpix < 0.0) + imi2[(y2*w2) + x2] = (int) (dpix - 0.5); + else + imi2[(y2*w2) + x2] = (int) (dpix + 0.5); + break; + case -16: + imu2 = (unsigned short *)image2; + if (dpix < 0.0) + imu2[(y2*w2) + x2] = (unsigned short) 0; + else + imu2[(y2*w2) + x2] = (unsigned short) (dpix + 0.5); + break; + case -32: + imr2 = (float *)image2; + imr2[(y2*w2) + x2] = (float) dpix; + break; + case -64: + imd2 = (double *)image2; + imd2[(y2*w2) + x2] = dpix; + break; + } + break; + } + return; +} + + +/* MAXVEC -- Get maximum value in vector from 2D image of any numeric type */ + +double +maxvec (image, bitpix, bzero, bscale, pix1, npix) + +char *image; /* Image array from which to read vector */ +int bitpix; /* Number of bits per pixel in image */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +double bzero; /* Zero point for pixel scaling */ +double bscale; /* Scale factor for pixel scaling */ +int pix1; /* Offset of first pixel to check */ +int npix; /* Number of pixels to check */ + +{ + short *im2, imax2, ip2; + int *im4, imax4, ip4; + unsigned short *imu, imaxu, ipu; + float *imr, imaxr, ipr; + double *imd; + double dmax = 0.0; + double ipd; + int ipix, pix2; + unsigned char *imc, imaxc, ipc; + + pix2 = pix1 + npix; + + switch (bitpix) { + + case 8: + imc = (unsigned char *)(image); + imaxc = *(imc + pix1); + for (ipix = pix1; ipix < pix2; ipix++) { + ipc = *(imc + ipix); + if (ipc > imaxc) + imaxc = ipc; + } + dmax = (double) imaxc; + break; + + case 16: + im2 = (short *)image; + imax2 = *(im2 + pix1); + for (ipix = pix1; ipix < pix2; ipix++) { + ip2 = *(im2 + ipix); + if (ip2 > imax2) + imax2 = ip2; + } + dmax = (double) imax2; + break; + + case 32: + im4 = (int *)image; + imax4 = *(im4 + pix1); + for (ipix = pix1; ipix < pix2; ipix++) { + ip4 = *(im4 + ipix); + if (ip4 > imax4) + imax4 = ip4; + } + dmax = (double) imax4; + break; + + case -16: + imu = (unsigned short *)image; + imaxu = *(imu + pix1); + for (ipix = pix1; ipix < pix2; ipix++) { + ipu = *(imu + ipix); + if (ipu > imaxu) + imaxu = ipu; + } + dmax = (double) imaxu; + break; + + case -32: + imr = (float *)image; + imaxr = *(imr + pix1); + for (ipix = pix1; ipix < pix2; ipix++) { + ipr = *(imr + ipix); + if (ipr > imaxr) + imax2 = ipr; + } + dmax = (double) imaxr; + break; + + case -64: + imd = (double *)image; + dmax = *(imd + pix1); + for (ipix = pix1; ipix < pix2; ipix++) { + ipd = *(imd + ipix); + if (ipd > dmax) + dmax = ipd; + } + break; + + } + + /* Scale data if either BZERO or BSCALE keyword has been set */ + if (scale && (bzero != 0.0 || bscale != 1.0)) + dmax = (dmax * bscale) + bzero; + + return (dmax); +} + + +/* MINVEC -- Get minimum value in vector from 2D image of any numeric type */ + +double +minvec (image, bitpix, bzero, bscale, pix1, npix) + +char *image; /* Image array from which to read vector */ +int bitpix; /* Number of bits per pixel in image */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +double bzero; /* Zero point for pixel scaling */ +double bscale; /* Scale factor for pixel scaling */ +int pix1; /* Offset of first pixel to check */ +int npix; /* Number of pixels to check */ + +{ + short *im2, imin2, ip2; + int *im4, imin4, ip4; + unsigned short *imu, iminu, ipu; + float *imr, iminr, ipr; + double *imd, ipd; + double dmin = 0.0; + int ipix, pix2; + unsigned char *imc, cmin, cp; + + pix2 = pix1 + npix; + + switch (bitpix) { + + case 8: + imc = (unsigned char *)image; + cmin = *(imc + pix1); + for (ipix = pix1; ipix < pix2; ipix++) { + cp = *(imc + ipix); + if (cp < cmin) + cmin = cp; + } + dmin = (double) cmin; + break; + + case 16: + im2 = (short *)image + pix1; + imin2 = *im2; + for (ipix = pix1; ipix < pix2; ipix++) { + ip2 = *(im2 + ipix); + if (ip2 < imin2) + imin2 = ip2; + } + dmin = (double) imin2; + break; + + case 32: + im4 = (int *)image; + imin4 = *(im4 + pix1); + for (ipix = pix1; ipix < pix2; ipix++) { + ip4 = *(im4 + ipix); + if (ip4 < imin4) + imin4 = ip4; + } + dmin = (double) imin4; + break; + + case -16: + imu = (unsigned short *)image; + iminu = *(imu + pix1); + for (ipix = pix1; ipix < pix2; ipix++) { + ipu = *(imu + ipix); + if (ipu < iminu) + iminu = ipu; + } + dmin = (double) iminu; + break; + + case -32: + imr = (float *)image; + iminr = *(imr + pix1); + for (ipix = pix1; ipix < pix2; ipix++) { + ipr = *(imr + ipix); + if (ipr < iminr) + iminr = ipr; + } + dmin = (double) iminr; + break; + + case -64: + imd = (double *)image; + dmin = *(imd + pix1); + for (ipix = pix1; ipix < pix2; ipix++) { + ipd = *(imd + ipix); + if (ipd < dmin) + dmin = ipd; + } + break; + + } + + /* Scale data if either BZERO or BSCALE keyword has been set */ + if (scale && (bzero != 0.0 || bscale != 1.0)) + dmin = (dmin * bscale) + bzero; + + return (dmin); +} + + +/* ADDVEC -- Add constant to pixel values in 2D image of any numeric type */ + +void +addvec (image, bitpix, bzero, bscale, pix1, npix, dpix) + +char *image; /* Image array from which to extract vector */ +int bitpix; /* Number of bits per pixel in image */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +double bzero; /* Zero point for pixel scaling */ +double bscale; /* Scale factor for pixel scaling */ +int pix1; /* Offset of first pixel to extract */ +int npix; /* Number of pixels to extract */ +double dpix; /* Value to add to pixels */ + +{ + unsigned char *imc, ccon; + short *im2, jcon; + int *im4, icon; + unsigned short *imu, ucon; + float *imr, rcon; + double *imd; + int ipix, pix2; + + pix2 = pix1 + npix; + + if (scale) + dpix = (dpix - bzero) / bscale; + + switch (bitpix) { + + case 8: + imc = (unsigned char *) (image + pix1); + if (dpix < 0) + ccon = (unsigned char) (dpix - 0.5); + else + ccon = (unsigned char) (dpix + 0.5); + for (ipix = pix1; ipix < pix2; ipix++) + *imc++ += ccon; + break; + + case 16: + im2 = (short *) (image + pix1); + if (dpix < 0) + jcon = (short) (dpix - 0.5); + else + jcon = (short) (dpix + 0.5); + for (ipix = pix1; ipix < pix2; ipix++) + *im2++ += jcon; + break; + + case 32: + im4 = (int *) (image + pix1); + if (dpix < 0) + icon = (int) (dpix - 0.5); + else + icon = (int) (dpix + 0.5); + for (ipix = pix1; ipix < pix2; ipix++) + *im4++ += icon; + break; + + case -16: + imu = (unsigned short *) (image + pix1); + if (dpix > 0) { + ucon = (unsigned short) (dpix + 0.5); + imu = (unsigned short *) (image + pix1); + for (ipix = pix1; ipix < pix2; ipix++) + *imu++ += ucon; + } + else { + icon = (int) (dpix - 0.5); + imu = (unsigned short *) (image + pix1); + for (ipix = pix1; ipix < pix2; ipix++) { + unsigned short tmp = (icon + (int) *imu); + *imu++ += tmp; + } + } + break; + + case -32: + rcon = (float) dpix; + imr = (float *) (image + pix1); + for (ipix = pix1; ipix < pix2; ipix++) + *imr++ += rcon; + break; + + case -64: + imd = (double *) (image + pix1); + for (ipix = pix1; ipix < pix2; ipix++) + *imd++ += dpix; + break; + } + return; +} + + +/* MULTVEC -- Multiply pixel values in place in 2D image of any numeric type */ + +void +multvec (image, bitpix, bzero, bscale, pix1, npix, dpix) + +char *image; /* Image array from which to extract vector */ +int bitpix; /* Number of bits per pixel in image */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +double bzero; /* Zero point for pixel scaling */ +double bscale; /* Scale factor for pixel scaling */ +int pix1; /* Offset of first pixel to extract */ +int npix; /* Number of pixels to extract */ +double dpix; /* Value by which to multiply pixels */ + +{ + char *imc, ccon; + short *im2, jcon; + int *im4, icon, isint; + unsigned short *imu, ucon; + float *imr, rcon; + double *imd, dcon, dval; + int ipix, pix2; + + pix2 = pix1 + npix; + + if (scale) + dpix = (dpix - bzero) / bscale; + ipix = (int) dpix; + dcon = (double) ipix; + if (dcon == dpix) + isint = 1; + else + isint = 0; + + switch (bitpix) { + + case 8: + imc = image + pix1; + if (isint) { + if (dpix < 0) + ccon = (char) (dpix - 0.5); + else + ccon = (char) (dpix + 0.5); + for (ipix = pix1; ipix < pix2; ipix++) + *imc++ *= ccon; + } + else { + for (ipix = pix1; ipix < pix2; ipix++) { + dval = ((double) *imc) * dpix; + if (dval < 256.0) + *imc++ = (char) dval; + else + *imc++ = (char) 255; + } + } + break; + + case 16: + im2 = (short *) (image + pix1); + if (isint) { + im2 = (short *)image; + if (dpix < 0) + jcon = (short) (dpix - 0.5); + else + jcon = (short) (dpix + 0.5); + for (ipix = pix1; ipix < pix2; ipix++) + *im2++ *= jcon; + } + else { + for (ipix = pix1; ipix < pix2; ipix++) { + dval = ((double) *im2) * dpix; + if (dval < 32768.0) + *im2++ = (short) dval; + else + *im2++ = (short) 32767; + } + } + break; + + case 32: + im4 = (int *) (image + pix1); + if (isint) { + if (dpix < 0) + icon = (int) (dpix - 0.5); + else + icon = (int) (dpix + 0.5); + for (ipix = pix1; ipix < pix2; ipix++) + *im4++ *= icon; + } + else { + for (ipix = pix1; ipix < pix2; ipix++) { + dval = ((double) *im4) * dpix; + if (dval < 32768.0) + *im4++ = (int) dval; + else + *im4++ = (int) 32767; + } + } + break; + + case -16: + imu = (unsigned short *) (image + pix1); + if (dpix > 0) { + ucon = (unsigned short) (dpix + 0.5); + imu = (unsigned short *) (image + pix1); + for (ipix = pix1; ipix < pix2; ipix++) + *imu++ *= ucon; + } + break; + + case -32: + rcon = (float) dpix; + imr = (float *) (image + pix1); + for (ipix = pix1; ipix < pix2; ipix++) + *imr++ *= rcon; + break; + + case -64: + imd = (double *) (image + pix1); + for (ipix = pix1; ipix < pix2; ipix++) + *imd++ *= dpix; + break; + + } + return; +} + + +/* GETVEC -- Get vector from 2D image of any numeric type */ + +void +getvec (image, bitpix, bzero, bscale, pix1, npix, dvec0) + +char *image; /* Image array from which to extract vector */ +int bitpix; /* Number of bits per pixel in image */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +double bzero; /* Zero point for pixel scaling */ +double bscale; /* Scale factor for pixel scaling */ +int pix1; /* Offset of first pixel to extract */ +int npix; /* Number of pixels to extract */ +double *dvec0; /* Vector of pixels (returned) */ + +{ + short *im2; + int *im4; + unsigned short *imu; + float *imr; + double *imd; + double *dvec; + int ipix, pix2; + + pix2 = pix1 + npix; + dvec = dvec0; + + switch (bitpix) { + + case 8: + for (ipix = pix1; ipix < pix2; ipix++) + *dvec++ = (double) *(image + ipix); + break; + + case 16: + im2 = (short *)image; + for (ipix = pix1; ipix < pix2; ipix++) + *dvec++ = (double) *(im2 + ipix); + break; + + case 32: + im4 = (int *)image; + for (ipix = pix1; ipix < pix2; ipix++) + *dvec++ = (double) *(im4 + ipix); + break; + + case -16: + imu = (unsigned short *)image; + for (ipix = pix1; ipix < pix2; ipix++) + *dvec++ = (double) *(imu + ipix); + break; + + case -32: + imr = (float *)image; + for (ipix = pix1; ipix < pix2; ipix++) + *dvec++ = (double) *(imr + ipix); + break; + + case -64: + imd = (double *)image; + for (ipix = pix1; ipix < pix2; ipix++) + *dvec++ = (double) *(imd + ipix); + break; + + } + + /* Scale data if either BZERO or BSCALE keyword has been set */ + if (scale && (bzero != 0.0 || bscale != 1.0)) { + dvec = dvec0; + for (ipix = pix1; ipix < pix2; ipix++) { + *dvec = (*dvec * bscale) + bzero; + dvec++; + } + } + + return; +} + + +/* PUTVEC -- Copy pixel vector into 2D image of any numeric type */ + +void +putvec (image, bitpix, bzero, bscale, pix1, npix, dvec) + +char *image; /* Image into which to copy vector */ +int bitpix; /* Number of bits per pixel im image */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +double bzero; /* Zero point for pixel scaling */ +double bscale; /* Scale factor for pixel scaling */ +int pix1; /* Offset of first pixel of vector in image */ +int npix; /* Number of pixels to copy */ +double *dvec; /* Vector of pixels to copy */ + +{ + short *im2; + int *im4; + unsigned short *imu; + float *imr; + double *imd; + int ipix, pix2; + double *dp = dvec; + + pix2 = pix1 + npix; + + /* Scale data if either BZERO or BSCALE keyword has been set */ + if (scale && (bzero != 0.0 || bscale != 1.0)) { + for (ipix = pix1; ipix < pix2; ipix++) { + *dp = (*dp - bzero) / bscale; + dp++; + } + dp = dvec; + } + + switch (bitpix) { + + case 8: + for (ipix = pix1; ipix < pix2; ipix++) + *(image+ipix) = (char) *dp++; + break; + + case 16: + im2 = (short *)image; + for (ipix = pix1; ipix < pix2; ipix++) { + if (*dp < 0.0) + *(im2+ipix) = (short) (*dp++ - 0.5); + else + *(im2+ipix) = (short) (*dp++ + 0.5); + } + break; + + case 32: + im4 = (int *)image; + for (ipix = pix1; ipix < pix2; ipix++) { + if (*dp < 0.0) + *(im4+ipix) = (int) (*dp++ - 0.5); + else + *(im4+ipix) = (int) (*dp++ + 0.5); + } + break; + + case -16: + imu = (unsigned short *)image; + for (ipix = pix1; ipix < pix2; ipix++) { + if (*dp < 0.0) + *(imu+ipix) = (unsigned short) 0; + else + *(imu+ipix) = (unsigned short) (*dp++ + 0.5); + } + break; + + case -32: + imr = (float *)image; + for (ipix = pix1; ipix < pix2; ipix++) + *(imr+ipix) = (float) *dp++; + break; + + case -64: + imd = (double *)image; + for (ipix = pix1; ipix < pix2; ipix++) + *(imd+ipix) = (double) *dp++; + break; + } + return; +} + + +/* FILLVEC1 -- Copy single value into a vector of any numeric type */ + +void +fillvec1 (image, bitpix, bzero, bscale, pix1, npix, dpix) + +char *image; /* Vector to fill */ +int bitpix; /* Number of bits per pixel im image */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +double bzero; /* Zero point for pixel scaling */ +double bscale; /* Scale factor for pixel scaling */ +int pix1; /* First pixel to fill */ +int npix; /* Number of pixels to fill */ +double dpix; /* Value with which to fill pixels */ +{ + fillvec (image, bitpix, bzero, bscale, pix1-1, npix, dpix); + return; +} + + +/* FILLVEC -- Copy single value into a vector of any numeric type */ + +void +fillvec (image, bitpix, bzero, bscale, pix1, npix, dpix) + +char *image; /* Vector to fill */ +int bitpix; /* Number of bits per pixel im image */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +double bzero; /* Zero point for pixel scaling */ +double bscale; /* Scale factor for pixel scaling */ +int pix1; /* First pixel to fill */ +int npix; /* Number of pixels to fill */ +double dpix; /* Value with which to fill pixels */ +{ + char ipc; + short *im2, ip2; + int *im4, ip4; + unsigned short *imu, ipu; + float *imr, ipr; + double *imd; + int ipix, pix2; + double dp; + + pix2 = pix1 + npix; + + /* Scale data if either BZERO or BSCALE keyword has been set */ + dp = dpix; + if (scale && (bzero != 0.0 || bscale != 1.0)) + dp = (dp - bzero) / bscale; + + switch (bitpix) { + + case 8: + if (dp < 0.0) + ipc = (char) (dp - 0.5); + else + ipc = (char) (dp + 0.5); + for (ipix = pix1; ipix < pix2; ipix++) + image[ipix] = ipc; + break; + + case 16: + im2 = (short *)image; + if (dp < 0.0) + ip2 = (short) (dp - 0.5); + else + ip2 = (short) (dp + 0.5); + for (ipix = pix1; ipix < pix2; ipix++) + im2[ipix] = ip2; + break; + + case 32: + im4 = (int *)image; + if (dp < 0.0) + ip4 = (int) (dp - 0.5); + else + ip4 = (int) (dp + 0.5); + for (ipix = pix1; ipix < pix2; ipix++) + im4[ipix] = ip4; + break; + + case -16: + imu = (unsigned short *)image; + if (dp < 0.0) + ipu = (unsigned short) (dp - 0.5); + else + ipu = (unsigned short) (dp + 0.5); + for (ipix = pix1; ipix < pix2; ipix++) + imu[ipix] = ipu; + break; + + case -32: + imr = (float *)image; + ipr = (float) dp; + for (ipix = pix1; ipix < pix2; ipix++) + imr[ipix] = ipr; + break; + + case -64: + imd = (double *)image; + for (ipix = pix1; ipix < pix2; ipix++) + imd[ipix] = dp; + break; + } + return; +} + + +/* IMSWAP -- Reverse bytes of any type of vector in place */ + +void +imswap (bitpix, string, nbytes) + +int bitpix; /* Number of bits per pixel */ + /* 16 = short, -16 = unsigned short, 32 = int */ + /* -32 = float, -64 = double */ +char *string; /* Address of starting point of bytes to swap */ +int nbytes; /* Number of bytes to swap */ + +{ + switch (bitpix) { + + case 8: + break; + + case 16: + if (nbytes < 2) return; + imswap2 (string,nbytes); + break; + + case 32: + if (nbytes < 4) return; + imswap4 (string,nbytes); + break; + + case -16: + if (nbytes < 2) return; + imswap2 (string,nbytes); + break; + + case -32: + if (nbytes < 4) return; + imswap4 (string,nbytes); + break; + + case -64: + if (nbytes < 8) return; + imswap8 (string,nbytes); + break; + + } + return; +} + + +/* IMSWAP2 -- Swap bytes in string in place */ + +void +imswap2 (string,nbytes) + + +char *string; /* Address of starting point of bytes to swap */ +int nbytes; /* Number of bytes to swap */ + +{ + char *sbyte, temp, *slast; + + slast = string + nbytes; + sbyte = string; + while (sbyte < slast) { + temp = sbyte[0]; + sbyte[0] = sbyte[1]; + sbyte[1] = temp; + sbyte= sbyte + 2; + } + return; +} + + +/* IMSWAP4 -- Reverse bytes of Integer*4 or Real*4 vector in place */ + +void +imswap4 (string,nbytes) + +char *string; /* Address of Integer*4 or Real*4 vector */ +int nbytes; /* Number of bytes to reverse */ + +{ + char *sbyte, *slast; + char temp0, temp1, temp2, temp3; + + slast = string + nbytes; + sbyte = string; + while (sbyte < slast) { + temp3 = sbyte[0]; + temp2 = sbyte[1]; + temp1 = sbyte[2]; + temp0 = sbyte[3]; + sbyte[0] = temp0; + sbyte[1] = temp1; + sbyte[2] = temp2; + sbyte[3] = temp3; + sbyte = sbyte + 4; + } + + return; +} + + +/* IMSWAP8 -- Reverse bytes of Real*8 vector in place */ + +void +imswap8 (string,nbytes) + +char *string; /* Address of Real*8 vector */ +int nbytes; /* Number of bytes to reverse */ + +{ + char *sbyte, *slast; + char temp[8]; + + slast = string + nbytes; + sbyte = string; + while (sbyte < slast) { + temp[7] = sbyte[0]; + temp[6] = sbyte[1]; + temp[5] = sbyte[2]; + temp[4] = sbyte[3]; + temp[3] = sbyte[4]; + temp[2] = sbyte[5]; + temp[1] = sbyte[6]; + temp[0] = sbyte[7]; + sbyte[0] = temp[0]; + sbyte[1] = temp[1]; + sbyte[2] = temp[2]; + sbyte[3] = temp[3]; + sbyte[4] = temp[4]; + sbyte[5] = temp[5]; + sbyte[6] = temp[6]; + sbyte[7] = temp[7]; + sbyte = sbyte + 8; + } + return; +} + +/* IMSWAPPED -- Returns 0 if big-endian (Sun,Mac), + 1 if little-endian(PC,Alpha) */ + +int +imswapped () + +{ + char *ctest; + int itest; + + itest = 1; + ctest = (char *)&itest; + if (*ctest) + return (1); + else + return (0); +} + +/* Apr 17 1996 New file + * May 22 1996 Add H so that PUTPIX and GETPIX can check coordinates + * Jun 11 1996 Simplify NEWIMAGE subroutine + * Jun 12 1996 Add byte-swapping subroutines + * + * Jul 24 1997 Add 8-bit option to subroutines + * + * May 27 1998 Include imio.h instead of fitshead.h + * Jun 17 1998 Fix bug, changing all unsigned int's to unsigned short's + * + * Apr 29 1999 Add scaling to getpix, putpix, getvec, and putvec + * Apr 29 1999 Fix bug in getvec in dealing with 1-byte data + * Sep 14 1999 Change dp incrementing so it works on Alpha compiler + * Sep 27 1999 Add interface for 1-based (FITS) image access + * Sep 27 1999 Add addpix() and addpix1() + * Dec 14 1999 In putpix(), addpix(), putvec(), round when output is integer + * + * Sep 20 2000 In getvec(), scale only if necessary + * + * Nov 27 2001 In movepix(), add char to char move + * + * Jan 23 2002 Add global scale switch to turn off scaling + * Jun 4 2002 In getvec() and putvec(), change dpix to dvec + * Jun 4 2002 Add addvec() to add to a vector + * Jul 19 2002 Fix getvec() bug rescaling scaled numbers + * + * May 20 2003 Declare scale0 in setscale() + * + * Jan 28 2004 Add image limit check to movepix() + * Feb 27 2004 Add fillvec() and fillvec1() to set vector to a constant + * + * Jun 27 2005 Fix major bug in fillvec(); pass value dpix in fillvec1(), too + * Aug 18 2005 Add maxvec(), addvec(), and multvec() + * + * Mar 1 2006 Fix bug of occasional double application of bscale in getvec() + * Apr 3 2006 Fix bad cast in unisigned int section of addvec() + * May 3 2006 Code fixes in addpix and multpix suggested by Robert Lupton + * Jun 8 2006 Drop erroneous second im2 assignment without offset in addvec() + * Jun 20 2006 Fix typos masquerading as unitialized variables + * + * Jan 8 2007 Include fitsfile.h instead of imio.h + * Jun 11 2007 Add minvec() and speed up maxvec() + * + * Apr 12 2012 Fix 8-bit variables to be unsigned char + * Oct 19 2012 Fix errors with character images in minvec() and maxvec() + * Oct 31 2012 Fix errors with short images in minvec() and maxvec() + * Oct 31 2012 Drop unused variable il2 from minvec() + */ diff --git a/tksao/wcssubs/imio.h b/tksao/wcssubs/imio.h new file mode 100644 index 0000000..a12d8e8 --- /dev/null +++ b/tksao/wcssubs/imio.h @@ -0,0 +1,64 @@ +/*** imio.h memory access subroutines + *** September 27, 1999 + *** By Jessica Mink, jmink@cfa.harvard.edu + *** Harvard-Smithsonian Center for Astrophysics + *** Copyright (C) 1996-2002 + *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Correspondence concerning WCSTools should be addressed as follows: + Internet email: jmink@cfa.harvard.edu + Postal address: Jessica Mink + Smithsonian Astrophysical Observatory + 60 Garden St. + Cambridge, MA 02138 USA + */ + +#ifndef imio_h_ +#define imio_h_ + +/* Image pixel access subroutines in imio.c */ +extern double getpix(); /* Read one pixel from any data type 2-D array (0,0)*/ +extern double getpix1(); /* Read one pixel from any data type 2-D array (1,1)*/ +extern void putpix(); /* Write one pixel to any data type 2-D array (0,0)*/ +extern void putpix1(); /* Write one pixel to any data type 2-D array (1,1) */ +extern void addpix(); /* Add to one pixel in any data type 2-D array (0,0)*/ +extern void addpix1(); /* Add to one pixel in any data type 2-D array (1,1)*/ +extern void movepix(); /* Move one pixel value between two 2-D arrays (0,0) */ +extern void movepix1(); /* Move one pixel value between two 2-D arrays (1,1) */ +extern void getvec(); /* Read vector from a 2-D array */ +extern void putvec(); /* Write vector into a 2-D array */ +extern void fillvec(); /* Write constant into a vector */ +extern void fillvec1(); /* Write constant into a vector */ +extern void imswap(); /* Swap alternating bytes in a vector */ +extern void imswap2(); /* Swap bytes in a vector of 2-byte (short) integers */ +extern void imswap4(); /* Reverse bytes in a vector of 4-byte numbers */ +extern void imswap8(); /* Reverse bytes in a vector of 8-byte numbers */ +extern int imswapped(); /* Return 1 if machine byte order is not FITS order */ + +#endif /* imio_h_ */ + +/* May 31 1996 Use stream I/O for reading as well as writing + * Jun 12 1996 Add byte-swapping subroutines + * Aug 6 1996 Add MOVEPIX, HDEL and HCHANGE declarations + * + * May 27 1998 Split off imio subroutines to imio.h + + * Sep 27 1999 Add Fortran-indexed (1,1), not (0,0) image access *1() + * Sep 28 1999 Add addpix() + * + * Feb 27 2004 Add fillvec() + */ diff --git a/tksao/wcssubs/lin.c b/tksao/wcssubs/lin.c new file mode 100644 index 0000000..c46bf19 --- /dev/null +++ b/tksao/wcssubs/lin.c @@ -0,0 +1,448 @@ +/*============================================================================= +* +* WCSLIB - an implementation of the FITS WCS proposal. +* Copyright (C) 1995-2002, Mark Calabretta +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* Correspondence concerning WCSLIB may be directed to: +* Internet email: mcalabre@atnf.csiro.au +* Postal address: Dr. Mark Calabretta, +* Australia Telescope National Facility, +* P.O. Box 76, +* Epping, NSW, 2121, +* AUSTRALIA +* +*============================================================================= +* +* C routines which implement the FITS World Coordinate System (WCS) +* convention. +* +* Summary of routines +* ------------------- +* These utility routines apply the linear transformation defined by the WCS +* FITS header cards. There are separate routines for the image-to-pixel, +* linfwd(), and pixel-to-image, linrev(), transformations. +* +* An initialization routine, linset(), computes intermediate values from +* the transformation parameters but need not be called explicitly - see the +* explanation of lin.flag below. +* +* An auxiliary matrix inversion routine, matinv(), is included. It uses +* LU-triangular factorization with scaled partial pivoting. +* +* +* Initialization routine; linset() +* -------------------------------- +* Initializes members of a linprm data structure which hold intermediate +* values. Note that this routine need not be called directly; it will be +* invoked by linfwd() and linrev() if the "flag" structure member is +* anything other than a predefined magic value. +* +* Given and/or returned: +* lin linprm* Linear transformation parameters (see below). +* +* Function return value: +* int Error status +* 0: Success. +* 1: Memory allocation error. +* 2: PC matrix is singular. +* +* Forward transformation; linfwd() +* -------------------------------- +* Compute pixel coordinates from image coordinates. Note that where +* celestial coordinate systems are concerned the image coordinates +* correspond to (x,y) in the plane of projection, not celestial (lng,lat). +* +* Given: +* imgcrd const double[] +* Image (world) coordinate. +* +* Given and returned: +* lin linprm* Linear transformation parameters (see below). +* +* Returned: +* pixcrd d[] Pixel coordinate. +* +* Function return value: +* int Error status +* 0: Success. +* 1: The transformation is not invertible. +* +* Reverse transformation; linrev() +* -------------------------------- +* Compute image coordinates from pixel coordinates. Note that where +* celestial coordinate systems are concerned the image coordinates +* correspond to (x,y) in the plane of projection, not celestial (lng,lat). +* +* Given: +* pixcrd const double[] +* Pixel coordinate. +* +* Given and/or returned: +* lin linprm* Linear transformation parameters (see below). +* +* Returned: +* imgcrd d[] Image (world) coordinate. +* +* Function return value: +* int Error status +* 0: Success. +* 1: Error. +* +* Linear transformation parameters +* -------------------------------- +* The linprm struct consists of the following: +* +* int flag +* This flag must be set to zero whenever any of the following members +* are set or modified. This signals the initialization routine, +* linset(), to recompute intermediaries. +* int naxis +* Number of image axes. +* double *crpix +* Pointer to the first element of an array of double containing the +* coordinate reference pixel, CRPIXn. +* double *pc +* Pointer to the first element of the PC (pixel coordinate) +* transformation matrix. The expected order is +* +* lin.pc = {PC1_1, PC1_2, PC2_1, PC2_2}; +* +* This may be conveniently constructed from a two-dimensional array +* via +* +* double m[2][2] = {{PC1_1, PC1_2}, +* {PC2_1, PC2_2}}; +* +* which is equivalent to, +* +* double m[2][2]; +* m[0][0] = PC1_1; +* m[0][1] = PC1_2; +* m[1][0] = PC2_1; +* m[1][1] = PC2_2; +* +* for which the storage order is +* +* PC1_1, PC1_2, PC2_1, PC2_2 +* +* so it would be legitimate to set lin.pc = *m. +* double *cdelt +* Pointer to the first element of an array of double containing the +* coordinate increments, CDELTn. +* +* The remaining members of the linprm struct are maintained by the +* initialization routine and should not be modified. +* +* double *piximg +* Pointer to the first element of the matrix containing the product +* of the CDELTn diagonal matrix and the PC matrix. +* double *imgpix +* Pointer to the first element of the inverse of the piximg matrix. +* +* linset allocates storage for the above arrays using malloc(). Note, +* however, that these routines do not free this storage so if a linprm +* variable has itself been malloc'd then these structure members must be +* explicitly freed before the linprm variable is free'd otherwise a memory +* leak will result. +* +* Author: Mark Calabretta, Australia Telescope National Facility +* $Id: lin.c,v 1.1.1.1 2016/03/30 20:00:02 joye Exp $ +*===========================================================================*/ + +#include +#include +#include "wcslib.h" + +/* Map error number to error message for each function. */ +const char *linset_errmsg[] = { + 0, + "Memory allocation error", + "PC matrix is singular"}; + +const char *linfwd_errmsg[] = { + 0, + "Memory allocation error", + "PC matrix is singular"}; + +const char *linrev_errmsg[] = { + 0, + "Memory allocation error", + "PC matrix is singular"}; + +int linset(lin) + +struct linprm *lin; + +{ + int i, ij, j, mem, n; + + n = lin->naxis; + + /* Allocate memory for internal arrays. */ + mem = n * n * sizeof(double); + lin->piximg = (double*)malloc(mem); + if (lin->piximg == (double*)0) return 1; + + lin->imgpix = (double*)malloc(mem); + if (lin->imgpix == (double*)0) { + free(lin->piximg); + return 1; + } + + /* Compute the pixel-to-image transformation matrix. */ + for (i = 0, ij = 0; i < n; i++) { + for (j = 0; j < n; j++, ij++) { + lin->piximg[ij] = lin->cdelt[i] * lin->pc[ij]; + } + } + + /* Compute the image-to-pixel transformation matrix. */ + if (matinv(n, lin->piximg, lin->imgpix)) return 2; + + lin->flag = LINSET; + + return 0; +} + +/*--------------------------------------------------------------------------*/ + +int linfwd(imgcrd, lin, pixcrd) + +const double imgcrd[]; +struct linprm *lin; +double pixcrd[]; + +{ + int i, ij, j, n; + + n = lin->naxis; + + if (lin->flag != LINSET) { + if (linset(lin)) return 1; + } + + for (i = 0, ij = 0; i < n; i++) { + pixcrd[i] = 0.0; + for (j = 0; j < n; j++, ij++) { + pixcrd[i] += lin->imgpix[ij] * imgcrd[j]; + } + } + + for (j = 0; j < n; j++) { + pixcrd[j] += lin->crpix[j]; + } + + return 0; +} + +/*--------------------------------------------------------------------------*/ + +int linrev(pixcrd, lin, imgcrd) + +const double pixcrd[]; +struct linprm *lin; +double imgcrd[]; + +{ + int i, ij, j, n; + double temp; + + n = lin->naxis; + + if (lin->flag != LINSET) { + if (linset(lin)) return 1; + } + + for (i = 0; i < n; i++) { + imgcrd[i] = 0.0; + } + + for (j = 0; j < n; j++) { + temp = pixcrd[j] - lin->crpix[j]; + for (i = 0, ij = j; i < n; i++, ij+=n) { + imgcrd[i] += lin->piximg[ij] * temp; + } + } + + return 0; +} + +/*--------------------------------------------------------------------------*/ + +int matinv(n, mat, inv) + +const int n; +const double mat[]; +double inv[]; + +{ + register int i, ij, ik, j, k, kj, pj; + int itemp, mem, *mxl, *lxm, pivot; + double colmax, *lu, *rowmax, dtemp; + + + /* Allocate memory for internal arrays. */ + mem = n * sizeof(int); + if ((mxl = (int*)malloc(mem)) == (int*)0) return 1; + if ((lxm = (int*)malloc(mem)) == (int*)0) { + free(mxl); + return 1; + } + + mem = n * sizeof(double); + if ((rowmax = (double*)malloc(mem)) == (double*)0) { + free(mxl); + free(lxm); + return 1; + } + + mem *= n; + if ((lu = (double*)malloc(mem)) == (double*)0) { + free(mxl); + free(lxm); + free(rowmax); + return 1; + } + + + /* Initialize arrays. */ + for (i = 0, ij = 0; i < n; i++) { + /* Vector which records row interchanges. */ + mxl[i] = i; + + rowmax[i] = 0.0; + + for (j = 0; j < n; j++, ij++) { + dtemp = fabs(mat[ij]); + if (dtemp > rowmax[i]) rowmax[i] = dtemp; + + lu[ij] = mat[ij]; + } + + /* A row of zeroes indicates a singular matrix. */ + if (rowmax[i] == 0.0) { + free(mxl); + free(lxm); + free(rowmax); + free(lu); + return 2; + } + } + + + /* Form the LU triangular factorization using scaled partial pivoting. */ + for (k = 0; k < n; k++) { + /* Decide whether to pivot. */ + colmax = fabs(lu[k*n+k]) / rowmax[k]; + pivot = k; + + for (i = k+1; i < n; i++) { + ik = i*n + k; + dtemp = fabs(lu[ik]) / rowmax[i]; + if (dtemp > colmax) { + colmax = dtemp; + pivot = i; + } + } + + if (pivot > k) { + /* We must pivot, interchange the rows of the design matrix. */ + for (j = 0, pj = pivot*n, kj = k*n; j < n; j++, pj++, kj++) { + dtemp = lu[pj]; + lu[pj] = lu[kj]; + lu[kj] = dtemp; + } + + /* Amend the vector of row maxima. */ + dtemp = rowmax[pivot]; + rowmax[pivot] = rowmax[k]; + rowmax[k] = dtemp; + + /* Record the interchange for later use. */ + itemp = mxl[pivot]; + mxl[pivot] = mxl[k]; + mxl[k] = itemp; + } + + /* Gaussian elimination. */ + for (i = k+1; i < n; i++) { + ik = i*n + k; + + /* Nothing to do if lu[ik] is zero. */ + if (lu[ik] != 0.0) { + /* Save the scaling factor. */ + lu[ik] /= lu[k*n+k]; + + /* Subtract rows. */ + for (j = k+1; j < n; j++) { + lu[i*n+j] -= lu[ik]*lu[k*n+j]; + } + } + } + } + + + /* mxl[i] records which row of mat corresponds to row i of lu. */ + /* lxm[i] records which row of lu corresponds to row i of mat. */ + for (i = 0; i < n; i++) { + lxm[mxl[i]] = i; + } + + + /* Determine the inverse matrix. */ + for (i = 0, ij = 0; i < n; i++) { + for (j = 0; j < n; j++, ij++) { + inv[ij] = 0.0; + } + } + + for (k = 0; k < n; k++) { + inv[lxm[k]*n+k] = 1.0; + + /* Forward substitution. */ + for (i = lxm[k]+1; i < n; i++) { + for (j = lxm[k]; j < i; j++) { + inv[i*n+k] -= lu[i*n+j]*inv[j*n+k]; + } + } + + /* Backward substitution. */ + for (i = n-1; i >= 0; i--) { + for (j = i+1; j < n; j++) { + inv[i*n+k] -= lu[i*n+j]*inv[j*n+k]; + } + inv[i*n+k] /= lu[i*n+i]; + } + } + + free(mxl); + free(lxm); + free(rowmax); + free(lu); + + return 0; +} +/* Dec 20 1999 Doug Mink - Include wcslib.h, which includes lin.h + * + * Feb 15 2001 Doug Mink - Add comments for WCSLIB 2.6; no code changes + * Sep 19 2001 Doug Mink - Add above change to WCSLIB 2.7 code + * Nov 20 2001 Doug Mink - Always include stdlib.h + * + * Jan 15 2002 Bill Joye - Add ifdef so this compiles on MacOS/X + * + * Nov 18 2003 Doug Mink - Include stdlib.h instead of malloc.h + */ diff --git a/tksao/wcssubs/platepos.c b/tksao/wcssubs/platepos.c new file mode 100644 index 0000000..8479350 --- /dev/null +++ b/tksao/wcssubs/platepos.c @@ -0,0 +1,391 @@ +/*** File saoimage/wcslib/platepos.c + *** February 29, 2000 + *** By Jessica Mink, jmink@cfa.harvard.edu + *** Harvard-Smithsonian Center for Astrophysics + *** Copyright (C) 1998-2002 + *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Correspondence concerning WCSTools should be addressed as follows: + Internet email: jmink@cfa.harvard.edu + Postal address: Jessica Mink + Smithsonian Astrophysical Observatory + 60 Garden St. + Cambridge, MA 02138 USA + + * Module: platepos.c (Plate solution WCS conversion + * Purpose: Compute WCS from plate fit + * Subroutine: platepos() converts from pixel location to RA,Dec + * Subroutine: platepix() converts from RA,Dec to pixel location + + These functions are based on the astrmcal.c portion of GETIMAGE by + J. Doggett and the documentation distributed with the Digital Sky Survey. + +*/ + +#include +#include +#include +#include "wcs.h" + +int +platepos (xpix, ypix, wcs, xpos, ypos) + +/* Routine to determine accurate position for pixel coordinates */ +/* returns 0 if successful otherwise 1 = angle too large for projection; */ +/* based on amdpos() from getimage */ + +/* Input: */ +double xpix; /* x pixel number (RA or long without rotation) */ +double ypix; /* y pixel number (dec or lat without rotation) */ +struct WorldCoor *wcs; /* WCS parameter structure */ + +/* Output: */ +double *xpos; /* Right ascension or longitude in degrees */ +double *ypos; /* Declination or latitude in degrees */ + +{ + double x, y, x2, y2, x3, y3, r2; + double xi, xir, eta, etar, raoff, ra, dec, ra0, dec0; + double twopi = 6.28318530717959; + double ctan, ccos; + int ncoeff1 = wcs->ncoeff1; + int ncoeff2 = wcs->ncoeff2; + + /* Ignore magnitude and color terms + double mag = 0.0; + double color = 0.0; */ + + /* Convert from pixels to millimeters */ + x = xpix - wcs->crpix[0]; + y = ypix - wcs->crpix[1]; + x2 = x * x; + y2 = y * y; + x3 = x * x2; + y3 = y * y2; + r2 = x2 + y2; + + /* Compute xi,eta coordinates in degrees from x,y and plate model */ + xi = wcs->x_coeff[ 0] + wcs->x_coeff[ 1]*x + + wcs->x_coeff[ 2]*y + wcs->x_coeff[ 3]*x2 + + wcs->x_coeff[ 4]*y2 + wcs->x_coeff[ 5]*x*y; + + if (ncoeff1 > 6) + xi = xi + wcs->x_coeff[ 6]*x3 + wcs->x_coeff[ 7]*y3; + + if (ncoeff1 > 8) { + xi = xi + wcs->x_coeff[ 8]*x2*y + wcs->x_coeff[ 9]*x*y2 + + wcs->x_coeff[10]*(r2) + wcs->x_coeff[11]*x*r2 + + wcs->x_coeff[12]*y*r2; + } + + eta = wcs->y_coeff[ 0] + wcs->y_coeff[ 1]*x + + wcs->y_coeff[ 2]*y + wcs->y_coeff[ 3]*x2 + + wcs->y_coeff[ 4]*y2 + wcs->y_coeff[ 5]*x*y; + + if (ncoeff2 > 6) + eta = eta + wcs->y_coeff[ 6]*x3 + wcs->y_coeff[ 7]*y3; + + if (ncoeff2 > 8) { + eta = eta + wcs->y_coeff[ 8]*x2*y + wcs->y_coeff[ 9]*y2*x + + wcs->y_coeff[10]*r2 + wcs->y_coeff[11]*x*r2 + + wcs->y_coeff[12]*y*r2; + } + + /* Convert to radians */ + xir = degrad (xi); + etar = degrad (eta); + + /* Convert to RA and Dec */ + ra0 = degrad (wcs->crval[0]); + dec0 = degrad (wcs->crval[1]); + ctan = tan (dec0); + ccos = cos (dec0); + raoff = atan2 (xir / ccos, 1.0 - etar * ctan); + ra = raoff + ra0; + if (ra < 0.0) ra = ra + twopi; + *xpos = raddeg (ra); + + dec = atan (cos (raoff) / ((1.0 - (etar * ctan)) / (etar + ctan))); + *ypos = raddeg (dec); + return 0; +} + + +int +platepix (xpos, ypos, wcs, xpix, ypix) + +/* Routine to determine pixel coordinates for sky position */ +/* returns 0 if successful otherwise 1 = angle too large for projection; */ +/* based on amdinv() from getimage */ + +/* Input: */ +double xpos; /* Right ascension or longitude in degrees */ +double ypos; /* Declination or latitude in degrees */ +struct WorldCoor *wcs; /* WCS parameter structure */ + +/* Output: */ +double *xpix; /* x pixel number (RA or long without rotation) */ +double *ypix; /* y pixel number (dec or lat without rotation) */ + +{ + double xi,eta,x,y,xy,x2,y2,x2y,y2x,x3,y3,r2,dx,dy; + double tdec,ctan,ccos,traoff, craoff, etar, xir; + double f,fx,fy,g,gx,gy; + double ra0, dec0, ra, dec; + double tolerance = 0.0000005; + int max_iterations = 50; + int i; + int ncoeff1 = wcs->ncoeff1; + int ncoeff2 = wcs->ncoeff2; + + /* Convert RA and Dec in radians to standard coordinates on a plate */ + ra = degrad (xpos); + dec = degrad (ypos); + tdec = tan (dec); + ra0 = degrad (wcs->crval[0]); + dec0 = degrad (wcs->crval[1]); + ctan = tan (dec0); + ccos = cos (dec0); + traoff = tan (ra - ra0); + craoff = cos (ra - ra0); + etar = (1.0 - ctan * craoff / tdec) / (ctan + (craoff / tdec)); + xir = traoff * ccos * (1.0 - (etar * ctan)); + xi = raddeg (xir); + eta = raddeg (etar); + + /* Set initial value for x,y */ + x = xi * wcs->dc[0] + eta * wcs->dc[1]; + y = xi * wcs->dc[2] + eta * wcs->dc[3]; + + /* if (wcs->x_coeff[1] == 0.0) + x = xi - wcs->x_coeff[0]; + else + x = (xi - wcs->x_coeff[0]) / wcs->x_coeff[1]; + if (wcs->y_coeff[2] == 0.0) + y = eta - wcs->y_coeff[0]; + else + y = (eta - wcs->y_coeff[0]) / wcs->y_coeff[2]; */ + + /* Iterate by Newton's method */ + for (i = 0; i < max_iterations; i++) { + + /* X plate model */ + xy = x * y; + x2 = x * x; + y2 = y * y; + x3 = x2 * x; + y3 = y2 * y; + x2y = x2 * y; + y2x = y2 * x; + r2 = x2 + y2; + + f = wcs->x_coeff[0] + wcs->x_coeff[1]*x + + wcs->x_coeff[2]*y + wcs->x_coeff[3]*x2 + + wcs->x_coeff[4]*y2 + wcs->x_coeff[5]*xy; + + /* Derivative of X model wrt x */ + fx = wcs->x_coeff[1] + wcs->x_coeff[3]*2.0*x + + wcs->x_coeff[5]*y; + + /* Derivative of X model wrt y */ + fy = wcs->x_coeff[2] + wcs->x_coeff[4]*2.0*y + + wcs->x_coeff[5]*x; + + if (ncoeff1 > 6) { + f = f + wcs->x_coeff[6]*x3 + wcs->x_coeff[7]*y3; + fx = fx + wcs->x_coeff[6]*3.0*x2; + fy = fy + wcs->x_coeff[7]*3.0*y2; + } + + if (ncoeff1 > 8) { + f = f + + wcs->x_coeff[8]*x2y + wcs->x_coeff[9]*y2x + + wcs->x_coeff[10]*r2 + wcs->x_coeff[11]*x*r2 + + wcs->x_coeff[12]*y*r2; + + fx = fx + wcs->x_coeff[8]*2.0*xy + + wcs->x_coeff[9]*y2 + + wcs->x_coeff[10]*2.0*x + + wcs->x_coeff[11]*(3.0*x2+y2) + + wcs->x_coeff[12]*2.0*xy; + + fy = fy + wcs->x_coeff[8]*x2 + + wcs->x_coeff[9]*2.0*xy + + wcs->x_coeff[10]*2.0*y + + wcs->x_coeff[11]*2.0*xy + + wcs->x_coeff[12]*(3.0*y2+x2); + } + + /* Y plate model */ + g = wcs->y_coeff[0] + wcs->y_coeff[1]*x + + wcs->y_coeff[2]*y + wcs->y_coeff[3]*x2 + + wcs->y_coeff[4]*y2 + wcs->y_coeff[5]*xy; + + /* Derivative of Y model wrt x */ + gx = wcs->y_coeff[1] + wcs->y_coeff[3]*2.0*x + + wcs->y_coeff[5]*y; + + /* Derivative of Y model wrt y */ + gy = wcs->y_coeff[2] + wcs->y_coeff[4]*2.0*y + + wcs->y_coeff[5]*x; + + if (ncoeff2 > 6) { + g = g + wcs->y_coeff[6]*x3 + wcs->y_coeff[7]*y3; + gx = gx + wcs->y_coeff[6]*3.0*x2; + gy = gy + wcs->y_coeff[7]*3.0*y2; + } + + if (ncoeff2 > 8) { + g = g + + wcs->y_coeff[8]*x2y + wcs->y_coeff[9]*y2x + + wcs->y_coeff[10]*r2 + wcs->y_coeff[11]*x*r2 + + wcs->y_coeff[12]*y*r2; + + gx = gx + wcs->y_coeff[8]*2.0*xy + + wcs->y_coeff[9]*y2 + + wcs->y_coeff[10]*2.0*x + + wcs->y_coeff[11]*(3.0*x2+y2) + + wcs->y_coeff[12]*2.0*xy; + + gy = gy + wcs->y_coeff[8]*x2 + + wcs->y_coeff[9]*2.0*xy + + wcs->y_coeff[10]*2.0*y + + wcs->y_coeff[11]*2.0*xy + + wcs->y_coeff[12]*(3.0*y2+x2); + } + + f = f - xi; + g = g - eta; + dx = ((-f * gy) + (g * fy)) / ((fx * gy) - (fy * gx)); + dy = ((-g * fx) + (f * gx)) / ((fx * gy) - (fy * gx)); + x = x + dx; + y = y + dy; + if ((fabs(dx) < tolerance) && (fabs(dy) < tolerance)) break; + } + + /* Convert from plate pixels to image pixels */ + *xpix = x + wcs->crpix[0]; + *ypix = y + wcs->crpix[1]; + + /* If position is off of the image, return offscale code */ + if (*xpix < 0.5 || *xpix > wcs->nxpix+0.5) + return -1; + if (*ypix < 0.5 || *ypix > wcs->nypix+0.5) + return -1; + + return 0; +} + + +/* Set plate fit coefficients in structure from arguments */ +int +SetPlate (wcs, ncoeff1, ncoeff2, coeff) + +struct WorldCoor *wcs; /* World coordinate system structure */ +int ncoeff1; /* Number of coefficients for x */ +int ncoeff2; /* Number of coefficients for y */ +double *coeff; /* Plate fit coefficients */ + +{ + int i; + + if (nowcs (wcs) || (ncoeff1 < 1 && ncoeff2 < 1)) + return 1; + + wcs->ncoeff1 = ncoeff1; + wcs->ncoeff2 = ncoeff2; + wcs->prjcode = WCS_PLT; + + for (i = 0; i < 20; i++) { + if (i < ncoeff1) + wcs->x_coeff[i] = coeff[i]; + else + wcs->x_coeff[i] = 0.0; + } + + for (i = 0; i < 20; i++) { + if (i < ncoeff2) + wcs->y_coeff[i] = coeff[ncoeff1+i]; + else + wcs->y_coeff[i] = 0.0; + } + return 0; +} + + +/* Return plate fit coefficients from structure in arguments */ +int +GetPlate (wcs, ncoeff1, ncoeff2, coeff) + +struct WorldCoor *wcs; /* World coordinate system structure */ +int *ncoeff1; /* Number of coefficients for x */ +int *ncoeff2; /* Number of coefficients for y) */ +double *coeff; /* Plate fit coefficients */ + +{ + int i; + + if (nowcs (wcs)) + return 1; + + *ncoeff1 = wcs->ncoeff1; + *ncoeff2 = wcs->ncoeff2; + + for (i = 0; i < *ncoeff1; i++) + coeff[i] = wcs->x_coeff[i]; + + for (i = 0; i < *ncoeff2; i++) + coeff[*ncoeff1+i] = wcs->y_coeff[i]; + + return 0; +} + + +/* Set FITS header plate fit coefficients from structure */ +void +SetFITSPlate (header, wcs) + +char *header; /* Image FITS header */ +struct WorldCoor *wcs; /* WCS structure */ + +{ + char keyword[16]; + int i; + + for (i = 0; i < wcs->ncoeff1; i++) { + sprintf (keyword,"CO1_%d",i+1); + hputnr8 (header, keyword, -15, wcs->x_coeff[i]); + } + for (i = 0; i < wcs->ncoeff2; i++) { + sprintf (keyword,"CO2_%d",i+1); + hputnr8 (header, keyword, -15, wcs->y_coeff[i]); + } + return; +} + +/* Mar 27 1998 New subroutines for direct image pixel <-> sky polynomials + * Apr 10 1998 Make terms identical for both x and y polynomials + * Apr 10 1998 Allow different numbers of coefficients for x and y + * Apr 16 1998 Drom NCOEFF header parameter + * Apr 28 1998 Change projection flags to WCS_* + * Sep 10 1998 Check for xc1 and yc2 divide by zero after Allen Harris, SAO + * + * Oct 21 1999 Drop unused variables after lint + * + * Feb 29 2000 Use inverse CD matrix to get initial X,Y in platepix() + * as suggested by Paolo Montegriffo from Bologna Ast. Obs. + */ diff --git a/tksao/wcssubs/poly.c b/tksao/wcssubs/poly.c new file mode 100644 index 0000000..f0f46cb --- /dev/null +++ b/tksao/wcssubs/poly.c @@ -0,0 +1,914 @@ + /* + poly.c + +*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +* +* Part of: A program using Polynomials +* +* Author: E.BERTIN (IAP) +* +* Contents: Polynomial fitting +* +* Last modify: 08/03/2005 +* +*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include "wcslib.h" + + +#define QCALLOC(ptr, typ, nel) \ + {if (!(ptr = (typ *)calloc((size_t)(nel),sizeof(typ)))) \ + qerror("Not enough memory for ", \ + #ptr " (" #nel " elements) !");;} + +#define QMALLOC(ptr, typ, nel) \ + {if (!(ptr = (typ *)malloc((size_t)(nel)*sizeof(typ)))) \ + qerror("Not enough memory for ", \ + #ptr " (" #nel " elements) !");;} + +/********************************* qerror ************************************/ +/* +I hope it will never be used! +*/ +void qerror(char *msg1, char *msg2) + { + fprintf(stderr, "\n> %s%s\n\n",msg1,msg2); + exit(-1); + } + + +/****** poly_init ************************************************************ +PROTO polystruct *poly_init(int *group, int ndim, int *degree, int ngroup) +PURPOSE Allocate and initialize a polynom structure. +INPUT 1D array containing the group for each parameter, + number of dimensions (parameters), + 1D array with the polynomial degree for each group, + number of groups. +OUTPUT polystruct pointer. +NOTES -. +AUTHOR E. Bertin (IAP) +VERSION 08/03/2003 + ***/ +polystruct *poly_init(int *group, int ndim, int *degree, int ngroup) + { + void qerror(char *msg1, char *msg2); + polystruct *poly; + char str[512]; + int nd[POLY_MAXDIM]; + int *groupt, + d,g,n,num,den; + + QCALLOC(poly, polystruct, 1); + if ((poly->ndim=ndim) > POLY_MAXDIM) + { + sprintf(str, "The dimensionality of the polynom (%d) exceeds the maximum\n" + "allowed one (%d)", ndim, POLY_MAXDIM); + qerror("*Error*: ", str); + } + + if (ndim) + QMALLOC(poly->group, int, poly->ndim); + for (groupt=poly->group, d=ndim; d--;) + *(groupt++) = *(group++)-1; + + poly->ngroup = ngroup; + if (ngroup) + { + group = poly->group; /* Forget the original *group */ + + QMALLOC(poly->degree, int, poly->ngroup); + +/*-- Compute the number of context parameters for each group */ + memset(nd, 0, ngroup*sizeof(int)); + for (d=0; d=ngroup) + qerror("*Error*: polynomial GROUP out of range", ""); + nd[g]++; + } + } + +/* Compute the total number of coefficients */ + poly->ncoeff = 1; + for (g=0; gdegree[g]=*(degree++))>POLY_MAXDEGREE) + { + sprintf(str, "The degree of the polynom (%d) exceeds the maximum\n" + "allowed one (%d)", poly->degree[g], POLY_MAXDEGREE); + qerror("*Error*: ", str); + } + +/*-- There are (n+d)!/(n!d!) coeffs per group, that is Prod_(i<=d) (n+i)/i */ + for (num=den=1, n=nd[g]; d; num*=(n+d), den*=d--); + poly->ncoeff *= num/den; + } + + QMALLOC(poly->basis, double, poly->ncoeff); + QCALLOC(poly->coeff, double, poly->ncoeff); + + return poly; + } + + +/****** poly_end ************************************************************* +PROTO void poly_end(polystruct *poly) +PURPOSE Free a polynom structure and everything it contains. +INPUT polystruct pointer. +OUTPUT -. +NOTES -. +AUTHOR E. Bertin (IAP, Leiden observatory & ESO) +VERSION 09/04/2000 + ***/ +void poly_end(polystruct *poly) + { + if (poly) + { + free(poly->coeff); + free(poly->basis); + free(poly->degree); + free(poly->group); + free(poly); + } + } + + +/****** poly_func ************************************************************ +PROTO double poly_func(polystruct *poly, double *pos) +PURPOSE Evaluate a multidimensional polynom. +INPUT polystruct pointer, + pointer to the 1D array of input vector data. +OUTPUT Polynom value. +NOTES Values of the basis functions are updated in poly->basis. +AUTHOR E. Bertin (IAP) +VERSION 03/03/2004 + ***/ +double poly_func(polystruct *poly, double *pos) + { + double xpol[POLY_MAXDIM+1]; + double *post, *xpolt, *basis, *coeff, xval; + long double val; + int expo[POLY_MAXDIM+1], gexpo[POLY_MAXDIM+1]; + int *expot, *degree,*degreet, *group,*groupt, *gexpot, + d,g,t, ndim; + +/* Prepare the vectors and counters */ + ndim = poly->ndim; + basis = poly->basis; + coeff = poly->coeff; + group = poly->group; + degree = poly->degree; + if (ndim) + { + for (xpolt=xpol, expot=expo, post=pos, d=ndim; --d;) + { + *(++xpolt) = 1.0; + *(++expot) = 0; + } + for (gexpot=gexpo, degreet=degree, g=poly->ngroup; g--;) + *(gexpot++) = *(degreet++); + if (gexpo[*group]) + gexpo[*group]--; + } + +/* The constant term is handled separately */ + val = *(coeff++); + *(basis++) = 1.0; + *expo = 1; + *xpol = *pos; + +/* Compute the rest of the polynom */ + for (t=poly->ncoeff; --t; ) + { +/*-- xpol[0] contains the current product of the x^n's */ + val += (*(basis++)=*xpol)**(coeff++); +/*-- A complex recursion between terms of the polynom speeds up computations */ +/*-- Not too good for roundoff errors (prefer Horner's), but much easier for */ +/*-- multivariate polynomials: this is why we use a long double accumulator */ + post = pos; + groupt = group; + expot = expo; + xpolt = xpol; + for (d=0; dncoeff; + ndim = poly->ndim; + matsize = ncoeff*ncoeff; + basis = poly->basis; + extbasist = extbasis; + QCALLOC(alpha, double, matsize); + QCALLOC(beta, double, ncoeff); + +/* Subtract an average offset to maintain precision (droped for now ) */ +/* + if (x) + { + for (d=0; dcoeff; + for (j=ncoeff; j--;) + *(coeff++) = *(betat++); +/* + poly_addcste(poly, offset); +*/ + free(beta); + + return; + } + + +/****** poly_addcste ********************************************************* +PROTO void poly_addcste(polystruct *poly, double *cste) +PURPOSE Modify matrix coefficients to mimick the effect of adding a cst to + the input of a polynomial. +INPUT Pointer to the polynomial structure, + Pointer to the vector of cst. +OUTPUT -. +NOTES Requires quadruple-precision. **For the time beeing, this function + returns completely wrong results!!** +AUTHOR E. Bertin (IAP) +VERSION 03/03/2004 + ***/ +void poly_addcste(polystruct *poly, double *cste) + { + long double *acoeff; + double *coeff,*mcoeff,*mcoefft, + val; + int *mpowers,*powers,*powerst,*powerst2, + i,j,n,p, denum, flag, maxdegree, ncoeff, ndim; + + ncoeff = poly->ncoeff; + ndim = poly->ndim; + maxdegree = 0; + for (j=0; jngroup; j++) + if (maxdegree < poly->degree[j]) + maxdegree = poly->degree[j]; + maxdegree++; /* Actually we need maxdegree+1 terms */ + QCALLOC(acoeff, long double, ncoeff); + QCALLOC(mcoeff, double, ndim*maxdegree); + QCALLOC(mpowers, int, ndim); + mcoefft = mcoeff; /* To avoid gcc -Wall warnings */ + powerst = powers = poly_powers(poly); + coeff = poly->coeff; + for (i=0; i