moved the following into the screen context rather then the view3d context so python...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 29 Oct 2009 19:59:38 +0000 (19:59 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 29 Oct 2009 19:59:38 +0000 (19:59 +0000)
 "visible_bones", "editable_bones", "selected_bones", "selected_editable_bones", "visible_pchans", "selected_pchans", "active_bone", "active_pchan",

added "C" to the consoles namespace, temp hack but useful

release/scripts/ui/space_console.py
source/blender/editors/animation/keyingsets.c
source/blender/editors/screen/screen_context.c
source/blender/editors/space_view3d/space_view3d.c

index 5bb211f7d9820b2efc18a22e210a0f0678817eb5..19024977992032f9d5ffc21e3ba9d1488a63a76d 100644 (file)
@@ -133,6 +133,7 @@ class CONSOLE_OT_exec(bpy.types.Operator):
                        return ('CANCELLED',)
                
                namespace, console, stdout, stderr = get_console(hash(context.region))
+               namespace['C'] = context
                
                # redirect output
                sys.stdout = stdout
index 97b64cb36c9aee10eccf1ce4de3623e2fa4feb13..0f4f29d009183db3dbfdf410c5f4d6473c8ba06d 100644 (file)
@@ -1267,7 +1267,8 @@ short modifykey_get_context_data (bContext *C, ListBase *dsources, KeyingSet *ks
        /* for now, the active area is used to determine what set of contexts apply */
        if (sa == NULL)
                return 0;
-               
+
+#if 0
        switch (sa->spacetype) {
                case SPACE_VIEW3D:      /* 3D-View: Selected Objects or Bones */
                        return modifykey_get_context_v3d_data(C, dsources, ks);
@@ -1275,6 +1276,10 @@ short modifykey_get_context_data (bContext *C, ListBase *dsources, KeyingSet *ks
        
        /* nothing happened */
        return 0;
+#endif
+
+       /* looking into this code, it doesnt use the 3D view - Campbell */
+       return modifykey_get_context_v3d_data(C, dsources, ks);
 } 
 
 /* KeyingSet Operations (Insert/Delete Keyframes) ------------ */
index e573ef062478768e166bfbdda65fd04d568b3e65..4f08ffb5c7bb382d5b874a2260519c09611ffa37 100644 (file)
 #include <string.h>
 
 #include "DNA_object_types.h"
+#include "DNA_armature_types.h"
+#include "DNA_action_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 
 #include "BKE_context.h"
 #include "BKE_utildefines.h"
 #include "BKE_global.h"
+#include "BKE_action.h"
 
 #include "RNA_access.h"
 
 #include "ED_object.h"
+#include "ED_armature.h"
 
 int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result)
 {
@@ -53,6 +57,8 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
                static const char *dir[] = {
                        "scene", "selected_objects", "selected_bases",
                        "selected_editable_objects", "selected_editable_bases",
+                       "visible_bones", "editable_bones", "selected_bones", "selected_editable_bones",
+                       "visible_pchans", "selected_pchans", "active_bone", "active_pchan",
                        "active_base", "active_object", "edit_object",
                        "sculpt_object", "vertex_paint_object", "weight_paint_object",
                        "texture_paint_object", "brush", "particle_edit_object", NULL};
@@ -96,6 +102,153 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
 
                return 1;
        }
+       else if(CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) {
+               Object *obedit= scene->obedit; // XXX get from context?
+               bArmature *arm= (obedit) ? obedit->data : NULL;
+               EditBone *ebone, *flipbone=NULL;
+               int editable_bones= CTX_data_equals(member, "editable_bones");
+               
+               if (arm && arm->edbo) {
+                       /* Attention: X-Axis Mirroring is also handled here... */
+                       for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
+                               /* first and foremost, bone must be visible and selected */
+                               if (EBONE_VISIBLE(arm, ebone)) {
+                                       /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
+                                        * so that most users of this data don't need to explicitly check for it themselves.
+                                        * 
+                                        * We need to make sure that these mirrored copies are not selected, otherwise some
+                                        * bones will be operated on twice.
+                                        */
+                                       if (arm->flag & ARM_MIRROR_EDIT)
+                                               flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
+                                       
+                                       /* if we're filtering for editable too, use the check for that instead, as it has selection check too */
+                                       if (editable_bones) {
+                                               /* only selected + editable */
+                                               if (EBONE_EDITABLE(ebone)) {
+                                                       CTX_data_list_add(result, &arm->id, &RNA_UnknownType, ebone);
+                                               
+                                                       if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
+                                                               CTX_data_list_add(result, &arm->id, &RNA_UnknownType, flipbone);
+                                               }
+                                       }
+                                       else {
+                                               /* only include bones if visible */
+                                               CTX_data_list_add(result, &arm->id, &RNA_UnknownType, ebone);
+                                               
+                                               if ((flipbone) && EBONE_VISIBLE(arm, flipbone)==0)
+                                                       CTX_data_list_add(result, &arm->id, &RNA_UnknownType, flipbone);
+                                       }
+                               }
+                       }       
+                       
+                       return 1;
+               }
+       }
+       else if(CTX_data_equals(member, "selected_bones") || CTX_data_equals(member, "selected_editable_bones")) {
+               Object *obedit= scene->obedit; // XXX get from context?
+               bArmature *arm= (obedit) ? obedit->data : NULL;
+               EditBone *ebone, *flipbone=NULL;
+               int selected_editable_bones= CTX_data_equals(member, "selected_editable_bones");
+               
+               if (arm && arm->edbo) {
+                       /* Attention: X-Axis Mirroring is also handled here... */
+                       for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
+                               /* first and foremost, bone must be visible and selected */
+                               if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) {
+                                       /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
+                                        * so that most users of this data don't need to explicitly check for it themselves.
+                                        * 
+                                        * We need to make sure that these mirrored copies are not selected, otherwise some
+                                        * bones will be operated on twice.
+                                        */
+                                       if (arm->flag & ARM_MIRROR_EDIT)
+                                               flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
+                                       
+                                       /* if we're filtering for editable too, use the check for that instead, as it has selection check too */
+                                       if (selected_editable_bones) {
+                                               /* only selected + editable */
+                                               if (EBONE_EDITABLE(ebone)) {
+                                                       CTX_data_list_add(result, &arm->id, &RNA_UnknownType, ebone);
+                                               
+                                                       if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
+                                                               CTX_data_list_add(result, &arm->id, &RNA_UnknownType, flipbone);
+                                               }
+                                       }
+                                       else {
+                                               /* only include bones if selected */
+                                               CTX_data_list_add(result, &arm->id, &RNA_UnknownType, ebone);
+                                               
+                                               if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
+                                                       CTX_data_list_add(result, &arm->id, &RNA_UnknownType, flipbone);
+                                       }
+                               }
+                       }       
+                       
+                       return 1;
+               }
+       }
+       else if(CTX_data_equals(member, "visible_pchans")) {
+               Object *obact= OBACT;
+               bArmature *arm= (obact) ? obact->data : NULL;
+               bPoseChannel *pchan;
+               
+               if (obact && arm) {
+                       for (pchan= obact->pose->chanbase.first; pchan; pchan= pchan->next) {
+                               /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
+                               if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
+                                       CTX_data_list_add(result, &obact->id, &RNA_PoseChannel, pchan);
+                               }
+                       }
+                       
+                       return 1;
+               }
+       }
+       else if(CTX_data_equals(member, "selected_pchans")) {
+               Object *obact= OBACT;
+               bArmature *arm= (obact) ? obact->data : NULL;
+               bPoseChannel *pchan;
+               
+               if (obact && arm) {
+                       for (pchan= obact->pose->chanbase.first; pchan; pchan= pchan->next) {
+                               /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
+                               if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
+                                       if (pchan->bone->flag & (BONE_SELECTED|BONE_ACTIVE)) 
+                                               CTX_data_list_add(result, &obact->id, &RNA_PoseChannel, pchan);
+                               }
+                       }
+                       
+                       return 1;
+               }
+       }
+       else if(CTX_data_equals(member, "active_bone")) {
+               Object *obedit= scene->obedit; // XXX get from context?
+               bArmature *arm= (obedit) ? obedit->data : NULL;
+               EditBone *ebone;
+               
+               if (arm && arm->edbo) {
+                       for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
+                               if (EBONE_VISIBLE(arm, ebone)) {
+                                       if (ebone->flag & BONE_ACTIVE) {
+                                               CTX_data_pointer_set(result, &arm->id, &RNA_UnknownType, ebone);
+                                               
+                                               return 1;
+                                       }
+                               }
+                       }
+               }
+               
+       }
+       else if(CTX_data_equals(member, "active_pchan")) {
+               Object *obact= OBACT;
+               bPoseChannel *pchan;
+               
+               pchan= get_active_posechannel(obact);
+               if (pchan) {
+                       CTX_data_pointer_set(result, &obact->id, &RNA_PoseChannel, pchan);
+                       return 1;
+               }
+       }
        else if(CTX_data_equals(member, "active_base")) {
                if(scene->basact)
                        CTX_data_pointer_set(result, &scene->id, &RNA_UnknownType, scene->basact);
index ae0c73e71cc2967f4b6e158bff7b06a1227e5fff..4a9042aa31c90d1324a8d27ab93e52aab35b2f60 100644 (file)
@@ -663,9 +663,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                static const char *dir[] = {
                        "selected_objects", "selected_bases", "selected_editable_objects",
                        "selected_editable_bases", "visible_objects", "visible_bases", "selectable_objects", "selectable_bases",
-                       "active_base", "active_object", "visible_bones", "editable_bones",
-                       "selected_bones", "selected_editable_bones", "visible_pchans",
-                       "selected_pchans", "active_bone", "active_pchan", NULL};
+                       "active_base", "active_object", NULL};
 
                CTX_data_dir_set(result, dir);
        }
@@ -749,154 +747,6 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                
                return 1;
        }
-       else if(CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) {
-               Object *obedit= scene->obedit; // XXX get from context?
-               bArmature *arm= (obedit) ? obedit->data : NULL;
-               EditBone *ebone, *flipbone=NULL;
-               int editable_bones= CTX_data_equals(member, "editable_bones");
-               
-               if (arm && arm->edbo) {
-                       /* Attention: X-Axis Mirroring is also handled here... */
-                       for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
-                               /* first and foremost, bone must be visible and selected */
-                               if (EBONE_VISIBLE(arm, ebone)) {
-                                       /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
-                                        * so that most users of this data don't need to explicitly check for it themselves.
-                                        * 
-                                        * We need to make sure that these mirrored copies are not selected, otherwise some
-                                        * bones will be operated on twice.
-                                        */
-                                       if (arm->flag & ARM_MIRROR_EDIT)
-                                               flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
-                                       
-                                       /* if we're filtering for editable too, use the check for that instead, as it has selection check too */
-                                       if (editable_bones) {
-                                               /* only selected + editable */
-                                               if (EBONE_EDITABLE(ebone)) {
-                                                       CTX_data_list_add(result, &arm->id, &RNA_UnknownType, ebone);
-                                               
-                                                       if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
-                                                               CTX_data_list_add(result, &arm->id, &RNA_UnknownType, flipbone);
-                                               }
-                                       }
-                                       else {
-                                               /* only include bones if visible */
-                                               CTX_data_list_add(result, &arm->id, &RNA_UnknownType, ebone);
-                                               
-                                               if ((flipbone) && EBONE_VISIBLE(arm, flipbone)==0)
-                                                       CTX_data_list_add(result, &arm->id, &RNA_UnknownType, flipbone);
-                                       }
-                               }
-                       }       
-                       
-                       return 1;
-               }
-       }
-       else if(CTX_data_equals(member, "selected_bones") || CTX_data_equals(member, "selected_editable_bones")) {
-               Object *obedit= scene->obedit; // XXX get from context?
-               bArmature *arm= (obedit) ? obedit->data : NULL;
-               EditBone *ebone, *flipbone=NULL;
-               int selected_editable_bones= CTX_data_equals(member, "selected_editable_bones");
-               
-               if (arm && arm->edbo) {
-                       /* Attention: X-Axis Mirroring is also handled here... */
-                       for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
-                               /* first and foremost, bone must be visible and selected */
-                               if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) {
-                                       /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
-                                        * so that most users of this data don't need to explicitly check for it themselves.
-                                        * 
-                                        * We need to make sure that these mirrored copies are not selected, otherwise some
-                                        * bones will be operated on twice.
-                                        */
-                                       if (arm->flag & ARM_MIRROR_EDIT)
-                                               flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
-                                       
-                                       /* if we're filtering for editable too, use the check for that instead, as it has selection check too */
-                                       if (selected_editable_bones) {
-                                               /* only selected + editable */
-                                               if (EBONE_EDITABLE(ebone)) {
-                                                       CTX_data_list_add(result, &arm->id, &RNA_UnknownType, ebone);
-                                               
-                                                       if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
-                                                               CTX_data_list_add(result, &arm->id, &RNA_UnknownType, flipbone);
-                                               }
-                                       }
-                                       else {
-                                               /* only include bones if selected */
-                                               CTX_data_list_add(result, &arm->id, &RNA_UnknownType, ebone);
-                                               
-                                               if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
-                                                       CTX_data_list_add(result, &arm->id, &RNA_UnknownType, flipbone);
-                                       }
-                               }
-                       }       
-                       
-                       return 1;
-               }
-       }
-       else if(CTX_data_equals(member, "visible_pchans")) {
-               Object *obact= OBACT;
-               bArmature *arm= (obact) ? obact->data : NULL;
-               bPoseChannel *pchan;
-               
-               if (obact && arm) {
-                       for (pchan= obact->pose->chanbase.first; pchan; pchan= pchan->next) {
-                               /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
-                               if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
-                                       CTX_data_list_add(result, &obact->id, &RNA_PoseChannel, pchan);
-                               }
-                       }
-                       
-                       return 1;
-               }
-       }
-       else if(CTX_data_equals(member, "selected_pchans")) {
-               Object *obact= OBACT;
-               bArmature *arm= (obact) ? obact->data : NULL;
-               bPoseChannel *pchan;
-               
-               if (obact && arm) {
-                       for (pchan= obact->pose->chanbase.first; pchan; pchan= pchan->next) {
-                               /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
-                               if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
-                                       if (pchan->bone->flag & (BONE_SELECTED|BONE_ACTIVE)) 
-                                               CTX_data_list_add(result, &obact->id, &RNA_PoseChannel, pchan);
-                               }
-                       }
-                       
-                       return 1;
-               }
-       }
-       else if(CTX_data_equals(member, "active_bone")) {
-               Object *obedit= scene->obedit; // XXX get from context?
-               bArmature *arm= (obedit) ? obedit->data : NULL;
-               EditBone *ebone;
-               
-               if (arm && arm->edbo) {
-                       for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
-                               if (EBONE_VISIBLE(arm, ebone)) {
-                                       if (ebone->flag & BONE_ACTIVE) {
-                                               CTX_data_pointer_set(result, &arm->id, &RNA_UnknownType, ebone);
-                                               
-                                               return 1;
-                                       }
-                               }
-                       }
-               }
-               
-       }
-       else if(CTX_data_equals(member, "active_pchan")) {
-               Object *obact= OBACT;
-               bPoseChannel *pchan;
-               
-               pchan= get_active_posechannel(obact);
-               if (pchan) {
-                       CTX_data_pointer_set(result, &obact->id, &RNA_PoseChannel, pchan);
-                       return 1;
-               }
-       }
-
        return 0;
 }