[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34264] trunk/blender/source/blender/ editors/armature: Added operator to show all armature layers ( similar to the 3D View

Joshua Leung aligorith at gmail.com
Tue Jan 11 22:12:49 CET 2011


Revision: 34264
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34264
Author:   aligorith
Date:     2011-01-11 21:12:48 +0000 (Tue, 11 Jan 2011)
Log Message:
-----------
Added operator to show all armature layers (similar to the 3D View
"Show All Layers"). This has been mapped to Ctrl-Accentkey

If necessary, you can alter your keymaps so that this operator is
invoked with its "all" property disabled. This will only toggle the
first row (first 16) layers, which is useful in most rigs for only
enabling all the layers with rig controls and not showing the layers
with rig mechanics.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/armature/armature_intern.h
    trunk/blender/source/blender/editors/armature/armature_ops.c
    trunk/blender/source/blender/editors/armature/poseobject.c

Modified: trunk/blender/source/blender/editors/armature/armature_intern.h
===================================================================
--- trunk/blender/source/blender/editors/armature/armature_intern.h	2011-01-11 18:40:44 UTC (rev 34263)
+++ trunk/blender/source/blender/editors/armature/armature_intern.h	2011-01-11 21:12:48 UTC (rev 34264)
@@ -76,6 +76,7 @@
 
 void ARMATURE_OT_flags_set(struct wmOperatorType *ot);
 
+void ARMATURE_OT_layers_show_all(struct wmOperatorType *ot);
 void ARMATURE_OT_armature_layers(struct wmOperatorType *ot);
 void ARMATURE_OT_bone_layers(struct wmOperatorType *ot);
 

Modified: trunk/blender/source/blender/editors/armature/armature_ops.c
===================================================================
--- trunk/blender/source/blender/editors/armature/armature_ops.c	2011-01-11 18:40:44 UTC (rev 34263)
+++ trunk/blender/source/blender/editors/armature/armature_ops.c	2011-01-11 21:12:48 UTC (rev 34264)
@@ -82,6 +82,7 @@
 	
 	WM_operatortype_append(ARMATURE_OT_flags_set);
 	
+	WM_operatortype_append(ARMATURE_OT_layers_show_all);
 	WM_operatortype_append(ARMATURE_OT_armature_layers);
 	WM_operatortype_append(ARMATURE_OT_bone_layers);
 
@@ -253,6 +254,7 @@
 		RNA_enum_set(kmi->ptr, "mode", 0); // clear
 		
 		/* armature/bone layers */
+	WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0);
 	WM_keymap_add_item(keymap, "ARMATURE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0);
 	WM_keymap_add_item(keymap, "ARMATURE_OT_bone_layers", MKEY, KM_PRESS, 0, 0);
 	
@@ -332,6 +334,7 @@
 		RNA_enum_set(kmi->ptr, "mode", 0); // clear
 		
 		/* armature/bone layers */
+	WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0);
 	WM_keymap_add_item(keymap, "POSE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0);
 	WM_keymap_add_item(keymap, "POSE_OT_bone_layers", MKEY, KM_PRESS, 0, 0);
 	

Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c	2011-01-11 18:40:44 UTC (rev 34263)
+++ trunk/blender/source/blender/editors/armature/poseobject.c	2011-01-11 21:12:48 UTC (rev 34264)
@@ -1594,6 +1594,64 @@
 
 /* ********************************************** */
 
+/* Show all armature layers */
+static int pose_armature_layers_showall_poll (bContext *C)
+{
+	/* this single operator can be used in posemode OR editmode for armatures */
+	return ED_operator_posemode(C) || ED_operator_editarmature(C);
+}
+
+static int pose_armature_layers_showall_exec (bContext *C, wmOperator *op)
+{
+	Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
+	bArmature *arm = (ob)? ob->data : NULL;
+	PointerRNA ptr;
+	int maxLayers = (RNA_boolean_get(op->ptr, "all"))? 32 : 16;
+	int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
+	int i;
+	
+	/* sanity checking */
+	if (arm == NULL)
+		return OPERATOR_CANCELLED;
+	
+	/* use RNA to set the layers
+	 * 	although it would be faster to just set directly using bitflags, we still
+	 *	need to setup a RNA pointer so that we get the "update" callbacks for free...
+	 */
+	RNA_id_pointer_create(&arm->id, &ptr);
+	
+	for (i = 0; i < maxLayers; i++)
+		layers[i] = 1;
+	
+	RNA_boolean_set_array(&ptr, "layers", layers);
+	
+	/* note, notifier might evolve */
+	WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+	
+	/* done */
+	return OPERATOR_FINISHED;
+}
+
+void ARMATURE_OT_layers_show_all (wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "Show All Layers";
+	ot->idname= "ARMATURE_OT_layers_show_all";
+	ot->description= "Make all armature layers visible";
+	
+	/* callbacks */
+	ot->exec= pose_armature_layers_showall_exec;
+	ot->poll= pose_armature_layers_showall_poll;
+	
+	/* flags */
+	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+	
+	/* properties */
+	ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All Layers", "Enable all layers or just the first 16 (top row)");
+}
+
+/* ------------------- */
+
 /* Present a popup to get the layers that should be used */
 static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt)
 {




More information about the Bf-blender-cvs mailing list