예제 #1
0
static void mol_rename_cb(Fl_Widget *w, void *v) {
  VMDApp *app = (VMDApp *)w->user_data();
  MolBrowser *browser = (MolBrowser *)v;
  int molid=-1;
  for (int i=0; i<browser->size(); i++)
    if (browser->selected(i+1)) {
      molid = app->molecule_id(i);
      break;
    }
  if (molid < 0) return;
  
  // this code snippet is replicated in MolBrowser.C:
  const char *oldname = app->molecule_name(molid);
  const char *newname = fl_input("Enter a new name for molecule %d:", 
      oldname, molid);
  if (newname) app->molecule_rename(molid, newname);
}
예제 #2
0
static void mol_delete_ts_cb(Fl_Widget *w, void *v) {
  VMDApp *app = (VMDApp *)w->user_data();
  MolBrowser *browser = (MolBrowser *)v;
  int molid=-1;
  for (int i=0; i<browser->size(); i++)
    if (browser->selected(i+1)) {
      molid = app->molecule_id(i);
      break;
    }
  if (molid < 0) return;
  
  // this code snippet is replicated in MolBrowser.C:
  int numframes = app->molecule_numframes(molid);
  if (!numframes) {
    fl_alert("Molecule %d has no frames to delete!", molid);
  } else {
    const char *molname = app->molecule_name(molid);
    int first=0, last=numframes-1, stride=0;
    int ok = frame_delete_selector(molname, last, &first, &last, &stride);
    if (ok) app->molecule_deleteframes(molid, first, last, stride);
  }
}