Blender  V2.93
wm_gizmo.c
Go to the documentation of this file.
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  * The Original Code is Copyright (C) 2014 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "MEM_guardedalloc.h"
25 
26 #include "BLI_listbase.h"
27 #include "BLI_math.h"
28 
29 #include "BKE_context.h"
30 
31 #include "GPU_batch.h"
32 
33 #include "RNA_access.h"
34 #include "RNA_define.h"
35 
36 #include "BKE_global.h"
37 #include "BKE_idprop.h"
38 #include "BKE_main.h"
39 
40 #include "WM_api.h"
41 #include "WM_toolsystem.h"
42 #include "WM_types.h"
43 
44 #include "ED_screen.h"
45 #include "ED_view3d.h"
46 
47 #include "UI_interface.h"
48 
49 #ifdef WITH_PYTHON
50 # include "BPY_extern.h"
51 #endif
52 
53 /* only for own init/exit calls (wm_gizmotype_init/wm_gizmotype_free) */
54 #include "wm.h"
55 
56 /* own includes */
57 #include "wm_gizmo_intern.h"
58 #include "wm_gizmo_wmapi.h"
59 
60 static void wm_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz);
61 
65 static wmGizmo *wm_gizmo_create(const wmGizmoType *gzt, PointerRNA *properties)
66 {
67  BLI_assert(gzt != NULL);
68  BLI_assert(gzt->struct_size >= sizeof(wmGizmo));
69 
70  wmGizmo *gz = MEM_callocN(
71  gzt->struct_size + (sizeof(wmGizmoProperty) * gzt->target_property_defs_len), __func__);
72  gz->type = gzt;
73 
74  /* initialize properties, either copy or create */
75  gz->ptr = MEM_callocN(sizeof(PointerRNA), "wmGizmoPtrRNA");
76  if (properties && properties->data) {
77  gz->properties = IDP_CopyProperty(properties->data);
78  }
79  else {
80  IDPropertyTemplate val = {0};
81  gz->properties = IDP_New(IDP_GROUP, &val, "wmGizmoProperties");
82  }
83  RNA_pointer_create(G_MAIN->wm.first, gzt->srna, gz->properties, gz->ptr);
84 
86 
87  unit_m4(gz->matrix_space);
88  unit_m4(gz->matrix_basis);
90 
91  gz->drag_part = -1;
92 
93  return gz;
94 }
95 
96 wmGizmo *WM_gizmo_new_ptr(const wmGizmoType *gzt, wmGizmoGroup *gzgroup, PointerRNA *properties)
97 {
98  wmGizmo *gz = wm_gizmo_create(gzt, properties);
99 
100  wm_gizmo_register(gzgroup, gz);
101 
102  if (gz->type->setup != NULL) {
103  gz->type->setup(gz);
104  }
105 
106  return gz;
107 }
108 
114 wmGizmo *WM_gizmo_new(const char *idname, wmGizmoGroup *gzgroup, PointerRNA *properties)
115 {
116  const wmGizmoType *gzt = WM_gizmotype_find(idname, false);
117  return WM_gizmo_new_ptr(gzt, gzgroup, properties);
118 }
119 
123 static void gizmo_init(wmGizmo *gz)
124 {
125  const float color_default[4] = {1.0f, 1.0f, 1.0f, 1.0f};
126 
127  gz->scale_basis = 1.0f;
128  gz->line_width = 1.0f;
129 
130  /* defaults */
131  copy_v4_v4(gz->color, color_default);
132  copy_v4_v4(gz->color_hi, color_default);
133 }
134 
140 static void wm_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz)
141 {
142  gizmo_init(gz);
143  wm_gizmogroup_gizmo_register(gzgroup, gz);
144 }
145 
152 {
153  if (gz->type->free != NULL) {
154  gz->type->free(gz);
155  }
156 
157 #ifdef WITH_PYTHON
158  if (gz->py_instance) {
159  /* do this first in case there are any __del__ functions or
160  * similar that use properties */
162  }
163 #endif
164 
165  if (gz->op_data) {
166  for (int i = 0; i < gz->op_data_len; i++) {
168  }
169  MEM_freeN(gz->op_data);
170  }
171 
172  if (gz->ptr != NULL) {
174  MEM_freeN(gz->ptr);
175  }
176 
177  if (gz->type->target_property_defs_len != 0) {
178  wmGizmoProperty *gz_prop_array = WM_gizmo_target_property_array(gz);
179  for (int i = 0; i < gz->type->target_property_defs_len; i++) {
180  wmGizmoProperty *gz_prop = &gz_prop_array[i];
181  if (gz_prop->custom_func.free_fn) {
182  gz_prop->custom_func.free_fn(gz, gz_prop);
183  }
184  }
185  }
186 
187  MEM_freeN(gz);
188 }
189 
194 void WM_gizmo_unlink(ListBase *gizmolist, wmGizmoMap *gzmap, wmGizmo *gz, bContext *C)
195 {
196  if (gz->state & WM_GIZMO_STATE_HIGHLIGHT) {
197  wm_gizmomap_highlight_set(gzmap, C, NULL, 0);
198  }
199  if (gz->state & WM_GIZMO_STATE_MODAL) {
200  wm_gizmomap_modal_set(gzmap, C, gz, NULL, false);
201  }
202  /* Unlink instead of setting so we don't run callbacks. */
203  if (gz->state & WM_GIZMO_STATE_SELECT) {
204  WM_gizmo_select_unlink(gzmap, gz);
205  }
206 
207  if (gizmolist) {
208  BLI_remlink(gizmolist, gz);
209  }
210 
211  BLI_assert(gzmap->gzmap_context.highlight != gz);
212  BLI_assert(gzmap->gzmap_context.modal != gz);
213 
214  WM_gizmo_free(gz);
215 }
216 
217 /* -------------------------------------------------------------------- */
224 struct wmGizmoOpElem *WM_gizmo_operator_get(wmGizmo *gz, int part_index)
225 {
226  if (gz->op_data && ((part_index >= 0) && (part_index < gz->op_data_len))) {
227  return &gz->op_data[part_index];
228  }
229  return NULL;
230 }
231 
233  int part_index,
235  IDProperty *properties)
236 {
237  BLI_assert(part_index < 255);
238  /* We could pre-allocate these but using multiple is such a rare thing. */
239  if (part_index >= gz->op_data_len) {
240  gz->op_data_len = part_index + 1;
241  gz->op_data = MEM_recallocN(gz->op_data, sizeof(*gz->op_data) * gz->op_data_len);
242  }
243  wmGizmoOpElem *gzop = &gz->op_data[part_index];
244  gzop->type = ot;
245 
246  if (gzop->ptr.data) {
248  }
250 
251  if (properties) {
252  gzop->ptr.data = properties;
253  }
254 
255  return &gzop->ptr;
256 }
257 
259 {
260  if (gz->flag & WM_GIZMO_OPERATOR_TOOL_INIT) {
261  /* Merge toolsettings into the gizmo properties. */
262  PointerRNA tref_ptr;
264  if (tref && WM_toolsystem_ref_properties_get_from_operator(tref, gzop->type, &tref_ptr)) {
265  if (gzop->ptr.data == NULL) {
266  IDPropertyTemplate val = {0};
267  gzop->ptr.data = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
268  }
269  IDP_MergeGroup(gzop->ptr.data, tref_ptr.data, false);
270  }
271  }
272  return WM_operator_name_call_ptr(C, gzop->type, WM_OP_INVOKE_DEFAULT, &gzop->ptr);
273 }
274 
276  const float z_axis[3])
277 {
278  /* old code, seems we can use simpler method */
279 #if 0
280  const float z_global[3] = {0.0f, 0.0f, 1.0f};
281  float rot[3][3];
282 
283  rotation_between_vecs_to_mat3(rot, z_global, z_axis);
284  copy_v3_v3(matrix[0], rot[0]);
285  copy_v3_v3(matrix[1], rot[1]);
286  copy_v3_v3(matrix[2], rot[2]);
287 #else
288  normalize_v3_v3(matrix[2], z_axis);
289  ortho_basis_v3v3_v3(matrix[0], matrix[1], matrix[2]);
290 #endif
291 }
292 
294  const float y_axis[3],
295  const float z_axis[3])
296 {
297  normalize_v3_v3(matrix[1], y_axis);
298  normalize_v3_v3(matrix[2], z_axis);
299  cross_v3_v3v3(matrix[0], matrix[1], matrix[2]);
300  normalize_v3(matrix[0]);
301 }
302 
306 void WM_gizmo_set_matrix_rotation_from_z_axis(wmGizmo *gz, const float z_axis[3])
307 {
309 }
311  const float y_axis[3],
312  const float z_axis[3])
313 {
315 }
316 void WM_gizmo_set_matrix_location(wmGizmo *gz, const float origin[3])
317 {
318  copy_v3_v3(gz->matrix_basis[3], origin);
319 }
320 
325 {
327 }
329  const float y_axis[3],
330  const float z_axis[3])
331 {
333 }
334 void WM_gizmo_set_matrix_offset_location(wmGizmo *gz, const float offset[3])
335 {
336  copy_v3_v3(gz->matrix_offset[3], offset);
337 }
338 
339 void WM_gizmo_set_flag(wmGizmo *gz, const int flag, const bool enable)
340 {
341  if (enable) {
342  gz->flag |= flag;
343  }
344  else {
345  gz->flag &= ~flag;
346  }
347 }
348 
349 void WM_gizmo_set_scale(wmGizmo *gz, const float scale)
350 {
351  gz->scale_basis = scale;
352 }
353 
354 void WM_gizmo_set_line_width(wmGizmo *gz, const float line_width)
355 {
356  gz->line_width = line_width;
357 }
358 
359 void WM_gizmo_get_color(const wmGizmo *gz, float color[4])
360 {
361  copy_v4_v4(color, gz->color);
362 }
363 void WM_gizmo_set_color(wmGizmo *gz, const float color[4])
364 {
365  copy_v4_v4(gz->color, color);
366 }
367 
368 void WM_gizmo_get_color_highlight(const wmGizmo *gz, float color_hi[4])
369 {
370  copy_v4_v4(color_hi, gz->color_hi);
371 }
372 void WM_gizmo_set_color_highlight(wmGizmo *gz, const float color_hi[4])
373 {
374  copy_v4_v4(gz->color_hi, color_hi);
375 }
376  /* Gizmo Creation API. */
378 
379 /* -------------------------------------------------------------------- */
384 {
385  gz->custom_modal = fn;
386 }
387 
390 /* -------------------------------------------------------------------- */
398  wmGizmoMap *gzmap, wmGizmo *gz, bool select, bool use_array, bool use_callback)
399 {
400  bool changed = false;
401 
402  if (select) {
403  if ((gz->state & WM_GIZMO_STATE_SELECT) == 0) {
404  if (use_array) {
406  }
408  changed = true;
409  }
410  }
411  else {
412  if (gz->state & WM_GIZMO_STATE_SELECT) {
413  if (use_array) {
415  }
417  changed = true;
418  }
419  }
420 
421  /* In the case of unlinking we only want to remove from the array
422  * and not write to the external state */
423  if (use_callback && changed) {
424  if (gz->type->select_refresh) {
425  gz->type->select_refresh(gz);
426  }
427  }
428 
429  return changed;
430 }
431 
432 /* Remove from selection array without running callbacks. */
434 {
435  return wm_gizmo_select_set_ex(gzmap, gz, false, true, false);
436 }
437 
439 {
440  return wm_gizmo_select_set_ex(gzmap, gz, select, true, true);
441 }
442 
444 {
445  return wm_gizmomap_highlight_set(gzmap, NULL, gz, gz ? gz->highlight_part : 0);
446 }
447 
449 {
450  if (WM_gizmo_select_set(gzmap, gz, true)) {
451  wm_gizmomap_highlight_set(gzmap, C, gz, gz->highlight_part);
452  return true;
453  }
454  return false;
455 }
456 
464  struct bContext *C,
465  struct wmGizmo *gz,
466  int part_index,
467  const wmEvent *event)
468 {
469  gz->highlight_part = part_index;
470  WM_gizmo_highlight_set(gzmap, gz);
471  if (false) {
472  wm_gizmomap_modal_set(gzmap, C, gz, event, true);
473  }
474  else {
475  /* WEAK: but it works. */
476  WM_operator_name_call(C, "GIZMOGROUP_OT_gizmo_tweak", WM_OP_INVOKE_DEFAULT, NULL);
477  }
478 }
479 
481 {
482  const RegionView3D *rv3d = CTX_wm_region_view3d(C);
483  float scale = UI_DPI_FAC;
484 
485  if ((gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_SCALE) == 0) {
486  scale *= U.gizmo_size;
487  if (rv3d) {
488  /* 'ED_view3d_pixel_size' includes 'U.pixelsize', remove it. */
489  float matrix_world[4][4];
490  if (gz->type->matrix_basis_get) {
491  float matrix_basis[4][4];
492  gz->type->matrix_basis_get(gz, matrix_basis);
493  mul_m4_m4m4(matrix_world, gz->matrix_space, matrix_basis);
494  }
495  else {
496  mul_m4_m4m4(matrix_world, gz->matrix_space, gz->matrix_basis);
497  }
498 
499  /* Exclude matrix_offset from scale. */
500  scale *= ED_view3d_pixel_size_no_ui_scale(rv3d, matrix_world[3]);
501  }
502  }
503 
504  gz->scale_final = gz->scale_basis * scale;
505 }
506 
508 {
509  /* gizmo property might have been changed, so update gizmo */
510  if (gz->type->property_update) {
511  wmGizmoProperty *gz_prop_array = WM_gizmo_target_property_array(gz);
512  for (int i = 0; i < gz->type->target_property_defs_len; i++) {
513  wmGizmoProperty *gz_prop = &gz_prop_array[i];
514  if (WM_gizmo_target_property_is_valid(gz_prop)) {
515  gz->type->property_update(gz, gz_prop);
516  }
517  }
518  }
519 }
520 
521 void wm_gizmo_update(wmGizmo *gz, const bContext *C, const bool refresh_map)
522 {
523  if (refresh_map) {
525  }
527 }
528 
530 {
531  if (gz->flag & WM_GIZMO_HIDDEN) {
532  return 0;
533  }
534  if ((gz->state & WM_GIZMO_STATE_MODAL) &&
536  /* don't draw while modal (dragging) */
537  return 0;
538  }
539  if ((gz->flag & WM_GIZMO_DRAW_HOVER) && !(gz->state & WM_GIZMO_STATE_HIGHLIGHT) &&
540  !(gz->state & WM_GIZMO_STATE_SELECT)) /* still draw selected gizmos */
541  {
542  /* update but don't draw */
544  }
545 
547 }
548 
550  const struct WM_GizmoMatrixParams *params,
551  float r_mat[4][4])
552 {
553  const float(*const matrix_space)[4] = params->matrix_space ? params->matrix_space :
554  gz->matrix_space;
555  const float(*const matrix_basis)[4] = params->matrix_basis ? params->matrix_basis :
556  gz->matrix_basis;
557  const float(*const matrix_offset)[4] = params->matrix_offset ? params->matrix_offset :
558  gz->matrix_offset;
559  const float *scale_final = params->scale_final ? params->scale_final : &gz->scale_final;
560 
561  float final_matrix[4][4];
562  if (params->matrix_basis == NULL && gz->type->matrix_basis_get) {
563  gz->type->matrix_basis_get(gz, final_matrix);
564  }
565  else {
566  copy_m4_m4(final_matrix, matrix_basis);
567  }
568 
569  if (gz->flag & WM_GIZMO_DRAW_NO_SCALE) {
570  mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
571  }
572  else {
573  if (gz->flag & WM_GIZMO_DRAW_OFFSET_SCALE) {
574  mul_mat3_m4_fl(final_matrix, *scale_final);
575  mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
576  }
577  else {
578  mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
579  mul_mat3_m4_fl(final_matrix, *scale_final);
580  }
581  }
582 
583  mul_m4_m4m4(r_mat, matrix_space, final_matrix);
584 }
585 
586 void WM_gizmo_calc_matrix_final_no_offset(const wmGizmo *gz, float r_mat[4][4])
587 {
588  float mat_identity[4][4];
589  unit_m4(mat_identity);
590 
592  &((struct WM_GizmoMatrixParams){
593  .matrix_space = NULL,
594  .matrix_basis = NULL,
595  .matrix_offset = mat_identity,
596  .scale_final = NULL,
597  }),
598  r_mat);
599 }
600 
601 void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
602 {
604  &((struct WM_GizmoMatrixParams){
605  .matrix_space = NULL,
606  .matrix_basis = NULL,
607  .matrix_offset = NULL,
608  .scale_final = NULL,
609  }),
610  r_mat);
611 }
612 
613 /* -------------------------------------------------------------------- */
621 {
623 }
624 
625 void WM_gizmo_properties_create(PointerRNA *ptr, const char *gtstring)
626 {
627  const wmGizmoType *gzt = WM_gizmotype_find(gtstring, false);
628 
629  if (gzt) {
631  }
632  else {
634  }
635 }
636 
637 /* similar to the function above except its uses ID properties
638  * used for keymaps and macros */
639 void WM_gizmo_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *gtstring)
640 {
641  if (*properties == NULL) {
642  IDPropertyTemplate val = {0};
643  *properties = IDP_New(IDP_GROUP, &val, "wmOpItemProp");
644  }
645 
646  if (*ptr == NULL) {
647  *ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr");
648  WM_gizmo_properties_create(*ptr, gtstring);
649  }
650 
651  (*ptr)->data = *properties;
652 }
653 
654 void WM_gizmo_properties_sanitize(PointerRNA *ptr, const bool no_context)
655 {
656  RNA_STRUCT_BEGIN (ptr, prop) {
657  switch (RNA_property_type(prop)) {
658  case PROP_ENUM:
659  if (no_context) {
661  }
662  else {
664  }
665  break;
666  case PROP_POINTER: {
667  StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
668 
669  /* recurse into gizmo properties */
670  if (RNA_struct_is_a(ptype, &RNA_GizmoProperties)) {
671  PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
672  WM_gizmo_properties_sanitize(&opptr, no_context);
673  }
674  break;
675  }
676  default:
677  break;
678  }
679  }
681 }
682 
691 bool WM_gizmo_properties_default(PointerRNA *ptr, const bool do_update)
692 {
693  bool changed = false;
694  RNA_STRUCT_BEGIN (ptr, prop) {
695  switch (RNA_property_type(prop)) {
696  case PROP_POINTER: {
697  StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
698  if (ptype != &RNA_Struct) {
699  PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
700  changed |= WM_gizmo_properties_default(&opptr, do_update);
701  }
702  break;
703  }
704  default:
705  if ((do_update == false) || (RNA_property_is_set(ptr, prop) == false)) {
706  if (RNA_property_reset(ptr, prop, -1)) {
707  changed = true;
708  }
709  }
710  break;
711  }
712  }
714 
715  return changed;
716 }
717 
718 /* remove all props without PROP_SKIP_SAVE */
720 {
721  if (gz->ptr->data) {
722  PropertyRNA *iterprop;
723  iterprop = RNA_struct_iterator_property(gz->type->srna);
724 
725  RNA_PROP_BEGIN (gz->ptr, itemptr, iterprop) {
726  PropertyRNA *prop = itemptr.data;
727 
728  if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) {
729  const char *identifier = RNA_property_identifier(prop);
730  RNA_struct_idprops_unset(gz->ptr, identifier);
731  }
732  }
733  RNA_PROP_END;
734  }
735 }
736 
738 {
739  IDProperty *properties = ptr->data;
740 
741  if (properties) {
742  IDP_ClearProperty(properties);
743  }
744 }
745 
747 {
748  IDProperty *properties = ptr->data;
749 
750  if (properties) {
751  IDP_FreeProperty(properties);
752  ptr->data = NULL; /* just in case */
753  }
754 }
755 
758 /* -------------------------------------------------------------------- */
763 {
764  switch (step) {
766  break;
767  }
770  if (ED_screen_animation_playing(wm)) {
771  return false;
772  }
773  break;
774  }
775  }
776  return true;
777 }
778 
typedef float(TangentPoint)[2]
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
struct RegionView3D * CTX_wm_region_view3d(const bContext *C)
Definition: context.c:769
#define G_MAIN
Definition: BKE_global.h:232
void IDP_FreeProperty(struct IDProperty *prop)
Definition: idprop.c:1040
void IDP_MergeGroup(struct IDProperty *dest, const struct IDProperty *src, const bool do_overwrite) ATTR_NONNULL()
struct IDProperty * IDP_New(const char type, const IDPropertyTemplate *val, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: idprop.c:907
void IDP_ClearProperty(struct IDProperty *prop)
Definition: idprop.c:1046
struct IDProperty * IDP_CopyProperty(const struct IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define BLI_assert(a)
Definition: BLI_assert.h:58
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:133
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:262
void mul_mat3_m4_fl(float R[4][4], float f)
Definition: math_matrix.c:982
void unit_m4(float m[4][4])
Definition: rct.c:1140
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:95
void rotation_between_vecs_to_mat3(float m[3][3], const float v1[3], const float v2[3])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE float normalize_v3(float r[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3])
Definition: math_vector.c:845
void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr)
@ IDP_GROUP
Definition: DNA_ID.h:101
bScreen * ED_screen_animation_playing(const struct wmWindowManager *wm)
float ED_view3d_pixel_size_no_ui_scale(const struct RegionView3D *rv3d, const float co[3])
Read Guarded memory(de)allocation.
#define MEM_recallocN(vmemh, len)
#define RNA_PROP_END
Definition: RNA_access.h:1268
#define RNA_STRUCT_BEGIN(sptr, prop)
Definition: RNA_access.h:1274
StructRNA RNA_Struct
#define RNA_STRUCT_END
Definition: RNA_access.h:1294
#define RNA_PROP_BEGIN(sptr, itemptr, prop)
Definition: RNA_access.h:1261
StructRNA RNA_GizmoProperties
@ PROP_ENUM
Definition: RNA_types.h:77
@ PROP_POINTER
Definition: RNA_types.h:78
@ PROP_ENUM_NO_CONTEXT
Definition: RNA_types.h:277
@ PROP_SKIP_SAVE
Definition: RNA_types.h:204
#define C
Definition: RandGen.cpp:39
#define UI_DPI_FAC
Definition: UI_interface.h:309
eWM_GizmoFlagMapDrawStep
@ WM_GIZMOMAP_DRAWSTEP_3D
@ WM_GIZMOMAP_DRAWSTEP_2D
@ WM_GIZMO_DRAW_NO_SCALE
@ WM_GIZMO_HIDDEN
@ WM_GIZMO_OPERATOR_TOOL_INIT
@ WM_GIZMO_DRAW_VALUE
@ WM_GIZMO_DRAW_MODAL
@ WM_GIZMO_DRAW_HOVER
@ WM_GIZMO_DRAW_OFFSET_SCALE
@ WM_GIZMOGROUPTYPE_SCALE
@ WM_GIZMO_STATE_HIGHLIGHT
@ WM_GIZMO_STATE_MODAL
@ WM_GIZMO_STATE_SELECT
#define WM_toolsystem_ref_properties_get_from_operator(tref, ot, r_ptr)
@ WM_OP_INVOKE_DEFAULT
Definition: WM_types.h:197
unsigned int U
Definition: btGjkEpa3.h:78
#define rot(x, k)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
Definition: rna_access.c:844
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:146
const char * RNA_property_identifier(const PropertyRNA *prop)
Definition: rna_access.c:1145
bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
Definition: rna_access.c:8030
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:6655
PropertyType RNA_property_type(PropertyRNA *prop)
Definition: rna_access.c:1155
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3641
StructRNA * RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:1567
int RNA_property_flag(PropertyRNA *prop)
Definition: rna_access.c:1192
bool RNA_struct_idprops_unset(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:829
PropertyRNA * RNA_struct_iterator_property(StructRNA *type)
Definition: rna_access.c:771
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1517
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
void * data
Definition: RNA_types.h:52
eWM_GizmoFlagGroupTypeFlag flag
struct wmGizmoGroupType * type
struct wmGizmoMap::@1146 gzmap_context
Gizmo map runtime context.
struct wmGizmo * modal
struct wmGizmo * highlight
PointerRNA ptr
struct wmOperatorType * type
struct wmGizmoProperty::@1149 custom_func
wmGizmoPropertyFnFree free_fn
wmGizmoFnSelectRefresh select_refresh
wmGizmoFnSetup setup
int target_property_defs_len
wmGizmoFnMatrixBasisGet matrix_basis_get
struct StructRNA * srna
wmGizmoFnFree free
wmGizmoFnPropertyUpdate property_update
eWM_GizmoFlagState state
struct wmGizmoGroup * parent_gzgroup
int highlight_part
float matrix_basis[4][4]
void * py_instance
float matrix_offset[4][4]
wmGizmoOpElem * op_data
float color_hi[4]
float scale_final
int op_data_len
float color[4]
struct PointerRNA * ptr
float scale_basis
float matrix_space[4][4]
float line_width
eWM_GizmoFlag flag
wmGizmoFnModal custom_modal
const struct wmGizmoType * type
struct IDProperty * properties
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: util_avxb.h:167
int WM_operator_name_call(bContext *C, const char *opstring, short context, PointerRNA *properties)
int WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, short context, PointerRNA *properties)
PointerRNA * ptr
Definition: wm_files.c:3157
wmOperatorType * ot
Definition: wm_files.c:3156
bool wm_gizmo_select_set_ex(wmGizmoMap *gzmap, wmGizmo *gz, bool select, bool use_array, bool use_callback)
Definition: wm_gizmo.c:397
void WM_gizmo_set_matrix_offset_location(wmGizmo *gz, const float offset[3])
Definition: wm_gizmo.c:334
bool WM_gizmo_context_check_drawstep(const struct bContext *C, eWM_GizmoFlagMapDrawStep step)
Definition: wm_gizmo.c:762
static void wm_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz)
Definition: wm_gizmo.c:140
void WM_gizmo_set_fn_custom_modal(struct wmGizmo *gz, wmGizmoFnModal fn)
Definition: wm_gizmo.c:383
static void gizmo_update_prop_data(wmGizmo *gz)
Definition: wm_gizmo.c:507
void WM_gizmo_calc_matrix_final_params(const wmGizmo *gz, const struct WM_GizmoMatrixParams *params, float r_mat[4][4])
Definition: wm_gizmo.c:549
PointerRNA * WM_gizmo_operator_set(wmGizmo *gz, int part_index, wmOperatorType *ot, IDProperty *properties)
Definition: wm_gizmo.c:232
void WM_gizmo_set_color_highlight(wmGizmo *gz, const float color_hi[4])
Definition: wm_gizmo.c:372
void WM_gizmo_set_line_width(wmGizmo *gz, const float line_width)
Definition: wm_gizmo.c:354
bool wm_gizmo_select_and_highlight(bContext *C, wmGizmoMap *gzmap, wmGizmo *gz)
Definition: wm_gizmo.c:448
int WM_gizmo_operator_invoke(bContext *C, wmGizmo *gz, wmGizmoOpElem *gzop)
Definition: wm_gizmo.c:258
void WM_gizmo_get_color_highlight(const wmGizmo *gz, float color_hi[4])
Definition: wm_gizmo.c:368
void WM_gizmo_modal_set_from_setup(struct wmGizmoMap *gzmap, struct bContext *C, struct wmGizmo *gz, int part_index, const wmEvent *event)
Definition: wm_gizmo.c:463
void WM_gizmo_free(wmGizmo *gz)
Definition: wm_gizmo.c:151
void WM_gizmo_set_matrix_offset_rotation_from_yz_axis(wmGizmo *gz, const float y_axis[3], const float z_axis[3])
Definition: wm_gizmo.c:328
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition: wm_gizmo.c:601
void WM_gizmo_set_matrix_rotation_from_yz_axis(wmGizmo *gz, const float y_axis[3], const float z_axis[3])
Definition: wm_gizmo.c:310
void WM_gizmo_properties_create_ptr(PointerRNA *ptr, wmGizmoType *gzt)
Definition: wm_gizmo.c:620
wmGizmo * WM_gizmo_new_ptr(const wmGizmoType *gzt, wmGizmoGroup *gzgroup, PointerRNA *properties)
Definition: wm_gizmo.c:96
static void wm_gizmo_set_matrix_rotation_from_yz_axis__internal(float matrix[4][4], const float y_axis[3], const float z_axis[3])
Definition: wm_gizmo.c:293
void WM_gizmo_get_color(const wmGizmo *gz, float color[4])
Definition: wm_gizmo.c:359
void WM_gizmo_calc_matrix_final_no_offset(const wmGizmo *gz, float r_mat[4][4])
Definition: wm_gizmo.c:586
void wm_gizmo_update(wmGizmo *gz, const bContext *C, const bool refresh_map)
Definition: wm_gizmo.c:521
bool WM_gizmo_highlight_set(wmGizmoMap *gzmap, wmGizmo *gz)
Definition: wm_gizmo.c:443
void WM_gizmo_set_matrix_offset_rotation_from_z_axis(wmGizmo *gz, const float z_axis[3])
Definition: wm_gizmo.c:324
static void gizmo_init(wmGizmo *gz)
Definition: wm_gizmo.c:123
void WM_gizmo_set_scale(wmGizmo *gz, const float scale)
Definition: wm_gizmo.c:349
void WM_gizmo_set_matrix_location(wmGizmo *gz, const float origin[3])
Definition: wm_gizmo.c:316
bool WM_gizmo_select_unlink(wmGizmoMap *gzmap, wmGizmo *gz)
Definition: wm_gizmo.c:433
void WM_gizmo_set_flag(wmGizmo *gz, const int flag, const bool enable)
Definition: wm_gizmo.c:339
void WM_gizmo_set_matrix_rotation_from_z_axis(wmGizmo *gz, const float z_axis[3])
Definition: wm_gizmo.c:306
static wmGizmo * wm_gizmo_create(const wmGizmoType *gzt, PointerRNA *properties)
Definition: wm_gizmo.c:65
static void wm_gizmo_set_matrix_rotation_from_z_axis__internal(float matrix[4][4], const float z_axis[3])
Definition: wm_gizmo.c:275
struct wmGizmoOpElem * WM_gizmo_operator_get(wmGizmo *gz, int part_index)
Definition: wm_gizmo.c:224
bool WM_gizmo_select_set(wmGizmoMap *gzmap, wmGizmo *gz, bool select)
Definition: wm_gizmo.c:438
void WM_gizmo_properties_sanitize(PointerRNA *ptr, const bool no_context)
Definition: wm_gizmo.c:654
wmGizmo * WM_gizmo_new(const char *idname, wmGizmoGroup *gzgroup, PointerRNA *properties)
Definition: wm_gizmo.c:114
void WM_gizmo_properties_free(PointerRNA *ptr)
Definition: wm_gizmo.c:746
void WM_gizmo_properties_reset(wmGizmo *gz)
Definition: wm_gizmo.c:719
void WM_gizmo_properties_clear(PointerRNA *ptr)
Definition: wm_gizmo.c:737
void wm_gizmo_calculate_scale(wmGizmo *gz, const bContext *C)
Definition: wm_gizmo.c:480
bool WM_gizmo_properties_default(PointerRNA *ptr, const bool do_update)
Definition: wm_gizmo.c:691
void WM_gizmo_properties_create(PointerRNA *ptr, const char *gtstring)
Definition: wm_gizmo.c:625
void WM_gizmo_set_color(wmGizmo *gz, const float color[4])
Definition: wm_gizmo.c:363
int wm_gizmo_is_visible(wmGizmo *gz)
Definition: wm_gizmo.c:529
void WM_gizmo_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *gtstring)
Definition: wm_gizmo.c:639
void WM_gizmo_unlink(ListBase *gizmolist, wmGizmoMap *gzmap, wmGizmo *gz, bContext *C)
Definition: wm_gizmo.c:194
int(* wmGizmoFnModal)(struct bContext *, struct wmGizmo *, const struct wmEvent *, eWM_GizmoFlagTweak)
Definition: wm_gizmo_fn.h:56
void wm_gizmogroup_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz)
@ WM_GIZMO_IS_VISIBLE_DRAW
@ WM_GIZMO_IS_VISIBLE_UPDATE
void wm_gizmomap_select_array_remove(struct wmGizmoMap *gzmap, wmGizmo *gz)
Definition: wm_gizmo_map.c:142
void wm_gizmomap_select_array_push_back(struct wmGizmoMap *gzmap, wmGizmo *gz)
Definition: wm_gizmo_map.c:131
void wm_gizmomap_modal_set(wmGizmoMap *gzmap, bContext *C, wmGizmo *gz, const wmEvent *event, bool enable)
bool wm_gizmomap_highlight_set(wmGizmoMap *gzmap, const bContext *C, wmGizmo *gz, int part)
Definition: wm_gizmo_map.c:999
bool WM_gizmo_target_property_is_valid(const wmGizmoProperty *gz_prop)
wmGizmoProperty * WM_gizmo_target_property_array(wmGizmo *gz)
const wmGizmoType * WM_gizmotype_find(const char *idname, bool quiet)
Definition: wm_gizmo_type.c:58
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
Definition: wm_operators.c:584
void WM_operator_properties_free(PointerRNA *ptr)
Definition: wm_operators.c:711
struct bToolRef * WM_toolsystem_ref_from_context(struct bContext *C)
Definition: wm_toolsystem.c:71