add 2.4x posemode & weightpaint feature as an operator - Flip Active, Shift+F.
authorCampbell Barton <ideasman42@gmail.com>
Wed, 23 Feb 2011 04:58:08 +0000 (04:58 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 23 Feb 2011 04:58:08 +0000 (04:58 +0000)
release/scripts/ui/space_view3d.py
source/blender/editors/armature/armature_intern.h
source/blender/editors/armature/armature_ops.c
source/blender/editors/armature/poseobject.c
source/blender/editors/transform/transform_ops.c

index f7f177e07e3614f06bc47bd61bda03c86cf3d7dc..e6d546dda228942e7bcfa3f3e0300b4f36db8c3c 100644 (file)
@@ -425,6 +425,7 @@ class VIEW3D_MT_select_pose(bpy.types.Menu):
 
         layout.operator("pose.select_all", text="Select/Deselect All")
         layout.operator("pose.select_inverse", text="Inverse")
+        layout.operator("pose.select_flip_active", text="Flip Active")
         layout.operator("pose.select_constraint_target", text="Constraint Target")
         layout.operator("pose.select_linked", text="Linked")
 
index d898eddd8850c8e7caa8a5ac7d816e1336a83760..2f85861cecd8fffae6020710af7f37159f8a84e1 100644 (file)
@@ -103,6 +103,7 @@ void POSE_OT_select_hierarchy(struct wmOperatorType *ot);
 void POSE_OT_select_linked(struct wmOperatorType *ot);
 void POSE_OT_select_constraint_target(struct wmOperatorType *ot);
 void POSE_OT_select_grouped(struct wmOperatorType *ot);
+void POSE_OT_select_flip_active(struct wmOperatorType *ot);
 
 void POSE_OT_group_add(struct wmOperatorType *ot);
 void POSE_OT_group_remove(struct wmOperatorType *ot);
index 1abb1c05489018d39c75ef3397993dc078921aa2..f480a3ba3a2cb0c55cab4e83c9491b727be68b7c 100644 (file)
@@ -119,6 +119,7 @@ void ED_operatortypes_armature(void)
        WM_operatortype_append(POSE_OT_select_linked);
        WM_operatortype_append(POSE_OT_select_constraint_target);
        WM_operatortype_append(POSE_OT_select_grouped);
+       WM_operatortype_append(POSE_OT_select_flip_active);
        
        WM_operatortype_append(POSE_OT_group_add);
        WM_operatortype_append(POSE_OT_group_remove);
@@ -132,7 +133,7 @@ void ED_operatortypes_armature(void)
        
        WM_operatortype_append(POSE_OT_autoside_names);
        WM_operatortype_append(POSE_OT_flip_names);
-       
+
        WM_operatortype_append(POSE_OT_quaternions_flip);
        
        WM_operatortype_append(POSE_OT_flags_set);
@@ -323,6 +324,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
 
        WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "POSE_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
+       WM_keymap_add_item(keymap, "POSE_OT_select_flip_active", FKEY, KM_PRESS, KM_SHIFT, 0);
        
        WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
index c122460e5bb6a151e6d288ffe0c270a2a1753040..1e9e5e6fb3b04c9a2c2152ef975e57cbbbef6687 100644 (file)
@@ -656,6 +656,62 @@ void POSE_OT_select_grouped (wmOperatorType *ot)
        ot->prop= RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", "");
 }
 
+
+/* ********************************************** */
+
+/* context active object, or weightpainted object with armature in posemode */
+static int pose_bone_flip_active_exec (bContext *C, wmOperator *UNUSED(op))
+{
+       Object *ob_act= CTX_data_active_object(C);
+       Object *ob= ED_object_pose_armature(ob_act);
+
+       if(ob && (ob->mode & OB_MODE_POSE)) {
+               bArmature *arm= ob->data;
+
+               if(arm->act_bone) {
+                       bPoseChannel *pchanf;
+                       char name[MAXBONENAME];
+                       flip_side_name(name, arm->act_bone->name, TRUE);
+
+                       pchanf= get_pose_channel(ob->pose, name);
+                       if(pchanf && pchanf->bone != arm->act_bone) {
+                               arm->act_bone->flag &= ~BONE_SELECTED;
+                               pchanf->bone->flag |= BONE_SELECTED;
+
+                               arm->act_bone= pchanf->bone;
+
+                               /* in weightpaint we select the associated vertex group too */
+                               if(ob_act->mode & OB_MODE_WEIGHT_PAINT) {
+                                       ED_vgroup_select_by_name(ob_act, name);
+                                       DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
+                               }
+
+                               WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
+
+                               return OPERATOR_FINISHED;
+                       }
+               }
+       }
+
+       return OPERATOR_CANCELLED;
+}
+
+void POSE_OT_select_flip_active(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Flip Selected Active Bone";
+       ot->idname= "POSE_OT_select_flip_active";
+       ot->description= "Activate the bone with a flipped name.";
+       
+       /* api callbacks */
+       ot->exec= pose_bone_flip_active_exec;
+       ot->poll= ED_operator_posemode;
+       
+       /* flags */
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+
 /* ********************************************** */
 #if 0 /* UNUSED 2.5 */
 static void pose_copy_menu(Scene *scene)
@@ -1560,48 +1616,6 @@ void POSE_OT_autoside_names (wmOperatorType *ot)
        ot->prop= RNA_def_enum(ot->srna, "axis", axis_items, 0, "Axis", "Axis tag names with.");
 }
 
-/* ********************************************** */
-
-/* context active object, or weightpainted object with armature in posemode */
-static void pose_activate_flipped_bone(Scene *scene)
-{
-       Object *ob= OBACT;
-
-       if(ob==NULL) return;
-
-       if(ob->mode & OB_MODE_WEIGHT_PAINT) {
-               ob= modifiers_isDeformedByArmature(ob);
-       }
-
-       if(ob && (ob->mode & OB_MODE_POSE)) {
-               bPoseChannel *pchanf;
-               bArmature *arm= ob->data;
-
-               if(arm->act_bone) {
-                       char name[32];
-                       flip_side_name(name, arm->act_bone->name, TRUE);
-                       
-                       pchanf= get_pose_channel(ob->pose, name);
-                       if(pchanf && pchanf->bone != arm->act_bone) {
-                               arm->act_bone->flag &= ~BONE_SELECTED;
-                               pchanf->bone->flag |= BONE_SELECTED;
-                               
-                               arm->act_bone= pchanf->bone;
-                               
-                               /* in weightpaint we select the associated vertex group too */
-                               if(ob->mode & OB_MODE_WEIGHT_PAINT) {
-                                       ED_vgroup_select_by_name(OBACT, name);
-                                       DAG_id_tag_update(&OBACT->id, OB_RECALC_DATA);
-                               }
-                               
-                               // XXX notifiers need to be sent to other editors to update
-                               
-                       }                       
-               }
-       }
-}
-
-
 /* ********************************************** */
 
 /* Show all armature layers */
index 5c42a59ac69d28d9a2b3777d81575fa4d8519819..fa602f7341f0d590fac4112f001761e0bba61916 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "BKE_context.h"
 #include "BKE_global.h"
+#include "BKE_armature.h"
 
 #include "WM_api.h"
 #include "WM_types.h"