diff options
author | Michael Fox <mfoxdogg@gmail.com> | 2009-02-12 02:50:06 +0300 |
---|---|---|
committer | Michael Fox <mfoxdogg@gmail.com> | 2009-02-12 02:50:06 +0300 |
commit | 9ad8f1cf6a1911516ebf48e268995bc0357ecf2c (patch) | |
tree | 6eaca4311734c00902328fd6a41b6e65a3a3275f /source/blender/editors/armature/editarmature.c | |
parent | b8e6e01cfd4caf96e8b5339b272aa6be4f22f7e7 (diff) |
2.5
******
ported selection_invert for both edit armature and pose mode
Diffstat (limited to 'source/blender/editors/armature/editarmature.c')
-rw-r--r-- | source/blender/editors/armature/editarmature.c | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index fdefd01a122..cb92c423783 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -3509,8 +3509,45 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", prop_editarm_clear_parent_types, 0, "ClearType", "What way to clear parenting"); } -/* ****** (de)select All *******/ +/* **************** Selections ******************/ + +static int armature_selection_invert_exec(bContext *C, wmOperator *op) +{ + Object *obedit = CTX_data_edit_object(C); + bArmature *arm= obedit->data; + EditBone *ebone; + + /* Set the flags */ + for (ebone=arm->edbo->first;ebone;ebone=ebone->next) { + /* select bone */ + if(arm->layer & ebone->layer && (ebone->flag & BONE_HIDDEN_A)==0) { + ebone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + ebone->flag &= ~BONE_ACTIVE; + } + } + + /* undo? */ + WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL); + + return OPERATOR_FINISHED; +} + +void ARMATURE_OT_selection_invert(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name= "Invert Selection"; + ot->idname= "ARMATURE_OT_selection_invert"; + + /* api callbacks */ + ot->exec= armature_selection_invert_exec; + ot->poll= ED_operator_editarmature; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + +} static int armature_de_select_all_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -4380,7 +4417,42 @@ void POSE_OT_rot_clear(wmOperatorType *ot) } +/* ***************** selections ********************** */ +static int pose_selection_invert_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_active_object(C); + bArmature *arm= ob->data; + bPoseChannel *pchan; + + /* Set the flags */ + for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + if ((pchan->bone->layer & arm->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) { + pchan->bone->flag ^= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + pchan->bone->flag &= ~BONE_ACTIVE; + } + } + + WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL); + + return OPERATOR_FINISHED; +} + +void POSE_OT_selection_invert(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name= "Invert Selection"; + ot->idname= "POSE_OT_selection_invert"; + + /* api callbacks */ + ot->exec= pose_selection_invert_exec; + ot->poll= ED_operator_posemode; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + +} static int pose_de_select_all_exec(bContext *C, wmOperator *op) { Object *ob= CTX_data_active_object(C); |