Page Menu
Home
Search
Configure Global Search
Log In
Files
F1502
delCurve-patch.txt
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Ken Hughes (khughes)
Nov 13 2013, 12:58 PM
Size
11 KB
Subscribers
None
delCurve-patch.txt
View Options
Index: source/blender/python/api2_2x/Ipo.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Ipo.c,v
retrieving revision 1.36
diff -u -u -r1.36 Ipo.c
--- source/blender/python/api2_2x/Ipo.c 9 Mar 2005 19:45:55 -0000 1.36
+++ source/blender/python/api2_2x/Ipo.c 11 Mar 2005 03:44:28 -0000
@@ -47,11 +47,6 @@
#include "constant.h"
#include "gen_utils.h"
-
-
-/* forward declarations */
-char *GetIpoCurveName( IpoCurve * icu );
-
/*****************************************************************************/
/* Python API function prototypes for the Ipo module. */
/*****************************************************************************/
@@ -95,6 +90,7 @@
static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args );
static PyObject *Ipo_getCurves( BPy_Ipo * self );
static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args );
+static PyObject *Ipo_delCurve( BPy_Ipo * self, PyObject * args );
static PyObject *Ipo_getNcurves( BPy_Ipo * self );
static PyObject *Ipo_getNBezPoints( BPy_Ipo * self, PyObject * args );
static PyObject *Ipo_DeleteBezPoints( BPy_Ipo * self, PyObject * args );
@@ -125,6 +121,8 @@
"(str) - Change Ipo rctf"},
{"addCurve", ( PyCFunction ) Ipo_addCurve, METH_VARARGS,
"() - Return Ipo ncurves"},
+ {"delCurve", ( PyCFunction ) Ipo_delCurve, METH_VARARGS,
+ "() - Delete Ipo curves"},
{"getNcurves", ( PyCFunction ) Ipo_getNcurves, METH_NOARGS,
"() - Return Ipo ncurves"},
{"getNBezPoints", ( PyCFunction ) Ipo_getNBezPoints, METH_VARARGS,
@@ -1125,6 +1123,46 @@
return IpoCurve_CreatePyObject( icu );
}
+/*
+ Function: Ipo_delCurve
+ Bpy: Blender.Ipo.delCurve(curtype)
+
+ delete an existing curve from IPO.
+ example:
+ ipo = Blender.Ipo.New('Object','ObIpo')
+ cu = ipo.delCurve('LocX')
+*/
+
+void del_ipoCurve ( IpoCurve * icu);
+
+static PyObject *Ipo_delCurve( BPy_Ipo * self, PyObject * args )
+{
+ IpoCurve *icu;
+ int num;
+ int i;
+
+ char *strname;
+ if( !PyArg_ParseTuple( args, "s", &strname ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected int or string argument" ) );
+
+ for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
+ char *str1 = GetIpoCurveName( icu );
+ if( !strcmp( str1, strname ) ) {
+ BLI_remlink( &(self->ipo->curve), icu);
+ if(icu->bezt) MEM_freeN(icu->bezt);
+ MEM_freeN(icu);
+ del_ipoCurve ( icu );
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+ }
+
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_RuntimeError, "IpoCurve not found" ) );
+}
+
static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args )
@@ -1144,57 +1182,6 @@
Py_INCREF( Py_None );
return Py_None;
-}
-
-char *GetIpoCurveName( IpoCurve * icu )
-{
- switch ( icu->blocktype ) {
- case ID_MA:
- {
- return getname_mat_ei( icu->adrcode );
- }
- case ID_WO:
- {
- return getname_world_ei( icu->adrcode );
- }
- case ID_CA:
- {
- return getname_cam_ei( icu->adrcode );
- }
- case ID_OB:
- {
- return getname_ob_ei( icu->adrcode, 1 ); /* solve: what if EffX/Y/Z are wanted? */
- }
- case ID_TE:
- {
- return getname_tex_ei( icu->adrcode );
- }
- case ID_LA:
- {
- return getname_la_ei( icu->adrcode );
- }
- case ID_AC:
- {
- return getname_ac_ei( icu->adrcode );
- }
- case ID_CU:
- {
- return getname_cu_ei( icu->adrcode );
- }
- case ID_KE:
- {
- return getname_key_ei( icu->adrcode );
- }
- case ID_SEQ:
- {
- return getname_seq_ei( icu->adrcode );
- }
- case IPO_CO:
- {
- return getname_co_ei( icu->adrcode );
- }
- }
- return NULL;
}
static PyObject *Ipo_getCurves( BPy_Ipo * self )
Index: source/blender/python/api2_2x/Ipocurve.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Ipocurve.c,v
retrieving revision 1.21
diff -u -u -r1.21 Ipocurve.c
--- source/blender/python/api2_2x/Ipocurve.c 30 Nov 2004 02:27:46 -0000 1.21
+++ source/blender/python/api2_2x/Ipocurve.c 11 Mar 2005 03:44:28 -0000
@@ -80,6 +80,7 @@
static PyObject *IpoCurve_Recalc( C_IpoCurve * self );
static PyObject *IpoCurve_setName( C_IpoCurve * self, PyObject * args );
static PyObject *IpoCurve_addBezier( C_IpoCurve * self, PyObject * args );
+static PyObject *IpoCurve_delBezier( C_IpoCurve * self, PyObject * args );
static PyObject *IpoCurve_setInterpolation( C_IpoCurve * self,
PyObject * args );
static PyObject *IpoCurve_getInterpolation( C_IpoCurve * self );
@@ -105,6 +106,8 @@
"(str) - Change IpoCurve Data name"},
{"addBezier", ( PyCFunction ) IpoCurve_addBezier, METH_VARARGS,
"(str) - Change IpoCurve Data name"},
+ {"delBezier", ( PyCFunction ) IpoCurve_delBezier, METH_VARARGS,
+ "(int) - delete Bezier point at index"},
{"setInterpolation", ( PyCFunction ) IpoCurve_setInterpolation,
METH_VARARGS,
"(str) - Change IpoCurve Data name"},
@@ -326,6 +329,71 @@
return Py_None;
}
+/*
+ Function: IpoCurve_delBezier
+ Bpy: Blender.Ipocurve.delBezier(0)
+
+ Delete an BezTriple from an IPO curve.
+ example:
+ ipo = Blender.Ipo.Get('ObIpo')
+ cu = ipo.getCurve('LocX')
+ cu.delBezier(0)
+*/
+
+static PyObject *IpoCurve_delBezier( C_IpoCurve * self, PyObject * args )
+{
+ short MEM_freeN( void *vmemh );
+ void *MEM_mallocN( unsigned int len, char *str );
+ int npoints;
+ int index;
+ IpoCurve *icu;
+ BezTriple *tmp;
+
+ if( !PyArg_ParseTuple( args, "i", &index ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int argument" ) );
+
+ icu = self->ipocurve;
+ npoints = icu->totvert - 1;
+
+ /* if index is negative, count from end of list */
+ if ( index < 0 ) index += icu->totvert;
+ /* check range of index */
+ if ( index < 0 || index > npoints )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_ValueError, "index outside of list" ) );
+
+ tmp = icu->bezt;
+
+ /*
+ if delete empties list, then delete it, otherwise copy the remaining
+ points to a new list
+ */
+
+ if ( npoints == 0 ) {
+ icu->bezt = NULL;
+ } else {
+ icu->bezt = MEM_mallocN( sizeof( BezTriple ) * npoints, "bezt" );
+ if ( index > 0 )
+ memmove( icu->bezt , tmp,
+ index * sizeof( BezTriple ) );
+ if ( index < npoints )
+ memmove( icu->bezt + index, tmp + index + 1,
+ (npoints - index) * sizeof( BezTriple ) );
+ }
+
+ /* free old list, adjust vertex count */
+ MEM_freeN( tmp );
+ icu->totvert--;
+
+ /* call calchandles_* instead of testhandles_* */
+ /* I'm not sure this is a complete solution but since we do not */
+ /* deal with curve handles right now, it seems ok */
+ calchandles_ipocurve( icu );
+
+ Py_INCREF( Py_None );
+ return Py_None;
+}
static PyObject *IpoCurve_setName( C_IpoCurve * self, PyObject * args )
{
@@ -468,10 +536,8 @@
/*****************************************************************************/
static PyObject *IpoCurveRepr( C_IpoCurve * self )
{
- void GetIpoCurveName( IpoCurve * icu, char *s );
- char s[100], s1[100];
- GetIpoCurveName( self->ipocurve, s1 );
- sprintf( s, "IpoCurve %s \n", s1 );
+ char s[100];
+ sprintf( s, "[IpoCurve \"%s\"]\n", GetIpoCurveName( self->ipocurve) );
return PyString_FromString( s );
}
@@ -538,3 +604,23 @@
return PyFloat_FromDouble( eval );
}
+
+char *GetIpoCurveName( IpoCurve * icu )
+{
+ switch ( icu->blocktype ) {
+ case ID_MA: return getname_mat_ei( icu->adrcode );
+ case ID_WO: return getname_world_ei( icu->adrcode );
+ case ID_CA: return getname_cam_ei( icu->adrcode );
+ case ID_OB: return getname_ob_ei( icu->adrcode, 1 );
+ /* solve: what if EffX/Y/Z are wanted? */
+ case ID_TE: return getname_tex_ei( icu->adrcode );
+ case ID_LA: return getname_la_ei( icu->adrcode );
+ case ID_AC: return getname_ac_ei( icu->adrcode );
+ case ID_CU: return getname_cu_ei( icu->adrcode );
+ case ID_KE: return getname_key_ei( icu->adrcode );
+ case ID_SEQ: return getname_seq_ei( icu->adrcode );
+ case IPO_CO: return getname_co_ei( icu->adrcode );
+ }
+ return NULL;
+}
+
Index: source/blender/python/api2_2x/Ipocurve.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Ipocurve.h,v
retrieving revision 1.8
diff -u -u -r1.8 Ipocurve.h
--- source/blender/python/api2_2x/Ipocurve.h 7 Oct 2004 19:25:39 -0000 1.8
+++ source/blender/python/api2_2x/Ipocurve.h 11 Mar 2005 03:44:28 -0000
@@ -50,7 +50,7 @@
PyObject *IpoCurve_CreatePyObject( IpoCurve * ipo );
int IpoCurve_CheckPyObject( PyObject * pyobj );
IpoCurve *IpoCurve_FromPyObject( PyObject * pyobj );
-
+char *GetIpoCurveName( IpoCurve * icu );
#endif /* EXPP_IPOCURVE_H */
Index: source/blender/src/editipo.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editipo.c,v
retrieving revision 1.46
diff -u -u -r1.46 editipo.c
--- source/blender/src/editipo.c 9 Mar 2005 19:45:56 -0000 1.46
+++ source/blender/src/editipo.c 11 Mar 2005 03:44:29 -0000
@@ -3126,8 +3126,25 @@
}
}
+/*
+ * When deleting an IPO curve from Python, check if the IPO is being
+ * edited and if so clear the pointer to the old curve.
+ */
+void del_ipoCurve ( IpoCurve * icu )
+{
+ int i;
+ EditIpo *ei= G.sipo->editipo;
+ if (!ei) return;
+ for(i=0; i<G.sipo->totipo; i++, ei++) {
+ if ( ei->icu == icu ) {
+ ei->flag &= ~(IPO_SELECT | IPO_EDIT);
+ ei->icu= 0;
+ return;
+ }
+ }
+}
void del_ipo()
{
Index: blender/source/blender/python/api2_2x/doc/Ipo.py
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/doc/Ipo.py,v
retrieving revision 1.22
diff -u -u -r1.22 Ipo.py
--- blender/source/blender/python/api2_2x/doc/Ipo.py 17 Dec 2004 17:34:51 -0000 1.22
+++ blender/source/blender/python/api2_2x/doc/Ipo.py 15 Mar 2005 17:12:45 -0000
@@ -90,7 +90,7 @@
MinkMExp, DistM, ColT, iScale, DistA, MgType, MgH, Lacu, Oct,
MgOff, MgGan, NBase1, NBase2.
7. Curve Ipo: Speed.
- 8. Key Ipo: Speed, 'Key 1' - 'Key 31'.
+ 8. Key Ipo: Speed, 'Key 1' - 'Key 63'.
9. Action Ipo: LocX, LocY, LocZ, SizeX, SizeY, SizeZ,
QuatX, QuatY, QuatZ, QuatW.
10. Sequence Ipo: Fac.
@@ -126,6 +126,14 @@
@return: the corresponding IpoCurve, or None.
"""
+ def removeCurve(curvename):
+ """
+ Remove a existing curve from the IPO object. See addCurve() for possible values for curvename.
+ @type curvename : string
+ @rtype: None
+ @return: None.
+ """
+
def setName(newname):
"""
Sets the name of the Ipo.
@@ -283,6 +291,15 @@
@rtype: None
@return: None
"""
+
+ def delBezier(index):
+ """
+ Deletes a Bezier point from a curve.
+ @type index: integer
+ @param index: the index of the Bezier point. Negative values index from the end of the list.
+ @rtype: None
+ @return: None
+ """
def Recalc():
"""
@@ -311,7 +328,7 @@
MinkMExp, DistM, ColT, iScale, DistA, MgType, MgH, Lacu, Oct,
MgOff, MgGan, NBase1, NBase2;
7. Curve Ipo: Speed;
- 8. Key Ipo: Speed, 'Key 1' - 'Key 31';
+ 8. Key Ipo: Speed, 'Key 1' - 'Key 63';
9. Action Ipo: LocX, LocY, LocZ, SizeX, SizeY, SizeZ,
QuatX, QuatY, QuatZ, QuatW;
10.Sequence Ipo: Fac;
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
31/ba/ac23698cb2a100e7c5365c0cd0a8
Event Timeline
Log In to Comment