Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_select.c
| Show First 20 Lines • Show All 911 Lines • ▼ Show 20 Lines | static bool gp_stroke_do_circle_sel(bGPDlayer *gpl, | ||||
| return changed; | return changed; | ||||
| } | } | ||||
| static int gpencil_circle_select_exec(bContext *C, wmOperator *op) | static int gpencil_circle_select_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| bGPdata *gpd = ED_gpencil_data_get_active(C); | bGPdata *gpd = ED_gpencil_data_get_active(C); | ||||
| ToolSettings *ts = CTX_data_tool_settings(C); | ToolSettings *ts = CTX_data_tool_settings(C); | ||||
| const int selectmode = ts->gpencil_selectmode; | Object *ob = CTX_data_active_object(C); | ||||
| const int selectmode = (ob && ob->mode == OB_MODE_SCULPT_GPENCIL) ? | |||||
| ts->gpencil_selectmode_sculpt : | |||||
| ts->gpencil_selectmode_edit; | |||||
| const float scale = ts->gp_sculpt.isect_threshold; | const float scale = ts->gp_sculpt.isect_threshold; | ||||
| /* if not edit/sculpt mode, the event is catched but not processed */ | /* if not edit/sculpt mode, the event is catched but not processed */ | ||||
| if (GPENCIL_NONE_EDIT_MODE(gpd)) { | if (GPENCIL_NONE_EDIT_MODE(gpd)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| ▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | typedef bool (*GPencilTestFn)(bGPDstroke *gps, | ||||
| const float diff_mat[4][4], | const float diff_mat[4][4], | ||||
| void *user_data); | void *user_data); | ||||
| static int gpencil_generic_select_exec(bContext *C, | static int gpencil_generic_select_exec(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| GPencilTestFn is_inside_fn, | GPencilTestFn is_inside_fn, | ||||
| void *user_data) | void *user_data) | ||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C); | |||||
| bGPdata *gpd = ED_gpencil_data_get_active(C); | bGPdata *gpd = ED_gpencil_data_get_active(C); | ||||
| ToolSettings *ts = CTX_data_tool_settings(C); | ToolSettings *ts = CTX_data_tool_settings(C); | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| const bool strokemode = ((ts->gpencil_selectmode == GP_SELECTMODE_STROKE) && | |||||
| const short selectmode = (ob && ob->mode == OB_MODE_SCULPT_GPENCIL) ? | |||||
| ts->gpencil_selectmode_sculpt : | |||||
| ts->gpencil_selectmode_edit; | |||||
| const bool strokemode = ((selectmode == GP_SELECTMODE_STROKE) && | |||||
| ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0)); | ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0)); | ||||
| const bool segmentmode = ((ts->gpencil_selectmode == GP_SELECTMODE_SEGMENT) && | const bool segmentmode = ((selectmode == GP_SELECTMODE_SEGMENT) && | ||||
| ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0)); | ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0)); | ||||
| const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode"); | const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode"); | ||||
| const float scale = ts->gp_sculpt.isect_threshold; | const float scale = ts->gp_sculpt.isect_threshold; | ||||
| GP_SpaceConversion gsc = {NULL}; | GP_SpaceConversion gsc = {NULL}; | ||||
| bool changed = false; | bool changed = false; | ||||
| ▲ Show 20 Lines • Show All 247 Lines • ▼ Show 20 Lines | CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { | ||||
| } | } | ||||
| } | } | ||||
| CTX_DATA_END; | CTX_DATA_END; | ||||
| } | } | ||||
| static int gpencil_select_exec(bContext *C, wmOperator *op) | static int gpencil_select_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| Object *ob = CTX_data_active_object(C); | |||||
| bGPdata *gpd = ED_gpencil_data_get_active(C); | bGPdata *gpd = ED_gpencil_data_get_active(C); | ||||
| ToolSettings *ts = CTX_data_tool_settings(C); | ToolSettings *ts = CTX_data_tool_settings(C); | ||||
| const float scale = ts->gp_sculpt.isect_threshold; | const float scale = ts->gp_sculpt.isect_threshold; | ||||
| /* "radius" is simply a threshold (screen space) to make it easier to test with a tolerance */ | /* "radius" is simply a threshold (screen space) to make it easier to test with a tolerance */ | ||||
| const float radius = 0.50f * U.widget_unit; | const float radius = 0.50f * U.widget_unit; | ||||
| const int radius_squared = (int)(radius * radius); | const int radius_squared = (int)(radius * radius); | ||||
| Show All 14 Lines | static int gpencil_select_exec(bContext *C, wmOperator *op) | ||||
| /* sanity checks */ | /* sanity checks */ | ||||
| if (sa == NULL) { | if (sa == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "No active area"); | BKE_report(op->reports, RPT_ERROR, "No active area"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* if select mode is stroke, use whole stroke */ | /* if select mode is stroke, use whole stroke */ | ||||
| if (ts->gpencil_selectmode == GP_SELECTMODE_STROKE) { | if ((ob) && (ob->mode == OB_MODE_SCULPT_GPENCIL)) { | ||||
| whole = true; | whole = (bool)(ts->gpencil_selectmode_sculpt == GP_SELECTMODE_STROKE); | ||||
| } | |||||
| else { | |||||
| whole = (bool)(ts->gpencil_selectmode_edit == GP_SELECTMODE_STROKE); | |||||
| } | } | ||||
| /* init space conversion stuff */ | /* init space conversion stuff */ | ||||
| gp_point_conversion_init(C, &gsc); | gp_point_conversion_init(C, &gsc); | ||||
| /* get mouse location */ | /* get mouse location */ | ||||
| RNA_int_get_array(op->ptr, "location", mval); | RNA_int_get_array(op->ptr, "location", mval); | ||||
| ▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | static int gpencil_select_exec(bContext *C, wmOperator *op) | ||||
| else { | else { | ||||
| /* just the point (and the stroke) */ | /* just the point (and the stroke) */ | ||||
| if (deselect == false) { | if (deselect == false) { | ||||
| /* we're adding selection, so selection must be true */ | /* we're adding selection, so selection must be true */ | ||||
| hit_point->flag |= GP_SPOINT_SELECT; | hit_point->flag |= GP_SPOINT_SELECT; | ||||
| hit_stroke->flag |= GP_STROKE_SELECT; | hit_stroke->flag |= GP_STROKE_SELECT; | ||||
| /* expand selection to segment */ | /* expand selection to segment */ | ||||
| if (ts->gpencil_selectmode == GP_SELECTMODE_SEGMENT) { | const short selectmode = (ob && ob->mode == OB_MODE_SCULPT_GPENCIL) ? | ||||
| ts->gpencil_selectmode_sculpt : | |||||
| ts->gpencil_selectmode_edit; | |||||
| if (selectmode == GP_SELECTMODE_SEGMENT) { | |||||
| float r_hita[3], r_hitb[3]; | float r_hita[3], r_hitb[3]; | ||||
| bool hit_select = (bool)(hit_point->flag & GP_SPOINT_SELECT); | bool hit_select = (bool)(hit_point->flag & GP_SPOINT_SELECT); | ||||
| ED_gpencil_select_stroke_segment( | ED_gpencil_select_stroke_segment( | ||||
| hit_layer, hit_stroke, hit_point, hit_select, false, scale, r_hita, r_hitb); | hit_layer, hit_stroke, hit_point, hit_select, false, scale, r_hita, r_hitb); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* deselect point */ | /* deselect point */ | ||||
| ▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines | |||||