GPv3: Set Uniform operator for Thickness and Opacity #114006

Merged
Antonio Vazquez merged 20 commits from antoniov/blender:GPv3_normalize into main 2023-11-08 16:19:10 +01:00
2 changed files with 54 additions and 0 deletions
Showing only changes of commit 7172784cd1 - Show all commits

View File

@ -5838,6 +5838,7 @@ class VIEW3D_MT_edit_greasepencil_stroke(Menu):
layout.separator()
layout.operator("grease_pencil.cyclical_set", text="Toggle Cyclic").type = 'TOGGLE'
layout.operator("grease_pencil.stroke_switch_direction")
class VIEW3D_MT_edit_greasepencil_point(Menu):

View File

@ -1123,6 +1123,58 @@ static void GREASE_PENCIL_OT_set_uniform_opacity(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
/** \name Switch Direction Operator
* \{ */
static int grease_pencil_stroke_switch_direction_exec(bContext *C, wmOperator *op)
{
const Scene *scene = CTX_data_scene(C);
Object *object = CTX_data_active_object(C);
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
bool changed = false;
const Array<MutableDrawingInfo> drawings = retrieve_editable_drawings(*scene, grease_pencil);
threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
bke::CurvesGeometry &curves = info.drawing.strokes_for_write();
IndexMaskMemory memory;
const IndexMask selected_curves = ed::curves::retrieve_selected_curves(curves, memory);
if (selected_curves.is_empty()) {
return;
}
/* Switch stroke direction. */
curves.reverse_curves(selected_curves);
changed = true;
});
if (changed) {
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, &grease_pencil);
}
return OPERATOR_FINISHED;
}
static void GREASE_PENCIL_OT_stroke_switch_direction(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Switch Direction";
ot->idname = "GREASE_PENCIL_OT_stroke_switch_direction";
ot->description = "Change direction of the points of the selected strokes";
/* Callbacks. */
ot->exec = grease_pencil_stroke_switch_direction_exec;
ot->poll = editable_grease_pencil_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
} // namespace blender::ed::greasepencil
void ED_operatortypes_grease_pencil_edit()
@ -1135,6 +1187,7 @@ void ED_operatortypes_grease_pencil_edit()
WM_operatortype_append(GREASE_PENCIL_OT_stroke_material_set);
WM_operatortype_append(GREASE_PENCIL_OT_cyclical_set);
WM_operatortype_append(GREASE_PENCIL_OT_set_active_material);
WM_operatortype_append(GREASE_PENCIL_OT_stroke_switch_direction);
WM_operatortype_append(GREASE_PENCIL_OT_set_uniform_thickness);
WM_operatortype_append(GREASE_PENCIL_OT_set_uniform_opacity);
}