本文整理汇总了C++中VMDApp::color_name方法的典型用法代码示例。如果您正苦于以下问题:C++ VMDApp::color_name方法的具体用法?C++ VMDApp::color_name怎么用?C++ VMDApp::color_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VMDApp
的用法示例。
在下文中一共展示了VMDApp::color_name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: py_set_colorid
static PyObject* py_set_colorid(PyObject *self, PyObject *args,
PyObject *kwargs)
{
const char *kwnames[] = {"id", "rgb", NULL};
float rgb[3];
int colorid;
VMDApp *app;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i(fff):color.set_colorid",
(char**) kwnames, &colorid, &rgb[0], &rgb[1],
&rgb[2]))
return NULL;
if (!(app = get_vmdapp()))
return NULL;
if (colorid >= app->num_regular_colors() || colorid < 0) {
PyErr_Format(PyExc_ValueError, "color index '%d' out of range", colorid);
return NULL;
}
app->color_change_rgb(app->color_name(colorid), rgb[0], rgb[1], rgb[2]);
Py_INCREF(Py_None);
return Py_None;
}
示例2:
static PyObject *set_colorid(PyObject *self, PyObject *args) {
int colorid;
float rgb[3];
if (!PyArg_ParseTuple(args, (char *)"i(fff)", &colorid, &rgb[0], &rgb[1], &rgb[2])) {
return NULL;
}
VMDApp *app = get_vmdapp();
if (colorid >= app->num_regular_colors() || colorid < 0) {
PyErr_SetString(PyExc_ValueError, (char *) "color index out of range");
return NULL;
}
const char *name = app->color_name(colorid);
app->color_changevalue(name, rgb[0], rgb[1], rgb[2]);
//We declare that we are returning a pyobject, so lets actually return one!
Py_INCREF(Py_None);
return Py_None;
}
示例3: 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;
}
示例4:
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;
}