Update of /cvsroot/ufraw/ufraw
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv3923
Modified Files:
Doxyfile uf_gtk.cc uf_gtk.h ufobject.cc ufobject.h ufraw.h
ufraw_lens_ui.c ufraw_lensfun.cc ufraw_preview.c
ufraw_settings.cc ufraw_ufraw.c ufraw_ui.h
Log Message:
Add ufFocalLength, ufAperture, ufDistance UFObjects.
Index: Doxyfile
===================================================================
RCS file: /cvsroot/ufraw/ufraw/Doxyfile,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Doxyfile 27 Jan 2010 21:23:22 -0000 1.1
+++ Doxyfile 26 Feb 2010 07:01:04 -0000 1.2
@@ -568,7 +568,7 @@
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
-INPUT = ufobject.h ufraw.h uf_gtk.h ufraw_settings.cc
+INPUT = ufobject.h ufraw.h uf_gtk.h ufraw_settings.cc
ufraw_lensfun.cc
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
@@ -1257,7 +1257,7 @@
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.
-PREDEFINED = __cplusplus
+PREDEFINED = __cplusplus HAVE_LENSFUN
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be
expanded.
Index: ufobject.cc
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufobject.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ufobject.cc 24 Feb 2010 00:24:15 -0000 1.5
+++ ufobject.cc 26 Feb 2010 07:01:04 -0000 1.6
@@ -199,18 +199,17 @@
public:
double Number;
double Default;
- _UFNumber(UFName name, double number, double minimum, double maximum,
- double defaultValue, int accuracyDigits,
- double step, double jump) :
+ _UFNumber(UFName name, double defaultValue, double minimum, double maximum,
+ int accuracyDigits, double step, double jump) :
_UFNumberCommon(name, minimum, maximum, accuracyDigits, step, jump),
- Number(number), Default(defaultValue) { }
+ Number(defaultValue), Default(defaultValue) { }
};
#define ufnumber (static_cast<_UFNumber *>(ufobject))
UFNumber::UFNumber(UFName name, double minimum, double maximum,
double defaultValue, int accuracyDigits, double step, double jump) :
- UFObject(new _UFNumber(name, defaultValue, minimum, maximum, defaultValue,
+ UFObject(new _UFNumber(name, defaultValue, minimum, maximum,
accuracyDigits, step, jump)) { }
const char *UFNumber::StringValue() const {
@@ -614,6 +613,14 @@
const char *indent, const char *attribute) {
if (group.IsDefault())
return "";
+ if (strcmp(attribute, "Index") == 0 && // If object is a UFArray and
+ group.UFGroup::IsDefault()) { // all the array elements are default
+ // Just print the value in a simple format.
+ char *value = g_markup_escape_text(group.StringValue(), -1);
+ std::string xml = (std::string)indent + "<" + group.Name() + ">" +
+ value + "</" + group.Name() + ">\n";
+ return xml;
+ }
std::string xml = "";
// For now, we don't want to surround the root XML with <[/]Image> tags.
if (strlen(indent) != 0) {
@@ -728,7 +735,6 @@
}
}
_UFGROUP_PARENT(object) = ufgroup;
- ufgroup->CallValueChangedEvent(this);
return *this;
}
@@ -749,6 +755,16 @@
return *dropObject;
}
+void UFGroup::Clear() {
+ for (_UFGroupMap::iterator iter = ufgroup->Map.begin();
+ iter != ufgroup->Map.end(); iter++) {
+ _UFGROUP_PARENT(iter->second) = NULL;
+ delete iter->second;
+ }
+ ufgroup->Map.clear();
+ ufgroup->List.clear();
+}
+
// object is a <UFObject *> and generally not a <UFArray *>.
// The cast to <UFArray *> is needed for accessing ufobject.
#define _UFARRAY_PARENT(object) static_cast<UFArray
*>(object)->ufobject->Parent
@@ -816,16 +832,12 @@
}
bool UFArray::SetIndex(int index) {
- if (ufgroup->Index == index)
- return true;
- ufgroup->Index = index;
_UFGroupList::iterator iter = ufgroup->List.begin();
std::advance(iter, index);
if (iter == ufgroup->List.end())
return false;
- g_free(ufgroup->String);
- ufgroup->String = g_strdup((*iter)->StringValue());
- ufgroup->CallValueChangedEvent(this);
+ ufgroup->Index = index;
+ Set((*iter)->StringValue());
return true;
}
@@ -864,7 +876,6 @@
}
}
_UFARRAY_PARENT(object) = ufgroup;
- ufgroup->CallValueChangedEvent(this);
return *this;
}
Index: uf_gtk.cc
===================================================================
RCS file: /cvsroot/ufraw/ufraw/uf_gtk.cc,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- uf_gtk.cc 22 Feb 2010 23:27:20 -0000 1.19
+++ uf_gtk.cc 26 Feb 2010 07:01:04 -0000 1.20
@@ -417,9 +417,14 @@
gtk_combo_box_set_active(combo, array.Index());
return;
}
- // If value not found activate first entry
- g_warning("_ufarray_object_event() value not found");
- gtk_combo_box_set_active(combo, 0);
+ if (GTK_IS_COMBO_BOX_ENTRY(combo)) {
+ GtkWidget *entry = gtk_bin_get_child(GTK_BIN(combo));
+ gtk_entry_set_text(GTK_ENTRY(entry), array.StringValue());
+ } else { // GTK_IS_COMBO_BOX()
+ // If value not found activate first entry
+ g_warning("_ufarray_object_event() value not found");
+ gtk_combo_box_set_active(combo, 0);
+ }
}
/* Return the widget-data for the object.
@@ -565,25 +570,47 @@
_ufobject_reset_button_state(object);
}
-// Create a new ComboBox text with small width.
-// The widget must be added with GTK_EXPAND|GTK_FILL.
-GtkWidget *ufarray_combo_box_new(UFObject *object) {
+static void _ufarray_entry_changed(GtkWidget *entry, UFObject *object) {
+ UFArray &array = *object;
+ array.Set(gtk_entry_get_text(GTK_ENTRY(entry)));
+ _ufobject_reset_button_state(object);
+}
+
+GtkWidget *_ufarray_combo_box_new(UFObject *object, GtkWidget *combo) {
UFArray &array = *object;
_UFWidgetData &data = _ufarray_widget_data(array);
- GtkWidget *combo = gtk_combo_box_new_text();
gtk_widget_set_size_request(combo, 50, -1);
data.gobject[0] = G_OBJECT(combo);
- g_signal_connect_after(G_OBJECT(combo), "changed",
- G_CALLBACK(_ufarray_combo_changed), object);
- int saveIndex = array.Index();
+ char *saveIndex = g_strdup(array.StringValue());
int i = 0;
while (array.SetIndex(i)) {
gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _(array.StringValue()));
i++;
}
- array.SetIndex(saveIndex);
+ array.Set(saveIndex);
+ g_free(saveIndex);
_ufarray_object_event(object, uf_value_changed);
+ gtk_widget_set_sensitive(combo, i > 0);
return combo;
}
+// Create a new ComboBox with small width.
+// The widget must be added with GTK_EXPAND|GTK_FILL.
+GtkWidget *ufarray_combo_box_new(UFObject *object) {
+ GtkWidget *combo = gtk_combo_box_new_text();
+ g_signal_connect_after(G_OBJECT(combo), "changed",
+ G_CALLBACK(_ufarray_combo_changed), object);
+ return _ufarray_combo_box_new(object, combo);
+}
+
+// Create a new ComboBoxEntry with small width.
+// The widget must be added with GTK_EXPAND|GTK_FILL.
+GtkWidget *ufarray_combo_box_entry_new(UFObject *object) {
+ GtkWidget *combo = gtk_combo_box_entry_new_text();
+ GtkWidget *entry = gtk_bin_get_child(GTK_BIN(combo));
+ g_signal_connect_after(G_OBJECT(entry), "changed",
+ G_CALLBACK(_ufarray_entry_changed), object);
+ return _ufarray_combo_box_new(object, combo);
+}
+
} // extern "C"
Index: uf_gtk.h
===================================================================
RCS file: /cvsroot/ufraw/ufraw/uf_gtk.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- uf_gtk.h 21 Feb 2010 10:03:55 -0000 1.10
+++ uf_gtk.h 26 Feb 2010 07:01:04 -0000 1.11
@@ -68,6 +68,7 @@
void ufobject_reset_button_add(GtkWidget *button, UFObject *object);
GtkWidget *ufstring_combo_box_new(UFObject *object);
GtkWidget *ufarray_combo_box_new(UFObject *object);
+GtkWidget *ufarray_combo_box_entry_new(UFObject *object);
#ifdef __cplusplus
}
Index: ufraw_settings.cc
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw_settings.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ufraw_settings.cc 23 Feb 2010 19:36:43 -0000 1.7
+++ ufraw_settings.cc 26 Feb 2010 07:01:04 -0000 1.8
@@ -213,13 +213,6 @@
}
};
-#ifdef HAVE_LENSFUN
-class Lensfun : public UFGroup {
-public:
- Lensfun();
-};
-#endif
-
// ufRawImage is short for 'raw image processing parameters'.
extern "C" { UFName ufRawImage = "Image"; }
Image::Image(UFObject *root) : UFGroup(ufRawImage), uf(NULL) {
@@ -232,7 +225,7 @@
;
#ifdef HAVE_LENSFUN
if (root == NULL || root->Name() != ufRawResources)
- *this << new Lensfun; // Lensfun data is not saved to .ufrawrc
+ *this << ufraw_lensfun_new(); // Lensfun data is not saved to .ufrawrc
#else
(void)root;
#endif
Index: ufraw_lens_ui.c
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw_lens_ui.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- ufraw_lens_ui.c 22 Feb 2010 01:07:23 -0000 1.34
+++ ufraw_lens_ui.c 26 Feb 2010 07:01:04 -0000 1.35
@@ -15,9 +15,7 @@
#include "uf_gtk.h"
#include "ufraw_ui.h"
#include <glib/gi18n.h>
-#include <string.h>
#include <ctype.h>
-#include <math.h>
#ifdef HAVE_LENSFUN
@@ -27,82 +25,6 @@
gtk_widget_destroy(widget);
}
-/**
- * Add a labeled GtkComboBoxEntry to a table or to a box.
- */
-static GtkComboBoxEntry *combo_entry_text(GtkWidget *container,
- guint x, guint y, gchar *lbl, gchar *tip)
-{
- GtkWidget *label = gtk_label_new(lbl);
- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- if (GTK_IS_TABLE(container))
- gtk_table_attach(GTK_TABLE(container), label, x, x + 1, y, y + 1,
- 0, 0, 2, 0);
- else if (GTK_IS_BOX(container))
- gtk_box_pack_start(GTK_BOX(container), label, FALSE, FALSE, 2);
- uf_widget_set_tooltip(label, tip);
-
- GtkWidget *combo = gtk_combo_box_entry_new_text();
- if (GTK_IS_TABLE(container))
- gtk_table_attach(GTK_TABLE(container), combo, x+1, x+2, y, y+1,
- 0, 0, 2, 0);
- else if (GTK_IS_BOX(container))
- gtk_box_pack_start(GTK_BOX(container), combo, FALSE, FALSE, 2);
- uf_widget_set_tooltip(combo, tip);
-
- return GTK_COMBO_BOX_ENTRY(combo);
-}
-
-/* simple function to compute the floating-point precision
- which is enough for "normal use". The criteria is to have
- 2 or 3 significant digits. */
-static int precision(double x)
-{
- if (x > 10.0 && (int)(10*x)%10 != 0)
- // Support focal length such as 10.5mm fisheye.
- return MAX(-floor(log(x) / log(10) - 1.99), 0);
- else
- return MAX(-floor(log(x) / log(10) - 0.99), 0);
-}
-
-static GtkComboBoxEntry *combo_entry_numeric(GtkWidget *container,
- guint x, guint y, gchar *lbl, gchar *tip,
- gdouble val, gdouble *values, int nvalues)
-{
- int i;
- char txt[30];
- GtkComboBoxEntry *combo = combo_entry_text(container, x, y, lbl, tip);
- GtkEntry *entry = GTK_ENTRY(GTK_BIN(combo)->child);
-
- gtk_entry_set_width_chars(entry, 4);
-
- snprintf(txt, sizeof(txt), "%.*f", precision(val), val);
- gtk_entry_set_text(entry, txt);
-
- for (i = 0; i < nvalues; i++) {
- gdouble v = values[i];
- snprintf(txt, sizeof(txt), "%.*f", precision(v), v);
- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), txt);
- }
- return combo;
-}
-
-static GtkComboBoxEntry *combo_entry_numeric_log(GtkWidget *container,
- guint x, guint y, gchar *lbl, gchar *tip,
- gdouble val, gdouble min, gdouble max, gdouble step)
-{
- int i, nvalues = (int)ceil(log(max/min) / log(step)) + 1;
- gdouble *values = g_new(gdouble, nvalues);
- values[0] = min;
- for (i=1; i < nvalues; i++)
- values[i] = values[i-1] * step;
-
- GtkComboBoxEntry *combo = combo_entry_numeric(container, x, y,
- lbl, tip, val, values, nvalues);
- g_free(values);
- return combo;
-}
-
static void camera_set(preview_data *data)
{
const char *maker = lf_mlstr_get(CFG->camera->Maker);
@@ -257,47 +179,21 @@
CFG->cur_lens_type);
}
-void ufraw_lensfun_interpolate(UFObject *lensfun, const lfLens *lens);
-
-static void lens_interpolate(preview_data *data, const lfLens *lens)
-{
- /* Interpolate all models and set the temp values accordingly */
- UFObject *lensfun = ufgroup_element(CFG->ufobject, ufLensfun);
- ufraw_lensfun_interpolate(lensfun, lens);
- lens_update_controls(data);
-}
-
-static void lens_combo_entry_update(GtkComboBox *widget, float *valuep)
+static void combo_entry_new(UFObject *object, GtkWidget *box,
+ const char *labelText, const char *tooltip)
{
- preview_data *data = get_preview_data(widget);
- char *text = gtk_combo_box_get_active_text(widget);
- if (sscanf(text, "%f", valuep) == 1)
- lens_interpolate(data, CFG->lens);
- g_free(text);
+ GtkWidget *label = gtk_label_new(labelText);
+ gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 2);
+ GtkWidget *combo = ufarray_combo_box_entry_new(object);
+ gtk_box_pack_start(GTK_BOX(box), combo, TRUE, TRUE, 2);
+ uf_widget_set_tooltip(label, tooltip);
}
-static void lens_set(preview_data *data, const lfLens *lens)
+static void lens_set(preview_data *data)
{
gchar *fm;
- GtkComboBoxEntry *combo;
- unsigned i;
- static gdouble focal_values[] = {
- 4.5, 8, 10, 12, 14, 15, 16, 17, 18, 20, 24, 28, 30, 31, 35, 38, 40, 43,
- 45, 50, 55, 60, 70, 75, 77, 80, 85, 90, 100, 105, 110, 120, 135,
- 150, 200, 210, 240, 250, 300, 400, 500, 600, 800, 1000
- };
- static gdouble aperture_values[] = {
- 1, 1.2, 1.4, 1.7, 2, 2.4, 2.8, 3.4, 4, 4.8, 5.6, 6.7,
- 8, 9.5, 11, 13, 16, 19, 22, 27, 32, 38, 45
- };
-
- if (lens == NULL) {
- gtk_entry_set_text(GTK_ENTRY(data->LensModel), "");
- uf_widget_set_tooltip(data->LensModel, NULL);
- return;
- }
- if (CFG->lens != lens)
- lf_lens_copy(CFG->lens, lens);
+ lfLens *lens = CFG->lens;
const char *maker = lf_mlstr_get(lens->Maker);
const char *model = lf_mlstr_get(lens->Model);
@@ -324,14 +220,15 @@
else
snprintf(aperture, sizeof(aperture), "%g", lens->MinAperture);
- mounts[0] = 0;
- if (lens->Mounts != NULL)
+ if (lens->Mounts != NULL) {
+ mounts[0] = 0;
+ unsigned i;
for (i = 0; lens->Mounts[i] != NULL; i++) {
if (i > 0)
g_strlcat(mounts, ", ", sizeof(mounts));
g_strlcat(mounts, lens->Mounts[i], sizeof(mounts));
}
-
+ }
fm = g_strdup_printf(_("Maker:\t\t%s\n"
"Model:\t\t%s\n"
"Focal range:\t%s\n"
@@ -348,51 +245,32 @@
/* Create the focal/aperture/distance combo boxes */
gtk_container_foreach(GTK_CONTAINER(data->LensParamBox),
delete_children, NULL);
+ UFObject *lensfun = ufgroup_element(CFG->ufobject, ufLensfun);
- int ffi = 0, fli = -1;
- for (i = 0; i < sizeof(focal_values) / sizeof(gdouble); i++) {
- if (focal_values[i] < lens->MinFocal)
- ffi = i + 1;
- if (focal_values[i] > lens->MaxFocal && fli == -1)
- fli = i;
- }
- if (lens->MaxFocal == 0 || fli < 0)
- fli = sizeof(focal_values) / sizeof(gdouble);
- if (fli < ffi)
- fli = ffi + 1;
- combo = combo_entry_numeric(data->LensParamBox, 0, 0,
- _("Focal"), _("Focal length"),
- CFG->focal_len, focal_values + ffi, fli - ffi);
- g_signal_connect(G_OBJECT(combo), "changed",
- G_CALLBACK(lens_combo_entry_update), &CFG->focal_len);
-
- ffi = 0;
- for (i = 0; i < sizeof(aperture_values) / sizeof(gdouble); i++)
- if (aperture_values[i] < lens->MinAperture)
- ffi = i + 1;
- combo = combo_entry_numeric(data->LensParamBox, 0, 0,
- _("F"), _("F-number (Aperture)"),
- CFG->aperture, aperture_values + ffi,
- sizeof(aperture_values) / sizeof(gdouble) - ffi);
- g_signal_connect(G_OBJECT(combo), "changed",
- G_CALLBACK(lens_combo_entry_update), &CFG->aperture);
-
- combo = combo_entry_numeric_log(data->LensParamBox, 0, 0,
- _("Distance"), _("Distance to subject"),
- CFG->subject_distance, 0.25, 1000, sqrt(2));
- g_signal_connect(G_OBJECT(combo), "changed",
- G_CALLBACK(lens_combo_entry_update), &CFG->subject_distance);
+ UFObject *FocalLength = ufgroup_element(lensfun, ufFocalLength);
+ combo_entry_new(FocalLength, data->LensParamBox,
+ _("Focal"), _("Focal length"));
+ UFObject *Aperture = ufgroup_element(lensfun, ufAperture);
+ combo_entry_new(Aperture, data->LensParamBox,
+ _("F"), _("F-number (Aperture)"));
+ UFObject *Distance = ufgroup_element(lensfun, ufDistance);
+ combo_entry_new(Distance, data->LensParamBox,
+ _("Distance"), _("Distance to subject in meters"));
gtk_widget_show_all(data->LensParamBox);
CFG->cur_lens_type = LF_UNKNOWN;
}
+void ufraw_lensfun_interpolate(UFObject *lensfun, const lfLens *lens);
+
static void lens_menu_select(GtkMenuItem *menuitem, preview_data *data)
{
lfLens *lens = (lfLens *)g_object_get_data(G_OBJECT(menuitem), "lfLens");
- lens_set(data, lens);
- lens_interpolate(data, lens);
+ UFObject *lensfun = ufgroup_element(CFG->ufobject, ufLensfun);
+ ufraw_lensfun_interpolate(lensfun, lens);
+ lens_set(data);
+ lens_update_controls(data);
}
static void lens_menu_fill(preview_data *data, const lfLens *const *lenslist)
@@ -693,7 +571,6 @@
gtk_label_set_text(GTK_LABEL(data->LensFromGeometryDesc), details);
ufraw_invalidate_layer(data->UF, ufraw_transform_phase);
- resize_canvas(data);
render_preview(data);
}
@@ -767,14 +644,6 @@
G_CALLBACK(geometry_model_changed), data);
}
-static void ufraw_lensfun_changed(UFObject *obj, UFEventType type)
-{
- if (type != uf_value_changed)
- return;
- preview_data *data = ufobject_user_data(obj);
- resize_canvas(data);
-}
-
/**
* Fill the "lens correction" page in the main notebook.
*/
@@ -782,11 +651,6 @@
{
GtkWidget *label, *button, *subpage;
- UFObject *image = CFG->ufobject;
- UFObject *lensfun = ufgroup_element(image, ufLensfun);
- ufobject_set_user_data(lensfun, data);
- ufobject_set_changed_event_handle(lensfun, ufraw_lensfun_changed);
-
/* Camera selector */
GtkTable *table = GTK_TABLE(gtk_table_new(10, 10, FALSE));
gtk_box_pack_start(GTK_BOX(page), GTK_WIDGET(table), FALSE, FALSE, 0);
@@ -840,7 +704,7 @@
/* Create a default lens & camera */
camera_set(data);
- lens_set(data, CFG->lens);
+ lens_set(data);
subpage = notebook_page_new(subnb,
_("Lateral chromatic aberration"), "tca");
Index: ufraw_preview.c
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw_preview.c,v
retrieving revision 1.344
retrieving revision 1.345
diff -u -d -r1.344 -r1.345
--- ufraw_preview.c 24 Feb 2010 18:00:19 -0000 1.344
+++ ufraw_preview.c 26 Feb 2010 07:01:04 -0000 1.345
@@ -874,6 +874,8 @@
render_status_text(data);
}
+void resize_canvas(preview_data *data);
+
static gboolean render_preview_now(preview_data *data)
{
if (data->FreezeDialog)
@@ -883,6 +885,9 @@
;
data->RenderSubArea = 0;
+ if (data->UF->Images[ufraw_transform_phase].invalidate_event)
+ resize_canvas(data);
+
if (CFG->autoExposure == apply_state) {
ufraw_invalidate_layer(data->UF, ufraw_develop_phase);
ufraw_auto_expose(data->UF);
@@ -3103,7 +3108,6 @@
CFG->orientation != CFG->CameraOrientation);
ufraw_invalidate_layer(data->UF, ufraw_transform_phase);
- resize_canvas(data);
render_preview(data);
}
Index: ufraw.h
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw.h,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -d -r1.151 -r1.152
--- ufraw.h 22 Feb 2010 23:27:20 -0000 1.151
+++ ufraw.h 26 Feb 2010 07:01:04 -0000 1.152
@@ -66,6 +66,9 @@
extern UFName ufGreen;
extern UFName ufChannelMultipliers;
extern UFName ufLensfun;
+extern UFName ufFocalLength;
+extern UFName ufAperture;
+extern UFName ufDistance;
extern UFName ufTCA;
extern UFName ufVignetting;
extern UFName ufDistortion;
@@ -79,6 +82,9 @@
#endif // __cplusplus
UFObject *ufraw_image_new();
+#ifdef HAVE_LENSFUN
+UFObject *ufraw_lensfun_new();
+#endif
struct ufraw_struct *ufraw_image_get_data(UFObject *obj);
void ufraw_image_set_data(UFObject *obj, struct ufraw_struct *uf);
UFObject *ufraw_resources_new();
Index: ufraw_ufraw.c
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw_ufraw.c,v
retrieving revision 1.245
retrieving revision 1.246
diff -u -d -r1.245 -r1.246
--- ufraw_ufraw.c 24 Feb 2010 17:44:27 -0000 1.245
+++ ufraw_ufraw.c 26 Feb 2010 07:01:04 -0000 1.246
@@ -697,7 +697,6 @@
g_free(uf->displayProfile);
g_free(uf->RawHistogram);
#ifdef HAVE_LENSFUN
- lf_lens_destroy(uf->conf->lens);
lf_modifier_destroy(uf->TCAmodifier);
lf_camera_destroy(uf->conf->camera);
lf_modifier_destroy(uf->modifier);
Index: ufobject.h
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufobject.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ufobject.h 22 Feb 2010 23:27:20 -0000 1.3
+++ ufobject.h 26 Feb 2010 07:01:04 -0000 1.4
@@ -335,7 +335,14 @@
virtual UFGroup &operator<<(UFObject *object);
/// Drop an object from the group. The dropped object is returned.
/// If it is not needed any more it should be deleted to free its memory.
+ /// \exception UFException is thrown if an element with the given name
+ /// does not exist. This can be avoided with the use of the Has() method.
+ /// For UFArray, the index does not get updated.
UFObject &Drop(UFName name);
+ /// Remove all elements from the group.
+ /// The removed elements are deleted from memory.
+ /// For UFArray, the index does not get updated.
+ void Clear();
};
/**
Index: ufraw_lensfun.cc
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw_lensfun.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ufraw_lensfun.cc 24 Feb 2010 00:24:15 -0000 1.2
+++ ufraw_lensfun.cc 26 Feb 2010 07:01:04 -0000 1.3
@@ -18,26 +18,159 @@
#include <glib/gi18n.h>
#include <string.h>
#include <assert.h>
+#include <math.h>
#ifdef HAVE_LENSFUN
namespace UFRaw {
class Lensfun : public UFGroup {
private:
- static lfDatabase *GlobalLensDB;
+ static lfDatabase *LensDB;
public:
+ lfLens Transformation;
+ lfLens Interpolation;
+ double FocalLengthValue;
+ double ApertureValue;
+ double DistanceValue;
Lensfun();
#if 0 // Can be useful for valgrind --leak-check=full
~Lensfun() {
- if (GlobalLensDB != NULL)
- lf_db_destroy(GlobalLensDB);
- GlobalLensDB = NULL;
+ if (LensDB != NULL)
+ lf_db_destroy(LensDB);
+ LensDB = NULL;
}
#endif
- void Interpolate(const lfLens *lens);
+ static Lensfun &Parent(UFObject &object) {
+ if (strcmp(object.Parent().Name(), ufLensfun) == 0)
+ return static_cast<Lensfun &>(object.Parent());
+ return Lensfun::Parent(object.Parent());
+ }
+ void Interpolate();
void Init();
};
+#define _buffer_size 80
+
+char *_StringNumber(char *buffer, double number) {
+/* int precision = 0;
+ while (floor(number * pow(10, precision))*10 <
+ floor(number * pow(10, precision+1)))
+ precision++;*/
+ // Compute the floating-point precision which is enough for "normal use".
+ // The criteria is to have 2 or 3 significant digits.
+ int precision;
+ if (number > 10.0 && (int)(10*number)%10 != 0)
+ // Support focal length such as 10.5mm fisheye.
+ precision = MAX(-floor(log(number) / log(10) - 1.99), 0);
+ else
+ precision = MAX(-floor(log(number) / log(10) - 0.99), 0);
+ snprintf(buffer, _buffer_size, "%.*f", precision, number);
+ return buffer;
+}
+
+extern "C" { UFName ufFocalLength = "FocalLength"; }
+class FocalLength : public UFArray {
+public:
+ FocalLength() : UFArray(ufFocalLength) { }
+ void OriginalValueChangedEvent() {
+ if (!HasParent())
+ return;
+ double value;
+ if (sscanf(StringValue(), "%lf", &value) != 1)
+ return;
+ Lensfun::Parent(*this).FocalLengthValue = value;
+ Lensfun::Parent(*this).Interpolate();
+ }
+ void CreatePresets() {
+ if (!HasParent())
+ return;
+ Clear();
+ lfLens &lens = Lensfun::Parent(*this).Interpolation;
+
+ static double focalValues[] = { 4, 5, 6, 7, 8, 10, 12, 14, 17, 21, 24,
+ 28, 35, 43, 50, 70, 85, 105, 135, 200, 300, 400, 600, 800, 0 };
+ char buffer[_buffer_size];
+ double min = lens.MinFocal, max = lens.MaxFocal;
+ if (min > 0)
+ *this << new UFString(ufPreset, _StringNumber(buffer, min));
+ int i = 0;
+ while (focalValues[i] < min && focalValues[i] != 0)
+ i++;
+ if (Has(_StringNumber(buffer, focalValues[i])))
+ i++; // Comparing string works better than comparing doubles.
+ while (focalValues[i] < max && focalValues[i] != 0) {
+ *this << new UFString(ufPreset, _StringNumber(buffer,
+ focalValues[i]));
+ i++;
+ }
+ if (max > min)
+ *this << new UFString(ufPreset, _StringNumber(buffer, max));
+ }
+};
+
+extern "C" { UFName ufAperture = "Aperture"; }
+class Aperture : public UFArray {
+public:
+ Aperture() : UFArray(ufAperture) { }
+ void OriginalValueChangedEvent() {
+ if (!HasParent())
+ return;
+ double value;
+ if (sscanf(StringValue(), "%lf", &value) != 1)
+ return;
+ Lensfun::Parent(*this).ApertureValue = value;
+ Lensfun::Parent(*this).Interpolate();
+ }
+ void CreatePresets() {
+ if (!HasParent())
+ return;
+ Clear();
+ lfLens &lens = Lensfun::Parent(*this).Interpolation;
+
+ static double apertureValues[] = { 1, 1.2, 1.4, 1.7, 2, 2.4, 2.8, 3.4,
+ 4, 4.8, 5.6, 6.7, 8, 9.5, 11, 13, 16, 19, 22, 27, 32, 38, 45, 0 };
+ char buffer[_buffer_size];
+ double min = lens.MinAperture;
+ if (min > 0)
+ *this << new UFString(ufPreset, _StringNumber(buffer, min));
+ int i = 0;
+ while (apertureValues[i] < min && apertureValues[i] != 0)
+ i++;
+ if (Has(_StringNumber(buffer, apertureValues[i])))
+ i++; // Comparing string works better than comparing doubles.
+ while (apertureValues[i] != 0) {
+ *this << new UFString(ufPreset, _StringNumber(buffer,
+ apertureValues[i]));
+ i++;
+ }
+ }
+};
+
+extern "C" { UFName ufDistance = "Distance"; }
+class Distance : public UFArray {
+public:
+ Distance() : UFArray(ufDistance) { }
+ void OriginalValueChangedEvent() {
+ if (!HasParent())
+ return;
+ double value;
+ if (sscanf(StringValue(), "%lf", &value) != 1)
+ return;
+ Lensfun::Parent(*this).DistanceValue = value;
+ Lensfun::Parent(*this).Interpolate();
+ }
+ void CreatePresets() {
+ Clear();
+ char buffer[_buffer_size];
+ double value = 0.25;
+ while (value < 1001) {
+ *this << new UFString(ufPreset, _StringNumber(buffer, value));
+ value *= sqrt(2);
+ if (value > 127 && value < 129) value = 125;
+ }
+ }
+};
+
extern "C" { UFName ufModel = "Model"; }
extern "C" { UFName ufTCA = "TCA"; }
@@ -66,14 +199,13 @@
ufraw_data *uf = ufraw_image_get_data(this);
if (uf == NULL)
return UFObject::Event(type);
- if (uf->conf->lens == NULL)
- return UFObject::Event(type);
- if (uf->conf->lens->CalibTCA != NULL)
- while (uf->conf->lens->CalibTCA[0] != NULL)
- uf->conf->lens->RemoveCalibTCA(0);
+ lfLens &lens = Lensfun::Parent(*this).Transformation;
+ if (lens.CalibTCA != NULL)
+ while (lens.CalibTCA[0] != NULL)
+ lens.RemoveCalibTCA(0);
lfLensCalibTCA calib;
calib.Model = static_cast<lfTCAModel>(Index());
- calib.Focal = uf->conf->focal_len;
+ calib.Focal = Lensfun::Parent(*this).FocalLengthValue;
const lfParameter **params;
lfLens::GetTCAModelDesc(calib.Model, NULL, ¶ms);
if (params != NULL) {
@@ -83,16 +215,17 @@
calib.Terms[i] = Param.DoubleValue();
}
}
- uf->conf->lens->AddCalibTCA(&calib);
+ lens.AddCalibTCA(&calib);
ufraw_invalidate_tca_layer(uf);
return UFObject::Event(type);
}
- void Interpolate(const lfLens *lens) {
- ufraw_data *uf = ufraw_image_get_data(this);
- if (uf == NULL)
+ void Interpolate() {
+ if (!HasParent())
return;
+ Lensfun &Lensfun = Lensfun::Parent(*this);
lfLensCalibTCA calib;
- if (!lens->InterpolateTCA(uf->conf->focal_len, calib)) {
+ if (!Lensfun.Interpolation.InterpolateTCA(
+ Lensfun.FocalLengthValue, calib)) {
SetIndex(0);
return;
}
@@ -136,16 +269,15 @@
ufraw_data *uf = ufraw_image_get_data(this);
if (uf == NULL)
return UFObject::Event(type);
- if (uf->conf->lens == NULL)
- return UFObject::Event(type);
- if (uf->conf->lens->CalibVignetting != NULL)
- while (uf->conf->lens->CalibVignetting[0] != NULL)
- uf->conf->lens->RemoveCalibVignetting(0);
+ lfLens &lens = Lensfun::Parent(*this).Transformation;
+ if (lens.CalibVignetting != NULL)
+ while (lens.CalibVignetting[0] != NULL)
+ lens.RemoveCalibVignetting(0);
lfLensCalibVignetting calib;
calib.Model = static_cast<lfVignettingModel>(Index());
- calib.Focal = uf->conf->focal_len;
- calib.Aperture = uf->conf->aperture;
- calib.Distance = uf->conf->subject_distance;
+ calib.Focal = Lensfun::Parent(*this).FocalLengthValue;
+ calib.Aperture = Lensfun::Parent(*this).ApertureValue;
+ calib.Distance = Lensfun::Parent(*this).DistanceValue;
const lfParameter **params;
lfLens::GetVignettingModelDesc(calib.Model, NULL, ¶ms);
if (params != NULL) {
@@ -155,17 +287,19 @@
calib.Terms[i] = Param.DoubleValue();
}
}
- uf->conf->lens->AddCalibVignetting(&calib);
+ lens.AddCalibVignetting(&calib);
ufraw_invalidate_layer(uf, ufraw_first_phase);
return UFObject::Event(type);
}
- void Interpolate(const lfLens *lens) {
+ void Interpolate() {
ufraw_data *uf = ufraw_image_get_data(this);
if (uf == NULL)
return;
+ Lensfun &Lensfun = Lensfun::Parent(*this);
lfLensCalibVignetting calib;
- if (!lens->InterpolateVignetting(uf->conf->focal_len,
- uf->conf->aperture, uf->conf->subject_distance, calib)) {
+ if (!Lensfun.Interpolation.InterpolateVignetting(
+ Lensfun.FocalLengthValue, Lensfun.FocalLengthValue,
+ Lensfun.DistanceValue, calib)) {
SetIndex(0);
return;
}
@@ -223,14 +357,13 @@
ufraw_data *uf = ufraw_image_get_data(this);
if (uf == NULL)
return UFObject::Event(type);
- if (uf->conf->lens == NULL)
- return UFObject::Event(type);
- if (uf->conf->lens->CalibDistortion != NULL)
- while (uf->conf->lens->CalibDistortion[0] != NULL)
- uf->conf->lens->RemoveCalibDistortion(0);
+ lfLens &lens = Lensfun::Parent(*this).Transformation;
+ if (lens.CalibDistortion != NULL)
+ while (lens.CalibDistortion[0] != NULL)
+ lens.RemoveCalibDistortion(0);
lfLensCalibDistortion calib;
calib.Model = static_cast<lfDistortionModel>(Index());
- calib.Focal = uf->conf->focal_len;
+ calib.Focal = Lensfun::Parent(*this).FocalLengthValue;
const lfParameter **params;
lfLens::GetDistortionModelDesc(calib.Model, NULL, ¶ms);
if (params != NULL) {
@@ -240,16 +373,17 @@
calib.Terms[i] = Param.DoubleValue();
}
}
- uf->conf->lens->AddCalibDistortion(&calib);
+ lens.AddCalibDistortion(&calib);
ufraw_invalidate_layer(uf, ufraw_transform_phase);
return UFObject::Event(type);
}
- void Interpolate(const lfLens *lens) {
- ufraw_data *uf = ufraw_image_get_data(this);
- if (uf == NULL)
+ void Interpolate() {
+ if (!HasParent())
return;
+ Lensfun &Lensfun = Lensfun::Parent(*this);
lfLensCalibDistortion calib;
- if (!lens->InterpolateDistortion(uf->conf->focal_len, calib)) {
+ if (!Lensfun.Interpolation.InterpolateDistortion(
+ Lensfun.FocalLengthValue, calib)) {
SetIndex(0);
return;
}
@@ -267,39 +401,43 @@
};
extern "C" { UFName ufLensfun = "Lensfun"; }
-Lensfun::Lensfun() : UFGroup(ufLensfun) {
+Lensfun::Lensfun() : UFGroup(ufLensfun), FocalLengthValue(0.0),
+ ApertureValue(0.0), DistanceValue(0.0) {
*this
+ << new FocalLength
+ << new Aperture
+ << new Distance
<< new TCA
<< new Vignetting
<< new Distortion
;
}
-void Lensfun::Interpolate(const lfLens *lens) {
- static_cast<TCA &>((*this)[ufTCA]).Interpolate(lens);
- static_cast<Vignetting &>((*this)[ufVignetting]).Interpolate(lens);
- static_cast<Distortion &>((*this)[ufDistortion]).Interpolate(lens);
+void Lensfun::Interpolate() {
+ static_cast<TCA &>((*this)[ufTCA]).Interpolate();
+ static_cast<Vignetting &>((*this)[ufVignetting]).Interpolate();
+ static_cast<Distortion &>((*this)[ufDistortion]).Interpolate();
}
-lfDatabase *Lensfun::GlobalLensDB = NULL;
+lfDatabase *Lensfun::LensDB = NULL;
void Lensfun::Init() {
/* Load lens database only once */
- if (GlobalLensDB == NULL) {
- GlobalLensDB = lfDatabase::Create();
- GlobalLensDB->Load();
+ if (LensDB == NULL) {
+ LensDB = lfDatabase::Create();
+ LensDB->Load();
}
ufraw_data *uf = ufraw_image_get_data(this);
- uf->conf->lensdb = GlobalLensDB;
+ uf->conf->lensdb = LensDB;
/* Create a default lens & camera */
- uf->conf->lens = lf_lens_new();
+ uf->conf->lens = &Transformation;
uf->conf->camera = lf_camera_new();
uf->conf->cur_lens_type = LF_UNKNOWN;
/* Set lens and camera from EXIF info, if possible */
if (uf->conf->real_make[0] || uf->conf->real_model[0]) {
- const lfCamera **cams = lf_db_find_cameras(uf->conf->lensdb,
+ const lfCamera **cams = LensDB->FindCameras(
uf->conf->real_make, uf->conf->real_model);
if (cams != NULL) {
lf_camera_copy(uf->conf->camera, cams[0]);
@@ -307,10 +445,11 @@
}
}
if (strlen(uf->conf->lensText) > 0) {
- const lfLens **lenses = lf_db_find_lenses_hd(uf->conf->lensdb,
- uf->conf->camera, NULL, uf->conf->lensText, 0);
+ const lfLens **lenses = LensDB->FindLenses(
+ uf->conf->camera, NULL, uf->conf->lensText);
if (lenses != NULL) {
- lf_lens_copy(uf->conf->lens, lenses[0]);
+ Interpolation = *lenses[0];
+ Transformation = *lenses[0];
lf_free(lenses);
}
}
@@ -328,14 +467,28 @@
(*this)[ufVignetting].Reset();
(*this)[ufDistortion].Reset();
} else {
- Interpolate(uf->conf->lens);
+ static_cast<FocalLength &>((*this)[ufFocalLength]).CreatePresets();
+ static_cast<Aperture &>((*this)[ufAperture]).CreatePresets();
+ static_cast<Distance &>((*this)[ufDistance]).CreatePresets();
+ Interpolate();
}
+ char buffer[_buffer_size];
+ (*this)[ufFocalLength].Set(_StringNumber(buffer, uf->conf->focal_len));
+ (*this)[ufFocalLength].SetDefault();
+ (*this)[ufAperture].Set(_StringNumber(buffer, uf->conf->aperture));
+ (*this)[ufAperture].SetDefault();
+ (*this)[ufDistance].Set(_StringNumber(buffer, uf->conf->subject_distance));
+ (*this)[ufDistance].SetDefault();
}
extern "C" {
void ufraw_lensfun_interpolate(UFObject *lensfun, const lfLens *lens) {
Lensfun &Lensfun = dynamic_cast<UFRaw::Lensfun &>(*lensfun);
- Lensfun.Interpolate(lens);
+ Lensfun.Interpolation = *lens;
+ static_cast<FocalLength &>(Lensfun[ufFocalLength]).CreatePresets();
+ static_cast<Aperture &>(Lensfun[ufAperture]).CreatePresets();
+ static_cast<Distance &>(Lensfun[ufDistance]).CreatePresets();
+ Lensfun.Interpolate();
}
void ufraw_lensfun_init(ufraw_data *uf) {
@@ -347,4 +500,9 @@
}
} // namespace UFRaw
+
+extern "C" UFObject *ufraw_lensfun_new() {
+ return new UFRaw::Lensfun();
+}
+
#endif // HAVE_LENSFUN
Index: ufraw_ui.h
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw_ui.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- ufraw_ui.h 21 Feb 2010 10:03:55 -0000 1.38
+++ ufraw_ui.h 26 Feb 2010 07:01:04 -0000 1.39
@@ -122,16 +122,10 @@
GtkWidget *LensMenu;
/* The lens fix notebook distortion page */
GtkWidget *LensDistortionTable, *LensDistortionDesc;
- /* The lens distortion model combobox */
- GtkWidget *LensDistortionModel;
/* The lens fix notebook TCA page */
GtkWidget *LensTCATable, *LensTCADesc;
- /* The lens TCA model combobox */
- GtkWidget *LensTCAModel;
/* The lens fix notebook vignetting page */
GtkWidget *LensVignettingTable, *LensVignettingDesc;
- /* The lens vignetting model combobox */
- GtkWidget *LensVignettingModel;
/* The lens fix notebook geometry page */
GtkWidget *LensGeometryTable, *LensFromGeometryDesc, *LensToGeometryDesc;
/* The 'from' and 'to' geometry selectors */
@@ -189,10 +183,6 @@
/* Start the render preview refresh thread for invalid layers in background */
void render_preview (preview_data *data);
-preview_data *get_preview_data (void *object);
-
-void resize_canvas(preview_data *data);
-
void lens_fill_interface (preview_data *data, GtkWidget *page);
GtkWidget *table_with_frame (GtkWidget *box, char *label, gboolean expand);
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
ufraw-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ufraw-cvs