1 /* 2 * This file is part of RawTherapee. 3 * 4 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com> 5 * 6 * RawTherapee is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * RawTherapee is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 #include <string> 20 #include <glibmm/ustring.h> 21 #include <map> 22 #include <cmath> 23 #include "rawimage.h" 24 25 namespace rtengine 26 { 27 28 class ffInfo 29 { 30 public: 31 32 Glib::ustring pathname; // filename of flat field 33 std::list<Glib::ustring> pathNames; // other similar dark frames, used for average 34 std::string maker; ///< manufacturer 35 std::string model; ///< model 36 std::string lens; ///< lens 37 double aperture; ///< aperture in stops 38 double focallength; ///< focal length in mm 39 time_t timestamp; ///< seconds since 1 Jan 1970 40 41 ffInfo(const Glib::ustring & name,const std::string & mak,const std::string & mod,const std::string & len,double focal,double apert,time_t t)42 ffInfo(const Glib::ustring &name, const std::string &mak, const std::string &mod, const std::string & len, double focal, double apert, time_t t) 43 : pathname(name), maker(mak), model(mod), lens(len), aperture(apert), focallength(focal), timestamp(t), ri(nullptr) {} 44 ffInfo(const ffInfo & o)45 ffInfo( const ffInfo &o) 46 : pathname(o.pathname), maker(o.maker), model(o.model), lens(o.lens), aperture(o.aperture), focallength(o.focallength), timestamp(o.timestamp), ri(nullptr) {} ~ffInfo()47 ~ffInfo() 48 { 49 if( ri ) { 50 delete ri; 51 } 52 } 53 54 55 ffInfo &operator =(const ffInfo &o); 56 bool operator <(const ffInfo &e2) const; 57 58 // Calculate virtual distance between two shots; different model return infinite 59 double distance(const std::string &mak, const std::string &mod, const std::string &lens, double focallength, double aperture) const; 60 61 static std::string key(const std::string &mak, const std::string &mod, const std::string &len, double focal, double apert ); key()62 std::string key() 63 { 64 return key( maker, model, lens, focallength, aperture); 65 } 66 67 RawImage *getRawImage(); 68 69 protected: 70 RawImage *ri; ///< Flat Field raw data 71 72 void updateRawImage(); 73 }; 74 75 class FFManager 76 { 77 public: 78 void init( Glib::ustring pathname ); getPathname()79 Glib::ustring getPathname() 80 { 81 return currentPath; 82 }; 83 void getStat( int &totFiles, int &totTemplate); 84 RawImage *searchFlatField( const std::string &mak, const std::string &mod, const std::string &len, double focallength, double apert, time_t t ); 85 RawImage *searchFlatField( const Glib::ustring filename ); 86 87 protected: 88 typedef std::multimap<std::string, ffInfo> ffList_t; 89 ffList_t ffList; 90 bool initialized; 91 Glib::ustring currentPath; 92 ffInfo *addFileInfo(const Glib::ustring &filename, bool pool = true ); 93 ffInfo *find( const std::string &mak, const std::string &mod, const std::string &len, double focal, double apert, time_t t ); 94 }; 95 96 extern FFManager ffm; 97 98 } 99