1 // -*- c-basic-offset: 4 -*- 2 /** @file PTScriptParsing.h 3 * 4 * @author Pablo d'Angelo <pablo.dangelo@web.de> 5 * 6 * $Id$ 7 * !! Panorama.h 1947 8 * 9 * This is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public 11 * License as published by the Free Software Foundation; either 12 * version 2 of the License, or (at your option) any later version. 13 * 14 * This software is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public 20 * License along with this software. If not, see 21 * <http://www.gnu.org/licenses/>. 22 * 23 */ 24 25 #ifndef _PANODATA_PTSCRIPTPARSING_H 26 #define _PANODATA_PTSCRIPTPARSING_H 27 28 #include <hugin_shared.h> 29 #include <string> 30 #include <vigra/diff2d.hxx> 31 32 #include <panodata/PanoramaVariable.h> 33 34 35 36 namespace HuginBase { 37 namespace PTScriptParsing { 38 39 40 /// helper functions for parsing a script line 41 IMPEX bool getPTParam(std::string & output, const std::string & line, const std::string & parameter); 42 43 // template <class T> 44 // bool getParam(T & value, const std::string & line, const std::string & name); 45 46 /// 47 template <class T> 48 bool getIntParam(T & value, const std::string & line, const std::string & name); 49 50 51 bool readVar(Variable & var, int & link, const std::string & line); 52 /* 53 bool getPTStringParam(std::string & output, const std::string & line, 54 const std::string & parameter); 55 56 bool getPTStringParamColon(std::string & output, const std::string & line, const std::string & parameter); 57 */ 58 59 bool getDoubleParam(double & d, const std::string & line, const std::string & name); 60 61 bool getPTDoubleParam(double & value, int & link, 62 const std::string & line, const std::string & var); 63 /// 64 struct ImgInfo 65 { 66 std::string filename; 67 std::string flatfieldname; 68 std::map<std::string, double> vars; 69 std::map<std::string, int> links; 70 int f; 71 // int blend_radius; 72 int width, height; 73 int vigcorrMode; 74 int responseType; 75 vigra::Rect2D crop; 76 bool autoCenterCrop; 77 double cropFactor; 78 bool enabled; 79 80 81 public: ImgInfoImgInfo82 ImgInfo() 83 { 84 init(); 85 } 86 ImgInfoImgInfo87 explicit ImgInfo(const std::string & line) 88 { 89 init(); 90 this->parse(line); 91 } 92 93 protected: 94 void init(); 95 96 public: 97 void parse(const std::string & line); 98 99 public: 100 static const char *varnames[]; 101 static double defaultValues[]; 102 103 }; 104 105 106 //============================================================================== 107 // template implementation 108 109 110 #if 0 111 template <class T> 112 bool getParam(T & value, const std::string & line, const std::string & name) 113 { 114 std::string s; 115 if (!getPTParam(s, line, name)) { 116 return false; 117 } 118 std::istringstream is(s); 119 is >> value; 120 return true; 121 } 122 #endif 123 124 template <class T> getIntParam(T & value,const std::string & line,const std::string & name)125 bool getIntParam(T & value, const std::string & line, const std::string & name) 126 { 127 std::string s; 128 if (!getPTParam(s, line, name)) { 129 return false; 130 } 131 std::istringstream is(s); 132 is >> value; 133 return true; 134 } 135 136 } // namespace 137 } // namespace 138 #endif //_H 139