Blender V4.3
wm_gizmo.cc File Reference
#include <new>
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
#include "BLI_math_matrix.h"
#include "BKE_context.hh"
#include "GPU_batch.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "RNA_prototypes.hh"
#include "BKE_global.hh"
#include "BKE_idprop.hh"
#include "BKE_main.hh"
#include "WM_api.hh"
#include "WM_toolsystem.hh"
#include "WM_types.hh"
#include "ED_screen.hh"
#include "ED_view3d.hh"
#include "wm_gizmo_intern.hh"
#include "wm_gizmo_wmapi.hh"

Go to the source code of this file.

Functions

static void wm_gizmo_register (wmGizmoGroup *gzgroup, wmGizmo *gz)
 
static wmGizmowm_gizmo_create (const wmGizmoType *gzt, PointerRNA *properties)
 
wmGizmoWM_gizmo_new_ptr (const wmGizmoType *gzt, wmGizmoGroup *gzgroup, PointerRNA *properties)
 
wmGizmoWM_gizmo_new (const char *idname, wmGizmoGroup *gzgroup, PointerRNA *properties)
 
static void gizmo_init (wmGizmo *gz)
 
void WM_gizmo_free (wmGizmo *gz)
 
void WM_gizmo_unlink (ListBase *gizmolist, wmGizmoMap *gzmap, wmGizmo *gz, bContext *C)
 
bool wm_gizmo_select_set_ex (wmGizmoMap *gzmap, wmGizmo *gz, bool select, bool use_array, bool use_callback)
 
bool WM_gizmo_select_unlink (wmGizmoMap *gzmap, wmGizmo *gz)
 
bool WM_gizmo_select_set (wmGizmoMap *gzmap, wmGizmo *gz, bool select)
 
bool WM_gizmo_highlight_set (wmGizmoMap *gzmap, wmGizmo *gz)
 
bool wm_gizmo_select_and_highlight (bContext *C, wmGizmoMap *gzmap, wmGizmo *gz)
 
void WM_gizmo_modal_set_from_setup (wmGizmoMap *gzmap, bContext *C, wmGizmo *gz, int part_index, const wmEvent *event)
 
void WM_gizmo_modal_set_while_modal (wmGizmoMap *gzmap, bContext *C, wmGizmo *gz, const wmEvent *event)
 
void wm_gizmo_calculate_scale (wmGizmo *gz, const bContext *C)
 
static void gizmo_update_prop_data (wmGizmo *gz)
 
void wm_gizmo_update (wmGizmo *gz, const bContext *C, const bool refresh_map)
 
int wm_gizmo_is_visible (wmGizmo *gz)
 
void WM_gizmo_calc_matrix_final_params (const wmGizmo *gz, const WM_GizmoMatrixParams *params, float r_mat[4][4])
 
void WM_gizmo_calc_matrix_final_no_offset (const wmGizmo *gz, float r_mat[4][4])
 
void WM_gizmo_calc_matrix_final (const wmGizmo *gz, float r_mat[4][4])
 
Gizmo Creation API

API for defining data on gizmo creation.

wmGizmoOpElemWM_gizmo_operator_get (wmGizmo *gz, int part_index)
 
PointerRNAWM_gizmo_operator_set (wmGizmo *gz, int part_index, wmOperatorType *ot, IDProperty *properties)
 
int WM_gizmo_operator_invoke (bContext *C, wmGizmo *gz, wmGizmoOpElem *gzop, const wmEvent *event)
 
static void wm_gizmo_set_matrix_rotation_from_z_axis__internal (float matrix[4][4], const float z_axis[3])
 
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])
 
void WM_gizmo_set_matrix_rotation_from_z_axis (wmGizmo *gz, const float z_axis[3])
 
void WM_gizmo_set_matrix_rotation_from_yz_axis (wmGizmo *gz, const float y_axis[3], const float z_axis[3])
 
void WM_gizmo_set_matrix_location (wmGizmo *gz, const float origin[3])
 
void WM_gizmo_set_matrix_offset_rotation_from_z_axis (wmGizmo *gz, const float z_axis[3])
 
void WM_gizmo_set_matrix_offset_rotation_from_yz_axis (wmGizmo *gz, const float y_axis[3], const float z_axis[3])
 
void WM_gizmo_set_matrix_offset_location (wmGizmo *gz, const float offset[3])
 
void WM_gizmo_set_flag (wmGizmo *gz, const int flag, const bool enable)
 
void WM_gizmo_set_scale (wmGizmo *gz, const float scale)
 
void WM_gizmo_set_line_width (wmGizmo *gz, const float line_width)
 
void WM_gizmo_get_color (const wmGizmo *gz, float color[4])
 
void WM_gizmo_set_color (wmGizmo *gz, const float color[4])
 
void WM_gizmo_get_color_highlight (const wmGizmo *gz, float color_hi[4])
 
void WM_gizmo_set_color_highlight (wmGizmo *gz, const float color_hi[4])
 
Gizmo Callback Assignment
void WM_gizmo_set_fn_custom_modal (wmGizmo *gz, wmGizmoFnModal fn)
 
Gizmo Property Access

Matches WM_operator_properties conventions.

void WM_gizmo_properties_create_ptr (PointerRNA *ptr, wmGizmoType *gzt)
 
void WM_gizmo_properties_create (PointerRNA *ptr, const char *gtstring)
 
void WM_gizmo_properties_alloc (PointerRNA **ptr, IDProperty **properties, const char *gtstring)
 
void WM_gizmo_properties_sanitize (PointerRNA *ptr, const bool no_context)
 
bool WM_gizmo_properties_default (PointerRNA *ptr, const bool do_update)
 
void WM_gizmo_properties_reset (wmGizmo *gz)
 
void WM_gizmo_properties_clear (PointerRNA *ptr)
 
void WM_gizmo_properties_free (PointerRNA *ptr)
 
General Utilities
bool WM_gizmo_context_check_drawstep (const bContext *C, eWM_GizmoFlagMapDrawStep step)
 

Function Documentation

◆ gizmo_init()

static void gizmo_init ( wmGizmo * gz)
static

Initialize default values and allocate needed memory for members.

Definition at line 103 of file wm_gizmo.cc.

References wmGizmo::color, wmGizmo::color_hi, copy_v4_v4(), wmGizmo::line_width, and wmGizmo::scale_basis.

Referenced by wm_gizmo_register().

◆ gizmo_update_prop_data()

static void gizmo_update_prop_data ( wmGizmo * gz)
static

◆ WM_gizmo_calc_matrix_final()

◆ WM_gizmo_calc_matrix_final_no_offset()

void WM_gizmo_calc_matrix_final_no_offset ( const wmGizmo * gz,
float r_mat[4][4] )

◆ WM_gizmo_calc_matrix_final_params()

◆ wm_gizmo_calculate_scale()

◆ WM_gizmo_context_check_drawstep()

bool WM_gizmo_context_check_drawstep ( const bContext * C,
eWM_GizmoFlagMapDrawStep step )

◆ wm_gizmo_create()

◆ WM_gizmo_free()

void WM_gizmo_free ( wmGizmo * gz)
Warning
this doesn't check wmGizmoMap (highlight, selection etc). Typical use is when freeing the windowing data, where caller can manage clearing selection, highlight... etc.

Definition at line 126 of file wm_gizmo.cc.

References BPY_DECREF_RNA_INVALIDATE(), wmGizmoProperty::custom_func, wmGizmoType::free, wmGizmoProperty::free_fn, MEM_freeN(), wmGizmo::op_data, wmGizmo::ptr, wmGizmo::py_instance, wmGizmoType::target_property_defs_len, wmGizmo::type, WM_gizmo_properties_free(), WM_gizmo_target_property_array(), and WM_operator_properties_free().

Referenced by WM_gizmo_unlink(), and wm_gizmogroup_free().

◆ WM_gizmo_get_color()

void WM_gizmo_get_color ( const wmGizmo * gz,
float color[4] )

Definition at line 323 of file wm_gizmo.cc.

References wmGizmo::color, and copy_v4_v4().

◆ WM_gizmo_get_color_highlight()

void WM_gizmo_get_color_highlight ( const wmGizmo * gz,
float color_hi[4] )

Definition at line 332 of file wm_gizmo.cc.

References wmGizmo::color_hi, and copy_v4_v4().

◆ WM_gizmo_highlight_set()

◆ wm_gizmo_is_visible()

◆ WM_gizmo_modal_set_from_setup()

void WM_gizmo_modal_set_from_setup ( wmGizmoMap * gzmap,
bContext * C,
wmGizmo * gz,
int part_index,
const wmEvent * event )

Special function to run from setup so gizmos start out interactive.

We could do this when linking them, but this complicates things since the window update code needs to run first.

Definition at line 415 of file wm_gizmo.cc.

References wmGizmo::highlight_part, WM_gizmo_highlight_set(), wm_gizmomap_modal_set(), WM_OP_INVOKE_DEFAULT, and WM_operator_name_call().

Referenced by gizmo_mesh_placement_modal_from_setup(), and gizmo_mesh_spin_redo_modal_from_setup().

◆ WM_gizmo_modal_set_while_modal()

void WM_gizmo_modal_set_while_modal ( wmGizmoMap * gzmap,
bContext * C,
wmGizmo * gz,
const wmEvent * event )

Replaces the current gizmo modal. The substitute gizmo start out interactive. It is similar to WM_gizmo_modal_set_from_setup but without operator initialization.

Definition at line 429 of file wm_gizmo.cc.

References wmGizmoMap::gzmap_context, wmGizmo::highlight_part, wmGizmoMap::modal, wm_gizmo_calculate_scale(), and wm_gizmomap_modal_set().

Referenced by transform_gizmo_3d_model_from_constraint_and_mode_set(), and transform_mode_snap_source_init().

◆ WM_gizmo_new()

◆ WM_gizmo_new_ptr()

◆ WM_gizmo_operator_get()

◆ WM_gizmo_operator_invoke()

◆ WM_gizmo_operator_set()

◆ WM_gizmo_properties_alloc()

void WM_gizmo_properties_alloc ( PointerRNA ** ptr,
IDProperty ** properties,
const char * gtstring )

Similar to WM_gizmo_properties_create except its uses ID properties used for key-maps and macros.

Definition at line 603 of file wm_gizmo.cc.

References blender::bke::idprop::create_group(), ptr, and WM_gizmo_properties_create().

◆ WM_gizmo_properties_clear()

void WM_gizmo_properties_clear ( PointerRNA * ptr)

Definition at line 691 of file wm_gizmo.cc.

References PointerRNA::data, IDP_ClearProperty(), and ptr.

◆ WM_gizmo_properties_create()

void WM_gizmo_properties_create ( PointerRNA * ptr,
const char * gtstring )

◆ WM_gizmo_properties_create_ptr()

void WM_gizmo_properties_create_ptr ( PointerRNA * ptr,
wmGizmoType * gzt )

Definition at line 586 of file wm_gizmo.cc.

References ptr, RNA_pointer_create(), and wmGizmoType::srna.

Referenced by WM_gizmo_properties_create().

◆ WM_gizmo_properties_default()

bool WM_gizmo_properties_default ( PointerRNA * ptr,
bool do_update )

Set all props to their default.

Parameters
do_updateOnly update un-initialized props.
Note
There's nothing specific to gizmos here. This could be made a general function.

Definition at line 646 of file wm_gizmo.cc.

References PROP_POINTER, ptr, RNA_property_is_set(), RNA_property_pointer_get(), RNA_property_pointer_type(), RNA_property_reset(), RNA_property_type(), RNA_STRUCT_BEGIN, RNA_STRUCT_END, and WM_gizmo_properties_default().

Referenced by WM_gizmo_properties_default().

◆ WM_gizmo_properties_free()

void WM_gizmo_properties_free ( PointerRNA * ptr)

Definition at line 700 of file wm_gizmo.cc.

References PointerRNA::data, IDP_FreeProperty(), and ptr.

Referenced by WM_gizmo_free().

◆ WM_gizmo_properties_reset()

◆ WM_gizmo_properties_sanitize()

◆ wm_gizmo_register()

static void wm_gizmo_register ( wmGizmoGroup * gzgroup,
wmGizmo * gz )
static

Register gizmo.

Note
Not to be confused with type registration from RNA.

Definition at line 120 of file wm_gizmo.cc.

References gizmo_init(), and wm_gizmogroup_gizmo_register().

Referenced by WM_gizmo_new_ptr().

◆ wm_gizmo_select_and_highlight()

bool wm_gizmo_select_and_highlight ( bContext * C,
wmGizmoMap * gzmap,
wmGizmo * gz )

◆ WM_gizmo_select_set()

bool WM_gizmo_select_set ( wmGizmoMap * gzmap,
wmGizmo * gz,
bool select )

◆ wm_gizmo_select_set_ex()

bool wm_gizmo_select_set_ex ( wmGizmoMap * gzmap,
wmGizmo * gz,
bool select,
bool use_array,
bool use_callback )

Add/Remove gizmo to selection. Reallocates memory for selected gizmos so better not call for selecting multiple ones.

Returns
if the selection has changed.

Definition at line 356 of file wm_gizmo.cc.

References select(), wmGizmoType::select_refresh, wmGizmo::state, wmGizmo::type, WM_GIZMO_STATE_SELECT, wm_gizmomap_select_array_push_back(), and wm_gizmomap_select_array_remove().

Referenced by WM_gizmo_select_set(), WM_gizmo_select_unlink(), and wm_gizmomap_deselect_all().

◆ WM_gizmo_select_unlink()

bool WM_gizmo_select_unlink ( wmGizmoMap * gzmap,
wmGizmo * gz )

Remove from selection array without running callbacks.

Definition at line 391 of file wm_gizmo.cc.

References wm_gizmo_select_set_ex().

Referenced by WM_gizmo_unlink(), and wm_gizmogroup_free().

◆ WM_gizmo_set_color()

◆ WM_gizmo_set_color_highlight()

void WM_gizmo_set_color_highlight ( wmGizmo * gz,
const float color_hi[4] )

◆ WM_gizmo_set_flag()

void WM_gizmo_set_flag ( wmGizmo * gz,
const int flag,
const bool enable )

Definition at line 303 of file wm_gizmo.cc.

References flag, and wmGizmo::flag.

Referenced by gizmo_3d_draw_invoke(), gizmo_3d_setup_draw_default(), gizmo_3d_setup_draw_from_twtype(), gizmo_3d_setup_draw_modal(), gizmo_mesh_bisect_setup(), gizmo_mesh_extrude_refresh(), gizmo_mesh_placement_setup(), gizmo_mesh_spin_init_draw_prepare(), gizmo_mesh_spin_init_refresh(), gizmo_mesh_spin_init_setup(), gizmo_mesh_spin_redo_setup(), gizmogroup_hide_all(), blender::ed::view3d::geometry_nodes_gizmos::NodeGizmos::hide_all(), ruler_item_add(), ruler_state_set(), blender::ed::view3d::geometry_nodes_gizmos::NodeGizmos::show_all(), blender::ed::view3d::geometry_nodes_gizmos::TransformGizmos::update_rotate_style(), blender::ed::view3d::geometry_nodes_gizmos::DialGizmo::update_style(), blender::ed::view3d::geometry_nodes_gizmos::DialGizmo::update_transform(), blender::ed::view3d::geometry_nodes_gizmos::TransformGizmos::update_translate_style(), blender::ed::view3d::geometry_nodes_gizmos::TransformGizmos::update_visibility(), WIDGETGROUP_armature_spline_setup(), WIDGETGROUP_camera_refresh(), WIDGETGROUP_camera_setup(), WIDGETGROUP_camera_view_refresh(), WIDGETGROUP_empty_image_setup(), WIDGETGROUP_forcefield_refresh(), WIDGETGROUP_forcefield_setup(), blender::ed::view3d::geometry_nodes_gizmos::WIDGETGROUP_geometry_nodes_refresh(), WIDGETGROUP_gizmo_draw_prepare(), WIDGETGROUP_light_area_setup(), WIDGETGROUP_light_point_setup(), WIDGETGROUP_light_spot_setup(), WIDGETGROUP_light_target_draw_prepare(), WIDGETGROUP_navigate_draw_prepare(), WIDGETGROUP_navigate_draw_prepare(), blender::ed::space_node::WIDGETGROUP_node_corner_pin_refresh(), blender::ed::space_node::WIDGETGROUP_node_crop_refresh(), blender::ed::space_node::WIDGETGROUP_node_sbeam_refresh(), blender::ed::space_node::WIDGETGROUP_node_transform_refresh(), WIDGETGROUP_tool_generic_refresh(), WIDGETGROUP_xform_cage_refresh(), WIDGETGROUP_xform_shear_refresh(), and WIDGETGROUP_xform_shear_setup().

◆ WM_gizmo_set_fn_custom_modal()

void WM_gizmo_set_fn_custom_modal ( wmGizmo * gz,
wmGizmoFnModal fn )

◆ WM_gizmo_set_line_width()

◆ WM_gizmo_set_matrix_location()

◆ WM_gizmo_set_matrix_offset_location()

void WM_gizmo_set_matrix_offset_location ( wmGizmo * gz,
const float offset[3] )

◆ WM_gizmo_set_matrix_offset_rotation_from_yz_axis()

void WM_gizmo_set_matrix_offset_rotation_from_yz_axis ( wmGizmo * gz,
const float y_axis[3],
const float z_axis[3] )

wmGizmo.matrix_offset utility, set the orientation by its Y/Z axis.

Definition at line 292 of file wm_gizmo.cc.

References wmGizmo::matrix_offset, and wm_gizmo_set_matrix_rotation_from_yz_axis__internal().

◆ WM_gizmo_set_matrix_offset_rotation_from_z_axis()

void WM_gizmo_set_matrix_offset_rotation_from_z_axis ( wmGizmo * gz,
const float z_axis[3] )

wmGizmo.matrix_offset utility, set the orientation by its Z axis.

Definition at line 288 of file wm_gizmo.cc.

References wmGizmo::matrix_offset, and wm_gizmo_set_matrix_rotation_from_z_axis__internal().

◆ WM_gizmo_set_matrix_rotation_from_yz_axis()

void WM_gizmo_set_matrix_rotation_from_yz_axis ( wmGizmo * gz,
const float y_axis[3],
const float z_axis[3] )

◆ wm_gizmo_set_matrix_rotation_from_yz_axis__internal()

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] )
static

◆ WM_gizmo_set_matrix_rotation_from_z_axis()

◆ wm_gizmo_set_matrix_rotation_from_z_axis__internal()

static void wm_gizmo_set_matrix_rotation_from_z_axis__internal ( float matrix[4][4],
const float z_axis[3] )
static

◆ WM_gizmo_set_scale()

◆ WM_gizmo_unlink()

◆ wm_gizmo_update()

void wm_gizmo_update ( wmGizmo * gz,
const bContext * C,
const bool refresh_map )

Definition at line 490 of file wm_gizmo.cc.

References gizmo_update_prop_data(), and wm_gizmo_calculate_scale().

Referenced by gizmo_prepare_drawing().