CMedit.C 12.94 KiB
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <memory.h>
#include <string.h>
#include <ctype.h>
#undef isspace
#include "CMedit.H"
#include "colorpatch.H"
#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
CMedit :: CMedit(int x, int y, int w, int h, const char *label)
: Fl_Gl_Window(x,y,w,h,label) {
init();
end();
}
int CMedit::fload( FILE *inf ) {
char line[256];
char *cp, *sp;
int count = -1;
int i, ix, ox, nix, prevox;
float rgba[4], hsba[4], phsba[4];
int lno;
static enum CMfield flds[4] = { HUE, SAT, BRIGHT, ALPHA };
int f;
char tc[2];
lno = 0;
this->postscale_ = 1;
this->postexpon_ = 1;
ox = 0;
while(fgets(line, sizeof(line), inf) != NULL) {
lno++;
for(cp = line; *cp && isspace(*cp); cp++)
;
if(*cp == '\0' || *cp == '\n')
continue;
sp = strstr(cp, "#Ascale");
if(sp != NULL) {
if(0==strncmp(sp, "#Ascale", 7)) {
*sp = '\0';
sp += 7;
if(*sp == '=' || *sp == ':')
sp++;
sscanf(sp, "%f%f", &this->postscale_, &this->postexpon_);
cp = sp; /* don't record this one as a comment */
}
}
if(*cp == '#') {
if(ncomments >= maxcomments) {
maxcomments *= 2;
comments = (char **)realloc( comments, maxcomments * sizeof(char *) );
}
comments[ncomments++] = strdup( line );
continue;
}
/* ``nnn:'' entries set the colormap pointer ... */
if(sscanf(line, "%d%1[:]", &nix, tc) == 2) {