4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2008 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Blender Foundation
26 * ***** END GPL LICENSE BLOCK *****
32 #include "MEM_guardedalloc.h"
34 #include "DNA_curve_types.h"
35 #include "DNA_mesh_types.h"
36 #include "DNA_object_types.h"
37 #include "DNA_scene_types.h"
38 #include "DNA_userdef_types.h"
40 #include "BLI_blenlib.h"
41 #include "BLI_editVert.h"
43 #include "BKE_context.h"
44 #include "BKE_global.h"
47 #include "ED_armature.h"
49 #include "ED_sculpt.h"
52 #include "UI_interface.h"
54 /* ********* general editor util funcs, not BKE stuff please! ********* */
56 /* frees all editmode stuff */
57 void ED_editors_exit(bContext *C)
61 /* frees all editmode undos */
62 undo_editmode_clear();
63 undo_imagepaint_clear();
65 for(sce=G.main->scene.first; sce; sce= sce->id.next) {
67 Object *ob= sce->obedit;
69 /* global in meshtools... */
70 mesh_octree_table(ob, NULL, NULL, 'e');
73 if(ob->type==OB_MESH) {
76 free_editMesh(me->edit_mesh);
77 MEM_freeN(me->edit_mesh);
81 else if(ob->type==OB_ARMATURE) {
82 ED_armature_edit_free(ob);
84 else if(ob->type==OB_FONT) {
87 // else if(ob->type==OB_MBALL)
88 // BLI_freelistN(&editelems);
98 /* ***** XXX: functions are using old blender names, cleanup later ***** */
101 /* now only used in 2d spaces, like time, ipo, nla, sima... */
102 /* XXX shift/ctrl not configurable */
103 void apply_keyb_grid(int shift, int ctrl, float *val, float fac1, float fac2, float fac3, int invert)
105 /* fac1 is for 'nothing', fac2 for CTRL, fac3 for SHIFT */
110 if(fac3!= 0.0) *val= fac3*floor(*val/fac3 +.5);
113 if(fac2!= 0.0) *val= fac2*floor(*val/fac2 +.5);
116 if(fac1!= 0.0) *val= fac1*floor(*val/fac1 +.5);
121 int GetButStringLength(char *str)
125 rt= UI_GetStringWidth(str);