Root/
| 1 | /* |
| 2 | * kicad/lib.h - Parse Eeschema .lib file |
| 3 | * |
| 4 | * Written 2016 by Werner Almesberger |
| 5 | * Copyright 2016 by Werner Almesberger |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | |
| 14 | #ifndef KICAD_LIB_H |
| 15 | #define KICAD_LIB_H |
| 16 | |
| 17 | #include <stdbool.h> |
| 18 | |
| 19 | #include "file/file.h" |
| 20 | #include "gfx/text.h" |
| 21 | |
| 22 | |
| 23 | enum lib_state { |
| 24 | lib_skip, /* before a definition */ |
| 25 | lib_def, /* in definition */ |
| 26 | lib_draw, /* in drawings */ |
| 27 | }; |
| 28 | |
| 29 | struct lib_obj { |
| 30 | enum lib_obj_type { |
| 31 | lib_obj_poly, |
| 32 | lib_obj_rect, |
| 33 | lib_obj_circ, |
| 34 | lib_obj_arc, |
| 35 | lib_obj_text, |
| 36 | lib_obj_pin, |
| 37 | } type; |
| 38 | unsigned unit; |
| 39 | unsigned convert; |
| 40 | union { |
| 41 | struct lib_poly { |
| 42 | int thick; |
| 43 | char fill; |
| 44 | int points; |
| 45 | int *x; |
| 46 | int *y; |
| 47 | } poly; |
| 48 | struct lib_rect { |
| 49 | int thick; |
| 50 | char fill; |
| 51 | int sx, sy; |
| 52 | int ex, ey; |
| 53 | } rect; |
| 54 | struct lib_circ { |
| 55 | int x, y; |
| 56 | int r; |
| 57 | int thick; |
| 58 | char fill; |
| 59 | } circ; |
| 60 | struct lib_arc { |
| 61 | int x, y; |
| 62 | int r; |
| 63 | int start_a, end_a; |
| 64 | int thick; |
| 65 | char fill; |
| 66 | } arc; |
| 67 | struct lib_text { |
| 68 | int orient; |
| 69 | int x, y; |
| 70 | int dim; |
| 71 | char *s; |
| 72 | enum text_style style; |
| 73 | char hor_align; |
| 74 | char vert_align; |
| 75 | } text; |
| 76 | struct lib_pin { |
| 77 | char *name; |
| 78 | char *number; |
| 79 | int x, y; |
| 80 | int length; |
| 81 | char orient; |
| 82 | int number_size; |
| 83 | int name_size; |
| 84 | char etype; |
| 85 | // @@@ shape |
| 86 | } pin; |
| 87 | } u; |
| 88 | struct lib_obj *next; |
| 89 | }; |
| 90 | |
| 91 | struct comp_alias { |
| 92 | const char *name; |
| 93 | struct comp_alias *next; |
| 94 | }; |
| 95 | |
| 96 | struct comp { |
| 97 | const char *name; |
| 98 | struct comp_alias *aliases; |
| 99 | unsigned units; |
| 100 | |
| 101 | unsigned visible; /* visible fields, bit mask */ |
| 102 | bool show_pin_name; |
| 103 | bool show_pin_num; |
| 104 | unsigned name_offset; |
| 105 | |
| 106 | struct lib_obj *objs; |
| 107 | struct comp *next; |
| 108 | }; |
| 109 | |
| 110 | struct lib { |
| 111 | enum lib_state state; |
| 112 | |
| 113 | struct comp *comps; |
| 114 | |
| 115 | struct comp *curr_comp; /* current component */ |
| 116 | struct comp **next_comp; |
| 117 | struct lib_obj **next_obj; |
| 118 | |
| 119 | }; |
| 120 | |
| 121 | |
| 122 | extern struct comp *comps; |
| 123 | |
| 124 | |
| 125 | const struct comp *lib_find(const struct lib *lib, const char *name); |
| 126 | bool lib_field_visible(const struct comp *comp, int n); |
| 127 | void lib_render(const struct comp *comp, unsigned unit, unsigned convert, |
| 128 | const int m[6]); |
| 129 | |
| 130 | bool lib_parse_file(struct lib *lib, struct file *file); |
| 131 | bool lib_parse(struct lib *lib, const char *name, const struct file *related); |
| 132 | void lib_init(struct lib *lib); |
| 133 | void lib_free(struct lib *lib); |
| 134 | |
| 135 | #endif /* !KICAD_LIB_H */ |
| 136 |
Branches:
master
