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

Curve.h « api2_2x « python « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c0921bead787d3e10885cbd5177a2435c4a1f66a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/* 
 *
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version. The Blender
 * Foundation also sells licenses for use in proprietary software under
 * the Blender License.  See http://www.blender.org/BL/ for information
 * about this.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 * All rights reserved.
 *
 * This is a new part of Blender.
 *
 * Contributor(s): Jacques Guignot
 *
 * ***** END GPL/BL DUAL LICENSE BLOCK *****
*/

#ifndef EXPP_CURVE_H
#define EXPP_CURVE_H

#include <Python.h>
#include <stdio.h>

#include <BLI_arithb.h>
#include <BLI_blenlib.h>
#include <BKE_main.h>
#include <BKE_global.h>
#include <BKE_object.h>
#include <BKE_library.h>
#include <BKE_curve.h>
#include <DNA_curve_types.h>

#include "gen_utils.h"

/*****************************************************************************/
/*  Python API function prototypes for the Curve module.                     */
/*****************************************************************************/
static PyObject *M_Curve_New (PyObject *self, PyObject *args);
static PyObject *M_Curve_Get (PyObject *self, PyObject *args);

/*****************************************************************************/
/* The following string definitions are used for documentation strings.      */
/* In Python these will be written to the console when doing a               */
/*  Blender.Curve.__doc__                                                    */
/*****************************************************************************/
char M_Curve_doc[] = "The Blender Curve module\n\n\
This module provides access to **Curve Data** in Blender.\n\
Functions :\n\
	New(opt name) : creates a new curve object with the given name (optional)\n\
	Get(name) : retreives a curve  with the given name (mandatory)\n\
	get(name) : same as Get. Kept for compatibility reasons";
char M_Curve_New_doc[] ="";
char M_Curve_Get_doc[] ="xxx";
/*****************************************************************************/
/*  Python method structure definition for Blender.Curve module:             */
/*****************************************************************************/
struct PyMethodDef M_Curve_methods[] = {
  {"New",(PyCFunction)M_Curve_New, METH_VARARGS,M_Curve_New_doc},
  {"Get",         M_Curve_Get,         METH_VARARGS, M_Curve_Get_doc},
  {"get",         M_Curve_Get,         METH_VARARGS, M_Curve_Get_doc},
  {NULL, NULL, 0, NULL}
};

/*****************************************************************************/
/* Python C_Curve structure definition:                                     */
/*****************************************************************************/
typedef struct {
  PyObject_HEAD
  Curve   *curve;
} C_Curve;

/*****************************************************************************/
/*  Python C_Curve methods declarations:                                     */
/*****************************************************************************/
static PyObject *Curve_getName(C_Curve *self);
static PyObject *Curve_setName(C_Curve *self, PyObject *args);
static PyObject *Curve_getPathLen(C_Curve *self);
static PyObject *Curve_setPathLen(C_Curve *self, PyObject *args);
static PyObject *Curve_getTotcol(C_Curve *self);
static PyObject *Curve_setTotcol(C_Curve *self, PyObject *args);
static PyObject *Curve_getMode(C_Curve *self);
static PyObject *Curve_setMode(C_Curve *self, PyObject *args);
static PyObject *Curve_getBevresol(C_Curve *self);
static PyObject *Curve_setBevresol(C_Curve *self, PyObject *args);
static PyObject *Curve_getResolu(C_Curve *self);
static PyObject *Curve_setResolu(C_Curve *self, PyObject *args);
static PyObject *Curve_getResolv(C_Curve *self);
static PyObject *Curve_setResolv(C_Curve *self, PyObject *args);
static PyObject *Curve_getWidth(C_Curve *self);
static PyObject *Curve_setWidth(C_Curve *self, PyObject *args);
static PyObject *Curve_getExt1(C_Curve *self);
static PyObject *Curve_setExt1(C_Curve *self, PyObject *args);
static PyObject *Curve_getExt2(C_Curve *self);
static PyObject *Curve_setExt2(C_Curve *self, PyObject *args);
static PyObject *Curve_getControlPoint(C_Curve *self, PyObject *args);
static PyObject *Curve_setControlPoint(C_Curve *self, PyObject *args);
static PyObject *Curve_getLoc(C_Curve *self);
static PyObject *Curve_setLoc(C_Curve *self, PyObject *args);
static PyObject *Curve_getRot(C_Curve *self);
static PyObject *Curve_setRot(C_Curve *self, PyObject *args);
static PyObject *Curve_getSize(C_Curve *self);
static PyObject *Curve_setSize(C_Curve *self, PyObject *args);

/*****************************************************************************/
/*  Python C_Curve methods table:                                            */
/*****************************************************************************/
static PyMethodDef C_Curve_methods[] = {
 /* name, method, flags, doc */
  {"getName", (PyCFunction)Curve_getName,
	METH_NOARGS,"() - Return Curve Data name"},
  {"setName", (PyCFunction)Curve_setName,
	METH_VARARGS,"() - Sets Curve Data name"},
  {"getPathLen", (PyCFunction)Curve_getPathLen,
	METH_NOARGS,"() - Return Curve path length"},
  {"setPathLen", (PyCFunction)Curve_setPathLen,
	METH_VARARGS,"(int) - Sets Curve path length"},
  {"getTotcol", (PyCFunction)Curve_getTotcol,
	METH_NOARGS,"() - Return totcol"},
  {"setTotcol", (PyCFunction)Curve_setTotcol, 
	METH_VARARGS,"(int) - Sets totcol"},
  {"getFlag", (PyCFunction)Curve_getMode, 
   	METH_NOARGS,"() - Return flag"},
  {"setFlag", (PyCFunction)Curve_setMode, 
	METH_VARARGS,"(int) - Sets flag"},
  {"getBevresol", (PyCFunction)Curve_getBevresol, 
	METH_NOARGS,"() - Return bevresol"},
  {"setBevresol", (PyCFunction)Curve_setBevresol, 
	METH_VARARGS,"(int) - Sets bevresol"},
  {"getResolu", (PyCFunction)Curve_getResolu, 
	METH_NOARGS,"() - Return resolu"},
  {"setResolu", (PyCFunction)Curve_setResolu, 
	METH_VARARGS,"(int) - Sets resolu"},
  {"getResolv", (PyCFunction)Curve_getResolv, 
	METH_NOARGS,"() - Return resolv"},
  {"setResolv", (PyCFunction)Curve_setResolv, 
	METH_VARARGS,"(int) - Sets resolv"},
  {"getWidth", (PyCFunction)Curve_getWidth, 
	METH_NOARGS,"() - Return width"},
  {"setWidth", (PyCFunction)Curve_setWidth, 
	METH_VARARGS,"(int) - Sets width"},
  {"getExt1", (PyCFunction)Curve_getExt1, 
	METH_NOARGS,"() - Return ext1"},
  {"setExt1", (PyCFunction)Curve_setExt1, 
	METH_VARARGS,"(int) - Sets ext1"},
  {"getExt2", (PyCFunction)Curve_getExt2, 
	METH_NOARGS,"() - Return ext2"},
  {"setExt2", (PyCFunction)Curve_setExt2, 
	METH_VARARGS,"(int) - Sets ext2"},
  {"getControlPoint", (PyCFunction)Curve_getControlPoint, 
	METH_VARARGS,"(int numcurve,int numpoint) - Gets a control point."
			"\nDepending upon the curve type, returne a list of 4 or 9 floats"},
  {"setControlPoint", (PyCFunction)Curve_setControlPoint, 
	METH_VARARGS,"(int numcurve,int numpoint,float x,float y,float z,\
loat w)(nurbs) or  (int numcurve,int numpoint,float x1,...,x9(bezier)\
Sets a control point "},
  {"getLoc", (PyCFunction)Curve_getLoc, 
	METH_NOARGS,"() - Gets Location"},
  {"setLoc", (PyCFunction)Curve_setLoc, 
	METH_VARARGS,"(float x,float y,float z) - Sets Location"},
  {"getRot", (PyCFunction)Curve_getRot, 
	METH_NOARGS,"() - Gets Rotation"},
  {"setRot", (PyCFunction)Curve_setRot, 
	METH_VARARGS,"(float x,float y,float z) - Sets Rotation"},
  {"getSize", (PyCFunction)Curve_getSize, 
	METH_NOARGS,"() - Gets Size"},
  {"setSize", (PyCFunction)Curve_setSize, 
	METH_VARARGS,"(float x,float y,float z) - Sets Size"},
  {0}
};

/*****************************************************************************/
/*  Python Curve_Type callback function prototypes:                           */
/*****************************************************************************/
static void CurveDeAlloc (C_Curve *msh);
static int CurvePrint (C_Curve *msh, FILE *fp, int flags);
static int CurveSetAttr (C_Curve *msh, char *name, PyObject *v);
static PyObject *CurveGetAttr (C_Curve *msh, char *name);
static PyObject *CurveRepr (C_Curve *msh);
PyObject* CurveCreatePyObject (struct Curve *curve);
int CurveCheckPyObject (PyObject *py_obj);
struct Curve* CurveFromPyObject (PyObject *py_obj);


/*****************************************************************************/
/* Python Curve_Type structure definition:                                   */
/*****************************************************************************/
static PyTypeObject Curve_Type =
{
  PyObject_HEAD_INIT(NULL)
  0,                                      /* ob_size */
  "Curve",                               /* tp_name */
  sizeof (C_Curve),                      /* tp_basicsize */
  0,                                      /* tp_itemsize */
  /* methods */
  (destructor)CurveDeAlloc,              /* tp_dealloc */
  (printfunc)CurvePrint,                 /* tp_print */
  (getattrfunc)CurveGetAttr,             /* tp_getattr */
  (setattrfunc)CurveSetAttr,             /* tp_setattr */
  0,                                      /* tp_compare */
  (reprfunc)CurveRepr,                   /* tp_repr */
  0,                                      /* tp_as_number */
  0,                                      /* tp_as_sequence */
  0,                                      /* tp_as_mapping */
  0,                                      /* tp_as_hash */
  0,0,0,0,0,0,
  0,                                      /* tp_doc */ 
  0,0,0,0,0,0,
  C_Curve_methods,                       /* tp_methods */
  0,                                      /* tp_members */
};

#endif /* EXPP_CURVE_H */