Update of /cvsroot/ufraw/ufraw In directory vz-cvs-3.sog:/tmp/cvs-serv29975
Modified Files: ufraw_lensfun.cc Log Message: Set the lens geometry according to the lens model. Index: ufraw_lensfun.cc =================================================================== RCS file: /cvsroot/ufraw/ufraw/ufraw_lensfun.cc,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- ufraw_lensfun.cc 6 Aug 2011 10:47:23 -0000 1.25 +++ ufraw_lensfun.cc 9 Aug 2011 05:03:54 -0000 1.26 @@ -93,6 +93,14 @@ void SetLensInterpolation(); // Interpolate the TCA, Vignetting and Distortion models. void Interpolate(); + // Mark settings as manual (not from LensDB). + void Manual() { + char *lens_model = g_strdup_printf("Generic, Crop factor %.4g", + Transformation.CropFactor); + (*this)[ufLensModel].Set(lens_model); + g_free(lens_model); + UFObject::Parent()[ufLensfunAuto].Set("no"); + } void Init(bool reset); }; @@ -197,6 +205,7 @@ return UFObject::Event(type); Lensfun::Parent(*this).FocalLengthValue = value; Lensfun::Parent(*this).Interpolate(); + ufraw_invalidate_layer(uf, ufraw_transform_phase); return UFObject::Event(type); } void CreatePresets() { @@ -342,15 +351,7 @@ if (ufraw_image_get_data(this) == NULL) return; Lensfun &Lensfun = Lensfun::Parent(*this); - if (Lensfun.Transformation.CropFactor == 1.0) { - Lensfun[ufLensModel].Reset(); - } else { - char *lens_model = g_strdup_printf("Generic, Crop factor %.4g", - Lensfun.Transformation.CropFactor); - Lensfun[ufLensModel].Set(lens_model); - g_free(lens_model); - } - Lensfun.UFObject::Parent()[ufLensfunAuto].Set("no"); + Lensfun.Manual(); } }; @@ -602,22 +603,42 @@ *this << new UFString("Type", typeName); } } - void OriginalValueChangedEvent() { + void Event(UFEventType type) { + if (type != uf_value_changed) + return UFObject::Event(type); ufraw_data *uf = ufraw_image_get_data(this); if (uf == NULL) - return; + return UFObject::Event(type); Lensfun::Parent(*this).Transformation.Type = lfLensType(Index()); ufraw_invalidate_layer(uf, ufraw_transform_phase); + return UFObject::Event(type); + } + void OriginalValueChangedEvent() { + if (!HasParent()) + return; + // While loading rc/cmd/conf data, do not reset other settings + if (ufraw_image_get_data(this) == NULL) + return; + Lensfun &Lensfun = Lensfun::Parent(*this); + Lensfun.Manual(); } }; extern "C" { UFName ufTargetLensGeometry = "TargetLensGeometry"; } -class TargetLensGeometry : public LensGeometry +class TargetLensGeometry : public UFArray { public: - TargetLensGeometry() : LensGeometry(ufTargetLensGeometry) { } + explicit TargetLensGeometry(UFName name = ufTargetLensGeometry) : + UFArray(name, lfLens::GetLensTypeDesc(LF_UNKNOWN, NULL)) { + for (lfLensType type = LF_UNKNOWN; ; type = lfLensType(type + 1)) { + const char *typeName = lfLens::GetLensTypeDesc(type, NULL); + if (typeName == NULL) + break; // End of loop. + *this << new UFString("Type", typeName); + } + } void OriginalValueChangedEvent() { ufraw_data *uf = ufraw_image_get_data(this); if (uf == NULL) @@ -651,16 +672,19 @@ char make[200], model[200]; parse_maker_model((*this)[ufLensModel].StringValue(), make, sizeof(make), model, sizeof(model)); - if (strcmp(make, "Generic") == 0) { - double crop_factor; - int count = sscanf(model, "Crop factor %lf", &crop_factor); - if (count == 1) { - lfLens cropLens; - cropLens.SetMaker(make); - cropLens.SetModel(model); - cropLens.CropFactor = crop_factor; - Interpolation = cropLens; - } + double crop_factor = 1.0; + int count = sscanf(model, "Crop factor %lf", &crop_factor); + if ((strcmp(make, "Generic") == 0 && count == 1) || + (strcmp(make, "") == 0 && strcmp(model, "") == 0)) { + lfLens cropLens; + cropLens.SetMaker(make); + cropLens.SetModel(model); + cropLens.CropFactor = crop_factor; + cropLens.MinFocal = 1.0; + cropLens.MaxFocal = 800.0; + UFArray &LensGeometry = (*this)[ufLensGeometry]; + cropLens.Type = lfLensType(LensGeometry.Index()); + Interpolation = cropLens; } else { const lfLens **lensList = LensDB()->FindLenses(&Camera, make, model, LF_SEARCH_LOOSE); @@ -674,6 +698,8 @@ lf_free(lensList); } Transformation.CropFactor = Interpolation.CropFactor; + UFArray &LensGeometry = (*this)[ufLensGeometry]; + LensGeometry.SetIndex(Interpolation.Type); static_cast<UFRaw::FocalLength &>((*this)[ufFocalLength]).CreatePresets(); static_cast<UFRaw::Aperture &>((*this)[ufAperture]).CreatePresets(); static_cast<UFRaw::Distance &>((*this)[ufDistance]).CreatePresets(); ------------------------------------------------------------------------------ uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev _______________________________________________ ufraw-cvs mailing list ufraw-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ufraw-cvs