[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12065] trunk/blender/source/blender: == Action Editor - Copy and Paste Tools ==

Joshua Leung aligorith at gmail.com
Mon Sep 17 13:41:13 CEST 2007


Revision: 12065
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12065
Author:   aligorith
Date:     2007-09-17 13:41:12 +0200 (Mon, 17 Sep 2007)

Log Message:
-----------
== Action Editor - Copy and Paste Tools ==

Now it is possible to do Copy+Paste in the Action Editor, like in the IPO Editor. There are two new buttons in the Action Editor header for this, using the familiar icons.

* To copy...
Select the keyframes you wish to copy, and the channels that they occur in (except for ShapeKey mode, where it is not possible to select channels). Click copy button.
* To paste... 
Place the current frame where you want the first of the keyframes from the buffer is to be pasted. Select all channels you wish the keyframes to be pasted into. Click paste button. 

Currently, keyframes are only pasted into 'compatible' curves (i.e.  LocX keyframes can only go to LocX, and so on). This may change after user feedback, if this is found to be too restrictive.

== Code Changes ==
I've made a few changes which allow this code to be nicer. 
* renamed insert_vert_ipo to insert_vert_icu, as that represents its actual purpose better (and changed all occurrences I could find)
* created a new function, insert_bezt_icu, which does the actual inserting of provided BezTriple data to a given IpoCurve 
* recoded insert_vert_icu to use this new function, and also the IPO-Editor keyframe pasting (i.e.  pasting in Editmode) 

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/bad_level_call_stubs/stubs.c
    trunk/blender/source/blender/blenkernel/intern/action.c
    trunk/blender/source/blender/include/BIF_editaction.h
    trunk/blender/source/blender/include/BSE_editipo.h
    trunk/blender/source/blender/include/blendef.h
    trunk/blender/source/blender/python/api2_2x/Constraint.c
    trunk/blender/source/blender/python/api2_2x/Ipo.c
    trunk/blender/source/blender/python/api2_2x/Ipocurve.c
    trunk/blender/source/blender/python/api2_2x/Object.c
    trunk/blender/source/blender/src/buttons_object.c
    trunk/blender/source/blender/src/drawaction.c
    trunk/blender/source/blender/src/editaction.c
    trunk/blender/source/blender/src/editipo.c
    trunk/blender/source/blender/src/editkey.c
    trunk/blender/source/blender/src/header_action.c
    trunk/blender/source/blender/src/usiblender.c

Modified: trunk/blender/source/blender/blenkernel/bad_level_call_stubs/stubs.c
===================================================================
--- trunk/blender/source/blender/blenkernel/bad_level_call_stubs/stubs.c	2007-09-17 11:30:45 UTC (rev 12064)
+++ trunk/blender/source/blender/blenkernel/bad_level_call_stubs/stubs.c	2007-09-17 11:41:12 UTC (rev 12065)
@@ -59,7 +59,7 @@
 struct bConstraintOb;
 
 char *getIpoCurveName( struct IpoCurve * icu );
-void insert_vert_ipo(struct IpoCurve *icu, float x, float y);
+void insert_vert_icu(struct IpoCurve *icu, float x, float y);
 struct IpoCurve *verify_ipocurve(struct ID *id, short a, char *b, char *d, int e);
 void elbeemDebugOut(char *msg);
 void fluidsimSettingsFree(struct FluidsimSettings* sb);
@@ -83,7 +83,7 @@
 	return 0;
 }
 
-void insert_vert_ipo(struct IpoCurve *icu, float x, float y)
+void insert_vert_icu(struct IpoCurve *icu, float x, float y)
 {
 }
 

Modified: trunk/blender/source/blender/blenkernel/intern/action.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/action.c	2007-09-17 11:30:45 UTC (rev 12064)
+++ trunk/blender/source/blender/blenkernel/intern/action.c	2007-09-17 11:41:12 UTC (rev 12065)
@@ -112,7 +112,6 @@
 			}
 		}
 	}
-					
 }
 
 void make_local_action(bAction *act)
@@ -165,27 +164,27 @@
 }
 
 
-void free_action(bAction *act)
+void free_action (bAction *act)
 {
 	bActionChannel *chan;
 	
 	/* Free channels */
-	for (chan=act->chanbase.first; chan; chan=chan->next){
+	for (chan=act->chanbase.first; chan; chan=chan->next) {
 		if (chan->ipo)
 			chan->ipo->id.us--;
 		free_constraint_channels(&chan->constraintChannels);
 	}
 	
 	if (act->chanbase.first)
-		BLI_freelistN (&act->chanbase);
+		BLI_freelistN(&act->chanbase);
 }
 
-bAction* copy_action(bAction *src)
+bAction *copy_action (bAction *src)
 {
 	bAction *dst = NULL;
 	bActionChannel *dchan, *schan;
 	
-	if(!src) return NULL;
+	if (!src) return NULL;
 	
 	dst= copy_libblock(src);
 	duplicatelist(&(dst->chanbase), &(src->chanbase));

Modified: trunk/blender/source/blender/include/BIF_editaction.h
===================================================================
--- trunk/blender/source/blender/include/BIF_editaction.h	2007-09-17 11:30:45 UTC (rev 12064)
+++ trunk/blender/source/blender/include/BIF_editaction.h	2007-09-17 11:41:12 UTC (rev 12065)
@@ -79,7 +79,6 @@
 	SET_IPO_BEZIER,
 };
 
-
 /* constants for setting ipo-extrapolation type */
 enum {
 	
@@ -92,6 +91,7 @@
 	SET_EXTEND_CYCLICEXTRAPOLATION
 };
 
+
 struct bAction;
 struct bActionChannel;
 struct bPoseChannel;
@@ -116,6 +116,11 @@
 void selectall_action_keys(short mval[], short mode, short selectmode);
 void markers_selectkeys_between(void);
 
+/* Action Data Copying */
+void free_actcopybuf(void);
+void copy_actdata(void);
+void paste_actdata(void);
+
 /* channel/strip operations */
 void up_sel_action(void);
 void down_sel_action(void);
@@ -132,11 +137,12 @@
 void deselect_action_channels(short test);
 void deselect_actionchannels(struct bAction *act, short test);
 int select_channel(struct bAction *act, struct bActionChannel *achan, int selectmode);
-void select_actionchannel_by_name (struct bAction *act, char *name, int select);
+void select_actionchannel_by_name(struct bAction *act, char *name, int select);
 
 /* ShapeKey stuff */
 struct Key *get_action_mesh_key(void);
 int get_nearest_key_num(struct Key *key, short *mval, float *x);
+
 void *get_nearest_act_channel(short mval[], short *ret_type);
 
 /* Action */

Modified: trunk/blender/source/blender/include/BSE_editipo.h
===================================================================
--- trunk/blender/source/blender/include/BSE_editipo.h	2007-09-17 11:30:45 UTC (rev 12064)
+++ trunk/blender/source/blender/include/BSE_editipo.h	2007-09-17 11:41:12 UTC (rev 12065)
@@ -91,8 +91,10 @@
 struct Ipo *verify_ipo(struct ID *, short, char *, char *);
 int texchannel_to_adrcode(int channel);
 
-void insert_vert_ipo(struct IpoCurve *icu, float x, float y);
+int insert_bezt_icu(struct IpoCurve *icu, struct BezTriple *bezt);
+void insert_vert_icu(struct IpoCurve *icu, float x, float y);
 void add_vert_ipo(void);
+
 void add_duplicate_editipo(void);
 void remove_doubles_ipo(void);
 void clean_ipo(void);

Modified: trunk/blender/source/blender/include/blendef.h
===================================================================
--- trunk/blender/source/blender/include/blendef.h	2007-09-17 11:30:45 UTC (rev 12064)
+++ trunk/blender/source/blender/include/blendef.h	2007-09-17 11:41:12 UTC (rev 12065)
@@ -390,6 +390,8 @@
 #define B_ACTMAIN		707
 #define	B_ACTPIN		708
 #define B_ACTBAKE		709
+#define B_ACTCOPYKEYS		710
+#define B_ACTPASTEKEYS		711
 
 /* TIME: 751 - 800 */
 #define B_TL_REW		751

Modified: trunk/blender/source/blender/python/api2_2x/Constraint.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Constraint.c	2007-09-17 11:30:45 UTC (rev 12064)
+++ trunk/blender/source/blender/python/api2_2x/Constraint.c	2007-09-17 11:41:12 UTC (rev 12065)
@@ -431,9 +431,9 @@
 				"cannot get a curve from this IPO, may be using libdata" );
 	
 	if( ob->action )
-		insert_vert_ipo( icu, get_action_frame(ob, cfra), con->enforce);
+		insert_vert_icu( icu, get_action_frame(ob, cfra), con->enforce);
 	else
-		insert_vert_ipo( icu, cfra, con->enforce);
+		insert_vert_icu( icu, cfra, con->enforce);
 
 	Py_RETURN_NONE;
 }

Modified: trunk/blender/source/blender/python/api2_2x/Ipo.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Ipo.c	2007-09-17 11:30:45 UTC (rev 12064)
+++ trunk/blender/source/blender/python/api2_2x/Ipo.c	2007-09-17 11:41:12 UTC (rev 12065)
@@ -1483,7 +1483,7 @@
 		icu->flag |= IPO_VISIBLE|IPO_AUTO_HORIZ;
 		set_icu_vars( icu );
 		BLI_addtail( &(ipo->curve), icu);
-		insert_vert_ipo( icu, time, curval );
+		insert_vert_icu( icu, time, curval );
 
 		allspace( REMAKEIPO, 0 );
 		EXPP_allqueue( REDRAWIPO, 0 );

Modified: trunk/blender/source/blender/python/api2_2x/Ipocurve.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Ipocurve.c	2007-09-17 11:30:45 UTC (rev 12064)
+++ trunk/blender/source/blender/python/api2_2x/Ipocurve.c	2007-09-17 11:41:12 UTC (rev 12065)
@@ -531,7 +531,7 @@
 		Py_DECREF( xobj );
 		y = (float)PyFloat_AsDouble( yobj );
 		Py_DECREF( yobj );
-		insert_vert_ipo( icu, x, y);
+		insert_vert_icu( icu, x, y);
 	}
 
 	Py_RETURN_NONE;
@@ -745,7 +745,7 @@
 
 	/* insert a key at the specified time */
 
-	insert_vert_ipo( self->ipocurve, time, curval );
+	insert_vert_icu( self->ipocurve, time, curval );
 	allspace(REMAKEIPO, 0);
 	return 0;
 }

Modified: trunk/blender/source/blender/python/api2_2x/Object.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Object.c	2007-09-17 11:30:45 UTC (rev 12064)
+++ trunk/blender/source/blender/python/api2_2x/Object.c	2007-09-17 11:41:12 UTC (rev 12065)
@@ -2517,7 +2517,7 @@
 		return EXPP_ReturnPyObjError( PyExc_RuntimeError,
 				"cannot get a curve from this IPO, may be using libdata" );		
 	
-	insert_vert_ipo(icu, (float)CFRA, influence);
+	insert_vert_icu(icu, (float)CFRA, influence);
 	self->object->recalc |= OB_RECALC_OB;  
 
 	Py_RETURN_NONE;

Modified: trunk/blender/source/blender/src/buttons_object.c
===================================================================
--- trunk/blender/source/blender/src/buttons_object.c	2007-09-17 11:30:45 UTC (rev 12064)
+++ trunk/blender/source/blender/src/buttons_object.c	2007-09-17 11:41:12 UTC (rev 12065)
@@ -263,9 +263,9 @@
 	}
 	
 	if(ob->action)
-		insert_vert_ipo(icu, get_action_frame(ob, (float)CFRA), con->enforce);
+		insert_vert_icu(icu, get_action_frame(ob, (float)CFRA), con->enforce);
 	else
-		insert_vert_ipo(icu, CFRA, con->enforce);
+		insert_vert_icu(icu, CFRA, con->enforce);
 	
 	/* make sure ipowin shows it */
 	ob->ipowin= ID_CO;

Modified: trunk/blender/source/blender/src/drawaction.c
===================================================================
--- trunk/blender/source/blender/src/drawaction.c	2007-09-17 11:30:45 UTC (rev 12064)
+++ trunk/blender/source/blender/src/drawaction.c	2007-09-17 11:41:12 UTC (rev 12065)
@@ -198,7 +198,7 @@
 	 * otherwise modify it's value
 	 */
 	if (!bezt) {
-		insert_vert_ipo(icu, cfra, icu->curval);
+		insert_vert_icu(icu, cfra, icu->curval);
 	}
 	else {
 		bezt->vec[1][1] = icu->curval;

Modified: trunk/blender/source/blender/src/editaction.c
===================================================================
--- trunk/blender/source/blender/src/editaction.c	2007-09-17 11:30:45 UTC (rev 12064)
+++ trunk/blender/source/blender/src/editaction.c	2007-09-17 11:41:12 UTC (rev 12065)
@@ -1335,7 +1335,7 @@
 				if (ob)
 					insertkey((ID *)ob, icu->blocktype, achan->name, NULL, icu->adrcode);
 				else
-					insert_vert_ipo(icu, cfra, icu->curval);
+					insert_vert_icu(icu, cfra, icu->curval);
 			}
 		}
 		
@@ -1352,7 +1352,7 @@
 		
 		if (key->ipo) {
 			for (icu= key->ipo->curve.first; icu; icu=icu->next) {
-				insert_vert_ipo(icu, cfra, icu->curval);
+				insert_vert_icu(icu, cfra, icu->curval);
 			}
 		}
 	}
@@ -1495,9 +1495,172 @@
 }
 
 /* **************************************************** */
+/* COPY/PASTE FOR ACTIONS */
+/* - The copy/paste buffer currently stores a set of IPO curves, with no
+ *   repeating curve-types (i.e.  no curves with the same adrcode). 
+ * - Only selected keyframes from the source curves are placed here. 
+ * - Only 'compatible' pastes are done.
+ */
+
+/* globals for copy/paste data (like for other copy/paste buffers) */
+ListBase actcopybuf = {NULL, NULL};
+
+/* This function frees any MEM_calloc'ed copy/paste buffer data */
+void free_actcopybuf ()
+{
+	IpoCurve *icu;
+	
+	while( (icu= actcopybuf.first) ) {
+		BLI_remlink(&actcopybuf, icu);
+		free_ipo_curve(icu);
+	}
+}
+
+/* This function adds data to the copy/paste buffer, freeing existing data first
+ * Only the active action channel gets its selected keyframes copied.
+ */
+void copy_actdata ()
+{
+	ListBase act_data = {NULL, NULL};
+	bActListElem *ale;
+	int filter;
+	void *data;
+	short datatype;
+	
+	/* clear buffer first */
+	free_actcopybuf();
+	
+	/* get data */
+	data= get_action_context(&datatype);
+	if (data == NULL) return;
+	
+	/* filter data */
+	filter= (ACTFILTER_VISIBLE | ACTFILTER_SEL | ACTFILTER_ONLYICU);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list