[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/extragear/graphics/digikam
From:       Gilles Caulier <caulier.gilles () gmail ! com>
Date:       2010-09-17 13:07:19
Message-ID: 20100917130719.C8043AC888 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1176360 by cgilles:

sync with trunk rev. #1176359.


 M  +2 -0      digikam/digikam.notifyrc  
 M  +3 -0      libs/dimg/filters/CMakeLists.txt  
 M  +5 -9      libs/dimg/filters/lens/lensfuncameraselector.cpp  
 M  +0 -2      libs/dimg/filters/lens/lensfuncameraselector.h  
 M  +101 -132  libs/dimg/filters/lens/lensfuniface.cpp  
 M  +17 -4     libs/dimg/filters/lens/lensfuniface.h  


--- branches/extragear/graphics/digikam/digikam/digikam.notifyrc #1176359:1176360
@@ -111,6 +111,7 @@
 Name[sv]=Spara fil klart
 Name[uk]=Зберігання файла завершено
 Name[x-test]=xxSave file completexx
+Name[zh_TW]=儲存檔案已完成
 Comment=A file from image editor is saved.
 Comment[da]=En fil fra billededitoren er blevet gemt.
 Comment[en_GB]=A file from image editor is saved.
@@ -127,6 +128,7 @@
 Comment[sv]=En fil från bildeditorn har sparats.
 Comment[uk]= едактором збережено файл зображення.
 Comment[x-test]=xxA file from image editor is saved.xx
+Comment[zh_TW]=影像編輯器裡的檔案已儲存。
 Action=Popup
 
 [Event/batchqueuecompleted]
--- branches/extragear/graphics/digikam/libs/dimg/filters/CMakeLists.txt \
#1176359:1176360 @@ -15,4 +15,7 @@
               sharp/refocusfilter.h 
          DESTINATION ${INCLUDE_INSTALL_DIR}/digikam COMPONENT Devel)
 
+IF(LENSFUN_FOUND)
 SUBDIRS(lens)
+ENDIF(LENSFUN_FOUND)
+
--- branches/extragear/graphics/digikam/libs/dimg/filters/lens/lensfuncameraselector.cpp \
#1176359:1176360 @@ -42,9 +42,6 @@
 
 using namespace KDcrawIface;
 
-Q_DECLARE_METATYPE( Digikam::LensFunCameraSelector::DevicePtr )
-Q_DECLARE_METATYPE( Digikam::LensFunCameraSelector::LensPtr )
-
 namespace Digikam
 {
 
@@ -274,7 +271,7 @@
         }
 
         QVariant v            = d->model->combo()->itemData( \
                d->model->currentIndex() );
-        DevicePtr dev         = v.value<LensFunCameraSelector::DevicePtr>();
+        LensFunIface::DevicePtr dev = v.value<LensFunIface::DevicePtr>();
         const lfLens** lenses = d->iface->m_lfDb->FindLenses( dev, NULL, \
lensCutted.toAscii().data() );  QString lensLF        = "";
         int count             = 0;
@@ -424,8 +421,7 @@
        // Fill models for current selected maker
        if ( (*it)->Model && (*it)->Maker == d->make->combo()->currentText() )
        {
-            LensFunCameraSelector::DevicePtr dev;
-            dev        = *it;
+            LensFunIface::DevicePtr dev = *it;
             QVariant b = qVariantFromValue(dev);
             d->model->combo()->addItem( (*it)->Model, b );
        }
@@ -444,7 +440,7 @@
     d->lens->combo()->clear();
 
     QVariant v    = d->model->combo()->itemData( d->model->currentIndex() );
-    DevicePtr dev = v.value<LensFunCameraSelector::DevicePtr>();
+    LensFunIface::DevicePtr dev = v.value<LensFunIface::DevicePtr>();
     if (!dev)
     {
         kDebug() << "Device is null!";
@@ -456,7 +452,7 @@
 
     while (lenses && *lenses)
     {
-        LensFunCameraSelector::LensPtr lens = *lenses;
+        LensFunIface::LensPtr lens = *lenses;
         QVariant b                          = qVariantFromValue(lens);
         d->lens->combo()->addItem((*lenses)->Model, b);
         ++lenses;
@@ -469,7 +465,7 @@
 void LensFunCameraSelector::slotLensSelected()
 {
     QVariant v           = d->lens->combo()->itemData( d->lens->currentIndex() );
-    d->iface->m_usedLens = v.value<LensFunCameraSelector::LensPtr>();
+    d->iface->m_usedLens = v.value<LensFunIface::LensPtr>();
 
     if ( d->iface->m_cropFactor <= 0.0 ) // this should not happen
         d->iface->m_cropFactor = d->iface->m_usedLens->CropFactor;
--- branches/extragear/graphics/digikam/libs/dimg/filters/lens/lensfuncameraselector.h \
#1176359:1176360 @@ -43,8 +43,6 @@
 public:
 
     typedef QMap<QString, QString> Device;
-    typedef const lfCamera*        DevicePtr;
-    typedef const lfLens*          LensPtr;
 
 public:
 
--- branches/extragear/graphics/digikam/libs/dimg/filters/lens/lensfuniface.cpp \
#1176359:1176360 @@ -80,207 +80,176 @@
     return m_usedLens->InterpolateVignetting(m_focalLength, m_aperture, \
m_subjectDistance, res);  }
 
-bool LensFunIface::findFromMetadata(const DMetadata& meta)
+LensFunIface::LensList LensFunIface::findLenses(const lfCamera* lfCamera, const \
QString& lensDesc,  +                                                const QString& \
lensMaker) const  {
-    if (meta.isEmpty())
-        return false;
+    LensList       lensList;
+    const lfLens** lfLens = 0;
 
-    PhotoInfoContainer photoInfo = meta.getPhotographInformation();
-    QString make                 = photoInfo.make;
-    QString model                = photoInfo.model;
-    QString lens                 = photoInfo.lens;
-
-    // ------------------------------------------------------------------------------------------------
                
-
-    const lfCamera** makes = m_lfDb->FindCameras( make.toAscii(), model.toAscii() );
-    QString makeLF;
-    QString modelLF;
-
-    if (makes && *makes)
-    {
-        makeLF  = (*makes)->Maker;
-        modelLF = (*makes)->Model;
-    }
+    if (!lensMaker.isEmpty())
+        lfLens = m_lfDb->FindLenses(lfCamera, lensMaker.toAscii().constData(), \
lensDesc.toAscii().constData());  else
-    {
-        return false;
-    }
+        lfLens = m_lfDb->FindLenses(lfCamera, NULL, lensDesc.toAscii().constData());
 
-    kDebug() << "makeLF:  " << makeLF;
-    kDebug() << "modelLF: " << modelLF;
-
-    const lfCamera* const* it = m_lfCameras;
-    const lfCamera* dev       = 0;
-
-    while ( *it )
+    while (lfLens && *lfLens)
     {
-       if ( ((*it)->Model == modelLF) && ((*it)->Maker == makeLF) )
-       {
-            dev = *it;
-            break;
+        lensList << (*lfLens);
+        ++lfLens;
        }
 
-       ++it;
+    return lensList;
     }
 
-    if (!dev) return false;
-
-    const lfLens** lenses = m_lfDb->FindLenses( dev, NULL, NULL );
-
-//    d->iface->m_cropFactor = dev->CropFactor;
-
-    while (lenses && *lenses)
+bool LensFunIface::findFromMetadata(const DMetadata& meta)
     {
-        if ((*lenses)->Model == lens)
-        {
-            kDebug() << "lensLF:  " << (*lenses)->Model;
-            break;
-        }
-        ++lenses;
-    }
+    if (meta.isEmpty())
+        return false;
 
-    return true;
-/*
-    slotUpdateCombos();
+    PhotoInfoContainer photoInfo = meta.getPhotographInformation();
+    QString make                 = photoInfo.make;
+    QString model                = photoInfo.model;
+    QString lens                 = photoInfo.lens;
 
-    int modelIdx = d->model->combo()->findText(model);
+    // Data to field
+    DevicePtr cameraPrt = 0;
+    LensPtr   lensPtr   = 0;
+    bool      ret       = false;
+    double    cropFactor, focal, aperture, distance;
 
-    if (modelIdx < 0)
-    {
-        const lfCamera** makes = d->iface->m_lfDb->FindCameras( make.toAscii(), \
                model.toAscii() );
-        QString modelLF        = "";
-        int count              = 0;
+    // ------------------------------------------------------------------------------------------------
  
-        while (makes && *makes)
-        {
-            modelLF = (*makes)->Model;
-            ++makes;
-            ++count;
-        }
-        if (count == 1)
-        {
-            modelIdx = d->model->combo()->findText(modelLF);
-        }
-    }
+    const lfCamera** lfCamera = m_lfDb->FindCameras( make.toAscii().constData(), \
model.toAscii().constData() );  
-    if (modelIdx >= 0)
+    if (lfCamera && *lfCamera)
     {
-        d->model->setCurrentIndex(modelIdx);
-        d->model->setEnabled(false);
-        slotUpdateLensCombo();
-    }
+        cameraPrt = *lfCamera;
+        ret       = true;
 
-    // The LensFun DB has the Maker before the Lens model name.
-    // We use here the Camera Maker, because the Lens Maker seems not to be
-    // part of the Exif data. This is of course bad for 3rd party lenses, but
-    // they seem anyway not to have Exif entries usually :/
-    int lensIdx = d->lens->combo()->findText(lens);
+        kDebug() << "Camera maker : " << cameraPrt->Maker;
+        kDebug() << "Camera model : " << cameraPrt->Model;
 
-    if (lensIdx < 0)
-       lensIdx = d->lens->combo()->findText(make + ' ' + lens);
+        // ------------------------------------------------------------------------------------------------
  
-    if (lensIdx < 0)
+        if (!lens.isEmpty())
     {
-        QString lensCutted = lens;
+            // Performing lens searches.
 
-        if (lensCutted.contains("Nikon"))
-        {
-            // adapt exiv2 strings to lensfun strings
+            kDebug() << "Lens desc.   : " << lens;
+            QMap<int, LensPtr> bestMatches;
+            QString            lensCutted;
+            LensList           lensList;
+
+            // In first, search in DB as well.
+            lensList = findLenses(cameraPrt, lens);
+            if (!lensList.isEmpty()) bestMatches.insert(lensList.count(), \
lensList[0]); +
+            // Adapt exiv2 strings to lensfun strings for Nikon.
+            lensCutted = lens;
             lensCutted.replace("Nikon ", "");
             lensCutted.replace("Zoom-", "");
             lensCutted.replace("IF-ID", "ED-IF");
-        }
+            lensList = findLenses(cameraPrt, lensCutted);
+            kDebug() << "* Check for Nikon lens (" << lensCutted << " : " << \
lensList.count() << ")"; +            if (!lensList.isEmpty()) \
bestMatches.insert(lensList.count(), lensList[0]);  
-        QVariant v            = d->model->combo()->itemData( \
                d->model->currentIndex() );
-        DevicePtr dev         = v.value<LensFunCameraSelector::DevicePtr>();
-        const lfLens** lenses = d->iface->m_lfDb->FindLenses( dev, NULL, \
                lensCutted.toAscii().data() );
-        QString lensLF        = "";
-        int count             = 0;
+            // Adapt exiv2 strings to lensfun strings. Some lens description use \
something like that : +            // "10.0 - 20.0 mm". This must be adapted like \
this : "10-20mm" +            lensCutted = lens;
+            lensCutted.replace(QRegExp("\\.[0-9]"), "");
+            lensCutted.replace(" - ", "-");
+            lensCutted.replace(" mm", "mn");
+            lensList = findLenses(cameraPrt, lensCutted);
+            kDebug() << "* Check for no maker lens (" << lensCutted << " : " << \
lensList.count() << ")"; +            if (!lensList.isEmpty()) \
bestMatches.insert(lensList.count(), lensList[0]);  
-        while (lenses && *lenses)
-        {
-            lensLF = (*lenses)->Model;
-            ++lenses;
-            ++count;
-        }
-        if (count == 1)
-        {
-            lensIdx = d->lens->combo()->findText(lensLF);
-        }
-    }
+            // Display the results.
 
-    if (lensIdx >= 0)
+            if (bestMatches.isEmpty())
     {
-        // found lens model directly, best case :)
-        d->lens->setCurrentIndex(lensIdx);
-        d->lens->setEnabled(false);
+                kDebug() << "lens matches : NOT FOUND";
+                ret &= false;
     }
     else
     {
-        // Lens not found, try to reduce the list according to the values we have
-        // FIXME: Implement removal of not matching lenses ...
-        d->lens->setEnabled(true);
+                lensPtr = bestMatches[bestMatches.keys()[0]];
+                kDebug() << "Lens found   : " << lensPtr->Model;
     }
 
-    kDebug() << "Search for Lens: " << make << " :: " << lens
-             << "< and found: >" << d->lens->combo()->itemText(0) + " <";
+            // ------------------------------------------------------------------------------------------------
  
+            cropFactor = lensPtr->CropFactor;
+            kDebug() << "Crop Factor  : " << cropFactor;
+
+            // ------------------------------------------------------------------------------------------------
 +
     QString temp = photoInfo.focalLength;
-    if (!temp.isEmpty())
+            if (temp.isEmpty())
     {
-        double focal = temp.mid(0, temp.length() -3).toDouble(); // HACK: strip the \
                " mm" at the end ...
-        kDebug() << "Focal Length: " << focal;
-        d->focal->setValue(focal);
-        d->focal->setEnabled(false);
+                kDebug() << "Focal Length : NOT FOUND";
+                ret &= false;
     }
+            focal = temp.mid(0, temp.length() -3).toDouble(); // HACK: strip the " \
mm" at the end ... +            kDebug() << "Focal Length : " << focal;
 
+            // ------------------------------------------------------------------------------------------------
 +
     temp = photoInfo.aperture;
-    if (!temp.isEmpty())
+            if (temp.isEmpty())
     {
-        double aperture = temp.mid(1).toDouble();
-        kDebug() << "Aperture: " << aperture;
-        d->aperture->setValue(aperture);
-        d->aperture->setEnabled(false);
+                kDebug() << "Aperture     : NOT FOUND";
+                ret &= false;
     }
+            aperture = temp.mid(1).toDouble();
+            kDebug() << "Aperture     : " << aperture;
 
     // ------------------------------------------------------------------------------------------------
  // Try to get subject distance value.
 
     // From standard Exif.
-    temp = d->metadata.getExifTagString("Exif.Photo.SubjectDistance");
+            temp = meta.getExifTagString("Exif.Photo.SubjectDistance");
     if (temp.isEmpty())
     {
         // From standard XMP.
-        temp = d->metadata.getXmpTagString("Xmp.exif.SubjectDistance");
+                temp = meta.getXmpTagString("Xmp.exif.SubjectDistance");
     }
     if (temp.isEmpty())
     {
         // From Canon Makernote.
-        temp = d->metadata.getExifTagString("Exif.CanonSi.SubjectDistance");
+                temp = meta.getExifTagString("Exif.CanonSi.SubjectDistance");
     }
     if (temp.isEmpty())
     {
         // From Nikon Makernote.
-        temp = d->metadata.getExifTagString("Exif.NikonLd2.FocusDistance");
+                temp = meta.getExifTagString("Exif.NikonLd2.FocusDistance");
     }
     if (temp.isEmpty())
     {
         // From Nikon Makernote.
-        temp = d->metadata.getExifTagString("Exif.NikonLd3.FocusDistance");
+                temp = meta.getExifTagString("Exif.NikonLd3.FocusDistance");
     }
     // TODO: Add here others Makernotes tags.
 
-    if (!temp.isEmpty())
+            if (temp.isEmpty())
     {
+                kDebug() << "Subject dist.: NOT FOUND";
+                ret &= false;
+            }
+
         temp            = temp.replace(" m", "");
-        double distance = temp.toDouble();
-        kDebug() << "Subject Distance: " << distance;
-        d->distance->setValue(distance);
-        d->distance->setEnabled(false);
+            distance = temp.toDouble();
+            kDebug() << "Subject dist.: " << distance;
     }
-*/
+        else
+        {
+            ret &= false;
 }
+    }
 
+    kDebug() << "Return val.  : " << ret;
+
+    return ret;
+}
+
 #if 0
 LensFunIface::correctionData LensFunIface::getCorrectionData()
 {
--- branches/extragear/graphics/digikam/libs/dimg/filters/lens/lensfuniface.h \
#1176359:1176360 @@ -40,16 +40,22 @@
 
 class DIGIKAM_EXPORT LensFunIface
 {
+    public:
 
+/*
+    typedef QMap<QString, QString> correctionData;
+    correctionData getCorrectionData();
+*/
+
+    typedef const lfCamera* DevicePtr;
+    typedef const lfLens*   LensPtr;
+    typedef QList<LensPtr>  LensList;
+
 public:
 
     LensFunIface();
     virtual ~LensFunIface();
 
-/*
-    typedef QMap<QString, QString> correctionData;
-    correctionData getCorrectionData();
-*/
     void setSettings(const LensFunContainer& settings);
 
     bool supportsDistortion();
@@ -66,6 +72,10 @@
 
 private:
 
+    LensList findLenses(const lfCamera* camera, const QString& lensDesc, const \
QString& lensMaker=QString()) const; +
+private:
+
     // my configuration
     bool                   m_init;
 
@@ -90,4 +100,7 @@
 
 }  // namespace Digikam
 
+Q_DECLARE_METATYPE( Digikam::LensFunIface::DevicePtr )
+Q_DECLARE_METATYPE( Digikam::LensFunIface::LensPtr )
+
 #endif /* LENSFUNIFACE_H */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic