Esempio n. 1
0
static PyObject *set_scale(PyObject *self, PyObject *args, PyObject *keywds) {
  static char *kwlist[] = {
    (char *)"method", (char *)"midpoint", (char *)"min", (char *)"max", NULL
  };

  char *method = NULL;
  float midpoint = -1, min = -1, max = -1;
  VMDApp *app = get_vmdapp();
  app->colorscale_info(&midpoint, &min, &max);
 
  if (!PyArg_ParseTupleAndKeywords(args, keywds, (char *)"|sfff", kwlist,
                                   &method, &midpoint, &min, &max)) 
    return NULL; 

  if (method) {
    int ind = app->colorscale_method_index(method);
    if (ind < 0) { 
      PyErr_SetString(PyExc_ValueError, (char *)"Invalid color scale method");
      return NULL;
    }
    app->colorscale_setmethod(ind);
  }
  app->colorscale_setvalues(midpoint, min, max);  
  Py_INCREF(Py_None);
  return Py_None;
}
Esempio n. 2
0
static PyObject* py_set_scale(PyObject *self, PyObject *args, PyObject *kwargs)
{

  const char *kwnames[] = {"method", "midpoint", "min", "max", NULL};
  float midpoint = -1, min = -1, max = -1;
  char *method = NULL;
  VMDApp *app;

  // Set midpoint, min and max to the current values
  if (!(app = get_vmdapp()))
    return NULL;
  app->colorscale_info(&midpoint, &min, &max);

  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|zfff:color.set_scale",
                                   (char**) kwnames, &method, &midpoint, &min,
                                   &max))
    return NULL;

  if (method) {
    int ind = app->colorscale_method_index(method);
    if (ind < 0) {
      PyErr_SetString(PyExc_ValueError, "Invalid color scale method");
      return NULL;
    }
    app->colorscale_setmethod(ind);
  }
  app->colorscale_setvalues(midpoint, min, max);

  Py_INCREF(Py_None);
  return Py_None;
}