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:
authorTon Roosendaal <ton@blender.org>2009-02-16 20:18:24 +0300
committerTon Roosendaal <ton@blender.org>2009-02-16 20:18:24 +0300
commit2415040b9f1f8b8fae6c7df79d9993cd05fb2c39 (patch)
tree177d9cb3936cc5471eae737d9d08ff09894c9e72 /source/blender/editors/armature
parent46417e136228d57d39dd912acbf880fb641979e3 (diff)
2.5
Patch from Arystan Dyussenov (A624), two operators for armatures; - select hierarchy up/down, using bracket [ ] with or without shift, and for editmode and posemode. Good work, thanks!
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.c30
-rw-r--r--source/blender/editors/armature/editarmature.c141
-rw-r--r--source/blender/editors/armature/poseobject.c47
4 files changed, 152 insertions, 68 deletions
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index 9aacec7e44b..ace30fab20e 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -43,6 +43,7 @@ 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 ARMATURE_OT_select_hierarchy(struct wmOperatorType *ot);
void POSE_OT_hide(struct wmOperatorType *ot);
void POSE_OT_reveal(struct wmOperatorType *ot);
@@ -52,6 +53,7 @@ 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);
+void POSE_OT_select_hierarchy(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 a8502aefcff..ffd547806ba 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -120,6 +120,7 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(ARMATURE_OT_de_select_all);
WM_operatortype_append(ARMATURE_OT_selection_invert);
+ WM_operatortype_append(ARMATURE_OT_select_hierarchy);
/* POSE */
WM_operatortype_append(POSE_OT_hide);
@@ -133,6 +134,7 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(POSE_OT_selection_invert);
WM_operatortype_append(POSE_OT_select_parent);
+ WM_operatortype_append(POSE_OT_select_hierarchy);
WM_operatortype_append(ARMATURE_OT_test); // XXX temp test for context iterators... to be removed
}
@@ -162,6 +164,20 @@ void ED_keymap_armature(wmWindowManager *wm)
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
+
+ kmi= WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
+ RNA_boolean_set(kmi->ptr, "add_to_sel", 0);
+ kmi= WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
+ RNA_boolean_set(kmi->ptr, "add_to_sel", 1);
+
+ kmi= WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
+ RNA_boolean_set(kmi->ptr, "add_to_sel", 0);
+ kmi= WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
+ RNA_boolean_set(kmi->ptr, "add_to_sel", 1);
/* Pose ------------------------ */
/* only set in posemode, by space_view3d listener */
@@ -180,5 +196,19 @@ void ED_keymap_armature(wmWindowManager *wm)
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);
+
+ kmi= WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
+ RNA_boolean_set(kmi->ptr, "add_to_sel", 0);
+ kmi= WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
+ RNA_boolean_set(kmi->ptr, "add_to_sel", 1);
+
+ kmi= WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
+ RNA_boolean_set(kmi->ptr, "add_to_sel", 0);
+ kmi= WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
+ RNA_boolean_set(kmi->ptr, "add_to_sel", 1);
}
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 004cfa078ea..68e9cb6ab5a 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -1201,60 +1201,6 @@ static EditBone *editbone_get_child(bArmature *arm, EditBone *pabone, short use_
return chbone;
}
-void armature_select_hierarchy(Scene *scene, short direction, short add_to_sel)
-{
- Object *obedit= scene->obedit; // XXX get from context
- Object *ob;
- bArmature *arm;
- EditBone *curbone, *pabone, *chbone;
-
- if (!obedit) return;
- else ob= obedit;
- arm= (bArmature *)ob->data;
-
- for (curbone= arm->edbo->first; curbone; curbone= curbone->next) {
- if (EBONE_VISIBLE(arm, curbone)) {
- if (curbone->flag & (BONE_ACTIVE)) {
- if (direction == BONE_SELECT_PARENT) {
- if (curbone->parent == NULL) continue;
- else pabone = curbone->parent;
-
- if (EBONE_VISIBLE(arm, pabone)) {
- pabone->flag |= (BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
- if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL;
-
- if (!add_to_sel) curbone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
- curbone->flag &= ~BONE_ACTIVE;
- break;
- }
-
- }
- else { // BONE_SELECT_CHILD
- chbone = editbone_get_child(arm, curbone, 1);
- if (chbone == NULL) continue;
-
- if (EBONE_VISIBLE(arm, chbone)) {
- chbone->flag |= (BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
-
- if (!add_to_sel) {
- curbone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL);
- if (curbone->parent) curbone->parent->flag &= ~BONE_TIPSEL;
- }
- curbone->flag &= ~BONE_ACTIVE;
- break;
- }
- }
- }
- }
- }
-
- armature_sync_selection(arm->edbo);
-
- if (direction==BONE_SELECT_PARENT)
- BIF_undo_push("Select edit bone parent");
- if (direction==BONE_SELECT_CHILD)
- BIF_undo_push("Select edit bone child");
-}
/* used by posemode and editmode */
void setflag_armature (Scene *scene, short mode)
@@ -3585,6 +3531,89 @@ void ARMATURE_OT_de_select_all(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+
+/* ********************* select hierarchy operator ************** */
+
+static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit= CTX_data_edit_object(C);
+ Object *ob;
+ bArmature *arm;
+ EditBone *curbone, *pabone, *chbone;
+ int direction = RNA_enum_get(op->ptr, "direction");
+ int add_to_sel = RNA_boolean_get(op->ptr, "add_to_sel");
+
+ ob= obedit;
+ arm= (bArmature *)ob->data;
+
+ for (curbone= arm->edbo->first; curbone; curbone= curbone->next) {
+ if (EBONE_VISIBLE(arm, curbone)) {
+ if (curbone->flag & (BONE_ACTIVE)) {
+ if (direction == BONE_SELECT_PARENT) {
+ if (curbone->parent == NULL) continue;
+ else pabone = curbone->parent;
+
+ if (EBONE_VISIBLE(arm, pabone)) {
+ pabone->flag |= (BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+ if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL;
+
+ if (!add_to_sel) curbone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+ curbone->flag &= ~BONE_ACTIVE;
+ break;
+ }
+
+ }
+ else { // BONE_SELECT_CHILD
+ chbone = editbone_get_child(arm, curbone, 1);
+ if (chbone == NULL) continue;
+
+ if (EBONE_VISIBLE(arm, chbone)) {
+ chbone->flag |= (BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+
+ if (!add_to_sel) {
+ curbone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL);
+ if (curbone->parent) curbone->parent->flag &= ~BONE_TIPSEL;
+ }
+ curbone->flag &= ~BONE_ACTIVE;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ armature_sync_selection(arm->edbo);
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void ARMATURE_OT_select_hierarchy(wmOperatorType *ot)
+{
+ static EnumPropertyItem direction_items[]= {
+ {BONE_SELECT_PARENT, "PARENT", "Select Parent", ""},
+ {BONE_SELECT_CHILD, "CHILD", "Select Child", ""},
+ {0, NULL, NULL, NULL}
+ };
+
+ /* identifiers */
+ ot->name= "Select Hierarchy";
+ ot->idname= "ARMATURE_OT_select_hierarchy";
+
+ /* api callbacks */
+ ot->exec= armature_select_hierarchy_exec;
+ ot->poll= ED_operator_editarmature;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* props */
+ RNA_def_enum(ot->srna, "direction", direction_items,
+ BONE_SELECT_PARENT, "Direction", "");
+ RNA_def_boolean(ot->srna, "add_to_sel", 0, "Add to Selection", "");
+}
+
/* ***************** EditBone Alignment ********************* */
/* helper to fix a ebone position if its parent has moved due to alignment*/
@@ -4410,9 +4439,6 @@ void POSE_OT_rot_clear(wmOperatorType *ot)
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 */
CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pchans) {
@@ -4519,6 +4545,7 @@ void POSE_OT_select_parent(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+
/* ************* hide/unhide pose bones ******************* */
static int hide_selected_pose_bone(Object *ob, Bone *bone, void *ptr)
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index 5f8532befe1..8f0d408ca3a 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -78,6 +78,7 @@
#include "ED_keyframing.h"
#include "ED_object.h"
#include "ED_mesh.h"
+#include "ED_screen.h"
#include "ED_view3d.h"
#include "armature_intern.h"
@@ -442,17 +443,16 @@ void pose_select_constraint_target(Scene *scene)
}
-void pose_select_hierarchy(Scene *scene, short direction, short add_to_sel)
+/* ******************* select hierarchy operator ************* */
+
+static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
{
- Object *obedit= scene->obedit; // XXX context
- Object *ob= OBACT;
+ Object *ob= CTX_data_active_object(C);
bArmature *arm= ob->data;
bPoseChannel *pchan;
Bone *curbone, *pabone, *chbone;
-
- /* paranoia checks */
- if (!ob && !ob->pose) return;
- if (ob==obedit || (ob->flag & OB_POSEMODE)==0) return;
+ int direction = RNA_enum_get(op->ptr, "direction");
+ int add_to_sel = RNA_boolean_get(op->ptr, "add_to_sel");
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
curbone= pchan->bone;
@@ -491,11 +491,36 @@ void pose_select_hierarchy(Scene *scene, short direction, short add_to_sel)
}
}
}
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void POSE_OT_select_hierarchy(wmOperatorType *ot)
+{
+ static EnumPropertyItem direction_items[]= {
+ {BONE_SELECT_PARENT, "PARENT", "Select Parent", ""},
+ {BONE_SELECT_CHILD, "CHILD", "Select Child", ""},
+ {0, NULL, NULL, NULL}
+ };
+
+ /* identifiers */
+ ot->name= "Select Hierarchy";
+ ot->idname= "POSE_OT_select_hierarchy";
+
+ /* api callbacks */
+ ot->exec= pose_select_hierarchy_exec;
+ ot->poll= ED_operator_posemode;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* props */
+ RNA_def_enum(ot->srna, "direction", direction_items,
+ BONE_SELECT_PARENT, "Direction", "");
+ RNA_def_boolean(ot->srna, "add_to_sel", 0, "Add to Selection", "");
- if (direction==BONE_SELECT_PARENT)
- BIF_undo_push("Select pose bone parent");
- if (direction==BONE_SELECT_CHILD)
- BIF_undo_push("Select pose bone child");
}