![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include "control/user_message.h"#include "math/math.h"#include "system/macros.h"#include "system/openmp.h"#include "system/mem_alloc.h"#include "common/logging.h"#include "common/times.h"#include "common/glib_utils.h"#include "caches/pixelpipe_cache_alloc.h"#include "widgets/gdkkeys.h"#include "widgets/accelerators.h"#include "widgets/widget_settings.h"#include "common/conf.h"#include "develop/imageop.h"#include "develop/masks/masks_distort.h"#include "develop/masks.h"#include "develop/masks_gui.h"#include "develop/masks/masks_functions.h"#include "develop/masks/masks_touched.h"#include "math/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.
Data Structures | |
| struct | _polygon_frame_t |
| struct | _polygon_walk_t |
| struct | _polygon_walk_state_t |
Macros | |
| #define | FADING_MIN 0.0005f |
| #define | FADING_MAX 1.0f |
| #define | BORDER_MIN 0.00005f |
| #define | BORDER_MAX 0.5f |
Typedefs | |
| typedef struct _polygon_frame_t | _polygon_frame_t |
| typedef struct _polygon_walk_t | _polygon_walk_t |
| typedef struct _polygon_walk_state_t | _polygon_walk_state_t |
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 gboolean | _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 radius_rate, 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 float | _polygon_radius_at (const float r1, const float r2, const double t) |
| static float | _polygon_radius_rate_at (const float r1, const float r2, const double t) |
| 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 void | _polygon_points_recurs_border_gaps (const float *const center_max, const float *const border_min, const float *const border_max, dt_masks_dynbuf_t *draw_points, dt_masks_dynbuf_t *draw_border, gboolean clockwise, const int step) |
| 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, const gboolean have_min, const gboolean have_max, gboolean have_border_min, gboolean have_border_max, gboolean *out_have_border) |
| Recursive subdivision to sample polygon and border points. | |
| static void | _polygon_segment_load (const dt_masks_node_polygon_t *const from, const dt_masks_node_polygon_t *const to, const _polygon_frame_t *const f, float p1[5], float p2[5]) |
| static void | _polygon_joint_arc (const _polygon_walk_t *const w, const float *const centre, const float *const from, const float *const to) |
| static gboolean | _polygon_walk_segment (const _polygon_walk_t *const w, _polygon_walk_state_t *const s, const int k) |
| static void | _polygon_walk_write_header (const _polygon_walk_t *const w) |
| static int | _polygon_get_pts_border (dt_develop_t *develop, dt_masks_form_t *mask_form, const double iop_order, const int transform_direction, const dt_masks_distort_t *const dist, float **point_buffer, int *point_count, float **border_buffer, int *border_count, gboolean source) |
| 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 dt_masks_raster_result_t | _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, dt_masks_skip_range_t **border_skips, int *border_skip_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 (dt_develop_t *dev, 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_fading (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 fading 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_handle, 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_handle, 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_fading (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 fading 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/fading/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 (struct dt_develop_t *dev, cairo_t *cr, const float *point_buffer, const int point_count, const int node_count, const gboolean draw_border, const gboolean draw_source, const dt_masks_skip_range_t *skips, const int skip_count) |
| 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 dt_masks_raster_result_t | _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 dt_masks_raster_result_t | _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 | _falloff_bridge_steps (const int *const last0, const int *const last1, const int *const p0, const int *const p1) |
| static void | _falloff_bridge_lerp (const int *const from, const int *const to, const float t, int *const out) |
| static void | _falloff_bridge_stamp (float *const restrict buffer, const int *const last0, const int *const last1, const int *const p0, const int *const p1, const int posx, const int posy, const int width) |
| static int | _falloff_bridge_queue (int *const dpoints, int dindex, const int capacity, const int *const last0, const int *const last1, const int *const p0, const int *const p1) |
| static dt_masks_raster_result_t | _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 dt_masks_raster_result_t | _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, dt_iop_roi_t *touched) |
| 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, 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 (struct dt_develop_t *dev, 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 |
| typedef struct _polygon_frame_t _polygon_frame_t |
| typedef struct _polygon_walk_state_t _polygon_walk_state_t |
| typedef struct _polygon_walk_t _polygon_walk_t |
|
static |
Definition at line 902 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, dt_masks_form_gui_t::dev, 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 fading for the active node scope or the full shape.
Definition at line 1490 of file polygon.c.
References _init_fading(), _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(), FADING_MAX, FADING_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 1421 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().
|
inlinestatic |
Definition at line 2341 of file polygon.c.
Referenced by _falloff_bridge_queue(), and _falloff_bridge_stamp().
|
inlinestatic |
Queue the bridging spokes for the ROI path, which stamps them in parallel afterwards. Returns the new write index. Same geometry as _falloff_bridge_stamp(), different sink.
Definition at line 2368 of file polygon.c.
References _falloff_bridge_lerp(), _falloff_bridge_steps(), k, and t.
Referenced by _polygon_get_mask_roi().
|
inlinestatic |
Stamp the bridging spokes straight into buffer.
Definition at line 2349 of file polygon.c.
References _falloff_bridge_lerp(), _falloff_bridge_steps(), _polygon_falloff(), k, t, and width.
Referenced by _polygon_get_mask().
|
inlinestatic |
How many sub-steps bridge the jump between two consecutive feather spokes.
The feather is the union of segments from each outline sample to its border sample, so it stays continuous only while consecutive segments are within a pixel of each other at BOTH ends. At a cut boundary they are not: the border side collapses to the cut's resume point and the fan opens in a single step, leaving a wedge nothing stamps – the thin dark radial line reported as "a radial spoke is missing" at node 12 of polygon #2 in issue #1313's sidecar. One sub-step per pixel of the larger jump closes it.
The two rasterisers differ only in where the bridging spokes GO, so the geometry lives here once and each sink gets its own three-line wrapper below.
Definition at line 2332 of file polygon.c.
Referenced by _falloff_bridge_queue(), and _falloff_bridge_stamp().
|
static |
Definition at line 1323 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 2237 of file polygon.c.
References _polygon_bounding_box(), _polygon_get_pts_border(), dt_iop_module_t::dev, DT_DEV_TRANSFORM_DIR_BACK_INCL, dt_masks_distort_for_pipe(), 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 fading from config and emit the toast with a size-normalized percentage.
Definition at line 1405 of file polygon.c.
References dt_masks_get_set_conf_value(), dt_toast_log(), FADING_MAX, and FADING_MIN.
Referenced by _change_fading().
|
inlinestatic |
Definition at line 400 of file polygon.c.
Referenced by _polygon_points_recurs().
Definition at line 3543 of file polygon.c.
References _add_node_to_segment(), dt_masks_form_gui_t::dev, 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 97 of file polygon.c.
References _polygon_get_XY(), d, double(), dt_masks_outline_envelope_offset(), FALSE, t, and TRUE.
Referenced by _polygon_points_recurs(), and _polygon_walk_segment().
|
static |
Polygon-specific border handle lookup.
Polygon borders are stored directly in gui_points->border at node indices.
Definition at line 1290 of file polygon.c.
References dt_masks_form_gui_points_t::border, FALSE, IS_NULL_PTR, and TRUE.
Referenced by _find_closest_handle().
|
static |
Compute bounding box and add a small padding for rasterization safety.
Definition at line 2223 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 2181 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 239 of file polygon.c.
Referenced by _polygon_init_ctrl_points().
|
static |
Close the polygon creation by removing the temporary last node.
Definition at line 1574 of file polygon.c.
References _polygon_init_ctrl_points(), dt_masks_form_gui_t::creation_module, dt_masks_form_gui_t::dev, 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 3487 of file polygon.c.
References _polygon_creation_closing_form(), dt_masks_form_gui_t::dev, 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 2679 of file polygon.c.
References delta, dt_alloc_align(), dt_free_align, 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 189 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 1302 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 1314 of file polygon.c.
References _polygon_get_distance(), and dist().
Referenced by _find_closest_handle().
|
static |
Draw a polygon or border polyline, skipping NaN points.
Definition at line 2014 of file polygon.c.
References dt_masks_draw_outline_runs(), and void().
|
static |
Definition at line 3471 of file polygon.c.
References dt_masks_duplicate_points().
|
static |
Definition at line 1597 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, dt_masks_form_gui_t::delta, dt_masks_form_gui_t::dev, 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_PRIMARY_MASK, dt_masks_form_gui_t::edit_mode, FADING_MAX, FADING_MIN, dt_masks_form_gui_t::form_selected, dt_masks_form_gui_t::handle_border_hovered, dt_masks_form_gui_t::handle_hovered, 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, dt_masks_form_t::type, and type.
|
static |
Definition at line 1775 of file polygon.c.
References dt_masks_form_gui_t::creation, dt_masks_gui_is_dragging(), and IS_NULL_PTR.
|
static |
Definition at line 1790 of file polygon.c.
References _polygon_creation_closing_form(), dt_masks_form_gui_t::creation, dt_masks_form_gui_t::dev, 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 1842 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, dt_masks_form_gui_t::dev, dt_dev_coordinates_image_abs_to_raw_norm(), dt_dev_geometry_snapshot(), 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(), geometry, 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_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/fading/opacity.
Definition at line 1532 of file polygon.c.
References _change_fading(), _change_size(), dt_masks_form_gui_t::creation, dt_masks_form_gui_t::dev, DT_MASKS_EDIT_FULL, dt_masks_form_change_opacity(), DT_MASKS_INCREMENT_OFFSET, DT_MASKS_INCREMENT_SCALE, DT_MASKS_INTERACTION_FADING, DT_MASKS_INTERACTION_OPACITY, DT_MASKS_INTERACTION_SIZE, dt_masks_is_anything_selected(), and dt_masks_form_gui_t::edit_mode.
|
static |
Draw polygon overlays (nodes, handles, borders, source) after exposure.
Definition at line 2033 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::border_skip_count, dt_masks_form_gui_points_t::border_skips, dt_masks_form_gui_points_t::clockwise, dt_masks_form_gui_t::creation, dt_masks_form_gui_t::dev, 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, selected, 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 2296 of file polygon.c.
Referenced by _falloff_bridge_stamp(), and _polygon_get_mask().
|
inlinestatic |
|
static |
Compute polygon centroid from the form nodes (normalized space).
Definition at line 1371 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 |
Definition at line 2280 of file polygon.c.
References _get_area(), dt_masks_raster_from_status(), FALSE, height, and width.
|
static |
Compute proximity between a point and the polygon GUI shape.
Definition at line 1158 of file polygon.c.
References dt_masks_form_gui_points_t::border, dt_masks_form_gui_points_t::border_count, dt_masks_form_gui_points_t::border_skip_count, dt_masks_form_gui_points_t::border_skips, dist(), dt_masks_gui_points_reach(), 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 1098 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 1065 of file polygon.c.
References dt_masks_node_polygon_t::border, dt_masks_get_form_size_from_nodes(), DT_MASKS_INTERACTION_FADING, DT_MASKS_INTERACTION_SIZE, IS_NULL_PTR, dt_masks_form_t::points, and size.
Referenced by _polygon_set_interaction_value().
|
static |
Definition at line 2389 of file polygon.c.
References __OMP_PARALLEL_FOR__, _falloff_bridge_stamp(), _polygon_bounding_box(), _polygon_falloff(), _polygon_get_pts_border(), dt_iop_module_t::dev, DT_DEBUG_MASKS, DT_DEBUG_PERF, DT_DEV_TRANSFORM_DIR_BACK_INCL, dt_get_debug_flags(), dt_get_wtime(), dt_masks_distort_for_pipe(), DT_MASKS_RASTER_ERROR, DT_MASKS_RASTER_OK, 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, v, and width.
|
static |
Definition at line 3013 of file polygon.c.
References __OMP_PARALLEL_FOR__, _falloff_bridge_queue(), _polygon_bounding_box_raw(), _polygon_crop_to_roi(), _polygon_falloff_roi(), _polygon_get_pts_border(), dt_iop_module_t::dev, DT_DEBUG_MASKS, DT_DEBUG_PERF, DT_DEV_TRANSFORM_DIR_BACK_INCL, dt_get_debug_flags(), dt_get_wtime(), dt_masks_distort_for_pipe(), DT_MASKS_RASTER_EMPTY, DT_MASKS_RASTER_ERROR, DT_MASKS_RASTER_OK, dt_masks_touched_full(), dt_masks_touched_none(), dt_masks_touched_set(), 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, v, width, dt_iop_roi_t::width, x, dt_iop_roi_t::x, and dt_iop_roi_t::y.
|
static |
Definition at line 965 of file polygon.c.
References _polygon_get_pts_border(), DT_DEV_TRANSFORM_DIR_ALL, dt_masks_distort_for_gui(), dt_masks_outline_boundary_skips(), DT_MASKS_RASTER_ERROR, dt_masks_raster_from_status(), dt_iop_module_t::iop_order, IS_NULL_PTR, dt_masks_form_t::points, and status.
|
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 864 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 |
get all points of the polygon and the border this takes care of gaps and iop distortions
Definition at line 674 of file polygon.c.
References __OMP_PARALLEL_FOR_SIMD__, _polygon_is_clockwise(), _polygon_joint_arc(), _polygon_walk_segment(), _polygon_walk_write_header(), dt_masks_node_polygon_t::ctrl1, dt_masks_node_polygon_t::ctrl2, dist(), dt_alloc_align(), DT_DEBUG_MASKS, DT_DEBUG_PERF, DT_DEV_TRANSFORM_DIR_ALL, DT_DEV_TRANSFORM_DIR_BACK_EXCL, DT_DEV_TRANSFORM_DIR_FORW_INCL, dt_free_align, dt_get_debug_flags(), dt_get_wtime(), dt_masks_distort_transform(), dt_masks_dynbuf_add_zeros(), dt_masks_dynbuf_free(), dt_masks_dynbuf_harvest(), dt_masks_dynbuf_init(), dt_masks_dynbuf_position(), dt_masks_dynbuf_reserve_n(), dt_pixelpipe_cache_free_align, dt_print(), i, IS_NULL_PTR, k, dt_masks_form_t::name, dt_masks_node_polygon_t::node, _polygon_walk_t::nodes, dt_masks_form_t::points, dt_masks_form_t::source, state, and _polygon_walk_t::with_border.
Referenced by _get_area(), _polygon_get_mask(), _polygon_get_mask_roi(), and _polygon_get_points_border().
|
static |
Definition at line 998 of file polygon.c.
References dt_masks_form_gui_points_t::border, dt_masks_form_gui_t::dev, 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_fading(), and _change_size().
|
static |
Definition at line 2268 of file polygon.c.
References _get_area(), dt_masks_raster_from_status(), height, TRUE, and width.
|
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 79 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 1336 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 212 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 255 of file polygon.c.
References _polygon_catmull_to_bezier(), dt_masks_node_polygon_t::ctrl1, dt_masks_node_polygon_t::ctrl2, dt_alloc_align(), dt_free_align, 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 3477 of file polygon.c.
References 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 314 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 |
Definition at line 585 of file polygon.c.
References _polygon_points_recurs_border_gaps(), _polygon_walk_t::clockwise, _polygon_walk_t::dborder, _polygon_walk_t::dpoints, dt_masks_outline_short_way(), and _polygon_walk_t::pixel_threshold.
Referenced by _polygon_get_pts_border(), and _polygon_walk_segment().
|
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 412 of file polygon.c.
References _is_within_pxl_threshold(), _polygon_border_get_XY(), _polygon_points_recurs(), _polygon_radius_at(), _polygon_radius_rate_at(), dt_masks_dynbuf_add_2(), dt_masks_outline_offset_along(), FALSE, IS_NULL_PTR, and TRUE.
Referenced by _polygon_points_recurs(), and _polygon_walk_segment().
|
static |
Fill gaps between border points with a circular arc.
This is used when the border has gaps, especially near_handle sharp nodes.
Definition at line 339 of file polygon.c.
References dt_masks_dynbuf_reserve_n(), IS_NULL_PTR, and M_PI.
Referenced by _polygon_joint_arc().
|
static |
Definition at line 3565 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_accels_display_mods(), dt_free, dt_masks_node_is_cusp(), DT_MENU_ICON_CIRCLE, DT_MENU_ICON_SQUARE, DT_PRIMARY_MASK, 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.
|
inlinestatic |
|
inlinestatic |
Definition at line 3519 of file polygon.c.
References _polygon_is_clockwise(), dt_masks_form_gui_points_t::clockwise, dt_masks_form_gui_t::dev, 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 |
Definition at line 540 of file polygon.c.
References dt_masks_node_polygon_t::border, dt_masks_node_polygon_t::ctrl1, dt_masks_node_polygon_t::ctrl2, f, MIN, dt_masks_node_polygon_t::node, and _polygon_frame_t::radius_sign.
Referenced by _polygon_walk_segment().
|
static |
Assign a default name for a polygon form.
Definition at line 3433 of file polygon.c.
References dt_masks_form_t::name.
|
static |
Definition at line 3438 of file polygon.c.
References dt_masks_form_gui_t::border_selected, dt_masks_form_gui_t::creation, dt_masks_form_gui_t::form_selected, dt_masks_form_gui_t::handle_border_hovered, dt_masks_form_gui_t::handle_hovered, dt_masks_form_gui_t::node_hovered, dt_masks_form_gui_t::node_selected, dt_masks_form_t::points, dt_masks_form_gui_t::seg_hovered, dt_masks_form_gui_t::seg_selected, and dt_masks_form_gui_t::source_selected.
|
static |
Definition at line 1131 of file polygon.c.
References _change_fading(), _change_size(), _polygon_get_interaction_value(), DT_MASKS_INTERACTION_FADING, DT_MASKS_INTERACTION_SIZE, dt_masks_form_gui_t::group_selected, IS_NULL_PTR, and value.
Definition at line 3497 of file polygon.c.
References dt_masks_node_polygon_t::ctrl1, dt_masks_node_polygon_t::ctrl2, dt_masks_form_gui_t::dev, 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 959 of file polygon.c.
References _polygon_translate_node(), and dt_masks_form_t::points.
Referenced by _polygon_events_mouse_moved().
|
inlinestatic |
Definition at line 954 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().
|
static |
Definition at line 595 of file polygon.c.
References _polygon_border_get_XY(), _polygon_joint_arc(), _polygon_points_recurs(), _polygon_segment_load(), _polygon_walk_state_t::b, _polygon_walk_state_t::c, c1, _polygon_walk_t::dborder, _polygon_walk_t::dpoints, dt_masks_dynbuf_add_2(), dt_masks_outline_offset_along(), FALSE, _polygon_walk_state_t::first_b, _polygon_walk_state_t::first_c, _polygon_walk_t::frame, _polygon_walk_state_t::have_first, _polygon_walk_state_t::have_prev, k, _polygon_walk_t::node_border, _polygon_walk_t::node_count, _polygon_walk_t::node_has_border, _polygon_walk_t::nodes, _polygon_walk_t::pixel_threshold, TRUE, and _polygon_walk_t::with_border.
Referenced by _polygon_get_pts_border().
|
static |
Definition at line 658 of file polygon.c.
References _polygon_walk_t::dborder, dt_masks_dynbuf_buffer(), k, _polygon_walk_t::node_border, _polygon_walk_t::node_count, _polygon_walk_t::node_has_border, and _polygon_walk_t::with_border.
Referenced by _polygon_get_pts_border().
| const dt_masks_functions_t dt_masks_functions_polygon |
Definition at line 3630 of file polygon.c.
Referenced by _polygon_events_post_expose(), _time_overlay_all(), _time_overlay_group(), dt_masks_create(), and main().