📄 chaos_analyser.c
字号:
voidadjust_length(item,value) Panel_item item; int value;{ Xv_Window window=canvas_paint_window(canvas); LENGTH=value; redraw_proc((Canvas)NULL,window, dpy, canvas_win, (Xv_xrectlist *) NULL);}voidadjust_alpha(item,value) Panel_item item; int value;{ Xv_Window window=canvas_paint_window(canvas); ALPHA=(value * PI)/180; T1=cos(ALPHA)*cos(BETA); T2=cos(ALPHA)*sin(BETA); T3=-sin(ALPHA); T4=(cos(BETA)*sin(GAMMA)*sin(ALPHA))-(cos(GAMMA)*sin(BETA)); T5=(sin(BETA)*sin(GAMMA)*cos(ALPHA))+(cos(GAMMA)*cos(BETA)); T6=sin(GAMMA)*cos(ALPHA); redraw_proc((Canvas)NULL,window, dpy, canvas_win, (Xv_xrectlist *) NULL);}voidadjust_beta(item,value) Panel_item item; int value;{ Xv_Window window=canvas_paint_window(canvas); BETA=(value * PI)/180; T1=cos(ALPHA)*cos(BETA); T2=cos(ALPHA)*sin(BETA); T4=(cos(BETA)*sin(GAMMA)*sin(ALPHA))-(cos(GAMMA)*sin(BETA)); T5=(sin(BETA)*sin(GAMMA)*cos(ALPHA))+(cos(GAMMA)*cos(BETA)); redraw_proc((Canvas)NULL,window, dpy, canvas_win, (Xv_xrectlist *) NULL);}voidadjust_gamma(item,value) Panel_item item; int value;{ Xv_Window window=canvas_paint_window(canvas); GAMMA=(value * PI)/180; T4=(cos(BETA)*sin(GAMMA)*sin(ALPHA))-(cos(GAMMA)*sin(BETA)); T5=(sin(BETA)*sin(GAMMA)*cos(ALPHA))+(cos(GAMMA)*cos(BETA)); T6=sin(GAMMA)*cos(ALPHA); redraw_proc((Canvas)NULL,window, dpy, canvas_win, (Xv_xrectlist *) NULL);}voidadjust_ghost(item,value) Panel_item item; int value;{ Xv_Window window=canvas_paint_window(canvas); GHOST_LENGTH=value; redraw_proc((Canvas)NULL,window, dpy, canvas_win, (Xv_xrectlist *) NULL);}voidm_delay(item,value) Panel_item item; int value;{ if (EMBED=='t'){ M=value; xv_set(SVD_M_SLIDER,PANEL_VALUE,value,NULL); } else{ SVD_COLS=value; xv_set(SVD_M_SLIDER,PANEL_VALUE,value,NULL); } newfile();}voidnumber_points(item,value) Panel_item item; int value;{ NO_POINTS=value; newfile();}voidadjust_step(item,value) Panel_item item; int value;{ STEP=value;}voidadjust_size(item,value) Panel_item item; int value;{ Xv_Window window=canvas_paint_window(canvas); MULT=value; SIZE=2.5* value/MAX_VAL; redraw_proc((Canvas)NULL,window, dpy, canvas_win, (Xv_xrectlist *) NULL);}voidtime_pos(item,value) Panel_item item; int value;{ Xv_Window window=canvas_paint_window(canvas); COUNTER=value; redraw_proc((Canvas)NULL,window, dpy, canvas_win, (Xv_xrectlist *) NULL);}voidreverse(item,value) Panel_item item; int value;{ STEP*=-1;}voidoptions(item,value) Panel_item item; int value;{ OPTIONS*=-1; if (OPTIONS==-1) xv_set(options_frame,XV_SHOW,FALSE,NULL); else{ xv_set(options_frame,XV_SHOW,TRUE,NULL); }}voidfreeze(item,value) Panel_item item; int value;{ int speed; FREEZE*=-1; speed=(int)xv_get(SPEED,PANEL_VALUE); if (speed > 0 && FREEZE==-1) { timer.it_value.tv_usec = (speed + 20) * 1000; timer.it_interval.tv_usec = (speed + 20) * 1000; notify_set_itimer_func(frame,step , ITIMER_REAL, &timer, NULL); } else /* turn it off */ notify_set_itimer_func(frame, NOTIFY_FUNC_NULL, ITIMER_REAL, NULL, NULL); if (FREEZE==1) xv_set(FR_BUT,PANEL_LABEL_STRING,"un-freeze",NULL); else xv_set(FR_BUT,PANEL_LABEL_STRING,"freeze",NULL);}Notify_valuestep(){ Xv_Window window1=canvas_paint_window(canvas); COUNTER+=STEP; if ((COUNT_LAST%1000)>(COUNTER%1000)) xv_set(POS_SLIDER,PANEL_VALUE,COUNTER,NULL); COUNT_LAST=COUNTER; repaint_proc((Canvas)NULL,window1, dpy, canvas_win, (Xv_xrectlist *) NULL); return NOTIFY_DONE;} voidadjust_speed(item, value)Panel_item item;int value;{ if (value > 0 && FREEZE==-1) { timer.it_value.tv_usec = (value + 20) * 1000; timer.it_interval.tv_usec = (value + 20) * 1000; notify_set_itimer_func(frame,step , ITIMER_REAL, &timer, NULL); } else /* turn it off */ notify_set_itimer_func(frame, NOTIFY_FUNC_NULL, ITIMER_REAL, NULL, NULL);}voidset_angles(){ T1=cos(ALPHA)*cos(BETA); T2=cos(ALPHA)*sin(BETA); T3=-sin(ALPHA); T4=(cos(BETA)*sin(GAMMA)*sin(ALPHA))-(cos(GAMMA)*sin(BETA)); T5=(sin(BETA)*sin(GAMMA)*cos(ALPHA))+(cos(GAMMA)*cos(BETA)); T6=sin(GAMMA)*cos(ALPHA); T7=(cos(BETA)*cos(GAMMA)*sin(ALPHA))+(sin(BETA)*sin(GAMMA)); T8=(cos(GAMMA)*sin(ALPHA)*sin(BETA))-(sin(GAMMA)*cos(BETA)); T9=cos(ALPHA)*cos(GAMMA);}voidredraw_proc(canvas,window, dpy, xwin, xrects)Canvas canvas; /* Ignored */Xv_Window window;Display *dpy;Window xwin;Xv_xrectlist *xrects; /* Ignored */{ int i,start; double x,y,x_last,y_last; char pos_msg[128]; Xv_Window window2=canvas_paint_window(canvas_time); Xv_Window window5=canvas_paint_window(canvas_poin); if (xv_get(time_frame,XV_SHOW)) time_paint_proc((Canvas)NULL,window2, dpy, canvas_win_time, (Xv_xrectlist *) NULL); if (xv_get(poin_frame,XV_SHOW)) poin_paint_proc((Canvas)NULL,window5, dpy, canvas_win_poin, (Xv_xrectlist *) NULL); XClearWindow(dpy, xwin); XSetForeground(dpy, gc, pixel_table[BLACK]); if (AXES==1){ XDrawLine(dpy,xwin,gc,X_SET,Y_SET,X_SET+100*T1,Y_SET-100*T4); XDrawLine(dpy,xwin,gc,X_SET,Y_SET,X_SET+100*T2,Y_SET-100*T5); XDrawLine(dpy,xwin,gc,X_SET,Y_SET,X_SET+100*T3,Y_SET-100*T6); } XSetForeground(dpy, gc, pixel_table[GREY]); if ((start=COUNTER-GHOST_LENGTH)<0) start=1; x_last=T1*DATA[start][1]+T2*DATA[start][2]+T3*DATA[start][3]; y_last=T4*DATA[start][1]+T5*DATA[start][2]+T6*DATA[start][3]; for (i=start;i<COUNTER;i++){ x=T1*DATA[i+1][1]+T2*DATA[i+1][2]+T3*DATA[i+1][3]; y=T4*DATA[i+1][1]+T5*DATA[i+1][2]+T6*DATA[i+1][3]; XDrawLine(dpy,xwin,gc,X_SET+x_last*SIZE,Y_SET-y_last*SIZE,X_SET+x*SIZE,Y_SET-y*SIZE); x_last=x; y_last=y; } XSetForeground(dpy, gc, pixel_table[BLACK]); for (i=COUNTER;i<=COUNTER+LENGTH;i++){ x=T1*DATA[i+1][1]+T2*DATA[i+1][2]+T3*DATA[i+1][3]; y=T4*DATA[i+1][1]+T5*DATA[i+1][2]+T6*DATA[i+1][3]; XDrawLine(dpy,xwin,gc,X_SET+x_last*SIZE,Y_SET-y_last*SIZE,X_SET+x*SIZE,Y_SET-y*SIZE); x_last=x; y_last=y; }}voidrepaint_proc(canvas,window, dpy, xwin, xrects)Canvas canvas; /* Ignored */Xv_Window window;Display *dpy;Window xwin;Xv_xrectlist *xrects; /* Ignored */{ int i,start; double x,y,x_last,y_last; char pos_msg[128]; Xv_Window window2=canvas_paint_window(canvas_time); Xv_Window window5=canvas_paint_window(canvas_poin); if (xv_get(time_frame,XV_SHOW)) time_paint_proc((Canvas)NULL,window2, dpy, canvas_win_time, (Xv_xrectlist *) NULL); if (xv_get(poin_frame,XV_SHOW)) poin_paint_proc((Canvas)NULL,window5, dpy, canvas_win_poin, (Xv_xrectlist *) NULL); XSetForeground(dpy, gc, pixel_table[BLACK]); if (AXES==1){ XDrawLine(dpy,xwin,gc,X_SET,Y_SET,X_SET+100*T1,Y_SET-100*T4); XDrawLine(dpy,xwin,gc,X_SET,Y_SET,X_SET+100*T2,Y_SET-100*T5); XDrawLine(dpy,xwin,gc,X_SET,Y_SET,X_SET+100*T3,Y_SET-100*T6); } XSetForeground(dpy, gc, pixel_table[WHITE]); if (STEP>=0){ if ((start=COUNTER-GHOST_LENGTH-STEP-1)<0) start=1; x_last=T1*DATA[start][1]+T2*DATA[start][2]+T3*DATA[start][3]; y_last=T4*DATA[start][1]+T5*DATA[start][2]+T6*DATA[start][3]; for (i=start;i<COUNTER-GHOST_LENGTH;i++){ x=T1*DATA[i+1][1]+T2*DATA[i+1][2]+T3*DATA[i+1][3]; y=T4*DATA[i+1][1]+T5*DATA[i+1][2]+T6*DATA[i+1][3]; XDrawLine(dpy,xwin,gc,X_SET+x_last*SIZE,Y_SET-y_last*SIZE,X_SET+x*SIZE,Y_SET-y*SIZE); x_last=x; y_last=y; } } else{ start=COUNTER+LENGTH-STEP+1; x_last=T1*DATA[start][1]+T2*DATA[start][2]+T3*DATA[start][3]; y_last=T4*DATA[start][1]+T5*DATA[start][2]+T6*DATA[start][3]; for (i=start;i>COUNTER+LENGTH;i--){ x=T1*DATA[i-1][1]+T2*DATA[i-1][2]+T3*DATA[i-1][3]; y=T4*DATA[i-1][1]+T5*DATA[i-1][2]+T6*DATA[i-1][3]; XDrawLine(dpy,xwin,gc,X_SET+x_last*SIZE,Y_SET-y_last*SIZE,X_SET+x*SIZE,Y_SET-y*SIZE); x_last=x; y_last=y; } } XSetForeground(dpy, gc, pixel_table[GREY]); if ((start=COUNTER-GHOST_LENGTH)<0) start=1; x_last=T1*DATA[start][1]+T2*DATA[start][2]+T3*DATA[start][3]; y_last=T4*DATA[start][1]+T5*DATA[start][2]+T6*DATA[start][3]; for (i=start;i<COUNTER;i++){ x=T1*DATA[i+1][1]+T2*DATA[i+1][2]+T3*DATA[i+1][3]; y=T4*DATA[i+1][1]+T5*DATA[i+1][2]+T6*DATA[i+1][3]; XDrawLine(dpy,xwin,gc,X_SET+x_last*SIZE,Y_SET-y_last*SIZE,X_SET+x*SIZE,Y_SET-y*SIZE); x_last=x; y_last=y; } XSetForeground(dpy, gc, pixel_table[BLACK]); for (i=COUNTER;i<=COUNTER+LENGTH;i++){ x=T1*DATA[i+1][1]+T2*DATA[i+1][2]+T3*DATA[i+1][3]; y=T4*DATA[i+1][1]+T5*DATA[i+1][2]+T6*DATA[i+1][3]; XDrawLine(dpy,xwin,gc,X_SET+x_last*SIZE,Y_SET-y_last*SIZE,X_SET+x*SIZE,Y_SET-y*SIZE); x_last=x; y_last=y; }}voidprint_attr(filename) char filename[100];{ int i,start,offset_x,offset_y; double x,y,x_last,y_last,mult; char msg[100],fig_file[100]; FILE *optr; offset_x=X_SET*20; offset_y=Y_SET*20; mult=20*SIZE; sprintf(fig_file,"%s.fig",filename); optr = fopen(fig_file,"w"); fprintf(optr,"#FIG 3.1\nPortrait\nCenter\nInches\n1200 2\n"); if (AXES==1){ draw_arrow(offset_x,offset_y,(int)(offset_x+2000*T1), (int)(offset_y-2000*T4),1,0,1,optr); draw_arrow(offset_x,offset_y,(int)(offset_x+2000*T2), (int)(offset_y-2000*T5),1,0,1,optr); draw_arrow(offset_x,offset_y,(int)(offset_x+2000*T3), (int)(offset_y-2000*T6),1,0,1,optr); } if ((start=COUNTER-GHOST_LENGTH)<0) start=1; x_last=T1*DATA[start][1]+T2*DATA[start][2]+T3*DATA[start][3]; y_last=T4*DATA[start][1]+T5*DATA[start][2]+T6*DATA[start][3]; for (i=start;i<COUNTER;i++){ x=T1*DATA[i+1][1]+T2*DATA[i+1][2]+T3*DATA[i+1][3]; y=T4*DATA[i+1][1]+T5*DATA[i+1][2]+T6*DATA[i+1][3]; draw_coloured_line((int)(offset_x+x_last*mult),(int)(offset_y-y_last*mult), (int)(offset_x+x*mult),(int)(offset_y-y*mult), 1,1,3,optr); x_last=x; y_last=y; } for (i=COUNTER;i<=COUNTER+LENGTH;i++){ x=T1*DATA[i+1][1]+T2*DATA[i+1][2]+T3*DATA[i+1][3]; y=T4*DATA[i+1][1]+T5*DATA[i+1][2]+T6*DATA[i+1][3]; draw_line((int)(offset_x+x_last*mult),(int)(offset_y-y_last*mult), (int)(offset_x+x*mult),(int)(offset_y-y*mult), 1,0,optr); x_last=x; y_last=y; } fclose(optr); sprintf(msg,"fig2dev -L ps -P %s > %s.ps",fig_file,filename); system(msg);}voidevent_proc(window, event)Xv_Window window;Event *event;{ int width,height; if (event_is_ascii(event)){ sprintf(kbd_msg, "Keyboard: key '%c' %d pressed at %d,%d", event_action(event), event_action(event), event_x(event), event_y(event)); } else switch (event_action(event)){ case ACTION_SELECT: case MS_LEFT: X_SET=event_x(event); Y_SET=event_y(event); break; default: return; } width=0.01 *event_x(event); height= 0.01*event_y(event); /* call repaint proc directly to update messages */ redraw_proc((Canvas)NULL, window, (Display *)xv_get(window, XV_DISPLAY), xv_get(window, XV_XID), (Xv_xrectlist *) NULL);}/* * main() * Create a canvas specifying a repaint procedure. * Get the paint window for the canvas and set the input * mask and the event procedure. */main(argc, argv)int argc;char *argv[];{ Panel panel,panel_time,message_panel,panel_lsvd,panel_lya; Panel panel_lx,panel_options,panel_poin,print_panel,panel_mut; XGCValues gc_val; XGCValues gcvalues; Cms cms; Server_image closed_image; Icon icon; static Xv_singlecolor colors[] = { { 255, 255, 255 }, /* white */ { 0, 0, 0}, /* red */ { 0, 0 , 0 }, /* green */ { 0, 0, 0 }, /* blue */ { 200, 200, 200 }, /* grey */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -