Blender  V3.3
Classes
gpencil_select.c File Reference
#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
#include "BLI_lasso_2d.h"
#include "BLI_math_vector.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "DNA_gpencil_types.h"
#include "DNA_material_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "BKE_context.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_curve.h"
#include "BKE_gpencil_geom.h"
#include "BKE_material.h"
#include "BKE_report.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "WM_api.h"
#include "WM_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "UI_view2d.h"
#include "ED_gpencil.h"
#include "ED_select_utils.h"
#include "ED_view3d.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "gpencil_intern.h"

Go to the source code of this file.

Classes

struct  GP_SelectUserData
 

Functions

Shared Utilities
static int gpencil_select_mode_from_sculpt (eGP_Sculpt_SelectMaskFlag mode)
 
static int gpencil_select_mode_from_vertex (eGP_Sculpt_SelectMaskFlag mode)
 
static bool gpencil_select_poll (bContext *C)
 
static bool gpencil_3d_point_to_screen_space (ARegion *region, const float diff_mat[4][4], const float co[3], int r_co[2])
 
static void deselect_all_selected (bContext *C)
 
static void select_all_stroke_points (bGPdata *gpd, bGPDstroke *gps, bool select)
 
static void select_all_curve_points (bGPdata *gpd, bGPDstroke *gps, bGPDcurve *gpc, bool deselect)
 
Select All Operator
static bool gpencil_select_all_poll (bContext *C)
 
static int gpencil_select_all_exec (bContext *C, wmOperator *op)
 
void GPENCIL_OT_select_all (wmOperatorType *ot)
 
Select Linked Operator
static int gpencil_select_linked_exec (bContext *C, wmOperator *op)
 
void GPENCIL_OT_select_linked (wmOperatorType *ot)
 
Select Alternate Operator
static int gpencil_select_alternate_exec (bContext *C, wmOperator *op)
 
void GPENCIL_OT_select_alternate (wmOperatorType *ot)
 
Select Random Operator
static int gpencil_select_random_exec (bContext *C, wmOperator *op)
 
void GPENCIL_OT_select_random (wmOperatorType *ot)
 
Select First
static int gpencil_select_first_exec (bContext *C, wmOperator *op)
 
void GPENCIL_OT_select_first (wmOperatorType *ot)
 
Select Last
static int gpencil_select_last_exec (bContext *C, wmOperator *op)
 
void GPENCIL_OT_select_last (wmOperatorType *ot)
 
Select Mode Operator
static int gpencil_select_more_exec (bContext *C, wmOperator *UNUSED(op))
 
void GPENCIL_OT_select_more (wmOperatorType *ot)
 
Select Less Operator
static int gpencil_select_less_exec (bContext *C, wmOperator *UNUSED(op))
 
void GPENCIL_OT_select_less (wmOperatorType *ot)
 
Circle Select Operator
static bool gpencil_stroke_do_circle_sel (bGPdata *gpd, bGPDlayer *gpl, bGPDstroke *gps, GP_SpaceConversion *gsc, const int mx, const int my, const int radius, const bool select, rcti *rect, const float diff_mat[4][4], const int selectmode, const float scale, const bool is_curve_edit)
 
static bool gpencil_do_curve_circle_sel (bContext *C, bGPDstroke *gps, bGPDcurve *gpc, const int mx, const int my, const int radius, const bool select, rcti *rect, const float diff_mat[4][4], const int selectmode)
 
static int gpencil_circle_select_exec (bContext *C, wmOperator *op)
 
void GPENCIL_OT_select_circle (wmOperatorType *ot)
 
Box Select Operator
static bool gpencil_test_box (ARegion *region, const float diff_mat[4][4], const float pt[3], GP_SelectUserData *user_data)
 
static int gpencil_box_select_exec (bContext *C, wmOperator *op)
 
void GPENCIL_OT_select_box (wmOperatorType *ot)
 
Lasso Select Operator
static bool gpencil_test_lasso (ARegion *region, const float diff_mat[4][4], const float pt[3], GP_SelectUserData *user_data)
 
static int gpencil_lasso_select_exec (bContext *C, wmOperator *op)
 
void GPENCIL_OT_select_lasso (wmOperatorType *ot)
 
Mouse Pick Select Operator
static void gpencil_select_curve_point (bContext *C, const int mval[2], const int radius_squared, bGPDlayer **r_gpl, bGPDstroke **r_gps, bGPDcurve **r_gpc, bGPDcurve_point **r_pt, char *handle)
 
static int gpencil_select_exec (bContext *C, wmOperator *op)
 
static int gpencil_select_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void GPENCIL_OT_select (wmOperatorType *ot)
 
static void gpencil_selected_hue_table (bContext *C, Object *ob, const int threshold, GHash *hue_table)
 
static bool gpencil_select_vertex_color_poll (bContext *C)
 
static int gpencil_select_vertex_color_exec (bContext *C, wmOperator *op)
 
void GPENCIL_OT_select_vertex_color (wmOperatorType *ot)
 

Select Grouped Operator

enum  eGP_SelectGrouped { GP_SEL_SAME_LAYER = 0 , GP_SEL_SAME_MATERIAL = 1 }
 
typedef enum eGP_SelectGrouped eGP_SelectGrouped
 
static bool gpencil_select_same_layer (bContext *C)
 
static bool gpencil_select_same_material (bContext *C)
 
static int gpencil_select_grouped_exec (bContext *C, wmOperator *op)
 
void GPENCIL_OT_select_grouped (wmOperatorType *ot)
 

Generic Select Utility

Use for lasso & box select.

typedef struct GP_SelectUserData GP_SelectUserData
 
typedef bool(* GPencilTestFn) (ARegion *region, const float diff_mat[4][4], const float pt[3], GP_SelectUserData *user_data)
 
static bool gpencil_generic_curve_select (bContext *C, Object *ob, GPencilTestFn is_inside_fn, rcti UNUSED(box), GP_SelectUserData *user_data, const bool strokemode, const eSelectOp sel_op)
 
static bool gpencil_generic_stroke_select (bContext *C, Object *ob, bGPdata *gpd, GPencilTestFn is_inside_fn, rcti box, GP_SelectUserData *user_data, const bool strokemode, const bool segmentmode, const eSelectOp sel_op, const float scale, const bool is_curve_edit)
 
static int gpencil_generic_select_exec (bContext *C, wmOperator *op, GPencilTestFn is_inside_fn, rcti box, GP_SelectUserData *user_data)
 

Typedef Documentation

◆ eGP_SelectGrouped

◆ GP_SelectUserData

◆ GPencilTestFn

typedef bool(* GPencilTestFn) (ARegion *region, const float diff_mat[4][4], const float pt[3], GP_SelectUserData *user_data)

Definition at line 1807 of file gpencil_select.c.

Enumeration Type Documentation

◆ eGP_SelectGrouped

Enumerator
GP_SEL_SAME_LAYER 
GP_SEL_SAME_MATERIAL 

Definition at line 739 of file gpencil_select.c.

Function Documentation

◆ deselect_all_selected()

static void deselect_all_selected ( bContext C)
static

◆ gpencil_3d_point_to_screen_space()

static bool gpencil_3d_point_to_screen_space ( ARegion region,
const float  diff_mat[4][4],
const float  co[3],
int  r_co[2] 
)
static

◆ gpencil_box_select_exec()

static int gpencil_box_select_exec ( bContext C,
wmOperator op 
)
static

◆ gpencil_circle_select_exec()

static int gpencil_circle_select_exec ( bContext C,
wmOperator op 
)
static

◆ gpencil_do_curve_circle_sel()

static bool gpencil_do_curve_circle_sel ( bContext C,
bGPDstroke gps,
bGPDcurve gpc,
const int  mx,
const int  my,
const int  radius,
const bool  select,
rcti rect,
const float  diff_mat[4][4],
const int  selectmode 
)
static

◆ gpencil_generic_curve_select()

static bool gpencil_generic_curve_select ( bContext C,
Object ob,
GPencilTestFn  is_inside_fn,
rcti   UNUSEDbox,
GP_SelectUserData user_data,
const bool  strokemode,
const eSelectOp  sel_op 
)
static

◆ gpencil_generic_select_exec()

static int gpencil_generic_select_exec ( bContext C,
wmOperator op,
GPencilTestFn  is_inside_fn,
rcti  box,
GP_SelectUserData user_data 
)
static

◆ gpencil_generic_stroke_select()

static bool gpencil_generic_stroke_select ( bContext C,
Object ob,
bGPdata gpd,
GPencilTestFn  is_inside_fn,
rcti  box,
GP_SelectUserData user_data,
const bool  strokemode,
const bool  segmentmode,
const eSelectOp  sel_op,
const float  scale,
const bool  is_curve_edit 
)
static

◆ gpencil_lasso_select_exec()

static int gpencil_lasso_select_exec ( bContext C,
wmOperator op 
)
static

◆ GPENCIL_OT_select()

void GPENCIL_OT_select ( wmOperatorType ot)

◆ GPENCIL_OT_select_all()

void GPENCIL_OT_select_all ( wmOperatorType ot)

◆ GPENCIL_OT_select_alternate()

void GPENCIL_OT_select_alternate ( wmOperatorType ot)

◆ GPENCIL_OT_select_box()

void GPENCIL_OT_select_box ( wmOperatorType ot)

◆ GPENCIL_OT_select_circle()

void GPENCIL_OT_select_circle ( wmOperatorType ot)

◆ GPENCIL_OT_select_first()

void GPENCIL_OT_select_first ( wmOperatorType ot)

◆ GPENCIL_OT_select_grouped()

void GPENCIL_OT_select_grouped ( wmOperatorType ot)

◆ GPENCIL_OT_select_lasso()

void GPENCIL_OT_select_lasso ( wmOperatorType ot)

◆ GPENCIL_OT_select_last()

void GPENCIL_OT_select_last ( wmOperatorType ot)

◆ GPENCIL_OT_select_less()

void GPENCIL_OT_select_less ( wmOperatorType ot)

◆ GPENCIL_OT_select_linked()

void GPENCIL_OT_select_linked ( wmOperatorType ot)

◆ GPENCIL_OT_select_more()

void GPENCIL_OT_select_more ( wmOperatorType ot)

◆ GPENCIL_OT_select_random()

void GPENCIL_OT_select_random ( wmOperatorType ot)

◆ GPENCIL_OT_select_vertex_color()

void GPENCIL_OT_select_vertex_color ( wmOperatorType ot)

◆ gpencil_select_all_exec()

static int gpencil_select_all_exec ( bContext C,
wmOperator op 
)
static

◆ gpencil_select_all_poll()

static bool gpencil_select_all_poll ( bContext C)
static

◆ gpencil_select_alternate_exec()

static int gpencil_select_alternate_exec ( bContext C,
wmOperator op 
)
static

◆ gpencil_select_curve_point()

static void gpencil_select_curve_point ( bContext C,
const int  mval[2],
const int  radius_squared,
bGPDlayer **  r_gpl,
bGPDstroke **  r_gps,
bGPDcurve **  r_gpc,
bGPDcurve_point **  r_pt,
char *  handle 
)
static

◆ gpencil_select_exec()

static int gpencil_select_exec ( bContext C,
wmOperator op 
)
static

Definition at line 2402 of file gpencil_select.c.

References blender::compositor::area(), bGPDcurve_point::bezt, BEZT_DESEL_IDX, BEZT_ISSEL_ANY, BEZT_SEL_IDX, BKE_gpencil_curve_sync_selection(), BKE_gpencil_stroke_editcurve_update(), BKE_gpencil_stroke_geometry_update(), BKE_gpencil_stroke_select_index_reset(), BKE_gpencil_stroke_select_index_set(), BKE_gpencil_stroke_sync_selection(), BKE_report(), bool, C, CTX_data_active_object(), CTX_data_tool_settings(), CTX_wm_area(), DEG_id_tag_update(), deselect_all_selected(), ED_gpencil_data_get_active(), ED_gpencil_select_stroke_segment(), bGPDstroke::editcurve, ELEM, BezTriple::f1, BezTriple::f2, BezTriple::f3, bGPDspoint::flag, bGPDcurve_point::flag, bGPDcurve::flag, bGPDstroke::flag, GP_CURVE_POINT_SELECT, GP_CURVE_SELECT, GP_EVALUATED_STROKES_BEGIN, GP_EVALUATED_STROKES_END, ToolSettings::gp_sculpt, GP_SELECTMODE_SEGMENT, GP_SELECTMODE_STROKE, GP_SPOINT_SELECT, GP_STROKE_NEEDS_CURVE_UPDATE, GP_STROKE_SELECT, GPENCIL_CURVE_EDIT_SESSIONS_ON, gpencil_point_conversion_init(), gpencil_point_to_parent_space(), gpencil_point_to_xy(), gpencil_select_curve_point(), gpencil_select_mode_from_sculpt(), gpencil_select_mode_from_vertex(), ToolSettings::gpencil_selectmode_edit, ToolSettings::gpencil_selectmode_sculpt, ToolSettings::gpencil_selectmode_vertex, bGPDstroke_Runtime::gps_orig, bGPdata::id, ID_RECALC_COPY_ON_WRITE, ID_RECALC_GEOMETRY, GP_Sculpt_Settings::isect_threshold, len_manhattan_v2v2_int(), Object::mode, NA_SELECTED, NC_GEOM, NC_GPENCIL, ND_SELECT, NULL, OB_MODE_SCULPT_GPENCIL, OB_MODE_VERTEX_GPENCIL, OPERATOR_CANCELLED, OPERATOR_FINISHED, OPERATOR_PASS_THROUGH, bGPDstroke::points, bGPDspoint_Runtime::pt_orig, wmOperator::ptr, GP_SelectUserData::radius, wmOperator::reports, RNA_boolean_get(), RNA_int_get_array(), RPT_ERROR, bGPDspoint::runtime, bGPDstroke::runtime, SELECT, select_all_curve_points(), V2D_IS_CLIPPED, WM_event_add_notifier(), and xy.

Referenced by GPENCIL_OT_select(), and gpencil_select_invoke().

◆ gpencil_select_first_exec()

static int gpencil_select_first_exec ( bContext C,
wmOperator op 
)
static

◆ gpencil_select_grouped_exec()

static int gpencil_select_grouped_exec ( bContext C,
wmOperator op 
)
static

◆ gpencil_select_invoke()

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

◆ gpencil_select_last_exec()

static int gpencil_select_last_exec ( bContext C,
wmOperator op 
)
static

◆ gpencil_select_less_exec()

static int gpencil_select_less_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ gpencil_select_linked_exec()

static int gpencil_select_linked_exec ( bContext C,
wmOperator op 
)
static

◆ gpencil_select_mode_from_sculpt()

static int gpencil_select_mode_from_sculpt ( eGP_Sculpt_SelectMaskFlag  mode)
static

◆ gpencil_select_mode_from_vertex()

static int gpencil_select_mode_from_vertex ( eGP_Sculpt_SelectMaskFlag  mode)
static

◆ gpencil_select_more_exec()

static int gpencil_select_more_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ gpencil_select_poll()

static bool gpencil_select_poll ( bContext C)
static

◆ gpencil_select_random_exec()

static int gpencil_select_random_exec ( bContext C,
wmOperator op 
)
static

◆ gpencil_select_same_layer()

static bool gpencil_select_same_layer ( bContext C)
static

◆ gpencil_select_same_material()

static bool gpencil_select_same_material ( bContext C)
static

◆ gpencil_select_vertex_color_exec()

static int gpencil_select_vertex_color_exec ( bContext C,
wmOperator op 
)
static

◆ gpencil_select_vertex_color_poll()

static bool gpencil_select_vertex_color_poll ( bContext C)
static

◆ gpencil_selected_hue_table()

static void gpencil_selected_hue_table ( bContext C,
Object ob,
const int  threshold,
GHash hue_table 
)
static

◆ gpencil_stroke_do_circle_sel()

static bool gpencil_stroke_do_circle_sel ( bGPdata gpd,
bGPDlayer gpl,
bGPDstroke gps,
GP_SpaceConversion gsc,
const int  mx,
const int  my,
const int  radius,
const bool  select,
rcti rect,
const float  diff_mat[4][4],
const int  selectmode,
const float  scale,
const bool  is_curve_edit 
)
static

◆ gpencil_test_box()

static bool gpencil_test_box ( ARegion region,
const float  diff_mat[4][4],
const float  pt[3],
GP_SelectUserData user_data 
)
static

◆ gpencil_test_lasso()

static bool gpencil_test_lasso ( ARegion region,
const float  diff_mat[4][4],
const float  pt[3],
GP_SelectUserData user_data 
)
static

◆ select_all_curve_points()

static void select_all_curve_points ( bGPdata gpd,
bGPDstroke gps,
bGPDcurve gpc,
bool  deselect 
)
static

◆ select_all_stroke_points()

static void select_all_stroke_points ( bGPdata gpd,
bGPDstroke gps,
bool  select 
)
static