converted more mixed tab/space indentations to tabs. only whitespace changes.
[blender.git] / source / blender / editors / armature / editarmature.c
index 3bb0124..23f91f8 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * $Id$
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
  * ***** END GPL LICENSE BLOCK *****
  */
 
+/** \file blender/editors/armature/editarmature.c
+ *  \ingroup edarmature
+ */
+
+
 #include <ctype.h>
 #include <stdlib.h>
 #include <stddef.h>
@@ -44,6 +49,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
+#include "BLI_utildefines.h"
 #include "BLI_editVert.h"
 #include "BLI_ghash.h"
 
@@ -81,6 +87,7 @@
 #include "ED_view3d.h"
 
 #include "UI_interface.h"
+#include "UI_resources.h"
 
 #include "armature_intern.h"
 #include "meshlaplacian.h"
@@ -119,7 +126,7 @@ void ED_armature_validate_active(struct bArmature *arm)
        EditBone *ebone= arm->act_edbone;
 
        if(ebone) { 
-               if(ebone->flag & BONE_HIDDEN_A || (ebone->flag & BONE_SELECTED)==0)
+               if(ebone->flag & BONE_HIDDEN_A)
                        arm->act_edbone= NULL;
        }
 }
@@ -152,6 +159,91 @@ void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
        bone_free(arm, exBone);
 }
 
+/* context: editmode armature */
+EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo)
+{
+       EditBone *eboflip= NULL;
+       char name[32];
+       
+       if (ebo == NULL)
+               return NULL;
+       
+       flip_side_name(name, ebo->name, FALSE);
+       
+       for (eboflip= edbo->first; eboflip; eboflip=eboflip->next) {
+               if (ebo != eboflip) {
+                       if (!strcmp (name, eboflip->name)) 
+                               break;
+               }
+       }
+       
+       return eboflip;
+}
+
+/* helper function for tools to work on mirrored parts.
+   it leaves mirrored bones selected then too, which is a good indication of what happened */
+static void armature_select_mirrored(bArmature *arm)
+{
+       /* Select mirrored bones */
+       if (arm->flag & ARM_MIRROR_EDIT) {
+               EditBone *curBone, *ebone_mirr;
+               
+               for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
+                       if (arm->layer & curBone->layer) {
+                               if (curBone->flag & BONE_SELECTED) {
+                                       ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone);
+                                       if (ebone_mirr)
+                                               ebone_mirr->flag |= BONE_SELECTED;
+                               }
+                       }
+               }
+       }
+       
+}
+
+static void armature_tag_select_mirrored(bArmature *arm)
+{
+       EditBone *curBone;
+
+       /* always untag */
+       for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
+               curBone->flag &= ~BONE_DONE;
+       }
+
+       /* Select mirrored bones */
+       if (arm->flag & ARM_MIRROR_EDIT) {
+               for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
+                       if (arm->layer & curBone->layer) {
+                               if (curBone->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL)) {
+                                       EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone);
+                                       if (ebone_mirr && (ebone_mirr->flag & BONE_SELECTED) == 0) {
+                                               ebone_mirr->flag |= BONE_DONE;
+                                       }
+                               }
+                       }
+               }
+
+               for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
+                       if (curBone->flag & BONE_DONE) {
+                               EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone);
+                               curBone->flag |= ebone_mirr->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL);
+                       }
+               }
+       }
+}
+
+
+/* only works when tagged */
+static void armature_tag_unselect(bArmature *arm)
+{
+       EditBone *curBone;
+
+       for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
+               if (curBone->flag & BONE_DONE) {
+                       curBone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL|BONE_DONE);
+               }
+       }
+}
 
 /* converts Bones to EditBone list, used for tools as well */
 EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone *actBone)
@@ -160,11 +252,6 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
        EditBone        *eBoneAct= NULL;
        EditBone        *eBoneTest= NULL;
        Bone            *curBone;
-       float delta[3];
-       float premat[3][3];
-       float postmat[3][3];
-       float imat[3][3];
-       float difmat[3][3];
                
        for (curBone=bones->first; curBone; curBone=curBone->next) {
                eBone= MEM_callocN(sizeof(EditBone), "make_editbone");
@@ -205,20 +292,8 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
                }
 
                copy_v3_v3(eBone->head, curBone->arm_head);
-               copy_v3_v3(eBone->tail, curBone->arm_tail);             
-               
-               eBone->roll= 0.0f;
-               
-               /* roll fixing */
-               sub_v3_v3v3(delta, eBone->tail, eBone->head);
-               vec_roll_to_mat3(delta, 0.0f, postmat);
-               
-               copy_m3_m4(premat, curBone->arm_mat);
-               
-               invert_m3_m3(imat, postmat);
-               mul_m3_m3m3(difmat, imat, premat);
-               
-               eBone->roll = (float)atan2(difmat[2][0], difmat[2][2]);
+               copy_v3_v3(eBone->tail, curBone->arm_tail);
+               eBone->roll = curBone->arm_roll;
                
                /* rest of stuff copy */
                eBone->length= curBone->length;
@@ -334,12 +409,16 @@ void ED_armature_from_edit(Object *obedit)
                eBone->temp= newBone;   /* Associate the real Bones with the EditBones */
                
                BLI_strncpy(newBone->name, eBone->name, sizeof(newBone->name));
-               memcpy(newBone->head, eBone->head, sizeof(newBone->head));
-               memcpy(newBone->tail, eBone->tail, sizeof(newBone->tail));
+               copy_v3_v3(newBone->arm_head, eBone->head);
+               copy_v3_v3(newBone->arm_tail, eBone->tail);
+               newBone->arm_roll = eBone->roll;
+               
                newBone->flag= eBone->flag;
                
                if (eBone == arm->act_edbone) {
-                       newBone->flag |= BONE_SELECTED; /* important, editbones can be active with only 1 point selected */
+                       /* don't change active selection, this messes up separate which uses
+                        * editmode toggle and can separate active bone which is de-selected originally */
+                       /* newBone->flag |= BONE_SELECTED; */ /* important, editbones can be active with only 1 point selected */
                        arm->act_edbone= NULL;
                        arm->act_bone= newBone;
                }
@@ -370,7 +449,6 @@ void ED_armature_from_edit(Object *obedit)
                        BLI_addtail(&newBone->parent->childbase, newBone);
                        
                        {
-                               float M_boneRest[3][3];
                                float M_parentRest[3][3];
                                float iM_parentRest[3][3];
                                float   delta[3];
@@ -379,10 +457,6 @@ void ED_armature_from_edit(Object *obedit)
                                sub_v3_v3v3(delta, eBone->parent->tail, eBone->parent->head);
                                vec_roll_to_mat3(delta, eBone->parent->roll, M_parentRest);
                                
-                               /* Get this bone's  matrix (rotation only) */
-                               sub_v3_v3v3(delta, eBone->tail, eBone->head);
-                               vec_roll_to_mat3(delta, eBone->roll, M_boneRest);
-                               
                                /* Invert the parent matrix */
                                invert_m3_m3(iM_parentRest, M_parentRest);
                                
@@ -395,8 +469,11 @@ void ED_armature_from_edit(Object *obedit)
                        }
                }
                /*      ...otherwise add this bone to the armature's bonebase */
-               else
+               else {
+                       copy_v3_v3(newBone->head, eBone->head);
+                       copy_v3_v3(newBone->tail, eBone->tail);
                        BLI_addtail(&arm->bonebase, newBone);
+               }
        }
        
        /* Make a pass through the new armature to fix rolling */
@@ -409,7 +486,7 @@ void ED_armature_from_edit(Object *obedit)
                        armature_rebuild_pose(obt, arm);
        }
        
-       DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
+       DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
 }
 
 void ED_armature_apply_transform(Object *ob, float mat[4][4])
@@ -429,6 +506,10 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4])
                ebone->rad_head *= scale;
                ebone->rad_tail *= scale;
                ebone->dist             *= scale;
+
+               /* we could be smarter and scale by the matrix along the x & z axis */
+               ebone->xwidth   *= scale;
+               ebone->zwidth   *= scale;
        }
        
        /* Turn the list into an armature */
@@ -563,6 +644,8 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op)
        
        /* helpful warnings... */
        // TODO: add warnings to be careful about actions, applying deforms first, etc.
+       if (ob->adt && ob->adt->action) 
+               BKE_report(op->reports, RPT_WARNING, "Actions on this armature will be destroyed by this new rest pose as the transforms stored are relative to the old rest pose");
        
        /* Get editbones of active armature to alter */
        ED_armature_to_edit(ob);        
@@ -602,10 +685,11 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op)
                }
                
                /* clear transform values for pchan */
-               pchan->loc[0]= pchan->loc[1]= pchan->loc[2]= 0.0f;
-               pchan->eul[0]= pchan->eul[1]= pchan->eul[2]= 0.0f;
-               pchan->quat[1]= pchan->quat[2]= pchan->quat[3]= 0.0f;
-               pchan->quat[0]= pchan->size[0]= pchan->size[1]= pchan->size[2]= 1.0f;
+               zero_v3(pchan->loc);
+               zero_v3(pchan->eul);
+               unit_qt(pchan->quat);
+               unit_axis_angle(pchan->rotAxis, &pchan->rotAngle);
+               pchan->size[0]= pchan->size[1]= pchan->size[2]= 1.0f;
                
                /* set anim lock */
                curbone->flag |= BONE_UNKEYED;
@@ -646,7 +730,6 @@ void POSE_OT_armature_apply (wmOperatorType *ot)
 /* set the current pose as the restpose */
 static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op))
 {
-       Scene *scene= CTX_data_scene(C);
        Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); // must be active object, not edit-object
 
        /* don't check if editmode (should be done by caller) */
@@ -659,25 +742,19 @@ static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op)
         * at once are to be predictable*/
        CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones)
        {
-               float delta_mat[4][4], imat[4][4], mat[4][4];
-
-               where_is_pose_bone(scene, ob, pchan, CFRA, 1);
-
-               copy_m4_m4(mat, pchan->pose_mat);
-
-               /* calculate pchan->pose_mat without loc/size/rot & constraints applied */
-               where_is_pose_bone(scene, ob, pchan, CFRA, 0);
-               invert_m4_m4(imat, pchan->pose_mat);
-               mul_m4_m4m4(delta_mat, mat, imat);
-
+               float delta_mat[4][4];
+               
+               /* chan_mat already contains the delta transform from rest pose to pose-mode pose
+                * as that is baked into there so that B-Bones will work. Once we've set this as the
+                * new raw-transform components, don't recalc the poses yet, otherwise IK result will 
+                * change, thus changing the result we may be trying to record.
+                */
+               copy_m4_m4(delta_mat, pchan->chan_mat);
                pchan_apply_mat4(pchan, delta_mat, TRUE);
-
-               where_is_pose_bone(scene, ob, pchan, CFRA, 1);
        }
        CTX_DATA_END;
-
-       // ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
-       DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+       
+       DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
 
        /* note, notifier might evolve */
        WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
@@ -922,7 +999,7 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
 static void separated_armature_fix_links(Object *origArm, Object *newArm)
 {
        Object *ob;
-       bPoseChannel *pchan, *pcha, *pchb;
+       bPoseChannel *pchan;
        bConstraint *con;
        ListBase *opchans, *npchans;
        
@@ -949,38 +1026,23 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
                                                         *      - the target isn't origArm/newArm itself
                                                         *      - the target is one that can be found in newArm/origArm
                                                         */
-                                                       if ((ct->tar == origArm) && (ct->subtarget[0] != 0)) {
-                                                               for (pcha=npchans->first, pchb=npchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) {
-                                                                       /* check if either one matches */
-                                                                       if ( (strcmp(pcha->name, ct->subtarget)==0) ||
-                                                                                (strcmp(pchb->name, ct->subtarget)==0) )
-                                                                       {
+                                                       if (ct->subtarget[0] != 0) {
+                                                               if (ct->tar == origArm) {
+                                                                       if(BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) {
                                                                                ct->tar= newArm;
-                                                                               break;
                                                                        }
-                                                                       
-                                                                       /* check if both ends have met (to stop checking) */
-                                                                       if (pcha == pchb) break;
-                                                               }                                                               
-                                                       }
-                                                       else if ((ct->tar == newArm) && (ct->subtarget[0] != 0)) {
-                                                               for (pcha=opchans->first, pchb=opchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) {
-                                                                       /* check if either one matches */
-                                                                       if ( (strcmp(pcha->name, ct->subtarget)==0) ||
-                                                                                (strcmp(pchb->name, ct->subtarget)==0) )
-                                                                       {
+                                                               }
+                                                               else if (ct->tar == newArm) {
+                                                                       if(BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) {
                                                                                ct->tar= origArm;
-                                                                               break;
                                                                        }
-                                                                       
-                                                                       /* check if both ends have met (to stop checking) */
-                                                                       if (pcha == pchb) break;
-                                                               }                                                               
+                                                               }
                                                        }
                                                }
-                                               
-                                               if (cti->flush_constraint_targets)
+
+                                               if (cti->flush_constraint_targets) {
                                                        cti->flush_constraint_targets(con, &targets, 0);
+                                               }
                                        }
                                }
                        }
@@ -1002,58 +1064,33 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
                                                 *      - the target isn't origArm/newArm itself
                                                 *      - the target is one that can be found in newArm/origArm
                                                 */
-                                               if ((ct->tar == origArm) && (ct->subtarget[0] != 0)) {
-                                                       for (pcha=npchans->first, pchb=npchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) {
-                                                               /* check if either one matches */
-                                                               if ( (strcmp(pcha->name, ct->subtarget)==0) ||
-                                                                        (strcmp(pchb->name, ct->subtarget)==0) )
-                                                               {
+                                               if(ct->subtarget[0] != '\0')  {
+                                                       if (ct->tar == origArm) {
+                                                               if(BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) {
                                                                        ct->tar= newArm;
-                                                                       break;
                                                                }
-                                                               
-                                                               /* check if both ends have met (to stop checking) */
-                                                               if (pcha == pchb) break;
-                                                       }                                                               
-                                               }
-                                               else if ((ct->tar == newArm) && (ct->subtarget[0] != 0)) {
-                                                       for (pcha=opchans->first, pchb=opchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) {
-                                                               /* check if either one matches */
-                                                               if ( (strcmp(pcha->name, ct->subtarget)==0) ||
-                                                                        (strcmp(pchb->name, ct->subtarget)==0) )
-                                                               {
+                                                       }
+                                                       else if (ct->tar == newArm) {
+                                                               if(BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) {
                                                                        ct->tar= origArm;
-                                                                       break;
                                                                }
-                                                               
-                                                               /* check if both ends have met (to stop checking) */
-                                                               if (pcha == pchb) break;
-                                                       }                                                               
+                                                       }
                                                }
                                        }
-                                       
-                                       if (cti->flush_constraint_targets)
+
+                                       if (cti->flush_constraint_targets) {
                                                cti->flush_constraint_targets(con, &targets, 0);
+                                       }
                                }
                        }
                }
                
                /* See if an object is parented to this armature */
-               if ((ob->parent) && (ob->parent == origArm)) {
+               if (ob->parent && (ob->parent == origArm)) {
                        /* Is object parented to a bone of this src armature? */
-                       if (ob->partype==PARBONE) {
-                               /* bone name in object */
-                               for (pcha=npchans->first, pchb=npchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) {
-                                       /* check if either one matches */
-                                       if ( (strcmp(pcha->name, ob->parsubstr)==0) ||
-                                                (strcmp(pchb->name, ob->parsubstr)==0) )
-                                       {
-                                               ob->parent= newArm;
-                                               break;
-                                       }
-                                       
-                                       /* check if both ends have met (to stop checking) */
-                                       if (pcha == pchb) break;
+                       if ((ob->partype == PARBONE) && (ob->parsubstr[0] != '\0')) {
+                               if(BLI_findstring(npchans, ob->parsubstr, offsetof(bPoseChannel, name))) {
+                                       ob->parent= newArm;
                                }
                        }
                }
@@ -1123,12 +1160,10 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op))
        Object *obedit= CTX_data_edit_object(C);
        Object *oldob, *newob;
        Base *oldbase, *newbase;
-       bArmature *arm;
        
        /* sanity checks */
        if (obedit == NULL)
                return OPERATOR_CANCELLED;
-       arm= obedit->data;
        
        /* set wait cursor in case this takes a while */
        WM_cursor_wait(1);
@@ -1172,8 +1207,8 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op))
        /* 4) fix links before depsgraph flushes */ // err... or after?
        separated_armature_fix_links(oldob, newob);
        
-       DAG_id_flush_update(&oldob->id, OB_RECALC_DATA);        /* this is the original one */
-       DAG_id_flush_update(&newob->id, OB_RECALC_DATA);        /* this is the separated one */
+       DAG_id_tag_update(&oldob->id, OB_RECALC_DATA);  /* this is the original one */
+       DAG_id_tag_update(&newob->id, OB_RECALC_DATA);  /* this is the separated one */
        
        
        /* 5) restore original conditions */
@@ -1213,15 +1248,11 @@ void ARMATURE_OT_separate (wmOperatorType *ot)
 Bone *get_indexed_bone (Object *ob, int index)
 {
        bPoseChannel *pchan;
-       int a= 0;
-       
        if(ob->pose==NULL) return NULL;
        index>>=16;             // bone selection codes use left 2 bytes
        
-       for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) {
-               if(a==index) return pchan->bone;
-       }
-       return NULL;
+       pchan= BLI_findlink(&ob->pose->chanbase, index);
+       return pchan ? pchan->bone : NULL;
 }
 
 /* See if there are any selected bones in this buffer */
@@ -1551,6 +1582,7 @@ void POSE_OT_select_linked(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Select Connected";
        ot->idname= "POSE_OT_select_linked";
+       ot->description= "Select bones related to selected ones by parent/child relationships";
        
        /* api callbacks */
        ot->exec= NULL;
@@ -1650,6 +1682,7 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Select Connected";
        ot->idname= "ARMATURE_OT_select_linked";
+       ot->description= "Select bones related to selected ones by parent/child relationships";
        
        /* api callbacks */
        ot->exec= NULL;
@@ -1753,34 +1786,12 @@ static EditBone *get_nearest_editbonepoint (ViewContext *vc, short mval[2], List
        return NULL;
 }
 
-/* context: editmode armature */
-EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo)
-{
-       EditBone *eboflip= NULL;
-       char name[32];
-       
-       if (ebo == NULL)
-               return NULL;
-
-       flip_side_name(name, ebo->name, FALSE);
-       
-       for (eboflip= edbo->first; eboflip; eboflip=eboflip->next) {
-               if (ebo != eboflip) {
-                       if (!strcmp (name, eboflip->name)) 
-                               break;
-               }
-       }
-       
-       return eboflip;
-}
-
-
 /* previously delete_armature */
 /* only editmode! */
 static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
 {
        bArmature *arm;
-       EditBone        *curBone, *next;
+       EditBone        *curBone, *ebone_next;
        bConstraint *con;
        Object *obedit= CTX_data_edit_object(C); // XXX get from context
        arm = obedit->data;
@@ -1789,24 +1800,13 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
        if (CTX_DATA_COUNT(C, selected_bones) == 0)
                return OPERATOR_CANCELLED;
        
-       /* Select mirrored bones */
-       if (arm->flag & ARM_MIRROR_EDIT) {
-               for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
-                       if (arm->layer & curBone->layer) {
-                               if (curBone->flag & BONE_SELECTED) {
-                                       next = ED_armature_bone_get_mirrored(arm->edbo, curBone);
-                                       if (next)
-                                               next->flag |= BONE_SELECTED;
-                               }
-                       }
-               }
-       }
+       armature_select_mirrored(arm);
        
        /*  First erase any associated pose channel */
        if (obedit->pose) {
-               bPoseChannel *pchan, *next;
-               for (pchan=obedit->pose->chanbase.first; pchan; pchan=next) {
-                       next= pchan->next;
+               bPoseChannel *pchan, *pchan_next;
+               for (pchan=obedit->pose->chanbase.first; pchan; pchan= pchan_next) {
+                       pchan_next= pchan->next;
                        curBone = editbone_name_exists(arm->edbo, pchan->name);
                        
                        if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) {
@@ -1844,8 +1844,8 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
        }
        
        
-       for (curBone=arm->edbo->first;curBone;curBone=next) {
-               next=curBone->next;
+       for (curBone=arm->edbo->first; curBone; curBone= ebone_next) {
+               ebone_next= curBone->next;
                if (arm->layer & curBone->layer) {
                        if (curBone->flag & BONE_SELECTED) {
                                if(curBone==arm->act_edbone) arm->act_edbone= NULL;
@@ -1867,6 +1867,7 @@ void ARMATURE_OT_delete(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Delete Selected Bone(s)";
        ot->idname= "ARMATURE_OT_delete";
+       ot->description= "Remove selected bones from the armature";
        
        /* api callbacks */
        ot->invoke = WM_operator_confirm;
@@ -1879,8 +1880,7 @@ void ARMATURE_OT_delete(wmOperatorType *ot)
 
 /* toggle==0: deselect
  * toggle==1: swap (based on test)
- * toggle==2: only active tag
- * toggle==3: swap (no test)
+ * toggle==2: swap (no test), CURRENTLY UNUSED
  */
 void ED_armature_deselect_all(Object *obedit, int toggle)
 {
@@ -1902,34 +1902,30 @@ void ED_armature_deselect_all(Object *obedit, int toggle)
        }
        else sel= toggle;
        
-       if(sel==2) {
-               arm->act_edbone= NULL;
-       } else {
-               /*      Set the flags */
-               for (eBone=arm->edbo->first;eBone;eBone=eBone->next) {
-                       if (sel==3) {
-                               /* invert selection of bone */
-                               if(EBONE_VISIBLE(arm, eBone)) {
-                                       eBone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
-                                       if(arm->act_edbone==eBone)
-                                               arm->act_edbone= NULL;
-                               }
-                       }
-                       else if (sel==1) {
-                               /* select bone */
-                               if(EBONE_VISIBLE(arm, eBone)) {
-                                       eBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
-                                       if(eBone->parent)
-                                               eBone->parent->flag |= (BONE_TIPSEL);
-                               }
-                       }
-                       else {
-                               /* deselect bone */
-                               eBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+       /*      Set the flags */
+       for (eBone=arm->edbo->first;eBone;eBone=eBone->next) {
+               if (sel==2) {
+                       /* invert selection of bone */
+                       if(EBONE_VISIBLE(arm, eBone)) {
+                               eBone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
                                if(arm->act_edbone==eBone)
                                        arm->act_edbone= NULL;
                        }
                }
+               else if (sel==1) {
+                       /* select bone */
+                       if(EBONE_VISIBLE(arm, eBone)) {
+                               eBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+                               if(eBone->parent)
+                                       eBone->parent->flag |= (BONE_TIPSEL);
+                       }
+               }
+               else {
+                       /* deselect bone */
+                       eBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+                       if(arm->act_edbone==eBone)
+                               arm->act_edbone= NULL;
+               }
        }
        
        ED_armature_sync_selection(arm->edbo);
@@ -1950,6 +1946,17 @@ void ED_armature_deselect_all_visible(Object *obedit)
        ED_armature_sync_selection(arm->edbo);
 }
 
+/* accounts for connected parents */
+static int ebone_select_flag(EditBone *ebone)
+{
+       if(ebone->parent && (ebone->flag & BONE_CONNECTED)) {
+               return ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0) | (ebone->flag & (BONE_SELECTED|BONE_TIPSEL));
+       }
+       else {
+               return ebone->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL);
+       }
+}
+
 /* context: editmode armature in view3d */
 int mouse_armature(bContext *C, short mval[2], int extend)
 {
@@ -2018,7 +2025,9 @@ int mouse_armature(bContext *C, short mval[2], int extend)
                
                if(nearBone) {
                        /* then now check for active status */
-                       if(nearBone->flag & BONE_SELECTED) arm->act_edbone= nearBone;
+                       if(ebone_select_flag(nearBone)) {
+                               arm->act_edbone= nearBone;
+                       }
                }
                
                WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, vc.obedit);
@@ -2084,7 +2093,7 @@ float ED_rollBoneToVector(EditBone *bone, const float align_axis[3], const short
                sub_v3_v3v3(align_axis_proj, align_axis, vec);
                
                if(axis_only) {
-                       if(angle_v3v3(align_axis_proj, mat[2]) > M_PI/2) {
+                       if(angle_v3v3(align_axis_proj, mat[2]) > (float)(M_PI/2.0)) {
                                negate_v3(align_axis_proj);
                        }
                }
@@ -2124,6 +2133,9 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
 
        float imat[3][3];
 
+       bArmature *arm= ob->data;
+       EditBone *ebone;
+
        copy_m3_m4(imat, ob->obmat);
        invert_m3(imat);
 
@@ -2138,13 +2150,14 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
                mul_m3_v3(imat, cursor_local);
 
                /* cursor */
-               CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) {
-                       float cursor_rel[3];
-                       sub_v3_v3v3(cursor_rel, cursor_local, ebone->head);
-                       if(axis_flip) negate_v3(cursor_rel);
-                       ebone->roll= ED_rollBoneToVector(ebone, cursor_rel, axis_only);
+               for(ebone= arm->edbo->first; ebone; ebone= ebone->next) {
+                       if(EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
+                               float cursor_rel[3];
+                               sub_v3_v3v3(cursor_rel, cursor_local, ebone->head);
+                               if(axis_flip) negate_v3(cursor_rel);
+                               ebone->roll= ED_rollBoneToVector(ebone, cursor_rel, axis_only);
+                       }
                }
-               CTX_DATA_END;
        }
        else {
                float vec[3]= {0.0f, 0.0f, 0.0f};
@@ -2159,10 +2172,8 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
                        mul_m3_v3(imat, vec);
                }
                else if (type==5) {
-                       bArmature *arm= ob->data;
-                       EditBone *ebone= (EditBone *)arm->act_edbone;
                        float mat[3][3], nor[3];
-
+                       ebone= (EditBone *)arm->act_edbone;
                        if(ebone==NULL) {
                                BKE_report(op->reports, RPT_ERROR, "No active bone set");
                                return OPERATOR_CANCELLED;
@@ -2181,11 +2192,23 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
 
                if(axis_flip) negate_v3(vec);
 
-               CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) {
-                       /* roll func is a callback which assumes that all is well */
-                       ebone->roll= ED_rollBoneToVector(ebone, vec, axis_only);
+               for(ebone= arm->edbo->first; ebone; ebone= ebone->next) {
+                       if(EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
+                               /* roll func is a callback which assumes that all is well */
+                               ebone->roll= ED_rollBoneToVector(ebone, vec, axis_only);
+                       }
+               }
+       }
+
+       if (arm->flag & ARM_MIRROR_EDIT) {
+               for(ebone= arm->edbo->first; ebone; ebone= ebone->next) {
+                       if((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) {
+                               EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, ebone);
+                               if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) {
+                                       ebone->roll= -ebone_mirr->roll;
+                               }
+                       }
                }
-               CTX_DATA_END;
        }
 
        /* note, notifier might evolve */
@@ -2199,6 +2222,7 @@ void ARMATURE_OT_calculate_roll(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Recalculate Roll";
        ot->idname= "ARMATURE_OT_calculate_roll";
+       ot->description= "Automatically fix alignment of select bones' axes";
        
        /* api callbacks */
        ot->invoke = WM_menu_invoke;
@@ -2525,6 +2549,7 @@ void ARMATURE_OT_click_extrude(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Click-Extrude";
        ot->idname= "ARMATURE_OT_click_extrude";
+       ot->description= "Create a new bone going from the last selected joint to the mouse position";
        
        /* api callbacks */
        ot->invoke = armature_click_extrude_invoke;
@@ -2699,7 +2724,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op))
 
        /* cancel if nothing selected */
        if (CTX_DATA_COUNT(C, selected_bones) == 0)
-         return OPERATOR_CANCELLED;
+               return OPERATOR_CANCELLED;
        
        ED_armature_sync_selection(arm->edbo); // XXX why is this needed?
 
@@ -2793,6 +2818,7 @@ void ARMATURE_OT_duplicate(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Duplicate Selected Bone(s)";
        ot->idname= "ARMATURE_OT_duplicate";
+       ot->description= "Make copies of the selected bones within the same armature";
        
        /* api callbacks */
        ot->exec = armature_duplicate_selected_exec;
@@ -2923,14 +2949,13 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
        bArmature *arm= (obedit) ? obedit->data : NULL;
        Scene *scene= CTX_data_scene(C);
        View3D *v3d= CTX_wm_view3d(C);
-       EditBone *newbone=NULL;
        ListBase points = {NULL, NULL};
        int count;
-       
+
        /* sanity checks */
-       if ELEM(NULL, obedit, arm)
+       if (ELEM(NULL, obedit, arm))
                return OPERATOR_CANCELLED;
-       
+
        /* loop over all bones, and only consider if visible */
        CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones)
        {
@@ -2964,7 +2989,7 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
                mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d));
                
                /* Create a bone */
-               newbone= add_points_bone(obedit, ebp->vec, curs);
+               /* newbone= */ add_points_bone(obedit, ebp->vec, curs);
        }
        else if (count == 2) {
                EditBonePoint *ebp, *ebp2;
@@ -3025,7 +3050,7 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
                
                /* add new bone and parent it to the appropriate end */
                if (headtail) {
-                       newbone= add_points_bone(obedit, head, tail);
+                       EditBone *newbone= add_points_bone(obedit, head, tail);
                        
                        /* do parenting (will need to set connected flag too) */
                        if (headtail == 2) {
@@ -3102,13 +3127,13 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
         *      - tail = head/tail of end (default tail)
         *      - parent = parent of start
         */
-       if ((start->flag & BONE_TIPSEL) && ((start->flag & BONE_SELECTED) || start==arm->act_edbone)==0) {
+       if ((start->flag & BONE_TIPSEL) && (start->flag & BONE_SELECTED)==0) {
                copy_v3_v3(head, start->tail);
        }
        else {
                copy_v3_v3(head, start->head);
        }
-       if ((end->flag & BONE_ROOTSEL) && ((end->flag & BONE_SELECTED) || end==arm->act_edbone)==0) {
+       if ((end->flag & BONE_ROOTSEL) && (end->flag & BONE_SELECTED)==0) {
                copy_v3_v3(tail, end->head);
        }
        else {
@@ -3116,6 +3141,9 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
        }
        newbone= add_points_bone(obedit, head, tail);
        newbone->parent = start->parent;
+
+       /* TODO, copy more things to the new bone */
+       newbone->flag= start->flag & (BONE_HINGE|BONE_NO_DEFORM|BONE_NO_SCALE|BONE_NO_CYCLICOFFSET|BONE_NO_LOCAL_LOCATION|BONE_DONE);
        
        /* step 2a: parent children of in-between bones to newbone */
        for (chain= chains->first; chain; chain= chain->next) {
@@ -3177,7 +3205,9 @@ static int armature_merge_exec (bContext *C, wmOperator *op)
                /* get chains (ends on chains) */
                chains_find_tips(arm->edbo, &chains);
                if (chains.first == NULL) return OPERATOR_CANCELLED;
-               
+
+               armature_tag_select_mirrored(arm);
+
                /* each 'chain' is the last bone in the chain (with no children) */
                for (chain= chains.first; chain; chain= nchain) {
                        EditBone *bstart= NULL, *bend= NULL;
@@ -3192,7 +3222,7 @@ static int armature_merge_exec (bContext *C, wmOperator *op)
                                /* check if visible + selected */
                                if ( EBONE_VISIBLE(arm, ebo) &&
                                         ((ebo->flag & BONE_CONNECTED) || (ebo->parent==NULL)) &&
-                                        ((ebo->flag & BONE_SELECTED) || (ebo==arm->act_edbone)) )
+                                        (ebo->flag & BONE_SELECTED) )
                                {
                                        /* set either end or start (end gets priority, unless it is already set) */
                                        if (bend == NULL)  {
@@ -3221,6 +3251,8 @@ static int armature_merge_exec (bContext *C, wmOperator *op)
                        BLI_insertlinkbefore(&chains, nchain, chain);
                }               
                
+               armature_tag_unselect(arm);
+
                BLI_freelistN(&chains);
        }
        
@@ -3258,11 +3290,12 @@ void ARMATURE_OT_merge (wmOperatorType *ot)
 /* ************** END Add/Remove stuff in editmode ************ */
 /* *************** Tools in editmode *********** */
 
-static int armature_hide_exec(bContext *C, wmOperator *UNUSED(op))
+static int armature_hide_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
        bArmature *arm= obedit->data;
        EditBone *ebone;
+       const int invert= RNA_boolean_get(op->ptr, "unselected") ? BONE_SELECTED : 0;
 
        /* cancel if nothing selected */
        if (CTX_DATA_COUNT(C, selected_bones) == 0)
@@ -3270,7 +3303,7 @@ static int armature_hide_exec(bContext *C, wmOperator *UNUSED(op))
 
        for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
                if (EBONE_VISIBLE(arm, ebone)) {
-                       if (ebone->flag & BONE_SELECTED) {
+                       if ((ebone->flag & BONE_SELECTED) != invert) {
                                ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
                                ebone->flag |= BONE_HIDDEN_A;
                        }
@@ -3279,7 +3312,7 @@ static int armature_hide_exec(bContext *C, wmOperator *UNUSED(op))
        ED_armature_validate_active(arm);
        ED_armature_sync_selection(arm->edbo);
 
-       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit);
+       WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
 
        return OPERATOR_FINISHED;
 }
@@ -3289,6 +3322,7 @@ void ARMATURE_OT_hide(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Hide Selected Bones";
        ot->idname= "ARMATURE_OT_hide";
+       ot->description= "Tag selected bones to not be visible in Edit Mode";
        
        /* api callbacks */
        ot->exec= armature_hide_exec;
@@ -3296,6 +3330,9 @@ void ARMATURE_OT_hide(wmOperatorType *ot)
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+       /* props */
+       RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected.");
 }
 
 static int armature_reveal_exec(bContext *C, wmOperator *UNUSED(op))
@@ -3315,7 +3352,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *UNUSED(op))
        ED_armature_validate_active(arm);
        ED_armature_sync_selection(arm->edbo);
 
-       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit);
+       WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
 
        return OPERATOR_FINISHED;
 }
@@ -3325,6 +3362,7 @@ void ARMATURE_OT_reveal(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Reveal Bones";
        ot->idname= "ARMATURE_OT_reveal";
+       ot->description= "Unhide all bones that have been tagged to be hidden in Edit Mode";
        
        /* api callbacks */
        ot->exec= armature_reveal_exec;
@@ -3332,9 +3370,10 @@ void ARMATURE_OT_reveal(wmOperatorType *ot)
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-}
 
-void hide_selected_armature_bones(Scene *scene)
+}
+#if 0 // remove this?
+static void hide_selected_armature_bones(Scene *scene)
 {
        Object *obedit= scene->obedit; // XXX get from context
        bArmature *arm= obedit->data;
@@ -3352,8 +3391,6 @@ void hide_selected_armature_bones(Scene *scene)
        ED_armature_sync_selection(arm->edbo);
 }
 
-
-#if 0 // remove this?
 static void hide_unselected_armature_bones(Scene *scene)
 {
        Object *obedit= scene->obedit; // XXX get from context
@@ -3373,9 +3410,7 @@ static void hide_unselected_armature_bones(Scene *scene)
        ED_armature_validate_active(arm);
        ED_armature_sync_selection(arm->edbo);
 }
-#endif
 
-#if 0 // remove this?
 void show_all_armature_bones(Scene *scene)
 {
        Object *obedit= scene->obedit; // XXX get from context
@@ -3522,13 +3557,12 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
        if (totbone==1 && first) arm->act_edbone= first;
 
        if (totbone==0) return OPERATOR_CANCELLED;
-       
-       if(arm->act_edbone && (((EditBone *)arm->act_edbone)->flag & BONE_SELECTED)==0)
-               arm->act_edbone= NULL;
 
        /* Transform the endpoints */
        ED_armature_sync_selection(arm->edbo);
 
+       WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
+
        return OPERATOR_FINISHED;
 }
 
@@ -3537,6 +3571,7 @@ void ARMATURE_OT_extrude(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Extrude";
        ot->idname= "ARMATURE_OT_extrude";
+       ot->description= "Create new bones from the selected joints";
        
        /* api callbacks */
        ot->exec= armature_extrude_exec;
@@ -3589,8 +3624,8 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
                add_v3_v3v3(bone->tail, bone->head, imat[2]);   // bone with unit length 1, pointing up Z
 
        /* note, notifier might evolve */
-       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit);
-       
+       WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
+
        return OPERATOR_FINISHED;
 }
 
@@ -3599,6 +3634,7 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Add Bone";
        ot->idname= "ARMATURE_OT_bone_primitive_add";
+       ot->description= "Add a new bone located at the 3D-Cursor";
        
        /* api callbacks */
        ot->exec = armature_bone_primitive_add_exec;
@@ -3688,6 +3724,7 @@ void ARMATURE_OT_subdivide(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Subdivide Multi";
        ot->idname= "ARMATURE_OT_subdivide";
+       ot->description= "Break selected bones into chains of smaller bones";
        
        /* api callbacks */
        ot->exec = armature_subdivide_exec;
@@ -3718,7 +3755,9 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
        /* get chains of bones (ends on chains) */
        chains_find_tips(arm->edbo, &chains);
        if (chains.first == NULL) return OPERATOR_CANCELLED;
-       
+
+       armature_tag_select_mirrored(arm);
+
        /* loop over chains, only considering selected and visible bones */
        for (chain= chains.first; chain; chain= chain->next) {
                EditBone *ebo, *child=NULL, *parent=NULL;
@@ -3774,8 +3813,10 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
        /* free chains */
        BLI_freelistN(&chains); 
 
+       armature_tag_unselect(arm);
+
        /* note, notifier might evolve */
-       WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+       WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
        
        return OPERATOR_FINISHED;
 }
@@ -3785,6 +3826,7 @@ void ARMATURE_OT_switch_direction(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Switch Direction";
        ot->idname= "ARMATURE_OT_switch_direction";
+       ot->description= "Change the direction that a chain of bones points in (head <-> tail swap)";
        
        /* api callbacks */
        ot->exec = armature_switch_direction_exec;
@@ -3924,7 +3966,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
        
 
        /* note, notifier might evolve */
-       WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+       WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
        
        return OPERATOR_FINISHED;
 }
@@ -3932,7 +3974,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
 static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
 {
        EditBone *actbone = CTX_data_active_bone(C);
-       uiPopupMenu *pup= uiPupMenuBegin(C, "Make Parent ", 0);
+       uiPopupMenu *pup= uiPupMenuBegin(C, "Make Parent ", ICON_NONE);
        uiLayout *layout= uiPupMenuLayout(pup);
        int allchildbones = 0;
        
@@ -3959,6 +4001,7 @@ void ARMATURE_OT_parent_set(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Make Parent";
        ot->idname= "ARMATURE_OT_parent_set";
+       ot->description= "Set the active bone as the parent of the selected bones";
        
        /* api callbacks */
        ot->invoke = armature_parent_set_invoke;
@@ -4002,7 +4045,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op)
        ED_armature_sync_selection(arm->edbo);
 
        /* note, notifier might evolve */
-       WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+       WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
        
        return OPERATOR_FINISHED;
 }
@@ -4012,6 +4055,7 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Clear Parent";
        ot->idname= "ARMATURE_OT_parent_clear";
+       ot->description= "Remove the parent-child relationship between selected bones and their parents";
        
        /* api callbacks */
        ot->invoke = WM_menu_invoke;
@@ -4048,6 +4092,7 @@ void ARMATURE_OT_select_inverse(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Select Inverse";
        ot->idname= "ARMATURE_OT_select_inverse";
+       ot->description= "Flip the selection status of bones (selected -> unselected, unselected -> selected)";
        
        /* api callbacks */
        ot->exec= armature_select_inverse_exec;
@@ -4085,7 +4130,8 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op)
                        case SEL_INVERT:
                                if (ebone->flag & BONE_SELECTED) {
                                        ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
-                               } else {
+                               } 
+                               else {
                                        ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
                                        if(ebone->parent)
                                                ebone->parent->flag |= (BONE_TIPSEL);
@@ -4103,10 +4149,10 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op)
 
 void ARMATURE_OT_select_all(wmOperatorType *ot)
 {
-       
        /* identifiers */
        ot->name= "Select or Deselect All";
        ot->idname= "ARMATURE_OT_select_all";
+       ot->description= "Toggle selection status of all bones";
        
        /* api callbacks */
        ot->exec= armature_de_select_all_exec;
@@ -4187,6 +4233,7 @@ void ARMATURE_OT_select_hierarchy(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Select Hierarchy";
        ot->idname= "ARMATURE_OT_select_hierarchy";
+       ot->description= "Select immediate parent/children of selected bones";
        
        /* api callbacks */
        ot->exec= armature_select_hierarchy_exec;
@@ -4416,7 +4463,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
                if (OBACT && OBACT->mode & OB_MODE_WEIGHT_PAINT) {
                        if (nearBone == arm->act_bone) {
                                ED_vgroup_select_by_name(OBACT, nearBone->name);
-                               DAG_id_flush_update(&OBACT->id, OB_RECALC_DATA);
+                               DAG_id_tag_update(&OBACT->id, OB_RECALC_DATA);
                        }
                }
                
@@ -4467,9 +4514,6 @@ void ED_pose_deselectall (Object *ob, int test)
                        }
                }
        }
-       
-       if(arm->act_bone && (arm->act_bone->flag & BONE_SELECTED)==0)
-               arm->act_bone= NULL;
 }
 
 static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap)
@@ -4626,14 +4670,14 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i
                                bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale);
                        
                        /* add the vert to the deform group if weight!=0.0 */
-                       if (distance!=0.0)
+                       if (distance != 0.0f)
                                ED_vgroup_vert_add (ob, dgroup, i, distance, WEIGHT_REPLACE);
                        else
                                ED_vgroup_vert_remove (ob, dgroup, i);
                        
                        /* do same for mirror */
                        if (dgroupflip && dgroupflip[j] && iflip >= 0) {
-                               if (distance!=0.0)
+                               if (distance != 0.0f)
                                        ED_vgroup_vert_add (ob, dgroupflip[j], iflip, distance,
                                                WEIGHT_REPLACE);
                                else
@@ -4643,7 +4687,7 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i
        }
 }
 
-void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, Object *par, int heat, int mirror)
+static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, Object *par, int heat, int mirror)
 {
        /* This functions implements the automatic computation of vertex group
         * weights, either through envelopes or using a heat equilibrium.
@@ -4842,21 +4886,157 @@ void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob,
 } 
 /* ************* Clear Pose *****************************/
 
-static int pose_clear_scale_exec(bContext *C, wmOperator *UNUSED(op)) 
+/* clear scale of pose-channel */
+static void pchan_clear_scale(bPoseChannel *pchan)
+{
+       if ((pchan->protectflag & OB_LOCK_SCALEX)==0)
+               pchan->size[0]= 1.0f;
+       if ((pchan->protectflag & OB_LOCK_SCALEY)==0)
+               pchan->size[1]= 1.0f;
+       if ((pchan->protectflag & OB_LOCK_SCALEZ)==0)
+               pchan->size[2]= 1.0f;
+}
+
+/* clear location of pose-channel */
+static void pchan_clear_loc(bPoseChannel *pchan)
+{
+       if ((pchan->protectflag & OB_LOCK_LOCX)==0)
+               pchan->loc[0]= 0.0f;
+       if ((pchan->protectflag & OB_LOCK_LOCY)==0)
+               pchan->loc[1]= 0.0f;
+       if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
+               pchan->loc[2]= 0.0f;
+}
+
+/* clear rotation of pose-channel */
+static void pchan_clear_rot(bPoseChannel *pchan)
+{
+       if (pchan->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ|OB_LOCK_ROTW)) {
+               /* check if convert to eulers for locking... */
+               if (pchan->protectflag & OB_LOCK_ROT4D) {
+                       /* perform clamping on a component by component basis */
+                       if (pchan->rotmode == ROT_MODE_AXISANGLE) {
+                               if ((pchan->protectflag & OB_LOCK_ROTW) == 0)
+                                       pchan->rotAngle= 0.0f;
+                               if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
+                                       pchan->rotAxis[0]= 0.0f;
+                               if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
+                                       pchan->rotAxis[1]= 0.0f;
+                               if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
+                                       pchan->rotAxis[2]= 0.0f;
+                                       
+                               /* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */
+                               if (IS_EQF(pchan->rotAxis[0], pchan->rotAxis[1]) && IS_EQF(pchan->rotAxis[1], pchan->rotAxis[2]))
+                                       pchan->rotAxis[1] = 1.0f;
+                       }
+                       else if (pchan->rotmode == ROT_MODE_QUAT) {
+                               if ((pchan->protectflag & OB_LOCK_ROTW) == 0)
+                                       pchan->quat[0]= 1.0f;
+                               if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
+                                       pchan->quat[1]= 0.0f;
+                               if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
+                                       pchan->quat[2]= 0.0f;
+                               if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
+                                       pchan->quat[3]= 0.0f;
+                       }
+                       else {
+                               /* the flag may have been set for the other modes, so just ignore the extra flag... */
+                               if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
+                                       pchan->eul[0]= 0.0f;
+                               if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
+                                       pchan->eul[1]= 0.0f;
+                               if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
+                                       pchan->eul[2]= 0.0f;
+                       }
+               }
+               else {
+                       /* perform clamping using euler form (3-components) */
+                       float eul[3], oldeul[3], quat1[4] = {0};
+                       float qlen = 0.0f;
+                       
+                       if (pchan->rotmode == ROT_MODE_QUAT) {
+                               qlen= normalize_qt_qt(quat1, pchan->quat);
+                               quat_to_eul(oldeul, quat1);
+                       }
+                       else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
+                               axis_angle_to_eulO( oldeul, EULER_ORDER_DEFAULT,pchan->rotAxis, pchan->rotAngle);
+                       }
+                       else {
+                               copy_v3_v3(oldeul, pchan->eul);
+                       }
+                       
+                       eul[0]= eul[1]= eul[2]= 0.0f;
+                       
+                       if (pchan->protectflag & OB_LOCK_ROTX)
+                               eul[0]= oldeul[0];
+                       if (pchan->protectflag & OB_LOCK_ROTY)
+                               eul[1]= oldeul[1];
+                       if (pchan->protectflag & OB_LOCK_ROTZ)
+                               eul[2]= oldeul[2];
+                       
+                       if (pchan->rotmode == ROT_MODE_QUAT) {
+                               eul_to_quat(pchan->quat, eul);
+                               
+                               /* restore original quat size */
+                               mul_qt_fl(pchan->quat, qlen);
+                               
+                               /* quaternions flip w sign to accumulate rotations correctly */
+                               if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) {
+                                       mul_qt_fl(pchan->quat, -1.0f);
+                               }
+                       }
+                       else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
+                               eulO_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,eul, EULER_ORDER_DEFAULT);
+                       }
+                       else {
+                               copy_v3_v3(pchan->eul, eul);
+                       }
+               }
+       }                                               // Duplicated in source/blender/editors/object/object_transform.c
+       else { 
+               if (pchan->rotmode == ROT_MODE_QUAT) {
+                       unit_qt(pchan->quat);
+               }
+               else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
+                       /* by default, make rotation of 0 radians around y-axis (roll) */
+                       unit_axis_angle(pchan->rotAxis, &pchan->rotAngle);
+               }
+               else {
+                       zero_v3(pchan->eul);
+               }
+       }
+}
+
+/* clear loc/rot/scale of pose-channel */
+static void pchan_clear_transforms(bPoseChannel *pchan)
+{
+       pchan_clear_loc(pchan);
+       pchan_clear_rot(pchan);
+       pchan_clear_scale(pchan);
+}
+
+/* --------------- */
+
+/* generic exec for clear-pose operators */
+static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op, 
+               void (*clear_func)(bPoseChannel*), const char default_ksName[])
 {
        Scene *scene= CTX_data_scene(C);
        Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
        short autokey = 0;
        
-       /* only clear those channels that are not locked */
-       CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones) {
-               if ((pchan->protectflag & OB_LOCK_SCALEX)==0)
-                       pchan->size[0]= 1.0f;
-               if ((pchan->protectflag & OB_LOCK_SCALEY)==0)
-                       pchan->size[1]= 1.0f;
-               if ((pchan->protectflag & OB_LOCK_SCALEZ)==0)
-                       pchan->size[2]= 1.0f;
-                       
+       /* sanity checks */
+       if ELEM(NULL, clear_func, default_ksName) {
+               BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform func or Keying Set Name");
+               return OPERATOR_CANCELLED;
+       }
+       
+       /* only clear relevant transforms for selected bones */
+       CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones) 
+       {
+               /* run provided clearing function */
+               clear_func(pchan);
+               
                /* do auto-keyframing as appropriate */
                if (autokeyframe_cfra_can_key(scene, &ob->id)) {
                        /* clear any unkeyed tags */
@@ -4877,7 +5057,7 @@ static int pose_clear_scale_exec(bContext *C, wmOperator *UNUSED(op))
        /* perform autokeying on the bones if needed */
        if (autokey) {
                /* get KeyingSet to use */
-               KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, "Scaling");
+               KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, default_ksName);
                
                /* insert keyframes */
                ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
@@ -4887,7 +5067,7 @@ static int pose_clear_scale_exec(bContext *C, wmOperator *UNUSED(op))
                        ED_pose_recalculate_paths(scene, ob);
        }
        
-       DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+       DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
 
        /* note, notifier might evolve */
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
@@ -4895,14 +5075,21 @@ static int pose_clear_scale_exec(bContext *C, wmOperator *UNUSED(op))
        return OPERATOR_FINISHED;
 }
 
+/* --------------- */
+
+static int pose_clear_scale_exec(bContext *C, wmOperator *op) 
+{
+       return pose_clear_transform_generic_exec(C, op, pchan_clear_scale, "Scaling");
+}
+
 void POSE_OT_scale_clear(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Clear Pose Scale";
        ot->idname= "POSE_OT_scale_clear";
+       ot->description = "Reset scaling of selected bones to their default values";
        
        /* api callbacks */
-       ot->invoke = WM_operator_confirm;
        ot->exec = pose_clear_scale_exec;
        ot->poll = ED_operator_posemode;
        
@@ -4910,58 +5097,31 @@ void POSE_OT_scale_clear(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
-static int pose_clear_loc_exec(bContext *C, wmOperator *UNUSED(op)) 
+
+static int pose_clear_rot_exec(bContext *C, wmOperator *op) 
 {
-       Scene *scene= CTX_data_scene(C);
-       Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
-       short autokey = 0;
-       
-       /* only clear those channels that are not locked */
-       CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones) {
-               /* clear location */
-               if ((pchan->protectflag & OB_LOCK_LOCX)==0)
-                       pchan->loc[0]= 0.0f;
-               if ((pchan->protectflag & OB_LOCK_LOCY)==0)
-                       pchan->loc[1]= 0.0f;
-               if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
-                       pchan->loc[2]= 0.0f;
-                       
-               /* do auto-keyframing as appropriate */
-               if (autokeyframe_cfra_can_key(scene, &ob->id)) {
-                       /* clear any unkeyed tags */
-                       if (pchan->bone)
-                               pchan->bone->flag &= ~BONE_UNKEYED;
-                               
-                       /* tag for autokeying later */
-                       autokey = 1;
-               }
-               else {
-                       /* add unkeyed tags */
-                       if (pchan->bone)
-                               pchan->bone->flag |= BONE_UNKEYED;
-               }
-       }
-       CTX_DATA_END;
+       return pose_clear_transform_generic_exec(C, op, pchan_clear_rot, "Rotation");
+}
+
+void POSE_OT_rot_clear(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Clear Pose Rotation";
+       ot->idname= "POSE_OT_rot_clear";
+       ot->description = "Reset rotations of selected bones to their default values";
        
-       /* perform autokeying on the bones if needed */
-       if (autokey) {
-               /* get KeyingSet to use */
-               KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, "Location");
-               
-               /* insert keyframes */
-               ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
-               
-               /* now recalculate paths */
-               if ((ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS))
-                       ED_pose_recalculate_paths(scene, ob);
-       }
+       /* api callbacks */
+       ot->exec = pose_clear_rot_exec;
+       ot->poll = ED_operator_posemode;
        
-       DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
 
-       /* note, notifier might evolve */
-       WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
-       
-       return OPERATOR_FINISHED;
+
+static int pose_clear_loc_exec(bContext *C, wmOperator *op) 
+{
+       return pose_clear_transform_generic_exec(C, op, pchan_clear_loc, "Location");
 }
 
 void POSE_OT_loc_clear(wmOperatorType *ot)
@@ -4969,9 +5129,9 @@ void POSE_OT_loc_clear(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Clear Pose Location";
        ot->idname= "POSE_OT_loc_clear";
+       ot->description = "Reset locations of selected bones to their default values";
        
        /* api callbacks */
-       ot->invoke = WM_operator_confirm;
        ot->exec = pose_clear_loc_exec;
        ot->poll = ED_operator_posemode;
        
@@ -4979,158 +5139,25 @@ void POSE_OT_loc_clear(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
-static int pose_clear_rot_exec(bContext *C, wmOperator *UNUSED(op)) 
-{
-       Scene *scene= CTX_data_scene(C);
-       Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
-       short autokey = 0;
-       
-       /* only clear those channels that are not locked */
-       CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones) {
-               if (pchan->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ|OB_LOCK_ROTW)) {
-                       /* check if convert to eulers for locking... */
-                       if (pchan->protectflag & OB_LOCK_ROT4D) {
-                               /* perform clamping on a component by component basis */
-                               if (pchan->rotmode == ROT_MODE_AXISANGLE) {
-                                       if ((pchan->protectflag & OB_LOCK_ROTW) == 0)
-                                               pchan->rotAngle= 0.0f;
-                                       if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
-                                               pchan->rotAxis[0]= 0.0f;
-                                       if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
-                                               pchan->rotAxis[1]= 0.0f;
-                                       if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
-                                               pchan->rotAxis[2]= 0.0f;
-                                               
-                                       /* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */
-                                       if (IS_EQ(pchan->rotAxis[0], pchan->rotAxis[1]) && IS_EQ(pchan->rotAxis[1], pchan->rotAxis[2]))
-                                               pchan->rotAxis[1] = 1.0f;
-                               }
-                               else if (pchan->rotmode == ROT_MODE_QUAT) {
-                                       if ((pchan->protectflag & OB_LOCK_ROTW) == 0)
-                                               pchan->quat[0]= 1.0f;
-                                       if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
-                                               pchan->quat[1]= 0.0f;
-                                       if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
-                                               pchan->quat[2]= 0.0f;
-                                       if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
-                                               pchan->quat[3]= 0.0f;
-                               }
-                               else {
-                                       /* the flag may have been set for the other modes, so just ignore the extra flag... */
-                                       if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
-                                               pchan->eul[0]= 0.0f;
-                                       if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
-                                               pchan->eul[1]= 0.0f;
-                                       if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
-                                               pchan->eul[2]= 0.0f;
-                               }
-                       }
-                       else {
-                               /* perform clamping using euler form (3-components) */
-                               float eul[3], oldeul[3], quat1[4] = {0};
-                               
-                               if (pchan->rotmode == ROT_MODE_QUAT) {
-                                       copy_qt_qt(quat1, pchan->quat);
-                                       quat_to_eul( oldeul,pchan->quat);
-                               }
-                               else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
-                                       axis_angle_to_eulO( oldeul, EULER_ORDER_DEFAULT,pchan->rotAxis, pchan->rotAngle);
-                               }
-                               else {
-                                       copy_v3_v3(oldeul, pchan->eul);
-                               }
-                               
-                               eul[0]= eul[1]= eul[2]= 0.0f;
-                               
-                               if (pchan->protectflag & OB_LOCK_ROTX)
-                                       eul[0]= oldeul[0];
-                               if (pchan->protectflag & OB_LOCK_ROTY)
-                                       eul[1]= oldeul[1];
-                               if (pchan->protectflag & OB_LOCK_ROTZ)
-                                       eul[2]= oldeul[2];
-                               
-                               if (pchan->rotmode == ROT_MODE_QUAT) {
-                                       eul_to_quat( pchan->quat,eul);
-                                       /* quaternions flip w sign to accumulate rotations correctly */
-                                       if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) {
-                                               mul_qt_fl(pchan->quat, -1.0f);
-                                       }
-                               }
-                               else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
-                                       eulO_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,eul, EULER_ORDER_DEFAULT);
-                               }
-                               else {
-                                       copy_v3_v3(pchan->eul, eul);
-                               }
-                       }
-               }                                               // Duplicated in source/blender/editors/object/object_transform.c
-               else { 
-                       if (pchan->rotmode == ROT_MODE_QUAT) {
-                               pchan->quat[1]=pchan->quat[2]=pchan->quat[3]= 0.0f; 
-                               pchan->quat[0]= 1.0f;
-                       }
-                       else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
-                               /* by default, make rotation of 0 radians around y-axis (roll) */
-                               pchan->rotAxis[0]=pchan->rotAxis[2]=pchan->rotAngle= 0.0f;
-                               pchan->rotAxis[1]= 1.0f;
-                       }
-                       else {
-                               pchan->eul[0]= pchan->eul[1]= pchan->eul[2]= 0.0f;
-                       }
-               }
-               
-               /* do auto-keyframing as appropriate */
-               if (autokeyframe_cfra_can_key(scene, &ob->id)) {
-                       /* clear any unkeyed tags */
-                       if (pchan->bone)
-                               pchan->bone->flag &= ~BONE_UNKEYED;
-                               
-                       /* tag for autokeying later */
-                       autokey = 1;
-               }
-               else {
-                       /* add unkeyed tags */
-                       if (pchan->bone)
-                               pchan->bone->flag |= BONE_UNKEYED;
-               }
-       }
-       CTX_DATA_END;
-       
-       /* perform autokeying on the bones if needed */
-       if (autokey) {
-               /* get KeyingSet to use */
-               KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, "Rotation");
-               
-               /* insert keyframes */
-               ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
-               
-               /* now recalculate paths */
-               if ((ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS))
-                       ED_pose_recalculate_paths(scene, ob);
-       }
-       
-       DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
 
-       /* note, notifier might evolve */
-       WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
-       
-       return OPERATOR_FINISHED;
+static int pose_clear_transforms_exec(bContext *C, wmOperator *op) 
+{
+       return pose_clear_transform_generic_exec(C, op, pchan_clear_transforms, "LocRotScale");
 }
 
-void POSE_OT_rot_clear(wmOperatorType *ot)
+void POSE_OT_transforms_clear(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Clear Pose Rotation";
-       ot->idname= "POSE_OT_rot_clear";
+       ot->name= "Clear Pose Transforms";
+       ot->idname= "POSE_OT_transforms_clear";
+       ot->description = "Reset location, rotation, and scaling of selected bones to their default values";
        
        /* api callbacks */
-       ot->invoke = WM_operator_confirm;
-       ot->exec = pose_clear_rot_exec;
+       ot->exec = pose_clear_transforms_exec;
        ot->poll = ED_operator_posemode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
 }
 
 /* ***************** selections ********************** */
@@ -5154,10 +5181,10 @@ static int pose_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
 
 void POSE_OT_select_inverse(wmOperatorType *ot)
 {
-       
        /* identifiers */
        ot->name= "Select Inverse";
        ot->idname= "POSE_OT_select_inverse";
+       ot->description= "Flip the selection status of bones (selected -> unselected, unselected -> selected)";
        
        /* api callbacks */
        ot->exec= pose_select_inverse_exec;
@@ -5172,20 +5199,7 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
        int action = RNA_enum_get(op->ptr, "action");
 
        if (action == SEL_TOGGLE) {
-               bPoseChannel *pchan= CTX_data_active_pose_bone(C);
-               int num_sel = CTX_DATA_COUNT(C, selected_pose_bones);
-               
-               /* cases for deselect:
-                *      1) there's only one bone selected, and that is the active one
-                *      2) there's more than one bone selected
-                */
-               if ( ((num_sel == 1) && (pchan) && (pchan->bone->flag & BONE_SELECTED)) ||
-                        (num_sel > 1) )
-               {
-                       action = SEL_DESELECT;
-               }
-               else 
-                       action = SEL_SELECT;
+               action= CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT;
        }
        
        /*      Set the flags */
@@ -5202,7 +5216,8 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
                case SEL_INVERT:
                        if (pchan->bone->flag & BONE_SELECTED) {
                                pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
-                       } else if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) {
+                       } 
+                       else if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) {
                                        pchan->bone->flag |= BONE_SELECTED;
                        }
                        break;
@@ -5217,10 +5232,10 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
 
 void POSE_OT_select_all(wmOperatorType *ot)
 {
-       
        /* identifiers */
        ot->name= "Select or Deselect All";
        ot->idname= "POSE_OT_select_all";
+       ot->description= "Toggle selection status of all bones";
        
        /* api callbacks */
        ot->exec= pose_de_select_all_exec;
@@ -5262,8 +5277,9 @@ static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op))
 void POSE_OT_select_parent(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "select parent bone";
+       ot->name= "Select Parent Bone";
        ot->idname= "POSE_OT_select_parent";
+       ot->description= "Select bones that are parents of the currently selected bones";
 
        /* api callbacks */
        ot->exec= pose_select_parent_exec;
@@ -5328,6 +5344,7 @@ void POSE_OT_hide(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Hide Selected";
        ot->idname= "POSE_OT_hide";
+       ot->description= "Tag selected bones to not be visible in Pose Mode";
        
        /* api callbacks */
        ot->exec= pose_hide_exec;
@@ -5373,6 +5390,7 @@ void POSE_OT_reveal(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Reveal Selected";
        ot->idname= "POSE_OT_reveal";
+       ot->description= "Unhide all bones that have been tagged to be hidden in Pose Mode";
        
        /* api callbacks */
        ot->exec= pose_reveal_exec;
@@ -5389,13 +5407,11 @@ static int bone_unique_check(void *arg, const char *name)
        return get_named_bone((bArmature *)arg, name) != NULL;
 }
 
-void unique_bone_name(bArmature *arm, char *name)
+static void unique_bone_name(bArmature *arm, char *name)
 {
        BLI_uniquename_cb(bone_unique_check, (void *)arm, "Bone", '.', name, sizeof(((Bone *)NULL)->name));
 }
 
-
-#define MAXBONENAME 32
 /* helper call for armature_bone_rename */
 static void constraint_bone_name_fix(Object *ob, ListBase *conlist, char *oldname, char *newname)
 {
@@ -5556,7 +5572,7 @@ static int armature_flip_names_exec (bContext *C, wmOperator *UNUSED(op))
        CTX_DATA_END;
        
        /* since we renamed stuff... */
-       DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+       DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
 
        /* note, notifier might evolve */
        WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
@@ -5569,7 +5585,7 @@ void ARMATURE_OT_flip_names (wmOperatorType *ot)
        /* identifiers */
        ot->name= "Flip Names";
        ot->idname= "ARMATURE_OT_flip_names";
-       ot->description= "Flips (and corrects) the names of selected bones";
+       ot->description= "Flips (and corrects) the axis suffixes of the names of selected bones";
        
        /* api callbacks */
        ot->exec= armature_flip_names_exec;
@@ -5602,7 +5618,7 @@ static int armature_autoside_names_exec (bContext *C, wmOperator *op)
        CTX_DATA_END;
        
        /* since we renamed stuff... */
-       DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+       DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
 
        /* note, notifier might evolve */
        WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
@@ -5790,7 +5806,7 @@ EditBone * test_subdivideByCorrelation(Scene *scene, Object *obedit, ReebArc *ar
                lastBone = subdivideArcBy(arm, arm->edbo, iter, invmat, tmat, nextAdaptativeSubdivision);
        }
        
-         return lastBone;
+       return lastBone;
 }
 
 float arcLengthRatio(ReebArc *arc)