Example #1
0
static gmx_bool appCallBack(struct t_x11 *x11, XEvent *event, Window w, void *data)
{
    t_app  *app;
    int     win;

    app = (t_app *)data;
    for (win = 0; (win < ebutNR); win++)
    {
        if (app->but[win].self == w)
        {
            break;
        }
    }
    if (win == ebutNR)
    {
        return FALSE;
    }

    switch (event->type)
    {
        case Expose:
            TextInWin(x11, &(app->but[win]), app->but[win].text, eXCenter, eYCenter);
            break;
        case ButtonPress:
            switch (win)
            {
                case ebQuit:
                    exit(1);
                case ebStart:
                    app->status = esGo;
                    ExposeWin(x11->disp, app->xrwd.self);
                    break;
                case ebStop:
                    app->status = esStop;
                    break;
                case ebRewind:
                    rewind_trj(app->xr->traj);
                    break;
                case ebGly:
                    app->bShowGly = !app->bShowGly;
                    ExposeWin(x11->disp, app->xrwd.self);
                    break;
                default:
                    XBell(x11->disp, 50);
                    break;
            }
            break;
    }
    return FALSE;
}
Example #2
0
static void HandleClient(t_x11 *x11,t_manager *man,long data[])
{
  int  ID,button,x,y;
  bool bPos;
  real fac;

  ID=data[0];
  button=data[1];
  x=data[2];
  y=data[3];
  bPos=(button==Button1);
  switch (ID) {
  case IDROTX:
  case IDROTY:
  case IDROTZ:
    rotate_3d(man->view,ID-IDROTX,bPos);
    draw_mol(x11,man);
    break;
  case IDZOOM:
    if (bPos)
      fac=0.8; /* Reduce distance between eye and origin */
    else
      fac=1.25;
    
    /*  zoom changed to scale by Berk Hess 3-7-96
    if (zoom_3d(man->view,fac))
      draw_mol(x11,man); */
    man->view->sc_x/=fac;
    man->view->sc_y/=fac;
    draw_mol(x11,man);
    break;
  case IDTRANSX:
  case IDTRANSY:
  case IDTRANSZ:
    translate_view(man->view,ID-IDTRANSX,bPos);
    draw_mol(x11,man);
    break;
  case IDREWIND:
    if (man->status != -1) {
      rewind_trj(man->status);
      read_next_x(man->status,&(man->time),man->natom,man->x,man->box);
      man->bEof=FALSE;
      draw_mol(x11,man);
    }
    break;
  case IDSTEP: {
    int      nat;

    nat=0;
    if (!step_man(man,&nat)) {
      man->bEof=TRUE;
      man->bStop=TRUE;
    }
    else {
      if (nat > 0) {
	draw_mol(x11,man);
	usleep(man->nWait*1000);
      }
    }
    break;
  }
  case IDFF:
    man->bStop=FALSE;
    break;
  case IDSTOP_ANI:
    man->bStop=TRUE;
    break;
  case IDDRAWMOL:
    draw_mol(x11,man);
    break;
  case IDLABEL:
    switch (button) {
    case Button1:
    case Button2:
      show_label(x11,man,x,y);
      break;
    case Button3:
      hide_label(x11,man,x,y);
      break;
    }
    break;
  default:
    break;
  }
  if (man->bAnimate && !man->bEof && !man->bStop)
    step_message(x11,man);
}