82 "SELECT op_params, blendop_params, name, description, operation,"
83 " autoapply, model, maker, lens, iso_min, iso_max, exposure_min,"
84 " exposure_max, aperture_min, aperture_max, focal_length_min,"
85 " focal_length_max, op_version, blendop_version, enabled,"
86 " multi_priority, multi_name, filter, def, format "
149 " (name, description, operation, autoapply,"
150 " model, maker, lens, iso_min, iso_max, exposure_min, exposure_max,"
151 " aperture_min, aperture_max, focal_length_min, focal_length_max,"
152 " op_params, op_version, blendop_params, blendop_version, enabled,"
153 " multi_priority, multi_name, filter, def, format, writeprotect)"
154 " VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, "
155 " ?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23, ?24, ?25, 0)",
203#define _PRESET_COLUMNS \
204 "(name, description, operation, op_version, op_params, blendop_params, " \
205 " blendop_version, enabled, model, maker, lens, iso_min, iso_max, exposure_min, " \
206 " exposure_max, aperture_min, aperture_max, focal_length_min, focal_length_max, " \
207 " writeprotect, autoapply, filter, def, format)"
234 " WHERE operation=?1 AND op_version=?2"
235 " ORDER BY writeprotect %s, LOWER(name), rowid",
244 "SELECT name, op_params, writeprotect FROM data.presets"
245 " WHERE operation=?1 AND op_version=?2",
268 p->op_version = op_version;
285 "SELECT rowid, op_version, op_params, name FROM data.presets"
286 " WHERE operation=?1"
287 " ORDER BY writeprotect DESC, LOWER(name), rowid",
318 "SELECT rowid, op_version, op_params, name FROM data.presets"
319 " WHERE operation=?1 AND op_version=?2"
320 " ORDER BY writeprotect DESC, LOWER(name), rowid",
353 "SELECT name FROM data.presets"
354 " WHERE operation = ?1 AND op_version = ?2 AND name = ?3",
371 "SELECT rowid FROM data.presets"
372 " WHERE name = ?1 AND operation = ?2 AND op_version = ?3",
391 "SELECT op_params, writeprotect FROM data.presets"
392 " WHERE operation = ?1 AND op_version = ?2 AND name = ?3",
409 p->op_version = op_version;
418 const int op_version,
const void *params,
425 " VALUES (?1, '', ?2, ?3, ?4, NULL, 0, 1, '%', '%', '%', 0, "
426 " 340282346638528859812000000000000000000, 0, 100000000, 0, 100000000, "
427 " 0, 1000, 0, 0, 0, 0, 0)",
439 const int op_version,
const void *params,
446 " VALUES (?1, '', ?2, ?3, ?4, NULL, 0, 1, '%', '%', '%', 0, "
447 " 340282346638528859812000000000000000000, 0, 10000000, 0, 100000000, "
448 " 0, 1000, ?5, 0, 0, 0, 0)",
463 const int op_version,
const void *params,
469 "UPDATE data.presets SET op_version=?2, op_params=?3"
470 " WHERE name=?4 AND operation=?1",
482 const int op_version)
486 "UPDATE data.presets SET op_version=?1 WHERE operation=?2 AND name=?3",
498 const int blendop_version,
const void *blend_params,
504 "SET blendop_version=?1, blendop_params=?2 "
505 "WHERE operation=?3 AND name=?4",
524 "SELECT name, op_version, op_params, blendop_version, blendop_params FROM data.presets WHERE operation = ?1",
557 "UPDATE data.presets SET name = ?1, description = ?2, op_params = ?3"
558 " WHERE operation = ?4 AND op_version = ?5 AND name = ?6",
578 " SELECT ?1, description, operation, op_version, op_params, blendop_params,"
579 " blendop_version, enabled, model, maker, lens, iso_min, iso_max,"
580 " exposure_min, exposure_max, aperture_min, aperture_max,"
581 " focal_length_min, focal_length_max, 0, autoapply, filter, def, format"
583 " WHERE operation = ?2 AND op_version = ?3 AND name = ?4",
600 "DELETE FROM data.presets"
601 " WHERE name=?1 AND operation=?2 AND op_version=?3 AND writeprotect=0",
618 "DELETE FROM data.presets WHERE operation=?1",
634 "UPDATE data.presets SET op_version=?1, op_params=?2 WHERE rowid=?3",
649 "DELETE FROM data.presets WHERE rowid=?1", -1, &
stmt,
NULL);
667 " SET iso_min=?1, iso_max=?2"
668 " WHERE operation=?3 AND op_version=?4 AND name=?5",
670 " SET aperture_min=?1, aperture_max=?2"
671 " WHERE operation=?3 AND op_version=?4 AND name=?5",
673 " SET exposure_min=?1, exposure_max=?2"
674 " WHERE operation=?3 AND op_version=?4 AND name=?5",
676 " SET focal_length_min=?1, focal_length_max=?2"
677 " WHERE operation=?3 AND op_version=?4 AND name=?5",
683 " WHERE operation=?2 AND op_version=?3 AND name=?4",
686 " WHERE operation=?2 AND op_version=?3 AND name=?4",
689 " WHERE operation=?2 AND op_version=?3 AND name=?4",
694 const double min,
const double max)
731 const char *
maker,
const char *
model,
const char *lens)
736 "UPDATE data.presets"
737 " SET maker='%' || ?1 || '%', model=?2, lens=?3"
738 " WHERE operation=?4 AND op_version=?5 AND name=?6",
763#define _PRESET_MATCH_PREDICATE \
764 "((?2 LIKE model AND ?3 LIKE maker) OR (?4 LIKE model AND ?5 LIKE maker))" \
765 " AND ?6 LIKE lens" \
766 " AND ?7 BETWEEN iso_min AND iso_max" \
767 " AND ?8 BETWEEN exposure_min AND exposure_max" \
768 " AND ?9 BETWEEN aperture_min AND aperture_max" \
769 " AND ?10 BETWEEN focal_length_min AND focal_length_max" \
770 " AND (format = 0 OR (format&?11 != 0 AND ~format&?12 != 0))"
834 const int blendop_version,
const int enabled)
840 " INTO data.presets (name, description, operation, op_version, op_params, enabled,"
841 " blendop_params, blendop_version, multi_priority, multi_name,"
842 " model, maker, lens, iso_min, iso_max, exposure_min, exposure_max,"
843 " aperture_min, aperture_max, focal_length_min, focal_length_max,"
844 " writeprotect, autoapply, filter, def, format)"
845 " VALUES (?1, '', ?2, ?3, ?4, ?5, ?6, ?7, 0, '', '%', '%', '%', 0,"
846 " 340282346638528859812000000000000000000, 0, 10000000, 0, 100000000, 0,"
847 " 1000, 1, 0, 0, 0, 0)",
871 "SELECT name, op_params, writeprotect, blendop_params, enabled"
873 " WHERE operation=?1 AND op_version=?2"
874 " ORDER BY writeprotect ASC, LOWER(name), rowid",
886 p->op_version = op_version;
904 "SELECT name, op_params, writeprotect, description, blendop_params, "
905 " op_version, enabled"
907 " WHERE operation=?1"
911 " ORDER BY writeprotect %s, LOWER(name), rowid",
920 "SELECT name, op_params, writeprotect, "
921 " description, blendop_params, op_version, enabled"
923 " WHERE operation=?1"
924 " ORDER BY writeprotect %s, LOWER(name), rowid",
950 "SELECT op_params, enabled, blendop_params, blendop_version, writeprotect"
952 " WHERE operation = ?1 AND op_version = ?2 AND name = ?3",
968 p->op_version = op_version;
993 " WHERE operation = ?1"
996 " AND operation NOT IN"
997 " ('ioporder', 'metadata', 'export', 'tagging', 'collect', 'basecurve'))"
998 " OR (name = ?13)) AND op_version = ?14",
1037 "SELECT rowid, description, model, maker, lens, iso_min, iso_max, "
1038 " exposure_min, exposure_max, aperture_min, aperture_max, focal_length_min, "
1039 " focal_length_max, autoapply, filter, format"
1040 " FROM data.presets"
1041 " WHERE name = ?1 AND operation = ?2 AND op_version = ?3",
1048 gboolean found =
FALSE;
1106 "UPDATE data.presets "
1108 " name=?1, description=?2,"
1109 " model=?3, maker=?4, lens=?5, iso_min=?6, iso_max=?7, exposure_min=?8,"
1110 " exposure_max=?9, aperture_min=?10,"
1111 " aperture_max=?11, focal_length_min=?12, focal_length_max=?13, autoapply=?14,"
1112 " filter=?15, format=?16 "
1123 const char *operation,
const int op_version,
1127 const int blendop_version)
1134 "INSERT INTO data.presets"
1135 " (name, description, "
1136 " model, maker, lens, iso_min, iso_max, exposure_min, exposure_max, aperture_min,"
1137 " aperture_max, focal_length_min, focal_length_max, autoapply,"
1138 " filter, format, def, writeprotect, operation, op_version, op_params, enabled,"
1139 " blendop_params, blendop_version, multi_priority, multi_name) "
1141 " (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, 0, 0, ?17,"
1142 " ?18, ?19, ?20, ?21, ?22, 0, '')",
1165 "SELECT operation, op_version FROM data.presets WHERE rowid = ?1",
1170 gboolean found =
FALSE;
1182 const int op_version,
1186 const int blendop_version)
1191 "UPDATE data.presets"
1192 " SET op_version=?2, op_params=?3, enabled=?4,"
1193 " blendop_params=?5, blendop_version=?6"
1194 " WHERE name=?7 AND operation=?1",
1213 "DELETE FROM data.presets WHERE rowid=?1 AND writeprotect=0",
1224 "DELETE FROM data.presets WHERE writeprotect = 1",
NULL,
NULL,
NULL);
1245 "SELECT rowid, name, operation, autoapply, model, maker, lens, iso_min, "
1246 "iso_max, exposure_min, exposure_max, aperture_min, aperture_max, "
1247 "focal_length_min, focal_length_max, writeprotect FROM data.presets ORDER BY "
1299 "SELECT rowid, name, operation FROM data.presets WHERE writeprotect = 0",
const char ** description(struct dt_iop_module_t *self)
size_t params_size(dt_imageio_module_format_t *self)
static const float const float const float min
sqlite3 * dt_database_get_sqlite3_global(void)
struct dt_iop_tonecurve_params_t preset
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
static float clamp(float f, float m, float M)
gboolean dt_preset_repository_insert(const dt_preset_t *preset)
Insert preset, replacing any row that collides with it.
void dt_preset_repository_delete_module_preset(const char *operation, const int op_version, const char *name)
Delete (operation, op_version, name) unless it is write-protected.
void dt_preset_repository_add_iop_preset(const char *name, const char *operation, const int op_version, const void *params, const int params_size, const void *blend_params, const int blend_params_size, const int blendop_version, const int enabled)
Store an IOP preset, blend parameters included, replacing any of the same name.
void dt_module_preset_free(gpointer data)
Release one dt_module_preset_t. Suits g_list_free_full().
GList * dt_preset_repository_list_all(void)
Every preset, ordered by (operation, name) – the grouping the tree relies on to start a new module no...
GList * dt_preset_repository_list_all_versions(const char *operation)
Every preset of operation at ANY version, with rowid and op_version filled in, SHIPPED FIRST then by ...
static dt_module_preset_t * _iop_row(sqlite3_stmt *stmt, const gboolean with_description)
static gchar * _column_text_or_null(sqlite3_stmt *stmt, const int col)
void dt_preset_row_free(gpointer data)
Free one dt_preset_row_t. Suits g_list_free_full().
static void * _column_blob(sqlite3_stmt *stmt, const int col, int *size)
void dt_preset_repository_update_range(const char *operation, const int op_version, const char *name, const dt_preset_range_t range, const double min, const double max)
Set the <range>_min / <range>_max pair of (operation, op_version, name).
GList * dt_preset_repository_list_for_module(const char *operation, const int op_version, const gboolean with_description, const gboolean shipped_first)
Every preset of (operation, op_version).
void dt_preset_repository_delete_shipped(void)
Delete every write-protected preset – the auto-generated ones, dropped at startup so module code can ...
void dt_preset_repository_cleanup(void)
Finalise the cached statements. See dt_colorlabel_repository_cleanup().
void dt_preset_repository_update_iop_params(const char *operation, const char *name, const int op_version, const void *params, const int params_size, const int enabled, const void *blend_params, const int blend_params_size, const int blendop_version)
Replace the module payload of (operation, name), at any version.
dt_module_preset_t * dt_preset_repository_get_iop_preset(const char *operation, const int op_version, const char *name)
One IOP preset by name, blend parameters included, or NULL.
dt_preset_t * dt_preset_repository_get_by_rowid(const int rowid)
The preset at rowid, or NULL when there is none. Free with dt_preset_free().
dt_module_preset_t * dt_preset_repository_get_module_preset(const char *operation, const int op_version, const char *name)
One preset by name, or NULL. Free with dt_module_preset_free().
void dt_preset_repository_update_conditions(const int rowid, const dt_preset_conditions_t *c)
Overwrite the conditions of the row at rowid.
GList * dt_preset_repository_list_for_menu(const char *operation, const dt_preset_match_t *match, const gboolean shipped_first)
Presets of operation to offer in a menu, in display order.
GList * dt_preset_repository_list_editable(void)
Every preset the user may edit (writeprotect = 0), in row order.
void dt_preset_repository_update_params_by_rowid(const int rowid, const int op_version, const void *params, const int params_size)
Replace the parameters of one row, by rowid.
GList * dt_preset_repository_list_for_upgrade(const char *operation)
Every preset of operation at any version, with both parameter blobs.
int dt_preset_repository_find_rowid(const char *operation, const int op_version, const char *name)
rowid of (operation, op_version, name), or -1.
static gchar * _column_text(sqlite3_stmt *stmt, const int col)
void dt_preset_repository_update_camera(const char *operation, const int op_version, const char *name, const char *maker, const char *model, const char *lens)
Set the camera match of (operation, op_version, name).
void dt_preset_repository_update_module_params(const char *operation, const char *name, const int op_version, const void *params, const int params_size)
Replace the parameters (and version) of (operation, name).
static const char *const _flag_query[DT_PRESET_FLAG_LAST]
void dt_preset_identity_free(gpointer data)
Free one dt_preset_identity_t. Suits g_list_free_full().
void dt_preset_repository_add_module_preset(const char *name, const char *operation, const int op_version, const void *params, const int params_size)
Create an empty user preset holding params, as the "new preset" menu item does.
GList * dt_preset_repository_list_for_version(const char *operation, const int op_version)
As above, restricted to one op_version. Same columns, same order.
void dt_preset_repository_delete_by_rowid(const int rowid)
Delete one row by rowid.
gboolean dt_preset_repository_get_conditions(const char *operation, const int op_version, const char *name, dt_preset_conditions_t *c, int *rowid)
Read the conditions of (operation, op_version, name).
static void _bind_conditions(sqlite3_stmt *stmt, const dt_preset_conditions_t *c)
static void _bind_text(sqlite3_stmt *stmt, const int idx, const char *value)
void dt_preset_repository_delete_all_for_module(const char *operation)
Delete every preset of operation, whatever its version or protection.
void dt_preset_free(dt_preset_t *preset)
Release a dt_preset_t and everything it owns. NULL-safe.
gboolean dt_preset_repository_module_preset_exists(const char *operation, const int op_version, const char *name)
TRUE when (operation, op_version, name) exists.
GList * dt_preset_repository_list_for_iop(const char *operation, const int op_version)
Every preset of (operation, op_version), with blend parameters.
void dt_preset_repository_rename_module_preset(const char *operation, const int op_version, const char *old_name, const char *new_name, const char *description, const void *params, const int params_size)
Replace name, description and parameters of (operation, op_version, old_name).
void dt_preset_repository_set_module_version(const char *operation, const char *name, const int op_version)
Set ONLY the version of (operation, name), leaving the parameters alone.
void dt_preset_repository_set_blend_params(const char *operation, const char *name, const int blendop_version, const void *blend_params, const int blend_params_size)
Replace the blend parameters (and blend version) of (operation, name), at any version....
void dt_preset_repository_delete_by_rowid_unprotected(const int rowid)
Delete the row at rowid unless it is write-protected.
void dt_preset_conditions_free(dt_preset_conditions_t *c)
Release the strings owned by c (not c itself).
gboolean dt_preset_repository_get_identity(const int rowid, gchar **operation, int *op_version)
The (operation, op_version) a rowid belongs to. Returns FALSE if there is none; *operation is newly a...
void dt_preset_repository_add_shipped_preset(const char *name, const char *operation, const int op_version, const void *params, const int params_size, const int writeprotect)
Create a preset from code rather than from the menu – the built-in presets a module registers at star...
void dt_preset_repository_update_flag(const char *operation, const int op_version, const char *name, const dt_preset_flag_t flag, const int value)
Set one integer condition of (operation, op_version, name).
static const char *const _range_query[DT_PRESET_RANGE_LAST]
void dt_preset_repository_insert_with_conditions(const dt_preset_conditions_t *c, const char *operation, const int op_version, const void *params, const int params_size, const int enabled, const void *blend_params, const int blend_params_size, const int blendop_version)
Create a preset from a full condition set plus its module payload.
void dt_preset_repository_duplicate_module_preset(const char *operation, const int op_version, const char *name, const char *new_name)
Copy (operation, op_version, name) to new_name, unprotected.
GList * dt_preset_repository_find_autoapply(const char *operation, const int op_version, const dt_preset_match_t *match, const char *always_name)
Names of the presets that should be applied to this image automatically.
#define _PRESET_MATCH_PREDICATE
static void _bind_match(sqlite3_stmt *stmt, const dt_preset_match_t *m, const gboolean clamp)
data.presets: a module's saved parameters, with the conditions under which it auto-applies.
@ DT_PRESET_FLAG_AUTOAPPLY
@ DT_PRESET_RANGE_FOCAL_LENGTH
@ DT_PRESET_RANGE_APERTURE
@ DT_PRESET_RANGE_EXPOSURE
void copy(TYPE *dest, TYPE *source, size_t num_el)
Copy a flat buffer used to initialize test matrices.
static const dt_aligned_pixel_simd_t value
Checked wrappers around the sqlite3_* calls: trace the statement, assert the return code,...
#define DT_DEBUG_SQLITE3_EXEC(a, b, c, d, e)
#define DT_DEBUG_SQLITE3_BIND_BLOB(a, b, c, d, e)
#define DT_DEBUG_SQLITE3_PREPARE_V2(a, b, c, d, e)
#define DT_DEBUG_SQLITE3_BIND_TEXT(a, b, c, d, e)
#define DT_DEBUG_SQLITE3_BIND_INT(a, b, c)
#define DT_DEBUG_SQLITE3_BIND_DOUBLE(a, b, c)
Identity of one preset, for callers listing rather than loading.
The facts about one image that decide whether a preset matches it.
One row of the Preferences preset tree, with its auto-apply conditions.
One row of data.presets, owned by the caller.