| 1 | typedef enum { |
| 2 | KT_OPEN = 1, |
| 3 | KT_CORNER = 2, |
| 4 | KT_LEFT = 4, |
| 5 | KT_RIGHT = 8, |
| 6 | KT_CORNU = 16, |
| 7 | KT_SELECTED = 256 |
| 8 | } kt_flags; |
| 9 | |
| 10 | typedef struct { |
| 11 | double x; |
| 12 | double y; |
| 13 | kt_flags flags; |
| 14 | } knot; |
| 15 | |
| 16 | typedef struct { |
| 17 | int n_kt; |
| 18 | int n_kt_max; |
| 19 | knot *kt; |
| 20 | int closed; |
| 21 | } subpath; |
| 22 | |
| 23 | typedef enum { |
| 24 | MOUSE_MODE_SELECT, |
| 25 | MOUSE_MODE_ADD_CURVE, |
| 26 | MOUSE_MODE_ADD_CORNER, |
| 27 | MOUSE_MODE_ADD_CORNU, |
| 28 | MOUSE_MODE_ADD_LEFT, |
| 29 | MOUSE_MODE_ADD_RIGHT |
| 30 | } mouse_mode; |
| 31 | |
| 32 | typedef enum { |
| 33 | MOTION_MODE_IDLE, |
| 34 | MOTION_MODE_SELECT, |
| 35 | MOTION_MODE_MOVE |
| 36 | } motion_mode; |
| 37 | |
| 38 | typedef struct { |
| 39 | double x0, y0; |
| 40 | const char *description; |
| 41 | |
| 42 | int n_sp; |
| 43 | int n_sp_max; |
| 44 | subpath *sp; |
| 45 | mouse_mode mmode; |
| 46 | mouse_mode last_curve_mmode; |
| 47 | motion_mode motmode; |
| 48 | double sel_x0, sel_y0; |
| 49 | } plate; |
| 50 | |
| 51 | typedef enum { |
| 52 | PRESS_MOD_SHIFT = 1, |
| 53 | PRESS_MOD_CTRL = 2, |
| 54 | PRESS_MOD_DOUBLE = 4, |
| 55 | PRESS_MOD_TRIPLE = 8 |
| 56 | } press_mod; |
| 57 | |
| 58 | plate * |
| 59 | new_plate(void); |
| 60 | |
| 61 | void |
| 62 | free_plate(plate *p); |
| 63 | |
| 64 | plate * |
| 65 | copy_plate(const plate *p); |
| 66 | |
| 67 | void |
| 68 | plate_select_all(plate *p, int selected); |
| 69 | |
| 70 | subpath * |
| 71 | plate_find_selected_sp(plate *p); |
| 72 | |
| 73 | subpath * |
| 74 | plate_new_sp(plate *p); |
| 75 | |
| 76 | void |
| 77 | plate_press(plate *p, double x, double y, press_mod mods); |
| 78 | |
| 79 | void |
| 80 | plate_motion_move(plate *p, double x, double y); |
| 81 | |
| 82 | void |
| 83 | plate_motion_select(plate *p, double x, double y); |
| 84 | |
| 85 | void plate_unpress(plate *p); |
| 86 | |
| 87 | void |
| 88 | plate_toggle_corner(plate *p); |
| 89 | |
| 90 | void |
| 91 | plate_delete_pt(plate *p); |
| 92 | |
| 93 | spiro_seg * |
| 94 | draw_subpath(const subpath *sp, bezctx *bc); |
| 95 | |
| 96 | int |
| 97 | file_write_plate(const char *fn, const plate *p); |
| 98 | |
| 99 | plate * |
| 100 | file_read_plate(const char *fn); |