doxygen: add newline after \file
[blender.git] / source / blender / bmesh / intern / bmesh_marking.h
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16
17 #ifndef __BMESH_MARKING_H__
18 #define __BMESH_MARKING_H__
19
20 /** \file
21  * \ingroup bmesh
22  */
23
24 typedef struct BMEditSelection {
25         struct BMEditSelection *next, *prev;
26         BMElem *ele;
27         char htype;
28 } BMEditSelection;
29
30 /* geometry hiding code */
31 #define BM_elem_hide_set(bm, ele, hide) _bm_elem_hide_set(bm, &(ele)->head, hide)
32 void _bm_elem_hide_set(BMesh *bm, BMHeader *ele, const bool hide);
33 void BM_vert_hide_set(BMVert *v, const bool hide);
34 void BM_edge_hide_set(BMEdge *e, const bool hide);
35 void BM_face_hide_set(BMFace *f, const bool hide);
36
37 /* Selection code */
38 void BM_elem_select_set(BMesh *bm, BMElem *ele, const bool select);
39
40 void BM_mesh_elem_hflag_enable_test(
41         BMesh *bm, const char htype, const char hflag,
42         const bool respecthide, const bool overwrite, const char hflag_test);
43 void BM_mesh_elem_hflag_disable_test(
44         BMesh *bm, const char htype, const char hflag,
45         const bool respecthide, const bool overwrite, const char hflag_test);
46
47 void BM_mesh_elem_hflag_enable_all(
48         BMesh *bm, const char htype, const char hflag,
49         const bool respecthide);
50 void BM_mesh_elem_hflag_disable_all(
51         BMesh *bm, const char htype, const char hflag,
52         const bool respecthide);
53
54 /* individual element select functions, BM_elem_select_set is a shortcut for these
55  * that automatically detects which one to use*/
56 void BM_vert_select_set(BMesh *bm, BMVert *v, const bool select);
57 void BM_edge_select_set(BMesh *bm, BMEdge *e, const bool select);
58 void BM_face_select_set(BMesh *bm, BMFace *f, const bool select);
59
60 /* lower level functions which don't do flushing */
61 void BM_edge_select_set_noflush(BMesh *bm, BMEdge *e, const bool select);
62 void BM_face_select_set_noflush(BMesh *bm, BMFace *e, const bool select);
63
64 void BM_mesh_select_mode_clean_ex(BMesh *bm, const short selectmode);
65 void BM_mesh_select_mode_clean(BMesh *bm);
66
67 void BM_mesh_select_mode_set(BMesh *bm, int selectmode);
68 void BM_mesh_select_mode_flush_ex(BMesh *bm, const short selectmode);
69 void BM_mesh_select_mode_flush(BMesh *bm);
70
71 void BM_mesh_deselect_flush(BMesh *bm);
72 void BM_mesh_select_flush(BMesh *bm);
73
74 int BM_mesh_elem_hflag_count_enabled(BMesh *bm, const char htype, const char hflag, const bool respecthide);
75 int BM_mesh_elem_hflag_count_disabled(BMesh *bm, const char htype, const char hflag, const bool respecthide);
76
77 /* edit selection stuff */
78 void    BM_mesh_active_face_set(BMesh *bm, BMFace *f);
79 BMFace *BM_mesh_active_face_get(BMesh *bm, const bool is_sloppy, const bool is_selected);
80 BMEdge *BM_mesh_active_edge_get(BMesh *bm);
81 BMVert *BM_mesh_active_vert_get(BMesh *bm);
82 BMElem *BM_mesh_active_elem_get(BMesh *bm);
83
84 void    BM_editselection_center(BMEditSelection *ese, float r_center[3]);
85 void    BM_editselection_normal(BMEditSelection *ese, float r_normal[3]);
86 void    BM_editselection_plane(BMEditSelection *ese,  float r_plane[3]);
87
88 #define BM_select_history_check(bm, ele)        _bm_select_history_check(bm,        &(ele)->head)
89 #define BM_select_history_remove(bm, ele)       _bm_select_history_remove(bm,       &(ele)->head)
90 #define BM_select_history_store_notest(bm, ele) _bm_select_history_store_notest(bm, &(ele)->head)
91 #define BM_select_history_store(bm, ele)        _bm_select_history_store(bm,        &(ele)->head)
92 #define BM_select_history_store_head_notest(bm, ele) _bm_select_history_store_head_notest(bm, &(ele)->head)
93 #define BM_select_history_store_head(bm, ele)        _bm_select_history_store_head(bm,        &(ele)->head)
94 #define BM_select_history_store_after_notest(bm, ese_ref, ele) _bm_select_history_store_after_notest(bm, ese_ref, &(ele)->head)
95 #define BM_select_history_store_after(bm, ese, ese_ref)        _bm_select_history_store_after(bm,        ese_ref, &(ele)->head)
96
97 bool _bm_select_history_check(BMesh *bm,  const BMHeader *ele);
98 bool _bm_select_history_remove(BMesh *bm,       BMHeader *ele);
99 void _bm_select_history_store_notest(BMesh *bm, BMHeader *ele);
100 void _bm_select_history_store(BMesh *bm,        BMHeader *ele);
101 void _bm_select_history_store_head_notest(BMesh *bm, BMHeader *ele);
102 void _bm_select_history_store_head(BMesh *bm,        BMHeader *ele);
103 void _bm_select_history_store_after(BMesh *bm,  BMEditSelection *ese_ref, BMHeader *ele);
104 void _bm_select_history_store_after_notest(BMesh *bm,  BMEditSelection *ese_ref, BMHeader *ele);
105
106 void BM_select_history_validate(BMesh *bm);
107 void BM_select_history_clear(BMesh *bm);
108 bool BM_select_history_active_get(BMesh *bm, struct BMEditSelection *ese);
109 struct GHash *BM_select_history_map_create(BMesh *bm);
110
111 void BM_select_history_merge_from_targetmap(
112         BMesh *bm, GHash *vert_map, GHash *edge_map, GHash *face_map, const bool use_chain);
113
114 #define BM_SELECT_HISTORY_BACKUP(bm) { \
115         ListBase _bm_prev_selected = (bm)->selected; BLI_listbase_clear(&(bm)->selected)
116
117 #define BM_SELECT_HISTORY_RESTORE(bm) \
118         (bm)->selected = _bm_prev_selected; } (void)0
119
120 #endif /* __BMESH_MARKING_H__ */