Ejemplo n.º 1
0
Archivo: adcap.c Proyecto: athurg/adcap
G_MODULE_EXPORT
void btn_save_cb(GtkButton *btn, gpointer data)
{
	cairo_t *cr;
	cairo_surface_t *surface;
	int i;
	double y;

	surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 512, 500);
	cr = cairo_create (surface);

	paint_bg(cr);
	paint_marker(cr);

	//画图(蓝色)
	cairo_set_line_width(cr, 1);
	cairo_set_source_rgb(cr, 0, 0, 1);
	y = TOY(buffer[0])>500 ? 500 : TOY(buffer[0]);
	cairo_move_to(cr, 0, TOY(buffer[0]));
	for (i=1; i<512; i++) {
		y = cfg.yref + yscale*TOY(buffer[i-1]);
		//cairo_line_to(cr, i-1, cfg.yref+yscale*TOY(buffer[i-1]));
		cairo_line_to(cr, i-1, y>500?500:y);
	}
	cairo_stroke(cr);

	cairo_surface_write_to_png(surface, "save.png");

	cairo_destroy(cr);
	cairo_surface_destroy(surface);
}
Ejemplo n.º 2
0
	void readData()
	{
		scanf("%d%d", &toyNum, &compareTimes);
		vtxNum = toyNum + compareTimes + 2;
		source = vtxNum - 2, sink = vtxNum - 1;

		for(int i = 0; i < toyNum; i ++)
		{
			scanf("%d%d", &initLowerBound[i], &initUpperBound[i]);
			initLowerBound[i] = max(initLowerBound[i], 0);
			initUpperBound[i] = min(initUpperBound[i], 20000);
		}
		for(int i = 0, l, r, d; i < compareTimes; i ++)
		{
			scanf("%d%d%d", &l, &r, &d);
			if(d > 0)
				addEdge(COMPARE(i), sink, d, d);
			else if(d < 0)
				addEdge(source, COMPARE(i), -d, -d);
			int toyIdx;
			while(l --)
			{
				scanf("%d", &toyIdx);
				toyIdx --;
				addEdge(TOY(toyIdx), COMPARE(i), 0, INFINITY);
			}
			while(r --)
			{
				scanf("%d", &toyIdx);
				toyIdx --;
				addEdge(COMPARE(i), TOY(toyIdx), 0, INFINITY);
			}
		}
	}
Ejemplo n.º 3
0
Archivo: adcap.c Proyecto: athurg/adcap
/**
	 根据共享数组,刷新显示
  */
G_MODULE_EXPORT
int paint(GtkWidget *widget, GdkEvent *event, gpointer data)
{
	cairo_t *cr;
	int i;
	double y;

	cr = gdk_cairo_create (widget->window);

	paint_bg(cr);

	//画图(蓝色)
	cairo_set_line_width(cr, 1);
	cairo_set_source_rgb(cr, 0, 0, 1);
	y = TOY(buffer[0])>500 ? 500 : TOY(buffer[0]);
	cairo_move_to(cr, 0, TOY(buffer[0]));
	for (i=1; i<512; i++) {
		//y轴分为10个div,每个div包含50个点
		//因此每1dBm对应的y坐标应该为50/ydiv
		//y = (cfg.yref+buffer[i-1]);//dBm值
		//y *= -1*50/cfg.ydiv;//坐标值
		y = power2axis(buffer[i-1]);
		cairo_line_to(cr, i-1, y>500?500:y);
	}
	cairo_stroke(cr);

	paint_marker(cr);
	cairo_destroy(cr);
	return TRUE;
}
Ejemplo n.º 4
0
	void appendExtraEdge()
	{
		for(int i = 0; i < toyNum; i ++)
		{
			int u = TOY(i);
			if(inEdge[u] == NULL)
				addEdge(source, u, 0, INFINITY);
			if(outEdge[u] == NULL)
				addEdge(u, sink, 0, INFINITY);
			inEdge[u]->lowerBound = initLowerBound[i];
			inEdge[u]->capacity = initUpperBound[i];
		}

		addEdge(sink, source, 0, INFINITY);
	}