Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
masks.c File Reference
#include "develop/masks.h"
#include "bauhaus/bauhaus.h"
#include "common/debug.h"
#include "common/mipmap_cache.h"
#include "control/conf.h"
#include "common/undo.h"
#include "develop/blend.h"
#include "develop/imageop.h"
#include "develop/imageop_gui.h"
#include "detail.c"
+ Include dependency graph for develop/masks/masks.c:

Functions

dt_masks_form_tdt_masks_dup_masks_form (const dt_masks_form_t *form)
 
static void_dup_masks_form_cb (const void *formdata, gpointer user_data)
 
GList * dt_masks_dup_forms_deep (GList *forms, dt_masks_form_t *form)
 
static int _get_opacity (dt_masks_form_gui_t *gui, const dt_masks_form_t *form)
 
static void _set_hinter_message (dt_masks_form_gui_t *gui, const dt_masks_form_t *form)
 
void dt_masks_init_form_gui (dt_masks_form_gui_t *gui)
 
void dt_masks_soft_reset_form_gui (dt_masks_form_gui_t *gui)
 
void dt_masks_gui_form_create (dt_masks_form_t *form, dt_masks_form_gui_t *gui, int index, dt_iop_module_t *module)
 
void dt_masks_form_gui_points_free (gpointer data)
 
static void _masks_remove_node (struct dt_iop_module_t *module, dt_masks_form_t *form, int parentid, dt_masks_form_gui_t *gui, int index)
 
static gboolean _masks_remove_shape (struct dt_iop_module_t *module, dt_masks_form_t *form, int parentid, dt_masks_form_gui_t *gui, int index)
 Remove a shape from the GUI and free its resources.
 
gboolean dt_masks_gui_delete (struct dt_iop_module_t *module, dt_masks_form_t *form, dt_masks_form_gui_t *gui, const int parentid)
 Delete a mask shape or node form from the GUI. This function is to be used with a popupmenu "Delete" action in the future.
 
void dt_masks_gui_form_remove (dt_masks_form_t *form, dt_masks_form_gui_t *gui, int index)
 
void dt_masks_gui_form_test_create (dt_masks_form_t *form, dt_masks_form_gui_t *gui, dt_iop_module_t *module)
 
static void _check_id (dt_masks_form_t *form)
 
static void _set_group_name_from_module (dt_iop_module_t *module, dt_masks_form_t *grp)
 
static dt_masks_form_t_group_create (dt_develop_t *dev, dt_iop_module_t *module, dt_masks_type_t type)
 
static dt_masks_form_t_group_from_module (dt_develop_t *dev, dt_iop_module_t *module)
 
void dt_masks_append_form (dt_develop_t *dev, dt_masks_form_t *form)
 
void dt_masks_remove_form (dt_develop_t *dev, dt_masks_form_t *form)
 
void dt_masks_gui_form_save_creation (dt_develop_t *dev, dt_iop_module_t *module, dt_masks_form_t *form, dt_masks_form_gui_t *gui)
 
int dt_masks_form_duplicate (dt_develop_t *dev, int formid)
 
int dt_masks_get_points_border (dt_develop_t *dev, dt_masks_form_t *form, float **points, int *points_count, float **border, int *border_count, int source, dt_iop_module_t *module)
 
int dt_masks_get_area (dt_iop_module_t *module, dt_dev_pixelpipe_iop_t *piece, dt_masks_form_t *form, int *width, int *height, int *posx, int *posy)
 
int dt_masks_get_source_area (dt_iop_module_t *module, dt_dev_pixelpipe_iop_t *piece, dt_masks_form_t *form, int *width, int *height, int *posx, int *posy)
 
int dt_masks_version (void)
 
static int dt_masks_legacy_params_v1_to_v2 (dt_develop_t *dev, void *params)
 
static void dt_masks_legacy_params_v2_to_v3_transform (const dt_image_t *img, float *points)
 
static void dt_masks_legacy_params_v2_to_v3_transform_only_rescale (const dt_image_t *img, float *points, size_t points_count)
 
static int dt_masks_legacy_params_v2_to_v3 (dt_develop_t *dev, void *params)
 
static int dt_masks_legacy_params_v3_to_v4 (dt_develop_t *dev, void *params)
 
static int dt_masks_legacy_params_v4_to_v5 (dt_develop_t *dev, void *params)
 
static int dt_masks_legacy_params_v5_to_v6 (dt_develop_t *dev, void *params)
 
int dt_masks_legacy_params (dt_develop_t *dev, void *params, const int old_version, const int new_version)
 
dt_masks_form_tdt_masks_create (dt_masks_type_t type)
 
dt_masks_form_tdt_masks_create_ext (dt_masks_type_t type)
 
void dt_masks_replace_current_forms (dt_develop_t *dev, GList *forms)
 
dt_masks_form_tdt_masks_get_from_id_ext (GList *forms, int id)
 
dt_masks_form_tdt_masks_get_from_id (dt_develop_t *dev, int id)
 
void dt_masks_read_masks_history (dt_develop_t *dev, const int32_t imgid)
 
void dt_masks_write_masks_history_item (const int32_t imgid, const int num, dt_masks_form_t *form)
 
void dt_masks_free_form (dt_masks_form_t *form)
 
int dt_masks_events_mouse_leave (struct dt_iop_module_t *module)
 
int dt_masks_events_mouse_enter (struct dt_iop_module_t *module)
 
static void _set_cursor_shape (dt_masks_form_gui_t *gui)
 
int dt_masks_events_mouse_moved (struct dt_iop_module_t *module, double x, double y, double pressure, int which)
 
int dt_masks_events_button_released (struct dt_iop_module_t *module, double x, double y, int which, uint32_t state)
 
int dt_masks_events_button_pressed (struct dt_iop_module_t *module, double x, double y, double pressure, int which, int type, uint32_t state)
 
int dt_masks_events_mouse_scrolled (struct dt_iop_module_t *module, double x, double y, int up, uint32_t state, int scrolling_delta)
 
gboolean dt_masks_is_corner_node (const dt_masks_form_gui_points_t *gpt, const int index, const int nb, const int coord_offset)
 returns wether a node is a corner or not. A node is a corner if its 2 control handles are at the same position, else it's a curve.
 
void _dt_masks_find_best_attachment_point (float *pos_x, float *pos_y, const float offset, const float radius, const float origin_x, const float origin_y, const float cosc, const float sinc, const float *points, const int points_count)
 Find the best attachment point for the arrow's tip or arrow's base along shape outline.
 
void dt_masks_draw_source (cairo_t *cr, dt_masks_form_gui_t *gui, const int index, const int nb, const float zoom_scale, const shape_draw_function_t *draw_shape_func)
 Draw the source for a correction mask.
 
void dt_masks_events_post_expose (struct dt_iop_module_t *module, cairo_t *cr, int32_t width, int32_t height, int32_t pointerx, int32_t pointery)
 
void dt_masks_clear_form_gui (dt_develop_t *dev)
 
void dt_masks_change_form_gui (dt_masks_form_t *newform)
 
void dt_masks_reset_form_gui (void)
 
void dt_masks_reset_show_masks_icons (void)
 
dt_masks_edit_mode_t dt_masks_get_edit_mode (struct dt_iop_module_t *module)
 
void dt_masks_set_edit_mode (struct dt_iop_module_t *module, dt_masks_edit_mode_t value)
 
static void _menu_no_masks (struct dt_iop_module_t *module)
 
static void _menu_add_shape (struct dt_iop_module_t *module, dt_masks_type_t type)
 
static void _menu_add_exist (dt_iop_module_t *module, int formid)
 
void dt_masks_group_update_name (dt_iop_module_t *module)
 
void dt_masks_iop_use_same_as (dt_iop_module_t *module, dt_iop_module_t *src)
 
void dt_masks_iop_combo_populate (GtkWidget *w, void *m)
 
void dt_masks_iop_value_changed_callback (GtkWidget *widget, struct dt_iop_module_t *module)
 
void dt_masks_form_remove (struct dt_iop_module_t *module, dt_masks_form_t *grp, dt_masks_form_t *form)
 
float dt_masks_form_get_opacity (dt_masks_form_t *form, int parentid)
 
const char * _get_mask_plugin (dt_masks_form_t *form)
 
const char * _get_mask_type (dt_masks_form_t *form)
 
float dt_masks_get_set_conf_value (dt_masks_form_t *form, char *feature, float new_value, float v_min, float v_max, dt_masks_increment_t increment, int flow)
 Change a numerical property of a mask shape, either by in/de-crementing the current value or setting it in an absolute fashion, then save it to configuration.
 
int dt_masks_form_set_opacity (dt_masks_form_t *form, int parentid, float opacity, dt_masks_increment_t offset, const int flow)
 
int dt_masks_form_change_opacity (dt_masks_form_t *form, int parentid, int up, const int flow)
 
void dt_masks_form_move (dt_masks_form_t *grp, int formid, int up)
 
static int _find_in_group (dt_masks_form_t *grp, int formid)
 
dt_masks_form_group_tdt_masks_group_add_form (dt_masks_form_t *grp, dt_masks_form_t *form)
 
void dt_masks_group_ungroup (dt_masks_form_t *dest_grp, dt_masks_form_t *grp)
 
uint64_t dt_masks_group_get_hash (uint64_t hash, dt_masks_form_t *form)
 
static void _cleanup_unused_recurs (GList *forms, int formid, int *used, int nb)
 
static int _masks_cleanup_unused (GList **_forms, GList *history_list, const int history_end)
 
void dt_masks_cleanup_unused_from_list (GList *history_list)
 
void dt_masks_cleanup_unused (dt_develop_t *dev)
 
int dt_masks_point_in_form_exact (float x, float y, float *points, int points_start, int points_count)
 Check whether the 2D point (x, y) lies inside the polygon (mask) described by points.
 
int dt_masks_point_in_form_near (float x, float y, float *points, int points_start, int points_count, float distance, int *near)
 
void dt_masks_select_form (struct dt_iop_module_t *module, dt_masks_form_t *sel)
 
void dt_masks_draw_clone_source_pos (cairo_t *cr, const float zoom_scale, const float x, const float y)
 
void dt_masks_set_source_pos_initial_state (dt_masks_form_gui_t *gui, const uint32_t state, const float pzx, const float pzy)
 
void dt_masks_set_source_pos_initial_value (dt_masks_form_gui_t *gui, dt_masks_form_t *form, const float pzx, const float pzy)
 
void dt_masks_calculate_source_pos_value (dt_masks_form_gui_t *gui, const int mask_type, const float initial_xpos, const float initial_ypos, const float xpos, const float ypos, float *px, float *py, const int adding)
 
float dt_masks_rotate_with_anchor (dt_develop_t *dev, const float anchor[2], const float center[2], dt_masks_form_gui_t *gui)
 Rotate a mask shape around its center. WARNING: gui->delta will be updated with the new position after rotation.
 
gboolean dt_masks_is_within_radius (const float px, const float py, const float cx, const float cy, const float radius)
 Check if a point (px,py) is inside a radius from a center point (cx,cy)
 

Variables

static int form_id = 0
 

Function Documentation

◆ _check_id()

◆ _cleanup_unused_recurs()

static void _cleanup_unused_recurs ( GList *  forms,
int  formid,
int *  used,
int  nb 
)
static

◆ _dt_masks_find_best_attachment_point()

void _dt_masks_find_best_attachment_point ( float *  pos_x,
float *  pos_y,
const float  offset,
const float  radius,
const float  origin_x,
const float  origin_y,
const float  cosc,
const float  sinc,
const float *  points,
const int  points_count 
)

Find the best attachment point for the arrow's tip or arrow's base along shape outline.

Parameters
pos_xresulting x position
pos_yresulting y position
offsetoffset from the shape outline
radiusmax radius of the shape
origin_xx position of the shape's origin point
origin_yy position of the shape's origin point
cosccosine of the angle
sincsine of the angle
pointsarray of points defining the shape outline
points_countnumber of points in the shape outline

References sqf().

Referenced by dt_masks_draw_source().

◆ _dup_masks_form_cb()

static void * _dup_masks_form_cb ( const void formdata,
gpointer  user_data 
)
static

◆ _find_in_group()

◆ _get_mask_plugin()

const char * _get_mask_plugin ( dt_masks_form_t form)

◆ _get_mask_type()

◆ _get_opacity()

◆ _group_create()

◆ _group_from_module()

◆ _masks_cleanup_unused()

static int _masks_cleanup_unused ( GList **  _forms,
GList *  history_list,
const int  history_end 
)
static

◆ _masks_remove_node()

◆ _masks_remove_shape()

static gboolean _masks_remove_shape ( struct dt_iop_module_t module,
dt_masks_form_t form,
int  parentid,
dt_masks_form_gui_t gui,
int  index 
)
static

Remove a shape from the GUI and free its resources.

Parameters
moduleThe module owning the mask
formThe form to remove
parentidThe parent ID of the form
guiThe GUI state
indexThe index of the form in the group
Returns
gboolean TRUE if the form was removed, FALSE otherwise.

References darktable, darktable_t::develop, dt_masks_change_form_gui(), dt_masks_clear_form_gui(), dt_masks_form_remove(), dt_masks_get_from_id(), DT_MASKS_GROUP, dt_masks_form_gui_t::edit_mode, dt_develop_t::form_visible, dt_masks_form_group_t::formid, dt_masks_form_t::formid, g_list_shorter_than(), dt_masks_form_t::points, and dt_masks_form_t::type.

Referenced by dt_masks_gui_delete().

◆ _menu_add_exist()

◆ _menu_add_shape()

◆ _menu_no_masks()

◆ _set_cursor_shape()

◆ _set_group_name_from_module()

static void _set_group_name_from_module ( dt_iop_module_t module,
dt_masks_form_t grp 
)
static

◆ _set_hinter_message()

◆ dt_masks_append_form()

void dt_masks_append_form ( dt_develop_t dev,
dt_masks_form_t form 
)

◆ dt_masks_calculate_source_pos_value()

void dt_masks_calculate_source_pos_value ( dt_masks_form_gui_t gui,
const int  mask_type,
const float  initial_xpos,
const float  initial_ypos,
const float  xpos,
const float  ypos,
float *  px,
float *  py,
const int  adding 
)

◆ dt_masks_change_form_gui()

◆ dt_masks_cleanup_unused()

◆ dt_masks_cleanup_unused_from_list()

void dt_masks_cleanup_unused_from_list ( GList *  history_list)

◆ dt_masks_clear_form_gui()

◆ dt_masks_create()

◆ dt_masks_create_ext()

dt_masks_form_t * dt_masks_create_ext ( dt_masks_type_t  type)

we create a completely new form and add it to darktable.develop->allforms.

References dt_develop_t::allforms, darktable, darktable_t::develop, dt_masks_create(), and type.

Referenced by dt_masks_set_edit_mode(), and rt_show_forms_for_current_scale().

◆ dt_masks_draw_clone_source_pos()

void dt_masks_draw_clone_source_pos ( cairo_t *  cr,
const float  zoom_scale,
const float  x,
const float  y 
)

◆ dt_masks_draw_source()

◆ dt_masks_dup_forms_deep()

GList * dt_masks_dup_forms_deep ( GList *  forms,
dt_masks_form_t form 
)

◆ dt_masks_dup_masks_form()

◆ dt_masks_events_button_pressed()

◆ dt_masks_events_button_released()

◆ dt_masks_events_mouse_enter()

int dt_masks_events_mouse_enter ( struct dt_iop_module_t module)

◆ dt_masks_events_mouse_leave()

int dt_masks_events_mouse_leave ( struct dt_iop_module_t module)

◆ dt_masks_events_mouse_moved()

◆ dt_masks_events_mouse_scrolled()

◆ dt_masks_events_post_expose()

◆ dt_masks_form_change_opacity()

int dt_masks_form_change_opacity ( dt_masks_form_t form,
int  parentid,
int  up,
const int  flow 
)

◆ dt_masks_form_duplicate()

◆ dt_masks_form_get_opacity()

float dt_masks_form_get_opacity ( dt_masks_form_t form,
int  parentid 
)

◆ dt_masks_form_gui_points_free()

◆ dt_masks_form_move()

void dt_masks_form_move ( dt_masks_form_t grp,
int  formid,
int  up 
)

◆ dt_masks_form_remove()

◆ dt_masks_form_set_opacity()

◆ dt_masks_free_form()

◆ dt_masks_get_area()

int dt_masks_get_area ( dt_iop_module_t module,
dt_dev_pixelpipe_iop_t piece,
dt_masks_form_t form,
int *  width,
int *  height,
int *  posx,
int *  posy 
)

get the rectangle which include the form and his border

References dt_masks_form_t::functions, dt_masks_functions_t::get_area, height, and width.

Referenced by masks_form_is_in_roi(), rt_compute_roi_in(), and rt_masks_form_is_in_roi().

◆ dt_masks_get_edit_mode()

◆ dt_masks_get_from_id()

dt_masks_form_t * dt_masks_get_from_id ( dt_develop_t dev,
int  id 
)

returns a form with formid == id from dev->forms

References dt_masks_get_from_id_ext(), and dt_develop_t::forms.

Referenced by _blendop_masks_show_and_edit(), _brush_events_button_released(), _circle_events_button_pressed(), _edit_masks(), _ellipse_events_button_pressed(), _find_in_group(), _get_opacity(), _group_events_button_pressed(), _group_events_button_released(), _group_events_mouse_moved(), _group_events_mouse_scrolled(), _group_events_post_expose_draw(), _group_from_module(), _group_get_mask(), _group_get_mask_roi(), _gui_reset_callback(), _is_form_used(), _lib_masks_list_recurs(), _masks_remove_shape(), _menu_add_exist(), _polygon_events_button_pressed(), _polygon_events_post_expose(), _reset_form_creation(), _resynch_params(), _set_hinter_message(), _shape_is_being_added(), _tree_add_exist(), _tree_button_pressed(), _tree_cell_edited(), _tree_delete_shape(), _tree_difference(), _tree_exclusion(), _tree_intersection(), _tree_inverse(), _tree_movedown(), _tree_moveup(), _tree_selection_change(), _tree_union(), _update_foreach(), dt_masks_form_duplicate(), dt_masks_form_get_opacity(), dt_masks_form_remove(), dt_masks_form_set_opacity(), dt_masks_group_get_hash(), dt_masks_group_ungroup(), dt_masks_gui_form_test_create(), dt_masks_iop_update(), dt_masks_iop_use_same_as(), dt_masks_set_edit_mode(), give_control_to_form(), gui_focus(), gui_update(), post_history_commit(), rt_display_selected_shapes_lbl(), rt_edit_masks_callback(), rt_get_mask_point_group(), rt_resynch_params(), rt_shape_is_being_added(), rt_show_forms_for_current_scale(), and rt_show_hide_controls().

◆ dt_masks_get_from_id_ext()

◆ dt_masks_get_points_border()

int dt_masks_get_points_border ( dt_develop_t dev,
dt_masks_form_t form,
float **  points,
int *  points_count,
float **  border,
int *  border_count,
int  source,
dt_iop_module_t module 
)

get points in real space with respect of distortion dx and dy are used to eventually move the center of the circle

References dt_masks_form_t::functions, and dt_masks_functions_t::get_points_border.

Referenced by dt_masks_gui_form_create().

◆ dt_masks_get_set_conf_value()

float dt_masks_get_set_conf_value ( dt_masks_form_t form,
char *  feature,
float  new_value,
float  v_min,
float  v_max,
dt_masks_increment_t  increment,
const int  flow 
)

Change a numerical property of a mask shape, either by in/de-crementing the current value or setting it in an absolute fashion, then save it to configuration.

Parameters
formthe shape to change. We will read its type internally
featurethe propertie to change: hardness, size, curvature (for gradients)
new_valueif increment is set to absolute, this is directly the updated value. if increment is offset, the updated value is old_value + new_value. if increment is scale, the updated value is old value * new_value.
v_minminimum acceptable value of the property for sanitization
v_maxmaximum acceptable value of the property for sanitization
incrementthe increment type: absolute, offset or scale.
flowthe value of the scroll distance that can be postive or negative.

References _get_mask_plugin(), _get_mask_type(), dt_conf_get_float(), dt_conf_set_float(), DT_MASKS_INCREMENT_OFFSET, DT_MASKS_INCREMENT_SCALE, key, MAX, and MIN.

Referenced by _brush_events_button_pressed(), _brush_events_button_released(), _brush_events_post_expose(), _change_hardness(), _change_size(), _init_curvature(), _init_extent(), _init_hardness(), _init_hardness(), _init_hardness(), _init_hardness(), _init_opacity(), _init_opacity(), _init_opacity(), _init_opacity(), _init_rotation(), _init_rotation(), _init_size(), _init_size(), and _init_size().

◆ dt_masks_get_source_area()

int dt_masks_get_source_area ( dt_iop_module_t module,
dt_dev_pixelpipe_iop_t piece,
dt_masks_form_t form,
int *  width,
int *  height,
int *  posx,
int *  posy 
)

◆ dt_masks_group_add_form()

◆ dt_masks_group_get_hash()

◆ dt_masks_group_ungroup()

◆ dt_masks_group_update_name()

◆ dt_masks_gui_delete()

gboolean dt_masks_gui_delete ( struct dt_iop_module_t module,
dt_masks_form_t form,
dt_masks_form_gui_t gui,
const int  parentid 
)

Delete a mask shape or node form from the GUI. This function is to be used with a popupmenu "Delete" action in the future.

Parameters
moduleThe module owning the mask
formThe form to delete
guiThe GUI state of the form
parentidThe parent ID of the form
Returns
gboolean TRUE if the form was deleted, FALSE otherwise

References _masks_remove_node(), _masks_remove_shape(), DT_MASKS_BRUSH, DT_MASKS_EDIT_FULL, DT_MASKS_POLYGON, dt_masks_form_gui_t::edit_mode, g_list_shorter_than(), dt_masks_form_gui_t::group_selected, dt_masks_form_gui_t::node_selected, dt_masks_form_t::points, and dt_masks_form_t::type.

Referenced by _group_events_button_pressed().

◆ dt_masks_gui_form_create()

◆ dt_masks_gui_form_remove()

◆ dt_masks_gui_form_save_creation()

◆ dt_masks_gui_form_test_create()

◆ dt_masks_init_form_gui()

◆ dt_masks_iop_combo_populate()

◆ dt_masks_iop_use_same_as()

◆ dt_masks_iop_value_changed_callback()

◆ dt_masks_is_corner_node()

gboolean dt_masks_is_corner_node ( const dt_masks_form_gui_points_t gpt,
const int  index,
const int  nb,
const int  coord_offset 
)

returns wether a node is a corner or not. A node is a corner if its 2 control handles are at the same position, else it's a curve.

Parameters
gptthe GUI points of the mask form
indexthe index of the node to test
nbthe number of coord by node
coord_offsetthe offset of the coordinates in the points array
Returns
TRUE if the node is a corner, FALSE it's a curve.

References dt_masks_form_gui_points_t::points.

Referenced by _brush_events_button_pressed(), _brush_events_post_expose(), _ellipse_draw_node(), _find_closest_handle(), _find_closest_handle(), _polygon_events_button_pressed(), and _polygon_events_post_expose().

◆ dt_masks_is_within_radius()

gboolean dt_masks_is_within_radius ( const float  px,
const float  py,
const float  cx,
const float  cy,
const float  radius 
)

Check if a point (px,py) is inside a radius from a center point (cx,cy)

Parameters
pxx coord of the point to test
pyy coord of the point to test
cxcenter x coord
cycenter y coord
radiusthe radius from center
Returns
gboolean TRUE if the point is inside the radius from center, FALSE otherwise

Referenced by _find_closest_handle(), _find_closest_handle(), and _find_closest_handle().

◆ dt_masks_legacy_params()

int dt_masks_legacy_params ( dt_develop_t dev,
void params,
const int  old_version,
const int  new_version 
)

◆ dt_masks_legacy_params_v1_to_v2()

◆ dt_masks_legacy_params_v2_to_v3()

◆ dt_masks_legacy_params_v2_to_v3_transform()

static void dt_masks_legacy_params_v2_to_v3_transform ( const dt_image_t img,
float *  points 
)
static

◆ dt_masks_legacy_params_v2_to_v3_transform_only_rescale()

static void dt_masks_legacy_params_v2_to_v3_transform_only_rescale ( const dt_image_t img,
float *  points,
size_t  points_count 
)
static

◆ dt_masks_legacy_params_v3_to_v4()

static int dt_masks_legacy_params_v3_to_v4 ( dt_develop_t dev,
void params 
)
static

◆ dt_masks_legacy_params_v4_to_v5()

static int dt_masks_legacy_params_v4_to_v5 ( dt_develop_t dev,
void params 
)
static

◆ dt_masks_legacy_params_v5_to_v6()

static int dt_masks_legacy_params_v5_to_v6 ( dt_develop_t dev,
void params 
)
static

◆ dt_masks_point_in_form_exact()

int dt_masks_point_in_form_exact ( float  x,
float  y,
float *  points,
int  points_start,
int  points_count 
)

Check whether the 2D point (x, y) lies inside the polygon (mask) described by points.

  • Algorithm: ray-casting (even-odd rule). Cast a horizontal ray to +X from the test point and count segment crossings; odd => inside, even => outside.
  • y is rounded using yf = floorf(y + 0.5f) to reduce problems caused by intersections with horizontal edges / vertex coordinates.
  • The function supports "deleted" vertices encoded as (NaN, next_index): when a vertex's x is NaN, its y stores the integer index of the next valid vertex to jump to (used for self-intersections).
  • To avoid double-counting intersections on segment endpoints the test uses: (yf > min(y1,y2)) && (yf <= max(y1,y2))
  • For each crossing, the intersection X coordinate is computed and compared to the test x.
Parameters
xThe x-coordinate of the point to test.
yThe y-coordinate of the point to test.
pointsThe array of polygon vertices.
points_startThe starting index of the polygon vertices in the array.
points_countThe total number of vertices in the polygon.
Returns
int 1 if the point is inside the polygon, 0 otherwise.

Referenced by _circle_get_distance(), _ellipse_get_distance(), _polygon_get_distance(), and dt_masks_draw_source().

◆ dt_masks_point_in_form_near()

int dt_masks_point_in_form_near ( float  x,
float  y,
float *  points,
int  points_start,
int  points_count,
float  distance,
int *  near 
)
Todo:
: distance is only evaluated in x, not y...

Referenced by _circle_get_distance().

◆ dt_masks_read_masks_history()

◆ dt_masks_remove_form()

void dt_masks_remove_form ( dt_develop_t dev,
dt_masks_form_t form 
)

References dt_develop_t::forms.

Referenced by dt_masks_form_remove().

◆ dt_masks_replace_current_forms()

void dt_masks_replace_current_forms ( dt_develop_t dev,
GList *  forms 
)

◆ dt_masks_reset_form_gui()

◆ dt_masks_reset_show_masks_icons()

void dt_masks_reset_show_masks_icons ( void  )

◆ dt_masks_rotate_with_anchor()

float dt_masks_rotate_with_anchor ( dt_develop_t dev,
const float  anchor[2],
const float  center[2],
dt_masks_form_gui_t gui 
)

Rotate a mask shape around its center. WARNING: gui->delta will be updated with the new position after rotation.

Parameters
devthe develop structure
anchorthe array representing the anchor position (grabbing point) in normalized coordinates.
centerthe array representing the origin point of rotation in normalized coordinates
guithe GUI form structure
Returns
* float : The signed angle to increment.

References dt_masks_form_gui_t::delta, dt_dev_distort_backtransform(), and M_PI.

Referenced by _ellipse_events_mouse_moved(), and _gradient_events_mouse_moved().

◆ dt_masks_select_form()

◆ dt_masks_set_edit_mode()

◆ dt_masks_set_source_pos_initial_state()

◆ dt_masks_set_source_pos_initial_value()

◆ dt_masks_soft_reset_form_gui()

◆ dt_masks_version()

int dt_masks_version ( void  )

◆ dt_masks_write_masks_history_item()

Variable Documentation

◆ form_id

int form_id = 0
static

Referenced by dt_masks_create().