static void DrawLegend(t_x11 *x11, t_windata *Win) { #define NLAB 6 #define COLS 3 static const char *lab[NLAB] = { "C", "O", "H", "S", "N", "P" }; int i, i0, dh, dw, w, y, x1, x0; unsigned long cind; real h_2; XClearWindow(x11->disp, Win->self); w = Win->width; h_2 = Win->height/(2.0*NLAB/COLS); dh = h_2-2; dw = dh; for (i = 0; (i < NLAB); i++) { i0 = i % (NLAB/COLS); x0 = (i / (NLAB/COLS))*(Win->width/COLS)+AIR; x1 = x0+2*dw+AIR; cind = Type2Color(lab[i]); XSetForeground(x11->disp, x11->gc, cind); y = ((2*i0+1)*h_2); XFillRectangle (x11->disp, Win->self, x11->gc, x0, y-dh, 2*dw, 2*dh); XSetForeground(x11->disp, x11->gc, WHITE); TextInRect(x11, Win->self, lab[i], x1, y-dh, w-x1, 2*dh, eXLeft, eYCenter); } XSetForeground(x11->disp, x11->gc, x11->fg); }
void set_file(t_x11 *x11,t_manager *man,char *trajectory,char *status) { gmx_atomprop_t aps; char buf[256],quote[256]; t_tpxheader sh; t_atoms *at; bool *bB; int i,idum; real rdum; read_tpxheader(status,&sh,TRUE,NULL,NULL); snew(man->ix,sh.natoms); snew(man->zz,sh.natoms); snew(man->col,sh.natoms); snew(man->size,sh.natoms); snew(man->vdw,sh.natoms); snew(man->bLabel,sh.natoms); snew(man->bVis,sh.natoms); for(i=0; (i<sh.natoms); i++) man->bVis[i]=FALSE; man->bPbc=FALSE; snew(man->szLab,sh.natoms); snew(man->bHydro,sh.natoms); snew(bB,sh.natoms); read_tpx_top(status,&(man->step),&(man->time),&rdum,NULL,man->box, &man->natom,NULL,NULL,NULL,&man->top); man->natom= read_first_x(&man->status,trajectory,&(man->time),&(man->x),man->box); man->trajfile=strdup(trajectory); if (man->natom > man->top.atoms.nr) gmx_fatal(FARGS,"Topology %s (%d atoms) and trajectory %s (%d atoms) " "do not match",status,man->top.atoms.nr, trajectory,man->natom); cool_quote(quote,255,NULL); sprintf(buf,"%s: %s",*man->top.name,quote); man->title.text = strdup(buf); man->view = init_view(man->box); at = &(man->top.atoms); aps = gmx_atomprop_init(); for(i=0; (i<man->natom); i++) { char *aname=*(at->atomname[i]); int resnr=at->atom[i].resnr; man->col[i]=Type2Color(aname); snew(man->szLab[i],20); sprintf(man->szLab[i],"%s%d, %s",*(at->resname[resnr]),resnr+1,aname); man->bHydro[i]=(toupper(aname[0])=='H'); if ( man->bHydro[i] ) man->vdw[i]=0; else if (!gmx_atomprop_query(aps,epropVDW, *(at->resname[resnr]),aname, &(man->vdw[i]))) man->vdw[i] = 0; } gmx_atomprop_destroy(aps); add_bpl(man,&(man->top.idef),bB); for(i=0; (i<man->natom); i++) if (!bB[i]) add_object(man,eOSingle,(atom_id) i,0); sfree(bB); ExposeWin(x11->disp,man->molw->wd.self); }
void set_file(t_x11 *x11, t_manager *man, const char *trajectory, const char *status) { gmx_atomprop_t aps; t_tpxheader sh; t_atoms *at; bool *bB; int i; read_tpxheader(status, &sh, true); snew(man->ix, sh.natoms); snew(man->zz, sh.natoms); snew(man->col, sh.natoms); snew(man->size, sh.natoms); snew(man->vdw, sh.natoms); snew(man->bLabel, sh.natoms); snew(man->bVis, sh.natoms); for (i = 0; (i < sh.natoms); i++) { man->bVis[i] = false; } man->bPbc = false; snew(man->szLab, sh.natoms); snew(man->bHydro, sh.natoms); snew(bB, sh.natoms); read_tpx_top(status, nullptr, man->box, &man->natom, nullptr, nullptr, &man->top); man->gpbc = gmx_rmpbc_init(&man->top.idef, -1, man->natom); man->natom = read_first_x(man->oenv, &man->status, trajectory, &(man->time), &(man->x), man->box); man->trajfile = gmx_strdup(trajectory); if (man->natom > man->top.atoms.nr) { gmx_fatal(FARGS, "Topology %s (%d atoms) and trajectory %s (%d atoms) " "do not match", status, man->top.atoms.nr, trajectory, man->natom); } man->title.text = gmx_strdup(gmx::formatString("%s: %s", *man->top.name, gmx::getCoolQuote().c_str()).c_str()); man->view = init_view(man->box); at = &(man->top.atoms); aps = gmx_atomprop_init(); for (i = 0; (i < man->natom); i++) { char *aname = *(at->atomname[i]); t_resinfo *ri = &at->resinfo[at->atom[i].resind]; man->col[i] = Type2Color(aname); snew(man->szLab[i], 20); if (ri->ic != ' ') { std::sprintf(man->szLab[i], "%s%d%c, %s", *ri->name, ri->nr, ri->ic, aname); } else { std::sprintf(man->szLab[i], "%s%d, %s", *ri->name, ri->nr, aname); } man->bHydro[i] = (toupper(aname[0]) == 'H'); if (man->bHydro[i]) { man->vdw[i] = 0; } else if (!gmx_atomprop_query(aps, epropVDW, *ri->name, aname, &(man->vdw[i]))) { man->vdw[i] = 0; } } gmx_atomprop_destroy(aps); add_bpl(man, &(man->top.idef), bB); for (i = 0; (i < man->natom); i++) { if (!bB[i]) { add_object(man, eOSingle, (int) i, 0); } } sfree(bB); ExposeWin(x11->disp, man->molw->wd.self); }