diff -urN wf-/Makefile wf/Makefile --- wf-/Makefile 2015-12-17 00:00:00.000000000 +0900 +++ wf/Makefile 2015-12-20 00:00:00.000000000 +0900 @@ -2,6 +2,7 @@ LIBS = -lm -lX11 -L/usr/X11R6/lib CFLAGS += -Wall -I/usr/X11R6/include +#CFLAGS += -DDBG WF_OBJS = wf_ex.o data.o eye.o way.o d3.o x.o util.o key.o select.o diff -urN wf-/data.c wf/data.c --- wf-/data.c 2015-12-19 00:00:00.000000000 +0900 +++ wf/data.c 2015-12-20 00:00:00.000000000 +0900 @@ -1,6 +1,42 @@ #include "x.h" #include "data.h" +#ifdef DBG +char * +type_str(int type) +{ +#define CASE_RET(type) case type: return #type + + switch(type){ + CASE_RET(type_end); + CASE_RET(type_wire_frame); + CASE_RET(type_bar); + CASE_RET(type_cross); + CASE_RET(type_square); + CASE_RET(type_cube); + CASE_RET(type_arr); + CASE_RET(type_op_data_set); + CASE_RET(type_slide); + CASE_RET(type_zoom); + CASE_RET(type_zoom_and_slide); + CASE_RET(type_rot); + CASE_RET(type_point_symmetry); + CASE_RET(type_mirror); + CASE_RET(type_timeshift); + CASE_RET(type_slide_way); + CASE_RET(type_rot_way); + CASE_RET(type_copy); + CASE_RET(type_copy_rot); + CASE_RET(type_copy_point_symmetry); + CASE_RET(type_copy_mirror); + CASE_RET(type_copy_timeshift); + default: break; + } + return "???"; +} + +#endif /* DBG */ + void prm_set_eye_update(prm_t *prm, eye_t *eye) { @@ -120,6 +156,10 @@ void data_draw(data_t *data, prm_t *prm) { +#ifdef DBG + fprintf(stderr, "%s() type=%s\r\n", + __func__, type_str(data->type)); +#endif switch(data->type){ case type_wire_frame: wire_frame_draw(data->p, prm); @@ -152,9 +192,13 @@ static void op_data_arr(data_t *op_arr, data_t *data, prm_t *prm) { - struct op_data_set set = { &op_arr[1], data }; - data_t d = { type_op_data_set, &set }; - op_data_draw(&op_arr[0], &d, prm); + if(op_arr[0].type == type_end) data_draw(data, prm); + else{ + data_t arr = { type_arr, &op_arr[1] }; + struct op_data_set set = { &arr, data }; + data_t d = { type_op_data_set, &set }; + op_data_draw(&op_arr[0], &d, prm); + } } static void @@ -310,6 +354,10 @@ { prm_t bak = *prm; +#ifdef DBG + fprintf(stderr, "%s() op.type=%s data.type=%s\r\n", + __func__, type_str(op->type), type_str(data->type)); +#endif switch(op->type){ case type_arr: op_data_arr(op->p, data, prm); diff -urN wf-/wf_ex.c wf/wf_ex.c --- wf-/wf_ex.c 2015-12-19 00:00:00.000000000 +0900 +++ wf/wf_ex.c 2015-12-20 00:00:00.000000000 +0900 @@ -205,11 +205,28 @@ .n = 3, .init_sec = 0, .step_sec = -0.3, .init = {0,0,0}, .step = {0,0,0} } }, .data = cube2 }}; + data_t *cup = &(data_t){ type_op_data_set, &(struct op_data_set){ + .op = &(data_t){ type_arr, (data_t[]){ + { type_slide, &(d3_t){20,20,0} }, + { type_copy_rot, &(struct copy_rot){ .n=4, .l=LINE_Z, .init_deg=0, .step_deg=90 } }, + { type_rot_way, &(struct rot_way){ + .l=LINE_Z, + .deg_way={ .n=2, .vs=(double[]){0,360*4}, .ts=(double[]){15,15}, .ps=NULL, .dg=3} } }, + { type_slide, &(d3_t){5,0,0} }, + { type_rot_way, &(struct rot_way){ + .l=LINE_Z, + .deg_way={ .n=2, .vs=(double[]){0,360*2}, .ts=(double[]){4,4}, .ps=NULL, .dg=3} } }, + { type_copy, &(struct copy){ .n={2,1,1}, .init={-2,0,0}, .step={4,0,0} } }, + { type_end } + }}, + .data = &(data_t){ type_cube } }}; + data.type = type_arr; data.p = (data_t[]){ *axyz, *cross, *cube, *cube3, + *cup, { type_end } }; }