[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32045] branches/soc-2008-mxcurioni: Added support for line styles in the Graph Editor, DopeSheet

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Wed Sep 22 00:23:10 CEST 2010


Revision: 32045
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32045
Author:   kjym3
Date:     2010-09-22 00:23:10 +0200 (Wed, 22 Sep 2010)

Log Message:
-----------
Added support for line styles in the Graph Editor, DopeSheet
and NLA Editor.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/release/scripts/ui/space_dopesheet.py
    branches/soc-2008-mxcurioni/source/blender/editors/animation/anim_channels_defines.c
    branches/soc-2008-mxcurioni/source/blender/editors/animation/anim_channels_edit.c
    branches/soc-2008-mxcurioni/source/blender/editors/animation/anim_filter.c
    branches/soc-2008-mxcurioni/source/blender/editors/animation/keyframes_draw.c
    branches/soc-2008-mxcurioni/source/blender/editors/animation/keyframes_edit.c
    branches/soc-2008-mxcurioni/source/blender/editors/include/ED_anim_api.h
    branches/soc-2008-mxcurioni/source/blender/editors/space_nla/nla_buttons.c
    branches/soc-2008-mxcurioni/source/blender/editors/space_nla/nla_channels.c
    branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_action_types.h
    branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h
    branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_action.c

Modified: branches/soc-2008-mxcurioni/release/scripts/ui/space_dopesheet.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/ui/space_dopesheet.py	2010-09-21 21:10:49 UTC (rev 32044)
+++ branches/soc-2008-mxcurioni/release/scripts/ui/space_dopesheet.py	2010-09-21 22:23:10 UTC (rev 32045)
@@ -60,6 +60,8 @@
         row.prop(dopesheet, "show_armatures", text="")
     if bpy.data.particles:
         row.prop(dopesheet, "show_particles", text="")
+    if bpy.data.linestyles:
+        row.prop(dopesheet, "show_linestyles", text="")
 
     if bpy.data.groups:
         row = layout.row(align=True)

Modified: branches/soc-2008-mxcurioni/source/blender/editors/animation/anim_channels_defines.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/editors/animation/anim_channels_defines.c	2010-09-21 21:10:49 UTC (rev 32044)
+++ branches/soc-2008-mxcurioni/source/blender/editors/animation/anim_channels_defines.c	2010-09-21 22:23:10 UTC (rev 32045)
@@ -42,6 +42,7 @@
 #include "DNA_space_types.h"
 #include "DNA_key_types.h"
 #include "DNA_lamp_types.h"
+#include "DNA_linestyle_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_material_types.h"
 #include "DNA_meta_types.h"
@@ -2157,6 +2158,82 @@
 	acf_dsntree_setting_ptr					/* pointer for setting */
 };
 
+/* LineStyle Expander  ------------------------------------------- */
+
+// TODO: just get this from RNA?
+static int acf_dslinestyle_icon(bAnimListElem *ale)
+{
+	return ICON_BRUSH_DATA; /* FIXME */
+}
+
+/* get the appropriate flag(s) for the setting when it is valid  */
+static int acf_dslinestyle_setting_flag(bAnimContext *ac, int setting, short *neg)
+{
+	/* clear extra return data first */
+	*neg= 0;
+	
+	switch (setting) {
+		case ACHANNEL_SETTING_EXPAND: /* expanded */
+			return LS_DS_EXPAND;
+			
+		case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
+			return ADT_NLA_EVAL_OFF;
+			
+		case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
+			*neg= 1;
+			return ADT_CURVES_NOT_VISIBLE;
+			
+		case ACHANNEL_SETTING_SELECT: /* selected */
+			return ADT_UI_SELECTED;
+			
+		default: /* unsupported */
+			return 0;
+	}
+}
+
+/* get pointer to the setting */
+static void *acf_dslinestyle_setting_ptr(bAnimListElem *ale, int setting, short *type)
+{
+	FreestyleLineStyle *linestyle= (FreestyleLineStyle *)ale->data;
+	
+	/* clear extra return data first */
+	*type= 0;
+	
+	switch (setting) {
+		case ACHANNEL_SETTING_EXPAND: /* expanded */
+			GET_ACF_FLAG_PTR(linestyle->flag);
+			
+		case ACHANNEL_SETTING_SELECT: /* selected */
+		case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
+		case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
+			if (linestyle->adt)
+				GET_ACF_FLAG_PTR(linestyle->adt->flag)
+			else
+				return NULL;
+			
+		default: /* unsupported */
+			return NULL;
+	}
+}
+
+/* node tree expander type define */
+static bAnimChannelType ACF_DSLINESTYLE= 
+{
+	"Line Style Expander",			/* type name */
+	
+	acf_generic_dataexpand_color,	/* backdrop color */
+	acf_generic_dataexpand_backdrop,/* backdrop */
+	acf_generic_indention_1,		/* indent level */
+	acf_generic_basic_offset,		/* offset */
+	
+	acf_generic_idblock_name,		/* name */
+	acf_dslinestyle_icon,			/* icon */
+	
+	acf_generic_dataexpand_setting_valid,	/* has setting */
+	acf_dslinestyle_setting_flag,			/* flag for setting */
+	acf_dslinestyle_setting_ptr				/* pointer for setting */
+};
+
 /* Mesh Expander  ------------------------------------------- */
 
 // TODO: just get this from RNA?
@@ -2489,6 +2566,7 @@
 		animchannelTypeInfo[type++]= &ACF_DSARM;		/* Armature Channel */
 		animchannelTypeInfo[type++]= &ACF_DSMESH;		/* Mesh Channel */
 		animchannelTypeInfo[type++]= &ACF_DSTEX;		/* Texture Channel */
+		animchannelTypeInfo[type++]= &ACF_DSLINESTYLE;	/* LineStyle Channel */
 		
 		animchannelTypeInfo[type++]= &ACF_SHAPEKEY;		/* ShapeKey */
 		

Modified: branches/soc-2008-mxcurioni/source/blender/editors/animation/anim_channels_edit.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/editors/animation/anim_channels_edit.c	2010-09-21 21:10:49 UTC (rev 32044)
+++ branches/soc-2008-mxcurioni/source/blender/editors/animation/anim_channels_edit.c	2010-09-21 22:23:10 UTC (rev 32045)
@@ -229,6 +229,7 @@
 				case ANIMTYPE_DSMESH:
 				case ANIMTYPE_DSNTREE:
 				case ANIMTYPE_DSTEX:
+				case ANIMTYPE_DSLINESTYLE:
 				{
 					if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
 						sel= ACHANNEL_SETFLAG_CLEAR;
@@ -312,6 +313,7 @@
 			case ANIMTYPE_DSMESH:
 			case ANIMTYPE_DSNTREE:
 			case ANIMTYPE_DSTEX:
+			case ANIMTYPE_DSLINESTYLE:
 			{
 				/* need to verify that this data is valid for now */
 				if (ale->adt) {
@@ -1733,6 +1735,7 @@
 		case ANIMTYPE_DSMESH:
 		case ANIMTYPE_DSNTREE:
 		case ANIMTYPE_DSTEX:
+		case ANIMTYPE_DSLINESTYLE:
 		{
 			/* sanity checking... */
 			if (ale->adt) {

Modified: branches/soc-2008-mxcurioni/source/blender/editors/animation/anim_filter.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/editors/animation/anim_filter.c	2010-09-21 21:10:49 UTC (rev 32044)
+++ branches/soc-2008-mxcurioni/source/blender/editors/animation/anim_filter.c	2010-09-21 22:23:10 UTC (rev 32045)
@@ -52,6 +52,7 @@
 #include "DNA_camera_types.h"
 #include "DNA_lamp_types.h"
 #include "DNA_lattice_types.h"
+#include "DNA_linestyle_types.h"
 #include "DNA_key_types.h"
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
@@ -681,6 +682,19 @@
 				ale->adt= BKE_animdata_from_id(data);
 			}
 				break;
+			case ANIMTYPE_DSLINESTYLE:
+			{
+				FreestyleLineStyle *linestyle= (FreestyleLineStyle *)data;
+				AnimData *adt= linestyle->adt;
+				
+				ale->flag= FILTER_LS_SCED(linestyle); 
+				
+				ale->key_data= (adt) ? adt->action : NULL;
+				ale->datatype= ALE_ACT;
+				
+				ale->adt= BKE_animdata_from_id(data);
+			}
+				break;
 			case ANIMTYPE_DSPART:
 			{
 				ParticleSettings *part= (ParticleSettings*)ale->data;
@@ -2010,7 +2024,99 @@
 		)
 	}
 
-	
+	/* line styles */
+	if (!(ads->filterflag & ADS_FILTER_NOLINESTYLE)) {
+		ListBase linestyles = {NULL, NULL};
+		LinkData *link;
+		SceneRenderLayer *srl;
+		FreestyleLineSet *lineset;
+		FreestyleLineStyle *linestyle;
+
+		for (srl = (SceneRenderLayer *)sce->r.layers.first; srl; srl = srl->next) {
+			if (!(srl->layflag & SCE_LAY_FRS))
+				continue;
+			for (lineset = (FreestyleLineSet *)srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
+				short ok = 0;
+
+				linestyle = lineset->linestyle;
+				if (!linestyle->adt)
+					continue;
+
+				ANIMDATA_FILTER_CASES(linestyle, 
+					{ /* AnimData blocks - do nothing... */ },
+					ok=1;, 
+					ok=1;, 
+					ok=1;)
+				if (ok == 0) continue;
+
+				/* check if the same linestyle is already in the list */
+				for (link = (LinkData *)linestyles.first; link; link = link->next) {
+					if (link->data == linestyle) {
+						ok = 0;
+						break;
+					}
+				}
+				if (ok == 0) continue;
+
+				/* add this linestyle to the list */
+				link= MEM_callocN(sizeof(LinkData), "DopeSheet LineStyle cache");
+				link->data= linestyle;
+				BLI_addtail(&linestyles, link);
+			}
+		}
+
+		if (linestyles.first) {
+
+			for (link = (LinkData *)linestyles.first; link; link = link->next) {
+				linestyle = (FreestyleLineStyle *)link->data;
+
+				/* Action, Drivers, or NLA for line styles */
+				adt= linestyle->adt;
+				ANIMDATA_FILTER_CASES(linestyle,
+					{ /* AnimData blocks - do nothing... */ },
+					{ /* nla */
+						/* add NLA tracks */
+						items += animdata_filter_nla(ac, anim_data, ads, adt, filter_mode, linestyle, ANIMTYPE_DSLINESTYLE, (ID *)linestyle);
+					},
+					{ /* drivers */
+						/* include linestyle-expand widget? */
+						if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
+							ale= make_new_animlistelem(linestyle, ANIMTYPE_DSLINESTYLE, sce, ANIMTYPE_SCENE, (ID *)linestyle);
+							if (ale) {
+								BLI_addtail(anim_data, ale);
+								items++;
+							}
+						}
+						
+						/* add F-Curve channels (drivers are F-Curves) */
+						if (FILTER_LS_SCED(linestyle)/*EXPANDED_DRVD(adt)*/ || !(filter_mode & ANIMFILTER_CHANNELS)) {
+							// XXX owner info is messed up now...
+							items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, linestyle, ANIMTYPE_DSLINESTYLE, filter_mode, (ID *)linestyle);
+						}
+					},
+					{ /* action */
+						/* include nodetree-expand widget? */
+						if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
+							ale= make_new_animlistelem(linestyle, ANIMTYPE_DSLINESTYLE, sce, ANIMTYPE_SCENE, (ID *)sce);
+							if (ale) {
+								BLI_addtail(anim_data, ale);
+								items++;
+							}
+						}
+						
+						/* add channels */
+						if (FILTER_LS_SCED(linestyle) || (filter_mode & ANIMFILTER_CURVESONLY)) {
+							items += animdata_filter_action(ac, anim_data, ads, adt->action, filter_mode, linestyle, ANIMTYPE_DSLINESTYLE, (ID *)linestyle); 
+						}
+					}
+				)
+			}
+
+			/* free cache */
+			BLI_freelistN(&linestyles);
+		}
+	}
+
 	// TODO: scene compositing nodes (these aren't standard node-trees)
 	
 	/* return the number of items added to the list */
@@ -2044,7 +2150,7 @@
 	/* scene-linked animation */
 	// TODO: sequencer, composite nodes - are we to include those here too?
 	{
-		short sceOk= 0, worOk= 0, nodeOk=0;
+		short sceOk= 0, worOk= 0, nodeOk=0, lsOk = 0;
 		
 		/* check filtering-flags if ok */
 		ANIMDATA_FILTER_CASES(sce, 
@@ -2084,17 +2190,41 @@
 				nodeOk= !(ads->filterflag & ADS_FILTER_NONTREE);, 
 				nodeOk= !(ads->filterflag & ADS_FILTER_NONTREE);)
 		}
+
+		/* line styles */
+		{
+			SceneRenderLayer *srl;
+			FreestyleLineSet *lineset;
+
+			for (srl = (SceneRenderLayer *)sce->r.layers.first; srl; srl = srl->next) {
+				if (srl->layflag & SCE_LAY_FRS) {
+					for (lineset = (FreestyleLineSet *)srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
+						ANIMDATA_FILTER_CASES(lineset->linestyle, 
+							{
+								/* for the special AnimData blocks only case, we only need to add
+								 * the block if it is valid... then other cases just get skipped (hence ok=0)
+								 */
+								ANIMDATA_ADD_ANIMDATA(lineset->linestyle);
+								lsOk=0;
+							},

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list