Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Fox <mfoxdogg@gmail.com>2009-02-12 02:50:06 +0300
committerMichael Fox <mfoxdogg@gmail.com>2009-02-12 02:50:06 +0300
commit9ad8f1cf6a1911516ebf48e268995bc0357ecf2c (patch)
tree6eaca4311734c00902328fd6a41b6e65a3a3275f /source/blender/editors/armature
parentb8e6e01cfd4caf96e8b5339b272aa6be4f22f7e7 (diff)
2.5
****** ported selection_invert for both edit armature and pose mode
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r--source/blender/editors/armature/armature_intern.h2
-rw-r--r--source/blender/editors/armature/armature_ops.c4
-rw-r--r--source/blender/editors/armature/editarmature.c74
3 files changed, 79 insertions, 1 deletions
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index a6fa50cfc6a..d3938961d85 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -42,6 +42,7 @@ void ARMATURE_OT_subdivide_multi(struct wmOperatorType *ot);
void ARMATURE_OT_parent_set(struct wmOperatorType *ot);
void ARMATURE_OT_parent_clear(struct wmOperatorType *ot);
void ARMATURE_OT_de_select_all(struct wmOperatorType *ot);
+void ARMATURE_OT_selection_invert(struct wmOperatorType *ot);
void POSE_OT_hide(struct wmOperatorType *ot);
void POSE_OT_reveil(struct wmOperatorType *ot);
@@ -49,6 +50,7 @@ void POSE_OT_rot_clear(struct wmOperatorType *ot);
void POSE_OT_loc_clear(struct wmOperatorType *ot);
void POSE_OT_scale_clear(struct wmOperatorType *ot);
void POSE_OT_de_select_all(struct wmOperatorType *ot);
+void POSE_OT_selection_invert(struct wmOperatorType *ot);
void POSE_OT_select_parent(struct wmOperatorType *ot);
#endif /* ED_ARMATURE_INTERN_H */
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index 5f482e13183..3fececc8cac 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -119,6 +119,7 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(ARMATURE_OT_parent_clear);
WM_operatortype_append(ARMATURE_OT_de_select_all);
+ WM_operatortype_append(ARMATURE_OT_selection_invert);
/* POSE */
WM_operatortype_append(POSE_OT_hide);
@@ -129,6 +130,7 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(POSE_OT_scale_clear);
WM_operatortype_append(POSE_OT_de_select_all);
+ WM_operatortype_append(POSE_OT_selection_invert);
WM_operatortype_append(POSE_OT_select_parent);
@@ -157,6 +159,7 @@ void ED_keymap_armature(wmWindowManager *wm)
WM_keymap_add_item(keymap, "ARMATURE_OT_clear_parent", PKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_de_select_all", AKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "ARMATURE_OT_selection_invert", IKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_test", TKEY, KM_PRESS, 0, 0); // XXX temp test for context iterators... to be removed
@@ -174,6 +177,7 @@ void ED_keymap_armature(wmWindowManager *wm)
WM_keymap_add_item(keymap, "POSE_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "POSE_OT_de_select_all", AKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "POSE_OT_selection_invert", IKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "POSE_OT_select_parent", PKEY, KM_PRESS, KM_SHIFT, 0);
}
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);