first attempts printing graphs to dfb visual
authorhackbard <hackbard>
Wed, 11 Aug 2004 21:07:41 +0000 (21:07 +0000)
committerhackbard <hackbard>
Wed, 11 Aug 2004 21:07:41 +0000 (21:07 +0000)
dfbapi.c
dfbapi.h
nlsop.c
nlsop.h

index 18cf9cc..3d0a6df 100644 (file)
--- a/dfbapi.c
+++ b/dfbapi.c
@@ -97,7 +97,7 @@ int d3_lattice_release(d3_lattice *d3_l)
 int dx_lattice_get_color(unsigned char *status,unsigned char *r,unsigned char *g,unsigned char *b,unsigned char mode)
 {
  *g=0;
 int dx_lattice_get_color(unsigned char *status,unsigned char *r,unsigned char *g,unsigned char *b,unsigned char mode)
 {
  *g=0;
- if(!mode)
+ if((!mode)||mode==3)
  {
   if((*status)&RED)
   {
  {
   if((*status)&RED)
   {
@@ -185,7 +185,7 @@ int d2_lattice_draw(d2_lattice *d2_l,int x,int y,int arg_c,char **arg_v,unsigned
  return 1;
 }
 
  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 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,u32 *p1,u32 max1,u32 *p2,u32 max2)
 {
  int x_c,y_c,z_c;
  int i;
 {
  int x_c,y_c,z_c;
  int i;
@@ -199,7 +199,16 @@ int d3_lattice_draw(d3_lattice *d3_l,int x,int y,int z,int arg_c,char **arg_v,un
  {
   for(z_c=0;z_c<d3_l->max_z;z_c++)
   {
  {
   for(z_c=0;z_c<d3_l->max_z;z_c++)
   {
-   if(!mode) dx_lattice_get_color((*d3_l).status+x_c+y_c*d3_l->max_x+z_c*d3_l->max_x*d3_l->max_y,&r,&g,&b,mode);
+   if((!mode)||mode==3) dx_lattice_get_color((*d3_l).status+x_c+y_c*d3_l->max_x+z_c*d3_l->max_x*d3_l->max_y,&r,&g,&b,mode);
+   if(mode==3)
+   {
+    if(d3_l->max_x*p1[z_c]/max1==x_c)
+    {
+     r=0xff;
+     g=0xff;
+     b=0xff;
+    }
+   }
    if(mode==1)
    {
     foobar=(unsigned char)(*(d3_l->extra+x_c+y_c*d3_l->max_x+z_c*d3_l->max_x*d3_l->max_y)*255/max_extra);
    if(mode==1)
    {
     foobar=(unsigned char)(*(d3_l->extra+x_c+y_c*d3_l->max_x+z_c*d3_l->max_x*d3_l->max_y)*255/max_extra);
@@ -229,7 +238,16 @@ int d3_lattice_draw(d3_lattice *d3_l,int x,int y,int z,int arg_c,char **arg_v,un
  {
   for(z_c=0;z_c<d3_l->max_z;z_c++)
   {
  {
   for(z_c=0;z_c<d3_l->max_z;z_c++)
   {
-   if(!mode) dx_lattice_get_color((*d3_l).status+x_c+y_c*d3_l->max_x+z_c*d3_l->max_x*d3_l->max_y,&r,&g,&b,mode);
+   if((!mode)||mode==3) dx_lattice_get_color((*d3_l).status+x_c+y_c*d3_l->max_x+z_c*d3_l->max_x*d3_l->max_y,&r,&g,&b,mode);
+   if(mode==3)
+   {
+    if(d3_l->max_y*p1[z_c]/max2==y_c)
+    {
+     r=0xff;
+     g=0xff;
+     b=0xff;
+    }
+   }
    if(mode==1)
    {
     foobar=(unsigned char)(*(d3_l->extra+x_c+y_c*d3_l->max_x+z_c*d3_l->max_x*d3_l->max_y)*255/max_extra);
    if(mode==1)
    {
     foobar=(unsigned char)(*(d3_l->extra+x_c+y_c*d3_l->max_x+z_c*d3_l->max_x*d3_l->max_y)*255/max_extra);
@@ -259,7 +277,7 @@ int d3_lattice_draw(d3_lattice *d3_l,int x,int y,int z,int arg_c,char **arg_v,un
  {
   for(y_c=0;y_c<d3_l->max_y;y_c++)
   {
  {
   for(y_c=0;y_c<d3_l->max_y;y_c++)
   {
-   if(!mode) dx_lattice_get_color((*d3_l).status+x_c+y_c*d3_l->max_x+z_c*d3_l->max_x*d3_l->max_y,&r,&g,&b,mode);
+   if((!mode)||mode==3) dx_lattice_get_color((*d3_l).status+x_c+y_c*d3_l->max_x+z_c*d3_l->max_x*d3_l->max_y,&r,&g,&b,mode);
    if(mode==1)
    {
     foobar=(unsigned char)(*(d3_l->extra+x_c+y_c*d3_l->max_x+z_c*d3_l->max_x*d3_l->max_y)*255/max_extra);
    if(mode==1)
    {
     foobar=(unsigned char)(*(d3_l->extra+x_c+y_c*d3_l->max_x+z_c*d3_l->max_x*d3_l->max_y)*255/max_extra);
@@ -296,32 +314,12 @@ int d3_lattice_draw(d3_lattice *d3_l,int x,int y,int z,int arg_c,char **arg_v,un
  d3_l->p_surface->DrawRectangle(d3_l->p_surface,
                                 d3_l->info_x,d3_l->info_y,
                                 d3_l->info_w,d3_l->info_h);
  d3_l->p_surface->DrawRectangle(d3_l->p_surface,
                                 d3_l->info_x,d3_l->info_y,
                                 d3_l->info_w,d3_l->info_h);
- /* old style
- d3_l->p_surface->DrawLine(d3_l->p_surface,
-                           d3_l->info_x+d3_l->info_w/2,
-                           d3_l->info_y,
-                           d3_l->info_x+d3_l->info_w/2,
-                           d3_l->info_y+d3_l->info_h);
- */
  d3_l->p_surface->SetColor(d3_l->p_surface,0x80,0x80,0xff,0xff);
  for(i=1;i<=arg_c;i++)
  d3_l->p_surface->SetColor(d3_l->p_surface,0x80,0x80,0xff,0xff);
  for(i=1;i<=arg_c;i++)
- {
-  // if(i<13)
-  // {
    d3_l->p_surface->DrawString(d3_l->p_surface,arg_v[i],-1,
                                d3_l->info_x+d3_l->fakt_x,
                                d3_l->info_y+2*d3_l->fakt_y+d3_l->font_h+(i-1)*d3_l->font_h,
                                DSTF_LEFT);
    d3_l->p_surface->DrawString(d3_l->p_surface,arg_v[i],-1,
                                d3_l->info_x+d3_l->fakt_x,
                                d3_l->info_y+2*d3_l->fakt_y+d3_l->font_h+(i-1)*d3_l->font_h,
                                DSTF_LEFT);
-  // } else
-  // {
-  /* old style
-    d3_l->p_surface->DrawString(d3_l->p_surface,arg_v[i],-1,
-                                d3_l->info_x+d3_l->info_w/2+d3_l->fakt_x,
-                                d3_l->info_y+2*d3_l->fakt_y+d3_l->font_h+(i%13-1)*d3_l->font_h,
-                                DSTF_LEFT);
-  */
-  // }
- }
 
  /* now we flip all to surface */
  d3_l->p_surface->Flip(d3_l->p_surface,NULL,0);
 
  /* now we flip all to surface */
  d3_l->p_surface->Flip(d3_l->p_surface,NULL,0);
@@ -361,7 +359,7 @@ int scan_event(d3_lattice *d3_l,int *x,int *y,int *z,int *q,int *esc,int *switch
   if(ke.key_id==DIKI_PAGE_DOWN && *z!=d3_l->max_z-1) *z+=1;
   if(ke.key_id==DIKI_Q) *q=1;
   if(ke.key_id==DIKI_ESCAPE) *esc=1;
   if(ke.key_id==DIKI_PAGE_DOWN && *z!=d3_l->max_z-1) *z+=1;
   if(ke.key_id==DIKI_Q) *q=1;
   if(ke.key_id==DIKI_ESCAPE) *esc=1;
-  if(ke.key_id==DIKI_M) *switchmode=(*switchmode+1)%3;
+  if(ke.key_id==DIKI_M) *switchmode=(*switchmode+1)%4;
   if(ke.key_id==DIKI_1) *bmp=1;
   if(ke.key_id==DIKI_2) *bmp=2;
   if(ke.key_id==DIKI_3) *bmp=3;
   if(ke.key_id==DIKI_1) *bmp=1;
   if(ke.key_id==DIKI_2) *bmp=2;
   if(ke.key_id==DIKI_3) *bmp=3;
index abee6e1..0e325ca 100644 (file)
--- a/dfbapi.h
+++ b/dfbapi.h
 #define Y_GAP X_GAP
 #define RED 1
 
 #define Y_GAP X_GAP
 #define RED 1
 
+#ifndef _U32
+#define _U32
+typedef unsigned int u32;
+#endif
+
 typedef struct __d2_lattice
 {
  int max_x,max_y;
 typedef struct __d2_lattice
 {
  int max_x,max_y;
@@ -69,7 +74,7 @@ int d2_lattice_release(d2_lattice *d2_l);
 int d2_lattice_draw(d2_lattice *d2_l,int x,int y,int arg_c,char **arg_v,unsigned char mode,int max_extra);
 int d3_lattice_init(int *argc,char **argv,d3_lattice *d3_l);
 int d3_lattice_release(d3_lattice *d3_l);
 int d2_lattice_draw(d2_lattice *d2_l,int x,int y,int arg_c,char **arg_v,unsigned char mode,int max_extra);
 int d3_lattice_init(int *argc,char **argv,d3_lattice *d3_l);
 int d3_lattice_release(d3_lattice *d3_l);
-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 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,u32 *p1,u32 max1,u32 *p2,u32 max2);
 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 *ac_distr);
 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 *ac_distr);
diff --git a/nlsop.c b/nlsop.c
index ab29fd1..ce06cec 100644 (file)
--- a/nlsop.c
+++ b/nlsop.c
@@ -1361,6 +1361,20 @@ int main(int argc,char **argv)
  arg_v[25]=NULL;
 #endif
 
  arg_v[25]=NULL;
 #endif
 
+ /* compute graphs for random number rejection method */
+ if((c_profile=(u32 *)malloc(d3_l.max_z*sizeof(unsigned int)))==NULL)
+ {
+  puts("failed allocating memory for carbon profile graph");
+  return -1;
+ }
+ if((n_e_loss=(u32 *)malloc(d3_l.max_z*sizeof(unsigned int)))==NULL)
+ {
+  puts("failed allocating memory for nuclear energy loss graph");
+  return -1;
+ }
+ ip_max=get_reject_graph(&my_info,&d3_l,p_file,c_profile);
+ ne_max=get_reject_graph(&my_info,&d3_l,n_e_file,n_e_loss);
+
  if((!strcmp(l_file,""))||(c_step))
  {
   /* calculate ratio of c_simwindow / c_total */
  if((!strcmp(l_file,""))||(c_step))
  {
   /* calculate ratio of c_simwindow / c_total */
@@ -1369,19 +1383,6 @@ int main(int argc,char **argv)
    puts("failed calculating ratio");
    return -1;
   }
    puts("failed calculating ratio");
    return -1;
   }
-  /* compute graphs for random number rejection method */
-  if((c_profile=(u32 *)malloc(d3_l.max_z*sizeof(unsigned int)))==NULL)
-  {
-   puts("failed allocating memory for carbon profile graph");
-   return -1;
-  }
-  if((n_e_loss=(u32 *)malloc(d3_l.max_z*sizeof(unsigned int)))==NULL)
-  {
-   puts("failed allocating memory for nuclear energy loss graph");
-   return -1;
-  }
-  ip_max=get_reject_graph(&my_info,&d3_l,p_file,c_profile);
-  ne_max=get_reject_graph(&my_info,&d3_l,n_e_file,n_e_loss);
 
 #ifdef DEBUG_RAND
  i=0;
 
 #ifdef DEBUG_RAND
  i=0;
@@ -1422,7 +1423,7 @@ int main(int argc,char **argv)
     sprintf(conc_txt,"conc: %d",*(d3_l.extra+x+y*d3_l.max_x+z*d3_l.max_x*d3_l.max_y));
     sprintf(steps_txt,"step: %d",i);
     sprintf(cc_txt,"total c: %d",my_info.cc);
     sprintf(conc_txt,"conc: %d",*(d3_l.extra+x+y*d3_l.max_x+z*d3_l.max_x*d3_l.max_y));
     sprintf(steps_txt,"step: %d",i);
     sprintf(cc_txt,"total c: %d",my_info.cc);
-    d3_lattice_draw(&d3_l,x,y,z,25,arg_v,mode,0);
+    d3_lattice_draw(&d3_l,x,y,z,25,arg_v,mode,0,NULL,0,NULL,0);
    }
 #endif
    if(i%resave==0 && strcmp(s_file,"") && resave!=0 && i!=0)
    }
 #endif
    if(i%resave==0 && strcmp(s_file,"") && resave!=0 && i!=0)
@@ -1460,6 +1461,7 @@ int main(int argc,char **argv)
   if(switchmode==0) mode=0;
   if(switchmode==1) mode=1;
   if(switchmode==2) mode=2;
   if(switchmode==0) mode=0;
   if(switchmode==1) mode=1;
   if(switchmode==2) mode=2;
+  if(switchmode==3) mode=3;
   /* end of bahh! */
   sprintf(xyz_txt,"x: %d  y: %d  z: %d",x+1,y+1,z+1);
   sprintf(status_txt,"status: %c",(*(d3_l.status+x+y*d3_l.max_x+z*d3_l.max_x*d3_l.max_y)&AMORPH)?'a':'c');
   /* end of bahh! */
   sprintf(xyz_txt,"x: %d  y: %d  z: %d",x+1,y+1,z+1);
   sprintf(status_txt,"status: %c",(*(d3_l.status+x+y*d3_l.max_x+z*d3_l.max_x*d3_l.max_y)&AMORPH)?'a':'c');
@@ -1469,7 +1471,8 @@ int main(int argc,char **argv)
   if(switchmode==0) strcpy(mode_txt,"view: a/c mode");
   if(switchmode==1) strcpy(mode_txt,"view: c conc mode");
   if(switchmode==2) strcpy(mode_txt,"view: a pressure mode");
   if(switchmode==0) strcpy(mode_txt,"view: a/c mode");
   if(switchmode==1) strcpy(mode_txt,"view: c conc mode");
   if(switchmode==2) strcpy(mode_txt,"view: a pressure mode");
-  d3_lattice_draw(&d3_l,x,y,z,25,arg_v,mode,max_extra);
+  if(switchmode==3) strcpy(mode_txt,"view: a/c + profiles mode");
+  d3_lattice_draw(&d3_l,x,y,z,25,arg_v,mode,max_extra,c_profile,ip_max,n_e_loss,ne_max);
   bmp=0;
   ac_distr=0;
   scan_event(&d3_l,&x,&y,&z,&quit,&escape,&switchmode,&bmp,&ac_distr);
   bmp=0;
   ac_distr=0;
   scan_event(&d3_l,&x,&y,&z,&quit,&escape,&switchmode,&bmp,&ac_distr);
diff --git a/nlsop.h b/nlsop.h
index 971a018..0d1396b 100644 (file)
--- a/nlsop.h
+++ b/nlsop.h
@@ -8,7 +8,10 @@
 #ifndef NLSOP_H
 #define NLSOP_H
 
 #ifndef NLSOP_H
 #define NLSOP_H
 
+#ifndef _U32
+#define _U32
 typedef unsigned int u32;
 typedef unsigned int u32;
+#endif
 
 typedef struct __info
 {
 
 typedef struct __info
 {