Enabled parser to detect path-types, fix indentation

This commit is contained in:
Mario Hüttel 2018-06-02 02:19:36 +02:00
parent d1a1cb762a
commit 0f4de608a2
3 changed files with 52 additions and 35 deletions

View File

@ -59,6 +59,7 @@ enum record {
BOX = 0x2D00, BOX = 0x2D00,
LAYER = 0x0D02, LAYER = 0x0D02,
WIDTH = 0x0F03, WIDTH = 0x0F03,
PATHTYPE = 0x2102
}; };
static int name_cell_ref(struct gds_cell_instance *cell_inst, static int name_cell_ref(struct gds_cell_instance *cell_inst,
@ -189,7 +190,8 @@ static GList *append_graphics(GList *curr_list, enum graphics_type type,
gfx->layer = 0; gfx->layer = 0;
gfx->vertices = NULL; gfx->vertices = NULL;
gfx->width_absolute = 0; gfx->width_absolute = 0;
gfx->type = type; gfx->gfx_type = type;
gfx->path_render_type = PATH_FLUSH;
} else } else
return NULL; return NULL;
@ -561,7 +563,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
case ENDEL: case ENDEL:
if (current_graphics != NULL) { if (current_graphics != NULL) {
printf("\tLeaving %s\n", (current_graphics->type == GRAPHIC_POLYGON ? "boundary" : "path")); printf("\tLeaving %s\n", (current_graphics->gfx_type == GRAPHIC_POLYGON ? "boundary" : "path"));
current_graphics = NULL; current_graphics = NULL;
} }
if (current_s_reference != NULL) { if (current_s_reference != NULL) {
@ -587,6 +589,8 @@ int parse_gds_from_file(const char *filename, GList **library_list)
break; break;
case WIDTH: case WIDTH:
break; break;
case PATHTYPE:
break;
default: default:
//GDS_WARN("Record: %04x, len: %u", (unsigned int)rec_type, (unsigned int)rec_data_length); //GDS_WARN("Record: %04x, len: %u", (unsigned int)rec_type, (unsigned int)rec_data_length);
break; break;
@ -693,6 +697,18 @@ int parse_gds_from_file(const char *filename, GList **library_list)
printf("\t\tAngle defined: %lf\n", current_s_reference->angle); printf("\t\tAngle defined: %lf\n", current_s_reference->angle);
} }
break; break;
case PATHTYPE:
if (current_graphics == NULL) {
GDS_WARN("Path type defined outside of path. Ignoring");
break;
}
if (current_graphics->gfx_type == GRAPHIC_PATH) {
current_graphics->path_render_type = (int)gds_convert_signed_int16(workbuff);
printf("\t\tPathtype: %d\n", current_graphics->path_render_type);
} else {
GDS_WARN("Path type defined inside non-path graphics object. Ignoring");
}
break;
} }

View File

@ -7,54 +7,55 @@
#define CELL_NAME_MAX (100) #define CELL_NAME_MAX (100)
enum graphics_type {GRAPHIC_PATH = 0, GRAPHIC_POLYGON = 1}; enum graphics_type {GRAPHIC_PATH = 0, GRAPHIC_POLYGON = 1};
enum path_type {PATH_FLUSH = 0, PATH_ROUNDED = 1, PATH_SQUARED = 2};
struct gds_time_field { struct gds_time_field {
uint16_t year; uint16_t year;
uint16_t month; uint16_t month;
uint16_t day; uint16_t day;
uint16_t hour; uint16_t hour;
uint16_t minute; uint16_t minute;
uint16_t second; uint16_t second;
}; };
struct gds_point { struct gds_point {
int x; int x;
int y; int y;
}; };
struct gds_graphics { struct gds_graphics {
enum graphics_type type; enum graphics_type gfx_type;
GList *vertices; GList *vertices;
unsigned int path_width; enum path_type path_render_type;
int width_absolute; int width_absolute;
int16_t layer; int16_t layer;
uint16_t datatype; uint16_t datatype;
}; };
struct gds_cell_instance { struct gds_cell_instance {
char ref_name[CELL_NAME_MAX]; char ref_name[CELL_NAME_MAX];
struct gds_cell *cell_ref; struct gds_cell *cell_ref;
struct gds_point origin; struct gds_point origin;
int flipped; int flipped;
double angle; double angle;
double magnification; double magnification;
}; };
struct gds_cell { struct gds_cell {
char name[CELL_NAME_MAX]; char name[CELL_NAME_MAX];
struct gds_time_field mod_time; struct gds_time_field mod_time;
struct gds_time_field access_time; struct gds_time_field access_time;
GList *child_cells; GList *child_cells;
GList *graphic_objs; GList *graphic_objs;
}; };
struct gds_library { struct gds_library {
char name[CELL_NAME_MAX]; char name[CELL_NAME_MAX];
struct gds_time_field mod_time; struct gds_time_field mod_time;
struct gds_time_field access_time; struct gds_time_field access_time;
double unit_to_meters; double unit_to_meters;
GList *cells; GList *cells;
GList *cell_names; GList *cell_names;
}; };
#endif /* __GDS_TYPES_H__ */ #endif /* __GDS_TYPES_H__ */

View File

@ -95,7 +95,7 @@ static void generate_graphics(FILE *tex_file, GList *graphics, GList *linfo, GSt
if (write_layer_env(tex_file, &color, (int)gfx->layer, linfo, buffer) == TRUE) { if (write_layer_env(tex_file, &color, (int)gfx->layer, linfo, buffer) == TRUE) {
/* Layer is defined => create graphics */ /* Layer is defined => create graphics */
if (gfx->type == GRAPHIC_POLYGON) { if (gfx->gfx_type == GRAPHIC_POLYGON) {
g_string_printf(buffer, "\\draw[line width=0.00001 pt, draw={c%d}, fill={c%d}, fill opacity={%lf}] ", g_string_printf(buffer, "\\draw[line width=0.00001 pt, draw={c%d}, fill={c%d}, fill opacity={%lf}] ",
gfx->layer, gfx->layer, color.alpha); gfx->layer, gfx->layer, color.alpha);
WRITEOUT_BUFFER(buffer); WRITEOUT_BUFFER(buffer);
@ -107,7 +107,7 @@ static void generate_graphics(FILE *tex_file, GList *graphics, GList *linfo, GSt
} }
g_string_printf(buffer, "cycle;\n"); g_string_printf(buffer, "cycle;\n");
WRITEOUT_BUFFER(buffer); WRITEOUT_BUFFER(buffer);
} else if(gfx->type == GRAPHIC_PATH) { } else if(gfx->gfx_type == GRAPHIC_PATH) {
g_string_printf(buffer, "\\draw[line width=%lf pt, draw={c%d}, opacity={%lf}] ", g_string_printf(buffer, "\\draw[line width=%lf pt, draw={c%d}, opacity={%lf}] ",
gfx->width_absolute/1000.0, gfx->layer, gfx->layer, color.alpha); gfx->width_absolute/1000.0, gfx->layer, gfx->layer, color.alpha);
WRITEOUT_BUFFER(buffer); WRITEOUT_BUFFER(buffer);