Example #1
0
void
FFSControlFrameTexture::draw_level(CVIEWptr& v, int k)
{
    // Draw the control curves for the Patch at level k,
    // which is relative to the control Patch.

    // Get the level-k edge strip:
    if (!build_strip(k))
        return;

    assert(_strip != NULL);

    // Set line thickness and color

    // Get a scale factor s used to control line width and color.
    // s drops toward 0 exponentially with increasing level:
    double r = Config::get_var_dbl("CONTROL_FRAME_RATIO", 0.6,true);
    assert(r > 0 && r < 1);
    double s = pow(r, _strip->mesh()->subdiv_level());

    // Default top-level line thickness is 1.0:
    double top_w = 1.0;
    double w = top_w*s;
    glLineWidth(GLfloat(v->line_scale()*w));       // GL_LINE_BIT

    // choose a lightest color:
    //COLOR l = interp(_color, COLOR::white, 0.75);


    // With white lines get too light in FFSTexture
    //l = interp(_color, COLOR(.659,.576,.467), 0.75);

    // line color drifts toward the light color as level k increases:
    //COLOR c = interp(l, _color, s);
    //GL_COL(c, alpha());                  // GL_CURRENT_BIT
    GL_COL(_color, s/3);

    //paper
    //str_ptr tf = Config::JOT_ROOT() + "nprdata/paper_textures/simon.png";
    //str_ptr ret_tf;
    //TEXTUREptr paper;

    //paper = PaperEffect::get_texture(tf, ret_tf);

    //PaperEffect::begin_paper_effect(paper);
    //PaperEffect::begin_paper_effect(VIEW::peek()->get_use_paper());
    //for(int i=0; i < _strip->num(); i++){
    //   PaperEffect::paper_coord(NDCZpt(_strip->vert(i)->loc()).data());
    //   glTexCoord2dv(NDCZpt(_strip->vert(i)->loc()).data());
    //}

    //paper

    _strip->draw(_cb);

    //PaperEffect::end_paper_effect(paper);
}
Example #2
0
/* Return the instrument error code */
static inst_code
dtp41_read_strip(
inst *pp,
char *name,			/* Strip name (7 chars) */
int npatch,			/* Number of patches in the pass */
char *pname,		/* Pass name (3 chars) */
int sguide,			/* Guide number */
double pwid,		/* Patch length in mm (For DTP41) */
double gwid,		/* Gap length in mm (For DTP41) */
double twid,		/* Trailer length in mm (For DTP41T) */
ipatch *vals) {		/* Pointer to array of instrument patch values */
	dtp41 *p = (dtp41 *)pp;
	char tbuf[200], *tp;
	static char buf[MAX_RD_SIZE];
	int i, se;
	inst_code ev = inst_ok;
	int switch_trig = 0;
	int user_trig = 0;

	if (!p->gotcoms)
		return inst_no_coms;
	if (!p->inited)
		return inst_no_init;

	/* Configure for dynamic mode */
	p->lastmode = (p->lastmode & ~inst_mode_sub_mask) | inst_mode_strip;
	activate_mode(p);

	build_strip(p, tbuf, name, npatch, pname, sguide, pwid, gwid, twid);
	
	/* Send strip definition */
	if ((ev = dtp41_command(p, tbuf, buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

	if (p->trig == inst_opt_trig_user_switch) {

		/* Wait for the Read status, or a user trigger/abort */
		for (;;) {
			if ((ev = dtp41_command(p, "", buf, MAX_MES_SIZE, 0.5)) != inst_ok) {
				if ((ev & inst_mask) == inst_needs_cal)
					p->need_cal = 1;

				if ((ev & inst_imask) != DTP41_TIMEOUT) 
					return ev;			/* Instrument or comms error */

				/* Timed out */
				if (p->uicallback != NULL) {	/* Check for user trigger */
					if ((ev = p->uicallback(p->uic_cntx, inst_armed)) != inst_ok) {
						if (ev == inst_user_abort)
							return ev;		/* User abort */
						if (ev == inst_user_trig) {
							user_trig = 1;
							break;
						}
					}
				}

			} else {	/* Got read status - assume triggered */
				switch_trig = 1;
				break;					/* Switch activated */
			}
		}
		/* Notify of trigger */
		if (p->uicallback)
			p->uicallback(p->uic_cntx, inst_triggered); 

	} else if (p->trig == inst_opt_trig_user) {

		if (p->uicallback == NULL) {
			a1logd(p->log, 1, "dtp41: inst_opt_trig_user but no uicallback function set!\n");
			return inst_unsupported;
		}

		for (;;) {
			if ((ev = p->uicallback(p->uic_cntx, inst_armed)) != inst_ok) {
				if (ev == inst_user_abort)
					return ev;				/* Abort */
				if (ev == inst_user_trig) {
					user_trig = 1;
					break;					/* Trigger */
				}
			}
			msec_sleep(200);
		}
		/* Notify of trigger */
		if (p->uicallback)
			p->uicallback(p->uic_cntx, inst_triggered); 

	/* Progromatic Trigger */
	} else {
		/* Check for abort */
		if (p->uicallback != NULL
		 && (ev = p->uicallback(p->uic_cntx, inst_armed)) == inst_user_abort)
			return ev;				/* Abort */
	}

	/* Trigger a read if the switch has not been used */
	if (switch_trig == 0) {
		/* Do a strip read */
		if ((ev = dtp41_command(p, "RM\r", buf, MAX_MES_SIZE, 30.0)) != inst_ok) {
			if ((ev & inst_mask) == inst_needs_cal)
				p->need_cal = 1;
			return ev;
		}
	}

	/* Gather the results in D50_2 XYZ */
	if ((ev = dtp41_command(p, "0405TS\r", buf, MAX_RD_SIZE, 0.5 + npatch * 0.1)) != inst_ok)
		return ev; 	/* Strip misread */

	/* Parse the buffer */
	/* Replace '\r' with '\000' */
	for (tp = buf; *tp != '\000'; tp++) {
		if (*tp == '\r')
			*tp = '\000';
	}
	for (tp = buf, i = 0; i < npatch; i++) {
		if (*tp == '\000')
			return inst_protocol_error;
		if (sscanf(tp, " %lf %lf %lf ",
		           &vals[i].XYZ[0], &vals[i].XYZ[1], &vals[i].XYZ[2]) != 3) {
			if (sscanf(tp, " %lf %lf %lf ",
			           &vals[i].XYZ[0], &vals[i].XYZ[1], &vals[i].XYZ[2]) != 3) {
				return inst_protocol_error;
			}
		}
		vals[i].loc[0] = '\000';
		if ((p->mode & inst_mode_illum_mask) == inst_mode_transmission)
			vals[i].mtype = inst_mrt_transmissive;
		else
			vals[i].mtype = inst_mrt_reflective;
		vals[i].XYZ_v = 1;
		vals[i].sp.spec_n = 0;
		vals[i].duration = 0.0;
		tp += strlen(tp) + 1;
	}

	if (p->mode & inst_mode_spectral) {

		/* Gather the results in Spectral reflectance */
		if ((ev = dtp41_command(p, "0403TS\r", buf, MAX_RD_SIZE, 0.5 + npatch * 0.1)) != inst_ok)
			return ev; 	/* Strip misread */
	
		/* Parse the buffer */
		/* Replace '\r' with '\000' */
		for (tp = buf; *tp != '\000'; tp++) {
			if (*tp == '\r')
				*tp = '\000';
		}
		/* Get each patches spetra */
		for (tp = buf, i = 0; i < npatch; i++) {
			int j;
			char *tpp;
			if (strlen(tp) < (31 * 8 - 1)) {
				return inst_protocol_error;
			}

			/* Read the spectral value */
			for (tpp = tp, j = 0; j < 31; j++, tpp += 8) {
				char c;
				c = tpp[7];
				tpp[7] = '\000';
				vals[i].sp.spec[j] = atof(tpp);
				tpp[7] = c;
			}

			vals[i].sp.spec_n = 31;
			vals[i].sp.spec_wl_short = 400.0;
			vals[i].sp.spec_wl_long = 700.0;
			vals[i].sp.norm = 100.0;
			tp += strlen(tp) + 1;
		}
	}
	if (user_trig)
		return inst_user_trig;
	return inst_ok;
}
Example #3
0
/* Return the dtp error code */
static inst_code
dtp51_read_strip(
inst *pp,
char *name,			/* Strip name (up to first 7 chars used) */
int npatch,			/* Number of patches in the pass */
char *pname,		/* Pass name (up to first 3 chars used) */
int sguide,			/* Guide number */
double pwid,		/* Patch length in mm (For DTP41) */
double gwid,		/* Gap length in mm (For DTP41) */
double twid,		/* Trailer length in mm (For DTP41T) */
ipatch *vals) {		/* Pointer to array of instrument patch values */
	dtp51 *p = (dtp51 *)pp;
	char tbuf[200], *tp;
	static char buf[MAX_RD_SIZE];
	int i, rv;
	inst_code ev = inst_ok;

	build_strip(tbuf, name, npatch, pname, sguide);
	
	if ((rv = dtp51_fcommand(p, "0105DS\r", buf, MAX_RD_SIZE, '*', 1, 0.5)) != DTP51_OK)
		return interp_code(pp, rv); 

	/* Expect '*' as response */
	if (buf[0] != '*' || buf[1] != '\000')
		return inst_coms_fail;

	/* Send strip definition */
	if ((ev = dtp51_command(p, tbuf, buf, MAX_RD_SIZE, 4.0)) != inst_ok)
		return ev; 

	/* Do a strip read */
	if ((ev = dtp51_command(p, "5SW\r", buf, MAX_RD_SIZE, 1.5)) != inst_ok) {
		if ((ev & inst_mask) == inst_needs_cal)
			p->need_cal = 1;
		return ev;
	}

	/* Wait for the Read status, or a user abort - allow 5 munutes. */
	ev = dtp51_command(p, "", buf, MAX_RD_SIZE, 5 * 60.0);

#ifdef NEVER		/* Why was this being done /? */
	/* Soft reset the unit */
	dtp51_command(p, "0PR\r", buf, MAX_RD_SIZE); /* Soft Reset it */

	if (ev != inst_user_abort && ev != inst_user_term && ev != inst_user_cmnd)
		sleep(2);	/* Let it recover from reset */
#endif

	if (ev != inst_ok) {
		if ((ev & inst_mask) == inst_needs_cal)
			p->need_cal = 1;
		return ev; 	/* misread or user abort */
	}

	if (p->trig_return)
		printf("\n");

	/* Gather the results */
	if ((ev = dtp51_command(p, "TS\r", buf, MAX_RD_SIZE, 0.5 + npatch * 0.1)) != inst_ok)
		return ev;

	/* Parse the buffer */
	/* Replace '\r' with '\000' */
	for (tp = buf; *tp != '\000'; tp++) {
		if (*tp == '\r')
			*tp = '\000';
	}
	for (tp = buf, i = 0; i < npatch; i++) {
		if (*tp == '\000')
			return inst_protocol_error;
#ifdef NEVER	/* Lab */
		if (sscanf(tp, " L %lf a %lf b %lf ",
		           &vals[i].Lab[0], &vals[i].Lab[1], &vals[i].Lab[2]) != 3) {
			if (sscanf(tp, " l %lf a %lf b %lf ",
			           &vals[i].Lab[0], &vals[i].Lab[1], &vals[i].Lab[2]) != 3) {
				return inst_protocol_error;
			}
		}
		vals[i].XYZ_v = 0;
		vals[i].aXYZ_v = 0
		vals[i].Lab_v = 1;
		vals[i].sp.spec_n = 0;
		vals[i].duration = 0.0;
#else /* XYZ */
		if (sscanf(tp, " X %lf Y %lf Z %lf ",
		           &vals[i].XYZ[0], &vals[i].XYZ[1], &vals[i].XYZ[2]) != 3) {
			if (sscanf(tp, " x %lf y %lf z %lf ",
			           &vals[i].XYZ[0], &vals[i].XYZ[1], &vals[i].XYZ[2]) != 3) {
				return inst_protocol_error;
			}
		}
		vals[i].XYZ_v = 1;
		vals[i].aXYZ_v = 0;
		vals[i].Lab_v = 0;
		vals[i].sp.spec_n = 0;
		vals[i].duration = 0.0;
#endif
		tp += strlen(tp) + 1;
	}

#ifdef NEVER
	/* Disable the read microswitch */
	if ((ev = dtp51_command(p, "0SM\r", buf, MAX_RD_SIZE)) != inst_ok)
		return ev;
#endif

	return inst_ok;
}
Example #4
0
/* return non-zero on an error, with dtp error code */
static inst_code
dtp51_init_inst(inst *pp) {
	dtp51 *p = (dtp51 *)pp;
	static char tbuf[100], buf[MAX_MES_SIZE];
	int rv;
	inst_code ev = inst_ok;

	if (p->gotcoms == 0)
		return inst_internal_error;		/* Must establish coms before calling init */

	/* Reset it */
	if ((ev = dtp51_command(p, "0PR\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;
	sleep(2);	/* Let it recover from reset */

	/* Turn echoing of characters off */
	if ((ev = dtp51_command(p, "EC\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

	/* Get the model and version number */
	if ((ev = dtp51_command(p, "SV\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

	/* Check that it is a DTP51 or 52 */
	if (   strlen(buf) < 12
	    || strncmp(buf,"X-Rite DTP5",11) != 0
	    || (buf[11] != '1' && buf[11] != '2'))
		return inst_unknown_model;

	/* Set the A/D Conversion rate to normal */
	if ((ev = dtp51_command(p, "00AD\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

	/* Disable Bar code reading to save time */
	if ((ev = dtp51_command(p, "0BC\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

	/* Set the Calibration Check tolerance to default of 0.15D */
	if ((ev = dtp51_command(p, "0FCC\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

	/* Set Automatic Transmit off */
	if ((ev = dtp51_command(p, "0005CF\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

	/* Set Read Status on */
	if ((ev = dtp51_command(p, "1RS\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

	/* Set decimal pont on */
	if ((ev = dtp51_command(p, "0106CF\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

	/* Set color data separator to TAB */
	if ((ev = dtp51_command(p, "0207CF\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

	/* Set default strip format to off */
	if ((ev = dtp51_command(p, "0009CF\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

	/* Set extra digit resolution */
	if ((ev = dtp51_command(p, "010ACF\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

	/* Set data after pass to off */
	if ((ev = dtp51_command(p, "000BCF\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

#ifdef NEVER	/* Doesn't seem to work on DTP51 */
	/* Set the patch detection window to default HRW = 3, LRW 0.122% */
	if ((ev = dtp51_command(p, "2CW\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;
#endif

	/* Enable the LCD display */
	if ((ev = dtp51_command(p, "EL\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

	/* Enable the read microswitch */
	if ((ev = dtp51_command(p, "1SM\r", buf, MAX_MES_SIZE, 1.5)) != inst_ok)
		return ev;

	/* Set a strip length of 1, to ensure parsing is invalidated */
	build_strip(tbuf, "       ", 1, "   ", 30);
	
	if ((rv = dtp51_fcommand(p, "0105DS\r", buf, MAX_MES_SIZE, '*', 1, 0.5)) != DTP51_OK)
		return interp_code(pp, rv); 

	/* Expect '*' as response */
	if (buf[0] != '*' || buf[1] != '\000')
		return inst_coms_fail;

	/* Send strip definition */
	if ((ev = dtp51_command(p, tbuf, buf, MAX_MES_SIZE, 4.0)) != inst_ok)
		return ev;

	/* This is the only mode supported */
	p->trig = inst_opt_trig_switch;

	if (ev == inst_ok)
		p->inited = 1;

	return ev;
}