/* * File Name : xyDSP.c * Creation Date : Nov 17 2000 * Author : Y.Nakaune */ #include #include #include #include #include #include "../include/daq.h" #include "variables.h" #include "gc_color.h" #include "hit_file_def.h" #include "hit_line.h" #include "hit_sci.h" #include "hit_dc.h" #include "hit_tgc.h" /*********************************************************** usage ***********************************************************/ static void usage ( char *cmd ) { fprintf( stderr, "\n" ); fprintf( stderr, "-------------------------------------------------\n" ); fprintf( stderr, "Usage : %s [file_name] [event_number]\n", cmd ); fprintf( stderr, " [file_name] : set the data_file to read.\n" ); fprintf( stderr, " data_file is \"xxxx.dat\".\n" ); fprintf( stderr, " [event_number] : set event_number to display. \n" ); fprintf( stderr, " ( defaule = 1 )\n" ); fprintf( stderr, " event_number > 0 \n" ); fprintf( stderr, "-------------------------------------------------\n" ); fprintf( stderr, "\n" ); exit( 1 ); } /*********************************************************** convert ***********************************************************/ /*--------scale_convert ( default : 2pixel = 1mm )--------*/ double scale_cvt ( double befer_value ) { double after_value; after_value = befer_value * scale_factor; return ( after_value ); } /*------------------------X_convert-----------------------*/ double Xcvt ( double before_X ) { double after_X; after_X = scale_cvt ( Xwidth / 2. + before_X ); return ( after_X ); } /*------------------------Y_convert-----------------------*/ double Ycvt ( double before_Y ) { double after_Y; after_Y = scale_cvt ( Height / 2. - before_Y ); return ( after_Y ); } /*------------------------Z_convert-----------------------*/ double Zcvt ( double before_Z ) { double after_Z; after_Z = scale_cvt ( before_Z + z_frame ); return ( after_Z ); } /*********************************************************** line-equation ***********************************************************/ double line_eq ( double start_x, double start_y, double end_x, double end_y, double value_Y ) { double katamuki, seppen, value_X; katamuki = ( end_y - start_y ) / ( end_x - start_x ); seppen = ( start_y * end_x - start_x * end_y ) / ( end_x - start_x ); value_X = ( value_Y - seppen ) / katamuki; return ( value_X ); } /*********************************************************** initialization ***********************************************************/ void initialization () { hit_line.X1 = 9999; hit_line.Y1 = 9999; hit_line.Z1 = 9999; hit_line.X2 = 9999; hit_line.Y2 = 9999; hit_line.Z2 = 9999; sci.ctnb = 9999; dc.nb = 9999; dc.xy = 9999; tgc.lay = 9999; tgc.ws = 9999; tgc.tgch = 9999; } /*********************************************************** Hit_Event_Draw ***********************************************************/ void Hit_Event_Draw ( gpointer data ) { GdkDrawable *drawable; GtkWidget *parent; GtkWidget *drawing_area; GtkType type; GtkViewport* viewport; Hit_Sci_List *sci_ptr, *sci_next_ptr; Hit_DC_List *dc_ptr, *dc_next_ptr; Hit_TGC_List *tgc_ptr, *tgc_next_ptr; int a, b, c; int numberW[TGC_MAX], numberS[TGC_MAX]; int numberDCx[DC_MAX], numberDCy[DC_MAX]; int w_ch[TGC_MAX][100], s_ch[TGC_MAX][100]; int dc_x_length[DC_MAX][100], dc_y_length[DC_MAX][100]; char str[TGC_MAX][500]; drawing_area = (GtkWidget *) data; drawable = drawing_area->window; /* initialize number of TGC_data */ for ( c = 0; c < TGC_MAX; c++ ) { numberW[c] = 0; numberS[c] = 0; } /* initialize number of TGC_data */ for ( c = 0; c < DC_MAX; c++ ) { numberDCx[c] = 0; numberDCy[c] = 0; } /*--- Hit SCI ---*/ sci_ptr = hit_sci_list_first(); while ( sci_ptr != NULL ) { sci_next_ptr = sci_ptr->next; sci.ctnb = (sci_ptr->hit_sci).ctnb; sci.trigger_t = (sci_ptr->hit_sci).trigger_t; if ( sci.ctnb < 4 ) { sci_ptr = sci_next_ptr; continue; } else if ( sci.ctnb == 9999 ) { return; } else { fprintf( stderr, "ERROR at Hit_Event_Draw in XY-view !\n" ); fprintf( stderr, "sci.ctnb = %d\n", sci.ctnb ); initialization (); return; } sci_ptr = sci_next_ptr; } /*--- Hit Drift Chamber ---*/ dc_ptr = hit_dc_list_first(); while ( dc_ptr != NULL ) { dc_next_ptr = dc_ptr->next; dc.nb = (dc_ptr->hit_dc).chmbnb; dc.xy = (dc_ptr->hit_dc).xy; dc.drift_l = (dc_ptr->hit_dc).drift_l; dc.hit_t = (dc_ptr->hit_dc).hit_t; if ( dc.nb < DC_MAX && dc.xy < 2 ) { if ( dc.xy == 0 ) { dc_x_length[ dc.nb ][ numberDCx[dc.nb] ] = dc.drift_l; numberDCx[dc.nb]++; } else if ( dc.xy == 1 ) { dc_y_length[ dc.nb ][ numberDCy[dc.nb] ] = dc.drift_l; numberDCy[dc.nb]++; } } else if ( dc.nb == 9999 && dc.xy == 9999 ) { return; } else { fprintf( stderr, "ERROR at Hit_Event_Draw in XY-view !\n" ); fprintf( stderr, "dc.nb = %d dc.xy = %d\n", dc.nb, dc.xy ); initialization (); return; } dc_ptr = dc_next_ptr; } for ( c = 0; c < 2; c++ ) { if ( !drawing_dc_flg || !event_load_flg ) continue; if ( c == 1 ) SetPenColor(0xffff, 0xcccc, 0x0000); /*---色の生成:---*/ if ( c == 0 ) SetPenColor(0xffff, 0xffff, 0x0000); /*---色の生成:黄色---*/ for ( a = 0; a < numberDCx[c]; a++ ) { for ( b = 0; b < numberDCy[c]; b++ ) { if ( c == 0 ) { gdk_draw_arc( drawable, g_gc, TRUE, Xcvt( dc_wire_x[c] + dc_x_length[c][a] )-5, Ycvt( dc_wire_y[c] - dc_y_length[c][b] )-5, 5, 5, 0, 360 * 64 ); } else if ( c == 1 ) { gdk_draw_arc( drawable, g_gc, TRUE, Xcvt( dc_wire_x[c] - dc_x_length[c][a] )-5, Ycvt( dc_wire_y[c] + dc_y_length[c][b] )-5, 5, 5, 0, 360 * 64 ); } } } } /*--- HitがあったTGCに色を塗る。---*/ tgc_ptr = hit_tgc_list_first(); while ( tgc_ptr != NULL ) { tgc_next_ptr = tgc_ptr->next; tgc.lay = (tgc_ptr->hit_tgc).layer; tgc.ws = (tgc_ptr->hit_tgc).ws; tgc.tgch = (tgc_ptr->hit_tgc).tgch; tgc.hit_t = (tgc_ptr->hit_tgc).hit_t; #if 0 if ( tgc.ws == 0 && tgc.lay < 2 ) { if ( tgc.tgch < 16 ) tgc.tgch = 15 - tgc.tgch; else if ( tgc.tgch >= 16 && tgc.tgch < 32 ) tgc.tgch = 31 - ( tgc.tgch - 16 ); } else if ( tgc.ws == 0 && tgc.lay >= 2 && tgc.lay < TGC_MAX ) { if ( tgc.tgch < 8 ) tgc.tgch = 7 - tgc.tgch; else if ( tgc.tgch >= 8 && tgc.tgch < 24 ) tgc.tgch = 23 - ( tgc.tgch - 8 ); } #endif if ( tgc.lay < 2 ) { if ( tgc.ws == 0 && tgc.tgch < 32 ) { w_ch[ tgc.lay ][ numberW[tgc.lay] ] = tgc.tgch; numberW[tgc.lay]++; } else if ( tgc.ws == 1 && tgc.tgch < 32 ) { s_ch[ tgc.lay ][ numberS[tgc.lay] ] = tgc.tgch; numberS[tgc.lay]++; } } else if ( tgc.lay >= 2 && tgc.lay < TGC_MAX ) { if ( tgc.ws == 0 && tgc.tgch < 24 ) { w_ch[ tgc.lay ][ numberW[tgc.lay] ] = tgc.tgch; numberW[tgc.lay]++; } else if ( tgc.ws == 1 && tgc.tgch < 32 ) { s_ch[ tgc.lay ][ numberS[tgc.lay] ] = tgc.tgch; numberS[tgc.lay]++; } } else if ( tgc.lay == 9999 && tgc.ws == 9999 && tgc.tgch == 9999 ) { return; } else { fprintf( stderr, "ERROR at Hit_Event_Draw in XY-view !\n" ); fprintf( stderr, "tgc.lay = %d tgc.ws = %d tgc.tgch = %d\n", tgc.lay, tgc.ws, tgc.tgch ); initialization (); return; } tgc_ptr = tgc_next_ptr; } for ( c = 0; c < TGC_MAX; c++ ) { if ( !drawing_layer_flg[c] || !event_load_flg ) { sprintf( TGC_str[c], "TGC layer %2d :", c ); gtk_label_set( GTK_LABEL( label[c] ), TGC_str[c] ); continue; } for ( a = 0; a < numberW[c]; a++ ) { if ( c == 3 ) { SetPenColor(0x0000, 0x0000, 0xffff); /*---色の生成:青---*/ gdk_draw_polygon( drawable, g_gc, FALSE, point[c][ w_ch[c][a] ][ 0 ], 5 ); } for ( b = 0; b < numberS[c]; b++ ) { if ( c == 0 ) SetPenColor(0xffff, 0x0000, 0xffff); /*---色の生成:ピンク---*/ if ( c == 1 ) SetPenColor(0xffff, 0x0000, 0x0000); /*---色の生成:赤---*/ if ( c == 2 ) SetPenColor(0x0000, 0xaaaa, 0xffff); /*---色の生成:薄水色---*/ if ( c == 4 ) SetPenColor(0x0000, 0x5555, 0xffff); /*---色の生成:水色---*/ gdk_draw_polygon( drawable, g_gc, TRUE, point[c][ w_ch[c][a] ][ s_ch[c][b] ], 5 ); if ( c == 0 ) SetPenColor(0xffff, 0xcccc, 0xffff); /*---色の生成:ピンク---*/ if ( c == 1 ) SetPenColor(0xffff, 0xaaaa, 0xffff); /*---色の生成:ピンク---*/ if ( c == 2 ) SetPenColor(0xcccc, 0xdddd, 0xffff); /*---色の生成:水色---*/ if ( c == 4 ) SetPenColor(0x8888, 0xdddd, 0xffff); /*---色の生成:水色---*/ gdk_draw_polygon( drawable, g_gc, FALSE, point[c][ w_ch[c][a] ][ s_ch[c][b] ], 5 ); } } sprintf( TGC_str[c], "TGC layer %2d : ",c ); if ( numberW[c] != 0 ) { sprintf( str[c], " Wire ch =" ); strcat( TGC_str[c], str[c] ); for ( a = 0; a < numberW[c]; a++ ) { sprintf( str[c], "%4d", w_ch[c][a] ); strcat( TGC_str[c], str[c] ); } } if ( c != 3 && numberS[c] != 0 ) { sprintf( str[c], " Strip ch =" ); strcat( TGC_str[c], str[c] ); for ( b = 0; b < numberS[c]; b++ ) { sprintf( str[c], "%4d", s_ch[c][b] ); strcat( TGC_str[c], str[c] ); } } gtk_label_set( GTK_LABEL( label[c] ), TGC_str[c] ); } for ( c = 2; c < DC_MAX; c++ ) { if ( !drawing_dc_flg || !event_load_flg ) continue; if ( c == 3 ) SetPenColor(0xffff, 0x6666, 0x0000); /*---色の生成:オレンジ---*/ if ( c == 2 ) SetPenColor(0xffff, 0x9999, 0x0000); /*---色の生成:---*/ for ( a = 0; a < numberDCx[c]; a++ ) { for ( b = 0; b < numberDCy[c]; b++ ) { if ( c == 2 ) { gdk_draw_arc( drawable, g_gc, TRUE, Xcvt( dc_wire_x[c] + dc_x_length[c][a] )-5, Ycvt( dc_wire_y[c] - dc_y_length[c][b] )-5, 5, 5, 0, 360 * 64 ); } else if ( c == 3 ) { gdk_draw_arc( drawable, g_gc, TRUE, Xcvt( dc_wire_x[c] - dc_x_length[c][a] )-5, Ycvt( dc_wire_y[c] + dc_y_length[c][b] )-5, 5, 5, 0, 360 * 64 ); } } } } } /*********************************************************** Paint ***********************************************************/ gint Paint ( gpointer data ) { int a, b, c; double x_length; char buff[BUFF_LENGTH]; GdkDrawable *drawable; GtkWidget *drawing_area; drawing_area = (GtkWidget *) data; drawable = drawing_area->window; gdk_draw_rectangle ( drawable, drawing_area->style->black_gc, 1, 0, 0, scale_cvt (Xwidth), scale_cvt (Height) );//---bg=white--- /*-----Drift Chamber--------------------------------------*/ for ( a = 0; a < DC_MAX; a++ ) { dc_x[a] = - DC_X / 2.; dc_y[a] = DC_Y / 2.; dc_window_x[a] = - DC_WINDOW / 2.; dc_window_y[a] = DC_WINDOW / 2.; } dc_wire_x[0] = - DC_WIRE; dc_wire_y[0] = DC_WIRE; dc_wire_x[1] = DC_WIRE; dc_wire_y[1] = - DC_WIRE; dc_wire_x[2] = - DC_WIRE; dc_wire_y[2] = DC_WIRE; dc_wire_x[3] = DC_WIRE; dc_wire_y[3] = - DC_WIRE; for ( a = 0; a < 2; a++ ) { if ( !drawing_dc_flg ) continue; SetPenColor(0xffff, 0xffff, 0xffff); /*---色の生成:白---*/ gdk_draw_rectangle ( drawable, g_gc, 0, Xcvt(dc_x[a]), Ycvt(dc_y[a]), scale_cvt(DC_X), scale_cvt(DC_Y) ); gdk_draw_rectangle ( drawable, g_gc, 0, Xcvt(dc_window_x[a]), Ycvt(dc_window_y[a]), scale_cvt(DC_WINDOW), scale_cvt(DC_WINDOW) ); } /*-----Thin Gap Chamber--------------------------------------*/ /* Flames of TGC */ Doublet_x[0] = D_x; Doublet_y[0] = D_y; Doublet_x[1] = Doublet_x[0] + ( TGC_Xdown - TGC_Xup ) / 2; Doublet_y[1] = Doublet_y[0] + TGC_Y; Doublet_x[2] = Doublet_x[1] + TGC_Xup; Doublet_y[2] = Doublet_y[1]; Doublet_x[3] = Doublet_x[0] + TGC_Xdown; Doublet_y[3] = Doublet_y[0]; Doublet_x[4] = Doublet_x[0]; Doublet_y[4] = Doublet_y[0]; Triplet_x[0] = T_x; Triplet_y[0] = T_y; Triplet_x[1] = Triplet_x[0] + ( TGC_Xdown - TGC_Xup ) / 2; Triplet_y[1] = Triplet_y[0] + TGC_Y; Triplet_x[2] = Triplet_x[1] + TGC_Xup; Triplet_y[2] = Triplet_y[1]; Triplet_x[3] = Triplet_x[0] + TGC_Xdown; Triplet_y[3] = Triplet_y[0]; Triplet_x[4] = Triplet_x[0]; Triplet_y[4] = Triplet_y[0]; for ( a = 0; a < TGC_MAX; a++ ) { D_frame[a].x = Xcvt( Doublet_x[a] ); D_frame[a].y = Ycvt( Doublet_y[a] ); T_frame[a].x = Xcvt( Triplet_x[a] ); T_frame[a].y = Ycvt( Triplet_y[a] ); } gdk_draw_polygon( drawable, drawing_area->style->white_gc, FALSE, D_frame, 5 ); /*---Draw Flame of Doublet---*/ gdk_draw_polygon( drawable, drawing_area->style->white_gc, FALSE, T_frame, 5 ); /*---Draw Flame of Triplet---*/ /* Each Areas of TGC(Doublet)'s Wire ch. & Strip ch. */ for ( c = 0; c < 2; c++ ) { if ( c == 0 ) SetPenColor(0xffff, 0xcccc, 0xffff); /*---色の生成:ピンク---*/ if ( c == 1 ) SetPenColor(0xffff, 0xaaaa, 0xffff); /*---色の生成:ピンク---*/ for ( a = 0; a <= D_WIRE_MAX; a++ ) { for ( b = 0; b <= STRIP_MAX; b++ ) { if ( a == 0 ) { TGC_y[c][a][b] = D_y + Fst_W; } else { TGC_y[c][a][b] = TGC_y[c][a-1][0] + TGC_W[c][a-1] * W_PITCH; } x_length = line_eq( ( Doublet_x[2]-Fst_S ), ( Doublet_y[2]-Fst_W ), ( Doublet_x[3]-Fst_S ), ( Doublet_y[3]+Fst_W ), TGC_y[c][a][0] ) -line_eq( ( Doublet_x[0]+Fst_S ), ( Doublet_y[0]+Fst_W ), ( Doublet_x[1]+Fst_S ), ( Doublet_y[1]-Fst_W ), TGC_y[c][a][0] ); TGC_x[c][a][b] = line_eq( ( Doublet_x[0]+Fst_S ), ( Doublet_y[0]+Fst_W ), ( Doublet_x[1]+Fst_S ), ( Doublet_y[1]-Fst_W ), TGC_y[c][a][0] ) + x_length / STRIP_MAX * b; } } /*---drawing flag---*/ if ( !drawing_layer_flg[c] ) continue; for ( a = 0; a < D_WIRE_MAX; a++ ) { for ( b = 0; b < STRIP_MAX; b++ ) { point[c][a][b][0].x = Xcvt( TGC_x[c][a][b] ); point[c][a][b][0].y = Ycvt( TGC_y[c][a][b] ); point[c][a][b][1].x = Xcvt( TGC_x[c][a][b+1] ); point[c][a][b][1].y = Ycvt( TGC_y[c][a][b+1] ); point[c][a][b][2].x = Xcvt( TGC_x[c][a+1][b+1] ); point[c][a][b][2].y = Ycvt( TGC_y[c][a+1][b+1] ); point[c][a][b][3].x = Xcvt( TGC_x[c][a+1][b] ); point[c][a][b][3].y = Ycvt( TGC_y[c][a+1][b] ); point[c][a][b][4].x = point[c][a][b][0].x; point[c][a][b][4].y = point[c][a][b][0].y; gdk_draw_polygon( drawable, g_gc, FALSE, point[c][a][b], 5 ); /*---Draw Doublet---*/ } } } /* Each Areas of TGC(Triplet)'s Wire ch. & Strip ch. */ for ( c = 2; c < TGC_MAX; c++ ) { if ( c == 2 ) SetPenColor(0xcccc, 0xdddd, 0xffff); /*---色の生成:水色---*/ if ( c == 3 ) SetPenColor(0xaaaa, 0xdddd, 0xffff); /*---色の生成:水色---*/ if ( c == 4 ) SetPenColor(0x8888, 0xdddd, 0xffff); /*---色の生成:水色---*/ for ( a = 0; a <= T_WIRE_MAX; a++ ) { for ( b = 0; b <= STRIP_MAX; b++ ) { if ( a == 0 ) { TGC_y[c][a][b] = T_y + Fst_W; } else { TGC_y[c][a][b] = TGC_y[c][a-1][0] + TGC_W[c][a-1] * W_PITCH; } x_length = line_eq( ( Triplet_x[2]-Fst_S ), ( Triplet_y[2]-Fst_W ), ( Triplet_x[3]-Fst_S ), ( Triplet_y[3]+Fst_W ), TGC_y[c][a][0] ) -line_eq( ( Triplet_x[0]+Fst_S ), ( Triplet_y[0]+Fst_W ), ( Triplet_x[1]+Fst_S ), ( Triplet_y[1]-Fst_W ), TGC_y[c][a][0] ); TGC_x[c][a][b] = line_eq( ( Triplet_x[0]+Fst_S ), ( Triplet_y[0]+Fst_W ), ( Triplet_x[1]+Fst_S ), ( Triplet_y[1]-Fst_W ), TGC_y[c][a][0] ) + x_length / STRIP_MAX * b; } } if ( c == 2 || c == 4 ) { /*---drawing flag---*/ if ( !drawing_layer_flg[c] ) continue; for ( a = 0; a < T_WIRE_MAX; a++ ) { for ( b = 0; b < STRIP_MAX; b++ ) { point[c][a][b][0].x = Xcvt( TGC_x[c][a][b] ); point[c][a][b][0].y = Ycvt( TGC_y[c][a][b] ); point[c][a][b][1].x = Xcvt( TGC_x[c][a][b+1] ); point[c][a][b][1].y = Ycvt( TGC_y[c][a][b+1] ); point[c][a][b][2].x = Xcvt( TGC_x[c][a+1][b+1] ); point[c][a][b][2].y = Ycvt( TGC_y[c][a+1][b+1] ); point[c][a][b][3].x = Xcvt( TGC_x[c][a+1][b] ); point[c][a][b][3].y = Ycvt( TGC_y[c][a+1][b] ); point[c][a][b][4].x = point[c][a][b][0].x; point[c][a][b][4].y = point[c][a][b][0].y; gdk_draw_polygon( drawable, g_gc, FALSE, point[c][a][b], 5 ); /*---Draw Triplet---*/ } } } else if ( c == 3 ) { /*---drawing flag---*/ if ( !drawing_layer_flg[c] ) continue; for ( a = 0; a < T_WIRE_MAX; a++ ) { point[c][a][0][0].x = Xcvt( TGC_x[c][a][0] ); point[c][a][0][0].y = Ycvt( TGC_y[c][a][0] ); point[c][a][0][1].x = Xcvt( TGC_x[c][a][32] ); point[c][a][0][1].y = Ycvt( TGC_y[c][a][32] ); point[c][a][0][2].x = Xcvt( TGC_x[c][a+1][32] ); point[c][a][0][2].y = Ycvt( TGC_y[c][a+1][32] ); point[c][a][0][3].x = Xcvt( TGC_x[c][a+1][0] ); point[c][a][0][3].y = Ycvt( TGC_y[c][a+1][0] ); point[c][a][0][4].x = point[c][a][0][0].x; point[c][a][0][4].y = point[c][a][0][0].y; gdk_draw_polygon( drawable, g_gc, FALSE, point[c][a][0], 5 ); /*---Draw Triplet---*/ } } else return; } /*-----Drift Chamber--------------------------------------*/ for ( a = 2; a < DC_MAX; a++ ) { if ( !drawing_dc_flg ) continue; SetPenColor(0xffff, 0xffff, 0xffff); /*---色の生成:白---*/ gdk_draw_rectangle ( drawable, g_gc, 0, Xcvt(dc_x[a]), Ycvt(dc_y[a]), scale_cvt(DC_X), scale_cvt(DC_Y) ); gdk_draw_rectangle ( drawable, g_gc, 0, Xcvt(dc_window_x[a]), Ycvt(dc_window_y[a]), scale_cvt(DC_WINDOW), scale_cvt(DC_WINDOW) ); } /*-----Beam Line--------------------------------------*/ SetPenColor(0x0000, 0xffff, 0x0000); /*---色の生成:緑---*/ gdk_draw_line( drawable, g_gc, Xcvt(-Xwidth), Ycvt(0), Xcvt(Xwidth), Ycvt(0) ); gdk_draw_line( drawable, g_gc, Xcvt(0), Ycvt(-Height), Xcvt(0), Ycvt(Height) ); } /********************************************************** Hit_Event_Load **********************************************************/ int decode_read_info ( char *read_info ) { if ( strcmp( read_info, "event" ) == 0 ) { return ( EVENT_MARK ); } else if ( strcmp( read_info, "hit_line_data" ) == 0 ) { return ( HIT_LINE_DATA ); } else if ( strcmp( read_info, "adc_sci_data" ) == 0 ) { return ( ADC_SCI_DATA ); } else if ( strcmp( read_info, "tmc_sci_data" ) == 0 ) { return ( TMC_SCI_DATA ); } else if ( strcmp( read_info, "tmc_dc_data" ) == 0 ) { return ( TMC_DC_DATA ); } else if ( strcmp( read_info, "adc_tgc_data" ) == 0 ) { return ( ADC_TGC_DATA ); } else if ( strcmp( read_info, "tmc_tgc_data" ) == 0 ) { return ( TMC_TGC_DATA ); } else if ( strcmp( read_info, "end" ) == 0 ) { return ( END_MARK ); } else { return ( ERROR ); } } int Hit_Event_Load ( GtkWidget *widget, gpointer data ) { FILE *fp; int i; int read_mode; unsigned long int read_number; char read_info[MAX_DATA]; int disp_flg = 0; char buff[BUFF_LENGTH], tmp[BUFF_LENGTH]; fp = fopen( Data_File, "r" ); if ( fp == NULL ) { sprintf ( data_str, "File \"%s\" not found !", Data_File); gtk_label_set ( GTK_LABEL ( g_label ), data_str ); return( ERROR ); } while ( fgets( buff, BUFF_LENGTH, fp ) != NULL ) { if ( buff[0] == '#' || buff[0] == '\n' ) continue; else sscanf( buff, "%s %d \n", read_info, &read_number ); read_mode = decode_read_info ( read_info ); if ( read_mode == EVENT_MARK ) { if ( read_number > Data_Number ) { sprintf ( data_str, "File : %s Event Number : %6lu \" No Exist ! \"", Data_File, Data_Number ); gtk_label_set ( GTK_LABEL ( g_label ), data_str ); return( ERROR ); } disp_flg = ( read_number == Data_Number ); } else if ( read_mode == HIT_LINE_DATA ) { if ( disp_flg ) { for ( i = 0; i < read_number; i++ ) { fscanf ( fp, "%lf %lf %lf %lf %lf %lf \n", &hit_line.X1, &hit_line.Y1, &hit_line.Z1, &hit_line.X2, &hit_line.Y2, &hit_line.Z2 ); } } } else if ( read_mode == ADC_SCI_DATA ) { if ( disp_flg ) { for ( i = 0; i < read_number; i++ ) { fgets( tmp, BUFF_LENGTH, fp ); } } } else if ( read_mode == TMC_SCI_DATA ) { if ( disp_flg ) { /*---clear contents of Sci list---*/ hit_sci_list_first (); hit_sci_list_remove_all (); hit_sci_list_read ( fp, read_number, read_mode ); } } else if ( read_mode == TMC_DC_DATA ) { if ( disp_flg ) { /*---clear contents of DC list---*/ hit_dc_list_first (); hit_dc_list_remove_all (); hit_dc_list_read ( fp, read_number, read_mode ); } } else if ( read_mode == ADC_TGC_DATA ) { if ( disp_flg ) { for ( i = 0; i < read_number; i++ ) { fgets( tmp, BUFF_LENGTH, fp ); } } } else if ( read_mode == TMC_TGC_DATA ) { if ( disp_flg ) { /*---clear contents of TGC list---*/ hit_tgc_list_first (); hit_tgc_list_remove_all (); hit_tgc_list_read ( fp, read_number, read_mode ); } } else if ( read_mode == END_MARK ) { if ( disp_flg ) break; } else { if ( disp_flg ) return( ERROR ); } } if ( read_number < Data_Number ) { sprintf ( data_str, "File : %s Event Number : %6lu \" No Exist ! \"", Data_File, Data_Number ); gtk_label_set ( GTK_LABEL ( g_label ), data_str ); return( ERROR ); } fclose( fp ); /* Set event load flag */ event_load_flg = TRUE; sprintf ( data_str, "File : %s Event Number : %6lu", Data_File, Data_Number ); gtk_label_set ( GTK_LABEL ( g_label ), data_str ); Hit_Event_Draw ( data ); } /********************************************************** destroy **********************************************************/ void quit () { gtk_exit (0); } /********************************************************** Hit_Event_Delete **********************************************************/ void Hit_Event_Delete ( GtkWidget *widget, gpointer data ) { /* Unset event load flag */ event_load_flg = FALSE; initialization (); hit_sci_list_init (); hit_dc_list_init (); hit_tgc_list_init (); Paint ( data ); Hit_Event_Draw ( data ); } /********************************************************** Expand **********************************************************/ void Expand ( GtkWidget *widget, gpointer data ) { GdkDrawable *drawable; GtkWidget *drawing_area; GtkWidget *parent; GtkViewport *viewport; GdkWindow *window; GtkType type; factor += ( scale_factor / 2 * 10 ); scale_factor *= 2; drawing_area = (GtkWidget *) data; window = gtk_widget_get_parent_window( drawing_area ); gdk_window_resize ( window, (int)scale_cvt( Xwidth ), (int)scale_cvt( Height ) ); window = drawing_area->window; gdk_window_resize ( window, (int)scale_cvt( Xwidth ), (int)scale_cvt( Height ) ); gtk_drawing_area_size ( GTK_DRAWING_AREA ( drawing_area ), scale_cvt( Xwidth ), scale_cvt( Height ) ); Paint ( data ); Hit_Event_Draw ( data ); /*--- pointer to GtkScroledWindow ---*/ parent = drawing_area->parent; viewport = GTK_VIEWPORT(parent); parent = parent->parent; if ( GTK_IS_SCROLLED_WINDOW (parent) ) { GtkScrolledWindow * swindow = GTK_SCROLLED_WINDOW (parent); GtkAdjustment *vadj, *hadj; hadj = gtk_scrolled_window_get_hadjustment ( swindow ); // hadj->upper = scale_cvt( Xwidth ); hadj->value = scale_cvt( Xwidth / (scale_factor * 10) * factor ); gtk_adjustment_changed ( hadj ); vadj = gtk_scrolled_window_get_vadjustment ( swindow ); // vadj->upper = scale_cvt( Height ); vadj->value = scale_cvt( Height / (scale_factor * 10) * factor ); gtk_adjustment_changed ( vadj ); } else { type = GTK_OBJECT_TYPE ( parent ); printf( "%s \n",gtk_type_name(type) ); } } /********************************************************** Reduce **********************************************************/ void Reduce ( GtkWidget *widget, gpointer data ) { GdkDrawable *drawable; GtkWidget *drawing_area; GtkWidget *parent; GtkViewport *viewport; GdkWindow *window; GtkType type; if ( scale_factor < 0.21 ) return; scale_factor /= 2; factor += -( scale_factor / 2 * 10 ); drawing_area = (GtkWidget *) data; window = gtk_widget_get_parent_window ( drawing_area ); gdk_window_resize( window, (int)scale_cvt(Xwidth), (int)scale_cvt(Height) ); window = drawing_area->window; gdk_window_resize( window, (int)scale_cvt(Xwidth), (int)scale_cvt(Height) ); gtk_drawing_area_size ( GTK_DRAWING_AREA (drawing_area), scale_cvt(Xwidth), scale_cvt(Height) ); Paint ( data ); Hit_Event_Draw ( data ); /*--- pointer to GtkScroledWindow ---*/ parent = drawing_area->parent; viewport = GTK_VIEWPORT (parent); parent = parent->parent; if ( GTK_IS_SCROLLED_WINDOW (parent) ) { GtkScrolledWindow * swindow = GTK_SCROLLED_WINDOW (parent); GtkAdjustment *vadj, *hadj; hadj = gtk_scrolled_window_get_hadjustment ( swindow ); // hadj->upper = scale_cvt(Xwidth); hadj->value = scale_cvt( Xwidth / (scale_factor * 10) * factor ); gtk_adjustment_changed ( hadj ); vadj = gtk_scrolled_window_get_vadjustment ( swindow ); // vadj->upper = scale_cvt(Height); vadj->value = scale_cvt( Height / (scale_factor * 10) * factor ); gtk_adjustment_changed ( vadj ); } else { type = GTK_OBJECT_TYPE ( parent ); printf( "%s \n",gtk_type_name(type) ); } } /********************************************************** Prev **********************************************************/ void Prev ( GtkWidget *widget, gpointer data ) { if ( Data_Number == 1 ) return; Hit_Event_Delete ( widget, data ); Data_Number += -1; Hit_Event_Load ( widget, data ); } /********************************************************** Next **********************************************************/ void Next ( GtkWidget *widget, gpointer data ) { Hit_Event_Delete ( widget,data ); Data_Number += 1; Hit_Event_Load ( widget,data ); } /********************************************************** Init_Draw_All **********************************************************/ void Init_Draw_All ( void ) { gtk_toggle_button_set_active( (GtkToggleButton*)button8, TRUE ); //layer0 gtk_toggle_button_set_active( (GtkToggleButton*)button9, TRUE ); //layer1 gtk_toggle_button_set_active( (GtkToggleButton*)button10, TRUE ); //layer2 gtk_toggle_button_set_active( (GtkToggleButton*)button11, TRUE ); //layer3 gtk_toggle_button_set_active( (GtkToggleButton*)button12, TRUE ); //layer4 gtk_toggle_button_set_active( (GtkToggleButton*)button15, TRUE ); //DC } /********************************************************** Draw_DC **********************************************************/ void Draw_DC ( GtkWidget *widget, gpointer data ) { drawing_dc_flg = !drawing_dc_flg; Paint ( data ); Hit_Event_Draw ( data ); } /********************************************************** Draw_layer0 **********************************************************/ void Draw_layer0 ( GtkWidget *widget, gpointer data ) { drawing_layer_flg[0] = !drawing_layer_flg[0]; Paint ( data ); Hit_Event_Draw ( data ); } /********************************************************** Draw_layer1 **********************************************************/ void Draw_layer1 ( GtkWidget *widget, gpointer data ) { drawing_layer_flg[1] = !drawing_layer_flg[1]; Paint ( data ); Hit_Event_Draw ( data ); } /********************************************************** Draw_layer2 **********************************************************/ void Draw_layer2 ( GtkWidget *widget, gpointer data ) { drawing_layer_flg[2] = !drawing_layer_flg[2]; Paint ( data ); Hit_Event_Draw ( data ); } /********************************************************** Draw_layer3 **********************************************************/ void Draw_layer3 ( GtkWidget *widget, gpointer data ) { drawing_layer_flg[3] = !drawing_layer_flg[3]; Paint ( data ); Hit_Event_Draw ( data ); } /********************************************************** Draw_layer4 **********************************************************/ void Draw_layer4 ( GtkWidget *widget, gpointer data) { drawing_layer_flg[4] = !drawing_layer_flg[4]; Paint ( data ); Hit_Event_Draw ( data ); } /********************************************************** Draw_All **********************************************************/ void Draw_All ( GtkWidget *widget, gpointer data ) { gtk_toggle_button_set_active( (GtkToggleButton*)button8, TRUE ); //layer0 gtk_toggle_button_set_active( (GtkToggleButton*)button9, TRUE ); //layer1 gtk_toggle_button_set_active( (GtkToggleButton*)button10, TRUE ); //layer2 gtk_toggle_button_set_active( (GtkToggleButton*)button11, TRUE ); //layer3 gtk_toggle_button_set_active( (GtkToggleButton*)button12, TRUE ); //layer4 gtk_toggle_button_set_active( (GtkToggleButton*)button15, TRUE ); //DC Paint ( data ); Hit_Event_Draw ( data ); } /********************************************************** Draw_Clear **********************************************************/ void Draw_Clear ( GtkWidget *widget, gpointer data ) { gtk_toggle_button_set_active( (GtkToggleButton*)button8, FALSE ); //layer0 gtk_toggle_button_set_active( (GtkToggleButton*)button9, FALSE ); //layer1 gtk_toggle_button_set_active( (GtkToggleButton*)button10, FALSE ); //layer2 gtk_toggle_button_set_active( (GtkToggleButton*)button11, FALSE ); //layer3 gtk_toggle_button_set_active( (GtkToggleButton*)button12, FALSE ); //layer4 gtk_toggle_button_set_active( (GtkToggleButton*)button15, FALSE ); //DC Paint ( data ); Hit_Event_Draw ( data ); } /********************************************************** GetWire **********************************************************/ void GetWire( char *ptr ) { int channel, doublet1, doublet2, triplet1, triplet2, triplet3; if ( wire_flg < 24 ) { if ( sscanf( ptr, "%d %d %d %d %d %d \n", &channel, &doublet1, &doublet2, &triplet1, &triplet2, &triplet3 ) != 6 ) { perror( "GetWire1 : find wrong format" ); printf("%d:%s\n",wire_flg, ptr); return; } TGC_W[0][channel] = doublet1; TGC_W[1][channel] = doublet2; TGC_W[2][channel] = triplet1; TGC_W[3][channel] = triplet2; TGC_W[4][channel] = triplet3; } else { if ( sscanf( ptr, "%d %d %d", &channel, &doublet1, &doublet2 ) != 3 ) { perror( "GetWire2 : find wrong format" ); return; } TGC_W[0][channel] = doublet1; TGC_W[1][channel] = doublet2; } wire_flg++; } /********************************************************** GetStrip **********************************************************/ void GetStrip( char *ptr ) { int channel, doublet1, doublet2, triplet1, triplet2, triplet3; sscanf( ptr, "%d %d %d %d %d %d \n", &channel, &doublet1, &doublet2, &triplet1, &triplet2, &triplet3 ); TGC_S[0][channel] = doublet1; TGC_S[1][channel] = doublet2; TGC_S[2][channel] = triplet1; TGC_S[3][channel] = triplet2; TGC_S[4][channel] = triplet3; } /********************************************************** GetTGC **********************************************************/ int GetTGC() { int id = 0; FILE *fp; char buff[BUFF_LENGTH]; if ( ( fp = fopen( TGC_FILE, "r" ) ) == NULL ) { fprintf( stderr, "File \"tgc_file\" not found !\n" ); return( ERROR ); } while ( fgets( buff, BUFF_LENGTH, fp ) != NULL ) { if ( buff[0] == '#' || buff[0] == '\n' ) continue; else if ( strncmp( buff, "WIRE", 4 ) == 0 ) id = WIRE; else if ( strncmp( buff, "STRIP", 5 ) == 0 ) id = STRIP; else switch ( id ) { case WIRE: GetWire( buff ); break; case STRIP: GetStrip( buff ); break; } } fclose( fp ); } /********************************************************** GetTGCPosition **********************************************************/ int GetTGCPosition( ) { FILE *fp; char buff[BUFF_LENGTH]; char *data_ptr; if ( ( fp = fopen( Data_File, "r" ) ) == NULL ) { sprintf( data_str, "File \"%s\" not found !", Data_File ); return( ERROR ); } while ( fgets( buff, BUFF_LENGTH, fp ) != NULL ) { if ( strncmp( buff, "# D1", 4 ) == 0 ) { /* search ':' */ data_ptr = strchr( buff, ':' ); if ( data_ptr == NULL ) { sprintf( data_str, "Error : Unable to find \':\' in %s\n", buff ); return( ERROR ); } data_ptr++; /* read parameters after ':'. Don't miss top space char in the format.*/ sscanf( data_ptr, " %d %d %d", &D_x, &D_y, &D_z ); } else if ( strncmp( buff, "# T3", 4 ) == 0 ) { /* search ':' */ data_ptr = strchr( buff, ':' ); if ( data_ptr == NULL ) { sprintf( data_str, "Error : Unable to find \':\' in %s\n", buff ); return( ERROR ); } data_ptr++; /* read parameters after ':'. Don't miss top space char in the format.*/ sscanf( ++data_ptr, " %d %d %d", &T_x, &T_y, &T_z ); break; } } fclose( fp ); } /********************************************************** メインプログラム **********************************************************/ int main ( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *scrolled_window; GtkWidget *drawing_area; GtkWidget *button1, *button2, *button3, *button4, *button5, *button6, *button7, *button13, *button14; GtkWidget *hbox1, *hbox2, *hbox3, *hbox4, *hbox5, *hbox6 ,*hbox7, *hbox8, *hbox9, *vbox; /*---initialize---*/ gtk_init ( &argc, &argv ); hit_sci_list_init (); hit_dc_list_init (); hit_tgc_list_init (); initialization (); /*---options---*/ if ( argc < 2 || argc > 3 ) usage( argv[0] ); Data_File = argv[1]; if ( argc == 2 ) Data_Number = 1; else Data_Number = atoi( argv[2] ); if ( Data_Number < 1 ) usage ( argv[0] ); /*---read tgc.cfg from data_file---*/ GetTGCPosition(); GetTGC(); /*---create widow---*/ window = gtk_dialog_new (); gtk_widget_set_usize ( window, scale_cvt(Xwidth + 110) , scale_cvt(Height + 1030) ); scrolled_window = gtk_scrolled_window_new ( NULL, NULL ); gtk_box_pack_start ( GTK_BOX (GTK_DIALOG (window)->vbox), scrolled_window, TRUE, TRUE, 0 ); drawing_area = gtk_drawing_area_new (); gtk_drawing_area_size ( GTK_DRAWING_AREA (drawing_area), scale_cvt(Xwidth), scale_cvt(Height) ); gtk_scrolled_window_add_with_viewport ( GTK_SCROLLED_WINDOW (scrolled_window), drawing_area ); gtk_signal_connect ( GTK_OBJECT (drawing_area), "expose_event", GTK_SIGNAL_FUNC (Paint), NULL ); gtk_signal_connect ( GTK_OBJECT(drawing_area), "expose_event", GTK_SIGNAL_FUNC (Hit_Event_Draw), NULL); gtk_widget_show ( drawing_area ); /*---create vertical box---*/ vbox = gtk_vbox_new ( FALSE, 0 ); gtk_box_pack_start ( GTK_BOX (GTK_DIALOG (window)->action_area), vbox, TRUE, TRUE, 0 ); gtk_widget_show ( vbox ); gtk_signal_connect ( GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (quit), NULL ); /*---create horizontal box---*/ hbox1 = gtk_hbox_new ( FALSE, 0 ); hbox2 = gtk_hbox_new ( FALSE, 0 ); hbox3 = gtk_hbox_new ( FALSE, 0 ); hbox4 = gtk_hbox_new ( FALSE, 0 ); hbox5 = gtk_hbox_new ( FALSE, 0 ); hbox6 = gtk_hbox_new ( FALSE, 0 ); hbox7 = gtk_hbox_new ( FALSE, 0 ); hbox8 = gtk_hbox_new ( FALSE, 0 ); hbox9 = gtk_hbox_new ( FALSE, 0 ); gtk_box_pack_start ( GTK_BOX (vbox), hbox1, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (vbox), hbox2, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (vbox), hbox3, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (vbox), hbox4, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (vbox), hbox5, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (vbox), hbox6, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (vbox), hbox7, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (vbox), hbox8, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (vbox), hbox9, TRUE, TRUE, 0 ); gtk_widget_show ( hbox1 ); gtk_widget_show ( hbox2 ); gtk_widget_show ( hbox3 ); gtk_widget_show ( hbox4 ); gtk_widget_show ( hbox5 ); gtk_widget_show ( hbox6 ); gtk_widget_show ( hbox7 ); gtk_widget_show ( hbox8 ); gtk_widget_show ( hbox9 ); /*---create label---*/ g_label = gtk_label_new(""); label[0] = gtk_label_new("TGC layer 0 :"); label[1] = gtk_label_new("TGC layer 1 :"); label[2] = gtk_label_new("TGC layer 2 :"); label[3] = gtk_label_new("TGC layer 3 :"); label[4] = gtk_label_new("TGC layer 4 :"); gtk_box_pack_start ( GTK_BOX (hbox1), g_label, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox2), label[0], FALSE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox3), label[1], FALSE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox4), label[2], FALSE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox5), label[3], FALSE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox6), label[4], FALSE, TRUE, 0 ); gtk_widget_show ( g_label ); gtk_widget_show ( label[0] ); gtk_widget_show ( label[1] ); gtk_widget_show ( label[2] ); gtk_widget_show ( label[3] ); gtk_widget_show ( label[4] ); if ( data_str[0] == '\0' ) { sprintf ( data_str, "File : %s Event Number : %6ld", Data_File, Data_Number ); } gtk_label_set ( GTK_LABEL ( g_label ), data_str ); /*---create button---*/ button1 = gtk_button_new_with_label ("Event_Load"); button2 = gtk_button_new_with_label ("Event_Delete"); button3 = gtk_button_new_with_label ("Expand"); button4 = gtk_button_new_with_label ("Reduce"); button5 = gtk_button_new_with_label (" Exit "); button6 = gtk_button_new_with_label (" Prev "); button7 = gtk_button_new_with_label (" Next "); button15 = gtk_toggle_button_new_with_label (" DC "); button8 = gtk_toggle_button_new_with_label ("layer 0"); button9 = gtk_toggle_button_new_with_label ("layer 1"); button10 = gtk_toggle_button_new_with_label ("layer 2"); button11 = gtk_toggle_button_new_with_label ("layer 3"); button12 = gtk_toggle_button_new_with_label ("layer 4"); button13 = gtk_button_new_with_label (" All "); button14 = gtk_button_new_with_label (" Clear "); gtk_box_pack_start ( GTK_BOX (hbox8), button6, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox8), button1, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox8), button2, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox8), button7, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox9), button3, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox9), button4, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox9), button5, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox7), button15, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox7), button8, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox7), button9, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox7), button10, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox7), button11, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox7), button12, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox7), button13, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX (hbox7), button14, TRUE, TRUE, 0 ); gtk_signal_connect ( GTK_OBJECT (button6), "clicked", GTK_SIGNAL_FUNC (Prev), drawing_area ); gtk_signal_connect ( GTK_OBJECT (button7), "clicked", GTK_SIGNAL_FUNC (Next), drawing_area ); gtk_signal_connect ( GTK_OBJECT (button3), "clicked", GTK_SIGNAL_FUNC (Expand), drawing_area ); gtk_signal_connect ( GTK_OBJECT (button4), "clicked", GTK_SIGNAL_FUNC (Reduce), drawing_area ); gtk_signal_connect ( GTK_OBJECT (button1), "clicked", GTK_SIGNAL_FUNC (Hit_Event_Load), drawing_area ); gtk_signal_connect ( GTK_OBJECT (button2), "clicked", GTK_SIGNAL_FUNC (Hit_Event_Delete), drawing_area ); gtk_signal_connect ( GTK_OBJECT (button5), "clicked", GTK_SIGNAL_FUNC (quit), drawing_area ); gtk_signal_connect ( GTK_OBJECT (button15), "toggled", GTK_SIGNAL_FUNC (Draw_DC), drawing_area ); gtk_signal_connect ( GTK_OBJECT (button8), "toggled", GTK_SIGNAL_FUNC (Draw_layer0), drawing_area ); gtk_signal_connect ( GTK_OBJECT (button9), "toggled", GTK_SIGNAL_FUNC (Draw_layer1), drawing_area ); gtk_signal_connect ( GTK_OBJECT (button10), "toggled", GTK_SIGNAL_FUNC (Draw_layer2), drawing_area ); gtk_signal_connect ( GTK_OBJECT (button11), "toggled", GTK_SIGNAL_FUNC (Draw_layer3), drawing_area ); gtk_signal_connect ( GTK_OBJECT (button12), "toggled", GTK_SIGNAL_FUNC (Draw_layer4), drawing_area ); gtk_signal_connect ( GTK_OBJECT (button13), "clicked", GTK_SIGNAL_FUNC (Draw_All), drawing_area ); gtk_signal_connect ( GTK_OBJECT (button14), "clicked", GTK_SIGNAL_FUNC (Draw_Clear), drawing_area ); gtk_widget_show ( button1 ); gtk_widget_show ( button2 ); gtk_widget_show ( button3 ); gtk_widget_show ( button4 ); gtk_widget_show ( button5 ); gtk_widget_show ( button6 ); gtk_widget_show ( button7 ); gtk_widget_show ( button15 ); gtk_widget_show ( button8 ); gtk_widget_show ( button9 ); gtk_widget_show ( button10 ); gtk_widget_show ( button11 ); gtk_widget_show ( button12 ); gtk_widget_show ( button13 ); gtk_widget_show ( button14 ); gtk_widget_show_all ( window ); CreatePen ( window ); Init_Draw_All(); gtk_main (); exit (0); } /********************************************************** E N D **********************************************************/