本文整理汇总了C++中VMDApp::label_add方法的典型用法代码示例。如果您正苦于以下问题:C++ VMDApp::label_add方法的具体用法?C++ VMDApp::label_add怎么用?C++ VMDApp::label_add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VMDApp
的用法示例。
在下文中一共展示了VMDApp::label_add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
// add(category, (molids), (atomids))
static PyObject *label_add(PyObject *self, PyObject *args) {
char *type;
PyObject *molids, *atomids;
int i;
if (!PyArg_ParseTuple(args, (char *)"sO!O!:label.add",
&type, &PyTuple_Type, &molids, &PyTuple_Type, &atomids))
return NULL;
VMDApp *app = get_vmdapp();
MoleculeList *mlist = app->moleculeList;
int cat = app->geometryList->geom_list_index(type);
if (cat < 0) {
PyErr_SetString(PyExc_ValueError, (char *)"Unknown label category");
return NULL;
}
int numitems;
if (PyTuple_Size(molids) == 1 && PyTuple_Size(atomids) == 1)
numitems = 1;
else if (PyTuple_Size(molids) == 2 && PyTuple_Size(atomids) == 2)
numitems = 2;
else if (PyTuple_Size(molids) == 3 && PyTuple_Size(atomids) == 3)
numitems = 3;
else if (PyTuple_Size(molids) == 4 && PyTuple_Size(atomids) == 4)
numitems = 4;
else {
PyErr_SetString(PyExc_TypeError, (char *)"label.add: 2nd and 3rd arguments"
" must be tuples of size 1, 2, 3, or 4");
return NULL;
}
int m[4], a[4];
for (i=0; i<numitems; i++) {
m[i] = PyInt_AsLong(PyTuple_GET_ITEM(molids, i));
a[i] = PyInt_AsLong(PyTuple_GET_ITEM(atomids, i));
if (PyErr_Occurred())
return NULL;
Molecule *mol = mlist->mol_from_id(m[i]);
if (!mol) {
PyErr_SetString(PyExc_ValueError, (char *)"Invalid molecule id");
return NULL;
}
if (a[i] < 0 || a[i] >= mol->nAtoms) {
PyErr_SetString(PyExc_ValueError, (char *)"Invalid atom id");
return NULL;
}
}
// Add the label, but don't toggle the on/off status.
int ind = app->label_add(type, numitems, m, a, NULL, 0.0f, 0);
if (ind < 0) {
Py_INCREF(Py_None);
return Py_None;
}
// Get the dict corresponding to this label. The dict we return
// corresponds to either the label we just created, or to an existing
// label whose state we have not changed. This makes it safe to use
// label.add to get a proxy to a VMD label.
GeomListPtr glist = app->geometryList->geom_list(cat);
return geom2dict((*glist)[ind]);
}
示例2: text_cmd_label
int text_cmd_label(ClientData cd, Tcl_Interp *interp, int argc,
const char *argv[]) {
VMDApp *app = (VMDApp *)cd;
if (argc < 2) {
Tcl_SetResult(interp,
(char *)
"label add [Atoms|Bonds|Angles|Dihedrals] {atoms as <molid>/<atomid>}\n"
"label addspring <molid> <atomid> <atomid> <k>\n"
"label list -- return label categories\n"
"label list <category> -- return id's of labels in given category\n"
"label [show|hide|delete] <category> [index] -- \n\tControl specific label or all labels in category\n"
"label graph <category> <index> -- Return a list of values for the given label\n\tfor all animation frames\n"
"label textsize [<newsize>]\n" ,
TCL_STATIC);
return TCL_ERROR;
}
if(!strupncmp(argv[1], "add", CMDLEN)) {
if(argc > 3) {
int n = argc-3;
const char **items = argv+3;
int *molid= new int[n];
int *atmid = new int[n];
int i;
for(i=0; i < n; i++) {
if (find_atom_from_name(interp, items[i], molid+i, atmid+i))
break;
}
int rc = -1;
if(i == n) { // all successfully parsed
rc = app->label_add(argv[2], argc-3, molid, atmid, NULL, 0.0f, 1);
}
delete [] molid;
delete [] atmid;
if (rc < 0) {
Tcl_AppendResult(interp, "\nUnable to add label.", NULL);
return TCL_ERROR;
}
}
else
return TCL_ERROR;
}
else if(!strupncmp(argv[1],"addspring",CMDLEN)) { /* add a spring */
if(argc != 6) {
Tcl_AppendResult(interp, "usage: label addspring <molid> <atomid> <atomid> <k>", NULL);
return TCL_ERROR;
}
int molid[2];
int atomid[2];
float k;
sscanf(argv[2],"%d",molid); /* convert all of the args to numbers */
sscanf(argv[3],"%d",atomid);
sscanf(argv[4],"%d",atomid+1);
sscanf(argv[5],"%f",&k);
molid[1]=molid[0];
if (app->label_add("Springs", 2, molid, atomid, NULL, k, 1) < 0) {
Tcl_AppendResult(interp, "Unable to add spring.", NULL);
return TCL_ERROR;
}
}
else if(!strupncmp(argv[1], "list", CMDLEN)) {
if(argc == 3) {
int cat = app->geometryList->geom_list_index(argv[2]);
if (cat < 0) {
Tcl_AppendResult(interp, "graph list category '", argv[2],
"' was not found", NULL);
return TCL_ERROR;
}
// go through the list by hand
GeomListPtr glist = app->geometryList->geom_list(cat);
int gnum = glist->num();
char s[30];
GeometryMol *g;
for (int i=0; i<gnum; i++) {
g = (*glist)[i];
Tcl_AppendResult(interp, i==0 ? "" : " ", "{", NULL);
for (int j=0; j<g->items(); j++) {
// append the molecule id/atom index
sprintf(s, "%d %d", g -> obj_index(j), g -> com_index(j));
Tcl_AppendElement(interp, s);
}
// and the value and the status
sprintf(s, "%f", g->ok() ? g->calculate() : 0.0);
Tcl_AppendElement(interp, s);
Tcl_AppendElement(interp, g -> displayed() ? "show" : "hide");
Tcl_AppendResult(interp, "}", NULL);
}
return TCL_OK;
}
else if (argc == 2) {
// return the main categories
for (int i=0; i<app->geometryList -> num_lists(); i++) {
Tcl_AppendElement(interp, app->geometryList -> geom_list_name(i));
}
return TCL_OK;
} else
return TCL_ERROR;
//.........这里部分代码省略.........