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:
authorJoshua Leung <aligorith@gmail.com>2010-07-14 07:19:19 +0400
committerJoshua Leung <aligorith@gmail.com>2010-07-14 07:19:19 +0400
commit7a2394c718112f9803418555fdcc0e222095ef2b (patch)
tree6690ec0abbdc5058cb96f4cdd2c224e229a3afc5
parent3580d6229a2c2ee5815ff76665d4bb014eacfb99 (diff)
Patch #22807: Add select/deselect buttons to armature bone group panel
Patch submitted by Torsten Rupp (rupp)
-rw-r--r--release/scripts/ui/properties_data_armature.py13
-rw-r--r--source/blender/editors/armature/armature_intern.h2
-rw-r--r--source/blender/editors/armature/armature_ops.c2
-rw-r--r--source/blender/editors/armature/poseobject.c119
4 files changed, 116 insertions, 20 deletions
diff --git a/release/scripts/ui/properties_data_armature.py b/release/scripts/ui/properties_data_armature.py
index 0575f13e8be..38903cc1f27 100644
--- a/release/scripts/ui/properties_data_armature.py
+++ b/release/scripts/ui/properties_data_armature.py
@@ -160,13 +160,16 @@ class DATA_PT_bone_groups(DataButtonsPanel):
col = split.column()
col.template_triColorSet(group, "colors")
- row = layout.row(align=True)
+ row = layout.row()
row.active = (ob.proxy is None)
- row.operator("pose.group_assign", text="Assign")
- row.operator("pose.group_unassign", text="Remove") #row.operator("pose.bone_group_remove_from", text="Remove")
- #row.operator("object.bone_group_select", text="Select")
- #row.operator("object.bone_group_deselect", text="Deselect")
+ sub = row.row(align=True)
+ sub.operator("pose.group_assign", text="Assign")
+ sub.operator("pose.group_unassign", text="Remove") #row.operator("pose.bone_group_remove_from", text="Remove")
+
+ sub = row.row(align=True)
+ sub.operator("pose.group_select", text="Select")
+ sub.operator("pose.group_deselect", text="Deselect")
# TODO: this panel will soon be depreceated too
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index a4a2d020482..fadb4f234d9 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -107,6 +107,8 @@ void POSE_OT_group_remove(struct wmOperatorType *ot);
void POSE_OT_group_remove(struct wmOperatorType *ot);
void POSE_OT_group_assign(struct wmOperatorType *ot);
void POSE_OT_group_unassign(struct wmOperatorType *ot);
+void POSE_OT_group_select(struct wmOperatorType *ot);
+void POSE_OT_group_deselect(struct wmOperatorType *ot);
void POSE_OT_paths_calculate(struct wmOperatorType *ot);
void POSE_OT_paths_clear(struct wmOperatorType *ot);
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index 672dd22b704..7abf8575921 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -126,6 +126,8 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(POSE_OT_group_remove);
WM_operatortype_append(POSE_OT_group_assign);
WM_operatortype_append(POSE_OT_group_unassign);
+ WM_operatortype_append(POSE_OT_group_select);
+ WM_operatortype_append(POSE_OT_group_deselect);
WM_operatortype_append(POSE_OT_paths_calculate);
WM_operatortype_append(POSE_OT_paths_clear);
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index 24c3aff9a6a..6fdce9b9c41 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -1247,8 +1247,8 @@ static int pose_group_assign_exec (bContext *C, wmOperator *op)
pose_add_group(ob);
/* add selected bones to group then */
- // NOTE: unfortunately, we cannot use the context-iterators here, since they might not be defined...
- CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones) {
+ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
+ {
pchan->agrp_index= pose->active_group;
done= 1;
}
@@ -1290,7 +1290,6 @@ static int pose_group_unassign_exec (bContext *C, wmOperator *op)
Object *ob;
bArmature *arm;
bPose *pose;
- bPoseChannel *pchan;
short done= 0;
/* since this call may also be used from the buttons window, we need to check for where to get the object */
@@ -1306,20 +1305,14 @@ static int pose_group_unassign_exec (bContext *C, wmOperator *op)
arm= ob->data;
/* find selected bones to remove from all bone groups */
- // NOTE: unfortunately, we cannot use the context-iterators here, since they might not be defined...
- // CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
- for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
- /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
- // NOTE: sync this view3d_context() in space_view3d.c
- if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
- if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone)) {
- if (pchan->agrp_index) {
- pchan->agrp_index= 0;
- done= 1;
- }
- }
+ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
+ {
+ if (pchan->agrp_index) {
+ pchan->agrp_index= 0;
+ done= 1;
}
}
+ CTX_DATA_END;
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
@@ -1346,6 +1339,102 @@ void POSE_OT_group_unassign (wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
+static void pose_group_select(bContext *C, Object *ob, int select)
+{
+ bPose *pose= ob->pose;
+
+ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, visible_pose_bones)
+ {
+ if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) {
+ if (select) {
+ if (pchan->agrp_index == pose->active_group)
+ pchan->bone->flag |= BONE_SELECTED;
+ }
+ else {
+ if (pchan->agrp_index == pose->active_group)
+ pchan->bone->flag &= ~BONE_SELECTED;
+ }
+ }
+ }
+ CTX_DATA_END;
+}
+
+static int pose_group_select_exec (bContext *C, wmOperator *op)
+{
+ ScrArea *sa= CTX_wm_area(C);
+ Object *ob;
+
+ /* since this call may also be used from the buttons window, we need to check for where to get the object */
+ if (sa->spacetype == SPACE_BUTS)
+ ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+ else
+ ob= CTX_data_active_object(C);
+
+ /* only continue if there's an object, and a pose there too */
+ if (ELEM(NULL, ob, ob->pose))
+ return OPERATOR_CANCELLED;
+
+ pose_group_select(C, ob, 1);
+
+ /* notifiers for updates */
+ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void POSE_OT_group_select (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Select Bones of Bone Group";
+ ot->idname= "POSE_OT_group_select";
+ ot->description= "Select bones in active Bone Group";
+
+ /* api callbacks */
+ ot->exec= pose_group_select_exec;
+ ot->poll= ED_operator_posemode;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int pose_group_deselect_exec (bContext *C, wmOperator *op)
+{
+ ScrArea *sa= CTX_wm_area(C);
+ Object *ob;
+
+ /* since this call may also be used from the buttons window, we need to check for where to get the object */
+ if (sa->spacetype == SPACE_BUTS)
+ ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+ else
+ ob= CTX_data_active_object(C);
+
+ /* only continue if there's an object, and a pose there too */
+ if (ELEM(NULL, ob, ob->pose))
+ return OPERATOR_CANCELLED;
+
+ pose_group_select(C, ob, 0);
+
+ /* notifiers for updates */
+ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void POSE_OT_group_deselect (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Deselecte Bone Group";
+ ot->idname= "POSE_OT_group_deselect";
+ ot->description= "Deselect bones of active Bone Group";
+
+ /* api callbacks */
+ ot->exec= pose_group_deselect_exec;
+ ot->poll= ED_operator_posemode;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/* ********************************************** */
static int pose_flip_names_exec (bContext *C, wmOperator *op)