Revision: 21853
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21853
Author:   aligorith
Date:     2009-07-24 15:02:16 +0200 (Fri, 24 Jul 2009)

Log Message:
-----------
2.5 - Restored 'AutoSide Name' and 'Flip Names' operators for both PoseMode and 
Edit Mode (Armatures). 

Only the PoseMode menus work for now (since these use operators)

Modified Paths:
--------------
    
branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
    branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
    branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
    branches/blender2.5/blender/source/blender/editors/armature/poseobject.c
    branches/blender2.5/blender/source/blender/editors/include/ED_armature.h
    
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c

Modified: 
branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h   
    2009-07-24 12:45:25 UTC (rev 21852)
+++ 
branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h   
    2009-07-24 13:02:16 UTC (rev 21853)
@@ -55,6 +55,9 @@
 void ARMATURE_OT_extrude(struct wmOperatorType *ot);
 void ARMATURE_OT_click_extrude(struct wmOperatorType *ot);
 
+void ARMATURE_OT_autoside_names(struct wmOperatorType *ot);
+void ARMATURE_OT_flip_names(struct wmOperatorType *ot);
+
 /* ******************************************************* */
 /* Pose-Mode Operators */
 void POSE_OT_hide(struct wmOperatorType *ot);
@@ -67,9 +70,6 @@
 void POSE_OT_copy(struct wmOperatorType *ot);
 void POSE_OT_paste(struct wmOperatorType *ot);
 
-void POSE_OT_paths_calculate(struct wmOperatorType *ot);
-void POSE_OT_paths_clear(struct wmOperatorType *ot);
-
 void POSE_OT_select_all_toggle(struct wmOperatorType *ot);
 void POSE_OT_select_inverse(struct wmOperatorType *ot);
 void POSE_OT_select_parent(struct wmOperatorType *ot);
@@ -84,6 +84,12 @@
 void POSE_OT_group_assign(struct wmOperatorType *ot);
 void POSE_OT_group_unassign(struct wmOperatorType *ot);
 
+void POSE_OT_paths_calculate(struct wmOperatorType *ot);
+void POSE_OT_paths_clear(struct wmOperatorType *ot);
+
+void POSE_OT_autoside_names(struct wmOperatorType *ot);
+void POSE_OT_flip_names(struct wmOperatorType *ot);
+
 /* ******************************************************* */
 /* Etch-A-Ton */
 

Modified: 
branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c  
2009-07-24 12:45:25 UTC (rev 21852)
+++ branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c  
2009-07-24 13:02:16 UTC (rev 21853)
@@ -129,6 +129,9 @@
        WM_operatortype_append(ARMATURE_OT_duplicate_selected);
        WM_operatortype_append(ARMATURE_OT_extrude);
        WM_operatortype_append(ARMATURE_OT_click_extrude);
+       
+       WM_operatortype_append(ARMATURE_OT_autoside_names);
+       WM_operatortype_append(ARMATURE_OT_flip_names);
 
        /* SKETCH */    
        WM_operatortype_append(SKETCH_OT_gesture);
@@ -150,9 +153,6 @@
        WM_operatortype_append(POSE_OT_copy);
        WM_operatortype_append(POSE_OT_paste);
        
-       WM_operatortype_append(POSE_OT_paths_calculate);
-       WM_operatortype_append(POSE_OT_paths_clear);
-       
        WM_operatortype_append(POSE_OT_select_all_toggle);
        WM_operatortype_append(POSE_OT_select_inverse);
 
@@ -167,6 +167,13 @@
        WM_operatortype_append(POSE_OT_group_assign);
        WM_operatortype_append(POSE_OT_group_unassign);
        
+       WM_operatortype_append(POSE_OT_paths_calculate);
+       WM_operatortype_append(POSE_OT_paths_clear);
+       
+       WM_operatortype_append(POSE_OT_autoside_names);
+       WM_operatortype_append(POSE_OT_flip_names);
+       
+       
        /* POSELIB */
        WM_operatortype_append(POSELIB_OT_browse_interactive);
        

Modified: 
branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/editarmature.c  
2009-07-24 12:45:25 UTC (rev 21852)
+++ branches/blender2.5/blender/source/blender/editors/armature/editarmature.c  
2009-07-24 13:02:16 UTC (rev 21853)
@@ -5227,48 +5227,111 @@
        }
 }
 
-/* context editmode object */
-void armature_flip_names(Scene *scene)
+
+static int armature_flip_names_exec (bContext *C, wmOperator *op)
 {
-       Object *obedit= scene->obedit; // XXX get from context
-       bArmature *arm= obedit->data;
-       EditBone *ebone;
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_edit_object(C);
+       bArmature *arm;
        char newname[32];
        
-       for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
-               if (arm->layer & ebone->layer) {
-                       if (ebone->flag & BONE_SELECTED) {
-                               BLI_strncpy(newname, ebone->name, 
sizeof(newname));
-                               bone_flip_name(newname, 1);             // 1 = 
do strip off number extensions
-                               ED_armature_bone_rename(arm, ebone->name, 
newname);
-                       }
-               }
+       /* paranoia checks */
+       if (ELEM(NULL, ob, ob->pose)) 
+               return OPERATOR_CANCELLED;
+       arm= ob->data;
+       
+       /* loop through selected bones, auto-naming them */
+       CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
+       {
+               BLI_strncpy(newname, ebone->name, sizeof(newname));
+               bone_flip_name(newname, 1);             // 1 = do strip off 
number extensions
+               ED_armature_bone_rename(arm, ebone->name, newname);
        }
+       CTX_DATA_END;
        
-       BIF_undo_push("Flip names");
+       /* since we renamed stuff... */
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+
+       /* note, notifier might evolve */
+       WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+       
+       return OPERATOR_FINISHED;
 }
 
-/* context: edtimode armature */
-void armature_autoside_names(Scene *scene, short axis)
+void ARMATURE_OT_flip_names (wmOperatorType *ot)
 {
-       Object *obedit= scene->obedit; // XXX get from context
-       bArmature *arm= obedit->data;
-       EditBone *ebone;
+       /* identifiers */
+       ot->name= "Flip Names";
+       ot->idname= "ARMATURE_OT_flip_names";
+       ot->description= "Flips (and corrects) the names of selected bones.";
+       
+       /* api callbacks */
+       ot->exec= armature_flip_names_exec;
+       ot->poll= ED_operator_editarmature;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+
+static int armature_autoside_names_exec (bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_edit_object(C);
+       bArmature *arm;
        char newname[32];
+       short axis= RNA_enum_get(op->ptr, "axis");
        
-       for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
-               if (arm->layer & ebone->layer) {
-                       if (ebone->flag & BONE_SELECTED) {
-                               BLI_strncpy(newname, ebone->name, 
sizeof(newname));
-                               bone_autoside_name(newname, 1, axis, 
ebone->head[axis], ebone->tail[axis]);
-                               ED_armature_bone_rename(arm, ebone->name, 
newname);
-                       }
-               }
+       /* paranoia checks */
+       if (ELEM(NULL, ob, ob->pose)) 
+               return OPERATOR_CANCELLED;
+       arm= ob->data;
+       
+       /* loop through selected bones, auto-naming them */
+       CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
+       {
+               BLI_strncpy(newname, ebone->name, sizeof(newname));
+               bone_autoside_name(newname, 1, axis, ebone->head[axis], 
ebone->tail[axis]);
+               ED_armature_bone_rename(arm, ebone->name, newname);
        }
+       CTX_DATA_END;
        
-       BIF_undo_push("Auto-side name");
+       /* since we renamed stuff... */
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+
+       /* note, notifier might evolve */
+       WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+       
+       return OPERATOR_FINISHED;
 }
 
+void ARMATURE_OT_autoside_names (wmOperatorType *ot)
+{
+       static EnumPropertyItem axis_items[]= {
+               {0, "XAXIS", 0, "X-Axis", "Left/Right"},
+               {1, "YAXIS", 0, "Y-Axis", "Front/Back"},
+               {2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"},
+               {0, NULL, 0, NULL, NULL}};
+       
+       /* identifiers */
+       ot->name= "AutoName by Axis";
+       ot->idname= "ARMATURE_OT_autoside_names";
+       ot->description= "Automatically renames the selected bones according to 
which side of the target axis they fall on.";
+       
+       /* api callbacks */
+       ot->invoke= WM_menu_invoke;
+       ot->exec= armature_autoside_names_exec;
+       ot->poll= ED_operator_editarmature;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       
+       /* settings */
+       RNA_def_enum(ot->srna, "axis", axis_items, 0, "Axis", "Axis tag names 
with.");
+}
+
+
+
 /* if editbone (partial) selected, copy data */
 /* context; editmode armature, with mirror editing enabled */
 void transform_armature_mirror_update(Object *obedit)

Modified: 
branches/blender2.5/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/poseobject.c    
2009-07-24 12:45:25 UTC (rev 21852)
+++ branches/blender2.5/blender/source/blender/editors/armature/poseobject.c    
2009-07-24 13:02:16 UTC (rev 21853)
@@ -1534,64 +1534,111 @@
 
 /* ********************************************** */
 
-/* context active object */
-void pose_flip_names(Scene *scene)
+static int pose_flip_names_exec (bContext *C, wmOperator *op)
 {
-       Object *obedit= scene->obedit; // XXX context
-       Object *ob= OBACT;
-       bArmature *arm= ob->data;
-       bPoseChannel *pchan;
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_active_object(C);
+       bArmature *arm;
        char newname[32];
        
        /* paranoia checks */
-       if(!ob && !ob->pose) return;
-       if(ob==obedit || (ob->flag & OB_POSEMODE)==0) return;
+       if (ELEM(NULL, ob, ob->pose)) 
+               return OPERATOR_CANCELLED;
+       arm= ob->data;
        
-       if(pose_has_protected_selected(ob, 0, 1))
-               return;
-       
-       for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
-               if(arm->layer & pchan->bone->layer) {
-                       if(pchan->bone->flag & (BONE_ACTIVE|BONE_SELECTED)) {
-                               BLI_strncpy(newname, pchan->name, 
sizeof(newname));
-                               bone_flip_name(newname, 1);     // 1 = do strip 
off number extensions
-                               ED_armature_bone_rename(arm, pchan->name, 
newname);
-                       }
-               }
+       /* loop through selected bones, auto-naming them */
+       CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans)
+       {
+               BLI_strncpy(newname, pchan->name, sizeof(newname));
+               bone_flip_name(newname, 1);     // 1 = do strip off number 
extensions
+               ED_armature_bone_rename(arm, pchan->name, newname);
        }
+       CTX_DATA_END;
        
-       BIF_undo_push("Flip names");
+       /* since we renamed stuff... */
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+
+       /* note, notifier might evolve */
+       WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+       
+       return OPERATOR_FINISHED;
 }
 
-/* context active object */
-void pose_autoside_names(Scene *scene, short axis)
+void POSE_OT_flip_names (wmOperatorType *ot)
 {
-       Object *obedit= scene->obedit; // XXX context
-       Object *ob= OBACT;
-       bArmature *arm= ob->data;
-       bPoseChannel *pchan;
+       /* identifiers */
+       ot->name= "Flip Names";
+       ot->idname= "POSE_OT_flip_names";
+       ot->description= "Flips (and corrects) the names of selected bones.";
+       
+       /* api callbacks */
+       ot->exec= pose_flip_names_exec;
+       ot->poll= ED_operator_posemode;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/* ------------------ */
+
+static int pose_autoside_names_exec (bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_active_object(C);
+       bArmature *arm;
        char newname[32];
+       short axis= RNA_enum_get(op->ptr, "axis");
        
        /* paranoia checks */
-       if (ELEM(NULL, ob, ob->pose)) return;

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to