PyObject * PyOCIO_ColorSpaceTransform_getDst(PyObject * self) { OCIO_PYTRY_ENTER() ConstColorSpaceTransformRcPtr transform = GetConstColorSpaceTransform(self); return PyString_FromString(transform->getDst()); OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_MatrixTransform_setValue(PyObject * self, PyObject * args) { OCIO_PYTRY_ENTER() PyObject* pymatrix = 0; PyObject* pyoffset = 0; if (!PyArg_ParseTuple(args, "OO:setValue", &pymatrix, &pyoffset)) return NULL; std::vector<float> matrix; std::vector<float> offset; if(!FillFloatVectorFromPySequence(pymatrix, matrix) || (matrix.size() != 16)) { PyErr_SetString(PyExc_TypeError, "First argument must be a float array, size 16"); return 0; } if(!FillFloatVectorFromPySequence(pyoffset, offset) || (offset.size() != 4)) { PyErr_SetString(PyExc_TypeError, "Second argument must be a float array, size 4"); return 0; } MatrixTransformRcPtr transform = GetEditableMatrixTransform(self); transform->setValue(&matrix[0], &offset[0]); Py_RETURN_NONE; OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_Look_getProcessSpace(PyObject * self) { OCIO_PYTRY_ENTER() ConstLookRcPtr look = GetConstLook(self, true); return PyString_FromString(look->getProcessSpace()); OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_GroupTransform_clear(PyObject * self) { OCIO_PYTRY_ENTER() GroupTransformRcPtr transform = GetEditableGroupTransform(self); transform->clear(); Py_RETURN_NONE; OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_CDLTransform_getSOP(PyObject * self) { OCIO_PYTRY_ENTER() ConstCDLTransformRcPtr transform = GetConstCDLTransform(self); std::vector<float> data(9); transform->getSOP(&data[0]); return CreatePyListFromFloatVector(data); OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_AllocationTransform_getVars(PyObject * self) { OCIO_PYTRY_ENTER() ConstAllocationTransformRcPtr transform = GetConstAllocationTransform(self); std::vector<float> vars(transform->getNumVars()); if(!vars.empty()) transform->getVars(&vars[0]); return CreatePyListFromFloatVector(vars); OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_MatrixTransform_getOffset(PyObject * self) { OCIO_PYTRY_ENTER() ConstMatrixTransformRcPtr transform = GetConstMatrixTransform(self); std::vector<float> offset(4); transform->getOffset(&offset[0]); return CreatePyListFromFloatVector(offset); OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_MatrixTransform_getMatrix(PyObject * self) { OCIO_PYTRY_ENTER() ConstMatrixTransformRcPtr transform = GetConstMatrixTransform(self); std::vector<float> matrix(16); transform->getMatrix(&matrix[0]); return CreatePyListFromFloatVector(matrix); OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_GroupTransform_getTransforms(PyObject * self) { OCIO_PYTRY_ENTER() ConstGroupTransformRcPtr transform = GetConstGroupTransform(self); std::vector<ConstTransformRcPtr> transforms; for(int i = 0; i < transform->size(); ++i) transforms.push_back(transform->getTransform(i)); return CreatePyListFromTransformVector(transforms); OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_AllocationTransform_setAllocation(PyObject * self, PyObject * args) { OCIO_PYTRY_ENTER() Allocation hwalloc; if (!PyArg_ParseTuple(args,"O&:setAllocation", ConvertPyObjectToAllocation, &hwalloc)) return NULL; AllocationTransformRcPtr transform = GetEditableAllocationTransform(self); transform->setAllocation(hwalloc); Py_RETURN_NONE; OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_SetCurrentConfig(PyObject * /*self*/, PyObject * args) { OCIO_PYTRY_ENTER() PyObject * pyconfig; if (!PyArg_ParseTuple(args, "O!:SetCurrentConfig", &OCIO::PyOCIO_ConfigType, &pyconfig)) return NULL; OCIO::ConstConfigRcPtr c = OCIO::GetConstConfig(pyconfig, true); OCIO::SetCurrentConfig(c); Py_RETURN_NONE; OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_CDLTransform_equals(PyObject * self, PyObject * args) { OCIO_PYTRY_ENTER() PyObject* pyother = 0; if (!PyArg_ParseTuple(args, "O:equals", &pyother)) return NULL; ConstCDLTransformRcPtr transform = GetConstCDLTransform(self); if(IsPyOCIOType(pyother, PyOCIO_CDLTransformType)) return PyBool_FromLong(false); ConstCDLTransformRcPtr other = GetConstCDLTransform(pyother); return PyBool_FromLong(transform->equals(other)); OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_GroupTransform_push_back(PyObject * self, PyObject * args) { OCIO_PYTRY_ENTER() PyObject* pytransform = 0; if (!PyArg_ParseTuple(args,"O:push_back", &pytransform)) return NULL; GroupTransformRcPtr transform = GetEditableGroupTransform(self); if(!IsPyTransform(pytransform)) throw Exception("GroupTransform.push_back requires a transform as the first arg."); transform->push_back(GetConstTransform(pytransform, true)); Py_RETURN_NONE; OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_MatrixTransform_Identity(PyObject * /*self*/) { OCIO_PYTRY_ENTER() std::vector<float> matrix(16); std::vector<float> offset(4); MatrixTransform::Identity(&matrix[0], &offset[0]); PyObject* pymatrix = CreatePyListFromFloatVector(matrix); PyObject* pyoffset = CreatePyListFromFloatVector(offset); PyObject* pyreturnval = Py_BuildValue("(OO)", pymatrix, pyoffset); Py_DECREF(pymatrix); Py_DECREF(pyoffset); return pyreturnval; OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_SetLoggingLevel(PyObject * /*self*/, PyObject * args) { OCIO_PYTRY_ENTER() PyObject* pylevel; if (!PyArg_ParseTuple(args, "O:SetLoggingLevel", &pylevel)) return NULL; // We explicitly cast to a str to handle both the str and int cases. PyObject* pystr = PyObject_Str(pylevel); if(!pystr) throw OCIO::Exception("Fist argument must be a LOGGING_LEVEL"); OCIO::LoggingLevel level = OCIO::LoggingLevelFromString(PyString_AsString(pystr)); OCIO::SetLoggingLevel(level); Py_DECREF(pystr); Py_RETURN_NONE; OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_MatrixTransform_getValue(PyObject * self) { OCIO_PYTRY_ENTER() ConstMatrixTransformRcPtr transform = GetConstMatrixTransform(self); std::vector<float> matrix(16); std::vector<float> offset(4); transform->getValue(&matrix[0], &offset[0]); PyObject* pymatrix = CreatePyListFromFloatVector(matrix); PyObject* pyoffset = CreatePyListFromFloatVector(offset); PyObject* pyreturnval = Py_BuildValue("(OO)", pymatrix, pyoffset); Py_DECREF(pymatrix); Py_DECREF(pyoffset); return pyreturnval; OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_AllocationTransform_setVars(PyObject * self, PyObject * args) { OCIO_PYTRY_ENTER() PyObject * pyvars = 0; if (!PyArg_ParseTuple(args,"O:setVars", &pyvars)) return NULL; std::vector<float> vars; if(!FillFloatVectorFromPySequence(pyvars, vars)) { PyErr_SetString(PyExc_TypeError, "First argument must be a float array."); return 0; } AllocationTransformRcPtr transform = GetEditableAllocationTransform(self); if(!vars.empty()) transform->setVars(static_cast<int>(vars.size()), &vars[0]); Py_RETURN_NONE; OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_CDLTransform_setSOP(PyObject * self, PyObject * args) { OCIO_PYTRY_ENTER() PyObject* pyData = 0; if (!PyArg_ParseTuple(args, "O:setSOP", &pyData)) return NULL; CDLTransformRcPtr transform = GetEditableCDLTransform(self); std::vector<float> data; if(!FillFloatVectorFromPySequence(pyData, data) || (data.size() != 9)) { PyErr_SetString(PyExc_TypeError, "First argument must be a float array, size 9"); return 0; } transform->setSOP(&data[0]); Py_RETURN_NONE; OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_GroupTransform_setTransforms(PyObject * self, PyObject * args) { OCIO_PYTRY_ENTER() PyObject* pytransforms = 0; if (!PyArg_ParseTuple(args,"O:setTransforms", &pytransforms)) return NULL; GroupTransformRcPtr transform = GetEditableGroupTransform(self); std::vector<ConstTransformRcPtr> data; if(!FillTransformVectorFromPySequence(pytransforms, data)) { PyErr_SetString(PyExc_TypeError, "First argument must be a transform array."); return 0; } transform->clear(); for(unsigned int i = 0; i < data.size(); ++i) transform->push_back(data[i]); Py_RETURN_NONE; OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_MatrixTransform_Fit(PyObject * /*self*/, PyObject * args) { OCIO_PYTRY_ENTER() PyObject* pyoldmin = 0; PyObject* pyoldmax = 0; PyObject* pynewmin = 0; PyObject* pynewmax = 0; if (!PyArg_ParseTuple(args,"OOOO:Fit", &pyoldmin, &pyoldmax, &pynewmin, &pynewmax)) return NULL; std::vector<float> oldmin; if(!FillFloatVectorFromPySequence(pyoldmin, oldmin) || (oldmin.size() != 4)) { PyErr_SetString(PyExc_TypeError, "First argument must be a float array, size 4"); return 0; } std::vector<float> oldmax; if(!FillFloatVectorFromPySequence(pyoldmax, oldmax) || (oldmax.size() != 4)) { PyErr_SetString(PyExc_TypeError, "Second argument must be a float array, size 4"); return 0; } std::vector<float> newmin; if(!FillFloatVectorFromPySequence(pynewmin, newmin) || (newmin.size() != 4)) { PyErr_SetString(PyExc_TypeError, "Third argument must be a float array, size 4"); return 0; } std::vector<float> newmax; if(!FillFloatVectorFromPySequence(pynewmax, newmax) || (newmax.size() != 4)) { PyErr_SetString(PyExc_TypeError, "Fourth argument must be a float array, size 4"); return 0; } std::vector<float> matrix(16); std::vector<float> offset(4); MatrixTransform::Fit(&matrix[0], &offset[0], &oldmin[0], &oldmax[0], &newmin[0], &newmax[0]); PyObject* pymatrix = CreatePyListFromFloatVector(matrix); PyObject* pyoffset = CreatePyListFromFloatVector(offset); PyObject* pyreturnval = Py_BuildValue("(OO)", pymatrix, pyoffset); Py_DECREF(pymatrix); Py_DECREF(pyoffset); return pyreturnval; OCIO_PYTRY_EXIT(NULL) }