本文整理汇总了C++中VMDApp::color_value方法的典型用法代码示例。如果您正苦于以下问题:C++ VMDApp::color_value方法的具体用法?C++ VMDApp::color_value怎么用?C++ VMDApp::color_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VMDApp
的用法示例。
在下文中一共展示了VMDApp::color_value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: py_get_colorlist
static PyObject* py_get_colorlist(PyObject *self, PyObject *args)
{
PyObject *newlist = NULL, *newtuple = NULL;
int i, j, listlen;
const char *name;
float col[3];
VMDApp *app;
if (!(app = get_vmdapp()))
return NULL;
listlen = app->num_regular_colors();
if (!(newlist = PyList_New(listlen)))
goto failure;
for (i = 0; i < listlen; i++) {
name = app->color_name(i);
if (!app->color_value(name, col, col+1, col+2))
goto failure;
if (!(newtuple = PyTuple_New(3)))
goto failure;
for (j = 0; j < 3; j++) {
PyTuple_SET_ITEM(newtuple, j, PyFloat_FromDouble(col[j]));
if (PyErr_Occurred())
goto failure;
}
PyList_SET_ITEM(newlist, i, newtuple);
if (PyErr_Occurred())
goto failure;
}
return newlist;
failure:
PyErr_SetString(PyExc_RuntimeError, "Problem getting color list");
Py_XDECREF(newlist);
Py_XDECREF(newtuple);
return NULL;
}
示例2:
static PyObject *get_colors(PyObject *self, PyObject *args) {
if (!PyArg_ParseTuple(args, (char *)""))
return NULL;
VMDApp *app = get_vmdapp();
PyObject *newdict = PyDict_New();
for (int i=0; i<app->num_regular_colors(); i++) {
float col[3];
const char *name = app->color_name(i);
if (!app->color_value(name, col, col+1, col+2)) {
PyErr_SetString(PyExc_ValueError, (char *)
"Unable to get color definition");
return NULL;
}
PyObject *newtuple = PyTuple_New(3);
for (int j=0; j<3; j++)
PyTuple_SET_ITEM(newtuple, j, PyFloat_FromDouble(col[j]));
PyDict_SetItemString(newdict, (char *)name, newtuple);
}
return newdict;
}