📄 sg.c
字号:
#include<gnome.h>#include"sg.h"#include"popmenu.h"#include"main.h"#define Sg_Num 30 gchar* color[7]={"red","blue","white","yellow","black","green","orange"}; int SgNode_StatTab[Sg_Num][7]={ /*信号静态表*/ 0x8000,0xf8, 60,380,0x0a,0x2003,0x2005, /* D1 */ 0x8001,0xdc,130,380,0x0a,0x4000,0x2004, /* D3 */ 0x8002,0xd0,140,320,0x0a,0x2006,0x4005, /* D5 */ 0x8003,0xe8,140,260,0x0a,0x2001,0x4003, /* D7 */ 0x8004,0xdc,210,320,0x0a,0x4002,0x8005, /* D9 */ 0x8005,0xd8,210,320,0x0a,0x8004,0x4006, /* D11 */ 0x8006,0xd8,210,380,0x0a,0x2004,0x4007, /* D13 */ 0x8007,0xd0,210,260,0x0a,0x4004,0x200b, /* D15 */ 0x8008,0xd0,280,380,0x0a,0x200a,0x200c, /* D17 */ 0x8009,0xe4,350,320,0x0a,0x400b,0x200b, /* D19 */ 0x800a,0xbb,40,320,0x0a,0x2002,0x4001, /* X */ 0x800b,0xbb,50,260,0x0a,0x2000,0x2001, /* Xd */ 0x800c,0x7e,350,260,0x0a,0x4008,0x200f, /* S3 */ 0x800d,0x7e,350,200,0x0a,0x4008,0x2011, /* S5 */ 0x800e,0x7e,350,380,0x0a,0x4009,0x200e, /* S2 */ 0x800f,0x7e,350,440,0x0a,0x4009,0x2010, /* S4 */ 0x8010,0xec,680,380,0x0a,0x400d,0x2013, /* D2 */ 0x8011,0xec,680,320,0x0a,0x400b,0x2014, /* D4 */ 0x8012,0xd4,610,320,0x0a,0x2018,0x400c, /* D6 */ 0x8013,0xe0,480,380,0x0a,0x200e,0x400e, /* D8 */ 0x8014,0xbf,760,380,0x0a,0x2013,0x2012, /* S */ 0x8015,0x78,480,320,0x0a,0x200d,0x400f, /* X1 */ 0x8016,0x78,480,260,0x0a,0x200f,0x4010, /* X3 */ 0x8017,0x78,480,440,0x0a,0x2010,0x400e, /* X4 */ 0x8018,0x78,480,200,0x0a,0x2011,0x4010, /* X5 */ 0x8019,0x00,40,320,0x01,0x800a,0x0000, /* XTA */ 0x801a,0x00,60,320,0x03,0x8002,0x0000, /* XDEA*/ 0x801b,0x00,50,380,0x05,0x8000,0x0000, /* SIEA*/ 0x801c,0x00,730,320,0x05,0x8011,0x0000, /* XLEA*/ 0x801d,0x00,710,380,0x05,0x8014,0x0000 /* STA */}; int SgNode_DynTab[Sg_Num][6]={ /*信号动态表*/ 0x8000,0x01,0x55,0x55,0x55,0x55, /* D1 */ 0x8001,0x01,0x55,0x55,0x55,0x55, /* D3 */ 0x8002,0x01,0x55,0x55,0x55,0x55, /* D5 */ 0x8003,0x01,0x55,0x55,0x55,0x55, /* D7 */ 0x8004,0x01,0x55,0x55,0x55,0x55, /* D9 */ 0x8005,0x01,0x55,0x55,0x55,0x55, /* D11 */ 0x8006,0x01,0x55,0x55,0x55,0x55, /* D13 */ 0x8007,0x01,0x55,0x55,0x55,0x55, /* D15 */ 0x8008,0x01,0x55,0x55,0x55,0x55, /* D17 */ 0x8009,0x01,0x55,0x55,0x55,0x55, /* D19 */ 0x800a,0x67,0x55,0x55,0x55,0x55, /* X */ 0x800b,0x0B,0x55,0x55,0x55,0x55, /* XD */ 0x800c,0x0d,0x55,0x55,0x55,0x55, /* S3 */ 0x800d,0x0d,0x55,0x55,0x55,0x55, /* S5 */ 0x800e,0x15,0x55,0x55,0x55,0x55, /* S2 */ 0x800f,0x15,0x55,0x55,0x55,0x55, /* S4 */ 0x8010,0x01,0x55,0x55,0x55,0x55, /* D2 */ 0x8011,0x01,0x55,0x55,0x55,0x55, /* D4 */ 0x8012,0x01,0x55,0x55,0x55,0x55, /* D6 */ 0x8013,0x01,0x55,0x55,0x55,0x55, /* D8 */ 0x8014,0x0b,0x55,0x55,0x55,0x55, /* S */ 0x8015,0x05,0x55,0x55,0x55,0x55, /* X1 */ 0x8016,0x01,0x55,0x55,0x55,0x55, /* X3 */ 0x8017,0x01,0x55,0x55,0x55,0x55, /* X4 */ 0x8018,0x01,0x55,0x55,0x55,0x55, /* X5 */ 0x8019,0x00,0x55,0x55,0x55,0x55, /* XTA */ 0x801a,0x00,0x55,0x55,0x55,0x55, /* XDEA*/ 0x801b,0x00,0x55,0x55,0x55,0x55, /* SLEA*/ 0x801c,0x00,0x55,0x55,0x55,0x55, /* XLEA*/ 0x801d,0x00,0x55,0x55,0x55,0x55 /* STA */ }; int Show_Leg(GtkWidget * canvas){ int dir,h,i,idlamp; double px,py; gchar* cr,*cr1,*cr2; unsigned char a,b,temp; if(Sg_Num<=1) return 0; for(i=0;i<25;i++){ idlamp=SgNode_StatTab[i][0]; b=SgNode_StatTab[i][1]; temp=SgNode_DynTab[i][1]; px=SgNode_StatTab[i][2]; py=SgNode_StatTab[i][3]; if((b==0xf8)||(b==0xdc)||(b==0xd0)||(b==0xe8)||(b==0xd8)||(b==0xe4)||(b==0xec) ||(b==0xd4)||(b==0xe0)){ /*单灯*/ a=b&0x01; if(a==0x01) h=1;/*有腿*/ else h=0;/*无腿*/ a=b&0x04; if(a==0x04) dir=1;/* <-- */ else dir=0;/*<--> */ if(temp==0x01) cr=color[1]; else cr=color[2]; DrawSignalSing(px,py,cr,dir,h,canvas,idlamp); } else if((b==0x78)||(b==0x7e)){ /*双灯*/ a=b&0x04; h=0; if(a==0x04) dir=1; /*<--*/ else dir=0; /*-->*/ cr1=cr2=color[4]; if(temp==0x15) cr1=color[5]; else if(temp==0x0d){ cr1=color[5]; cr2=color[5]; } else if(temp==0x03) cr1=color[2]; else if(temp==0x01) cr1=color[0]; else if(temp==0x05) cr1=color[5]; DrawSignalDouble(px,py,cr1,cr2,dir,h,canvas,idlamp); } else if((b==0xbb)||(b==0xbf)){ /*三灯*/ a=b&0x01; if(a==0x01) h=1; else h=0; a=b&0x04; if(a==0x04) dir=1;/*<--*/ else dir=0; /*-->*/ if((temp==0x36)||(temp==0x37)) cr1=color[5]; else if(temp==0x67){ cr1=color[5]; cr2=color[3]; } else if((temp==0x26)||(temp==0x27)) cr1=color[3]; else if(temp==0x23){ cr1=color[3]; cr2=color[3]; } else if(temp==0x0b){ cr1=color[0]; cr2=color[2]; } else if((temp==0x02)||(temp==0x03)) cr1=color[0]; DrawSignalDouble(px,py,cr1,cr2,dir,h,canvas,idlamp,i); } } return 1;} int DrawSignalSing(double x,double y,gchar *cor,int dir,int h,GtkWidget * canvas,int idlamp,int i){ GnomeCanvasGroup *group; GnomeCanvasPoints *point1; GnomeCanvasPoints *point2; GnomeCanvasItem *line1; GnomeCanvasItem *line2; GnomeCanvasItem *singlelamp; group=gnome_canvas_root(GNOME_CANVAS(canvas)); gdouble p1x,p1y,p2x,p2y,p3x,p3y,p4x,p4y,p5x,p5y,p6x,p6y,p7x,p7y,p8x,p8y; if((dir==0)&&(h==0)){ p1x=x+0.0; p1y=y+5.0; p2x=x+0.0; p2y=y-5.0; p3x=x+0.0; p3y=y-8.0; p4x=x+0.0; p4y=p3y-10.0; p5x=x+3.0; p5y=p4y; p6x=p5x; p6y=p5y+10.0; p7x=p5x+10.0; p7y=p4y; p8x=p7x; p8y=p6y; point1=gnome_canvas_points_new(2); point1->coords[0]=p1x; point1->coords[1]=p1y; point1->coords[2]=p2x; point1->coords[3]=p2y; gnome_canvas_item_new(group,gnome_canvas_line_get_type(), "points",point1,"fill_color", "white","width_units",0.7, "join_style", GDK_CAP_BUTT,"line_style", GDK_LINE_SOLID,NULL); gnome_canvas_points_unref(point1); point2=gnome_canvas_points_new(2); point2->coords[0]=p3x; point2->coords[1]=p3y; point2->coords[2]=p4x; point2->coords[3]=p4y; line2= gnome_canvas_item_new(group,gnome_canvas_line_get_type(), "points",point2,"fill_color", "white","width_units",0.6, "join_style", GDK_CAP_BUTT,"line_style", GDK_LINE_SOLID,NULL); gnome_canvas_points_unref(point2); } else if((dir==1)&&(h==0)){ p1x=x; p1y=y-5; p2x=x; p2y=y+5; p3x=x; p3y=y+8; p4x=x; p4y=p3y+10; p5x=p3x-3; p5y=p3y; p6x=p5x; p6y=p4y; p7x=p5x-10; p7y=p5y; p8x=p7x; p8y=p4y; point1=gnome_canvas_points_new(2); point1->coords[0]=p1x; point1->coords[1]=p1y; point1->coords[2]=p2x; point1->coords[3]=p2y; line1= gnome_canvas_item_new(group,gnome_canvas_line_get_type(), "points",point1,"fill_color", "white","width_units",0.7, "join_style", GDK_CAP_BUTT,"line_style", GDK_LINE_SOLID,NULL); gnome_canvas_points_unref(point1); point2=gnome_canvas_points_new(2); point2->coords[0]=p3x; point2->coords[1]=p3y; point2->coords[2]=p4x; point2->coords[3]=p4y; line2= gnome_canvas_item_new(group,gnome_canvas_line_get_type(), "points",point2,"fill_color", "white","width_units",0.6, "join_style", GDK_CAP_BUTT,"line_style", GDK_LINE_SOLID,NULL); gnome_canvas_points_unref(point2); } return 1;}int DrawSignalDouble(double x,double y,gchar *cor1,gchar *cor2,int dir,int h,GtkWidget * canvas,int idlamp,int i){ GnomeCanvasGroup *group; GnomeCanvasPoints *point1; GnomeCanvasPoints *point2; GnomeCanvasPoints *point3; GnomeCanvasItem *line1; GnomeCanvasItem *line2; GnomeCanvasItem *line3; GnomeCanvasItem *doublelamp; group=gnome_canvas_root(GNOME_CANVAS(canvas)); gdouble p1x,p1y,p2x,p2y,p3x,p3y,p4x,p4y,p5x,p5y,p6x,p6y,p7x,p7y,p8x,p8y,p9x,p9y,p10x,p10y,p11x,p11y,p12x,p12y; if((dir==0)&&(h==0)){ p1x=x; p1y=y+5; p2x=x; p2y=y-5; p3x=x; p3y=y-8; p4x=x; p4y=p3y-10; p5x=p3x+3; p5y=p4y; p6x=p5x; p6y=p3y; p7x=p5x+10; p7y=p5y; p8x=p7x; p8y=p3y; p9x=p7x+10; p9y=p7y; p10x=p9x; p10y=p3y; point1=gnome_canvas_points_new(2); point1->coords[0]=p1x; point1->coords[1]=p1y; point1->coords[2]=p2x; point1->coords[3]=p2y; line1= gnome_canvas_item_new(group,gnome_canvas_line_get_type(), "points",point1,"fill_color", "white","width_units",0.7, "join_style", GDK_CAP_BUTT,"line_style", GDK_LINE_SOLID,NULL); gnome_canvas_points_unref(point1); point2=gnome_canvas_points_new(2); point2->coords[0]=p3x; point2->coords[1]=p3y; point2->coords[2]=p4x; point2->coords[3]=p4y; line2= gnome_canvas_item_new(group,gnome_canvas_line_get_type(), "points",point2,"fill_color", "white","width_units",0.6, "join_style", GDK_CAP_BUTT,"line_style", GDK_LINE_SOLID,NULL); gnome_canvas_points_unref(point2); } if((dir==1)&&(h==0)){ p1x=x; p1y=y-5; p2x=x; p2y=y+5; p3x=x; p3y=y+8; p4x=x; p4y=p3y+10; p5x=p3x-3; p5y=p3y; p6x=p5x; p6y=p4y; p7x=p5x-10; p7y=p5y; p8x=p7x; p8y=p4y; p9x=p7x-10; p9y=p3y; p10x=p9x; p10y=p4y; point1=gnome_canvas_points_new(2); point1->coords[0]=p1x; point1->coords[1]=p1y; point1->coords[2]=p2x; point1->coords[3]=p2y; line1= gnome_canvas_item_new(group,gnome_canvas_line_get_type(), "points",point1,"fill_color", "white","width_units",0.7, "join_style", GDK_CAP_BUTT,"line_style", GDK_LINE_SOLID,NULL); gnome_canvas_points_unref(point1); point2=gnome_canvas_points_new(2); point2->coords[0]=p3x; point2->coords[1]=p3y; point2->coords[2]=p4x; point2->coords[3]=p4y; line2= gnome_canvas_item_new(group,gnome_canvas_line_get_type(), "points",point2,"fill_color", "white","width_units",0.6, "join_style", GDK_CAP_BUTT,"line_style", GDK_LINE_SOLID,NULL); gnome_canvas_points_unref(point2); } if((dir==0)&&(h==1)){/*画三灯-->*/ p1x=x; p1y=y+5; p2x=x; p2y=y-5; p3x=x; p3y=y-8; p4x=x; p4y=p3y-5; p5x=x; p5y=p3y-10; p6x=p5x+7; p6y=p5y; p7x=p6x; p7y=p6y+5; p8x=p7x; p8y=p6y+10; p9x=p6x+10; p9y=p5y; p10x=p9x; p10y=p3y; p11x=p9x+10; p11y=p9y; p12x=p11x; p12y=p10y; point1=gnome_canvas_points_new(2); point1->coords[0]=p1x; point1->coords[1]=p1y; point1->coords[2]=p2x; point1->coords[3]=p2y; line1= gnome_canvas_item_new(group,gnome_canvas_line_get_type(), "points",point1,"fill_color", "white","width_units",0.7, "join_style", GDK_CAP_BUTT,"line_style", GDK_LINE_SOLID,NULL); gnome_canvas_points_unref(point1); point2=gnome_canvas_points_new(2); point2->coords[0]=p3x; point2->coords[1]=p3y; point2->coords[2]=p5x; point2->coords[3]=p5y; line2= gnome_canvas_item_new(group,gnome_canvas_line_get_type(), "points",point2,"fill_color", "white","width_units",0.6, "join_style", GDK_CAP_BUTT,"line_style", GDK_LINE_SOLID,NULL); gnome_canvas_points_unref(point2); point3=gnome_canvas_points_new(2); point3->coords[0]=p4x; point3->coords[1]=p4y; point3->coords[2]=p7x; point3->coords[3]=p7y; line3= gnome_canvas_item_new(group,gnome_canvas_line_get_type(), "points",point3,"fill_color", "white","width_units",0.6, "join_style", GDK_CAP_BUTT,"line_style", GDK_LINE_SOLID,NULL); gnome_canvas_points_unref(point3); } if((dir==1)&&(h==1)){/*画三灯-->*/ p1x=x; p1y=y-5; p2x=x; p2y=y+5; p3x=x; p3y=y+8; p4x=x; p4y=p3y+5; p5x=x; p5y=p3y+10; p6x=p5x-7; p6y=p5y; p7x=p6x; p7y=p6y-5; p8x=p7x; p8y=p6y-10; p9x=p8x-10; p9y=p3y; p10x=p9x; p10y=p5y; p11x=p9x-10; p11y=p3y; p12x=p11x; p12y=p10y; point1=gnome_canvas_points_new(2); point1->coords[0]=p1x; point1->coords[1]=p1y; point1->coords[2]=p2x; point1->coords[3]=p2y; line1= gnome_canvas_item_new(group,gnome_canvas_line_get_type(), "points",point1,"fill_color", "white","width_units",0.7, "join_style", GDK_CAP_BUTT,"line_style", GDK_LINE_SOLID,NULL); gnome_canvas_points_unref(point1); point2=gnome_canvas_points_new(2); point2->coords[0]=p3x; point2->coords[1]=p3y; point2->coords[2]=p5x; point2->coords[3]=p5y; line2= gnome_canvas_item_new(group,gnome_canvas_line_get_type(), "points",point2,"fill_color", "white","width_units",0.6, "join_style", GDK_CAP_BUTT,"line_style", GDK_LINE_SOLID,NULL); gnome_canvas_points_unref(point2); point3=gnome_canvas_points_new(2); point3->coords[0]=p4x; point3->coords[1]=p4y; point3->coords[2]=p7x; point3->coords[3]=p7y; line3= gnome_canvas_item_new(group,gnome_canvas_line_get_type(), "points",point3,"fill_color", "white","width_units",0.6, "join_style", GDK_CAP_BUTT,"line_style", GDK_LINE_SOLID,NULL); gnome_canvas_points_unref(point3); } return 1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -