Cleanup: Moving selection domain getter for GP
It was a bit odd having `ED_view3d_grease_pencil_selection_domain_get` in the `ED_view3d.h` header. Moving it to `ED_grease_pencil.h` makes more sense.
This commit is contained in:
@@ -60,11 +60,11 @@ static int select_all_exec(bContext *C, wmOperator *op)
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *object = CTX_data_active_object(C);
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
|
||||
eAttrDomain domain = ED_view3d_grease_pencil_selection_domain_get(C);
|
||||
eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(C);
|
||||
|
||||
grease_pencil.foreach_editable_drawing(
|
||||
scene->r.cfra, [action, domain](int /*drawing_index*/, GreasePencilDrawing &drawing) {
|
||||
blender::ed::curves::select_all(drawing.geometry.wrap(), domain, action);
|
||||
scene->r.cfra, [&](int /*drawing_index*/, GreasePencilDrawing &drawing) {
|
||||
blender::ed::curves::select_all(drawing.geometry.wrap(), selection_domain, action);
|
||||
});
|
||||
|
||||
/* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
|
||||
@@ -97,7 +97,6 @@ static int select_more_exec(bContext *C, wmOperator * /*op*/)
|
||||
|
||||
grease_pencil.foreach_editable_drawing(
|
||||
scene->r.cfra, [](int /*drawing_index*/, GreasePencilDrawing &drawing) {
|
||||
/* TODO: Support different selection domains. */
|
||||
blender::ed::curves::select_adjacent(drawing.geometry.wrap(), false);
|
||||
});
|
||||
|
||||
@@ -129,7 +128,6 @@ static int select_less_exec(bContext *C, wmOperator * /*op*/)
|
||||
|
||||
grease_pencil.foreach_editable_drawing(
|
||||
scene->r.cfra, [](int /*drawing_index*/, GreasePencilDrawing &drawing) {
|
||||
/* TODO: Support different selection domains. */
|
||||
blender::ed::curves::select_adjacent(drawing.geometry.wrap(), true);
|
||||
});
|
||||
|
||||
@@ -161,7 +159,6 @@ static int select_linked_exec(bContext *C, wmOperator * /*op*/)
|
||||
|
||||
grease_pencil.foreach_editable_drawing(
|
||||
scene->r.cfra, [](int /*drawing_index*/, GreasePencilDrawing &drawing) {
|
||||
/* TODO: Support different selection domains. */
|
||||
blender::ed::curves::select_linked(drawing.geometry.wrap());
|
||||
});
|
||||
|
||||
@@ -192,12 +189,12 @@ static int select_random_exec(bContext *C, wmOperator *op)
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *object = CTX_data_active_object(C);
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
|
||||
eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(C);
|
||||
|
||||
grease_pencil.foreach_editable_drawing(
|
||||
scene->r.cfra, [&](int drawing_index, GreasePencilDrawing &drawing) {
|
||||
// TODO: Support different selection domains.
|
||||
blender::ed::curves::select_random(drawing.geometry.wrap(),
|
||||
ATTR_DOMAIN_POINT,
|
||||
selection_domain,
|
||||
blender::get_default_hash_2<int>(seed, drawing_index),
|
||||
ratio);
|
||||
});
|
||||
@@ -283,6 +280,25 @@ static void keymap_grease_pencil_editing(wmKeyConfig *keyconf)
|
||||
}
|
||||
|
||||
} // namespace blender::ed::greasepencil
|
||||
|
||||
eAttrDomain ED_grease_pencil_selection_domain_get(bContext *C)
|
||||
{
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
|
||||
switch (ts->gpencil_selectmode_edit) {
|
||||
case GP_SELECTMODE_POINT:
|
||||
return ATTR_DOMAIN_POINT;
|
||||
break;
|
||||
case GP_SELECTMODE_STROKE:
|
||||
return ATTR_DOMAIN_CURVE;
|
||||
break;
|
||||
case GP_SELECTMODE_SEGMENT:
|
||||
return ATTR_DOMAIN_POINT;
|
||||
break;
|
||||
}
|
||||
return ATTR_DOMAIN_POINT;
|
||||
}
|
||||
|
||||
void ED_operatortypes_grease_pencil(void)
|
||||
{
|
||||
using namespace blender::ed::greasepencil;
|
||||
|
||||
@@ -25,6 +25,10 @@ extern "C" {
|
||||
|
||||
void ED_operatortypes_grease_pencil(void);
|
||||
void ED_keymap_grease_pencil(struct wmKeyConfig *keyconf);
|
||||
/**
|
||||
* Get the selection mode for Grease Pencil selection operators: point, stroke, segment.
|
||||
*/
|
||||
eAttrDomain ED_grease_pencil_selection_domain_get(struct bContext *C);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -996,10 +996,6 @@ void ED_view3d_viewcontext_init(struct bContext *C,
|
||||
* So object-mode specific values should remain cleared when initialized with another object.
|
||||
*/
|
||||
void ED_view3d_viewcontext_init_object(struct ViewContext *vc, struct Object *obact);
|
||||
/**
|
||||
* Get the selection mode for Grease Pencil selection operators: point, stroke, segment.
|
||||
*/
|
||||
eAttrDomain ED_view3d_grease_pencil_selection_domain_get(struct bContext *C);
|
||||
/**
|
||||
* Use this call when executing an operator,
|
||||
* event system doesn't set for each event the OpenGL drawing context.
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
#include "ED_curve.h"
|
||||
#include "ED_curves.h"
|
||||
#include "ED_gpencil_legacy.h"
|
||||
#include "ED_grease_pencil.h"
|
||||
#include "ED_lattice.h"
|
||||
#include "ED_mball.h"
|
||||
#include "ED_mesh.h"
|
||||
@@ -141,24 +142,6 @@ void ED_view3d_viewcontext_init_object(ViewContext *vc, Object *obact)
|
||||
}
|
||||
}
|
||||
|
||||
eAttrDomain ED_view3d_grease_pencil_selection_domain_get(bContext *C)
|
||||
{
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
|
||||
switch (ts->gpencil_selectmode_edit) {
|
||||
case GP_SELECTMODE_POINT:
|
||||
return ATTR_DOMAIN_POINT;
|
||||
break;
|
||||
case GP_SELECTMODE_STROKE:
|
||||
return ATTR_DOMAIN_CURVE;
|
||||
break;
|
||||
case GP_SELECTMODE_SEGMENT:
|
||||
return ATTR_DOMAIN_POINT;
|
||||
break;
|
||||
}
|
||||
return ATTR_DOMAIN_POINT;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -1201,7 +1184,7 @@ static bool do_lasso_select_grease_pencil(ViewContext *vc,
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(vc->obedit->data);
|
||||
|
||||
/* Get selection domain from tool settings. */
|
||||
const eAttrDomain selection_domain = ED_view3d_grease_pencil_selection_domain_get(vc->C);
|
||||
const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(vc->C);
|
||||
|
||||
bool changed = false;
|
||||
grease_pencil.foreach_editable_drawing(
|
||||
@@ -3191,7 +3174,7 @@ static bool ed_grease_pencil_select_pick(bContext *C,
|
||||
});
|
||||
|
||||
/* Get selection domain from tool settings. */
|
||||
const eAttrDomain selection_domain = ED_view3d_grease_pencil_selection_domain_get(C);
|
||||
const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(C);
|
||||
|
||||
const ClosestGreasePencilDrawing closest = threading::parallel_reduce(
|
||||
drawings.index_range(),
|
||||
@@ -4207,7 +4190,7 @@ static bool do_grease_pencil_box_select(ViewContext *vc, const rcti *rect, const
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(vc->obedit->data);
|
||||
|
||||
/* Get selection domain from tool settings. */
|
||||
const eAttrDomain selection_domain = ED_view3d_grease_pencil_selection_domain_get(vc->C);
|
||||
const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(vc->C);
|
||||
|
||||
bool changed = false;
|
||||
grease_pencil.foreach_editable_drawing(
|
||||
|
||||
Reference in New Issue
Block a user