return 1;
}
-int scan_event(d3_lattice *d3_l,int *x,int *y,int *z,int *q,int *esc,int *switchmode,int *bmp)
+int scan_event(d3_lattice *d3_l,int *x,int *y,int *z,int *q,int *esc,int *switchmode,int *bmp,int *ac_distr)
{
DFBInputEvent ke;
if(ke.key_id==DIKI_3) *bmp=3;
if(ke.key_id==DIKI_4) *bmp=4;
if(ke.key_id==DIKI_5) *bmp=5;
+ if(ke.key_id==DIKI_A) *ac_distr=1;
+ if(ke.key_id==DIKI_C) *ac_distr=2;
+ if(ke.key_id==DIKI_B) *ac_distr=3;
}
return 1;
int d3_lattice_draw(d3_lattice *d3_l,int x,int y,int z,int arg_c,char **arg_v,unsigned char mode,int max_extra);
int d2_event_init(d2_lattice *d2_l);
int d3_event_init(d3_lattice *d3_l);
-int scan_event(d3_lattice *d3_l,int *x,int *y,int *z,int *q,int *esc,int *switchmode,int *bmp);
+int scan_event(d3_lattice *d3_l,int *x,int *y,int *z,int *q,int *esc,int *switchmode,int *bmp,int *ac_distr);
int dx_lattice_get_color(unsigned char *status,unsigned char *r,unsigned char *g,unsigned char *b,unsigned char mode);
#endif /* DFBAPI_H */
return max;
}
+int write_ac_distr(d3_lattice *d3_l,int ac_distr)
+{
+ int fd,x,y,z;
+ int count=0,offset;
+ char file[16];
+
+ if(ac_distr==1) strcpy(file,"a.plot");
+ if(ac_distr==2) strcpy(file,"c.plot");
+ if(ac_distr==3) strcpy(file,"b.plot");
+
+ if((fd=open(file,O_WRONLY|O_CREAT))<0)
+ {
+ puts("cannot open plot file");
+ return -1;
+ }
+
+ for(z=0;z<d3_l->max_z;z++)
+ {
+ for(x=0;x<d3_l->max_x;x++)
+ {
+ for(y=0;y<d3_l->max_y;y++)
+ {
+ offset=x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y;
+ if(ac_distr==1)
+ if(*(d3_l->status+offset)&AMORPH) count+=*(d3_l->extra+offset);
+ if(ac_distr==2)
+ if(!(*(d3_l->status+offset)&AMORPH)) count+=*(d3_l->extra+offset);
+ if(ac_distr==3) count+=*(d3_l->extra+offset);
+ }
+ }
+ dprintf(fd,"%d %d\n",z,count);
+ }
+ close(fd);
+
+ return 1;
+}
+
int write_bmp(d3_lattice *d3_l,int window,u32 x,u32 y,u32 z)
{
int fd,i,j,size=0,foo=0,end=0;
int main(int argc,char **argv)
{
u32 x,y,z,x_c,y_c,z_c;
- int i,j,quit,escape,switchmode,nowait,bmp;
+ int i,j,quit,escape,switchmode,nowait,bmp,ac_distr;
int refresh,resave;
int c_step;
char s_file[MAX_CHARS];
if(switchmode==2) strcpy(mode_txt,"view: a pressure mode");
d3_lattice_draw(&d3_l,x,y,z,25,arg_v,mode,max_extra);
bmp=0;
- scan_event(&d3_l,&x,&y,&z,&quit,&escape,&switchmode,&bmp);
+ ac_distr=0;
+ scan_event(&d3_l,&x,&y,&z,&quit,&escape,&switchmode,&bmp,&ac_distr);
if(bmp) write_bmp(&d3_l,bmp,x,y,z);
-
+ if(ac_distr) write_ac_distr(&d3_l,ac_distr);
}
d3_lattice_release(&d3_l);