Exemplo n.º 1
0
static void img_nordic_triangle_x(cairo_t* cr,
		float val,
		const float _xc, const float _yc,
		const float _r2, const float scale) {
	float  c, s;
	if (val < 0.00f) val = 0.00f;
	if (val > 1.05f) val = 1.05f;
	val = (val - 0.5f) * 1.5708f;
	c = cosf (val);
	s = sinf (val);

	cairo_save(cr);
	cairo_translate (cr, _xc + s * _r2, _yc - c * _r2);
	cairo_rotate (cr, val);
	cairo_move_to (cr,  0.0, 10.0 * scale);
	cairo_line_to (cr,  6.9282 * scale,  -2.0 * scale);
	cairo_line_to (cr, -6.9282 * scale,  -2.0 * scale);
	cairo_close_path(cr);
	cairo_set_line_width (cr, 1.2 * scale);

	CairoSetSouerceRGBA(c_nrd);
	cairo_fill_preserve (cr);
	CairoSetSouerceRGBA(c_wht);
	cairo_stroke (cr);
	cairo_restore(cr);
}
Exemplo n.º 2
0
static void draw_bit_dist (cairo_t* cr, float x0, float y0, float w, float h, float val) {
	if (val < 0) {
		cairo_rectangle (cr, x0 + 2, y0, w - 3, h);
		CairoSetSouerceRGBA(c_gry);
		cairo_fill (cr);
	} else {
		cairo_rectangle (cr, x0 + 2, y0, w - 3, h * (1. - val));
		CairoSetSouerceRGBA(c_g20);
		cairo_fill (cr);
		cairo_rectangle (cr, x0 + 2, y0 + h, w - 3, -h * val);
		CairoSetSouerceRGBA(c_wht);
		cairo_fill (cr);
	}
}
Exemplo n.º 3
0
static bool draw_bit_box (BITui* ui, cairo_t* cr, float x0, float y0, float rd, int hit, int set) {
	const int scnt = ui->integration_spl;
	if ( (hit < 0 && scnt == ui->f_zero) || (hit == 0)) {
		cairo_set_source_rgba (cr, .5, .5, .5, 1.0);
	} else if (set == 0) {
		cairo_set_source_rgba (cr, .0, .0, .9, 1.0);
	} else if (set == scnt) {
		cairo_set_source_rgba (cr, .9, .0, .0, 1.0);
	} else if (3.f * set / (float)scnt > 2.f) {
		cairo_set_source_rgba (cr, .8, .5, .1, 1.0);
	} else if (3.f * set / (float)scnt < 1.f) {
		cairo_set_source_rgba (cr, .1, .6, .9, 1.0);
	} else {
		cairo_set_source_rgba (cr, .1, .9, .1, 1.0);
	}

	cairo_rectangle (cr, x0 + .5, y0 + .5, rd, rd);
	cairo_fill_preserve (cr);

	CairoSetSouerceRGBA(c_blk);
	cairo_set_line_width (cr, 1);
	cairo_stroke (cr);

	return TRUE;
}
Exemplo n.º 4
0
/** prepare drawing surfaces, render fixed background */
static void m0_create_surfaces(MF2UI* ui) {
	cairo_t* cr;
	const double ccc = ui->width / 2.0 + .5;
	const double rad = (ui->width - XOFF) * .5;

	if (ui->sf_ann) cairo_surface_destroy(ui->sf_ann);
	ui->sf_ann = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, ui->width, ui->height);
	cr = cairo_create (ui->sf_ann);
	cairo_rectangle (cr, 0, 0, ui->width, ui->height);
	CairoSetSouerceRGBA(ui->c_bg);
	cairo_fill (cr);
	cairo_destroy (cr);

	if (ui->sf_dat) cairo_surface_destroy(ui->sf_dat);
	ui->sf_dat = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, ui->width, ui->height);
	cr = cairo_create (ui->sf_dat);
	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
	cairo_set_source_rgba(cr, 0, 0, 0, 0.0);
	cairo_rectangle (cr, 0, 0, ui->width, ui->height);
	cairo_fill (cr);
	cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
	cairo_set_source_rgba(cr, 0, 0, 0, 1.0);
	cairo_arc (cr, ccc, ccc, rad, 0, 2.0 * M_PI);
	cairo_fill (cr);
	cairo_destroy (cr);
}
Exemplo n.º 5
0
static void bw_knob (cairo_t* cr)
{
	const double GED_CY = 33.5;
	float xlp, ylp;
	CairoSetSouerceRGBA(c_dlf);
	cairo_set_line_width(cr, 1.25);
	cairo_move_to (cr,  1 + BWX, GZLINE);
	cairo_line_to (cr,  8 + BWX, GZLINE);
	cairo_line_to (cr, 10 + BWX, GZLINE - 4);
	cairo_line_to (cr, 12 + BWX, GZLINE);
	cairo_line_to (cr, 19 + BWX, GZLINE);
	cairo_move_to (cr, 12 + BWX, GZLINE);
	cairo_line_to (cr, 10 + BWX, GZLINE + 4);
	cairo_line_to (cr,  8 + BWX, GZLINE);
	cairo_stroke (cr);

	cairo_move_to (cr, GED_WIDTH - BWX -  1, GZLINE);
	cairo_line_to (cr, GED_WIDTH - BWX -  4, GZLINE);
	cairo_line_to (cr, GED_WIDTH - BWX - 10, GZLINE - 4);
	cairo_line_to (cr, GED_WIDTH - BWX - 16, GZLINE);
	cairo_line_to (cr, GED_WIDTH - BWX - 19, GZLINE);
	cairo_move_to (cr, GED_WIDTH - BWX - 16, GZLINE);
	cairo_line_to (cr, GED_WIDTH - BWX - 10, GZLINE + 4);
	cairo_line_to (cr, GED_WIDTH - BWX -  4, GZLINE);
	cairo_stroke (cr);

	{ DIALDOTS(bw_to_dial (powf(2.f,  4 / 2.f)), .0, .5) }
	{ DIALDOTS(bw_to_dial (powf(2.f,  2 / 2.f)), .0, .5) }
	{ DIALDOTS(bw_to_dial (powf(2.f,  0 / 2.f)), .0, .5) }
	{ DIALDOTS(bw_to_dial (powf(2.f, -2 / 2.f)), .0, .5) }
	{ DIALDOTS(bw_to_dial (powf(2.f, -4 / 2.f)), .0, .5) }
	{ DIALDOTS(bw_to_dial (powf(2.f, -6 / 2.f)), .0, .5) }
	{ DIALDOTS(bw_to_dial (powf(2.f, -8 / 2.f)), .0, .5) }
}
Exemplo n.º 6
0
static void img_nordic(cairo_t* cr, float scale) {
	MAKELOCALVARS(scale);
	const float _rx = 155 * _sc;
	const float	_yl = 95 * _sc;

	int db; char buf[48];
	for (db = -36; db <= 12 ; db+=6) {
		float v = img_deflect_nordic(db);
		if (db == 0) {
			img_nordic_triangle(cr, v, _rs);
			img_needle_label(cr, "TEST\n", v, _rl);
			continue;
		}
		img_draw_needle(cr, v, _ri, _rl, c_wht, 1.5);
		if (db == 12) {
			continue;
		}
		sprintf(buf, "%+d\n", db);
		img_needle_label(cr, buf, v, _rl);
	}
	for (db = -33; db <= 12 ; db+=6) {
		float v = img_deflect_nordic(db);
		img_draw_needle(cr, v, _ri, _rs, c_wht, 1.5);
		if (db == 9) {
			sprintf(buf, "%+d", db);
			img_needle_label(cr, buf, v, _rl);
		}
	}

	cairo_arc (cr, _xc, _yc, _rx,
			img_radi(img_deflect_nordic(6)),
			img_radi(img_deflect_nordic(12)));

	cairo_set_line_width (cr, 12.5 * _sc);
	CairoSetSouerceRGBA(c_wht);
	cairo_stroke_preserve(cr);
	CairoSetSouerceRGBA(c_nrd);
	cairo_set_line_width (cr, 10 * _sc);
	cairo_stroke(cr);

	img_draw_needle(cr, img_deflect_nordic(6),  _rx - 12.5/2.0 * _sc, _ri, c_wht, 1.5);
	img_draw_needle(cr, img_deflect_nordic(12), _rx - 12.5/2.0 * _sc, _ri, c_wht, 1.5);

	CairoSetSouerceRGBA(c_wht);
	img_write_text(cr, "dB", img_fonthuge, _xc + .5, _yl, 0);
}
Exemplo n.º 7
0
static void bw_hs_knob (cairo_t* cr)
{
	const double GED_CY = 33.5;
	float xlp, ylp;
	CairoSetSouerceRGBA(c_dlf);
	cairo_set_line_width(cr, 1.25);
	cairo_move_to (cr, 18 + BWX, GZLINE - 3);
	cairo_line_to (cr, 15 + BWX, GZLINE - 3);
	cairo_line_to (cr,  5 + BWX, GZLINE);
	cairo_line_to (cr,  1 + BWX, GZLINE);
	cairo_move_to (cr,  5 + BWX, GZLINE);
	cairo_line_to (cr, 15 + BWX, GZLINE + 3);
	cairo_line_to (cr, 18 + BWX, GZLINE + 3);
	cairo_stroke (cr);

	cairo_move_to (cr, GED_WIDTH - BWX - 18, GZLINE);
	cairo_line_to (cr, GED_WIDTH - BWX - 12, GZLINE);
	cairo_line_to (cr, GED_WIDTH - BWX -  8, GZLINE - 3);
	cairo_line_to (cr, GED_WIDTH - BWX -  1, GZLINE - 3);
	cairo_move_to (cr, GED_WIDTH - BWX - 12, GZLINE);
	cairo_line_to (cr, GED_WIDTH - BWX -  9, GZLINE + 3);
	cairo_line_to (cr, GED_WIDTH - BWX -  1, GZLINE + 3);
	cairo_stroke (cr);

	CairoSetSouerceRGBA(c_ann);
	cairo_set_line_width (cr, 1.0);
	cairo_arc (cr, GED_CX + 0, GED_CY, GED_RADIUS + 2.0, -.25 * M_PI, .25 * M_PI);
	cairo_stroke (cr);
	cairo_arc (cr, GED_CX - 1, GED_CY, GED_RADIUS + 2.0, 0.75 * M_PI, 1.25 * M_PI);
	cairo_stroke (cr);
	CairoSetSouerceRGBA(c_dlf);

	{ DIALDOTS(  0.0, .0, .5) }
	{ DIALDOTS(1/6.f, .0, .5) }
	{ DIALDOTS(2/6.f, .0, .5) }
	{ DIALDOTS(3/6.f, .0, .5) }
	{ DIALDOTS(4/6.f, .0, .5) }
	{ DIALDOTS(5/6.f, .0, .5) }
	{ DIALDOTS(  1.0, .0, .5) }
}
Exemplo n.º 8
0
void img_needle_label_col_x(cairo_t* cr,
		const char *txt, const char *font,
		float val,
		const float _xc, const float _yc,
		const float _r2, const float * const col)
{
	float  c, s;
	if (val < 0.00f) val = 0.00f;
	if (val > 1.05f) val = 1.05f;
	val = (val - 0.5f) * 1.5708f;
	c = cosf (val);
	s = sinf (val);

	CairoSetSouerceRGBA(col);
	img_write_text(cr, txt, font, _xc + s * _r2, _yc - c * _r2,  val);
}
Exemplo n.º 9
0
static void annotation_txt(MF2UI *ui, RobTkDial * d, cairo_t *cr, const char *txt) {
	int tw, th;
	cairo_save(cr);
	PangoLayout * pl = pango_cairo_create_layout(cr);
	pango_layout_set_font_description(pl, ui->font[1]);
	pango_layout_set_text(pl, txt, -1);
	pango_layout_get_pixel_size(pl, &tw, &th);
	cairo_translate (cr, d->w_cx, d->w_height);
	cairo_translate (cr, -tw/2.0 - 0.5, -th);
	cairo_set_source_rgba (cr, .0, .0, .0, .7);
	rounded_rectangle(cr, -1, -1, tw+3, th+1, 3);
	cairo_fill(cr);
	CairoSetSouerceRGBA(c_wht);
	pango_cairo_layout_path(cr, pl);
	cairo_fill(cr);
	g_object_unref(pl);
	cairo_restore(cr);
	cairo_new_path(cr);
}
Exemplo n.º 10
0
static void img_draw_needle_x (
		cairo_t* cr, float val,
		const float _xc, const float _yc,
		const float _r1, const float _r2,
		const float * const col, const float lw)
{
	float  c, s;
	if (val < 0.00f) val = 0.00f;
	if (val > 1.05f) val = 1.05f;
	val = (val - 0.5f) * 1.5708f;
	c = cosf (val);
	s = sinf (val);
	cairo_new_path (cr);
	cairo_move_to (cr, _xc + s * _r1, _yc - c * _r1);
	cairo_line_to (cr, _xc + s * _r2, _yc - c * _r2);
	CairoSetSouerceRGBA(col);
	cairo_set_line_width (cr, lw);
	cairo_stroke (cr);

}
Exemplo n.º 11
0
static void create_surfaces(SFSUI* ui) {
	cairo_t* cr;
	ui->sf_ann = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, ui->width, ui->height);
	cr = cairo_create (ui->sf_ann);
	cairo_rectangle (cr, 0, 0, ui->width, ui->height);
	CairoSetSouerceRGBA(ui->c_bg);
	cairo_fill (cr);
	cairo_destroy (cr);

	ui->sf_dat = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, ui->width, ui->height);
	cr = cairo_create (ui->sf_dat);
	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
	cairo_set_source_rgba(cr, 0, 0, 0, 0.0);
	cairo_rectangle (cr, 0, 0, ui->width, ui->height);
	cairo_fill (cr);
	cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
	cairo_set_source_rgba(cr, 0, 0, 0, 1.0);
	rounded_rectangle (cr, SS_BORDER, SS_BORDER, SS_SIZE, SS_SIZE, SS_BORDER);
	cairo_fill (cr);
	cairo_destroy (cr);
}
Exemplo n.º 12
0
static void bw_hp_knob (cairo_t* cr)
{
	float xlp, ylp;
	CairoSetSouerceRGBA(c_dlf);
	cairo_set_line_width(cr, 1.25);
	cairo_move_to (cr,  1 + HLX, GZLINE + 3);
	cairo_curve_to (cr, 1 + HLX, GZLINE - 0, 11 + HLX, GZLINE - 1, 13 + HLX, GZLINE - 1);
	cairo_line_to (cr, 18 + HLX, GZLINE - 1);
	cairo_stroke (cr);

	cairo_move_to (cr, GED_WIDTH - HLX - 18, GZLINE + 3);
	cairo_line_to (cr, GED_WIDTH - HLX - 12, GZLINE - 3);
	cairo_line_to (cr, GED_WIDTH - HLX -  8, GZLINE - 1);
	cairo_line_to (cr, GED_WIDTH - HLX -  1, GZLINE - 1);
	cairo_stroke (cr);

	{ DIALDOTS(  0.0,             .0, .5) }
	{ DIALDOTS(hplp_to_dial(.71), .0, .5) }
	{ DIALDOTS(  0.5,             .0, .5) }
	{ DIALDOTS(hplp_to_dial(1.0), .0, .5) }
	{ DIALDOTS(  1.0,             .0, .5) }
}
Exemplo n.º 13
0
static void update_grid(SFSUI* ui) {
	cairo_t *cr = cairo_create (ui->sf_ann);

	cairo_rectangle (cr, 0, 0, ui->width, ui->height);
	CairoSetSouerceRGBA(ui->c_bg);
	cairo_fill (cr);

	cairo_set_line_width (cr, 1.0);

	rounded_rectangle (cr, SS_BORDER, SS_BORDER, SS_SIZE, SS_SIZE, SS_BORDER);
	cairo_set_source_rgba(cr, 0, 0, 0, 1.0);
	cairo_fill(cr);
	rounded_rectangle (cr, SS_BORDER-.5, SS_BORDER-.5, SS_SIZE+1, SS_SIZE+1, SS_BORDER);
	CairoSetSouerceRGBA(c_g90);
	cairo_stroke(cr);

	const double dash1[] = {1.0, 2.0};
	cairo_set_dash(cr, dash1, 2, 0);

	CairoSetSouerceRGBA(c_grd);

#define FREQ_ANN(FRQ, TXT) { \
	const float py = rintf(SS_BORDER + SS_SIZE * (1.0 - fast_log10(1.0 + 2 * FRQ * ui->log_rate / ui->rate) / ui->log_base)) + .5; \
	cairo_move_to(cr, SS_BORDER, py); \
	cairo_line_to(cr, SS_BORDER + SS_SIZE, py); \
	cairo_stroke(cr); \
	write_text_full(cr, TXT, ui->font[0], SS_SIZE, py, 0, -1, c_ahz); \
	}

	float freq = 62.5;
	while (freq < ui->rate / 2) {
		char txt[16];
		if (freq < 1000) {
			snprintf(txt, 16, "%d Hz", (int)ceil(freq));
		} else {
			snprintf(txt, 16, "%d KHz", (int)ceil(freq/1000.f));
		}
		FREQ_ANN(freq, txt);
		freq *= 2.0;
	}

#define LEVEL_ANN(LVL, TXT) { \
	const float dx =  .5 * SS_SIZE * (1 - powf(10, .05 * (LVL))); \
	const float p0 = .5 + rintf(SS_BORDER + .5 * SS_SIZE + dx); \
	const float p1 = .5 + rintf(SS_BORDER + .5 * SS_SIZE - dx); \
	cairo_move_to(cr, p0, SS_BORDER); \
	cairo_line_to(cr, p0, SS_BORDER + SS_SIZE); \
	cairo_stroke(cr); \
	cairo_move_to(cr, p1, SS_BORDER); \
	cairo_line_to(cr, p1, SS_BORDER + SS_SIZE); \
	cairo_stroke(cr); \
	write_text_full(cr, TXT, ui->font[0], p0, SS_BORDER + 3, -.5 * M_PI, -1, c_ahz); \
	write_text_full(cr, TXT, ui->font[0], p1, SS_BORDER + 3, -.5 * M_PI, -1, c_ahz); \
	}

	LEVEL_ANN(-1, "1dB");
	LEVEL_ANN(-3, "3dB");
	LEVEL_ANN(-6, "6dB");
	LEVEL_ANN(-10, "10dB");
	LEVEL_ANN(-20, "20dB");


	const double dash2[] = {1.0, 3.0};
	cairo_set_line_width(cr, 3.5);
	cairo_set_dash(cr, dash2, 2, 2);

	const float xmid = rintf(SS_BORDER + SS_SIZE *.5) + .5;
	cairo_move_to(cr, xmid, SS_BORDER);
	cairo_line_to(cr, xmid, SS_BORDER + SS_SIZE);
	cairo_stroke(cr);

	write_text_full(cr, "L",  ui->font[1], SS_BORDER + 6,           SS_BORDER + 12, 0, -2, c_ann);
	write_text_full(cr, "R",  ui->font[1], SS_BORDER + SS_SIZE - 6, SS_BORDER + 12, 0, -2, c_ann);

	cairo_destroy (cr);
}
Exemplo n.º 14
0
static bool expose_event (RobWidget* rw, cairo_t* cr, cairo_rectangle_t *ev) {
	BITui* ui = (BITui*)GET_HANDLE(rw);
	cairo_rectangle (cr, ev->x, ev->y, ev->width, ev->height);
	cairo_clip (cr);

	const int ww = rw->area.width;
	const int hh = rw->area.height;

	CairoSetSouerceRGBA(c_g30);
	cairo_rectangle (cr, 0, 0, ww, hh);
	cairo_fill (cr);

	if (!ui->m0_faceplate) {
		gen_faceplate (ui, ww, hh);
	}

	const int spc = (int) floorf ((ww - 28) / 28.) & ~1;
	const int rad = ceilf (spc * .75);
	const int x0r = rint (ww * .5 + 12 * spc);
	const int xpr = rint (ww * .5 - 13 * spc);

	const int spc_s = (int) floorf (ww / 45.) & ~1;
	const int rad_s = ceilf (spc_s * .75);
	const int x0r_s  = ww * .5 + 20 * spc_s;

	const int y0   = hh - 60 - rad_s - spc;
	const int y0_s = hh - 20 - rad_s;

	const int y0_g = 10;
	const int y1_g = y0 - 4;
	const int yh_g = y1_g - y0_g;

	// draw distribution
	if ((int)ui->integration_spl == ui->f_zero) { // all blank
		draw_bit_dist (cr, xpr, y0_g, rad, yh_g, -1);
		for (int k = 0; k < 23; ++k) {
			const float xp = x0r - rintf (spc * (.5 * (k / 8) + k));
			draw_bit_dist (cr, xp, y0_g, rad, yh_g, -1);
		}
	} else {
		const float scnt = ui->integration_spl;
		draw_bit_dist (cr, xpr, y0_g, rad, yh_g, ui->f_pos / scnt);
		for (int k = 0; k < 23; ++k) {
			const float xp = x0r - rintf (spc * (.5 * (k / 8) + k));
			const float v = ui->flt[k + BIM_DSET] / scnt;
			draw_bit_dist (cr, xp, y0_g, rad, yh_g, v);
		}
	}

	cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
	cairo_set_source_surface(cr, ui->m0_faceplate, 0, 0);
	cairo_paint (cr);

	/* quick glance boxes */
	// sign - bit
	draw_bit_box (ui, cr, xpr, y0, rad, -1, ui->f_pos);

	// "+" sign
	const float mid = .5 + rintf (spc * .75 * .5);
	const float span = ceilf (spc * .75 * .2);
	CairoSetSouerceRGBA(c_wht);
	cairo_set_line_width (cr, 1);
	cairo_move_to (cr, xpr + mid, y0 + mid - span);
	cairo_line_to (cr, xpr + mid, y0 + mid + span);
	cairo_stroke (cr);
	cairo_move_to (cr, xpr + mid - span, y0 + mid);
	cairo_line_to (cr, xpr + mid + span, y0 + mid);
	cairo_stroke (cr);

	// mantissa
	for (int k = 0; k < 23; ++k) {
		const float xp = x0r - rintf (spc * (.5 * (k / 8) + k));
		draw_bit_box (ui, cr, xp, y0, rad, -1, ui->flt[k + BIM_DSET]);
	}

	// magnitude
	for (int k = 0; k < 40; ++k) {
		const int o = k + 118;
		const float xp = .5 * (k / 8) + k;
		draw_bit_box (ui, cr, x0r_s - rintf (xp * spc_s), y0_s, rad_s, ui->flt[o + BIM_DHIT], ui->flt[o + BIM_DONE]);
	}

	if (ui->integration_spl == 0) {
		cairo_set_source_rgba (cr, 0, 0, 0, .6);
		cairo_rectangle (cr, 0, 0, ww, hh);
		cairo_fill (cr);
		write_text_full (cr, "<markup><b>No data available.</b></markup>",
				FONT(FONT_S), rintf(ww * .5f), rintf(hh * .5f), 0, 2, c_wht);
	}
	else if (ui->integration_spl >= 2147483647) {
		cairo_set_source_rgba (cr, .9, .9, .9, .5);
		cairo_rectangle (cr, 0, 0, ww, hh);
		cairo_fill (cr);
		write_text_full (cr, "<markup>Reached <b>2<sup><small>31</small></sup> sample limit.\nData acquisition suspended.</b></markup>",
				FONT(FONT_S), rintf(ww * .5f), rintf(hh * .5f), 0, 2, c_blk);
	} else if ((int)ui->integration_spl == ui->f_zero) { // all blank
		write_text_full (cr, "<markup><b>All samples are zero.</b></markup>",
				FONT(FONT_S), rintf(ww * .5f), rintf(y0_g + yh_g * .5f), 0, 2, c_wht);
	}
	return TRUE;
}
Exemplo n.º 15
0
/** draw frequency calibration circles
 * and on screen annotations - sample-rate dependent
 */
static void update_grid(MF2UI* ui) {
	const double ccc = ui->width / 2.0 + .5;
	const double rad = (ui->width - XOFF) * .5;
	cairo_t *cr = cairo_create (ui->sf_ann);

	cairo_rectangle (cr, 0, 0, ui->width, ui->height);
	CairoSetSouerceRGBA(ui->c_bg);
	cairo_fill (cr);

	cairo_set_line_width (cr, 1.0);

	cairo_arc (cr, ccc, ccc, rad, 0, 2.0 * M_PI);
	cairo_set_source_rgba(cr, 0, 0, 0, 1.0);
	cairo_fill_preserve(cr);
	CairoSetSouerceRGBA(c_g90);
	cairo_stroke(cr);

	const double dash1[] = {1.0, 2.0};
	cairo_set_dash(cr, dash1, 2, 0);

	CairoSetSouerceRGBA(c_grd);

	float freq = 62.5;
	while (freq < ui->rate / 2) {
		char txt[16];
		if (freq < 1000) {
			snprintf(txt, 16, "%d Hz", (int)ceil(freq));
		} else {
			snprintf(txt, 16, "%d KHz", (int)ceil(freq/1000.f));
		}

		{
			const float dr = ui->scale * PH_RAD * fast_log10(1.0 + 2 * freq * ui->log_rate / ui->rate) / ui->log_base;
			cairo_arc (cr, ccc, ccc, dr, 0, 2.0 * M_PI);
			cairo_stroke(cr);
			const float px = ccc + dr * sinf(M_PI * -.75);
			const float py = ccc - dr * cosf(M_PI * -.75);
			write_text_full(cr, txt, ui->font[0], px, py, M_PI * -.75, -2, c_ahz);
		}

		freq *= 2.0;
	}

	const double dash2[] = {1.0, 3.0};
	cairo_set_line_width(cr, 3.5);
	cairo_set_dash(cr, dash2, 2, 2);

	cairo_set_line_width(cr, 1.5);
	cairo_move_to(cr, ccc - rad, ccc);
	cairo_line_to(cr, ccc + rad, ccc);
	cairo_stroke(cr);

	cairo_set_line_width(cr, 3.5);
	cairo_move_to(cr, ccc, ccc - rad);
	cairo_line_to(cr, ccc, ccc + rad);
	cairo_stroke(cr);
	cairo_set_dash(cr, NULL, 0, 0);

	write_text_full(cr, "+L",  ui->font[0], ccc, ccc - rad * .92, 0, -2, c_ann);
	write_text_full(cr, "-L",  ui->font[0], ccc, ccc + rad * .92, 0, -2, c_ann);
	write_text_full(cr, "0\u00B0",  ui->font[0], ccc, ccc - rad * .80, 0, -2, c_ann);
	write_text_full(cr, "180\u00B0",  ui->font[0], ccc, ccc + rad * .80, 0, -2, c_ann);

	write_text_full(cr, "-R",  ui->font[0], ccc - rad * .92, ccc, 0, -2, c_ann);
	write_text_full(cr, "+R",  ui->font[0], ccc + rad * .92, ccc, 0, -2, c_ann);
	write_text_full(cr, "-90\u00B0",  ui->font[0], ccc - rad * .80, ccc, 0, -2, c_ann);
	write_text_full(cr, "+90\u00B0",  ui->font[0], ccc + rad * .80, ccc, 0, -2, c_ann);
	cairo_destroy (cr);
}
Exemplo n.º 16
0
static void gen_faceplate (BITui* ui, const int ww, const int hh) {
	assert(!ui->m0_faceplate);
	ui->m0_faceplate = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, ww, hh);
	cairo_t* cr = cairo_create (ui->m0_faceplate);

	cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
	cairo_paint (cr);
	cairo_set_operator (cr, CAIRO_OPERATOR_OVER);

	const int spc = (int) floorf ((ww - 28) / 28.) & ~1;
	const int rad = ceilf (spc * .75);
	const int mid = rint (spc * .75 * .5);
	const int x0r = rint (ww * .5 + 12 * spc);
	const int xpr = rint (ww * .5 - 13 * spc);

	const int spc_s = (int) floorf (ww / 45.) & ~1;
	const int rad_s = ceilf (spc_s * .75);
	const int x0r_s  = ww * .5 + 20 * spc_s;

	const int y0   = hh - 60 - rad_s - spc;
	const int y0_s = hh - 20 - rad_s;

	const int y0_g = 10;
	const int y1_g = y0 - 4;
	const int yh_g = y1_g - y0_g;

	// grid & annotations -- TODO statically allocate surface
	const float x0_g = xpr - 2;
	const float x1_b = x0r + rad + 2;
	const float x1_g = x1_b + mid + 2;
	const float yc_g = rintf (y0_g + .5 * yh_g);
	const float y6_g = rintf (y0_g +  yh_g * 2. / 3.);
	const float y3_g = rintf (y0_g +  yh_g / 3.);

	cairo_rectangle (cr, x1_b, y0_g, mid, y3_g);
	cairo_set_source_rgba (cr, .8, .5, .1, 1.0);
	cairo_fill (cr);
	cairo_rectangle (cr, x1_b, y3_g, mid, y6_g - y3_g);
	cairo_set_source_rgba (cr, .1, .9, .1, 1.0);
	cairo_fill (cr);
	cairo_rectangle (cr, x1_b, y6_g, mid, y1_g - y6_g);
	cairo_set_source_rgba (cr, .1, .6, .9, 1.0);
	cairo_fill (cr);

	cairo_set_line_width (cr, 2);
	cairo_move_to (cr, x1_b, y0_g);
	cairo_line_to (cr, x1_b + mid, y0_g);
	cairo_set_source_rgba (cr, .9, .0, .0, 1.0);
	cairo_stroke (cr);
	cairo_move_to (cr, x1_b, y0_g + yh_g);
	cairo_line_to (cr, x1_b + mid, y0_g + yh_g);
	cairo_set_source_rgba (cr, .0, .0, .9, 1.0);
	cairo_stroke (cr);

	CairoSetSouerceRGBA(c_g80);
	cairo_set_line_width (cr, 1);

	cairo_save (cr);
	double dash = 1;
	cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
	cairo_set_dash (cr, &dash, 1, 0);

	cairo_move_to (cr, x0_g, y0_g - .5);
	cairo_line_to (cr, x1_b, y0_g - .5);
	cairo_stroke (cr);

	cairo_move_to (cr, x0_g, .5 + yc_g);
	cairo_line_to (cr, x0_g + spc + 4, .5 + yc_g);
	cairo_stroke (cr);

	cairo_move_to (cr, x0_g, .5 + y6_g);
	cairo_line_to (cr, x1_b, .5 + y6_g);
	cairo_stroke (cr);

	cairo_move_to (cr, x0_g, .5 + y3_g);
	cairo_line_to (cr, x1_b, .5 + y3_g);
	cairo_stroke (cr);

	cairo_move_to (cr, x0_g, y1_g + .5);
	cairo_line_to (cr, x1_b, y1_g + .5);
	cairo_stroke (cr);

	cairo_restore (cr);

	cairo_move_to (cr, 1.5 + rintf (x0r_s - 33 * spc_s), y0_s - 1.5);
	cairo_line_to (cr, 1.5 + rintf (x0r_s - 33 * spc_s), y0_s + rad_s + 3.5);
	cairo_line_to (cr, .5 + rintf (x0r_s - 35.5 * spc_s), y0_s + rad_s + 3.5);
	cairo_stroke (cr);


	write_text_full (cr, ">1.0",
				FONT(FONT_M), x0r_s - 33.0 * spc_s, hh - 2, 0, 4, c_wht);
	write_text_full (cr, "<markup>2<small><sup>-32</sup></small></markup>",
				FONT(FONT_M), x0r_s + 0.5 * spc_s, hh - 2, 0, 5, c_wht);
	write_text_full (cr, "<markup>2<small><sup>-24</sup></small></markup>",
				FONT(FONT_M), x0r_s - 8.0 * spc_s, hh - 2, 0, 5, c_wht);
	write_text_full (cr, "<markup>2<small><sup>-16</sup></small></markup>",
				FONT(FONT_M), x0r_s - 16.5 * spc_s, hh - 2, 0, 5, c_wht);
	write_text_full (cr, "<markup>2<small><sup>-8</sup></small></markup>",
				FONT(FONT_M), x0r_s - 25.0 * spc_s, hh - 2, 0, 5, c_wht);
	write_text_full (cr, "<markup>2<small><sup>7</sup></small></markup>",
				FONT(FONT_M), x0r_s - 40.5 * spc_s, hh - 2, 0, 5, c_wht);

	write_text_full (cr, "% time bit is set",
				FONT(FONT_M), x1_g, yc_g, -.5 * M_PI, 8, c_wht);

	write_text_full (cr, "100%", FONT(FONT_M), x0_g - 2, y0_g, 0, 1, c_wht);
	write_text_full (cr, "50%", FONT(FONT_M), x0_g - 2, yc_g, 0, 1, c_wht);
	write_text_full (cr, "0%", FONT(FONT_M), x0_g - 2, y1_g, 0, 1, c_wht);

	// sep
	int ysep = .5 * (y0 + rad + y0_s);
	CairoSetSouerceRGBA(c_g60);
	cairo_move_to (cr, 15, ysep + .5);
	cairo_line_to (cr, ww - 30 , ysep + .5);
	cairo_stroke (cr);
	write_text_full (cr, "Sign & Mantissa (23bit significand)", FONT(FONT_S), ww * .5, ysep - 2, 0, 5, c_wht);
	write_text_full (cr, "Full Scale", FONT(FONT_S), ww * .5, ysep + 3, 0, 8, c_wht);

	write_text_full (cr, ui->nfo, FONT(FONT_M), 2, hh -2, 1.5 * M_PI, 9, c_gry);

	cairo_destroy (cr);
}
Exemplo n.º 17
0
static void img_draw_vu(cairo_t* cr, float scale) {
	MAKELOCALVARS(scale);
	const float _rx = 155 * _sc;
	const float	_yl = 95 * _sc;

	sprintf(img_fontname, "Sans %d", (int)rint(_rn / 21)); // XXX

	const float percZ = img_deflect_vu(-60);
	const float percS = (img_deflect_vu(0) - percZ)/10.0;
	for (int pc = 0; pc <= 10; ++pc) {
		img_draw_needle(cr, percZ + pc * percS,  _ri, _rs, c_blk, 1.5);
		if ((pc%2) == 0) {
			char buf[8];
			if (pc==10)
				sprintf(buf, "  100%%");
			else
				sprintf(buf, "%d", pc*10);
			img_needle_label_col(cr, buf, percZ + pc * percS, _rx, c_blk);
		}
	}

	sprintf(img_fontname, "Sans Bold %d", (int)rint(_rl/20));

	CairoSetSouerceRGBA(c_blk);

	cairo_arc (cr, _xc, _yc, _rs,
			img_radi(img_deflect_vu(-60)),
			img_radi(img_deflect_vu(0)));
	cairo_set_line_width (cr, 1.5 * _sc);
	cairo_stroke(cr);

	cairo_arc (cr, _xc, _yc, _rs + .75 * _sc,
			img_radi(img_deflect_vu(0)),
			img_radi(img_deflect_vu(3)));
	cairo_set_line_width (cr, 3.0 * _sc);
	CairoSetSouerceRGBA(c_nvu);
	cairo_stroke(cr);

	img_draw_needle(cr, img_deflect_vu(-60), _rs, _rl, c_blk, 1.5);
	img_draw_needle(cr, img_deflect_vu(-20), _rs, _rl, c_blk, 1.5);
	img_draw_needle(cr, img_deflect_vu(-10), _rs, _rl, c_blk, 1.5);
	img_draw_needle(cr, img_deflect_vu(-7),  _rs, _rl, c_blk, 1.5);
	img_draw_needle(cr, img_deflect_vu(-6),  _rs, _rl, c_blk, 1.5);
	img_draw_needle(cr, img_deflect_vu(-5),  _rs, _rl, c_blk, 1.5);
	img_draw_needle(cr, img_deflect_vu(-4),  _rs, _rl, c_blk, 1.5);
	img_draw_needle(cr, img_deflect_vu(-3),  _rs, _rl, c_blk, 1.5);
	img_draw_needle(cr, img_deflect_vu(-2),  _rs, _rl, c_blk, 1.5);
	img_draw_needle(cr, img_deflect_vu(-1),  _rs, _rl, c_blk, 1.5);

	img_draw_needle(cr, img_deflect_vu(0),  _rs-.75*_sc, _rl, c_nrd, 1.5);
	img_draw_needle(cr, img_deflect_vu(1),  _rs, _rl, c_nrd, 1.5);
	img_draw_needle(cr, img_deflect_vu(2),  _rs, _rl, c_nrd, 1.5);
	img_draw_needle(cr, img_deflect_vu(3),  _rs-.75*_sc, _rl, c_nrd, 1.5);

	img_needle_label_col(cr, "-20\n", img_deflect_vu(-20), _rl, c_blk);
	img_needle_label_col(cr,  "10\n", img_deflect_vu(-10), _rl, c_blk);
	img_needle_label_col(cr,   "7\n", img_deflect_vu(-7), _rl, c_blk);
	img_needle_label_col(cr,   "5\n", img_deflect_vu(-5), _rl, c_blk);
	img_needle_label_col(cr,   "3\n", img_deflect_vu(-3), _rl, c_blk);
	img_needle_label_col(cr,   "2\n", img_deflect_vu(-2), _rl, c_blk);
	img_needle_label_col(cr,   "1\n", img_deflect_vu(-1), _rl, c_blk);
	img_needle_label_col(cr,   "0\n", img_deflect_vu(0), _rl, c_red);
	img_needle_label_col(cr,   "1\n", img_deflect_vu(1), _rl, c_red);
	img_needle_label_col(cr,   "2\n", img_deflect_vu(2), _rl, c_red);
	img_needle_label_col(cr,  "+3\n", img_deflect_vu(3), _rl, c_red);

	CairoSetSouerceRGBA(c_blk);
	img_write_text(cr, "VU", img_fonthuge, _xc + .5, _yl, 0);
}
Exemplo n.º 18
0
void img_draw_din(cairo_t* cr, float scale) {
	MAKELOCALVARS(scale);
	const float _rf = 164 * _sc;
	const float _rg = 176 * _sc;
	const float _rd = 190 * _sc;
	const float	_yl = 95 * _sc;

	CairoSetSouerceRGBA(c_wht);
	cairo_arc (cr, _xc, _yc, _rs,
			img_radi(img_deflect_din(-60)),
			img_radi(img_deflect_din(6)));
	cairo_set_line_width (cr, 1.5 * _sc);
	cairo_stroke(cr);

	cairo_arc (cr, _xc, _yc, _rs+3.5*_sc,
			img_radi(img_deflect_din(0)),
			img_radi(img_deflect_din(6)));
	CairoSetSouerceRGBA(c_nvu);
	cairo_set_line_width (cr, 5.5 * _sc);
	cairo_stroke(cr);

	img_draw_needle(cr, img_deflect_din(-60), _ri, _rg, c_wht, 1.5);
	img_draw_needle(cr, img_deflect_din(-50), _rs, _rd, c_wht, 1.5);
	img_draw_needle(cr, img_deflect_din(-45), _rs, _rg, c_wht, 1.5);
	img_draw_needle(cr, img_deflect_din(-40), _rs, _rd, c_wht, 1.5);
	img_draw_needle(cr, img_deflect_din(-35), _rs, _rg, c_wht, 1.5);
	img_draw_needle(cr, img_deflect_din(-40), _rs, _rd, c_wht, 1.5);
	img_draw_needle(cr, img_deflect_din(-35), _rs, _rg, c_wht, 1.5);
	img_draw_needle(cr, img_deflect_din(-30), _rs, _rd, c_wht, 1.5);
	img_draw_needle(cr, img_deflect_din(-25), _rs, _rg, c_wht, 1.5);
	img_draw_needle(cr, img_deflect_din(-20), _rs, _rd, c_wht, 1.5);
	img_draw_needle(cr, img_deflect_din(-15), _rs, _rg, c_wht, 1.5);
	img_draw_needle(cr, img_deflect_din(-10), _rs, _rd, c_wht, 1.5);
	img_draw_needle(cr, img_deflect_din( -9), _rs-.75*_sc, _rl, c_red, 1.5);
	img_draw_needle(cr, img_deflect_din( -5), _rs, _rd, c_wht, 1.5);

	for (int d = -4; d<0; d++) {
		img_draw_needle(cr, img_deflect_din(d), _rs, _rg, c_wht, 1.5);
	}
	for (int d = 1; d<=5; d++) {
		img_draw_needle(cr, img_deflect_din(d), _rs, _rg, c_wsh, 1.5);
	}

	img_draw_needle(cr, img_deflect_din(  0), _rf, _rd, c_red, 1.5);
	img_draw_needle(cr, img_deflect_din(  5), _rs, _rd, c_wht, 1.5);
	img_draw_needle(cr, img_deflect_din(  6), _ri, _rg, c_wht, 1.5);

	img_draw_needle(cr, img_deflect_din(    -40), _rf, _rs, c_wht, 1.5); //  1 %
	img_draw_needle(cr, img_deflect_din(-33.979), _rf, _rs, c_wht, 1.5); //  2 %
	img_draw_needle(cr, img_deflect_din(-30.457), _rf, _rs, c_wht, 1.5); //  3 %
	img_draw_needle(cr, img_deflect_din(-26.021), _rf, _rs, c_wht, 1.5); //  5 %
	img_draw_needle(cr, img_deflect_din(    -20), _rf, _rs, c_wht, 1.5); // 10 %
	img_draw_needle(cr, img_deflect_din(-16.478), _rf, _rs, c_wht, 1.5); // 15 %
	img_draw_needle(cr, img_deflect_din(-13.979), _rf, _rs, c_wht, 1.5); // 20 %
	img_draw_needle(cr, img_deflect_din(-10.458), _rf, _rs, c_wht, 1.5); // 30 %
	img_draw_needle(cr, img_deflect_din(-6.0205), _rf, _rl, c_red, 1.5); // 50 %

	sprintf(img_fontname, "Sans %dpx", (int)rint(_rn / 19.));

	img_needle_label_col(cr,  "\n200", img_deflect_din(6.0205), _ri, c_wht);
	img_needle_label_col(cr,  "\n100", img_deflect_din(0     ), _ri, c_red);
	img_needle_label_col(cr,  "\n50", img_deflect_din(-6.0205), _ri, c_red);
	img_needle_label(cr,      "\n30", img_deflect_din(-10.458), _ri);
	img_needle_label(cr,      "\n10", img_deflect_din(    -20), _ri);
	img_needle_label(cr,       "\n5", img_deflect_din(-26.021), _ri);
	img_needle_label(cr,       "\n3", img_deflect_din(-30.457), _ri);
	img_needle_label(cr,       "\n1", img_deflect_din(    -40), _ri);
	img_needle_label(cr,       "\n0", img_deflect_din(    -60), _ri);

	sprintf(img_fontname, "Sans Bold %dpx", (int)rint(_rn / 19.)); // XXX

	img_needle_label(cr, "-50\n", img_deflect_din(-50), _rd);
	img_needle_label(cr, "-30\n", img_deflect_din(-30), _rd);
	img_needle_label(cr, "-20\n", img_deflect_din(-20), _rd);
	img_needle_label(cr, "-10\n", img_deflect_din(-10), _rd);
	img_needle_label(cr,  "-9\n", img_deflect_din( -9), _rl);
	img_needle_label(cr,  "-5\n", img_deflect_din( -5), _rd);
	img_needle_label(cr,   "0\n", img_deflect_din(  0), _rd);
	img_needle_label(cr,  "+5\n", img_deflect_din(  5), _rd);

	CairoSetSouerceRGBA(c_wht);
	img_write_text(cr, "dB", img_fonthuge, _xc + .5, _yl, 0);
	img_write_text(cr, "\n\n%", img_fonthuge, _xc + .5, _yl, 0);
}
Exemplo n.º 19
0
static void img_phase(cairo_t* cr, float scale) {
	MAKELOCALVARS(scale);
	const float _rx = 155 * _sc;
	const float	_yl = 95 * _sc;

	CairoSetSouerceRGBA(c_nrd);
	cairo_arc (cr, _xc, _yc, _ri+5*_sc, -M_PI/2 - M_PI/4, -M_PI/2 );
	cairo_set_line_width (cr, 10*_sc);
	cairo_stroke (cr);

	CairoSetSouerceRGBA(c_ngr);
	cairo_arc (cr, _xc, _yc, _ri+5*_sc, -M_PI/2, -M_PI/2 + M_PI/4 );
	cairo_set_line_width (cr, 10*_sc);
	cairo_stroke (cr);

	cairo_save(cr);
	cairo_arc (cr, _xc, _yc, _ri+10*_sc, -M_PI/2 - M_PI/4, -M_PI/2 + M_PI/4 );
	cairo_arc_negative (cr, _xc, _yc, _ri, -M_PI/2 + M_PI/4, -M_PI/2 - M_PI/4);
	cairo_close_path(cr);
	cairo_clip(cr);

#if 1 // S*fam
	cairo_arc (cr, _xc, _yc, _rs, -M_PI/2 - M_PI/8, -M_PI/2 + M_PI/8 );
	cairo_arc_negative (cr, 200*_sc, 129.5*_sc, 80*_sc, -M_PI/2 + M_PI/36 , -M_PI/2 - M_PI/8);
	cairo_arc_negative(cr, _xc, _yc, _ri, -M_PI/2,  -M_PI/2 - M_PI/36);
	cairo_arc_negative(cr, 99*_sc, 129.5*_sc, 80.5*_sc, -M_PI/2 + M_PI/8  , -M_PI/2 - M_PI/36);
	CairoSetSouerceRGBA(c_nyl);
	cairo_fill(cr);
#endif
	cairo_restore(cr);

	CairoSetSouerceRGBA(c_wht);
	cairo_arc (cr, _xc, _yc, _ri+10*_sc, -M_PI/2 - M_PI/8, -M_PI/2 + M_PI/8 );
	cairo_set_line_width (cr, .5 * _sc);
	cairo_stroke (cr);

	cairo_arc (cr, _xc, _yc, _ri, -M_PI/2 - M_PI/4, -M_PI/2 + M_PI/4 );
	cairo_set_line_width (cr, 1 * _sc);
	cairo_stroke (cr);

	int v;
	for (v = 0; v <= 20 ; v++) {
		if (v == 0 || v == 5 || v == 10 || v == 15 || v == 20) {
			continue;
		} else {
			img_draw_needle(cr, v/20.0, _ri, _rs, c_wsh, 1.0);
		}
	}

	img_draw_needle(cr, 0.0,  _rx, _rl-5, c_wht, 1.5);
	img_draw_needle(cr, 0.25, _rx, _rl-5, c_wht, 1.5);
	img_draw_needle(cr, 0.5,  _rx, _rl-5, c_wht, 1.5);
	img_draw_needle(cr, 0.75, _rx, _rl-5, c_wht, 1.5);
	img_draw_needle(cr, 1.0,  _rx, _rl-5, c_wht, 1.5);

	sprintf(img_fontname, "Sans Bold %dpx", (int)rint(_rl/20));

	img_needle_label(cr, "-1",     0, _rs-24*_sc);
	img_needle_label(cr, "-0.5", .25, _rs-24*_sc);
	img_needle_label(cr,  "0",   0.5, _rs-24*_sc);
	img_needle_label(cr, "+0.5", .75, _rs-24*_sc);
	img_needle_label(cr, "+1",   1.0, _rs-24*_sc);

	img_needle_label(cr,"   180\u00B0\n",   0, _rl);
	img_needle_label(cr,  " 135\u00B0\n", .25, _rl);
	img_needle_label(cr,   " 90\u00B0\n", 0.5, _rl);
	img_needle_label(cr,   " 45\u00B0\n", .75, _rl);
	img_needle_label(cr,    " 0\u00B0\n", 1.0, _rl);

	CairoSetSouerceRGBA(c_wht);
	img_write_text(cr, "Corr", img_fonthuge, _xc + .5, _yl, 0);
}
Exemplo n.º 20
0
/** draw level-range display
 * depends on gain (dial) and cutoff
 */
static void update_annotations(MF2UI* ui) {
	cairo_t* cr = cairo_create (ui->sf_gain);

	cairo_rectangle (cr, 0, 0, ANN_W, 40);
	CairoSetSouerceRGBA(ui->c_bg);
	cairo_fill (cr);

	rounded_rectangle (cr, 3, 3 , ANN_W - 6, ANN_H - 6, 6);
	if (ui->drag_cutoff_x >= 0 || ui->prelight_cutoff) {
		cairo_set_source_rgba(cr, .15, .15, .15, 1.0);
	} else {
		cairo_set_source_rgba(cr, .0, .0, .0, 1.0);
	}
	cairo_fill (cr);

	cairo_set_line_width (cr, 1.0);
	const uint32_t mxw = ANN_W - XOFF * 2 - 36;
	const uint32_t mxo = XOFF + 18;
	const float cutoff = ui->db_cutoff;
	const uint32_t   cutoff_m = floor(mxw * (MIN_CUTOFF - cutoff) / MIN_CUTOFF);
	assert(cutoff_m < mxw);
	const uint32_t   cutoff_w = mxw - cutoff_m;

	for (uint32_t i=0; i < mxw; ++i) {
		float clr[3];
		if (i < cutoff_m) {
			clr[0] = clr[1] = clr[2] = .1;
		} else {
			const float pk = (i-cutoff_m) / (float)cutoff_w;
			hsl2rgb(clr, .68 - .72 * pk, .9, .2 + pk * .4);
		}

		cairo_set_source_rgba(cr, clr[0], clr[1], clr[2], 1.0);

		cairo_move_to(cr, mxo + i + .5, ANN_B - 5);
		cairo_line_to(cr, mxo + i + .5, ANN_B);
		cairo_stroke(cr);
	}

	cairo_set_source_rgba(cr, .8, .8, .8, .8);

	const float gain = robtk_dial_get_value(ui->gain);
	for (int32_t db = MIN_CUTOFF; db <=0 ; db+= 10) {
		char dbt[16];
		if (db == 0) {
			snprintf(dbt, 16, "\u2265%+.0fdB", (db - gain));
		} else {
			snprintf(dbt, 16, "%+.0fdB", (db - gain));
		}
		write_text_full(cr, dbt, ui->font[0], mxo + rint(mxw * (-MIN_CUTOFF + db) / -MIN_CUTOFF), ANN_B - 14 , 0, 2, c_wht);
		cairo_move_to(cr, mxo + rint(mxw * (-MIN_CUTOFF + db) / -MIN_CUTOFF) + .5, ANN_B - 7);
		cairo_line_to(cr, mxo + rint(mxw * (-MIN_CUTOFF + db) / -MIN_CUTOFF) + .5, ANN_B);
		cairo_stroke(cr);
	}

	/* black overlay above low-end cutoff */
	if (ui->db_cutoff > MIN_CUTOFF && (ui->drag_cutoff_x >= 0 || ui->prelight_cutoff)) {
		const float cox = rint(mxw * (ui->db_cutoff - MIN_CUTOFF)/ -MIN_CUTOFF);
		cairo_rectangle(cr, mxo, 6, cox, ANN_B - 6);
		cairo_set_source_rgba(cr, .0, .0, .0, .7);
		cairo_fill(cr);

		cairo_set_line_width (cr, 1.0);
		cairo_set_source_rgba(cr, .9, .5, .5, .6);
		cairo_move_to(cr, mxo + cox + .5, ANN_B - 6);
		cairo_line_to(cr, mxo + cox + .5, ANN_B + 1);
		cairo_stroke(cr);
	}

	cairo_destroy (cr);
}
Exemplo n.º 21
0
/* stereo-phase correlation display */
static bool pc_expose_event(RobWidget* handle, cairo_t* cr, cairo_rectangle_t *ev) {
	MF2UI* ui = (MF2UI*)GET_HANDLE(handle);

	if (!ui->sf_nfo && ui->nfo) {
		PangoFontDescription *fd = pango_font_description_from_string("Sans 10px");
		create_text_surface2(&ui->sf_nfo,
				12, PC_BOUNDH,
				0, PC_TOP,
				ui->nfo, fd, M_PI * -.5, 7, c_g60);
			pango_font_description_free(fd);
	}

	cairo_save(cr);
	cairo_translate(cr, 0, rint((ui->m0_height - ui->height) * .5));

	cairo_rectangle (cr, ev->x, ev->y, ev->width, ev->height);
	cairo_clip (cr);

	/* display phase-correlation */
	cairo_set_operator (cr, CAIRO_OPERATOR_OVER);

	/* PC meter backgroud */
	CairoSetSouerceRGBA(ui->c_bg);
	cairo_rectangle (cr, 0, 0, PC_BOUNDW, PC_BOUNDH);
	cairo_fill(cr);

	CairoSetSouerceRGBA(c_blk);
	cairo_set_line_width(cr, 1.0);
	rounded_rectangle (cr, PC_LEFT-1, PC_TOP + 1.0, PC_WIDTH+2, PC_HEIGHT - 2.0, 3);
	cairo_fill_preserve(cr);
	cairo_save(cr);
	cairo_clip(cr);

	/* value */
	CairoSetSouerceRGBA(c_glb);
	const float c = rintf(PC_TOP + PC_BLOCKSIZE * ui->cor);
	rounded_rectangle (cr, PC_LEFT, c, PC_WIDTH, PC_BLOCK, 4);
	cairo_fill(cr);

	/* labels w/ background */
	cairo_set_source_surface(cr, ui->sf_pc[0], PC_LEFT, PC_TOP + 5);
	cairo_paint (cr);
	cairo_set_source_surface(cr, ui->sf_pc[1], PC_LEFT, PC_TOP + PC_HEIGHT - 25);
	cairo_paint (cr);

	cairo_restore(cr);

	rounded_rectangle (cr, PC_LEFT - .5, PC_TOP + .5, PC_WIDTH + 1, PC_HEIGHT - 1, 3);
	CairoSetSouerceRGBA(c_g90);
	cairo_stroke(cr);

	/* annotations */
	cairo_set_operator (cr, CAIRO_OPERATOR_SCREEN);
	CairoSetSouerceRGBA(c_grd);
	cairo_set_line_width(cr, 1.0);

#define PC_ANNOTATION(YPOS, OFF) \
	cairo_move_to(cr, PC_LEFT + OFF, rintf(PC_TOP + YPOS) + 0.5); \
	cairo_line_to(cr, PC_LEFT + PC_WIDTH - OFF, rintf(PC_TOP + YPOS) + 0.5);\
	cairo_stroke(cr);

	PC_ANNOTATION(PC_HEIGHT * 0.1, 4.0);
	PC_ANNOTATION(PC_HEIGHT * 0.2, 4.0);
	PC_ANNOTATION(PC_HEIGHT * 0.3, 4.0);
	PC_ANNOTATION(PC_HEIGHT * 0.4, 4.0);
	PC_ANNOTATION(PC_HEIGHT * 0.6, 4.0);
	PC_ANNOTATION(PC_HEIGHT * 0.7, 4.0);
	PC_ANNOTATION(PC_HEIGHT * 0.8, 4.0);
	PC_ANNOTATION(PC_HEIGHT * 0.9, 4.0);

	CairoSetSouerceRGBA(c_glr);
	cairo_set_line_width(cr, 1.5);
	PC_ANNOTATION(PC_HEIGHT * 0.5, 1.5);

	cairo_restore(cr);
	if (ui->sf_nfo) {
		cairo_rectangle (cr, ev->x, ev->y, ev->width, ev->height);
		cairo_clip (cr);
		cairo_set_source_surface(cr, ui->sf_nfo, PC_BOUNDW - 14, 0);
		cairo_paint (cr);
	}

	return TRUE;
}