Commit d0508cfd authored by saeed's avatar saeed

log is added

parent fa765c9d
static void log_station(struct station *station){
printf("number of points in a file is %d \n",station->ns);
}
static void log_stn(struct stn_set *stn_set){
printf("number of files nt %d\n",stn_set->nt);
printf("current stations icur %d\n",stn_set->icur);
for (int i=0; i < stn_set->nt;++i){
log_station(stn_set->stns[i]);
}
printf("here\n");
}
static void log_odb(void){
}
static void log_obs(void){
}
static void movewindow(struct Vis *vis, int x, int y){
XMoveWindow(vis->dsp, vis->win, x, y);
(void)XMoveWindow(vis->dsp, vis->win, x, y);
}
static void colortoRGBA(uint32 color, uint8 *red, uint8 *green, uint8 *blue, uint8 *alpha){
......@@ -62,8 +62,6 @@ static XImage *CreateTrueColorImage(Display *display, Visual *visual, int width,
return XCreateImage(display, visual, 24, ZPixmap, 0, FLD->image32, width, height, 32, 0);
}
static struct Vis init_x(int w, int h){
struct Vis result = {0};
......@@ -159,7 +157,7 @@ static int isinsymbol(int i, int j,float radius, int x, int y){
}
static void drawonscreen_expose(struct Vis *vis,struct dsp_field *dspf,struct Colort *scolor, int ncolor, struct obs *obsp, struct screen_dim *scdim){
static void drawonscreen_expose(struct Vis *vis,struct dsp_field *dspf,struct Colort *scolor, int ncolor, struct obs_set *obsp, struct screen_dim *scdim){
float minv = 0.0f, maxv = 0.0f;
uint8 ured = 0x0, ugreen = 0x0, ublue = 0x0, ualpha = 0x0;
......@@ -193,9 +191,9 @@ static void drawonscreen_expose(struct Vis *vis,struct dsp_field *dspf,struct Co
ximage = XCreateImage(vis->dsp, vis->visual, 24, ZPixmap, 0, dspf->image32, vis->w, vis->h, 32, 0);
XPutImage(vis->dsp, pixmap, vis->gc, ximage, 0, 0, 0, 0, vis->w, vis->h);
XSetForeground(vis->dsp, vis->gc, stn_color);
for (int i=0; i< obsp->npy;++i){
if (obsp->iindex[i] != -1 && obsp->jindex[i] != -1){
struct Index index = map(obsp->iindex[i], obsp->jindex[i], vis->w, vis->h, NX, NY);
for (int i=0; i< obsp->obs[obsp->icur]->npy;++i){
if (obsp->obs[obsp->icur]->iindex[i] != -1 && obsp->obs[obsp->icur]->jindex[i] != -1){
struct Index index = map(obsp->obs[obsp->icur]->iindex[i], obsp->obs[obsp->icur]->jindex[i], vis->w, vis->h, NX, NY);
XFillArc (vis->dsp, pixmap, vis->gc,index.i - (int)(symb.radius *0.50), vis->h - index.j -1 - (int)(symb.radius *0.50), (int)(symb.radius),(int)(symb.radius), 0, 360 * 64);
XFlush(vis->dsp);
}
......@@ -207,7 +205,7 @@ static void drawonscreen_expose(struct Vis *vis,struct dsp_field *dspf,struct Co
free_dsp_field(dspf);
}
static void drawonscreen_configure(struct Vis *vis,XEvent *e,struct Colort *scolor, int ncolor, struct obs *obsp, struct screen_dim *scdim){
static void drawonscreen_configure(struct Vis *vis,XEvent *e,struct Colort *scolor, int ncolor, struct obs_set *obsp, struct screen_dim *scdim){
while(XCheckTypedEvent(vis->dsp,ConfigureNotify,e));
XConfigureEvent xce = e->xconfigure;
vis->w = (int)xce.width;
......@@ -219,7 +217,7 @@ static void drawonscreen_configure(struct Vis *vis,XEvent *e,struct Colort *scol
}
static void drawonscreen_changecolormap(struct Vis *vis,XEvent *e,struct Colort *scolor, int ncolor, struct obs *obsp, struct screen_dim *scdim){
static void drawonscreen_changecolormap(struct Vis *vis,XEvent *e,struct Colort *scolor, int ncolor, struct obs_set *obsp, struct screen_dim *scdim){
struct dsp_field *dspf = NULL;
struct dsp_field dspf_t = adjusttowindowsize(vis, &FLD);
dspf = &dspf_t;
......@@ -244,7 +242,7 @@ static int changecolorcursor(Display *dsp, Cursor *cursor, XColor* cfg, XColor*
return result;
}
static void drawonscreen_motion(struct Vis *vis,struct Colort *scolor, int ncolor,struct obs *obsp, XEvent *e,struct screen_dim *scdim){
static void drawonscreen_motion(struct Vis *vis,struct Colort *scolor, int ncolor,struct obs_set *obsp, XEvent *e,struct screen_dim *scdim){
while(XCheckTypedEvent(vis->dsp,MotionNotify,e));
......@@ -270,9 +268,9 @@ static void drawonscreen_motion(struct Vis *vis,struct Colort *scolor, int ncolo
int istn = -1;
int ipos = -1;
int jpos = -1;
for (int i=0; i< obsp->npy;++i){
if (obsp->iindex[i] != -1 && obsp->jindex[i] != -1){
struct Index index = map(obsp->iindex[i], obsp->jindex[i], vis->w, vis->h, NX, NY);
for (int i=0; i< obsp->obs[obsp->icur]->npy;++i){
if (obsp->obs[obsp->icur]->iindex[i] != -1 && obsp->obs[obsp->icur]->jindex[i] != -1){
struct Index index = map(obsp->obs[obsp->icur]->iindex[i], obsp->obs[obsp->icur]->jindex[i], vis->w, vis->h, NX, NY);
if (isinsymbol(index.i,index.j,symb.radius *0.5,x,y)){
istn = i;
ipos = index.i;
......@@ -305,17 +303,17 @@ static void drawonscreen_motion(struct Vis *vis,struct Colort *scolor, int ncolo
ximage = XCreateImage(vis->dsp, vis->visual, 24, ZPixmap, 0, dspf->image32, vis->w, vis->h, 32, 0);
XPutImage(vis->dsp, pixmap, vis->gc, ximage, 0, 0, 0, 0, vis->w, vis->h);
XSetForeground(vis->dsp, vis->gc, stn_color);
for (int i=0; i< obsp->npy;++i){
if (obsp->iindex[i] != -1 && obsp->jindex[i] != -1){
for (int i=0; i< obsp->obs[obsp->icur]->npy;++i){
if (obsp->obs[obsp->icur]->iindex[i] != -1 && obsp->obs[obsp->icur]->jindex[i] != -1){
if (i != istn){
struct Index index = map(obsp->iindex[i], obsp->jindex[i], vis->w, vis->h, NX, NY);
struct Index index = map(obsp->obs[obsp->icur]->iindex[i], obsp->obs[obsp->icur]->jindex[i], vis->w, vis->h, NX, NY);
XFillArc (vis->dsp, pixmap, vis->gc,index.i - (int)(symb.radius *0.50), vis->h - index.j -1 - (int)(symb.radius *0.50), (int)(symb.radius),(int)(symb.radius), 0, 360 * 64);
XFlush(vis->dsp);
}
}
}
if (obsp->iindex[istn] != -1 && obsp->jindex[istn] != -1){
struct Index index = map(obsp->iindex[istn], obsp->jindex[istn], vis->w, vis->h, NX, NY);
if (obsp->obs[obsp->icur]->iindex[istn] != -1 && obsp->obs[obsp->icur]->jindex[istn] != -1){
struct Index index = map(obsp->obs[obsp->icur]->iindex[istn], obsp->obs[obsp->icur]->jindex[istn], vis->w, vis->h, NX, NY);
XSetForeground(vis->dsp, vis->gc, stn_color);
XFillArc (vis->dsp, pixmap, vis->gc,index.i - (int)(symb.radius *0.50*increase_radius), vis->h - index.j -1 - (int)(symb.radius *0.50*increase_radius), (int)(symb.radius *increase_radius),(int)(symb.radius * increase_radius), 0, 360 * 64);
XFlush(vis->dsp);
......@@ -360,9 +358,9 @@ static void drawonscreen_motion(struct Vis *vis,struct Colort *scolor, int ncolo
ximage = XCreateImage(vis->dsp, vis->visual, 24, ZPixmap, 0, dspf->image32, vis->w, vis->h, 32, 0);
XPutImage(vis->dsp, pixmap, vis->gc, ximage, 0, 0, 0, 0, vis->w, vis->h);
XSetForeground(vis->dsp, vis->gc, stn_color);
for (int i=0; i< obsp->npy;++i){
if (obsp->iindex[i] != -1 && obsp->jindex[i] != -1){
struct Index index = map(obsp->iindex[i], obsp->jindex[i], vis->w, vis->h, NX, NY);
for (int i=0; i< obsp->obs[obsp->icur]->npy;++i){
if (obsp->obs[obsp->icur]->iindex[i] != -1 && obsp->obs[obsp->icur]->jindex[i] != -1){
struct Index index = map(obsp->obs[obsp->icur]->iindex[i], obsp->obs[obsp->icur]->jindex[i], vis->w, vis->h, NX, NY);
XFillArc (vis->dsp, pixmap, vis->gc,index.i - (int)(symb.radius *0.50), vis->h - index.j -1 - (int)(symb.radius*0.50), (int)(symb.radius),(int)(symb.radius), 0, 360 * 64);
XFlush(vis->dsp);
}
......@@ -478,7 +476,7 @@ static void odbinfo_onotherwindow(struct Vis *vis, struct odbinfo *odbinfo){
}
static int handle_keyboard(struct Vis *vis, XEvent *e, struct obs *obsp,struct Colort *scolor, int ncolor,struct screen_dim *scdim){
static int handle_keyboard(struct Vis *vis, XEvent *e, struct obs_set *obsp,struct Colort *scolor, int ncolor,struct screen_dim *scdim){
int result = 1;
static int palet = 0;
......@@ -511,13 +509,13 @@ static void handle_event(struct Vis *vis,struct Vis *vis1, struct dsp_field *dsp
int done = 1;
XEvent e;
struct obs obsp = fill_obs(FLD.lon, FLD.lat, NX, NY);
obs_set = fill_obs_set(FLD.lon, FLD.lat, NX, NY);
for(;done;){
XNextEvent (vis->dsp,&e);
if (XPending(vis->dsp)){
if (e.type == Expose){
drawonscreen_expose(vis,dspf,scolor,ncolor,&obsp,scdim);
drawonscreen_expose(vis,dspf,scolor,ncolor,&obs_set,scdim);
odbinfo_onotherwindow(vis1, &odbinfo);
}
done = 0;
......@@ -538,7 +536,7 @@ static void handle_event(struct Vis *vis,struct Vis *vis1, struct dsp_field *dsp
}
if (e.type == ConfigureNotify) {
printf("configure\n");
drawonscreen_configure(vis,&e,scolor,ncolor,&obsp,scdim);
drawonscreen_configure(vis,&e,scolor,ncolor,&obs_set,scdim);
usleep(500000);
}
if (e.type == ButtonPress ){
......@@ -546,10 +544,10 @@ static void handle_event(struct Vis *vis,struct Vis *vis1, struct dsp_field *dsp
}
if (e.type == MotionNotify){
printf("motion in \n");
drawonscreen_motion(vis,scolor,ncolor,&obsp,&e,scdim);
drawonscreen_motion(vis,scolor,ncolor,&obs_set,&e,scdim);
}
if (e.type == KeyPress){
done = handle_keyboard(vis,&e,&obsp,scolor,ncolor,scdim);
done = handle_keyboard(vis,&e,&obs_set,scolor,ncolor,scdim);
}
}
}
......
......@@ -156,6 +156,7 @@ struct Index {
#include"util.c"
#include"renderer.c"
#include"renderer_thread.c"
#include"loginfo.c"
#include"run_main.c"
int main(int argc, char *argv[]){
......
static int run_view(int argc,char *argv[]){
int result = 0;
if (argc == 1){
printf("\nUsage %s odb_file\n\n",argv[0]);
result = 1;
}
if (argc >= 2 ){
int width = WIDTH_INIT;
int height = HEIGHT_INIT;
int ncolor = 0;
land_color = landcolor;
ocean_color = oceancolor;
stn_color = stncolor;
if (usesrgb) land_color = lineartosrgbi(landcolor);
if (usesrgb) ocean_color = lineartosrgbi(oceancolor);
if (usesrgb) stn_color = lineartosrgbi(stncolor);
struct screen_dim scdim = {0,0,0};
scdim.width = width;
scdim.height = height;
scdim.symbol_radius = SYM_SIZE;
struct Colort *scolor = NULL;
stn_set = getstn_set(argc,argv,&odbinfo_set);
log_stn(&stn_set);
return result;
get2dfield_binary("landseamask.bin",&FLD);
struct Vis visu = init_x(width,height);
struct dsp_field dspf = adjusttowindowsize(&visu, &FLD);
width = WIDTH_TR1;
height = HEIGHT_TR1;
struct Vis visu_1 = init_x(width,height);
map_window(&visu_1);
map_window(&visu);
movewindow(&visu,(int)(WIDTH_TR1*1.01),0);
pthread_t thread_id[NUM_THREADS];
for (int i=0; i < NUM_THREADS;++i){
pthread_create(&thread_id[i], NULL, handle_event_thread, (void *)&visu_1);
}
handle_event(&visu,&visu_1,&dspf,scolor,ncolor,&scdim);
}
return result;
}
......@@ -232,9 +232,9 @@ static struct stn_set getstn_set(int argc, char *argv[], struct odbinfo_set *odb
result.stns = (struct station **)malloc(sizeof(struct station *) * result.nt);
odbinfo_set->odb_set = (struct odbinfo **)malloc(sizeof(struct odbinfo *) * result.nt);
if (result.stns && odbinfo_set->odb_set){
for (int i=1; i< result.nt;++i){
for (int i=0; i< result.nt;++i){
*(odbinfo_set->odb_set + nf) = (struct odbinfo *)malloc(sizeof(struct odbinfo ));
*(result.stns + nf ) = getstn(argv[i], *(odbinfo_set->odb_set + nf));
*(result.stns + nf ) = getstn(argv[i+1], *(odbinfo_set->odb_set + nf));
nf++;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment