[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18831] trunk/blender/source/blender/ python/api2_2x/sceneSequence.c: 2.4x Sequencer Python API

Campbell Barton ideasman42 at gmail.com
Fri Feb 6 15:03:29 CET 2009


Revision: 18831
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18831
Author:   campbellbarton
Date:     2009-02-06 15:03:29 +0100 (Fri, 06 Feb 2009)

Log Message:
-----------
2.4x Sequencer Python API
- add metastrips now possible
- access to speed options
- access to wipe options
- added seq.startDisp seq.endDisp seq.update()

Modified Paths:
--------------
    trunk/blender/source/blender/python/api2_2x/sceneSequence.c

Modified: trunk/blender/source/blender/python/api2_2x/sceneSequence.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/sceneSequence.c	2009-02-06 13:07:02 UTC (rev 18830)
+++ trunk/blender/source/blender/python/api2_2x/sceneSequence.c	2009-02-06 14:03:29 UTC (rev 18831)
@@ -54,7 +54,8 @@
 #include "IMB_imbuf_types.h" // RFS: IB_rect
 #include "IMB_imbuf.h" // RFS: IMB_anim_get_duration
 
-enum seq_consts {
+enum seq_consts
+{
 	EXPP_SEQ_ATTR_TYPE = 0,
 	EXPP_SEQ_ATTR_CHAN,
 	EXPP_SEQ_ATTR_LENGTH,
@@ -62,10 +63,26 @@
 	EXPP_SEQ_ATTR_STARTOFS,
 	EXPP_SEQ_ATTR_ENDOFS,
 	EXPP_SEQ_ATTR_STARTSTILL,
-	EXPP_SEQ_ATTR_ENDSTILL
+	EXPP_SEQ_ATTR_ENDSTILL,
+	EXPP_SEQ_ATTR_STARTDISP,
+	EXPP_SEQ_ATTR_ENDDISP
 };
 
+enum seq_effect_consts
+{
+		/* speed  */
+	EXPP_SEQ_ATTR_EFFECT_GLOBAL_SPEED,
+	EXPP_SEQ_ATTR_EFFECT_IPO_IS_VELOCITY,
+	EXPP_SEQ_ATTR_EFFECT_FRAME_BLENDING,
+	EXPP_SEQ_ATTR_EFFECT_NORMALIZE_IPO_0_1,
 
+		/* wipe */
+	EXPP_SEQ_ATTR_EFFECT_ANGLE,
+	EXPP_SEQ_ATTR_EFFECT_BLUR,
+	EXPP_SEQ_ATTR_EFFECT_WIPE_IN
+};
+
+
 /*****************************************************************************/
 /* Python API function prototypes for the Blender module.		 */
 /*****************************************************************************/
@@ -84,141 +101,200 @@
 /*****************************************************************************/
 /* Python BPy_Sequence methods table:					   */
 /*****************************************************************************/
-static PyObject *Sequence_copy( BPy_Sequence * self );
-static PyObject *Sequence_new( BPy_Sequence * self, PyObject * args );
-static PyObject *Sequence_remove( BPy_Sequence * self, PyObject * args );
-static PyObject *Sequence_rebuildProxy( BPy_Sequence * self );
+static PyObject *Sequence_copy(BPy_Sequence * self);
+static PyObject *Sequence_update(BPy_Sequence * self);
+static PyObject *Sequence_new(BPy_Sequence * self, PyObject * args);
+static PyObject *Sequence_remove(BPy_Sequence * self, PyObject * args);
+static PyObject *Sequence_rebuildProxy(BPy_Sequence * self);
 
-static PyObject *SceneSeq_new( BPy_SceneSeq * self, PyObject * args );
-static PyObject *SceneSeq_remove( BPy_SceneSeq * self, PyObject * args );
-static void intern_pos_update(Sequence * seq); 
+static PyObject *SceneSeq_new(BPy_SceneSeq * self, PyObject * args);
+static PyObject *SceneSeq_remove(BPy_SceneSeq * self, PyObject * args);
+static void intern_pos_update(Sequence * seq);
 
 static PyMethodDef BPy_Sequence_methods[] = {
 	/* name, method, flags, doc */
-	{"new", ( PyCFunction ) Sequence_new, METH_VARARGS,
-	 "(data) - Return a new sequence."},
-	{"remove", ( PyCFunction ) Sequence_remove, METH_VARARGS,
-	 "(data) - Remove a strip."},
-	{"__copy__", ( PyCFunction ) Sequence_copy, METH_NOARGS,
-	 "() - Return a copy of the sequence containing the same objects."},
-	{"copy", ( PyCFunction ) Sequence_copy, METH_NOARGS,
-	 "() - Return a copy of the sequence containing the same objects."},
-	{"rebuildProxy", ( PyCFunction ) Sequence_rebuildProxy, METH_VARARGS,
-	 "() - Rebuild the active strip's Proxy."},
+	{"new", (PyCFunction) Sequence_new, METH_VARARGS,
+		"(data) - Return a new sequence."},
+	{"remove", (PyCFunction) Sequence_remove, METH_VARARGS,
+		"(data) - Remove a strip."},
+	{"__copy__", (PyCFunction) Sequence_copy, METH_NOARGS,
+		"() - Return a copy of the sequence containing the same objects."},
+	{"copy", (PyCFunction) Sequence_copy, METH_NOARGS,
+		"() - Return a copy of the sequence containing the same objects."},
+	{"update", (PyCFunction) Sequence_update, METH_NOARGS,
+		"() - Force and update of the sequence strip"},
+	{"rebuildProxy", (PyCFunction) Sequence_rebuildProxy, METH_VARARGS,
+		"() - Rebuild the active strip's Proxy."},
 	{NULL, NULL, 0, NULL}
 };
 
 static PyMethodDef BPy_SceneSeq_methods[] = {
 	/* name, method, flags, doc */
-	{"new", ( PyCFunction ) SceneSeq_new, METH_VARARGS,
-	 "(data) - Return a new sequence."},
-	{"remove", ( PyCFunction ) SceneSeq_remove, METH_VARARGS,
-	 "(data) - Remove a strip."},
+	{"new", (PyCFunction) SceneSeq_new, METH_VARARGS,
+		"(data) - Return a new sequence."},
+	{"remove", (PyCFunction) SceneSeq_remove, METH_VARARGS,
+		"(data) - Remove a strip."},
 	{NULL, NULL, 0, NULL}
 };
 
-
 /* use to add a sequence to a scene or its listbase */
 static PyObject *NewSeq_internal(ListBase *seqbase, PyObject * args, Scene *sce)
 {
 	PyObject *py_data = NULL;
-	
+
 	Sequence *seq;
-	PyObject *pyob1= NULL, *pyob2= NULL, *pyob3= NULL; /* for effects */
+	PyObject *pyob1 = NULL, *pyob2 = NULL, *pyob3 = NULL; /* for effects */
 	int type;
 
 	int a;
 	Strip *strip;
 	StripElem *se;
 	int start, machine;
-	
-	if( !PyArg_ParseTuple( args, "Oii", &py_data, &start, &machine ) )
-		return EXPP_ReturnPyObjError( PyExc_ValueError,
-			"expect sequence data then 2 ints - (seqdata, start, track)" );
 
-	if (machine < 1 || machine >= MAXSEQ) {
-		return EXPP_ReturnPyObjError( PyExc_ValueError,
-			"track out of range" );
+	if (!PyArg_ParseTuple(args, "Oii", &py_data, &start, &machine))
+		return EXPP_ReturnPyObjError(PyExc_ValueError,
+									"expect sequence data then 2 ints - (seqdata, start, track)");
+
+	if (machine < 1 || machine >= MAXSEQ)
+	{
+		return EXPP_ReturnPyObjError(PyExc_ValueError,
+									"track out of range");
 	}
 
 	seq = alloc_sequence(seqbase, start, machine); /* warning, this sets last */
 
 
-	if (PyTuple_Check(py_data) && PyTuple_GET_SIZE(py_data) >= 2 && BPy_Sequence_Check(PyTuple_GET_ITEM(py_data, 1))) {
-	
+	if (PyList_Check(py_data)) /* new metastrip, list of seqs */
+	{
+		/* Warning, no checks for audio which should not be allowed, or a blank metaseq if an empty list */
+		int fail= 0;
+		Sequence *seq_iter;
+		PyObject *item;
+		seq->type= SEQ_META;
+
+
+		for(a=PyList_GET_SIZE(py_data)-1; a >= 0; a--) {
+			item= PyList_GET_ITEM(py_data, a);
+			if (!BPy_Sequence_Check(item)) { /* ignore non seq types */
+				fail= 1;
+				break;
+			}
+
+			seq_iter = ((BPy_Sequence *) item)->seq;
+			if (BLI_findindex(seqbase, seq_iter) == -1) {
+				fail= 2;
+				break;
+			}
+		}
+
+		if (fail) {
+			BLI_remlink(seqbase, seq);
+			free_sequence(seq);
+
+			if (fail==1)
+				return EXPP_ReturnPyObjError(PyExc_ValueError, "One of more of the list items was not a sequence strip");
+			else
+				return EXPP_ReturnPyObjError(PyExc_ValueError, "One of more of the list items sequence strips is not in this meta or scene");
+		}
+
+
+		for(a=PyList_GET_SIZE(py_data)-1; a >= 0; a--) {
+			item= PyList_GET_ITEM(py_data, a);
+			seq_iter = ((BPy_Sequence *) item)->seq;
+			BLI_remlink(seqbase, seq_iter);
+			BLI_addtail(&seq->seqbase, seq_iter);
+		}
+
+		clear_last_seq(); /* just incase */
+		calc_sequence(seq);
+
+		seq->strip= MEM_callocN(sizeof(Strip), "metastrip");
+		seq->strip->len= seq->len;
+		seq->strip->us= 1;
+	}
+	else if (PyTuple_Check(py_data) && PyTuple_GET_SIZE(py_data) >= 2 && BPy_Sequence_Check(PyTuple_GET_ITEM(py_data, 1)))
+	{
+
 		struct SeqEffectHandle sh;
-		Sequence *seq1, *seq2= NULL, *seq3= NULL; /* for effects */
+		Sequence *seq1, *seq2 = NULL, *seq3 = NULL; /* for effects */
 
-		if (!PyArg_ParseTuple( py_data, "iO!|O!O!", &type, &Sequence_Type, &pyob1, &Sequence_Type, &pyob2, &Sequence_Type, &pyob3)) {
+		if (!PyArg_ParseTuple(py_data, "iO!|O!O!", &type, &Sequence_Type, &pyob1, &Sequence_Type, &pyob2, &Sequence_Type, &pyob3))
+		{
 			BLI_remlink(seqbase, seq);
 			free_sequence(seq);
-			
-			return EXPP_ReturnPyObjError( PyExc_ValueError,
-				"effect stripts expected an effect type int and 1 to 3 sequence strips");
+
+			return EXPP_ReturnPyObjError(PyExc_ValueError,
+										"effect stripts expected an effect type int and 1 to 3 sequence strips");
 		}
 
 
-		seq1= ((BPy_Sequence *)pyob1)->seq;
-		if(pyob2) seq2= ((BPy_Sequence *)pyob2)->seq;
-		if(pyob3) seq3= ((BPy_Sequence *)pyob3)->seq;
+		seq1 = ((BPy_Sequence *) pyob1)->seq;
+		if (pyob2) seq2 = ((BPy_Sequence *) pyob2)->seq;
+		if (pyob3) seq3 = ((BPy_Sequence *) pyob3)->seq;
 
-		if (type <= SEQ_EFFECT || type > SEQ_EFFECT_MAX || type==SEQ_PLUGIN){
+		if (type <= SEQ_EFFECT || type > SEQ_EFFECT_MAX || type == SEQ_PLUGIN)
+		{
 			BLI_remlink(seqbase, seq);
 			free_sequence(seq);
-			
-			return EXPP_ReturnPyObjError( PyExc_ValueError,
-				"sequencer type out of range, expected a value from 9 to 29, plugins not supported");
+
+			return EXPP_ReturnPyObjError(PyExc_ValueError,
+										"sequencer type out of range, expected a value from 9 to 29, plugins not supported");
 		}
-	
 
-		if (BLI_findindex(seqbase, seq1)==-1 || (seq2 && BLI_findindex(seqbase, seq2)==-1) || (seq3 && BLI_findindex(seqbase, seq3)==-1)) {
+
+		if (BLI_findindex(seqbase, seq1) == -1 || (seq2 && BLI_findindex(seqbase, seq2) == -1) || (seq3 && BLI_findindex(seqbase, seq3) == -1))
+		{
 			BLI_remlink(seqbase, seq);
 			free_sequence(seq);
-			
-			return EXPP_ReturnPyObjError( PyExc_ValueError,
-				"one of the given effect sequences wasnt in accessible at the same level as the sequence being added");
+
+			return EXPP_ReturnPyObjError(PyExc_ValueError,
+										"one of the given effect sequences wasnt in accessible at the same level as the sequence being added");
 		}
 
-		if ((seq2 && seq2==seq1) || (seq3 && (seq3==seq1 || seq3==seq2))) {
+		if ((seq2 && seq2 == seq1) || (seq3 && (seq3 == seq1 || seq3 == seq2)))
+		{
 			BLI_remlink(seqbase, seq);
 			free_sequence(seq);
-			
-			return EXPP_ReturnPyObjError( PyExc_ValueError,
-				"2 or more of the sequence arguments were the same");
 
+			return EXPP_ReturnPyObjError(PyExc_ValueError,
+										"2 or more of the sequence arguments were the same");
+
 		}
 
 		/* allocate and initialize */
-		seq->type= type;
+		seq->type = type;
 
 		sh = get_sequence_effect(seq);
 
-		seq->seq1= seq1;
-		seq->seq2= seq2;
-		seq->seq3= seq3;
+		seq->seq1 = seq1;
+		seq->seq2 = seq2;
+		seq->seq3 = seq3;
 
 		sh.init(seq);
 
-		if (!seq1) {
-			seq->len= 1;
-			seq->startstill= 25;
-			seq->endstill= 24;
+		if (!seq1)
+		{
+			seq->len = 1;
+			seq->startstill = 25;
+			seq->endstill = 24;
 		}
 
 		calc_sequence(seq);
 
-		seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
-		strip->len= seq->len;
-		strip->us= 1;
-		if(seq->len>0)
-			strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
+		seq->strip = strip = MEM_callocN(sizeof (Strip), "strip");
+		strip->len = seq->len;
+		strip->us = 1;
+		if (seq->len > 0)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list