summaryrefslogtreecommitdiffstats
path: root/tksao/colorbar
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2016-10-27 18:59:29 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2016-10-27 18:59:29 (GMT)
commitd4d595fa7fb12903db9227d33d48b2b00120dbd1 (patch)
tree7d18365de0d6d1b29399b6a17c7eb01c2eb3ed49 /tksao/colorbar
parent949f96e29bfe0bd8710d775ce220e597064e2589 (diff)
downloadblt-d4d595fa7fb12903db9227d33d48b2b00120dbd1.zip
blt-d4d595fa7fb12903db9227d33d48b2b00120dbd1.tar.gz
blt-d4d595fa7fb12903db9227d33d48b2b00120dbd1.tar.bz2
Initial commit
Diffstat (limited to 'tksao/colorbar')
-rw-r--r--tksao/colorbar/cbgrid.C210
-rw-r--r--tksao/colorbar/cbgrid.h33
-rw-r--r--tksao/colorbar/colorbar.C880
-rw-r--r--tksao/colorbar/colorbar.h94
-rw-r--r--tksao/colorbar/colorbarbase.C1103
-rw-r--r--tksao/colorbar/colorbarbase.h200
-rw-r--r--tksao/colorbar/colorbarrgb.C490
-rw-r--r--tksao/colorbar/colorbarrgb.h55
-rw-r--r--tksao/colorbar/colorbarrgbtruecolor16.C294
-rw-r--r--tksao/colorbar/colorbarrgbtruecolor16.h20
-rw-r--r--tksao/colorbar/colorbarrgbtruecolor24.C531
-rw-r--r--tksao/colorbar/colorbarrgbtruecolor24.h24
-rw-r--r--tksao/colorbar/colorbarrgbtruecolor8.C200
-rw-r--r--tksao/colorbar/colorbarrgbtruecolor8.h20
-rw-r--r--tksao/colorbar/colorbartruecolor16.C215
-rw-r--r--tksao/colorbar/colorbartruecolor16.h20
-rw-r--r--tksao/colorbar/colorbartruecolor24.C335
-rw-r--r--tksao/colorbar/colorbartruecolor24.h24
-rw-r--r--tksao/colorbar/colorbartruecolor8.C169
-rw-r--r--tksao/colorbar/colorbartruecolor8.h20
-rw-r--r--tksao/colorbar/colormap.C44
-rw-r--r--tksao/colorbar/colormap.h68
-rw-r--r--tksao/colorbar/colortag.C78
-rw-r--r--tksao/colorbar/colortag.h62
-rw-r--r--tksao/colorbar/default.C586
-rw-r--r--tksao/colorbar/default.h104
-rw-r--r--tksao/colorbar/lex.C2070
-rw-r--r--tksao/colorbar/lex.L127
-rw-r--r--tksao/colorbar/lut.C174
-rw-r--r--tksao/colorbar/lut.h76
-rw-r--r--tksao/colorbar/lutlex.C1699
-rw-r--r--tksao/colorbar/lutlex.L106
-rw-r--r--tksao/colorbar/lutparser.C1632
-rw-r--r--tksao/colorbar/lutparser.H89
-rw-r--r--tksao/colorbar/lutparser.Y75
-rw-r--r--tksao/colorbar/parser.C2215
-rw-r--r--tksao/colorbar/parser.H182
-rw-r--r--tksao/colorbar/parser.Y249
-rw-r--r--tksao/colorbar/sao.C209
-rw-r--r--tksao/colorbar/sao.h85
-rw-r--r--tksao/colorbar/saolex.C1754
-rw-r--r--tksao/colorbar/saolex.L111
-rw-r--r--tksao/colorbar/saoparser.C1674
-rw-r--r--tksao/colorbar/saoparser.H99
-rw-r--r--tksao/colorbar/saoparser.Y98
45 files changed, 18603 insertions, 0 deletions
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 <tk.h>
+
+#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 <fstream>
+
+#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; jj<height; jj++) {
+ for (int ii=0; ii<width; ii++) {
+ int kk = (int)(double(ii)/width*colorCount)*3;
+ unsigned char red = colorCells[kk+2];
+ unsigned char green = colorCells[kk+1];
+ unsigned char blue = colorCells[kk];
+
+ switch (psColorSpace) {
+ case BW:
+ case GRAY:
+ filter << RGB2Gray(red, green, blue);
+ break;
+ case RGB:
+ filter << red << green << blue;
+ break;
+ case CMYK:
+ {
+ unsigned char cyan, magenta, yellow, black;
+ RGB2CMYK(red, green, blue, &cyan, &magenta, &yellow, &black);
+ filter << cyan << magenta << yellow << black;
+ }
+ break;
+ }
+ str << filter;
+ }
+ }
+}
+
+void Colorbar::psVert(ostream& str, Filter& filter, int width, int height)
+{
+ for (int jj=0; jj<height; jj++) {
+ int kk = (int)(double(jj)/height*colorCount)*3;
+ unsigned char red = colorCells[kk+2];
+ unsigned char green = colorCells[kk+1];
+ unsigned char blue = colorCells[kk];
+
+ switch (psColorSpace) {
+ case BW:
+ case GRAY:
+ for (int ii=0; ii<width; ii++)
+ filter << RGB2Gray(red, green, blue);
+ break;
+ case RGB:
+ for (int ii=0; ii<width; ii++)
+ filter << red << green << blue;
+ break;
+ case CMYK:
+ for (int ii=0; ii<width; ii++) {
+ unsigned char cyan, magenta, yellow, black;
+ RGB2CMYK(red, green, blue, &cyan, &magenta, &yellow, &black);
+ filter << cyan << magenta << yellow << black;
+ }
+ break;
+ }
+ str << filter;
+ }
+}
+
+void Colorbar::reset()
+{
+ bias = 0.5;
+ contrast = 1.0;
+ invert = 0;
+
+ updateColors();
+}
+
+void Colorbar::updateColorCells()
+{
+ // fill rgb table
+ // note: its filled bgr to match XImage
+
+ if (cmaps.current())
+ for(int i=0, j=colorCount-1; i<colorCount; i++, j--) {
+ int index = invert ? calcContrastBias(j) : calcContrastBias(i);
+ colorCells[i*3] = cmaps.current()->getBlueChar(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(); ii<ctags.current()->stop(); 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() && ss<ctags.current()->stop()) {
+ 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]<lut[0] && vv[1]<lut[0])
+ return;
+
+ mm =0;
+ for (int ii=0; ii<cnt; ii++)
+ if (vv[0]<lut[ii]) {
+ mm=ii;
+ break;
+ }
+ nn =cnt-1;
+ for (int ii=cnt-1; ii>=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() && ss<ctags.current()->stop()) {
+ 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 && ss<stop) {
+ if (ss>stop-10 && ss<stop) {
+ tagaction =STOP;
+ }
+ else if (ss>start && ss<start+10) {
+ tagaction =START;
+ }
+ else {
+ tagaction =MOVE;
+ }
+ tag = ctags.current();
+ taginit =rr;
+ return;
+ }
+ ctags.next();
+ }
+
+ // else create a new tag
+ ctags.append(new ColorTag(this,ss,ss,color));
+ tag = ctags.current();
+ tagaction =CREATE;
+ taginit =rr;
+}
+
+void Colorbar::tagEditMotionCmd(int xx, int yy)
+{
+ ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options;
+
+ if (tag) {
+ int rr,ss,tt;
+ if (!opts->orientation) {
+ 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<lut[0] && bb<lut[0])
+ continue;
+
+ mm =0;
+ for (int ii=0; ii<cnt; ii++)
+ if (aa<lut[ii]) {
+ mm=ii;
+ break;
+ }
+ nn =cnt-1;
+ for (int ii=cnt-1; ii>=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; jj<height; jj++)
+ for (int ii=0; ii<width; ii++) {
+ int kk = (int)(double(ii)/width*colorCount)*3;
+ *dptr++ = colorCells[kk+2];
+ *dptr++ = colorCells[kk+1];
+ *dptr++ = colorCells[kk];
+ *dptr++ = 0;
+ }
+ }
+ else {
+ for (int jj=0; jj<height; jj++) {
+ int kk = (int)(double(jj)/height*colorCount)*3;
+ unsigned char rr = colorCells[kk+2];
+ unsigned char gg = colorCells[kk+1];
+ unsigned char bb = colorCells[kk];
+ for (int ii=0; ii<width; ii++) {
+ *dptr++ = rr;
+ *dptr++ = gg;
+ *dptr++ = bb;
+ *dptr++ = 0;
+ }
+ }
+ }
+
+ macosxBitmapCreate(dst, width, height, v, s);
+
+ if (dst)
+ delete [] dst;
+}
+#endif
+
+#ifdef __WIN32
+void Colorbar::win32(float scale, int width, int height,
+ const Vector& v, const Vector& s)
+{
+ if (!colorCells)
+ 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* dptr = dst;
+
+ if (!((ColorbarBaseOptions*)options)->orientation) {
+ for (int jj=0; jj<height; jj++) {
+ for (int ii=0; ii<width; ii++) {
+ int kk = (int)(double(ii)/width*colorCount)*3;
+ *dptr++ = colorCells[kk];
+ *dptr++ = colorCells[kk+1];
+ *dptr++ = colorCells[kk+2];
+ }
+ dptr += jjpad;
+ }
+ }
+ else {
+ for (int jj=0; jj<height; jj++) {
+ int kk = (int)(double(jj)/height*colorCount)*3;
+ unsigned char rr = colorCells[kk];
+ unsigned char gg = colorCells[kk+1];
+ unsigned char bb = colorCells[kk+2];
+ for (int ii=0; ii<width; ii++) {
+ *dptr++ = rr;
+ *dptr++ = gg;
+ *dptr++ = bb;
+ }
+ dptr += jjpad;
+ }
+ }
+
+ win32Clip(v,s);
+ win32BitmapCreate(dst, jjwidth, height, v, s);
+ win32Clip(Vector(INT_MIN,INT_MIN),Vector(INT_MAX,INT_MAX));
+
+ if (dst)
+ delete [] dst;
+}
+#endif
diff --git a/tksao/colorbar/colorbar.h b/tksao/colorbar/colorbar.h
new file mode 100644
index 0000000..93ac43a
--- /dev/null
+++ b/tksao/colorbar/colorbar.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 __colorbar_h__
+#define __colorbar_h__
+
+#include "colorbarbase.h"
+#include "colormap.h"
+#include "colortag.h"
+#include "list.h"
+
+// Colormap(s) are X window Colormap ID's. ColorMapInfo(s) contain a fixed
+// number of real RGB color cells. RGB Values of ColorMapInfo(s) are
+// never altered. Colormap(s) are initialized from ColorMapInfo values.
+// Colormap RGB values will changed, based on user input.
+
+class Filter;
+
+class Colorbar : public ColorbarBase {
+ public:
+ enum ColorTagAction {NONE,CREATE,START,STOP,MOVE};
+
+ protected:
+ List<ColorMapInfo> cmaps;
+ List<ColorTag> 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 <tkInt.h>
+
+#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 <FlexLexer.h>
+
+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; ii<tickcnt; ii++)
+ if (ticktxt[ii])
+ delete [] ticktxt[ii];
+ delete [] ticktxt;
+ }
+}
+
+int ColorbarBase::configure(int argc, const char* argv[], int flags)
+{
+ if (Widget::configure(argc, argv, flags) == TCL_ERROR)
+ return TCL_ERROR;
+
+ // only valid for the initial configuration call
+ if (flags != TK_CONFIG_ARGV_ONLY)
+ return initColormap();
+ else {
+ if ((configSpecs[CONFIGORIENTATION].specFlags & TK_CONFIG_OPTION_SPECIFIED) ||
+ (configSpecs[CONFIGNUMERICS].specFlags & TK_CONFIG_OPTION_SPECIFIED) ||
+ (configSpecs[CONFIGSIZE].specFlags & TK_CONFIG_OPTION_SPECIFIED) ||
+ (configSpecs[CONFIGFONT].specFlags & TK_CONFIG_OPTION_SPECIFIED) ||
+ (configSpecs[CONFIGFONTSTYLE].specFlags & TK_CONFIG_OPTION_SPECIFIED) ||
+ (configSpecs[CONFIGFONTSIZE].specFlags & TK_CONFIG_OPTION_SPECIFIED) ||
+ (configSpecs[CONFIGSPACE].specFlags & TK_CONFIG_OPTION_SPECIFIED) ||
+ (configSpecs[CONFIGTICKS].specFlags & TK_CONFIG_OPTION_SPECIFIED)) {
+ updateBBox();
+
+ invalidPixmap();
+ redraw();
+ }
+ }
+ return TCL_OK;
+}
+
+void ColorbarBase::invalidPixmap()
+{
+ Widget::invalidPixmap();
+
+ if (xmap)
+ XDestroyImage(xmap);
+ xmap = NULL;
+}
+
+int ColorbarBase::parse(istringstream& istr)
+{
+ result = TCL_OK;
+ cbFlexLexer* ll = new cbFlexLexer(&istr);
+ cbparse(this, ll);
+ delete ll;
+
+ return result;
+}
+
+Tk_Font ColorbarBase::getFont()
+{
+ ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options;
+
+ ostringstream fstr;
+#ifdef MAC_OSX_TK
+ int fz = int(opts->fontSize*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; ii<tickcnt; ii++)
+ delete [] ticktxt[ii];
+ delete [] ticktxt;
+ tickcnt = opts->ticks;
+ ticktxt = new char*[opts->ticks];
+ for (int ii=0; ii<opts->ticks; 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; ii<opts->ticks; 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; ii<opts->ticks; 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; ii<opts->ticks; 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; ii<opts->ticks-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 (incrcnt<skipcnt)
+ incrcnt++;
+ else
+ incrcnt=0;
+ }
+
+ Tk_FreeFont(font);
+}
+
+void ColorbarBase::renderGridAST()
+{
+ if (grid)
+ delete grid;
+ grid = NULL;
+
+ if (cnt>1 && 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; ii<opts->ticks; 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 (incrcnt<skipcnt)
+ incrcnt++;
+ else
+ incrcnt=0;
+ }
+
+ Tk_FreeFont(font);
+}
+
+void ColorbarBase::psGridAST()
+{
+ ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options;
+
+ Vector oo;
+ Vector uu(options->width, 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; ii<cc; ii++)
+ same &= (lut[ii] == ff[ii]);
+ if (same)
+ return;
+ }
+
+ // remove the old
+ if (lut)
+ delete [] lut;
+ cnt = cc;
+ lut = new double[cc];
+ for (int ii=0; ii<cc; ii++)
+ lut[ii] = ff[ii];
+
+ invalidPixmap();
+ redraw();
+}
+
+// MacOSX
+
+#ifdef MAC_OSX_TK
+void ColorbarBase::macosxPrintCmd()
+{
+ ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options;
+
+ if (!visible)
+ return;
+
+ // init
+ macosxBegin();
+
+ int ww,hh;
+ if (!opts->orientation) {
+ 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; ii<opts->ticks; 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 (incrcnt<skipcnt)
+ incrcnt++;
+ else
+ incrcnt=0;
+ }
+
+ Tk_FreeFont(font);
+}
+
+void ColorbarBase::macosxGridAST()
+{
+ ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options;
+
+ Vector oo(originX, originY);
+ Vector uu(options->width, 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; ii<opts->ticks; 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 (incrcnt<skipcnt)
+ incrcnt++;
+ else
+ incrcnt=0;
+ }
+
+ Tk_FreeFont(font);
+}
+
+void ColorbarBase::win32GridAST()
+{
+ ColorbarBaseOptions* opts = (ColorbarBaseOptions*)options;
+
+ Vector oo(originX, originY);
+ Vector uu(options->width, 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 <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+// 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; ii<width; ii++) {
+ unsigned char red = colorCells[(int)(double(ii)/width*colorCount)*3+2];
+ unsigned char green = 0;
+ unsigned char blue = 0;
+
+ switch (psColorSpace) {
+ case BW:
+ case GRAY:
+ filter << RGB2Gray(red, green, blue);
+ break;
+ case RGB:
+ filter << red << green << blue;
+ break;
+ case CMYK:
+ {
+ unsigned char cyan, magenta, yellow, black;
+ RGB2CMYK(red, green, blue, &cyan, &magenta, &yellow, &black);
+ filter << cyan << magenta << yellow << black;
+ }
+ break;
+ }
+ str << filter;
+ }
+ }
+
+ // green
+ for (int jj=(int)(height/3.); jj<(int)(height*2/3.); jj++) {
+ for (int ii=0; ii<width; ii++) {
+ unsigned char red = 0;
+ unsigned char green = colorCells[(int)(double(ii)/width*colorCount)*3+1];
+ unsigned char blue = 0;
+
+ switch (psColorSpace) {
+ case BW:
+ case GRAY:
+ filter << RGB2Gray(red, green, blue);
+ break;
+ case RGB:
+ filter << red << green << blue;
+ break;
+ case CMYK:
+ {
+ unsigned char cyan, magenta, yellow, black;
+ RGB2CMYK(red, green, blue, &cyan, &magenta, &yellow, &black);
+ filter << cyan << magenta << yellow << black;
+ }
+ break;
+ }
+ str << filter;
+ }
+ }
+
+ // blue
+ for (int jj=(int)(height*2/3.); jj<height; jj++) {
+ for (int ii=0; ii<width; ii++) {
+ unsigned char red = 0;
+ unsigned char green = 0;
+ unsigned char blue = colorCells[(int)(double(ii)/width*colorCount)*3];
+
+ switch (psColorSpace) {
+ case BW:
+ case GRAY:
+ filter << RGB2Gray(red, green, blue);
+ break;
+ case RGB:
+ filter << red << green << blue;
+ break;
+ case CMYK:
+ {
+ unsigned char cyan, magenta, yellow, black;
+ RGB2CMYK(red, green, blue, &cyan, &magenta, &yellow, &black);
+ filter << cyan << magenta << yellow << black;
+ }
+ break;
+ }
+ str << filter;
+ }
+ }
+}
+
+void ColorbarRGB::psVert(ostream& str, Filter& filter, int width, int height)
+{
+ for (int jj=0; jj<height; jj++) {
+ int kk = (int)(double(jj)/height*colorCount)*3;
+ unsigned char red = colorCells[kk+2];
+ unsigned char green = colorCells[kk+1];
+ unsigned char blue = colorCells[kk];
+
+ switch (psColorSpace) {
+ case BW:
+ case GRAY:
+ for (int ii=0; ii<(int)(width/3.); ii++)
+ filter << RGB2Gray(red, 0, 0);
+ for (int ii=(int)(width/3.); ii<(int)(width*2/3.); ii++)
+ filter << RGB2Gray(0, green, 0);
+ for (int ii=(int)(width*2/3.); ii<width; ii++)
+ filter << RGB2Gray(0, 0, blue);
+ break;
+ case RGB:
+ for (int ii=0; ii<(int)(width/3.); ii++)
+ filter << red << 0 << 0;
+ for (int ii=(int)(width/3.); ii<(int)(width*2/3.); ii++)
+ filter << 0 << green << 0;
+ for (int ii=(int)(width*2/3.); ii<width; ii++)
+ filter << 0 << 0 << blue;
+ break;
+ case CMYK:
+ {
+ unsigned char cyan, magenta, yellow, black;
+ for (int ii=0; ii<(int)(width/3.); ii++) {
+ RGB2CMYK(red, 0, 0, &cyan, &magenta, &yellow, &black);
+ filter << cyan << magenta << yellow << black;
+ }
+ for (int ii=(int)(width/3.); ii<(int)(width*2/3.); ii++) {
+ RGB2CMYK(0, green, 0, &cyan, &magenta, &yellow, &black);
+ filter << cyan << magenta << yellow << black;
+ }
+ for (int ii=(int)(width*2/3.); ii<width; ii++) {
+ RGB2CMYK(0, 0, blue, &cyan, &magenta, &yellow, &black);
+ filter << cyan << magenta << yellow << black;
+ }
+ }
+ break;
+ }
+ str << filter;
+ }
+}
+
+void ColorbarRGB::reset()
+{
+ for (int i=0; i<3; i++) {
+ bias[i] = .5;
+ contrast[i] = 1.0;
+ }
+ invert = 0;
+
+ updateColors();
+}
+
+void ColorbarRGB::updateColorCells()
+{
+ // fill rgb table
+ // note: its filled bgr to match XImage
+ // for(int i=0; i<colorCount; i++) {
+ for(int i=0, j=colorCount-1; i<colorCount; i++, j--) {
+ int idr = invert ? calcContrastBias(j,bias[0],contrast[0]) :
+ calcContrastBias(i,bias[0],contrast[0]);
+ int idg = invert ? calcContrastBias(j,bias[1],contrast[1]) :
+ calcContrastBias(i,bias[1],contrast[1]);
+ int idb = invert ? calcContrastBias(j,bias[2],contrast[2]) :
+ calcContrastBias(i,bias[2],contrast[2]);
+
+ colorCells[i*3] = (int)(256.*idr/colorCount);
+ colorCells[i*3+1] = (int)(256.*idg/colorCount);
+ colorCells[i*3+2] = (int)(256.*idb/colorCount);
+ }
+}
+
+// Commands
+
+void ColorbarRGB::adjustCmd(float c, float b)
+{
+ contrast[channel] = c;
+ bias[channel] = b;
+
+ updateColors();
+}
+
+void ColorbarRGB::getBiasCmd()
+{
+ ostringstream str;
+ str << bias[channel] << ends;
+ Tcl_AppendResult(interp, str.str().c_str(), NULL);
+}
+
+void ColorbarRGB::getColorbarCmd()
+{
+ ostringstream str;
+ str << "rgb ";
+ for (int i=0; i<3; i++)
+ str << bias[i] << ' ';
+ for (int i=0; i<3; i++)
+ str << contrast[i] << ' ';
+ str << invert << ends;
+ Tcl_AppendResult(interp, str.str().c_str(), NULL);
+}
+
+void ColorbarRGB::getColormapCmd()
+{
+ // use fixed so that the frame parser will not be confused with an int
+ // as the first number
+ ostringstream str;
+ str << "rgb " << setiosflags(ios::fixed);
+ for (int i=0; i<3; i++)
+ str << bias[i] << ' ';
+ for (int i=0; i<3; i++)
+ str << contrast[i] << ' ';
+ str << invert << ' ';
+ str << (unsigned short*)colorCells << ' ' << colorCount << ends;
+ Tcl_AppendResult(interp, str.str().c_str(), NULL);
+}
+
+void ColorbarRGB::getColormapNameCmd(int id)
+{
+ Tcl_AppendResult(interp, "rgb", NULL);
+}
+
+void ColorbarRGB::getColormapFileNameCmd(int id)
+{
+ Tcl_AppendResult(interp, "rgb.rgb", NULL);
+}
+
+void ColorbarRGB::getContrastCmd()
+{
+ ostringstream str;
+ str << contrast[channel] << ends;
+ Tcl_AppendResult(interp, str.str().c_str(), NULL);
+}
+
+void ColorbarRGB::getCurrentNameCmd()
+{
+ Tcl_AppendResult(interp, "rgb", NULL);
+}
+
+void ColorbarRGB::getCurrentIDCmd()
+{
+ Tcl_AppendResult(interp, "rgb", NULL);
+}
+
+void ColorbarRGB::getCurrentFileNameCmd()
+{
+ Tcl_AppendResult(interp, "rgb", NULL);
+}
+
+void ColorbarRGB::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 ColorbarRGB::setColorbarCmd(float rb, float gb, float bb,
+ float rc, float gc, float bc, int i)
+
+{
+ bias[0] = rb;
+ bias[1] = gb;
+ bias[2] = bb;
+
+ contrast[0] = rc;
+ contrast[1] = gc;
+ contrast[2] = bc;
+
+ invert = i;
+ updateColors();
+}
+
+void ColorbarRGB::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;
+}
+
+#ifdef MAC_OSX_TK
+void ColorbarRGB::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) {
+ // blue
+ for (int jj=0; jj<(int)(height/3.); jj++)
+ for (int ii=0; ii<width; ii++) {
+ *dptr++ = 0;
+ *dptr++ = 0;
+ *dptr++ = colorCells[(int)(double(ii)/width*colorCount)*3];
+ *dptr++ = 0;
+ }
+
+ // green
+ for (int jj=(int)(height/3.); jj<(int)(height*2/3.); jj++)
+ for (int ii=0; ii<width; ii++) {
+ *dptr++ = 0;
+ *dptr++ = colorCells[(int)(double(ii)/width*colorCount)*3+1];
+ *dptr++ = 0;
+ *dptr++ = 0;
+ }
+
+ // red
+ for (int jj=(int)(height*2/3.); jj<height; jj++)
+ for (int ii=0; ii<width; ii++) {
+ *dptr++ = colorCells[(int)(double(ii)/width*colorCount)*3+2];
+ *dptr++ = 0;
+ *dptr++ = 0;
+ *dptr++ = 0;
+ }
+ }
+ else {
+ for (int jj=0; jj<height; jj++) {
+ int kk = (int)(double(jj)/height*colorCount)*3;
+
+ // blue
+ for (int ii=0; ii<(int)(width/3.); ii++) {
+ *dptr++ = 0;
+ *dptr++ = 0;
+ *dptr++ = colorCells[kk];
+ *dptr++ = 0;
+ }
+
+ // green
+ for (int ii=(int)(width/3.); ii<(int)(width*2/3.); ii++) {
+ *dptr++ = 0;
+ *dptr++ = colorCells[kk+1];
+ *dptr++ = 0;
+ *dptr++ = 0;
+ }
+
+ // red
+ for (int ii=(int)(width*2/3.); ii<width; ii++) {
+ *dptr++ = colorCells[kk+2];
+ *dptr++ = 0;
+ *dptr++ = 0;
+ *dptr++ = 0;
+ }
+ }
+ }
+
+ macosxBitmapCreate(dst, width, height, v, s);
+
+ if (dst)
+ delete [] dst;
+}
+#endif
+
+#ifdef __WIN32
+void ColorbarRGB::win32(float scale, int width, int height,
+ const Vector& v, const Vector& s)
+{
+ if (!colorCells)
+ 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* dptr = dst;
+
+ if (!((ColorbarBaseOptions*)options)->orientation) {
+ // blue
+ for (int jj=0; jj<(int)(height/3.); jj++) {
+ for (int ii=0; ii<width; ii++) {
+ *dptr++ = colorCells[(int)(double(ii)/width*colorCount)*3];
+ *dptr++ = 0;
+ *dptr++ = 0;
+ }
+ dptr += jjpad;
+ }
+
+ // green
+ for (int jj=(int)(height/3.); jj<(int)(height*2/3.); jj++) {
+ for (int ii=0; ii<width; ii++) {
+ *dptr++ = 0;
+ *dptr++ = colorCells[(int)(double(ii)/width*colorCount)*3+1];
+ *dptr++ = 0;
+ }
+ dptr += jjpad;
+ }
+
+ // red
+ for (int jj=(int)(height*2/3.); jj<height; jj++) {
+ for (int ii=0; ii<width; ii++) {
+ *dptr++ = 0;
+ *dptr++ = 0;
+ *dptr++ = colorCells[(int)(double(ii)/width*colorCount)*3+2];
+ }
+ dptr += jjpad;
+ }
+ }
+ else {
+ for (int jj=0; jj<height; jj++) {
+ int kk = (int)(double(jj)/height*colorCount)*3;
+
+ // blue
+ for (int ii=0; ii<(int)(width/3.); ii++) {
+ *dptr++ = colorCells[kk];
+ *dptr++ = 0;
+ *dptr++ = 0;
+ }
+ dptr += jjpad;
+
+ // green
+ for (int ii=(int)(width/3.); ii<(int)(width*2/3.); ii++) {
+ *dptr++ = 0;
+ *dptr++ = colorCells[kk+1];
+ *dptr++ = 0;
+ }
+ dptr += jjpad;
+
+ // red
+ for (int ii=(int)(width*2/3.); ii<width; ii++) {
+ *dptr++ = 0;
+ *dptr++ = 0;
+ *dptr++ = colorCells[kk+2];
+ }
+ dptr += jjpad;
+ }
+ }
+
+
+ win32Clip(v,s);
+ win32BitmapCreate(dst, jjwidth, height, v, s);
+ win32Clip(Vector(INT_MIN,INT_MIN),Vector(INT_MAX,INT_MAX));
+
+ if (dst)
+ delete [] dst;
+}
+#endif
diff --git a/tksao/colorbar/colorbarrgb.h b/tksao/colorbar/colorbarrgb.h
new file mode 100644
index 0000000..bc18475
--- /dev/null
+++ b/tksao/colorbar/colorbarrgb.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 __colorbarrgb_h__
+#define __colorbarrgb_h__
+
+#include "colorbarbase.h"
+
+class Filter;
+
+class ColorbarRGB : public ColorbarBase {
+ protected:
+ int channel;
+ float bias[3];
+ float contrast[3];
+
+ private:
+ void psHorz(ostream&, Filter&, int, int);
+ void psVert(ostream&, Filter&, int, int);
+
+protected:
+ int calcContrastBias(int, float, float);
+ 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:
+ ColorbarRGB(Tcl_Interp*, Tk_Canvas, Tk_Item*);
+
+ // SubCommandFunctions
+
+ 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 setColorbarCmd(float, float, float, float, float, float, int);
+ void getRGBChannelCmd();
+ void setRGBChannelCmd(const char*);
+};
+
+#endif
diff --git a/tksao/colorbar/colorbarrgbtruecolor16.C b/tksao/colorbar/colorbarrgbtruecolor16.C
new file mode 100644
index 0000000..65cdb69
--- /dev/null
+++ b/tksao/colorbar/colorbarrgbtruecolor16.C
@@ -0,0 +1,294 @@
+// Copyright (C) 1999-2016
+// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
+// For conditions of distribution and use, see copyright notice in "copyright"
+
+#include "colorbarrgbtruecolor16.h"
+#include "util.h"
+
+// Tk Canvas Widget Function Declarations
+
+int ColorbarRGBTrueColor16CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int,
+ Tcl_Obj *const []);
+
+// ColorbarRGB Specs
+
+static Tk_CustomOption tagsOption = {
+ Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+};
+
+static Tk_ConfigSpec colorbarRGBTrueColor16Specs[] = {
+
+ {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "colorbarrgb",
+ Tk_Offset(ColorbarBaseOptions, cmdName),
+ TK_CONFIG_OPTION_SPECIFIED,NULL},
+ {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, x),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, y),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512",
+ Tk_Offset(ColorbarBaseOptions, width),
+ TK_CONFIG_OPTION_SPECIFIED,
+ NULL},
+ {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "22",
+ Tk_Offset(ColorbarBaseOptions, height),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw",
+ Tk_Offset(ColorbarBaseOptions, 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(ColorbarBaseOptions, helvetica), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier",
+ Tk_Offset(ColorbarBaseOptions, courier), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times",
+ Tk_Offset(ColorbarBaseOptions, times), 0, NULL},
+
+ {TK_CONFIG_BOOLEAN, (char*)"-orientation", NULL, NULL, "0",
+ Tk_Offset(ColorbarBaseOptions, orientation), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-size", NULL, NULL, "20",
+ Tk_Offset(ColorbarBaseOptions, size), 0, NULL},
+
+ {TK_CONFIG_STRING, (char*)"-font", NULL, NULL, "helvetica",
+ Tk_Offset(ColorbarBaseOptions, font), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-fontsize", NULL, NULL, "10",
+ Tk_Offset(ColorbarBaseOptions, fontSize), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-fontweight", "fontweight", NULL, "normal",
+ Tk_Offset(ColorbarBaseOptions, fontWeight), 0, NULL},
+ {TK_CONFIG_SYNONYM, (char*)"-fontstyle", "fontweight", NULL, NULL, 0, 0},
+ {TK_CONFIG_STRING, (char*)"-fontslant", NULL, NULL, "roman",
+ Tk_Offset(ColorbarBaseOptions, fontSlant), 0, NULL},
+
+ {TK_CONFIG_BOOLEAN, (char*)"-numerics", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, numerics), 0, NULL},
+ {TK_CONFIG_BOOLEAN, (char*)"-space", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, space), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-ticks", NULL, NULL, "11",
+ Tk_Offset(ColorbarBaseOptions, ticks), 0, NULL},
+
+ {TK_CONFIG_INT, (char*)"-colors", NULL, NULL, "1024",
+ Tk_Offset(ColorbarBaseOptions, colors), 0, NULL},
+
+ {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL},
+};
+
+// Tk Static Structure
+
+static Tk_ItemType colorbarRGBTrueColor16Type = {
+ (char*)"colorbarrgbtruecolor16", // name
+ sizeof(ColorbarBaseOptions), // size
+ ColorbarRGBTrueColor16CreateProc, // configProc
+ colorbarRGBTrueColor16Specs, // 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 ColorbarRGBTrueColor16_Init(Tcl_Interp* interp)
+{
+ Tk_CreateItemType(&colorbarRGBTrueColor16Type);
+ return TCL_OK;
+}
+
+int ColorbarRGBTrueColor16CreateProc(Tcl_Interp* interp, Tk_Canvas canvas,
+ Tk_Item* item, int argc,
+ Tcl_Obj *const argv[])
+{
+ ColorbarRGBTrueColor16* colorbar =
+ new ColorbarRGBTrueColor16(interp, canvas, item);
+
+ // and set default configuration
+ if (colorbar->configure(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; ii<width; ii++) {
+ unsigned short r = colorCells[((int)(double(ii)/width*colorCount))*3];
+ unsigned short a = 0;
+ a |= rs_>0 ? ((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; ii<width; ii++) {
+ unsigned short g = colorCells[((int)(double(ii)/width*colorCount))*3+1];
+ unsigned short a = 0;
+ a |= gs_>0 ? ((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; ii<width; ii++) {
+ unsigned short b = colorCells[((int)(double(ii)/width*colorCount))*3+2];
+ unsigned short a = 0;
+ a |= bs_>0 ? ((b & bm_) << bs_) : ((b & bm_) >> -bs_);
+ memcpy(row+ii*2, &a, 2);
+ }
+ for (int jj=(int)(height*2/3.); jj<height; jj++)
+ memcpy(data+(jj*xmap->bytes_per_line), row, xmap->bytes_per_line);
+
+ }
+ else {
+ // red
+ for (int ii=0; ii<width; ii++) {
+ unsigned short r = colorCells[((int)(double(ii)/width*colorCount))*3];
+ unsigned short a = 0;
+ a |= rs_>0 ? ((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; ii<width; ii++) {
+ unsigned short g = colorCells[((int)(double(ii)/width*colorCount))*3+1];
+ unsigned short a = 0;
+ a |= gs_>0 ? ((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; ii<width; ii++) {
+ unsigned short b = colorCells[((int)(double(ii)/width*colorCount))*3+2];
+ unsigned short a = 0;
+ a |= bs_>0 ? ((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.); jj<height; jj++)
+ memcpy(data+(jj*xmap->bytes_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<width; ii++)
+ memcpy(data+ii*2, &a, 2);
+ }
+ }
+ }
+ else {
+ 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_);
+ 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.); ii<width; ii++) {
+ *(data+ii*2) = *(rr+1);
+ *(data+ii*2+1) = *(rr);
+ }
+ }
+ }
+ }
+}
+
diff --git a/tksao/colorbar/colorbarrgbtruecolor16.h b/tksao/colorbar/colorbarrgbtruecolor16.h
new file mode 100644
index 0000000..99bddc5
--- /dev/null
+++ b/tksao/colorbar/colorbarrgbtruecolor16.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 __colorbarrgbtruecolor16_h__
+#define __colorbarrgbtruecolor16_h__
+
+#include "colorbarrgb.h"
+#include "truecolor16.h"
+
+class ColorbarRGBTrueColor16 : public ColorbarRGB, TrueColor16 {
+private:
+ void updateColorsHorz();
+ void updateColorsVert();
+
+public:
+ ColorbarRGBTrueColor16(Tcl_Interp*, Tk_Canvas, Tk_Item*);
+};
+
+#endif
diff --git a/tksao/colorbar/colorbarrgbtruecolor24.C b/tksao/colorbar/colorbarrgbtruecolor24.C
new file mode 100644
index 0000000..4fce92e
--- /dev/null
+++ b/tksao/colorbar/colorbarrgbtruecolor24.C
@@ -0,0 +1,531 @@
+// Copyright (C) 1999-2016
+// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
+// For conditions of distribution and use, see copyright notice in "copyright"
+
+#include "colorbarrgbtruecolor24.h"
+#include "util.h"
+
+// Tk Canvas Widget Function Declarations
+
+int ColorbarRGBTrueColor24CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int,
+ Tcl_Obj *const []);
+
+// ColorbarRGB Specs
+
+static Tk_CustomOption tagsOption = {
+ Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+};
+
+static Tk_ConfigSpec colorbarRGBTrueColor24Specs[] = {
+ {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "colorbarrgb",
+ Tk_Offset(ColorbarBaseOptions, cmdName),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, x),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, y),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512",
+ Tk_Offset(ColorbarBaseOptions, width),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "22",
+ Tk_Offset(ColorbarBaseOptions, height),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw",
+ Tk_Offset(ColorbarBaseOptions, 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(ColorbarBaseOptions, helvetica), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier",
+ Tk_Offset(ColorbarBaseOptions, courier), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times",
+ Tk_Offset(ColorbarBaseOptions, times), 0, NULL},
+
+ {TK_CONFIG_BOOLEAN, (char*)"-orientation", NULL, NULL, "0",
+ Tk_Offset(ColorbarBaseOptions, orientation), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-size", NULL, NULL, "20",
+ Tk_Offset(ColorbarBaseOptions, size), 0, NULL},
+
+ {TK_CONFIG_STRING, (char*)"-font", NULL, NULL, "helvetica",
+ Tk_Offset(ColorbarBaseOptions, font), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-fontsize", NULL, NULL, "10",
+ Tk_Offset(ColorbarBaseOptions, fontSize), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-fontweight", "fontweight", NULL, "normal",
+ Tk_Offset(ColorbarBaseOptions, fontWeight), 0, NULL},
+ {TK_CONFIG_SYNONYM, (char*)"-fontstyle", "fontweight", NULL, NULL, 0, 0},
+ {TK_CONFIG_STRING, (char*)"-fontslant", NULL, NULL, "roman",
+ Tk_Offset(ColorbarBaseOptions, fontSlant), 0, NULL},
+
+ {TK_CONFIG_BOOLEAN, (char*)"-numerics", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, numerics), 0, NULL},
+ {TK_CONFIG_BOOLEAN, (char*)"-space", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, space), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-ticks", NULL, NULL, "11",
+ Tk_Offset(ColorbarBaseOptions, ticks), 0, NULL},
+
+ {TK_CONFIG_INT, (char*)"-colors", NULL, NULL, "1024",
+ Tk_Offset(ColorbarBaseOptions, colors), 0, NULL},
+
+ {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL},
+};
+
+// Tk Static Structure
+
+static Tk_ItemType colorbarRGBTrueColor24Type = {
+ (char*)"colorbarrgbtruecolor24", // name
+ sizeof(ColorbarBaseOptions), // size
+ ColorbarRGBTrueColor24CreateProc, // configProc
+ colorbarRGBTrueColor24Specs, // 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 ColorbarRGBTrueColor24_Init(Tcl_Interp* interp)
+{
+ Tk_CreateItemType(&colorbarRGBTrueColor24Type);
+ return TCL_OK;
+}
+
+int ColorbarRGBTrueColor24CreateProc(Tcl_Interp* interp, Tk_Canvas canvas,
+ Tk_Item* item, int argc,
+ Tcl_Obj *const argv[])
+{
+ ColorbarRGBTrueColor24* colorbar =
+ new ColorbarRGBTrueColor24(interp,canvas,item);
+
+ // and set default configuration
+ if (colorbar->configure(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; ii<width; ii++) {
+ unsigned int r = colorCells[(int)(double(ii)/width*colorCount)*3];
+ unsigned int a = 0;
+ a |= r << rs_;
+ memcpy(row+ii*3, &a, 3);
+ }
+ 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<width; ii++) {
+ unsigned int g = colorCells[(int)(double(ii)/width*colorCount)*3+1];
+ unsigned int a = 0;
+ a |= g << gs_;
+ memcpy(row+ii*3, &a, 3);
+ }
+ 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<width; ii++) {
+ unsigned int b = colorCells[(int)(double(ii)/width*colorCount)*3+2];
+ unsigned int a = 0;
+ a |= b << bs_;
+ memcpy(row+ii*3, &a, 3);
+ }
+ for (int jj=(int)(height*2/3.); jj<height; jj++)
+ memcpy(data+(jj*xmap->bytes_per_line), row, xmap->bytes_per_line);
+
+ }
+ else {
+ // red
+ for (int ii=0; ii<width; ii++) {
+ unsigned int r = colorCells[(int)(double(ii)/width*colorCount)*3];
+ unsigned int a = 0;
+ a |= r << rs_;
+ unsigned char* rr = (unsigned char*)(&a);
+ *(row+ii*3) = *(rr+3);
+ *(row+ii*3+1) = *(rr+2);
+ *(row+ii*3+2) = *(rr+1);
+ }
+ 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<width; ii++) {
+ unsigned int g = colorCells[(int)(double(ii)/width*colorCount)*3+1];
+ unsigned int a = 0;
+ a |= g << gs_;
+ unsigned char* rr = (unsigned char*)(&a);
+ *(row+ii*3) = *(rr+3);
+ *(row+ii*3+1) = *(rr+2);
+ *(row+ii*3+2) = *(rr+1);
+ }
+ 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<width; ii++) {
+ unsigned int b = colorCells[(int)(double(ii)/width*colorCount)*3+2];
+ unsigned int a = 0;
+ a |= b << bs_;
+ unsigned char* rr = (unsigned char*)(&a);
+ *(row+ii*3) = *(rr+3);
+ *(row+ii*3+1) = *(rr+2);
+ *(row+ii*3+2) = *(rr+1);
+ }
+ for (int jj=(int)(height*2/3.); jj<height; jj++)
+ memcpy(data+(jj*xmap->bytes_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<width; ii++)
+ memcpy(data+ii*3, &a, 3);
+ }
+ }
+ }
+ else {
+ 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_;
+ 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.); ii<width; ii++) {
+ *(data+ii*3) = *(rr+3);
+ *(data+ii*3+1) = *(rr+2);
+ *(data+ii*3+2) = *(rr+1);
+ }
+ }
+ }
+ }
+}
+
+void ColorbarRGBTrueColor24::updateColors32Horz(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; ii<width; ii++) {
+ unsigned int r = colorCells[(int)(double(ii)/width*colorCount)*3];
+ unsigned int a = 0;
+#ifdef MAC_OSX_TK
+ a |= 0xff << 24;
+#endif
+ a |= r << rs_;
+ memcpy(row+ii*4, &a, 4);
+ }
+ 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<width; ii++) {
+ unsigned int g = colorCells[(int)(double(ii)/width*colorCount)*3+1];
+ unsigned int a = 0;
+#ifdef MAC_OSX_TK
+ a |= 0xff << 24;
+#endif
+ a |= g << gs_;
+ memcpy(row+ii*4, &a, 4);
+ }
+ 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<width; ii++) {
+ unsigned int b = colorCells[(int)(double(ii)/width*colorCount)*3+2];
+ unsigned int a = 0;
+#ifdef MAC_OSX_TK
+ a |= 0xff << 24;
+#endif
+ a |= b << bs_;
+ memcpy(row+ii*4, &a, 4);
+ }
+ for (int jj=(int)(height*2/3.); jj<height; jj++)
+ memcpy(data+(jj*xmap->bytes_per_line), row, xmap->bytes_per_line);
+
+ }
+ else {
+ // red
+ for (int i=0; i<width; i++) {
+ unsigned int r = colorCells[(int)(double(i)/width*colorCount)*3];
+ unsigned int a = 0;
+#ifdef MAC_OSX_TK
+ a |= 0xff << 24;
+#endif
+ a |= r << rs_;
+ unsigned char* rr = (unsigned char*)(&a);
+ *(row+i*4) = *(rr+3);
+ *(row+i*4+1) = *(rr+2);
+ *(row+i*4+2) = *(rr+1);
+ *(row+i*4+3) = *(rr);
+ }
+ for (int j=0; j<(int)(height/3.); j++)
+ memcpy(data+(j*xmap->bytes_per_line), row, xmap->bytes_per_line);
+
+ // green
+ for (int i=0; i<width; i++) {
+ unsigned int g = colorCells[(int)(double(i)/width*colorCount)*3+1];
+ unsigned int a = 0;
+#ifdef MAC_OSX_TK
+ a |= 0xff << 24;
+#endif
+ a |= g << gs_;
+ unsigned char* rr = (unsigned char*)(&a);
+ *(row+i*4) = *(rr+3);
+ *(row+i*4+1) = *(rr+2);
+ *(row+i*4+2) = *(rr+1);
+ *(row+i*4+3) = *(rr);
+ }
+ for (int j=(int)(height/3.); j<(int)(height*2/3.); j++)
+ memcpy(data+(j*xmap->bytes_per_line), row, xmap->bytes_per_line);
+
+ // blue
+ for (int i=0; i<width; i++) {
+ unsigned int b = colorCells[(int)(double(i)/width*colorCount)*3+2];
+ unsigned int a = 0;
+#ifdef MAC_OSX_TK
+ a |= 0xff << 24;
+#endif
+ a |= b << bs_;
+ unsigned char* rr = (unsigned char*)(&a);
+ *(row+i*4) = *(rr+3);
+ *(row+i*4+1) = *(rr+2);
+ *(row+i*4+2) = *(rr+1);
+ *(row+i*4+3) = *(rr);
+ }
+ for (int j=(int)(height*2/3.); j<height; j++)
+ memcpy(data+(j*xmap->bytes_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<width; ii++)
+ memcpy(data+ii*4, &a, 4);
+ }
+ }
+ }
+ else {
+ 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_;
+ 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.); ii<width; ii++) {
+ *(data+ii*4) = *(rr+3);
+ *(data+ii*4+1) = *(rr+2);
+ *(data+ii*4+2) = *(rr+1);
+ *(data+ii*4+3) = *(rr);
+ }
+ }
+ }
+ }
+}
diff --git a/tksao/colorbar/colorbarrgbtruecolor24.h b/tksao/colorbar/colorbarrgbtruecolor24.h
new file mode 100644
index 0000000..377b126
--- /dev/null
+++ b/tksao/colorbar/colorbarrgbtruecolor24.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 __colorbarrgbtruecolor24_h__
+#define __colorbarrgbtruecolor24_h__
+
+#include "colorbarrgb.h"
+#include "truecolor24.h"
+
+class ColorbarRGBTrueColor24 : public ColorbarRGB, public TrueColor24 {
+private:
+ void updateColorsHorz();
+ void updateColorsVert();
+ void updateColors24Horz(int, int, char*);
+ void updateColors24Vert(int, int, char*);
+ void updateColors32Horz(int, int, char*);
+ void updateColors32Vert(int, int, char*);
+
+public:
+ ColorbarRGBTrueColor24(Tcl_Interp*, Tk_Canvas, Tk_Item*);
+};
+
+#endif
diff --git a/tksao/colorbar/colorbarrgbtruecolor8.C b/tksao/colorbar/colorbarrgbtruecolor8.C
new file mode 100644
index 0000000..9cb462e
--- /dev/null
+++ b/tksao/colorbar/colorbarrgbtruecolor8.C
@@ -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"
+
+#include "colorbarrgbtruecolor8.h"
+#include "util.h"
+
+// Tk Canvas Widget Function Declarations
+
+int ColorbarRGBTrueColor8CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int,
+ Tcl_Obj *const []);
+
+// Colorbar Specs
+
+static Tk_CustomOption tagsOption = {
+ Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+};
+
+static Tk_ConfigSpec colorbarRGBTrueColor8Specs[] = {
+ {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "colorbarrgb",
+ Tk_Offset(ColorbarBaseOptions, cmdName),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, x),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, y),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512",
+ Tk_Offset(ColorbarBaseOptions, width),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "22",
+ Tk_Offset(ColorbarBaseOptions, height),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw",
+ Tk_Offset(ColorbarBaseOptions, 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(ColorbarBaseOptions, helvetica), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier",
+ Tk_Offset(ColorbarBaseOptions, courier), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times",
+ Tk_Offset(ColorbarBaseOptions, times), 0, NULL},
+
+ {TK_CONFIG_BOOLEAN, (char*)"-orientation", NULL, NULL, "0",
+ Tk_Offset(ColorbarBaseOptions, orientation), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-size", NULL, NULL, "20",
+ Tk_Offset(ColorbarBaseOptions, size), 0, NULL},
+
+ {TK_CONFIG_STRING, (char*)"-font", NULL, NULL, "helvetica",
+ Tk_Offset(ColorbarBaseOptions, font), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-fontsize", NULL, NULL, "10",
+ Tk_Offset(ColorbarBaseOptions, fontSize), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-fontweight", "fontweight", NULL, "normal",
+ Tk_Offset(ColorbarBaseOptions, fontWeight), 0, NULL},
+ {TK_CONFIG_SYNONYM, (char*)"-fontstyle", "fontweight", NULL, NULL, 0, 0},
+ {TK_CONFIG_STRING, (char*)"-fontslant", NULL, NULL, "roman",
+ Tk_Offset(ColorbarBaseOptions, fontSlant), 0, NULL},
+
+ {TK_CONFIG_BOOLEAN, (char*)"-numerics", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, numerics), 0, NULL},
+ {TK_CONFIG_BOOLEAN, (char*)"-space", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, space), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-ticks", NULL, NULL, "11",
+ Tk_Offset(ColorbarBaseOptions, ticks), 0, NULL},
+
+ {TK_CONFIG_INT, (char*)"-colors", NULL, NULL, "1024",
+ Tk_Offset(ColorbarBaseOptions, colors), 0, NULL},
+
+ {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL},
+};
+
+// Tk Static Structure
+
+static Tk_ItemType colorbarRGBTrueColor8Type = {
+ (char*)"colorbarrgbtruecolor8", // name
+ sizeof(ColorbarBaseOptions), // size
+ ColorbarRGBTrueColor8CreateProc, // configProc
+ colorbarRGBTrueColor8Specs, // 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 ColorbarRGBTrueColor8_Init(Tcl_Interp* interp)
+{
+ Tk_CreateItemType(&colorbarRGBTrueColor8Type);
+ return TCL_OK;
+}
+
+int ColorbarRGBTrueColor8CreateProc(Tcl_Interp* interp, Tk_Canvas canvas,
+ Tk_Item* item, int argc,
+ Tcl_Obj *const argv[])
+{
+ ColorbarRGBTrueColor8* colorbar =
+ new ColorbarRGBTrueColor8(interp, canvas, item);
+
+ // and set default configuration
+ if (colorbar->configure(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<width; ii++) {
+ char r = colorCells[((int)(double(ii)/width*colorCount))*3];
+ row[ii] = (r & rm_) >> 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<width; ii++) {
+ char g = colorCells[((int)(double(ii)/width*colorCount))*3+1];
+ row[ii] = (g & gm_) >> 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<width; ii++) {
+ char b =colorCells[((int)(double(ii)/width*colorCount))*3+2];
+ row[ii] = (b & bm_) >> bs_;
+ }
+ for (int jj=(int)(height*2/3.); jj<height; jj++)
+ memcpy(data+(jj*xmap->bytes_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.); ii<width; ii++)
+ data[ii] = a;
+ }
+ }
+}
+
diff --git a/tksao/colorbar/colorbarrgbtruecolor8.h b/tksao/colorbar/colorbarrgbtruecolor8.h
new file mode 100644
index 0000000..8f9f38e
--- /dev/null
+++ b/tksao/colorbar/colorbarrgbtruecolor8.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 __colorbarrgbtruecolor8_h__
+#define __colorbarrgbtruecolor8_h__
+
+#include "colorbarrgb.h"
+#include "truecolor8.h"
+
+class ColorbarRGBTrueColor8 : public ColorbarRGB, TrueColor8 {
+private:
+ void updateColorsHorz();
+ void updateColorsVert();
+
+public:
+ ColorbarRGBTrueColor8(Tcl_Interp*, Tk_Canvas, Tk_Item*);
+};
+
+#endif
diff --git a/tksao/colorbar/colorbartruecolor16.C b/tksao/colorbar/colorbartruecolor16.C
new file mode 100644
index 0000000..c05701b
--- /dev/null
+++ b/tksao/colorbar/colorbartruecolor16.C
@@ -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"
+
+#include "colorbartruecolor16.h"
+#include "util.h"
+
+// Tk Canvas Widget Function Declarations
+
+int ColorbarTrueColor16CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int,
+ Tcl_Obj *const []);
+
+// Colorbar Specs
+
+static Tk_CustomOption tagsOption = {
+ Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+};
+
+static Tk_ConfigSpec colorbarTrueColor16Specs[] = {
+
+ {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "colorbar",
+ Tk_Offset(ColorbarBaseOptions, cmdName), TK_CONFIG_OPTION_SPECIFIED,
+ NULL},
+ {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, x), TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, y), TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512",
+ Tk_Offset(ColorbarBaseOptions, width), TK_CONFIG_OPTION_SPECIFIED,
+ NULL},
+ {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "22",
+ Tk_Offset(ColorbarBaseOptions, height), TK_CONFIG_OPTION_SPECIFIED,
+ NULL},
+ {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw",
+ Tk_Offset(ColorbarBaseOptions, 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(ColorbarBaseOptions, helvetica), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier",
+ Tk_Offset(ColorbarBaseOptions, courier), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times",
+ Tk_Offset(ColorbarBaseOptions, times), 0, NULL},
+
+ {TK_CONFIG_BOOLEAN, (char*)"-orientation", NULL, NULL, "0",
+ Tk_Offset(ColorbarBaseOptions, orientation), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-size", NULL, NULL, "20",
+ Tk_Offset(ColorbarBaseOptions, size), 0, NULL},
+
+ {TK_CONFIG_STRING, (char*)"-font", NULL, NULL, "helvetica",
+ Tk_Offset(ColorbarBaseOptions, font), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-fontsize", NULL, NULL, "10",
+ Tk_Offset(ColorbarBaseOptions, fontSize), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-fontweight", "fontweight", NULL, "normal",
+ Tk_Offset(ColorbarBaseOptions, fontWeight), 0, NULL},
+ {TK_CONFIG_SYNONYM, (char*)"-fontstyle", "fontweight", NULL, NULL, 0, 0},
+ {TK_CONFIG_STRING, (char*)"-fontslant", NULL, NULL, "roman",
+ Tk_Offset(ColorbarBaseOptions, fontSlant), 0, NULL},
+
+ {TK_CONFIG_BOOLEAN, (char*)"-numerics", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, numerics), 0, NULL},
+ {TK_CONFIG_BOOLEAN, (char*)"-space", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, space), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-ticks", NULL, NULL, "11",
+ Tk_Offset(ColorbarBaseOptions, ticks), 0, NULL},
+
+ {TK_CONFIG_INT, (char*)"-colors", NULL, NULL, "1024",
+ Tk_Offset(ColorbarBaseOptions, colors), 0, NULL},
+
+ {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL},
+};
+
+// Tk Static Structure
+
+static Tk_ItemType colorbarTrueColor16Type = {
+ (char*)"colorbartruecolor16", // name
+ sizeof(ColorbarBaseOptions), // size
+ ColorbarTrueColor16CreateProc, // configProc
+ colorbarTrueColor16Specs, // 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 ColorbarTrueColor16_Init(Tcl_Interp* interp)
+{
+ Tk_CreateItemType(&colorbarTrueColor16Type);
+ return TCL_OK;
+}
+
+int ColorbarTrueColor16CreateProc(Tcl_Interp* interp, Tk_Canvas canvas,
+ Tk_Item* item, int argc,
+ Tcl_Obj *const argv[])
+{
+ ColorbarTrueColor16* colorbar =
+ new ColorbarTrueColor16(interp, canvas, item);
+
+ // and set default configuration
+ if (colorbar->configure(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; ii<width; ii++) {
+ unsigned short r = colorCells[((int)(double(ii)/width*colorCount))*3+2];
+ unsigned short g = colorCells[((int)(double(ii)/width*colorCount))*3+1];
+ unsigned short b = colorCells[((int)(double(ii)/width*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_);
+
+ memcpy(data+ii*2, &a, 2);
+ }
+ }
+ else {
+ for (int ii=0; ii<width; ii++) {
+ unsigned short r = colorCells[((int)(double(ii)/width*colorCount))*3+2];
+ unsigned short g = colorCells[((int)(double(ii)/width*colorCount))*3+1];
+ unsigned short b = colorCells[((int)(double(ii)/width*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);
+ *(data+ii*2) = *(rr+1);
+ *(data+ii*2+1) = *(rr);
+ }
+ }
+
+ // --and duplicate for remaining rows
+ for (int jj=1; jj<height; jj++)
+ memcpy(data+(jj*xmap->bytes_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<width; ii++)
+ memcpy(data+ii*2, &a, 2);
+ }
+ }
+ else {
+ 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_);
+
+ unsigned char* rr = (unsigned char*)(&a);
+ for (int ii=0; ii<width; ii++) {
+ *(data+ii*2) = *(rr+1);
+ *(data+ii*2+1) = *(rr);
+ }
+ }
+ }
+}
+
diff --git a/tksao/colorbar/colorbartruecolor16.h b/tksao/colorbar/colorbartruecolor16.h
new file mode 100644
index 0000000..a3a60c3
--- /dev/null
+++ b/tksao/colorbar/colorbartruecolor16.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 __colorbartruecolor16_h__
+#define __colorbartruecolor16_h__
+
+#include "colorbar.h"
+#include "truecolor16.h"
+
+class ColorbarTrueColor16 : public Colorbar, TrueColor16 {
+private:
+ void updateColorsHorz();
+ void updateColorsVert();
+
+public:
+ ColorbarTrueColor16(Tcl_Interp*, Tk_Canvas, Tk_Item*);
+};
+
+#endif
diff --git a/tksao/colorbar/colorbartruecolor24.C b/tksao/colorbar/colorbartruecolor24.C
new file mode 100644
index 0000000..40e92c9
--- /dev/null
+++ b/tksao/colorbar/colorbartruecolor24.C
@@ -0,0 +1,335 @@
+// Copyright (C) 1999-2016
+// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
+// For conditions of distribution and use, see copyright notice in "copyright"
+
+#include "colorbartruecolor24.h"
+#include "util.h"
+
+// Tk Canvas Widget Function Declarations
+
+int ColorbarTrueColor24CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int,
+ Tcl_Obj *const []);
+
+// Colorbar Specs
+
+static Tk_CustomOption tagsOption = {
+ Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+};
+
+static Tk_ConfigSpec colorbarTrueColor24Specs[] = {
+
+ {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "colorbar",
+ Tk_Offset(ColorbarBaseOptions, cmdName),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, x), TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, y), TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512",
+ Tk_Offset(ColorbarBaseOptions, width),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "22",
+ Tk_Offset(ColorbarBaseOptions, height),
+ TK_CONFIG_OPTION_SPECIFIED, NULL},
+ {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw",
+ Tk_Offset(ColorbarBaseOptions, 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(ColorbarBaseOptions, helvetica), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier",
+ Tk_Offset(ColorbarBaseOptions, courier), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times",
+ Tk_Offset(ColorbarBaseOptions, times), 0, NULL},
+
+ {TK_CONFIG_BOOLEAN, (char*)"-orientation", NULL, NULL, "0",
+ Tk_Offset(ColorbarBaseOptions, orientation), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-size", NULL, NULL, "20",
+ Tk_Offset(ColorbarBaseOptions, size), 0, NULL},
+
+ {TK_CONFIG_STRING, (char*)"-font", NULL, NULL, "helvetica",
+ Tk_Offset(ColorbarBaseOptions, font), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-fontsize", NULL, NULL, "10",
+ Tk_Offset(ColorbarBaseOptions, fontSize), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-fontweight", "fontweight", NULL, "normal",
+ Tk_Offset(ColorbarBaseOptions, fontWeight), 0, NULL},
+ {TK_CONFIG_SYNONYM, (char*)"-fontstyle", "fontweight", NULL, NULL, 0, 0},
+ {TK_CONFIG_STRING, (char*)"-fontslant", NULL, NULL, "roman",
+ Tk_Offset(ColorbarBaseOptions, fontSlant), 0, NULL},
+
+ {TK_CONFIG_BOOLEAN, (char*)"-numerics", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, numerics), 0, NULL},
+ {TK_CONFIG_BOOLEAN, (char*)"-space", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, space), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-ticks", NULL, NULL, "11",
+ Tk_Offset(ColorbarBaseOptions, ticks), 0, NULL},
+
+ {TK_CONFIG_INT, (char*)"-colors", NULL, NULL, "1024",
+ Tk_Offset(ColorbarBaseOptions, colors), 0, NULL},
+
+ {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL},
+};
+
+// Tk Static Structure
+
+static Tk_ItemType colorbarTrueColor24Type = {
+ (char*)"colorbartruecolor24", // name
+ sizeof(ColorbarBaseOptions), // size
+ ColorbarTrueColor24CreateProc, // configProc
+ colorbarTrueColor24Specs, // 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 ColorbarTrueColor24_Init(Tcl_Interp* interp)
+{
+ Tk_CreateItemType(&colorbarTrueColor24Type);
+ return TCL_OK;
+}
+
+int ColorbarTrueColor24CreateProc(Tcl_Interp* interp, Tk_Canvas canvas,
+ Tk_Item* item, int argc,
+ Tcl_Obj *const argv[])
+{
+ ColorbarTrueColor24* colorbar = new ColorbarTrueColor24(interp,canvas,item);
+
+ // and set default configuration
+ if (colorbar->configure(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; ii<width; ii++) {
+ unsigned int r = colorCells[(int)(double(ii)/width*colorCount)*3+2];
+ unsigned int g = colorCells[(int)(double(ii)/width*colorCount)*3+1];
+ unsigned int b = colorCells[(int)(double(ii)/width*colorCount)*3];
+ unsigned int a = 0;
+ a |= r << rs_;
+ a |= g << gs_;
+ a |= b << bs_;
+
+ memcpy(data+ii*3, &a, 3);
+ }
+ }
+ else {
+ for (int ii=0; ii<width; ii++) {
+ unsigned int r = colorCells[(int)(double(ii)/width*colorCount)*3+2];
+ unsigned int g = colorCells[(int)(double(ii)/width*colorCount)*3+1];
+ unsigned int b = colorCells[(int)(double(ii)/width*colorCount)*3];
+ unsigned int a = 0;
+ a |= r << rs_;
+ a |= g << gs_;
+ a |= b << bs_;
+
+ unsigned char* rr = (unsigned char*)(&a);
+ *(data+ii*3) = *(rr+3);
+ *(data+ii*3+1) = *(rr+2);
+ *(data+ii*3+2) = *(rr+1);
+ }
+ }
+
+ // --and duplicate for remaining rows
+ for (int jj=1; jj<height; jj++)
+ memcpy(data+(jj*xmap->bytes_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<width; ii++)
+ memcpy(data+ii*3, &a, 3);
+ }
+ }
+ else {
+ 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_;
+
+ unsigned char* rr = (unsigned char*)(&a);
+ for (int ii=0; ii<width; ii++) {
+ *(data+ii*3) = *(rr+3);
+ *(data+ii*3+1) = *(rr+2);
+ *(data+ii*3+2) = *(rr+1);
+ }
+ }
+ }
+}
+
+void ColorbarTrueColor24::updateColors32Horz(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; ii<width; ii++) {
+ unsigned int r = colorCells[(int)(double(ii)/width*colorCount)*3+2];
+ unsigned int g = colorCells[(int)(double(ii)/width*colorCount)*3+1];
+ unsigned int b = colorCells[(int)(double(ii)/width*colorCount)*3];
+ unsigned int a = 0;
+#ifdef MAC_OSX_TK
+ a |= 0xff << 24;
+#endif
+ a |= r << rs_;
+ a |= g << gs_;
+ a |= b << bs_;
+
+ memcpy(data+ii*4, &a, 4);
+ }
+ }
+ else {
+ for (int ii=0; ii<width; ii++) {
+ unsigned int r = colorCells[(int)(double(ii)/width*colorCount)*3+2];
+ unsigned int g = colorCells[(int)(double(ii)/width*colorCount)*3+1];
+ unsigned int b = colorCells[(int)(double(ii)/width*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);
+ *(data+ii*4) = *(rr+3);
+ *(data+ii*4+1) = *(rr+2);
+ *(data+ii*4+2) = *(rr+1);
+ *(data+ii*4+3) = *(rr);
+ }
+ }
+
+ // --and duplicate for remaining rows
+ for (int jj=1; jj<height; jj++)
+ memcpy(data+(jj*xmap->bytes_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<width; ii++)
+ memcpy(data+ii*4, &a, 4);
+ }
+ }
+ else {
+ 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_;
+
+ unsigned char* rr = (unsigned char*)(&a);
+ for (int ii=0; ii<width; ii++) {
+ *(data+ii*4) = *(rr+3);
+ *(data+ii*4+1) = *(rr+2);
+ *(data+ii*4+2) = *(rr+1);
+ *(data+ii*4+3) = *(rr);
+ }
+ }
+ }
+}
+
diff --git a/tksao/colorbar/colorbartruecolor24.h b/tksao/colorbar/colorbartruecolor24.h
new file mode 100644
index 0000000..83ae12e
--- /dev/null
+++ b/tksao/colorbar/colorbartruecolor24.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 __colorbartruecolor24_h__
+#define __colorbartruecolor24_h__
+
+#include "colorbar.h"
+#include "truecolor24.h"
+
+class ColorbarTrueColor24 : public Colorbar, public TrueColor24 {
+private:
+ void updateColorsHorz();
+ void updateColorsVert();
+ void updateColors24Horz(int, int, char*);
+ void updateColors24Vert(int, int, char*);
+ void updateColors32Horz(int, int, char*);
+ void updateColors32Vert(int, int, char*);
+
+public:
+ ColorbarTrueColor24(Tcl_Interp*, Tk_Canvas, Tk_Item*);
+};
+
+#endif
diff --git a/tksao/colorbar/colorbartruecolor8.C b/tksao/colorbar/colorbartruecolor8.C
new file mode 100644
index 0000000..c51ca64
--- /dev/null
+++ b/tksao/colorbar/colorbartruecolor8.C
@@ -0,0 +1,169 @@
+// Copyright (C) 1999-2016
+// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
+// For conditions of distribution and use, see copyright notice in "copyright"
+
+#include "colorbartruecolor8.h"
+#include "util.h"
+
+// Tk Canvas Widget Function Declarations
+
+int ColorbarTrueColor8CreateProc(Tcl_Interp*, Tk_Canvas, Tk_Item*, int,
+ Tcl_Obj *const []);
+
+// Colorbar Specs
+
+static Tk_CustomOption tagsOption = {
+ Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+};
+
+static Tk_ConfigSpec colorbarTrueColor8Specs[] = {
+
+ {TK_CONFIG_STRING, (char*)"-command", NULL, NULL, "colorbar",
+ Tk_Offset(ColorbarBaseOptions, cmdName), TK_CONFIG_OPTION_SPECIFIED,
+ NULL},
+ {TK_CONFIG_INT, (char*)"-x", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, x), TK_CONFIG_OPTION_SPECIFIED,
+ NULL},
+ {TK_CONFIG_INT, (char*)"-y", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, y), TK_CONFIG_OPTION_SPECIFIED,
+ NULL},
+ {TK_CONFIG_INT, (char*)"-width", NULL, NULL, "512",
+ Tk_Offset(ColorbarBaseOptions, width), TK_CONFIG_OPTION_SPECIFIED,
+ NULL},
+ {TK_CONFIG_INT, (char*)"-height", NULL, NULL, "22",
+ Tk_Offset(ColorbarBaseOptions, height), TK_CONFIG_OPTION_SPECIFIED,
+ NULL},
+ {TK_CONFIG_ANCHOR, (char*)"-anchor", NULL, NULL, "nw",
+ Tk_Offset(ColorbarBaseOptions, 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(ColorbarBaseOptions, helvetica), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-courier", NULL, NULL, "courier",
+ Tk_Offset(ColorbarBaseOptions, courier), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-times", NULL, NULL, "times",
+ Tk_Offset(ColorbarBaseOptions, times), 0, NULL},
+
+ {TK_CONFIG_BOOLEAN, (char*)"-orientation", NULL, NULL, "0",
+ Tk_Offset(ColorbarBaseOptions, orientation), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-size", NULL, NULL, "20",
+ Tk_Offset(ColorbarBaseOptions, size), 0, NULL},
+
+ {TK_CONFIG_STRING, (char*)"-font", NULL, NULL, "helvetica",
+ Tk_Offset(ColorbarBaseOptions, font), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-fontsize", NULL, NULL, "10",
+ Tk_Offset(ColorbarBaseOptions, fontSize), 0, NULL},
+ {TK_CONFIG_STRING, (char*)"-fontweight", "fontweight", NULL, "normal",
+ Tk_Offset(ColorbarBaseOptions, fontWeight), 0, NULL},
+ {TK_CONFIG_SYNONYM, (char*)"-fontstyle", "fontweight", NULL, NULL, 0, 0},
+ {TK_CONFIG_STRING, (char*)"-fontslant", NULL, NULL, "roman",
+ Tk_Offset(ColorbarBaseOptions, fontSlant), 0, NULL},
+
+ {TK_CONFIG_BOOLEAN, (char*)"-numerics", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, numerics), 0, NULL},
+ {TK_CONFIG_BOOLEAN, (char*)"-space", NULL, NULL, "1",
+ Tk_Offset(ColorbarBaseOptions, space), 0, NULL},
+ {TK_CONFIG_INT, (char*)"-ticks", NULL, NULL, "11",
+ Tk_Offset(ColorbarBaseOptions, ticks), 0, NULL},
+
+ {TK_CONFIG_INT, (char*)"-colors", NULL, NULL, "1024",
+ Tk_Offset(ColorbarBaseOptions, colors), 0, NULL},
+
+ {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL},
+};
+
+// Tk Static Structure
+
+static Tk_ItemType colorbarTrueColor8Type = {
+ (char*)"colorbartruecolor8", // name
+ sizeof(ColorbarBaseOptions), // size
+ ColorbarTrueColor8CreateProc, // configProc
+ colorbarTrueColor8Specs, // 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 ColorbarTrueColor8_Init(Tcl_Interp* interp)
+{
+ Tk_CreateItemType(&colorbarTrueColor8Type);
+ return TCL_OK;
+}
+
+int ColorbarTrueColor8CreateProc(Tcl_Interp* interp, Tk_Canvas canvas,
+ Tk_Item* item, int argc,
+ Tcl_Obj *const argv[])
+{
+ ColorbarTrueColor8* colorbar = new ColorbarTrueColor8(interp, canvas, item);
+
+ // and set default configuration
+ if (colorbar->configure(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<width; ii++)
+ data[ii] =
+ ((colorCells[((int)(double(ii)/width*colorCount))*3] & bm_) >> 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; jj<height; jj++)
+ memcpy(data+(jj*xmap->bytes_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<width; ii++)
+ data[ii] = a;
+ }
+}
+
diff --git a/tksao/colorbar/colorbartruecolor8.h b/tksao/colorbar/colorbartruecolor8.h
new file mode 100644
index 0000000..977a2b4
--- /dev/null
+++ b/tksao/colorbar/colorbartruecolor8.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 __colorbartruecolor8_h__
+#define __colorbartruecolor8_h__
+
+#include "colorbar.h"
+#include "truecolor8.h"
+
+class ColorbarTrueColor8 : public Colorbar, TrueColor8 {
+private:
+ void updateColorsHorz();
+ void updateColorsVert();
+
+public:
+ ColorbarTrueColor8(Tcl_Interp*, Tk_Canvas, Tk_Item*);
+};
+
+#endif
diff --git a/tksao/colorbar/colormap.C b/tksao/colorbar/colormap.C
new file mode 100644
index 0000000..f8cc656
--- /dev/null
+++ b/tksao/colorbar/colormap.C
@@ -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"
+
+#include "colormap.h"
+#include "util.h"
+
+static int squenceID = 1;
+
+// ColorMapInfo
+
+ColorMapInfo::ColorMapInfo(Colorbar* p) : parent_(p)
+{
+ id = squenceID++;
+ name =NULL;
+ fileName =NULL;
+ next_ =NULL;
+ previous_ =NULL;
+}
+
+ColorMapInfo::~ColorMapInfo()
+{
+ if (name)
+ delete [] name;
+
+ if (fileName)
+ delete [] fileName;
+}
+
+void ColorMapInfo::setName(const char* n)
+{
+ if (name)
+ delete [] name;
+
+ name = dupstr(n);
+}
+
+void ColorMapInfo::setFileName(const char* n)
+{
+ if (fileName)
+ delete [] fileName;
+
+ fileName = dupstr(n);
+}
diff --git a/tksao/colorbar/colormap.h b/tksao/colorbar/colormap.h
new file mode 100644
index 0000000..d68a256
--- /dev/null
+++ b/tksao/colorbar/colormap.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 __colormap_h__
+#define __colormap_h__
+
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <iomanip>
+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 <string.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <iomanip>
+using namespace std;
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+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 <math.h>
+
+#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<size; i++) {
+ // generate in hsv
+ float frac = 1.0 - ((float)i / (float)(size - 1));
+
+ float h = frac * 360.0 + 270.0;
+ float s = fabs(sin (frac * 3.1416));
+ float v = pow((1.0 - frac), (1.0 / 3.0));
+
+ // convert to rgb
+ while (h >= 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 <inttypes.h>. 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 <inttypes.h>
+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 <iostream>
+#include <errno.h>
+#include <cstdlib>
+#include <cstring>
+/* 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 <FlexLexer.h>
+
+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 <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+
+ #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 <unistd.h>
+#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 <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+
+ #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 <FlexLexer.h>
+
+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 && index<size)
+ return (unsigned char)(colors[index]->red() * 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 && index<size)
+ return (unsigned char)(colors[index]->green() * 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 && index<size)
+ return (unsigned char)(colors[index]->blue() * 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 && index<size)
+ return (unsigned short)(colors[index]->green() * 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 && index<size)
+ return (unsigned short)(colors[index]->blue() * 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<RGBColor> 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 <inttypes.h>. 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 <inttypes.h>
+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 <iostream>
+#include <errno.h>
+#include <cstdlib>
+#include <cstring>
+/* 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 <FlexLexer.h>
+
+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 <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <ctype.h>
+
+ #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 <unistd.h>
+#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 <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <ctype.h>
+
+ #include "util.h"
+ #include "lutparser.H"
+
+ extern YYSTYPE* rgblval;
+ extern rgbFlexLexer* rgblexx;
+%}
+
+%x DISCARD
+
+D [0-9]
+E [Ee][+-]?{D}+
+
+/* rules */
+
+%%
+
+<DISCARD>[\n] { // special case-- #\n
+ BEGIN INITIAL;
+ yyless(0); // put back the terminator
+ strcpy(rgblval->str,""); // feed a blank string
+ return STRING;
+ }
+
+<DISCARD>[^\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>> { // 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 <string.h>
+#include <iostream>
+
+#include "lut.h"
+
+#undef yyFlexLexer
+#define yyFlexLexer rgbFlexLexer
+#include <FlexLexer.h>
+
+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 <stddef.h> /* 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 <libintl.h> /* 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 <alloca.h> /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include <malloc.h> /* 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 <stdlib.h> /* 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 <stdlib.h> /* 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 <stdio.h> /* 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 <string.h>
+#include <iostream>
+
+#include "lut.h"
+
+#undef yyFlexLexer
+#define yyFlexLexer rgbFlexLexer
+#include <FlexLexer.h>
+
+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 <real> numeric
+
+%token <real> REAL
+%token <integer> INT
+%token <str> 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 <stdlib.h>
+
+#include "colorbarbase.h"
+
+#undef yyFlexLexer
+#define yyFlexLexer cbFlexLexer
+#include <FlexLexer.h>
+
+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 <stddef.h> /* 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 <libintl.h> /* 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 <alloca.h> /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include <malloc.h> /* 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 <stdlib.h> /* 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 <stdlib.h> /* 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 <stdio.h> /* 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 <stdlib.h>
+
+#include "colorbarbase.h"
+
+#undef yyFlexLexer
+#define yyFlexLexer cbFlexLexer
+#include <FlexLexer.h>
+
+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 <real> numeric
+%type <integer> yesno
+%type <integer> pscolorspace
+
+%token <integer> INT
+%token <real> REAL
+%token <str> STRING
+%token <ptr> 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 <FlexLexer.h>
+
+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<LIColor>* 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<LIColor>* 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<LIColor> red;
+ List<LIColor> green;
+ List<LIColor> blue;
+ List<LIColor>* current;
+
+protected:
+ unsigned char getColorChar(int, int, List<LIColor>*);
+ unsigned short getColorShrt(int, int, List<LIColor>*);
+
+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 <inttypes.h>. 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 <inttypes.h>
+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 <iostream>
+#include <errno.h>
+#include <cstdlib>
+#include <cstring>
+/* 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 <FlexLexer.h>
+
+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 <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <ctype.h>
+
+ #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 <unistd.h>
+#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 <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <ctype.h>
+
+ #include "util.h"
+ #include "saoparser.H"
+
+ extern YYSTYPE* lilval;
+ extern liFlexLexer* lilexx;
+%}
+
+%x DISCARD
+
+D [0-9]
+E [Ee][+-]?{D}+
+
+/* rules */
+
+%%
+
+<DISCARD>[\n] { // special case-- #\n
+ BEGIN INITIAL;
+ yyless(0); // put back the terminator
+ strcpy(lilval->str,""); // feed a blank string
+ return STRING;
+ }
+
+<DISCARD>[^\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>> { // 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 <string.h>
+#include <iostream>
+
+#include "sao.h"
+
+#undef yyFlexLexer
+#define yyFlexLexer liFlexLexer
+#include <FlexLexer.h>
+
+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 <stddef.h> /* 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 <libintl.h> /* 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 <alloca.h> /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include <malloc.h> /* 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 <stdlib.h> /* 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 <stdlib.h> /* 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 <stdio.h> /* 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 <string.h>
+#include <iostream>
+
+#include "sao.h"
+
+#undef yyFlexLexer
+#define yyFlexLexer liFlexLexer
+#include <FlexLexer.h>
+
+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 <real> numeric
+
+%token <real> REAL
+%token <integer> INT
+%token <str> 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;}
+ ;
+%%