void dt_dev_reprocess_center(dt_develop_t *dev) { if(darktable.gui->reset) return; if(dev && dev->gui_attached) { dev->pipe->changed |= DT_DEV_PIPE_SYNCH; dev->pipe->cache_obsolete = 1; dt_similarity_image_dirty(dev->image_storage.id); // invalidate buffers and force redraw of darkroom dt_dev_invalidate_all(dev); /* redraw */ dt_control_queue_redraw_center(); } }
void dt_dev_add_history_item(dt_develop_t *dev, dt_iop_module_t *module, gboolean enable) { if(darktable.gui->reset) return; dt_pthread_mutex_lock(&dev->history_mutex); if(dev->gui_attached) { GList *history = g_list_nth (dev->history, dev->history_end); while(history) { GList *next = g_list_next(history); dt_dev_history_item_t *hist = (dt_dev_history_item_t *)(history->data); // printf("removing obsoleted history item: %s\n", hist->module->op); free(hist->params); free(hist->blend_params); free(history->data); dev->history = g_list_delete_link(dev->history, history); history = next; } history = g_list_nth(dev->history, dev->history_end-1); if(!history || module->instance != ((dt_dev_history_item_t *)history->data)->module->instance) { // new operation, push new item // printf("adding new history item %d - %s\n", dev->history_end, module->op); // if(history) printf("because item %d - %s is different operation.\n", dev->history_end-1, ((dt_dev_history_item_t *)history->data)->module->op); dev->history_end++; dt_dev_history_item_t *hist = (dt_dev_history_item_t *)malloc(sizeof(dt_dev_history_item_t)); if (enable) { module->enabled = TRUE; if(module->off) { darktable.gui->reset = 1; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(module->off), module->enabled); darktable.gui->reset = 0; } } hist->enabled = module->enabled; hist->module = module; hist->params = malloc(module->params_size); /* allocate and set hist blend_params */ hist->blend_params = malloc(sizeof(dt_develop_blend_params_t)); memset(hist->blend_params, 0, sizeof(dt_develop_blend_params_t)); memcpy(hist->params, module->params, module->params_size); if(module->flags() & IOP_FLAGS_SUPPORTS_BLENDING) memcpy(hist->blend_params, module->blend_params, sizeof(dt_develop_blend_params_t)); dev->history = g_list_append(dev->history, hist); dev->pipe->changed |= DT_DEV_PIPE_SYNCH; dev->preview_pipe->changed |= DT_DEV_PIPE_SYNCH; // topology remains, as modules are fixed for now. } else { // same operation, change params // printf("changing same history item %d - %s\n", dev->history_end-1, module->op); dt_dev_history_item_t *hist = (dt_dev_history_item_t *)history->data; memcpy(hist->params, module->params, module->params_size); if(module->flags() & IOP_FLAGS_SUPPORTS_BLENDING) memcpy(hist->blend_params, module->blend_params, sizeof(dt_develop_blend_params_t)); // if the user changed stuff and the module is still not enabled, do it: if(!hist->enabled && !module->enabled) { module->enabled = 1; if(module->off) { darktable.gui->reset = 1; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(module->off), module->enabled); darktable.gui->reset = 0; } } hist->enabled = module->enabled; dev->pipe->changed |= DT_DEV_PIPE_TOP_CHANGED; dev->preview_pipe->changed |= DT_DEV_PIPE_TOP_CHANGED; } } #if 0 { // debug: printf("remaining %d history items:\n", dev->history_end); GList *history = dev->history; int i = 0; while(history) { dt_dev_history_item_t *hist = (dt_dev_history_item_t *)(history->data); printf("%d %s\n", i, hist->module->op); history = g_list_next(history); i++; } } #endif /* invalidate image data*/ dt_similarity_image_dirty(dev->image_storage.id); // invalidate buffers and force redraw of darkroom dt_dev_invalidate_all(dev); dt_pthread_mutex_unlock(&dev->history_mutex); if(dev->gui_attached) { /* signal that history has changed */ dt_control_signal_raise(darktable.signals, DT_SIGNAL_DEVELOP_HISTORY_CHANGE); /* redraw */ dt_control_queue_redraw_center(); } }