Beispiel #1
0
static RLayout *
extract_layout(char *filename, int linenum, char *line)
{
	char **names = NULL, *geom;
	RAreaList *list;
	int num_names = 0;
	unsigned int width, height, x, y;

	list = RAreaListNew(10, NULL);
	names = NULL;

	while((geom = strsep(&line, " ")) != NULL) {
		if(geom[0] == '\0') {
			continue;
		}

		switch(extract_geometry(geom, &names, &num_names,
		                        &x, &y, &width, &height)) {
			case 1:
				break;

			case 0:
				fprintf(stderr, "%s:%d: layout unrecognized geometry (%s)\n",
				        filename, linenum, geom);
			// fallthrough
			default:
				return NULL;
		}

		RAreaListAdd(list, RAreaNewStatic((int)x, (int)y, (int)width, (int)height));
	}

	return RLayoutSetMonitorsNames(RLayoutNew(list), names);
}
Beispiel #2
0
static RLayout *
read_layout_file(FILE *file, char *filename)
{
	char buf[128], *line, **names;
	RAreaList *list;
	RLayout *layout;
	int num, num_names, comment;
	unsigned int width, height, x, y;

	list = RAreaListNew(10, NULL);
	names = NULL;
	num_names = 0;
	for(num = 1; fgets(buf, sizeof(buf), file) != NULL; num++) {
		line = trim_spaces(buf);

		// Multiline comments: =comment -> =end
		if(comment) {
			if(strcmp(line, "=end") == 0) {
				comment = 0;
			}
			continue;
		}

		if(strcmp(line, "=comment") == 0) {
			comment = 1;
			continue;
		}

		if(line[0] == '#' || line[0] == '\0') {
			continue;
		}

		if(strcmp(line, "__END__") == 0) {
			break;
		}

		switch(extract_geometry(line, &names, &num_names,
		                        &x, &y, &width, &height)) {
			case 1:
				break;

			case 0:
				fprintf(stderr, "%s:%d: layout unrecognized line (%s)\n", filename, num, line);
			// fallthrough
			default:
				return NULL;
		}

		RAreaListAdd(list, RAreaNewStatic((int)x, (int)y, (int)width, (int)height));
	}

	layout = RLayoutSetMonitorsNames(RLayoutNew(list), names);

	//RLayoutPrint(layout);

	return layout;
}
Beispiel #3
0
const algebra::Segment3D &RigidBodyTorque::get_geometry() const {
    cache_ = extract_geometry(p_);
    return cache_;
}
Beispiel #4
0
RigidBodyTorque::RigidBodyTorque(Particle *p)
    : display::SegmentGeometry(extract_geometry(p), p->get_name()), p_(p) {}