Blender  V2.93
Classes | Macros | Typedefs | Enumerations | Variables
view3d_gizmo_ruler.c File Reference
#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 RulerItemruler_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 bGPDlayerview3d_ruler_layer_get (bGPdata *gpd)
 
static RulerItemgzgroup_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)
 

Macro Definition Documentation

◆ ARC_STEPS

#define ARC_STEPS   24

◆ MVAL_MAX_PX_DIST

#define MVAL_MAX_PX_DIST   12.0f

Definition at line 74 of file view3d_gizmo_ruler.c.

◆ PART_LINE

#define PART_LINE   0xff

Definition at line 91 of file view3d_gizmo_ruler.c.

◆ RULER_ID

#define RULER_ID   "RulerData3D"

Definition at line 427 of file view3d_gizmo_ruler.c.

◆ RULER_PICK_DIST

#define RULER_PICK_DIST   12.0f

Definition at line 87 of file view3d_gizmo_ruler.c.

◆ RULER_PICK_DIST_SQ

#define RULER_PICK_DIST_SQ   (RULER_PICK_DIST * RULER_PICK_DIST)

Definition at line 88 of file view3d_gizmo_ruler.c.

Typedef Documentation

◆ RulerInfo

typedef struct RulerInfo RulerInfo

◆ RulerInteraction

◆ RulerItem

typedef struct RulerItem RulerItem

Enumeration Type Documentation

◆ anonymous enum

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

anonymous enum
Enumerator
RULER_STATE_NORMAL 
RULER_STATE_DRAG 

Definition at line 96 of file view3d_gizmo_ruler.c.

Function Documentation

◆ gizmo_ruler_cursor_get()

static int gizmo_ruler_cursor_get ( wmGizmo gz)
static

◆ gizmo_ruler_draw()

static void gizmo_ruler_draw ( const bContext C,
wmGizmo gz 
)
static

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().

◆ gizmo_ruler_exit()

static void gizmo_ruler_exit ( bContext C,
wmGizmo gz,
const bool  cancel 
)
static

◆ gizmo_ruler_invoke()

static int gizmo_ruler_invoke ( bContext C,
wmGizmo gz,
const wmEvent event 
)
static

◆ gizmo_ruler_modal()

static int gizmo_ruler_modal ( bContext C,
wmGizmo gz,
const wmEvent event,
eWM_GizmoFlagTweak  tweak_flag 
)
static

◆ gizmo_ruler_test_select()

static int gizmo_ruler_test_select ( bContext UNUSEDC,
wmGizmo gz,
const int  mval[2] 
)
static

◆ gzgroup_ruler_item_first_get()

static RulerItem* gzgroup_ruler_item_first_get ( wmGizmoGroup gzgroup)
static

◆ ruler_item_add()

static RulerItem* ruler_item_add ( wmGizmoGroup gzgroup)
static

◆ ruler_item_as_string()

static void ruler_item_as_string ( RulerItem ruler_item,
UnitSettings unit,
char *  numstr,
size_t  numstr_size,
int  prec 
)
static

◆ ruler_item_remove()

static void ruler_item_remove ( bContext C,
wmGizmoGroup gzgroup,
RulerItem ruler_item 
)
static

◆ ruler_state_set()

static void ruler_state_set ( RulerInfo ruler_info,
int  state 
)
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().

◆ VIEW3D_GGT_ruler()

void VIEW3D_GGT_ruler ( wmGizmoGroupType gzgt)

◆ VIEW3D_GT_ruler_item()

void VIEW3D_GT_ruler_item ( wmGizmoType gzt)

◆ VIEW3D_OT_ruler_add()

void VIEW3D_OT_ruler_add ( wmOperatorType ot)

◆ VIEW3D_OT_ruler_remove()

void VIEW3D_OT_ruler_remove ( wmOperatorType ot)

◆ view3d_ruler_add_invoke()

static int view3d_ruler_add_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ view3d_ruler_from_gpencil()

static bool view3d_ruler_from_gpencil ( const bContext C,
wmGizmoGroup gzgroup 
)
static

◆ view3d_ruler_item_mousemove()

static bool view3d_ruler_item_mousemove ( struct Depsgraph depsgraph,
RulerInfo ruler_info,
RulerItem ruler_item,
const int  mval[2],
const bool  do_thickness 
)
static

◆ view3d_ruler_item_project()

static void view3d_ruler_item_project ( RulerInfo ruler_info,
float  r_co[3],
const int  xy[2] 
)
static

◆ view3d_ruler_layer_get()

static bGPDlayer* view3d_ruler_layer_get ( bGPdata gpd)
static

◆ view3d_ruler_pick()

static bool view3d_ruler_pick ( wmGizmoGroup gzgroup,
RulerItem ruler_item,
const float  mval[2],
int *  r_co_index 
)
static

◆ view3d_ruler_poll()

static bool view3d_ruler_poll ( bContext C)
static

◆ view3d_ruler_remove_invoke()

static int view3d_ruler_remove_invoke ( bContext C,
wmOperator op,
const wmEvent UNUSEDevent 
)
static

◆ view3d_ruler_to_gpencil()

static bool view3d_ruler_to_gpencil ( bContext C,
wmGizmoGroup gzgroup 
)
static

◆ WIDGETGROUP_ruler_setup()

static void WIDGETGROUP_ruler_setup ( const bContext C,
wmGizmoGroup gzgroup 
)
static

Variable Documentation

◆ view3d_gzgt_ruler_id

const char* view3d_gzgt_ruler_id = "VIEW3D_GGT_ruler"
static