diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-12-27 09:46:55 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-12-27 10:01:11 +0300 |
commit | f820c45534c653c7a2baa799b99067710def136b (patch) | |
tree | 7f08c2e1fa8e5aa2dbdbe38c64a1684495df124f /source/blender/editors/curve | |
parent | b254905c384d87764cd92ed631f86f3f97caa4de (diff) |
WM: add checker_interval utility functions
Diffstat (limited to 'source/blender/editors/curve')
-rw-r--r-- | source/blender/editors/curve/editcurve_select.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c index 34ac3b8bb97..4855f9d1e6c 100644 --- a/source/blender/editors/curve/editcurve_select.c +++ b/source/blender/editors/curve/editcurve_select.c @@ -1075,7 +1075,7 @@ void CURVE_OT_select_random(wmOperatorType *ot) /********************* every nth number of point *******************/ -static void select_nth_bezt(Nurb *nu, BezTriple *bezt, int nth, int skip, int offset) +static void select_nth_bezt(Nurb *nu, BezTriple *bezt, const struct CheckerIntervalParams *params) { int a, start; @@ -1085,7 +1085,7 @@ static void select_nth_bezt(Nurb *nu, BezTriple *bezt, int nth, int skip, int of while (a--) { const int depth = abs(start - a); - if ((offset + depth) % (skip + nth) >= skip) { + if (WM_operator_properties_checker_interval_test(params, depth)) { select_beztriple(bezt, DESELECT, SELECT, HIDDEN); } @@ -1093,7 +1093,7 @@ static void select_nth_bezt(Nurb *nu, BezTriple *bezt, int nth, int skip, int of } } -static void select_nth_bp(Nurb *nu, BPoint *bp, int nth, int skip, int offset) +static void select_nth_bp(Nurb *nu, BPoint *bp, const struct CheckerIntervalParams *params) { int a, startrow, startpnt; int row, pnt; @@ -1108,7 +1108,7 @@ static void select_nth_bp(Nurb *nu, BPoint *bp, int nth, int skip, int offset) while (a--) { const int depth = abs(pnt - startpnt) + abs(row - startrow); - if ((offset + depth) % (skip + nth) >= skip) { + if (WM_operator_properties_checker_interval_test(params, depth)) { select_bpoint(bp, DESELECT, SELECT, HIDDEN); } @@ -1122,7 +1122,7 @@ static void select_nth_bp(Nurb *nu, BPoint *bp, int nth, int skip, int offset) } } -bool ED_curve_select_nth(Curve *cu, int nth, int skip, int offset) +static bool ed_curve_select_nth(Curve *cu, const struct CheckerIntervalParams *params) { Nurb *nu = NULL; void *vert = NULL; @@ -1131,10 +1131,10 @@ bool ED_curve_select_nth(Curve *cu, int nth, int skip, int offset) return false; if (nu->bezt) { - select_nth_bezt(nu, vert, nth, skip, offset); + select_nth_bezt(nu, vert, params); } else { - select_nth_bp(nu, vert, nth, skip, offset); + select_nth_bp(nu, vert, params); } return true; @@ -1143,14 +1143,11 @@ bool ED_curve_select_nth(Curve *cu, int nth, int skip, int offset) static int select_nth_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); - const int nth = RNA_int_get(op->ptr, "nth") - 1; - const int skip = RNA_int_get(op->ptr, "skip"); - int offset = RNA_int_get(op->ptr, "offset"); + struct CheckerIntervalParams op_params; - /* so input of offset zero ends up being (nth - 1) */ - offset = mod_i(offset, nth + skip); + WM_operator_properties_checker_interval_from_op(op, &op_params); - if (!ED_curve_select_nth(obedit->data, nth, skip, offset)) { + if (!ed_curve_select_nth(obedit->data, &op_params)) { if (obedit->type == OB_SURF) { BKE_report(op->reports, RPT_ERROR, "Surface has not got active point"); } @@ -1180,9 +1177,7 @@ void CURVE_OT_select_nth(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_int(ot->srna, "nth", 2, 2, INT_MAX, "Nth Selection", "", 2, 100); - RNA_def_int(ot->srna, "skip", 1, 1, INT_MAX, "Skip", "", 1, 100); - RNA_def_int(ot->srna, "offset", 0, INT_MIN, INT_MAX, "Offset", "", -100, 100); + WM_operator_properties_checker_interval(ot, false); } |