![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include "common/darktable.h"#include "gui/gdkkeys.h"#include "bauhaus/bauhaus.h"#include "common/debug.h"#include "common/imagebuf.h"#include "common/undo.h"#include "control/conf.h"#include "develop/blend.h"#include "develop/imageop.h"#include "develop/masks.h"#include "develop/openmp_maths.h"#include "gui/actions/menu.h"#include <assert.h>
Include dependency graph for polygon.c:Go to the source code of this file.
Macros | |
| #define | HARDNESS_MIN 0.0005f |
| #define | HARDNESS_MAX 1.0f |
| #define | BORDER_MIN 0.00005f |
| #define | BORDER_MAX 0.5f |
| #define | POLYGON_MAX_SELF_INTERSECTIONS(nb_nodes) ((nb_nodes) * 4) |
Functions | |
| static void | _polygon_bounding_box_raw (const float *const point_buffer, const float *border_buffer, const int corner_count, const int point_count, int border_count, float *x_min, float *x_max, float *y_min, float *y_max) |
| Compute raw bounding box for polygon points and border samples. | |
| static void | _polygon_get_XY (const float p0_x, const float p0_y, const float p1_x, const float p1_y, const float p2_x, const float p2_y, const float p3_x, const float p3_y, const float t, float *out_x, float *out_y) |
| Evaluate a cubic Bezier at t in [0, 1]. | |
| static void | _polygon_border_get_XY (const float p0_x, const float p0_y, const float p1_x, const float p1_y, const float p2_x, const float p2_y, const float p3_x, const float p3_y, const float t, const float radius, float *center_x, float *center_y, float *border_x, float *border_y) |
| Evaluate a cubic Bezier and its border offset at t in [0, 1]. | |
| static void | _polygon_ctrl2_to_handle (const float point_x, const float point_y, const float ctrl_x, const float ctrl_y, float *handle_x, float *handle_y, const gboolean clockwise) |
| Convert control point #2 into a handle extremity. | |
| static void | _polygon_handle_to_ctrl (const float point_x, const float point_y, const float handle_x, const float handle_y, float *ctrl1_x, float *ctrl1_y, float *ctrl2_x, float *ctrl2_y, const gboolean clockwise) |
| Convert a handle extremity into symmetric Bezier control points. | |
| static void | _polygon_catmull_to_bezier (const float x1, const float y1, const float x2, const float y2, const float x3, const float y3, const float x4, const float y4, float *bezier_x1, float *bezier_y1, float *bezier_x2, float *bezier_y2) |
| Convert a Catmull-Rom segment to Bezier control points. | |
| static void | _polygon_init_ctrl_points (dt_masks_form_t *mask_form) |
| Initialize control points to match a Catmull-Rom-like spline. | |
| static gboolean | _polygon_is_clockwise (dt_masks_form_t *mask_form) |
| Determine polygon winding order. | |
| static int | _polygon_fill_gaps (int last_x, int last_y, int target_x, int target_y, dt_masks_dynbuf_t *points) |
| Fill gaps between two points with an integer Bresenham line. | |
| static void | _polygon_points_recurs_border_gaps (float *center_max, float *border_min, float *border_min2, float *border_max, dt_masks_dynbuf_t *draw_points, dt_masks_dynbuf_t *draw_border, gboolean clockwise) |
| Fill gaps between border points with a circular arc. | |
| static gboolean | _is_within_pxl_threshold (float *min, float *max, int pixel_threshold) |
| static void | _polygon_points_recurs (float *segment_start, float *segment_end, double t_min, double t_max, float *polygon_min, float *polygon_max, float *border_min, float *border_max, float *result_polygon, float *result_border, dt_masks_dynbuf_t *draw_points, dt_masks_dynbuf_t *draw_border, int with_border, const int pixel_threshold) |
| Recursive subdivision to sample polygon and border points. | |
| static int | _polygon_find_self_intersection (dt_masks_dynbuf_t *intersections, int node_count, float *border_points, int border_point_count, int *intersection_count_out) |
| Find all self-intersection segments in a polygon border. | |
| static int | _polygon_get_pts_border (dt_develop_t *develop, dt_masks_form_t *mask_form, const double iop_order, const int transform_direction, dt_dev_pixelpipe_t *pipe, float **point_buffer, int *point_count, float **border_buffer, int *border_count, gboolean source) |
| Build point and border buffers for a polygon mask. | |
| static float | _polygon_get_position_in_segment (float point_x, float point_y, dt_masks_form_t *mask_form, int segment_index) |
| Find the parametric position along a segment closest to a point. | |
| static void | _add_node_to_segment (struct dt_iop_module_t *module, dt_masks_form_t *mask_form, int parent_id, dt_masks_form_gui_t *mask_gui, int form_index) |
| static void | _polygon_translate_node (dt_masks_node_polygon_t *node, const float delta_x, const float delta_y) |
| static void | _polygon_translate_all_nodes (dt_masks_form_t *mask_form, const float delta_x, const float delta_y) |
| static int | _polygon_get_points_border (dt_develop_t *develop, dt_masks_form_t *mask_form, float **point_buffer, int *point_count, float **border_buffer, int *border_count, int source, const dt_iop_module_t *module) |
| static void | _polygon_get_sizes (struct dt_iop_module_t *module, dt_masks_form_t *mask_form, dt_masks_form_gui_t *mask_gui, int form_index, float *mask_size, float *border_size) |
| static gboolean | _polygon_form_gravity_center (const dt_masks_form_t *mask_form, float *center_x, float *center_y, float *area) |
| Compute polygon centroid from the form nodes (normalized space). | |
| static float | _polygon_get_interaction_value (const dt_masks_form_t *mask_form, dt_masks_interaction_t interaction) |
| static gboolean | _polygon_get_gravity_center (const dt_masks_form_t *mask_form, float center[2], float *area) |
| static int | _change_size (dt_masks_form_t *mask_form, int parent_id, dt_masks_form_gui_t *mask_gui, struct dt_iop_module_t *module, int form_index, const float amount, const dt_masks_increment_t increment, const int flow) |
| Scale the polygon around its centroid. | |
| static int | _change_hardness (dt_masks_form_t *mask_form, int parent_id, dt_masks_form_gui_t *mask_gui, struct dt_iop_module_t *module, int form_index, const float amount, const dt_masks_increment_t increment, int flow) |
| Change polygon hardness for the active node scope or the full shape. | |
| static float | _polygon_set_interaction_value (dt_masks_form_t *mask_form, dt_masks_interaction_t interaction, float value, dt_masks_increment_t increment, int flow, dt_masks_form_gui_t *mask_gui, struct dt_iop_module_t *module) |
| static void | _polygon_get_distance (float point_x, float point_y, float radius, dt_masks_form_gui_t *mask_gui, int form_index, int node_count, int *inside, int *inside_border, int *near, int *inside_source, float *dist) |
| Compute proximity between a point and the polygon GUI shape. | |
| static gboolean | _polygon_border_handle_cb (const dt_masks_form_gui_points_t *gui_points, int node_count, int node_index, float *handle_x, float *handle_y, void *user_data) |
| Polygon-specific border handle lookup. | |
| static void | _polygon_curve_handle_cb (const dt_masks_form_gui_points_t *gui_points, int node_index, float *handle_x, float *handle_y, void *user_data) |
| Polygon-specific curve handle lookup (depends on winding direction). | |
| static void | _polygon_distance_cb (float pointer_x, float pointer_y, float cursor_radius, dt_masks_form_gui_t *mask_gui, int form_index, int node_count, int *inside, int *inside_border, int *near, int *inside_source, float *dist, void *user_data) |
| Polygon-specific inside/border/segment hit testing. | |
| static int | _find_closest_handle (dt_masks_form_t *mask_form, dt_masks_form_gui_t *mask_gui, int form_index) |
| static void | _polygon_gui_gravity_center (const float *point_buffer, int point_count, float *center_x, float *center_y, float *area) |
| Compute polygon centroid from GUI points using the shoelace formula. | |
| static int | _init_hardness (dt_masks_form_t *mask_form, const float amount, const dt_masks_increment_t increment, const int flow, const float mask_size, const float border_size) |
| Initialize hardness from config and emit the toast with a size-normalized percentage. | |
| static int | _polygon_events_mouse_scrolled (struct dt_iop_module_t *module, double x, double y, int up, int flow, uint32_t state, dt_masks_form_t *mask_form, int parent_id, dt_masks_form_gui_t *mask_gui, int form_index, dt_masks_interaction_t interaction) |
| Handle mouse wheel updates for polygon size/hardness/opacity. | |
| static int | _polygon_creation_closing_form (dt_masks_form_t *mask_form, dt_masks_form_gui_t *mask_gui) |
| Close the polygon creation by removing the temporary last node. | |
| static int | _polygon_events_button_pressed (struct dt_iop_module_t *module, double x, double y, double pressure, int which, int type, uint32_t state, dt_masks_form_t *mask_form, int parent_id, dt_masks_form_gui_t *mask_gui, int form_index) |
| static int | _polygon_events_button_released (struct dt_iop_module_t *module, double x, double y, int which, uint32_t state, dt_masks_form_t *mask_form, int parent_id, dt_masks_form_gui_t *mask_gui, int form_index) |
| static int | _polygon_events_key_pressed (struct dt_iop_module_t *module, GdkEventKey *event, dt_masks_form_t *mask_form, int parent_id, dt_masks_form_gui_t *mask_gui, int form_index) |
| static int | _polygon_events_mouse_moved (struct dt_iop_module_t *module, double x, double y, double pressure, int which, dt_masks_form_t *mask_form, int parent_id, dt_masks_form_gui_t *mask_gui, int form_index) |
| Polygon mouse-move handler. | |
| static void | _polygon_draw_shape (cairo_t *cr, const float *point_buffer, const int point_count, const int node_count, const gboolean draw_border, const gboolean draw_source) |
| Draw a polygon or border polyline, skipping NaN points. | |
| static void | _polygon_events_post_expose (cairo_t *cr, float zoom_scale, dt_masks_form_gui_t *mask_gui, int form_index, int node_count) |
| Draw polygon overlays (nodes, handles, borders, source) after exposure. | |
| static void | _polygon_bounding_box (const float *const point_buffer, const float *border_buffer, const int corner_count, const int point_count, int border_count, int *width, int *height, int *posx, int *posy) |
| Compute bounding box and add a small padding for rasterization safety. | |
| static int | _get_area (const dt_iop_module_t *const module, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *const piece, dt_masks_form_t *const mask_form, int *width, int *height, int *posx, int *posy, gboolean get_source) |
| static int | _polygon_get_source_area (dt_iop_module_t *module, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, dt_masks_form_t *mask_form, int *width, int *height, int *posx, int *posy) |
| static int | _polygon_get_area (const dt_iop_module_t *const module, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *const piece, dt_masks_form_t *const mask_form, int *width, int *height, int *posx, int *posy) |
| void | _polygon_falloff (float *const restrict buffer, int *p0, int *p1, int posx, int posy, int buffer_width) |
| Write a falloff segment into the mask buffer. | |
| static int | _polygon_get_mask (const dt_iop_module_t *const module, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *const piece, dt_masks_form_t *const mask_form, float **buffer, int *width, int *height, int *posx, int *posy) |
| static int | _polygon_crop_to_roi (float *polygon, const int point_count, float xmin, float xmax, float ymin, float ymax) |
| static void | _polygon_falloff_roi (float *buffer, int *p0, int *p1, int bw, int bh) |
| static int | _polygon_get_mask_roi (const dt_iop_module_t *const module, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *const piece, dt_masks_form_t *const mask_form, const dt_iop_roi_t *roi, float *buffer) |
| static void | _polygon_sanitize_config (dt_masks_type_t type) |
| static void | _polygon_set_form_name (struct dt_masks_form_t *const mask_form, const size_t form_number) |
| Assign a default name for a polygon form. | |
| static void | _polygon_set_hint_message (const dt_masks_form_gui_t *const mask_gui, const dt_masks_form_t *const mask_form, const int opacity, char *const restrict msgbuf, const size_t msgbuf_len) |
| static void | _polygon_duplicate_points (dt_develop_t *const dev, dt_masks_form_t *const base, dt_masks_form_t *const dest) |
| static void | _polygon_initial_source_pos (const float iwd, const float iht, float *x, float *y) |
| static void | _polygon_creation_closing_form_callback (GtkWidget *widget, gpointer user_data) |
| static void | _polygon_switch_node_callback (GtkWidget *widget, gpointer user_data) |
| static void | _polygon_reset_round_node_callback (GtkWidget *widget, gpointer user_data) |
| static void | _polygon_add_node_callback (GtkWidget *menu, gpointer user_data) |
| static int | _polygon_populate_context_menu (GtkWidget *menu, struct dt_masks_form_t *mask_form, struct dt_masks_form_gui_t *mask_gui, const float pzx, const float pzy) |
Variables | |
| const dt_masks_functions_t | dt_masks_functions_polygon |
| #define POLYGON_MAX_SELF_INTERSECTIONS | ( | nb_nodes | ) | ((nb_nodes) * 4) |
|
static |
Definition at line 1077 of file polygon.c.
References _polygon_get_position_in_segment(), _polygon_init_ctrl_points(), dt_masks_node_polygon_t::border, dt_masks_node_polygon_t::ctrl1, dt_masks_node_polygon_t::ctrl2, darktable, darktable_t::develop, dt_free, dt_masks_gui_cursor_to_raw_norm(), dt_masks_gui_form_create(), dt_masks_gui_selected_segment_index(), DT_MASKS_POINT_STATE_NORMAL, FALSE, g_list_next_wraparound(), IS_NULL_PTR, dt_masks_node_polygon_t::node, dt_masks_form_gui_t::node_hovered, dt_masks_form_gui_t::node_selected, dt_masks_form_gui_t::node_selected_idx, dt_masks_form_t::points, dt_masks_form_gui_t::seg_hovered, dt_masks_form_gui_t::seg_selected, dt_masks_node_polygon_t::state, t, and TRUE.
Referenced by _polygon_add_node_callback(), and _polygon_events_button_pressed().
|
static |
Change polygon hardness for the active node scope or the full shape.
Definition at line 1618 of file polygon.c.
References _init_hardness(), _polygon_get_sizes(), dt_masks_node_polygon_t::border, CLAMPF, dt_masks_apply_increment_precomputed(), dt_masks_gui_change_affects_selected_node_or_all(), dt_masks_gui_form_create(), HARDNESS_MAX, HARDNESS_MIN, and dt_masks_form_t::points.
Referenced by _polygon_events_mouse_scrolled(), and _polygon_set_interaction_value().
|
static |
Scale the polygon around its centroid.
This preserves each node's local control-point offsets so the curve shape scales uniformly with the polygon size.
Definition at line 1549 of file polygon.c.
References _polygon_form_gravity_center(), _polygon_get_sizes(), dt_masks_node_polygon_t::ctrl1, dt_masks_node_polygon_t::ctrl2, dt_masks_gui_change_affects_selected_node_or_all(), dt_masks_gui_form_create(), DT_MASKS_INCREMENT_ABSOLUTE, DT_MASKS_INCREMENT_OFFSET, DT_MASKS_INCREMENT_SCALE, dt_toast_log(), IS_NULL_PTR, dt_masks_node_polygon_t::node, and dt_masks_form_t::points.
Referenced by _polygon_events_mouse_scrolled(), and _polygon_set_interaction_value().
|
static |
Definition at line 1451 of file polygon.c.
References _polygon_border_handle_cb(), _polygon_curve_handle_cb(), _polygon_distance_cb(), and dt_masks_find_closest_handle_common().
|
static |
Definition at line 2366 of file polygon.c.
References _polygon_bounding_box(), _polygon_get_pts_border(), dt_iop_module_t::dev, DT_DEV_TRANSFORM_DIR_BACK_INCL, dt_pixelpipe_cache_free_align, height, dt_iop_module_t::iop_order, IS_NULL_PTR, dt_masks_form_t::points, and width.
Referenced by _polygon_get_area(), and _polygon_get_source_area().
|
static |
Initialize hardness from config and emit the toast with a size-normalized percentage.
Definition at line 1533 of file polygon.c.
References dt_masks_get_set_conf_value(), dt_toast_log(), HARDNESS_MAX, and HARDNESS_MIN.
Referenced by _change_hardness().
|
inlinestatic |
Definition at line 399 of file polygon.c.
Referenced by _polygon_points_recurs().
Definition at line 3556 of file polygon.c.
References _add_node_to_segment(), darktable, darktable_t::develop, dt_masks_form_get_selected_group(), dt_masks_get_from_id(), dt_masks_get_visible_form(), dt_masks_form_group_t::formid, dt_masks_form_gui_t::group_selected, IS_NULL_PTR, and dt_masks_form_group_t::parentid.
Referenced by _polygon_populate_context_menu().
|
static |
Evaluate a cubic Bezier and its border offset at t in [0, 1].
The border point is offset along the normal, scaled by rad.
Definition at line 88 of file polygon.c.
References _polygon_get_XY(), d, double(), and t.
Referenced by _polygon_get_pts_border(), and _polygon_points_recurs().
|
static |
Polygon-specific border handle lookup.
Polygon borders are stored directly in gui_points->border at node indices.
Definition at line 1418 of file polygon.c.
References dt_masks_form_gui_points_t::border, FALSE, and IS_NULL_PTR.
Referenced by _find_closest_handle().
|
static |
Compute bounding box and add a small padding for rasterization safety.
Definition at line 2352 of file polygon.c.
References _polygon_bounding_box_raw(), height, and width.
Referenced by _get_area(), and _polygon_get_mask().
|
static |
Compute raw bounding box for polygon points and border samples.
Definition at line 2309 of file polygon.c.
Referenced by _polygon_bounding_box(), and _polygon_get_mask_roi().
|
static |
Convert a Catmull-Rom segment to Bezier control points.
Definition at line 178 of file polygon.c.
Referenced by _polygon_init_ctrl_points().
|
static |
Close the polygon creation by removing the temporary last node.
Definition at line 1691 of file polygon.c.
References _polygon_init_ctrl_points(), dt_masks_form_gui_t::creation_module, darktable, darktable_t::develop, dt_free, dt_masks_gui_form_save_creation(), dt_toast_log(), g_list_shorter_than(), dt_masks_form_gui_t::node_dragging, and dt_masks_form_t::points.
Referenced by _polygon_creation_closing_form_callback(), _polygon_events_button_pressed(), and _polygon_events_key_pressed().
|
static |
Definition at line 3500 of file polygon.c.
References _polygon_creation_closing_form(), darktable, darktable_t::develop, dt_masks_get_visible_form(), and IS_NULL_PTR.
Referenced by _polygon_populate_context_menu().
|
static |
crop polygon to roi given by xmin, xmax, ymin, ymax. polygon segments outside of roi are replaced by nodes lying on roi borders.
Definition at line 2714 of file polygon.c.
References delta, dt_free, IS_NULL_PTR, k, n, r, and x.
Referenced by _polygon_get_mask_roi().
|
static |
Convert control point #2 into a handle extremity.
The values are expected in orthonormal space.
Definition at line 128 of file polygon.c.
Referenced by _polygon_curve_handle_cb(), _polygon_events_button_pressed(), and _polygon_events_post_expose().
|
static |
Polygon-specific curve handle lookup (depends on winding direction).
Definition at line 1430 of file polygon.c.
References _polygon_ctrl2_to_handle(), dt_masks_form_gui_points_t::clockwise, and dt_masks_form_gui_points_t::points.
Referenced by _find_closest_handle().
|
static |
Polygon-specific inside/border/segment hit testing.
Definition at line 1442 of file polygon.c.
References _polygon_get_distance(), and dist().
Referenced by _find_closest_handle().
|
static |
|
static |
Definition at line 3484 of file polygon.c.
References dt_masks_duplicate_points().
|
static |
Definition at line 1714 of file polygon.c.
References _add_node_to_segment(), _polygon_creation_closing_form(), _polygon_ctrl2_to_handle(), _polygon_init_ctrl_points(), dt_masks_node_polygon_t::border, dt_masks_form_gui_points_t::border, dt_masks_form_gui_points_t::clockwise, dt_masks_form_gui_t::creation, dt_masks_form_gui_t::creation_closing_form, dt_masks_node_polygon_t::ctrl1, dt_masks_node_polygon_t::ctrl2, darktable, dt_masks_form_gui_t::delta, darktable_t::develop, dt_conf_get_float(), DT_MASKS_CLONE, DT_MASKS_EDIT_FULL, dt_masks_gui_cursor_to_raw_norm(), dt_masks_gui_form_create(), dt_masks_node_is_cusp(), DT_MASKS_POINT_STATE_NORMAL, DT_MASKS_POINT_STATE_USER, dt_masks_set_source_pos_initial_state(), dt_masks_set_source_pos_initial_value(), dt_masks_toggle_bezier_node_type(), dt_modifier_is(), dt_masks_form_gui_t::edit_mode, dt_masks_form_gui_t::form_selected, dt_masks_form_gui_t::handle_border_hovered, dt_masks_form_gui_t::handle_hovered, HARDNESS_MAX, HARDNESS_MIN, IS_NULL_PTR, MAX, MIN, dt_masks_node_polygon_t::node, dt_masks_form_gui_t::node_dragging, dt_masks_form_gui_t::node_hovered, dt_masks_form_gui_t::node_selected, dt_masks_form_gui_t::node_selected_idx, dt_masks_form_t::points, dt_masks_form_gui_points_t::points, dt_masks_form_gui_t::points, dt_masks_form_gui_t::pos, dt_masks_form_gui_t::seg_hovered, dt_masks_form_t::source, dt_masks_form_gui_points_t::source, dt_masks_form_gui_t::source_selected, dt_masks_node_polygon_t::state, state, TRUE, type, and dt_masks_form_t::type.
|
static |
Definition at line 1892 of file polygon.c.
References dt_masks_form_gui_t::creation, dt_masks_gui_is_dragging(), and IS_NULL_PTR.
|
static |
Definition at line 1907 of file polygon.c.
References _polygon_creation_closing_form(), dt_masks_form_gui_t::creation, darktable, darktable_t::develop, dt_dev_pixelpipe_update_history_preview, dt_keys_mainpad_alternatives(), dt_masks_form_exit_creation(), dt_masks_remove_node(), IS_NULL_PTR, key, dt_masks_node_polygon_t::node, dt_masks_form_gui_t::node_dragging, and dt_masks_form_t::points.
|
static |
Polygon mouse-move handler.
Widget-space coordinates are only used by the top-level dispatcher. Absolute output-image coordinates come from mask_gui->pos, normalized output-image coordinates come from mask_gui->rel_pos, and raw-space edits are derived locally through the appropriate backtransform helper.
Definition at line 1959 of file polygon.c.
References _polygon_handle_to_ctrl(), _polygon_init_ctrl_points(), _polygon_is_clockwise(), _polygon_translate_all_nodes(), _polygon_translate_node(), dt_masks_node_polygon_t::border, dt_masks_form_gui_points_t::border, dt_masks_form_gui_points_t::clockwise, dt_masks_form_gui_t::creation, dt_masks_form_gui_t::creation_closing_form, dt_masks_node_polygon_t::ctrl1, dt_masks_node_polygon_t::ctrl2, darktable, darktable_t::develop, dt_dev_coordinates_image_abs_to_raw_norm(), DT_GUI_MOUSE_EFFECT_RADIUS, dt_masks_border_from_projected_handle(), DT_MASKS_CLONE, dt_masks_gui_delta_from_raw_anchor(), dt_masks_gui_delta_to_image_abs(), dt_masks_gui_delta_to_raw_norm(), dt_masks_gui_form_create(), dt_masks_gui_form_create_throttled(), DT_MASKS_POINT_STATE_USER, dt_masks_project_on_line(), dt_masks_set_ctrl_points(), dt_masks_translate_source(), dt_masks_form_gui_t::form_dragging, g_list_next_wraparound(), g_list_shorter_than(), dt_masks_form_gui_t::handle_border_dragging, dt_masks_form_gui_t::handle_dragging, IS_NULL_PTR, dt_masks_node_polygon_t::node, dt_masks_form_gui_t::node_dragging, p, dt_masks_form_t::points, dt_masks_form_gui_points_t::points, dt_masks_form_gui_t::points, dt_masks_form_gui_t::pos, dt_develop_t::raw_height, dt_develop_t::raw_width, dt_develop_t::roi, dt_masks_form_gui_t::seg_dragging, dt_masks_form_t::source, dt_masks_form_gui_t::source_dragging, dt_masks_node_polygon_t::state, and dt_masks_form_t::type.
|
static |
Handle mouse wheel updates for polygon size/hardness/opacity.
Definition at line 1660 of file polygon.c.
References _change_hardness(), _change_size(), dt_masks_form_gui_t::creation, DT_MASKS_EDIT_FULL, dt_masks_form_change_opacity(), DT_MASKS_INCREMENT_OFFSET, DT_MASKS_INCREMENT_SCALE, dt_masks_is_anything_selected(), dt_modifier_is(), dt_masks_form_gui_t::edit_mode, dt_masks_form_gui_t::node_selected, and state.
|
static |
Draw polygon overlays (nodes, handles, borders, source) after exposure.
Definition at line 2161 of file polygon.c.
References _polygon_ctrl2_to_handle(), _polygon_gui_gravity_center(), _polygon_is_clockwise(), dt_masks_form_gui_points_t::border, dt_masks_form_gui_points_t::border_count, dt_masks_form_gui_t::border_selected, dt_masks_form_gui_points_t::clockwise, dt_masks_form_gui_t::creation, darktable, darktable_t::develop, dt_masks_functions_t::draw_shape, dt_draw_handle(), dt_draw_node(), dt_draw_shape_lines(), DT_MASKS_CLONE, DT_MASKS_DASH_STICK, dt_masks_draw_path_seg_by_seg(), dt_masks_draw_source(), dt_masks_draw_source_preview(), dt_masks_functions_polygon, dt_masks_get_from_id(), dt_masks_get_visible_form(), DT_MASKS_GROUP, dt_masks_gui_selected_handle_border_index(), dt_masks_gui_selected_handle_index(), dt_masks_gui_selected_node_index(), DT_MASKS_IS_RETOUCHE, dt_masks_node_is_cusp(), FALSE, dt_masks_form_group_t::formid, dt_masks_form_gui_t::group_selected, dt_masks_form_gui_t::handle_border_hovered, dt_masks_form_gui_t::handle_hovered, dt_masks_form_gui_t::handle_selected, IS_NULL_PTR, dt_masks_gui_center_point_t::main, dt_masks_form_gui_t::node_dragging, dt_masks_form_gui_t::node_hovered, dt_masks_form_gui_t::node_selected, dt_masks_form_t::points, dt_masks_form_gui_points_t::points, dt_masks_form_gui_t::points, dt_masks_form_gui_points_t::points_count, dt_masks_form_gui_t::pos, dt_masks_form_gui_points_t::source, dt_masks_gui_center_point_t::source, dt_masks_form_gui_points_t::source_count, TRUE, dt_masks_form_t::type, dt_masks_form_gui_t::type, x, dt_masks_gui_center_point_t::x, and dt_masks_gui_center_point_t::y.
| void _polygon_falloff | ( | float *const restrict | buffer, |
| int * | p0, | ||
| int * | p1, | ||
| int | posx, | ||
| int | posy, | ||
| int | buffer_width | ||
| ) |
Write a falloff segment into the mask buffer.
Definition at line 2414 of file polygon.c.
Referenced by _polygon_get_mask().
|
inlinestatic |
|
static |
Fill gaps between two points with an integer Bresenham line.
This avoids repeated floating-point division and rounding errors.
Definition at line 278 of file polygon.c.
References dt_masks_dynbuf_add_2(), and dt_masks_dynbuf_reset().
Referenced by _polygon_find_self_intersection().
|
static |
Find all self-intersection segments in a polygon border.
Definition at line 478 of file polygon.c.
References _polygon_fill_gaps(), dt_masks_dynbuf_add_2(), dt_masks_dynbuf_buffer(), dt_masks_dynbuf_free(), dt_masks_dynbuf_get(), dt_masks_dynbuf_init(), dt_masks_dynbuf_position(), dt_masks_dynbuf_set(), dt_pixelpipe_cache_alloc_align_cache, dt_pixelpipe_cache_free_align, i, IS_NULL_PTR, k, and POLYGON_MAX_SELF_INTERSECTIONS.
Referenced by _polygon_get_pts_border().
|
static |
Compute polygon centroid from the form nodes (normalized space).
Definition at line 1499 of file polygon.c.
References FALSE, g_list_next_wraparound(), g_list_shorter_than(), IS_NULL_PTR, dt_masks_node_polygon_t::node, dt_masks_form_t::points, and TRUE.
Referenced by _change_size().
|
static |
|
static |
Compute proximity between a point and the polygon GUI shape.
Definition at line 1301 of file polygon.c.
References dt_masks_form_gui_points_t::border, dt_masks_form_gui_points_t::border_count, dist(), dt_masks_point_in_form_exact(), i, IS_NULL_PTR, dt_masks_form_gui_points_t::points, dt_masks_form_gui_t::points, dt_masks_form_gui_points_t::points_count, dt_masks_form_gui_points_t::source, and dt_masks_form_gui_points_t::source_count.
Referenced by _polygon_distance_cb().
|
static |
Definition at line 1244 of file polygon.c.
References dt_alloc_align_float(), dt_free_align, dt_masks_center_of_gravity_from_points(), FALSE, i, IS_NULL_PTR, dt_masks_node_polygon_t::node, and dt_masks_form_t::points.
|
static |
Definition at line 1211 of file polygon.c.
References dt_masks_node_polygon_t::border, dt_masks_get_form_size_from_nodes(), DT_MASKS_INTERACTION_HARDNESS, DT_MASKS_INTERACTION_SIZE, IS_NULL_PTR, dt_masks_form_t::points, and size.
Referenced by _polygon_set_interaction_value().
|
static |
Definition at line 2439 of file polygon.c.
References __OMP_PARALLEL_FOR__, _polygon_bounding_box(), _polygon_falloff(), _polygon_get_pts_border(), darktable, dt_iop_module_t::dev, DT_DEBUG_MASKS, DT_DEBUG_PERF, dt_dev_pixelpipe_has_preview_output(), DT_DEV_PIXELPIPE_THUMBNAIL, DT_DEV_TRANSFORM_DIR_BACK_INCL, dt_get_wtime(), dt_pixelpipe_cache_alloc_align_float_cache, dt_pixelpipe_cache_free_align, dt_print(), FALSE, height, i, dt_iop_module_t::iop_order, IS_NULL_PTR, k, dt_masks_form_t::name, dt_masks_form_t::points, row, state, t, TRUE, dt_dev_pixelpipe_t::type, darktable_t::unmuted, v, and width.
|
static |
Definition at line 3048 of file polygon.c.
References __OMP_PARALLEL_FOR__, _polygon_bounding_box_raw(), _polygon_crop_to_roi(), _polygon_falloff_roi(), _polygon_get_pts_border(), darktable, dt_iop_module_t::dev, DT_DEBUG_MASKS, DT_DEBUG_PERF, dt_dev_pixelpipe_has_preview_output(), DT_DEV_PIXELPIPE_THUMBNAIL, DT_DEV_TRANSFORM_DIR_BACK_INCL, dt_get_wtime(), dt_pixelpipe_cache_alloc_align_cache, dt_pixelpipe_cache_alloc_align_float_cache, dt_pixelpipe_cache_free_align, dt_print(), FALSE, height, dt_iop_roi_t::height, i, dt_iop_module_t::iop_order, IS_NULL_PTR, k, m, MAX, MIN, n, dt_masks_form_t::name, dt_masks_form_t::points, row, dt_iop_roi_t::scale, state, t, TRUE, dt_dev_pixelpipe_t::type, darktable_t::unmuted, v, width, dt_iop_roi_t::width, x, dt_iop_roi_t::x, and dt_iop_roi_t::y.
|
static |
Definition at line 1140 of file polygon.c.
References _polygon_get_pts_border(), DT_DEV_TRANSFORM_DIR_ALL, dt_iop_module_t::iop_order, IS_NULL_PTR, and dt_develop_t::virtual_pipe.
|
static |
Find the parametric position along a segment closest to a point.
We only need 1% precision, so we use exhaustive sampling.
Definition at line 1039 of file polygon.c.
References _polygon_get_XY(), dist(), g_list_next_bounded(), i, IS_NULL_PTR, dt_masks_node_polygon_t::node, dt_masks_form_t::points, and t.
Referenced by _add_node_to_segment().
|
static |
Build point and border buffers for a polygon mask.
This handles gaps, self-intersections, and optional iop distortion transforms.
Definition at line 689 of file polygon.c.
References __OMP_PARALLEL_FOR_SIMD__, _polygon_border_get_XY(), _polygon_find_self_intersection(), _polygon_is_clockwise(), _polygon_points_recurs(), _polygon_points_recurs_border_gaps(), dt_masks_node_polygon_t::border, dt_masks_node_polygon_t::ctrl1, dt_masks_node_polygon_t::ctrl2, darktable, darktable_t::develop, DT_DEBUG_MASKS, DT_DEBUG_PERF, dt_dev_distort_transform_plus(), dt_dev_pixelpipe_has_preview_output(), DT_DEV_PIXELPIPE_THUMBNAIL, DT_DEV_TRANSFORM_DIR_ALL, DT_DEV_TRANSFORM_DIR_BACK_EXCL, DT_DEV_TRANSFORM_DIR_FORW_INCL, dt_get_wtime(), dt_masks_dynbuf_add_2(), dt_masks_dynbuf_add_zeros(), dt_masks_dynbuf_buffer(), dt_masks_dynbuf_free(), dt_masks_dynbuf_get(), dt_masks_dynbuf_harvest(), dt_masks_dynbuf_init(), dt_masks_dynbuf_position(), dt_masks_dynbuf_reserve_n(), dt_masks_dynbuf_set(), dt_pixelpipe_cache_alloc_align_float_cache, dt_pixelpipe_cache_free_align, dt_print(), g_list_next_wraparound(), i, dt_dev_pixelpipe_t::iheight, IS_NULL_PTR, dt_dev_pixelpipe_t::iwidth, MAX, MIN, dt_masks_form_t::name, dt_masks_node_polygon_t::node, dt_masks_form_t::points, dt_masks_form_t::source, dt_dev_pixelpipe_t::type, darktable_t::unmuted, and v.
Referenced by _get_area(), _polygon_get_mask(), _polygon_get_mask_roi(), and _polygon_get_points_border().
|
static |
Definition at line 1152 of file polygon.c.
References dt_masks_form_gui_points_t::border, darktable, darktable_t::develop, dt_dev_coordinates_preview_abs_to_image_norm(), fx, i, IS_NULL_PTR, dt_masks_form_t::points, dt_masks_form_gui_points_t::points, dt_masks_form_gui_t::points, dt_masks_form_gui_points_t::points_count, and x.
Referenced by _change_hardness(), and _change_size().
|
static |
|
static |
Evaluate a cubic Bezier at t in [0, 1].
Uses the four control points (p0..p3) and returns the interpolated point.
Definition at line 70 of file polygon.c.
Referenced by _polygon_border_get_XY(), and _polygon_get_position_in_segment().
|
static |
Compute polygon centroid from GUI points using the shoelace formula.
This treats the polygon as simple and closed, using the node positions only (no border points). The area is returned with sign (clockwise vs counter).
Definition at line 1464 of file polygon.c.
References IS_NULL_PTR.
Referenced by _polygon_events_post_expose().
|
static |
Convert a handle extremity into symmetric Bezier control points.
The values are expected in orthonormal space.
Definition at line 151 of file polygon.c.
Referenced by _polygon_events_mouse_moved().
|
static |
Initialize control points to match a Catmull-Rom-like spline.
Only points in DT_MASKS_POINT_STATE_NORMAL are regenerated.
Definition at line 194 of file polygon.c.
References _polygon_catmull_to_bezier(), dt_masks_node_polygon_t::ctrl1, dt_masks_node_polygon_t::ctrl2, dt_free, DT_MASKS_POINT_STATE_NORMAL, IS_NULL_PTR, dt_masks_node_polygon_t::node, dt_masks_form_t::points, and dt_masks_node_polygon_t::state.
Referenced by _add_node_to_segment(), _polygon_creation_closing_form(), _polygon_events_button_pressed(), and _polygon_events_mouse_moved().
|
static |
Definition at line 3490 of file polygon.c.
References darktable, darktable_t::develop, dt_dev_coordinates_raw_norm_to_raw_abs(), and x.
|
static |
Determine polygon winding order.
Returns TRUE when points are clockwise in normalized space.
Definition at line 253 of file polygon.c.
References g_list_next_wraparound(), g_list_shorter_than(), IS_NULL_PTR, dt_masks_node_polygon_t::node, dt_masks_form_t::points, and TRUE.
Referenced by _polygon_events_mouse_moved(), _polygon_events_post_expose(), _polygon_get_pts_border(), and _polygon_reset_round_node_callback().
|
static |
Recursive subdivision to sample polygon and border points.
This avoids large gaps by subdividing until points are within a pixel threshold.
Definition at line 411 of file polygon.c.
References _is_within_pxl_threshold(), _polygon_border_get_XY(), _polygon_points_recurs(), and dt_masks_dynbuf_add_2().
Referenced by _polygon_get_pts_border(), and _polygon_points_recurs().
|
static |
Fill gaps between border points with a circular arc.
This is used when the border has gaps, especially near sharp nodes.
Definition at line 337 of file polygon.c.
References dt_masks_dynbuf_reserve_n(), IS_NULL_PTR, and M_PI.
Referenced by _polygon_get_pts_border().
|
static |
Definition at line 3578 of file polygon.c.
References _masks_gui_delete_node_callback(), _polygon_add_node_callback(), _polygon_creation_closing_form_callback(), _polygon_reset_round_node_callback(), _polygon_switch_node_callback(), dt_masks_form_gui_t::creation, ctx_gtk_menu_item_new_with_icon_and_shortcut(), ctx_gtk_menu_item_new_with_markup(), ctx_gtk_menu_item_new_with_markup_and_shortcut(), dt_free, dt_masks_node_is_cusp(), DT_MENU_ICON_CIRCLE, DT_MENU_ICON_SQUARE, FALSE, g_list_shorter_than(), dt_masks_form_gui_t::group_selected, IS_NULL_PTR, menu_item_set_fake_accel, dt_masks_form_gui_t::node_hovered, dt_masks_form_t::points, dt_masks_form_gui_t::points, dt_masks_form_gui_t::seg_selected, and TRUE.
Definition at line 3532 of file polygon.c.
References _polygon_is_clockwise(), dt_masks_form_gui_points_t::clockwise, darktable, darktable_t::develop, dt_masks_get_from_id(), dt_masks_gui_selected_handle_index(), dt_masks_reset_bezier_ctrl_points(), dt_masks_form_gui_t::formid, dt_masks_form_gui_t::group_selected, IS_NULL_PTR, MAX, dt_masks_form_gui_t::node_hovered, dt_masks_form_gui_t::node_selected, dt_masks_form_gui_t::node_selected_idx, dt_masks_form_t::points, dt_masks_form_gui_t::points, dt_masks_node_polygon_t::state, and TRUE.
Referenced by _polygon_populate_context_menu().
|
static |
|
static |
Assign a default name for a polygon form.
Definition at line 3452 of file polygon.c.
References dt_masks_form_t::name.
|
static |
|
static |
Definition at line 1277 of file polygon.c.
References _change_hardness(), _change_size(), _polygon_get_interaction_value(), DT_MASKS_INTERACTION_HARDNESS, DT_MASKS_INTERACTION_SIZE, IS_NULL_PTR, and value.
Definition at line 3510 of file polygon.c.
References dt_masks_node_polygon_t::ctrl1, dt_masks_node_polygon_t::ctrl2, darktable, darktable_t::develop, dt_masks_get_from_id(), dt_masks_gui_selected_node_index(), dt_masks_toggle_bezier_node_type(), dt_masks_form_gui_t::formid, dt_masks_form_gui_t::group_selected, IS_NULL_PTR, dt_masks_node_polygon_t::node, dt_masks_form_gui_t::node_hovered, dt_masks_form_gui_t::node_selected, dt_masks_form_gui_t::node_selected_idx, dt_masks_form_t::points, dt_masks_form_gui_t::points, dt_masks_node_polygon_t::state, and TRUE.
Referenced by _polygon_populate_context_menu().
|
static |
Definition at line 1134 of file polygon.c.
References _polygon_translate_node(), and dt_masks_form_t::points.
Referenced by _polygon_events_mouse_moved().
|
inlinestatic |
Definition at line 1129 of file polygon.c.
References dt_masks_node_polygon_t::ctrl1, dt_masks_node_polygon_t::ctrl2, dt_masks_translate_ctrl_node(), and dt_masks_node_polygon_t::node.
Referenced by _polygon_events_mouse_moved(), and _polygon_translate_all_nodes().
| const dt_masks_functions_t dt_masks_functions_polygon |
Definition at line 3643 of file polygon.c.
Referenced by _polygon_events_post_expose(), and dt_masks_create().