00001
00026 #ifndef _PANODATA_PANORAMAVARIABLE_H
00027 #define _PANODATA_PANORAMAVARIABLE_H
00028
00029
00030 #include <hugin_shared.h>
00031 #include <string>
00032 #include <iostream>
00033 #include <vector>
00034 #include <set>
00035 #include <map>
00036
00037 #include <hugin_utils/stl_utils.h>
00038
00039
00040 namespace HuginBase {
00041
00048 class IMPEX Variable
00049 {
00050 public :
00051
00052 #ifdef HUGIN_HSI
00053 Variable(const std::string & name = "" ,
00054 double val = 0.0)
00055 : name(name), value(val)
00056 {};
00057 #else
00058 Variable(const std::string & name, double val = 0.0)
00059 : name(name), value(val)
00060 {};
00061 #endif
00062 virtual ~Variable()
00063 {};
00064
00065
00067 virtual std::ostream & print(std::ostream & o) const;
00068
00069
00070 const std::string & getName() const
00071 { return name; }
00072
00073 void setValue(double v)
00074 { value = v; }
00075
00076 double getValue() const
00077 { return value; }
00078
00079 protected:
00080 std::string name;
00081 double value;
00082 };
00083
00084
00085
00086
00087 class IMPEX LinkedVariable : public Variable
00088 {
00089
00090 public:
00091 LinkedVariable(const std::string & name = "",
00092 double val = 0.0,
00093 int link=-1)
00094 : Variable(name, val), m_link(link)
00095 {}
00096
00097 bool isLinked() const
00098 { return m_link >= 0; }
00099
00100 int getLink() const
00101 { return m_link; }
00102
00103 void setLink(int link)
00104 { m_link = link; }
00105
00106 protected:
00107 int m_link;
00108 };
00109
00110
00111
00117
00118
00119
00120 class IMPEX LensVariable : public Variable
00121 {
00122 public:
00123
00124
00125 #ifdef HUGIN_HSI
00126 LensVariable(const std::string & name = "" ,
00127 double value = 0.0 ,
00128 bool link=false)
00129 : Variable(name, value), linked(link)
00130 {};
00131 #else
00132 LensVariable(const std::string & name, double value, bool link=false)
00133 : Variable(name, value), linked(link)
00134 {};
00135 #endif
00136 virtual ~LensVariable()
00137 {};
00138
00139
00141 virtual std::ostream& printLink(std::ostream & o, unsigned int link) const;
00142
00143
00145 bool isLinked() const
00146 { return linked; }
00148 void setLinked(bool l=true)
00149 { linked = l; }
00150
00151 private:
00152 bool linked;
00153
00154 };
00155
00157 #ifndef SWIG
00158
00159
00160 struct PrintVar : public std::unary_function<Variable, void>
00161 {
00162 PrintVar(std::ostream & o)
00163 : os(o)
00164 {};
00165
00166 void operator()(Variable x) const
00167 { x.print(os) << " "; };
00168
00169 std::ostream& os;
00170 };
00171 #endif
00172
00174 typedef std::map<std::string,Variable> VariableMap;
00175
00177 IMPEX void fillVariableMap(VariableMap & vars);
00178
00180 IMPEX void printVariableMap(std::ostream & o, const VariableMap & vars);
00181
00183 typedef std::vector<VariableMap> VariableMapVector;
00184
00185
00187 typedef std::map<std::string,LensVariable> LensVarMap;
00188
00190 IMPEX void fillLensVarMap(LensVarMap & vars);
00191
00192
00194 typedef std::vector<std::set<std::string> > OptimizeVector;
00195
00196
00197 }
00198 #endif // _H