15#include <fmt/format.h>
76 switch (modal_state) {
178 if (wait_for_input) {
205 switch (event->
val) {
238 switch (event->
type) {
244 else if (gesture->
move) {
259#ifdef WITH_INPUT_NDOF
371 bool is_circle_size =
false;
372 bool is_finished =
false;
375 switch (event->
val) {
377 fac = 0.3f * (
event->xy[1] -
event->prev_xy[1]);
384 if (rect->
xmax < 1) {
387 is_circle_size =
true;
391 is_circle_size =
true;
395 if (rect->
xmax < 1) {
398 is_circle_size =
true;
430 if (is_circle_size) {
437#ifdef WITH_INPUT_NDOF
466 ot->
name =
"Circle Gesture";
467 ot->
idname =
"WM_OT_circle_gesture";
468 ot->
description =
"Enter rotate mode with a circular gesture";
541 const float *lasso =
static_cast<const float *
>(gesture->
customdata);
546 for (i = 0; i < gesture->
points; i++, lasso += 2) {
570 switch (event->
val) {
578 switch (event->
type) {
594 const float2 last_position(lasso[gesture->
points - 1][0], lasso[gesture->
points - 1][1]);
596 const float2 delta = current_mouse_position - last_position;
601 for (
int i = 0; i < gesture->
points; i++) {
602 lasso[i][0] += delta.
x;
603 lasso[i][1] += delta.
y;
607 if (dist_squared >
square_f(radius)) {
609 current_mouse_position, last_position, factor);
611 lasso[gesture->
points][0] = result.x;
612 lasso[gesture->
points][1] = result.y;
678 mcoords[i] =
int2(loc[0], loc[1]);
695 printf(
"Location: %f %f\n", loc[0], loc[1]);
706 ot->
name =
"Lasso Gesture";
712 ot->
exec = gesture_lasso_exec;
758 if (is_click_submitted) {
764 const short prev_x = points[num_points - 1][0];
765 const short prev_y = points[num_points - 1][1];
785 if (valid_points <= 2) {
798 const short *border =
static_cast<const short int *
>(gesture->
customdata);
803 for (
int i = 0; i < gesture->
points; i++, border += 2) {
809 if (valid_points > gesture->
points) {
810 loc[0] = gesture->
mval.x;
811 loc[1] = gesture->
mval.y;
832 switch (event->
val) {
838 short(*border)[2] =
static_cast<short int(*)[2]
>(gesture->
customdata);
839 const short prev_x = border[gesture->
points - 1][0];
840 const short prev_y = border[gesture->
points - 1][1];
842 if (gesture->
mval.x == prev_x && gesture->
mval.y == prev_y) {
847 const float2 orig(border[0][0], border[0][1]);
849 const float dist =
len_v2v2(cur, orig);
858 border[gesture->
points - 1][0] = gesture->
mval.x;
859 border[gesture->
points - 1][1] = gesture->
mval.y;
873 switch (event->
type) {
884 short(*border)[2] =
static_cast<short int(*)[2]
>(gesture->
customdata);
888 const int dx = gesture->
mval.x - border[gesture->
points - 1][0];
889 const int dy = gesture->
mval.y - border[gesture->
points - 1][1];
891 for (
int i = 0; i < gesture->
points; i++) {
918 printf(
"Location: %f %f\n", loc[0], loc[1]);
929 ot->
name =
"Polyline Gesture";
930 ot->
idname =
"WM_OT_polyline_gesture";
931 ot->
description =
"Outline a selection area with each mouse click";
935 ot->
exec = gesture_polyline_exec;
1038 const float x_axis[2] = {1.0f, 0.0f};
1040 float line_direction[2];
1041 sub_v2_v2v2(line_direction, line_end, line_start);
1042 const float line_length =
normalize_v2(line_direction);
1045 const float adjusted_angle = current_angle + (snap_angle / 2.0f);
1046 const float angle_snapped = -
floorf(adjusted_angle / snap_angle) * snap_angle;
1048 float line_snapped_end[2];
1050 mul_v2_fl(line_snapped_end, line_length);
1051 add_v2_v2(line_snapped_end, line_start);
1053 rect->
xmax =
int(line_snapped_end[0]);
1054 rect->
ymax =
int(line_snapped_end[1]);
1065 int ylen = rect->
ymax - rect->
ymin;
1066 if (
abs(ylen) != xlen) {
1067 ylen = xlen * (ylen >= 0 ? 1 : -1);
1084 switch (event->
val) {
1123 switch (event->
type) {
1129 else if (gesture->
move) {
1168 switch (event->
val) {
1212 switch (event->
type) {
1218 else if (gesture->
move) {
1254 ot->
name =
"Straight Line Gesture";
1255 ot->
idname =
"WM_OT_straightline_gesture";
1256 ot->
description =
"Draw a straight line defined by the cursor";
1260 ot->
exec = gesture_straightline_exec;
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
MINLINE int min_ii(int a, int b)
MINLINE float pow2f(float x)
MINLINE int max_ii(int a, int b)
MINLINE float square_f(float a)
MINLINE int compare_ff(float a, float b, float max_diff)
MINLINE float len_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void add_v2_v2(float r[2], const float a[2])
float angle_signed_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float normalize_v2(float n[2])
void rotate_v2_v2fl(float r[2], const float p[2], float angle)
void BLI_rcti_translate(struct rcti *rect, int x, int y)
#define UNUSED_FUNCTION(x)
#define OPERATOR_RETVAL_CHECK(ret)
void ED_area_tag_redraw(ScrArea *area)
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
#define RNA_BEGIN(sptr, itemptr, propname)
#define RNA_PROP_BEGIN(sptr, itemptr, prop)
@ OPTYPE_DEPENDS_ON_CURSOR
#define WM_GESTURE_STRAIGHTLINE
#define WM_GESTURE_CIRCLE
#define WM_GESTURE_CROSS_RECT
#define WM_GESTURE_POLYLINE
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
MINLINE float fractf(float a)
ccl_device_inline float2 floor(const float2 a)
ccl_device_inline float3 ceil(const float3 a)
T length_squared(const VecBase< T, Size > &a)
T interpolate(const T &a, const T &b, const FactorT &t)
constexpr float POLYLINE_CLICK_RADIUS
void RNA_collection_clear(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
void RNA_collection_add(PointerRNA *ptr, const char *name, PointerRNA *r_value)
int RNA_int_get(PointerRNA *ptr, const char *name)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
float RNA_float_get(PointerRNA *ptr, const char *name)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
void RNA_def_property_struct_runtime(StructOrFunctionRNA *cont, PropertyRNA *prop, StructRNA *type)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
struct wmOperatorType * type
ccl_device_inline int abs(int x)
void WM_cursor_modal_set(wmWindow *win, int val)
void WM_cursor_modal_restore(wmWindow *win)
bool WM_event_is_mouse_drag_or_press(const wmEvent *event)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
@ GESTURE_MODAL_CIRCLE_SIZE
@ GESTURE_MODAL_CIRCLE_ADD
@ GESTURE_MODAL_CIRCLE_SUB
wmGesture * WM_gesture_new(wmWindow *window, const ARegion *region, const wmEvent *event, int type)
void wm_gesture_tag_redraw(wmWindow *win)
void WM_gesture_end(wmWindow *win, wmGesture *gesture)
static int UNUSED_FUNCTION gesture_modal_state_from_operator(wmOperator *op)
void WM_gesture_box_cancel(bContext *C, wmOperator *op)
int WM_gesture_polyline_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static SnapAngle get_snap_angle(const ScrArea &area, const ToolSettings &tool_settings)
static bool gesture_box_apply(bContext *C, wmOperator *op)
int WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_lines_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void gesture_modal_end(bContext *C, wmOperator *op)
Array< int2 > WM_gesture_lasso_path_to_array(bContext *, wmOperator *op)
void WM_gesture_straightline_cancel(bContext *C, wmOperator *op)
void WM_gesture_polyline_cancel(bContext *C, wmOperator *op)
void WM_gesture_lines_cancel(bContext *C, wmOperator *op)
int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_polyline_modal(bContext *C, wmOperator *op, const wmEvent *event)
static bool gesture_polyline_can_apply(const wmGesture &wmGesture, const bool is_click_submitted)
static bool gesture_straightline_apply(bContext *C, wmOperator *op)
void WM_gesture_circle_cancel(bContext *C, wmOperator *op)
static void gesture_circle_apply(bContext *C, wmOperator *op)
static void wm_gesture_straightline_do_angle_snap(rcti *rect, float snap_angle)
int WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int gesture_polyline_apply(bContext *C, wmOperator *op, const bool is_click_submitted)
static bool gesture_box_apply_rect(wmOperator *op)
int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
void WM_gesture_lasso_cancel(bContext *C, wmOperator *op)
int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void gesture_modal_state_to_operator(wmOperator *op, int modal_state)
static int gesture_polyline_valid_points(const wmGesture &wmGesture, const bool is_click_submitted)
static int gesture_lasso_apply(bContext *C, wmOperator *op)
int WM_gesture_lines_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_straightline_oneshot_modal(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_straightline_active_side_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
void WM_operator_properties_gesture_polyline(wmOperatorType *ot)
void WM_operator_properties_gesture_circle(wmOperatorType *ot)
bool WM_operator_winactive(bContext *C)