Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/curve/editcurve.c
| Context not available. | |||||
| /********************** select random *********************/ | /********************** select random *********************/ | ||||
| static void selectrandom_curve(ListBase *editnurb, float randfac) | static void selectrandom_curve(ListBase *editnurb, float randfac, int action) | ||||
| { | { | ||||
| Nurb *nu; | Nurb *nu; | ||||
| BezTriple *bezt; | BezTriple *bezt; | ||||
| Context not available. | |||||
| a = nu->pntsu; | a = nu->pntsu; | ||||
| while (a--) { | while (a--) { | ||||
| if (BLI_frand() < randfac) | if (BLI_frand() < randfac) | ||||
| select_beztriple(bezt, SELECT, SELECT, VISIBLE); | switch (action) { | ||||
| case SEL_SELECT: | |||||
| select_beztriple(bezt, SELECT, SELECT, VISIBLE); | |||||
| break; | |||||
| case SEL_DESELECT: | |||||
| select_beztriple(bezt, DESELECT, SELECT, VISIBLE); | |||||
| break; | |||||
| } | |||||
| bezt++; | bezt++; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| while (a--) { | while (a--) { | ||||
| if (BLI_frand() < randfac) | if (BLI_frand() < randfac) | ||||
| select_bpoint(bp, SELECT, SELECT, VISIBLE); | switch (action) { | ||||
| case SEL_SELECT: | |||||
| select_bpoint(bp, SELECT, SELECT, VISIBLE); | |||||
| break; | |||||
| case SEL_DESELECT: | |||||
| select_bpoint(bp, DESELECT, SELECT, VISIBLE); | |||||
| break; | |||||
| } | |||||
| bp++; | bp++; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| { | { | ||||
| Object *obedit = CTX_data_edit_object(C); | Object *obedit = CTX_data_edit_object(C); | ||||
| ListBase *editnurb = object_editcurve_get(obedit); | ListBase *editnurb = object_editcurve_get(obedit); | ||||
| const int action = RNA_enum_get(op->ptr, "action"); | |||||
| selectrandom_curve(editnurb, RNA_float_get(op->ptr, "percent") / 100.0f, action); | |||||
| if (!RNA_boolean_get(op->ptr, "extend")) | |||||
| CU_deselect_all(obedit); | |||||
| selectrandom_curve(editnurb, RNA_float_get(op->ptr, "percent") / 100.0f); | |||||
| WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); | WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| Context not available. | |||||
| void CURVE_OT_select_random(wmOperatorType *ot) | void CURVE_OT_select_random(wmOperatorType *ot) | ||||
| { | { | ||||
| static EnumPropertyItem select_actions[] = { | |||||
| {SEL_SELECT, "SELECT", 0, "Select", "Select all elements"}, | |||||
| {SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"}, | |||||
| {0, NULL, 0, NULL, NULL} | |||||
| }; | |||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Select Random"; | ot->name = "Select Random"; | ||||
| ot->idname = "CURVE_OT_select_random"; | ot->idname = "CURVE_OT_select_random"; | ||||
| Context not available. | |||||
| /* properties */ | /* properties */ | ||||
| RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f, "Percent", "Percentage of elements to select randomly", 0.f, 100.0f); | RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f, "Percent", "Percentage of elements to select randomly", 0.f, 100.0f); | ||||
| RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); | RNA_def_enum(ot->srna, "action", select_actions, SEL_SELECT, "Action", "Selection action to execute"); | ||||
| } | } | ||||
| /********************* every nth number of point *******************/ | /********************* every nth number of point *******************/ | ||||
| Context not available. | |||||