Blender V2.61 - r43446

view3d_header.c

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version. 
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2004-2008 Blender Foundation.
00019  * All rights reserved.
00020  *
00021  * 
00022  * Contributor(s): Blender Foundation
00023  *
00024  * ***** END GPL LICENSE BLOCK *****
00025  */
00026 
00032 #include <string.h>
00033 #include <stdio.h>
00034 #include <stdlib.h>
00035 
00036 #include "DNA_scene_types.h"
00037 #include "DNA_object_types.h"
00038 
00039 #include "RNA_access.h"
00040 
00041 #include "MEM_guardedalloc.h"
00042 
00043 #include "BLI_math.h"
00044 #include "BLI_blenlib.h"
00045 #include "BLI_editVert.h"
00046 #include "BLI_utildefines.h"
00047 
00048 #include "BLF_translation.h"
00049 
00050 #include "BKE_context.h"
00051 #include "BKE_depsgraph.h"
00052 #include "BKE_effect.h"
00053 #include "BKE_main.h"
00054 #include "BKE_mesh.h"
00055 #include "BKE_modifier.h"
00056 #include "BKE_paint.h"
00057 #include "BKE_screen.h"
00058 
00059 #include "ED_mesh.h"
00060 #include "ED_util.h"
00061 #include "ED_screen.h"
00062 #include "ED_transform.h"
00063 #include "ED_types.h"
00064 
00065 #include "WM_api.h"
00066 #include "WM_types.h"
00067 
00068 #include "RNA_define.h"
00069 #include "RNA_enum_types.h"
00070 
00071 #include "UI_interface.h"
00072 #include "UI_resources.h"
00073 
00074 #include "view3d_intern.h"
00075 
00076 
00077 /* View3d->modeselect 
00078  * This is a bit of a dodgy hack to enable a 'mode' menu with icons+labels
00079  * rather than those buttons.
00080  * I know the implementation's not good - it's an experiment to see if this
00081  * approach would work well
00082  *
00083  * This can be cleaned when I make some new 'mode' icons.
00084  */
00085 
00086 /* view3d handler codes */
00087 #define VIEW3D_HANDLER_BACKGROUND   1
00088 #define VIEW3D_HANDLER_PROPERTIES   2
00089 #define VIEW3D_HANDLER_OBJECT       3
00090 #define VIEW3D_HANDLER_PREVIEW      4
00091 #define VIEW3D_HANDLER_MULTIRES         5
00092 #define VIEW3D_HANDLER_TRANSFORM    6
00093 #define VIEW3D_HANDLER_GREASEPENCIL 7
00094 #define VIEW3D_HANDLER_BONESKETCH   8
00095 
00096 /* end XXX ************* */
00097 
00098 static void do_view3d_header_buttons(bContext *C, void *arg, int event);
00099 
00100 #define B_SCENELOCK 101
00101 #define B_FULL      102
00102 #define B_HOME      103
00103 #define B_VIEWBUT   104
00104 #define B_PERSP     105
00105 #define B_MODESELECT 108
00106 #define B_SEL_VERT  110
00107 #define B_SEL_EDGE  111
00108 #define B_SEL_FACE  112
00109 #define B_MAN_TRANS 116
00110 #define B_MAN_ROT   117
00111 #define B_MAN_SCALE 118
00112 #define B_NDOF      119 
00113 #define B_MAN_MODE  120
00114 #define B_REDR      122
00115 #define B_NOP       123
00116 
00117 // XXX quickly ported across
00118 static void handle_view3d_lock(bContext *C) 
00119 {
00120     Main *bmain= CTX_data_main(C);
00121     Scene *scene= CTX_data_scene(C);
00122     ScrArea *sa= CTX_wm_area(C);
00123     View3D *v3d= CTX_wm_view3d(C);
00124     
00125     if (v3d != NULL && sa != NULL) {
00126         if(v3d->localvd==NULL && v3d->scenelock && sa->spacetype==SPACE_VIEW3D) {
00127             /* copy to scene */
00128             scene->lay= v3d->lay;
00129             scene->layact= v3d->layact;
00130             scene->camera= v3d->camera;
00131 
00132             /* not through notifiery, listener don't have context
00133                and non-open screens or spaces need to be updated too */
00134             BKE_screen_view3d_main_sync(&bmain->screen, scene);
00135             
00136             /* notifiers for scene update */
00137             WM_event_add_notifier(C, NC_SCENE|ND_LAYER, scene);
00138         }
00139     }
00140 }
00141 
00142 /* layer code is on three levels actually:
00143 - here for operator
00144 - uiTemplateLayers in interface/ code for buttons
00145 - ED_view3d_scene_layer_set for RNA
00146  */
00147 static void view3d_layers_editmode_ensure(Scene *scene, View3D *v3d)
00148 {
00149     /* sanity check - when in editmode disallow switching the editmode layer off since its confusing
00150      * an alternative would be to always draw the editmode object. */
00151     if(scene->obedit && (scene->obedit->lay & v3d->lay)==0) {
00152         int bit;
00153         for(bit=0; bit<32; bit++) {
00154             if(scene->obedit->lay & (1<<bit)) {
00155                 v3d->lay |= 1<<bit;
00156                 break;
00157             }
00158         }
00159     }
00160 }
00161 
00162 static int view3d_layers_exec(bContext *C, wmOperator *op)
00163 {
00164     Scene *scene= CTX_data_scene(C);
00165     ScrArea *sa= CTX_wm_area(C);
00166     View3D *v3d= sa->spacedata.first;
00167     int nr= RNA_int_get(op->ptr, "nr");
00168     int toggle= RNA_boolean_get(op->ptr, "toggle");
00169     
00170     if(nr < 0)
00171         return OPERATOR_CANCELLED;
00172 
00173     if(nr == 0) {
00174         /* all layers */
00175         if(!v3d->layact)
00176             v3d->layact= 1;
00177 
00178         if (toggle && v3d->lay == ((1<<20)-1)) {
00179             /* return to active layer only */
00180             v3d->lay = v3d->layact;
00181 
00182             view3d_layers_editmode_ensure(scene, v3d);
00183         }
00184         else {
00185             v3d->lay |= (1<<20)-1;
00186         }       
00187     }
00188     else {
00189         int bit;
00190         nr--;
00191 
00192         if(RNA_boolean_get(op->ptr, "extend")) {
00193             if(toggle && v3d->lay & (1<<nr) && (v3d->lay & ~(1<<nr)))
00194                 v3d->lay &= ~(1<<nr);
00195             else
00196                 v3d->lay |= (1<<nr);
00197         } else {
00198             v3d->lay = (1<<nr);
00199         }
00200 
00201         view3d_layers_editmode_ensure(scene, v3d);
00202 
00203         /* set active layer, ensure to always have one */
00204         if(v3d->lay & (1<<nr))
00205            v3d->layact= 1<<nr;
00206         else if((v3d->lay & v3d->layact)==0) {
00207             for(bit=0; bit<32; bit++) {
00208                 if(v3d->lay & (1<<bit)) {
00209                     v3d->layact= 1<<bit;
00210                     break;
00211                 }
00212             }
00213         }
00214     }
00215     
00216     if(v3d->scenelock) handle_view3d_lock(C);
00217     
00218     DAG_on_visible_update(CTX_data_main(C), FALSE);
00219 
00220     ED_area_tag_redraw(sa);
00221     
00222     return OPERATOR_FINISHED;
00223 }
00224 
00225 /* applies shift and alt, lazy coding or ok? :) */
00226 /* the local per-keymap-entry keymap will solve it */
00227 static int view3d_layers_invoke(bContext *C, wmOperator *op, wmEvent *event)
00228 {
00229     if(event->ctrl || event->oskey)
00230         return OPERATOR_PASS_THROUGH;
00231     
00232     if(event->shift)
00233         RNA_boolean_set(op->ptr, "extend", TRUE);
00234     
00235     if(event->alt) {
00236         int nr= RNA_int_get(op->ptr, "nr") + 10;
00237         RNA_int_set(op->ptr, "nr", nr);
00238     }
00239     view3d_layers_exec(C, op);
00240     
00241     return OPERATOR_FINISHED;
00242 }
00243 
00244 static int view3d_layers_poll(bContext *C)
00245 {
00246     return (ED_operator_view3d_active(C) && CTX_wm_view3d(C)->localvd==NULL);
00247 }
00248 
00249 void VIEW3D_OT_layers(wmOperatorType *ot)
00250 {
00251     /* identifiers */
00252     ot->name= "Layers";
00253     ot->description= "Toggle layer(s) visibility";
00254     ot->idname= "VIEW3D_OT_layers";
00255     
00256     /* api callbacks */
00257     ot->invoke= view3d_layers_invoke;
00258     ot->exec= view3d_layers_exec;
00259     ot->poll= view3d_layers_poll;
00260     
00261     /* flags */
00262     ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
00263     
00264     RNA_def_int(ot->srna, "nr", 1, 0, 20, "Number", "The layer number to set, zero for all layers", 0, 20);
00265     RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Add this layer to the current view layers");
00266     RNA_def_boolean(ot->srna, "toggle", 1, "Toggle", "Toggle the layer");
00267 }
00268 
00269 static int modeselect_addmode(char *str, const char *title, int id, int icon)
00270 {
00271     static char formatstr[] = "|%s %%x%d %%i%d";
00272 
00273     return sprintf(str, formatstr, IFACE_(title), id, icon);
00274 }
00275 
00276 static char *view3d_modeselect_pup(Scene *scene)
00277 {
00278     Object *ob= OBACT;
00279     static char string[512];
00280     const char *title= IFACE_("Mode: %t");
00281     char *str = string;
00282 
00283     BLI_strncpy(str, title, sizeof(string));
00284 
00285     str += modeselect_addmode(str, N_("Object Mode"), OB_MODE_OBJECT, ICON_OBJECT_DATA);
00286 
00287     if(ob==NULL || ob->data==NULL) return string;
00288     if(ob->id.lib) return string;
00289 
00290     if(!((ID *)ob->data)->lib) {
00291         /* if active object is editable */
00292         if ( ((ob->type == OB_MESH)
00293             || (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT)
00294             || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) {
00295 
00296             str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT, ICON_EDITMODE_HLT);
00297         }
00298         else if (ob->type == OB_ARMATURE) {
00299             if (ob->mode & OB_MODE_POSE)
00300                 str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT|OB_MODE_POSE, ICON_EDITMODE_HLT);
00301             else
00302                 str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT, ICON_EDITMODE_HLT);
00303         }
00304 
00305         if (ob->type == OB_MESH) {
00306 
00307             str += modeselect_addmode(str, N_("Sculpt Mode"), OB_MODE_SCULPT, ICON_SCULPTMODE_HLT);
00308             str += modeselect_addmode(str, N_("Vertex Paint"), OB_MODE_VERTEX_PAINT, ICON_VPAINT_HLT);
00309             str += modeselect_addmode(str, N_("Texture Paint"), OB_MODE_TEXTURE_PAINT, ICON_TPAINT_HLT);
00310             str += modeselect_addmode(str, N_("Weight Paint"), OB_MODE_WEIGHT_PAINT, ICON_WPAINT_HLT);
00311         }
00312     }
00313 
00314     /* if active object is an armature */
00315     if (ob->type==OB_ARMATURE) {
00316         str += modeselect_addmode(str, N_("Pose Mode"), OB_MODE_POSE, ICON_POSE_HLT);
00317     }
00318 
00319     if ( ob->particlesystem.first ||
00320          modifiers_findByType(ob, eModifierType_Cloth) ||
00321          modifiers_findByType(ob, eModifierType_Softbody))
00322     {
00323         str += modeselect_addmode(str, N_("Particle Mode"), OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE);
00324     }
00325     (void)str;
00326     return (string);
00327 }
00328 
00329 
00330 static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
00331 {
00332     wmWindow *win= CTX_wm_window(C);
00333     ToolSettings *ts= CTX_data_tool_settings(C);
00334     ScrArea *sa= CTX_wm_area(C);
00335     View3D *v3d= sa->spacedata.first;
00336     Object *obedit = CTX_data_edit_object(C);
00337     EditMesh *em= NULL;
00338     int ctrl= win->eventstate->ctrl, shift= win->eventstate->shift;
00339     PointerRNA props_ptr;
00340     
00341     if(obedit && obedit->type==OB_MESH) {
00342         em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
00343     }
00344     /* watch it: if sa->win does not exist, check that when calling direct drawing routines */
00345 
00346     switch(event) {
00347     case B_REDR:
00348         ED_area_tag_redraw(sa);
00349         break;
00350         
00351     case B_MODESELECT:
00352         WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set");
00353         RNA_enum_set(&props_ptr, "mode", v3d->modeselect);
00354         WM_operator_name_call(C, "OBJECT_OT_mode_set", WM_OP_EXEC_REGION_WIN, &props_ptr);
00355         WM_operator_properties_free(&props_ptr);
00356         break;      
00357         
00358     case B_SEL_VERT:
00359         if(em) {
00360             if(shift==0 || em->selectmode==0)
00361                 em->selectmode= SCE_SELECT_VERTEX;
00362             ts->selectmode= em->selectmode;
00363             EM_selectmode_set(em);
00364             WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
00365             ED_undo_push(C, "Selectmode Set: Vertex");
00366         }
00367         break;
00368     case B_SEL_EDGE:
00369         if(em) {
00370             if(shift==0 || em->selectmode==0){
00371                 if( (em->selectmode ^ SCE_SELECT_EDGE) == SCE_SELECT_VERTEX){
00372                     if(ctrl) EM_convertsel(em, SCE_SELECT_VERTEX,SCE_SELECT_EDGE); 
00373                 }
00374                 em->selectmode = SCE_SELECT_EDGE;
00375             }
00376             ts->selectmode= em->selectmode;
00377             EM_selectmode_set(em);
00378             WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
00379             ED_undo_push(C, "Selectmode Set: Edge");
00380         }
00381         break;
00382     case B_SEL_FACE:
00383         if(em) {
00384             if( shift==0 || em->selectmode==0){
00385                 if( ((em->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_VERTEX) || ((em->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_EDGE)){
00386                     if(ctrl)
00387                         EM_convertsel(em, (em->selectmode ^ SCE_SELECT_FACE),SCE_SELECT_FACE);
00388                 }
00389                 em->selectmode = SCE_SELECT_FACE;
00390             }
00391             ts->selectmode= em->selectmode;
00392             EM_selectmode_set(em);
00393             WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
00394             ED_undo_push(C, "Selectmode Set: Face");
00395         }
00396         break;  
00397 
00398     case B_MAN_TRANS:
00399         if( shift==0 || v3d->twtype==0) {
00400             v3d->twtype= V3D_MANIP_TRANSLATE;
00401         }
00402         ED_area_tag_redraw(sa);
00403         break;
00404     case B_MAN_ROT:
00405         if( shift==0 || v3d->twtype==0) {
00406             v3d->twtype= V3D_MANIP_ROTATE;
00407         }
00408         ED_area_tag_redraw(sa);
00409         break;
00410     case B_MAN_SCALE:
00411         if( shift==0 || v3d->twtype==0) {
00412             v3d->twtype= V3D_MANIP_SCALE;
00413         }
00414         ED_area_tag_redraw(sa);
00415         break;
00416     case B_NDOF:
00417         ED_area_tag_redraw(sa);
00418         break;
00419     case B_MAN_MODE:
00420         ED_area_tag_redraw(sa);
00421         break;
00422     default:
00423         break;
00424     }
00425 
00426     if(obedit && obedit->type==OB_MESH)
00427         BKE_mesh_end_editmesh(obedit->data, em);
00428 }
00429 
00430 /* Returns the icon associated with an object mode */
00431 static int object_mode_icon(int mode)
00432 {
00433     EnumPropertyItem *item = object_mode_items;
00434     
00435     while(item->name != NULL) {
00436         if(item->value == mode)
00437             return item->icon;
00438         ++item;
00439     }
00440 
00441     return ICON_OBJECT_DATAMODE;
00442 }
00443 
00444 void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C)
00445 {
00446     Object *obedit = CTX_data_edit_object(C);
00447     uiBlock *block= uiLayoutGetBlock(layout);
00448 
00449     uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL);
00450 
00451     if(obedit && (obedit->type == OB_MESH)) {
00452         EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
00453         uiLayout *row;
00454 
00455         row= uiLayoutRow(layout, 1);
00456         block= uiLayoutGetBlock(row);
00457         uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, 0,0,UI_UNIT_X,UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode");
00458         uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, 0,0,UI_UNIT_X,UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Edge select mode");
00459         uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, 0,0,UI_UNIT_X,UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Face select mode");
00460 
00461         BKE_mesh_end_editmesh(obedit->data, em);
00462     }
00463 }
00464 
00465 void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
00466 {
00467     bScreen *screen= CTX_wm_screen(C);
00468     ScrArea *sa= CTX_wm_area(C);
00469     View3D *v3d= sa->spacedata.first;
00470     Scene *scene= CTX_data_scene(C);
00471     ToolSettings *ts= CTX_data_tool_settings(C);
00472     PointerRNA v3dptr, toolsptr, sceneptr;
00473     Object *ob= OBACT;
00474     Object *obedit = CTX_data_edit_object(C);
00475     uiBlock *block;
00476     uiBut *but;
00477     uiLayout *row;
00478     const float dpi_fac= UI_DPI_FAC;
00479     
00480     RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr);    
00481     RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &toolsptr);
00482     RNA_pointer_create(&scene->id, &RNA_Scene, scene, &sceneptr);
00483 
00484     block= uiLayoutGetBlock(layout);
00485     uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL);
00486 
00487     /* other buttons: */
00488     uiBlockSetEmboss(block, UI_EMBOSS);
00489     
00490     /* mode */
00491     if(ob) {
00492         v3d->modeselect = ob->mode;
00493     }
00494     else {
00495         v3d->modeselect = OB_MODE_OBJECT;
00496     }
00497 
00498     row= uiLayoutRow(layout, 1);
00499     uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene) , 
00500               0,0,126 * dpi_fac, UI_UNIT_Y, &(v3d->modeselect), 0, 0, 0, 0, TIP_("Mode"));
00501     
00502     /* Draw type */
00503     uiItemR(layout, &v3dptr, "viewport_shade", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
00504 
00505     if (obedit==NULL && ((ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)))) {
00506         /* Manipulators aren't used in weight paint mode */
00507         
00508         PointerRNA meshptr;
00509 
00510         RNA_pointer_create(&ob->id, &RNA_Mesh, ob->data, &meshptr);
00511         if(ob->mode & (OB_MODE_TEXTURE_PAINT|OB_MODE_VERTEX_PAINT)) {
00512             uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
00513         }
00514         else {
00515             
00516             row= uiLayoutRow(layout, 1);
00517             uiItemR(row, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
00518             uiItemR(row, &meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
00519         }
00520     } else {
00521         const char *str_menu;
00522 
00523         row= uiLayoutRow(layout, 1);
00524         uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
00525 
00526         /* pose/object only however we want to allow in weight paint mode too
00527          * so dont be totally strict and just check not-editmode for now */
00528         if (obedit == NULL) {
00529             uiItemR(row, &v3dptr, "use_pivot_point_align", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
00530         }
00531 
00532         /* Transform widget / manipulators */
00533         row= uiLayoutRow(layout, 1);
00534         uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
00535         block= uiLayoutGetBlock(row);
00536         
00537         if(v3d->twflag & V3D_USE_MANIPULATOR) {
00538             but= uiDefIconButBitC(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_("Translate manipulator mode"));
00539             uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
00540             but= uiDefIconButBitC(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_("Rotate manipulator mode"));
00541             uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
00542             but= uiDefIconButBitC(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_("Scale manipulator mode"));
00543             uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
00544         }
00545             
00546         if (v3d->twmode > (BIF_countTransformOrientation(C) - 1) + V3D_MANIP_CUSTOM) {
00547             v3d->twmode = 0;
00548         }
00549             
00550         str_menu = BIF_menustringTransformOrientation(C, "Orientation");
00551         but= uiDefButC(block, MENU, B_MAN_MODE, str_menu,0,0,70 * dpi_fac, UI_UNIT_Y, &v3d->twmode, 0, 0, 0, 0, TIP_("Transform Orientation"));
00552         uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
00553         MEM_freeN((void *)str_menu);
00554     }
00555 
00556     if(obedit==NULL && v3d->localvd==NULL) {
00557         unsigned int ob_lay = ob ? ob->lay : 0;
00558 
00559         /* Layers */
00560         uiTemplateLayers(layout, v3d->scenelock ? &sceneptr : &v3dptr, "layers", &v3dptr, "layers_used", ob_lay);
00561 
00562         /* Scene lock */
00563         uiItemR(layout, &v3dptr, "lock_camera_and_layers", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
00564     }
00565     
00566     uiTemplateEditModeSelection(layout, C);
00567 }