|
Blender
V2.93
|
#include "BLI_listbase.h"#include "BLI_math.h"#include "BLI_rect.h"#include "BLI_string.h"#include "BLI_utildefines.h"#include "BLT_translation.h"#include "BKE_context.h"#include "BKE_gpencil.h"#include "BKE_main.h"#include "BKE_report.h"#include "BKE_material.h"#include "BKE_object.h"#include "BKE_unit.h"#include "DNA_gpencil_types.h"#include "DNA_meshdata_types.h"#include "DNA_object_types.h"#include "DNA_view3d_types.h"#include "ED_gizmo_library.h"#include "ED_gizmo_utils.h"#include "ED_gpencil.h"#include "ED_screen.h"#include "ED_transform_snap_object_context.h"#include "ED_view3d.h"#include "UI_interface.h"#include "UI_resources.h"#include "MEM_guardedalloc.h"#include "RNA_access.h"#include "WM_api.h"#include "WM_toolsystem.h"#include "WM_types.h"#include "DEG_depsgraph_query.h"#include "view3d_intern.h"#include "GPU_immediate.h"#include "GPU_immediate_util.h"#include "GPU_matrix.h"#include "GPU_state.h"#include "BLF_api.h"Go to the source code of this file.
Classes | |
| struct | RulerInfo |
| struct | RulerItem |
| struct | RulerInteraction |
Macros | |
| #define | MVAL_MAX_PX_DIST 12.0f |
| #define | RULER_PICK_DIST 12.0f |
| #define | RULER_PICK_DIST_SQ (RULER_PICK_DIST * RULER_PICK_DIST) |
| #define | PART_LINE 0xff |
| #define | ARC_STEPS 24 |
Typedefs | |
| typedef struct RulerInfo | RulerInfo |
| typedef struct RulerItem | RulerItem |
| typedef struct RulerInteraction | RulerInteraction |
Enumerations | |
| enum | { RULERITEM_USE_ANGLE = (1 << 0) , RULERITEM_USE_ANGLE_ACTIVE = (1 << 1) } |
| enum | { RULER_STATE_NORMAL = 0 , RULER_STATE_DRAG } |
Functions | |
Internal Ruler Utilities | |
| static RulerItem * | ruler_item_add (wmGizmoGroup *gzgroup) |
| static void | ruler_item_remove (bContext *C, wmGizmoGroup *gzgroup, RulerItem *ruler_item) |
| static void | ruler_item_as_string (RulerItem *ruler_item, UnitSettings *unit, char *numstr, size_t numstr_size, int prec) |
| static bool | view3d_ruler_pick (wmGizmoGroup *gzgroup, RulerItem *ruler_item, const float mval[2], int *r_co_index) |
| static void | ruler_state_set (RulerInfo *ruler_info, int state) |
| static void | view3d_ruler_item_project (RulerInfo *ruler_info, float r_co[3], const int xy[2]) |
| static bool | view3d_ruler_item_mousemove (struct Depsgraph *depsgraph, RulerInfo *ruler_info, RulerItem *ruler_item, const int mval[2], const bool do_thickness) |
Ruler Item Gizmo Type | |
| static void | gizmo_ruler_draw (const bContext *C, wmGizmo *gz) |
| static int | gizmo_ruler_test_select (bContext *UNUSED(C), wmGizmo *gz, const int mval[2]) |
| static int | gizmo_ruler_modal (bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag) |
| static int | gizmo_ruler_invoke (bContext *C, wmGizmo *gz, const wmEvent *event) |
| static void | gizmo_ruler_exit (bContext *C, wmGizmo *gz, const bool cancel) |
| static int | gizmo_ruler_cursor_get (wmGizmo *gz) |
| void | VIEW3D_GT_ruler_item (wmGizmoType *gzt) |
Ruler Gizmo Group | |
| static void | WIDGETGROUP_ruler_setup (const bContext *C, wmGizmoGroup *gzgroup) |
| void | VIEW3D_GGT_ruler (wmGizmoGroupType *gzgt) |
Add Ruler Operator | |
| static bool | view3d_ruler_poll (bContext *C) |
| static int | view3d_ruler_add_invoke (bContext *C, wmOperator *op, const wmEvent *event) |
| void | VIEW3D_OT_ruler_add (wmOperatorType *ot) |
Remove Ruler Operator | |
| static int | view3d_ruler_remove_invoke (bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) |
| void | VIEW3D_OT_ruler_remove (wmOperatorType *ot) |
Variables | |
| static const char * | view3d_gzgt_ruler_id = "VIEW3D_GGT_ruler" |
Ruler/Grease Pencil Conversion | |
| #define | RULER_ID "RulerData3D" |
| static bGPDlayer * | view3d_ruler_layer_get (bGPdata *gpd) |
| static RulerItem * | gzgroup_ruler_item_first_get (wmGizmoGroup *gzgroup) |
| static bool | view3d_ruler_to_gpencil (bContext *C, wmGizmoGroup *gzgroup) |
| static bool | view3d_ruler_from_gpencil (const bContext *C, wmGizmoGroup *gzgroup) |
| #define ARC_STEPS 24 |
| #define MVAL_MAX_PX_DIST 12.0f |
Definition at line 74 of file view3d_gizmo_ruler.c.
| #define PART_LINE 0xff |
Definition at line 91 of file view3d_gizmo_ruler.c.
| #define RULER_ID "RulerData3D" |
Definition at line 427 of file view3d_gizmo_ruler.c.
| #define RULER_PICK_DIST 12.0f |
Definition at line 87 of file view3d_gizmo_ruler.c.
| #define RULER_PICK_DIST_SQ (RULER_PICK_DIST * RULER_PICK_DIST) |
Definition at line 88 of file view3d_gizmo_ruler.c.
| typedef struct RulerInteraction RulerInteraction |
| anonymous enum |
| Enumerator | |
|---|---|
| RULERITEM_USE_ANGLE | Use protractor. |
| RULERITEM_USE_ANGLE_ACTIVE | Protractor vertex is selected (deleting removes it). |
Definition at line 79 of file view3d_gizmo_ruler.c.
| anonymous enum |
| Enumerator | |
|---|---|
| RULER_STATE_NORMAL | |
| RULER_STATE_DRAG | |
Definition at line 96 of file view3d_gizmo_ruler.c.
|
static |
Definition at line 1087 of file view3d_gizmo_ruler.c.
References wmGizmo::highlight_part, PART_LINE, WM_CURSOR_CROSS, and WM_CURSOR_NSEW_SCROLL.
Referenced by VIEW3D_GT_ruler_item().
Definition at line 547 of file view3d_gizmo_ruler.c.
References angle(), angle_normalized_v3v3(), ARC_STEPS, axis_angle_to_quat(), BLF_color3ubv(), BLF_disable(), BLF_draw(), BLF_enable(), blf_mono_font, BLF_position(), BLF_rotation(), BLF_ROTATION, BLF_size(), BLF_width_and_height(), C, RulerItem::co, col, copy_v3_fl(), copy_v3_v3(), cross_v3_v3v3(), CTX_data_scene(), wmGizmoGroup::customdata, ED_view3d_pixel_size_no_ui_scale(), ED_view3d_project_float_global(), RulerItem::flag, GPU_blend(), GPU_BLEND_ALPHA, GPU_BLEND_NONE, GPU_COMP_F32, GPU_FETCH_FLOAT, GPU_line_smooth(), GPU_line_width(), GPU_matrix_identity_set(), GPU_matrix_pop(), GPU_matrix_pop_projection(), GPU_matrix_projection_set, GPU_matrix_push(), GPU_matrix_push_projection(), GPU_matrix_set, GPU_PRIM_LINE_STRIP, GPU_PRIM_LINES, GPU_SHADER_2D_UNIFORM_COLOR, GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR, GPU_SHADER_3D_UNIFORM_COLOR, GPU_vertformat_attr_add(), GPU_viewport_size_get_f(), immBegin(), immBindBuiltinProgram(), immEnd(), immRectf(), immUnbindProgram(), immUniform1f(), immUniform1i(), immUniform2f(), immUniformArray4fv(), immUniformColor3fv(), immUniformColor3ubv(), immUniformColor4fv(), immVertex2f(), immVertex2fv(), immVertex3fv(), immVertexFormat(), RulerInfo::item_active, len_v2v2(), madd_v2_v2v2fl(), madd_v3_v3v3fl(), mid_v2_v2v2(), min_fff(), mul_qt_v3(), normalize_v2(), normalize_v3(), wmGizmo::parent_gzgroup, RulerInfo::region, ARegion::regiondata, ruler_item_as_string(), RULERITEM_USE_ANGLE, RULERITEM_USE_ANGLE_ACTIVE, scene, sub_v2_v2v2(), sub_v3_v3v3(), TH_TEXT, TH_WIRE, UI_GetThemeColor3ubv(), Scene::unit, V3D_PROJ_RET_OK, V3D_PROJ_TEST_CLIP_NEAR, RegionView3D::viewmat, RegionView3D::winmat, and wmOrtho2_region_pixelspace().
Referenced by VIEW3D_GT_ruler_item().
Definition at line 1068 of file view3d_gizmo_ruler.c.
References C, wmGizmoGroup::customdata, RulerInfo::gizmo, wmGizmo::interaction_data, MEM_SAFE_FREE, wmGizmo::parent_gzgroup, RulerInfo::prop_prevpoint, wmGizmo::ptr, RNA_property_unset(), RULER_STATE_DRAG, RULER_STATE_NORMAL, ruler_state_set(), RulerInfo::snap_data, RulerInfo::state, and view3d_ruler_to_gpencil().
Referenced by VIEW3D_GT_ruler_item().
Definition at line 975 of file view3d_gizmo_ruler.c.
References C, CLAMP, RulerItem::co, RulerInteraction::co_index, copy_v3_v3(), CTX_data_ensure_evaluated_depsgraph(), wmGizmoGroup::customdata, depsgraph, RulerInteraction::drag_start_co, ED_view3d_project_float_global(), RulerItem::flag, RulerInfo::gizmo, wmGizmo::highlight_part, wmGizmo::interaction_data, interp_v3_v3v3(), RulerInfo::item_active, line_point_factor_v2(), MEM_callocN, wmEvent::mval, NULL, OPERATOR_RUNNING_MODAL, wmGizmo::parent_gzgroup, PART_LINE, RulerInfo::prop_prevpoint, wmGizmo::ptr, RulerInfo::region, RNA_property_float_set_array(), RNA_property_unset(), RULER_STATE_DRAG, ruler_state_set(), RULERITEM_USE_ANGLE, RULERITEM_USE_ANGLE_ACTIVE, RulerInfo::snap_data, UNPACK2, USE_SNAP_DETECT_FROM_KEYMAP_HACK, V3D_PROJ_TEST_NOP, and view3d_ruler_item_mousemove().
Referenced by VIEW3D_GT_ruler_item().
|
static |
Definition at line 927 of file view3d_gizmo_ruler.c.
References C, CTX_data_ensure_evaluated_depsgraph(), CTX_wm_region(), wmGizmoGroup::customdata, depsgraph, RulerInfo::do_thickness, RulerInfo::drag_state_prev, ED_region_tag_redraw_editor_overlays(), KM_RELEASE, MOUSEMOVE, wmEvent::mval, OPERATOR_RUNNING_MODAL, wmGizmo::parent_gzgroup, RulerInfo::region, RULER_STATE_DRAG, RulerInfo::state, wmEvent::type, USE_SNAP_DETECT_FROM_KEYMAP_HACK, view3d_ruler_item_mousemove(), WM_GIZMO_TWEAK_PRECISE, and WM_GIZMO_TWEAK_SNAP.
Referenced by VIEW3D_GT_ruler_item().
Definition at line 907 of file view3d_gizmo_ruler.c.
References RulerItem::flag, wmGizmo::parent_gzgroup, PART_LINE, RULERITEM_USE_ANGLE, UNPACK2, and view3d_ruler_pick().
Referenced by VIEW3D_GT_ruler_item().
|
static |
Definition at line 418 of file view3d_gizmo_ruler.c.
References BLI_assert, wmGizmoGroup::customdata, ListBase::first, RulerInfo::gizmo, wmGizmoGroup::gizmos, and RulerInfo::snap_data.
Referenced by view3d_ruler_to_gpencil().
|
static |
Definition at line 153 of file view3d_gizmo_ruler.c.
References RulerItem::gz, NULL, WM_GIZMO_DRAW_MODAL, WM_gizmo_new_ptr(), WM_gizmo_set_flag(), and WM_gizmotype_find().
Referenced by view3d_ruler_add_invoke(), and view3d_ruler_from_gpencil().
|
static |
Definition at line 171 of file view3d_gizmo_ruler.c.
References angle_v3v3v3(), B_UNIT_LENGTH, B_UNIT_ROTATION, BKE_unit_value_as_string(), BLI_snprintf(), RulerItem::co, RulerItem::flag, len_v3v3(), RAD2DEGF, RULERITEM_USE_ANGLE, UnitSettings::scale_length, UnitSettings::system, and USER_UNIT_NONE.
Referenced by gizmo_ruler_draw().
|
static |
Definition at line 162 of file view3d_gizmo_ruler.c.
References C, wmGizmoGroup::customdata, wmGizmoGroup::gizmos, RulerItem::gz, RulerInfo::item_active, NULL, wmGizmoGroup::parent_gzmap, and WM_gizmo_unlink().
Referenced by view3d_ruler_remove_invoke().
|
static |
Ensure the 'snap_context' is only cached while dragging, needed since the user may toggle modes between tool use.
Definition at line 278 of file view3d_gizmo_ruler.c.
References BLI_assert, RulerInfo::drag_state_prev, RULER_STATE_DRAG, RULER_STATE_NORMAL, RulerInfo::state, and state.
Referenced by gizmo_ruler_exit(), and gizmo_ruler_invoke().
| void VIEW3D_GGT_ruler | ( | wmGizmoGroupType * | gzgt | ) |
Definition at line 1158 of file view3d_gizmo_ruler.c.
References ED_gizmo_poll_or_unlink_delayed_from_tool(), wmGizmoGroupType::flag, wmGizmoGroupType::gzmap_params, wmGizmoGroupType::idname, wmGizmoGroupType::name, wmGizmoGroupType::poll, wmGizmoMapType_Params::regionid, RGN_TYPE_WINDOW, wmGizmoGroupType::setup, SPACE_VIEW3D, wmGizmoMapType_Params::spaceid, view3d_gzgt_ruler_id, WIDGETGROUP_ruler_setup(), WM_GIZMOGROUPTYPE_3D, WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL, and WM_GIZMOGROUPTYPE_SCALE.
Referenced by view3d_widgets().
| void VIEW3D_GT_ruler_item | ( | wmGizmoType * | gzt | ) |
Definition at line 1095 of file view3d_gizmo_ruler.c.
References wmGizmoType::cursor_get, wmGizmoType::draw, wmGizmoType::exit, gizmo_ruler_cursor_get(), gizmo_ruler_draw(), gizmo_ruler_exit(), gizmo_ruler_invoke(), gizmo_ruler_modal(), gizmo_ruler_test_select(), wmGizmoType::idname, wmGizmoType::invoke, wmGizmoType::modal, wmGizmoType::struct_size, and wmGizmoType::test_select.
Referenced by view3d_widgets().
| void VIEW3D_OT_ruler_add | ( | wmOperatorType * | ot | ) |
Definition at line 1244 of file view3d_gizmo_ruler.c.
References wmOperatorType::description, wmOperatorType::flag, wmOperatorType::idname, wmOperatorType::invoke, wmOperatorType::name, OPTYPE_INTERNAL, OPTYPE_UNDO, ot, wmOperatorType::poll, view3d_ruler_add_invoke(), and view3d_ruler_poll().
Referenced by view3d_operatortypes().
| void VIEW3D_OT_ruler_remove | ( | wmOperatorType * | ot | ) |
Definition at line 1298 of file view3d_gizmo_ruler.c.
References wmOperatorType::flag, wmOperatorType::idname, wmOperatorType::invoke, wmOperatorType::name, OPTYPE_INTERNAL, OPTYPE_UNDO, ot, wmOperatorType::poll, view3d_ruler_poll(), and view3d_ruler_remove_invoke().
Referenced by view3d_operatortypes().
|
static |
Definition at line 1188 of file view3d_gizmo_ruler.c.
References BKE_report(), C, RulerItem::co, RulerInteraction::co_index, copy_v3_v3(), CTX_data_ensure_evaluated_depsgraph(), CTX_wm_region(), CTX_wm_view3d(), wmGizmoGroup::customdata, depsgraph, RulerInteraction::drag_start_co, RulerInfo::gizmo, View3D::gizmo_flag, ARegion::gizmo_map, RulerItem::gz, wmGizmo::highlight_part, wmGizmo::interaction_data, wmEvent::mval, negate_v3_v3(), NULL, OB_SOLID, RegionView3D::ofs, OPERATOR_CANCELLED, OPERATOR_FINISHED, OPERATOR_RUNNING_MODAL, RulerInfo::prop_prevpoint, wmGizmo::ptr, ARegion::regiondata, wmOperator::reports, RNA_property_float_set_array(), RPT_WARNING, ruler_item_add(), View3D::shading, RulerInfo::snap_data, View3DShading::type, USE_SNAP_DETECT_FROM_KEYMAP_HACK, V3D_GIZMO_HIDE, V3D_GIZMO_HIDE_TOOL, view3d_gzgt_ruler_id, view3d_ruler_item_mousemove(), view3d_ruler_item_project(), WM_gizmo_highlight_set(), WM_gizmomap_group_find(), WM_OP_INVOKE_REGION_WIN, and WM_operator_name_call().
Referenced by VIEW3D_OT_ruler_add().
|
static |
Definition at line 499 of file view3d_gizmo_ruler.c.
References BKE_gpencil_layer_frame_get(), C, CFRA, RulerItem::co, copy_v3_v3(), CTX_data_scene(), ListBase::first, RulerItem::flag, GP_GETFRAME_USE_PREV, Scene::gpd, bGPDstroke::next, NULL, bGPDstroke::points, ruler_item_add(), RULERITEM_USE_ANGLE, scene, bGPDframe::strokes, bGPDstroke::totpoints, view3d_ruler_layer_get(), and bGPDspoint::x.
Referenced by WIDGETGROUP_ruler_setup().
|
static |
Definition at line 303 of file view3d_gizmo_ruler.c.
References RulerInfo::area, RulerItem::co, RulerInteraction::co_index, copy_v3_v3(), DEG_get_input_scene(), depsgraph, RulerInteraction::drag_start_co, ED_gizmotypes_snap_3d_context_ensure(), ED_gizmotypes_snap_3d_data_get(), ED_gizmotypes_snap_3d_is_enabled(), ED_gizmotypes_snap_3d_update(), ED_transform_snap_object_project_ray(), ED_transform_snap_object_project_view3d(), ListBase::first, RulerItem::flag, RulerInfo::gizmo, RulerItem::gz, wmGizmo::interaction_data, madd_v3_v3v3fl(), MVAL_MAX_PX_DIST, negate_v3(), NULL, RulerInfo::prop_prevpoint, wmGizmo::ptr, RulerInfo::region, RNA_property_float_set_array(), RULERITEM_USE_ANGLE, SCE_SNAP_MODE_FACE, scene, SNAP_ALL, RulerInfo::snap_data, ScrArea::spacedata, UNPACK2, view3d_ruler_item_project(), and RulerInfo::wm.
Referenced by gizmo_ruler_invoke(), gizmo_ruler_modal(), and view3d_ruler_add_invoke().
|
static |
Definition at line 297 of file view3d_gizmo_ruler.c.
References RulerInfo::area, ED_view3d_win_to_3d_int(), ListBase::first, RulerInfo::region, and ScrArea::spacedata.
Referenced by view3d_ruler_add_invoke(), and view3d_ruler_item_mousemove().
Definition at line 408 of file view3d_gizmo_ruler.c.
References GP_LAYER_IS_RULER, bGPdata::layers, LISTBASE_FOREACH, and NULL.
Referenced by view3d_ruler_from_gpencil(), and view3d_ruler_to_gpencil().
|
static |
Definition at line 204 of file view3d_gizmo_ruler.c.
References RulerItem::co, wmGizmoGroup::customdata, dist_squared_to_line_segment_v2(), ED_view3d_project_float_global(), RulerItem::flag, len_squared_v2v2(), min_axis_v3(), min_ff(), min_fff(), RulerInfo::region, RULER_PICK_DIST_SQ, RULERITEM_USE_ANGLE, UNPACK2, UNPACK3, and V3D_PROJ_TEST_NOP.
Referenced by gizmo_ruler_test_select().
|
static |
Definition at line 1178 of file view3d_gizmo_ruler.c.
References C, CTX_wm_region_view3d(), bToolRef_Runtime::gizmo_group, NULL, STREQ, view3d_gzgt_ruler_id, and WM_toolsystem_runtime_from_context().
Referenced by VIEW3D_OT_ruler_add(), and VIEW3D_OT_ruler_remove().
|
static |
Definition at line 1264 of file view3d_gizmo_ruler.c.
References BKE_report(), C, CTX_wm_region(), CTX_wm_view3d(), wmGizmoGroup::customdata, ED_region_tag_redraw_editor_overlays(), RulerItem::flag, View3D::gizmo_flag, ARegion::gizmo_map, RulerInfo::item_active, OPERATOR_CANCELLED, OPERATOR_FINISHED, OPERATOR_PASS_THROUGH, wmOperator::reports, RPT_WARNING, ruler_item_remove(), RULERITEM_USE_ANGLE, RULERITEM_USE_ANGLE_ACTIVE, V3D_GIZMO_HIDE, V3D_GIZMO_HIDE_TOOL, view3d_gzgt_ruler_id, view3d_ruler_to_gpencil(), and WM_gizmomap_group_find().
Referenced by VIEW3D_OT_ruler_remove().
|
static |
Definition at line 428 of file view3d_gizmo_ruler.c.
References bGPDstroke::aspect_ratio, BKE_gpencil_data_addnew(), BKE_gpencil_free_strokes(), BKE_gpencil_layer_addnew(), BKE_gpencil_layer_frame_get(), BLI_addtail(), C, CFRA, RulerItem::co, bGPDlayer::color, copy_v2_fl(), copy_v3_v3(), copy_v4_v4(), CTX_data_main(), CTX_data_scene(), bGPDstroke::fill_opacity_fac, RulerItem::flag, bGPDstroke::flag, bGPDlayer::flag, GP_GETFRAME_ADD_NEW, GP_LAYER_HIDE, GP_LAYER_IS_RULER, GP_STROKE_3DSPACE, Scene::gpd, RulerItem::gz, gzgroup_ruler_item_first_get(), bGPDstroke::hardeness, MEM_callocN, wmGizmo::next, NULL, bGPDstroke::points, bGPDspoint::pressure, RULER_ID, RULERITEM_USE_ANGLE, scene, bGPDspoint::strength, bGPDframe::strokes, bGPDstroke::thickness, bGPDlayer::thickness, bGPDstroke::totpoints, bGPDstroke::uv_scale, view3d_ruler_layer_get(), and bGPDspoint::x.
Referenced by gizmo_ruler_exit(), and view3d_ruler_remove_invoke().
|
static |
Definition at line 1117 of file view3d_gizmo_ruler.c.
References blender::compositor::area(), RulerInfo::area, C, CTX_wm_area(), CTX_wm_manager(), CTX_wm_region(), CTX_wm_window(), wmGizmoGroup::customdata, RulerInfo::gizmo, MEM_callocN, NULL, ot, RulerInfo::prop_prevpoint, wmGizmo::ptr, RulerInfo::region, RNA_enum_set(), RNA_struct_find_property(), SCE_SNAP_MODE_EDGE, SCE_SNAP_MODE_EDGE_MIDPOINT, SCE_SNAP_MODE_EDGE_PERPENDICULAR, SCE_SNAP_MODE_FACE, SCE_SNAP_MODE_VERTEX, RulerInfo::snap_data, view3d_ruler_from_gpencil(), RulerInfo::win, RulerInfo::wm, WM_gizmo_new_ptr(), WM_gizmo_operator_set(), WM_gizmo_set_color(), WM_gizmotype_find(), and WM_operatortype_find().
Referenced by VIEW3D_GGT_ruler().
|
static |
Definition at line 72 of file view3d_gizmo_ruler.c.
Referenced by VIEW3D_GGT_ruler(), view3d_ruler_add_invoke(), view3d_ruler_poll(), and view3d_ruler_remove_invoke().