Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/freestyle/intern/python')
-rw-r--r--source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp156
-rw-r--r--source/blender/freestyle/intern/python/BPy_ContextFunctions.h18
-rw-r--r--source/blender/freestyle/intern/python/BPy_Freestyle.cpp2
3 files changed, 176 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp
new file mode 100644
index 00000000000..f8e4afb2400
--- /dev/null
+++ b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp
@@ -0,0 +1,156 @@
+#include "BPy_ContextFunctions.h"
+#include "BPy_Convert.h"
+
+#include "../stroke/ContextFunctions.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+/*-----------------------Python API function prototypes for the ContextFunctions module--*/
+
+static PyObject * ContextFunctions_GetTimeStampCF( PyObject* self );
+static PyObject * ContextFunctions_GetCanvasWidthCF( PyObject* self );
+static PyObject * ContextFunctions_GetCanvasHeightCF( PyObject* self );
+static PyObject * ContextFunctions_LoadMapCF( PyObject *self, PyObject *args );
+static PyObject * ContextFunctions_ReadMapPixelCF( PyObject *self, PyObject *args );
+static PyObject * ContextFunctions_ReadCompleteViewMapPixelCF( PyObject *self, PyObject *args );
+static PyObject * ContextFunctions_ReadDirectionalViewMapPixelCF( PyObject *self, PyObject *args );
+static PyObject * ContextFunctions_GetSelectedFEdgeCF( PyObject *self );
+
+/*-----------------------ContextFunctions module docstring-------------------------------*/
+
+static char module_docstring[] = "The Blender.Freestyle.ContextFunctions submodule";
+
+/*-----------------------ContextFunctions module functions definitions-------------------*/
+
+static PyMethodDef module_functions[] = {
+ {"GetTimeStampCF", (PyCFunction)ContextFunctions_GetTimeStampCF, METH_NOARGS, ""},
+ {"GetCanvasWidthCF", (PyCFunction)ContextFunctions_GetCanvasWidthCF, METH_NOARGS, ""},
+ {"GetCanvasHeightCF", (PyCFunction)ContextFunctions_GetCanvasHeightCF, METH_NOARGS, ""},
+ {"LoadMapCF", (PyCFunction)ContextFunctions_LoadMapCF, METH_VARARGS, ""},
+ {"ReadMapPixelCF", (PyCFunction)ContextFunctions_ReadMapPixelCF, METH_VARARGS, ""},
+ {"ReadCompleteViewMapPixelCF", (PyCFunction)ContextFunctions_ReadCompleteViewMapPixelCF, METH_VARARGS, ""},
+ {"ReadDirectionalViewMapPixelCF", (PyCFunction)ContextFunctions_ReadDirectionalViewMapPixelCF, METH_VARARGS, ""},
+ {"GetSelectedFEdgeCF", (PyCFunction)ContextFunctions_GetSelectedFEdgeCF, METH_NOARGS, ""},
+ {NULL, NULL, 0, NULL}
+};
+
+//------------------- MODULE INITIALIZATION --------------------------------
+
+void ContextFunctions_Init( PyObject *module )
+{
+ PyObject *m, *d, *f;
+
+ if( module == NULL )
+ return;
+
+ m = Py_InitModule3("Blender.Freestyle.ContextFunctions", module_functions, module_docstring);
+ if (m == NULL)
+ return;
+ PyModule_AddObject(module, "ContextFunctions", m);
+
+ // from ContextFunctions import *
+ d = PyModule_GetDict(m);
+ for (PyMethodDef *p = module_functions; p->ml_name; p++) {
+ f = PyDict_GetItemString(d, p->ml_name);
+ Py_INCREF(f);
+ PyModule_AddObject(module, p->ml_name, f);
+ }
+}
+
+//------------------------ MODULE FUNCTIONS ----------------------------------
+
+static PyObject *
+ContextFunctions_GetTimeStampCF( PyObject* self )
+{
+ return PyInt_FromLong( ContextFunctions::GetTimeStampCF() );
+}
+
+static PyObject *
+ContextFunctions_GetCanvasWidthCF( PyObject* self )
+{
+ return PyInt_FromLong( ContextFunctions::GetCanvasWidthCF() );
+}
+
+static PyObject *
+ContextFunctions_GetCanvasHeightCF( PyObject* self )
+{
+ return PyInt_FromLong( ContextFunctions::GetCanvasHeightCF() );
+}
+
+static PyObject *
+ContextFunctions_LoadMapCF( PyObject *self, PyObject *args )
+{
+ char *fileName, *mapName;
+ unsigned nbLevels;
+ float sigma;
+
+ if( !PyArg_ParseTuple(args, "ssIf", &fileName, &mapName, &nbLevels, &sigma) )
+ return NULL;
+
+ ContextFunctions::LoadMapCF(fileName, mapName, nbLevels, sigma);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+ContextFunctions_ReadMapPixelCF( PyObject *self, PyObject *args )
+{
+ char *mapName;
+ int level;
+ unsigned x, y;
+
+ if( !PyArg_ParseTuple(args, "siII", &mapName, &level, &x, &y) )
+ return NULL;
+
+ float f = ContextFunctions::ReadMapPixelCF(mapName, level, x, y);
+
+ return PyFloat_FromDouble( f );
+}
+
+static PyObject *
+ContextFunctions_ReadCompleteViewMapPixelCF( PyObject *self, PyObject *args )
+{
+ int level;
+ unsigned x, y;
+
+ if( !PyArg_ParseTuple(args, "iII", &level, &x, &y) )
+ return NULL;
+
+ float f = ContextFunctions::ReadCompleteViewMapPixelCF(level, x, y);
+
+ return PyFloat_FromDouble( f );
+}
+
+static PyObject *
+ContextFunctions_ReadDirectionalViewMapPixelCF( PyObject *self, PyObject *args )
+{
+ int orientation, level;
+ unsigned x, y;
+
+ if( !PyArg_ParseTuple(args, "iiII", &orientation, &level, &x, &y) )
+ return NULL;
+
+ float f = ContextFunctions::ReadDirectionalViewMapPixelCF(orientation, level, x, y);
+
+ return PyFloat_FromDouble( f );
+}
+
+static PyObject *
+ContextFunctions_GetSelectedFEdgeCF( PyObject *self )
+{
+ FEdge *fe = ContextFunctions::GetSelectedFEdgeCF();
+ if( fe )
+ return BPy_FEdge_from_FEdge( *fe );
+
+ Py_RETURN_NONE;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/freestyle/intern/python/BPy_ContextFunctions.h b/source/blender/freestyle/intern/python/BPy_ContextFunctions.h
new file mode 100644
index 00000000000..b02145c455a
--- /dev/null
+++ b/source/blender/freestyle/intern/python/BPy_ContextFunctions.h
@@ -0,0 +1,18 @@
+#ifndef FREESTYLE_PYTHON_CONTEXTFUNCTIONS_H
+#define FREESTYLE_PYTHON_CONTEXTFUNCTIONS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <Python.h>
+
+/*---------------------------Python BPy_ContextFunctions visible prototypes-----------*/
+
+PyMODINIT_FUNC ContextFunctions_Init( PyObject *module );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREESTYLE_PYTHON_CONTEXTFUNCTIONS_H */
diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
index 8c55fdc3fd0..1afc3cc903e 100644
--- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
@@ -3,6 +3,7 @@
#include "BPy_BBox.h"
#include "BPy_BinaryPredicate0D.h"
#include "BPy_BinaryPredicate1D.h"
+#include "BPy_ContextFunctions.h"
#include "BPy_FrsMaterial.h"
#include "BPy_FrsNoise.h"
#include "BPy_Id.h"
@@ -147,6 +148,7 @@ PyObject *Freestyle_Init( void )
BBox_Init( module );
BinaryPredicate0D_Init( module );
BinaryPredicate1D_Init( module );
+ ContextFunctions_Init( module );
FrsMaterial_Init( module );
FrsNoise_Init( module );
Id_Init( module );