Revision: 3967
http://hugin.svn.sourceforge.net/hugin/?rev=3967&view=rev
Author: jlegg
Date: 2009-06-25 22:34:07 +0000 (Thu, 25 Jun 2009)
Log Message:
-----------
Updated SrcPanoImg::getVar, ::setVar, and ::getVariableMap to work with all necessary image variables using image_variables.h. It is not quite as elegant as I hoped. However, now each image variable has its name, type, and default value defined in a single line in image_variables.h; and a conversion for PanoramaVariable like structures defined in a single line in ImageVariableTranslate.h.
Modified Paths:
--------------
hugin/branches/gsoc2009_layout/src/hugin_base/panodata/ImageVariable.h
hugin/branches/gsoc2009_layout/src/hugin_base/panodata/SrcPanoImage.cpp
hugin/branches/gsoc2009_layout/src/hugin_base/panodata/SrcPanoImage.h
hugin/branches/gsoc2009_layout/src/hugin_base/panodata/image_variables.h
Added Paths:
-----------
hugin/branches/gsoc2009_layout/src/hugin_base/panodata/ImageVariableTranslate.h
Modified: hugin/branches/gsoc2009_layout/src/hugin_base/panodata/ImageVariable.h
===================================================================
--- hugin/branches/gsoc2009_layout/src/hugin_base/panodata/ImageVariable.h 2009-06-25 20:17:08 UTC (rev 3966)
+++ hugin/branches/gsoc2009_layout/src/hugin_base/panodata/ImageVariable.h 2009-06-25 22:34:07 UTC (rev 3967)
@@ -283,6 +283,7 @@
if (searchBackwards(link) || searchForwards(link))
{
DEBUG_WARN("Attempt to link already linked variables");
+ return;
}
else
{
Added: hugin/branches/gsoc2009_layout/src/hugin_base/panodata/ImageVariableTranslate.h
===================================================================
--- hugin/branches/gsoc2009_layout/src/hugin_base/panodata/ImageVariableTranslate.h (rev 0)
+++ hugin/branches/gsoc2009_layout/src/hugin_base/panodata/ImageVariableTranslate.h 2009-06-25 22:34:07 UTC (rev 3967)
@@ -0,0 +1,340 @@
+// -*- c-basic-offset: 4 -*-
+/** @file ImageVariableTranslate.h
+ *
+ * @brief Convenience functions for SrcPanoImage to use on the image variables.
+ *
+ * @author James Legg
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _PANODATA_IMAGEVARIABLETRANSLATE_H
+#define _PANODATA_IMAGEVARIABLETRANSLATE_H
+
+namespace HuginBase
+{
+/* We define stuff to use the PTO codes i image_variables.h
+ */
+/** Parent class to anything that aids conversion between PTO file variables and
+ * the image variables of SrcPanoImg.
+ *
+ * Although this class doesn't really do anything itself, it will be used when
+ * the variable in SrcPanoImg is not written to a file.
+ *
+ * We derive children of these to handle more specific cases, which are usually
+ * templates to handle similar things (e.g. all vectors)
+ * We then typedef to make a convertor for each variable in SrcPanoImg.
+ */
+class PTOVariableConverterNoOp
+{
+public:
+ /** Check if a given pto format variable name applies to this image
+ * variable.
+ *
+ * @return true if we can handle this variable name, false otherwise.
+ * @param name The code used to identify the variable in the PTO file
+ * format. For example "Eev".
+ */
+ inline static bool checkApplicability(const std::string name)
+ {
+ return false;
+ }
+
+ /** Get a pto format variable's value, given its name and a reference to the
+ * variable in SrcPanoImg.
+ *
+ * It is a precondition of this function that the checkApplicability
+ * function returns true when passed name.
+ *
+ * @return 0 in this case, but child objects should return the value to
+ * write in a pto file for this variable.
+ * @param name The code used to identify the variable in the PTO file
+ * format. For example "Eev".
+ * @param var Some ImageVariable used by SrcPanoImg to hold this variable.
+ * @tparam T the template parameter of the ImageVariable var.
+ */
+ template <class T>
+ inline static double getValueFromVariable(
+ const std::string name,
+ const ImageVariable<T> & var
+ )
+ {
+ return 0;
+ }
+
+ /** Set a ImageVariable in SrcPanoImg given the pto format variable.
+ *
+ * It is a precondition of this function that the checkApplicability
+ * function returns true when passed name.
+ *
+ * @param name The name used in the PTO format image variable.
+ * @param var The image variable used in SrcPanoImg to change.
+ * @param value The value specified in the PTO format image variable.
+ * @tparam T The template parameter of ImageVariable var.
+ */
+ template <class T>
+ inline static void setValueFromVariable(
+ const std::string name,
+ ImageVariable<T> & var,
+ const double value
+ )
+ {
+ }
+
+ /** Add all PTO format variables specifed by an image variable in SrcPanoImg
+ * to a VariableMap.
+ *
+ * @param var The image variable used in SrcPanoImg to get values from.
+ * @param map The VariableMap
+ * @tparam T The template parameter of ImageVariable var.
+ */
+ template <class T>
+ inline static void addToVariableMap(
+ const ImageVariable<T> & var,
+ VariableMap & map
+ )
+ {
+ }
+};
+
+/** Object to group conversion functions for PTO format variables of up to three
+ * characters representing a single variable in SrcPanoImg.
+ * @tparam code1 1st character of identifier used in PTO file format.
+ * @tparam code2 2nd character of identifier used in PTO file format (or '/0').
+ * @tparam code3 3rd character of identifier used in PTO file format (or '/0').
+ * @tparam T type used in the ImageVariable. Should really be double, but some
+ * are small integers or enumerations.
+ */
+template <char code1, char code2 = '\0', char code3 = '\0', class T = double>
+class PTOVariableConverterSingle
+{
+public:
+ inline static bool checkApplicability(const std::string name)
+ {
+ DEBUG_TRACE(name);
+ static const char code[] = {code1, code2, code3, '\0'};
+ return ((std::string)code) == name;
+ }
+
+ inline static double getValueFromVariable(const std::string name, const ImageVariable<T> & var)
+ {
+ DEBUG_TRACE(name);
+ return var.getData();
+ }
+
+ inline static void setValueFromVariable(const std::string name, ImageVariable<T> & var, const double value)
+ {
+ DEBUG_TRACE(name);
+ var.setData((T)value);
+ }
+
+ inline static void addToVariableMap(const ImageVariable<T> & var, VariableMap & map)
+ {
+ static const char code[] = {code1, code2, code3, '\0'};
+ DEBUG_TRACE(code)
+ map.insert(std::make_pair(code, Variable(code, (double)var.getData())));
+ }
+};
+
+
+/** Object to group conversion functions for PTO format variables representing
+ * a std::vector variable in SrcPanoImg, using an identifying first character.
+ *
+ * It can only represent PTO format variables that can be expressed as some
+ * constant character followed by a index character, where the first element of
+ * the vector has the index character 'a' and the others follow in order.
+ *
+ * @tparam base_code string used in PTO file format upto the the character.
+ * @tparam T type used in SrcImageVariable. Should really be double, but could
+ * be float or something.
+ * @tparam size The number of letters and the size of the vector.
+ */
+template <char base_code, class T = double, size_t size = 4>
+class PTOVariableConverterVectorChar
+{
+public:
+ inline static bool checkApplicability(const std::string name)
+ {
+ DEBUG_TRACE(name);
+ return name.size() == 2 && name[0] == base_code && name[1] >= 'a' && name[1] < 'a' + char(size);
+ }
+
+ inline static double getValueFromVariable(const std::string name, const ImageVariable<std::vector<T> > & var)
+ {
+ DEBUG_TRACE(name);
+ return var.getData()[name[1]-'a'];
+ }
+
+ inline static void setValueFromVariable(const std::string name, ImageVariable<std::vector<T> > & var, const double value)
+ {
+ DEBUG_TRACE(name);
+ std::vector<T> temp = var.getData();
+ temp[name[1]-'a'] = value;
+ var.setData(temp);
+ }
+
+ inline static void addToVariableMap(const ImageVariable<std::vector<T> > & var, VariableMap & map)
+ {
+ char s[3] = {base_code, 'a', '\0'};
+ for (size_t index = 0; index < size; index++, s[1]++)
+ {
+ map.insert(std::make_pair(s, Variable(s, (double)var.getData()[index])));
+ DEBUG_TRACE(s)
+ }
+ }
+};
+
+/** Object to group conversion functions for PTO format variables representing
+ * a std::vector variable in SrcPanoImg, using characters stating from 'a'.
+ *
+ * This can only be used for one variable, and it is RadialDistortion.
+ *
+ * @tparam base_code string used in PTO file format upto the the character.
+ * @tparam T type used in the ImageVariable. Should really be double, but could
+ * be float or something.
+ * @tparam size The number of letters and the size of the vector.
+ */
+template <class T = double, size_t size = 3>
+class PTOVariableConverterVector
+{
+public:
+ inline static bool checkApplicability(const std::string name)
+ {
+ return name[0] >= 'a' && name[0] < 'a' + char(size);
+ }
+
+ inline static double getValueFromVariable(const std::string name, const ImageVariable<std::vector<T> > & var)
+ {
+ DEBUG_TRACE(name);
+ return var.getData()[name[0]-'a'];
+ }
+
+ inline static void setValueFromVariable(const std::string name, ImageVariable<std::vector<T> > & var, const double value)
+ {
+ std::vector<T> temp = var.getData();
+ temp[name[0]-'a'] = value;
+ var.setData(temp);
+ DEBUG_TRACE(name);
+ }
+
+ inline static void addToVariableMap(const ImageVariable<std::vector<T> > & var, VariableMap & map)
+ {
+ char s[] = "a";
+ for (size_t index = 0; index < size; index++, s[0]++)
+ {
+ map.insert(std::make_pair(s, Variable(s, (double)var.getData()[index])));
+ DEBUG_TRACE(s)
+ }
+ }
+};
+
+/** Object to group conversion functions for PTO format variables representing
+ * a hugin_utils::FDiff2D variable in SrcPanoImg. Each element must have a pto
+ * file format code that is 1 or 2 characters in length.
+ *
+ * @tparam code_x The PTO format code that matches the x memeber in the FDiff2D.
+ * @tparam code_y The PTO format code that matches the y memeber in the FDiff2D.
+ */
+template <char code_x1, char code_y1, char code_x2 = '\0', char code_y2 = '\0'>
+class PTOVariableConverterFDiff2D
+{
+public:
+ inline static bool checkApplicability(const std::string name)
+ {
+ static const char code_x[] = {code_x1, code_x2, '\0'};
+ static const char code_y[] = {code_y1, code_y2, '\0'};
+ return name == (std::string) code_x || name == (std::string) code_y;
+ }
+
+ inline static double getValueFromVariable(const std::string name, const ImageVariable<hugin_utils::FDiff2D> & var)
+ {
+ static const char code_x[] = {code_x1, code_x2, '\0'};
+ return name == (std::string) code_x ? var.getData().x : var.getData().y;
+ }
+
+ inline static void setValueFromVariable(const std::string name, ImageVariable<hugin_utils::FDiff2D> & var, const double value)
+ {
+ hugin_utils::FDiff2D temp = var.getData();
+ static const char code_x[] = {code_x1, code_x2, '\0'};
+ (name == (std::string)code_x ? temp.x : temp.y) = value;
+ var.setData(temp);
+ }
+
+ inline static void addToVariableMap(const ImageVariable<hugin_utils::FDiff2D> & var, VariableMap & map)
+ {
+ static const char s_x[] = {code_x1, code_x2, '\0'};
+ static const char s_y[] = {code_y1, code_y2, '\0'};
+ map.insert(std::make_pair(s_x, Variable(s_x, var.getData().x)));
+ map.insert(std::make_pair(s_y, Variable(s_y, var.getData().y)));
+ DEBUG_TRACE(s_x)
+ DEBUG_TRACE(s_y)
+ }
+};
+
+// Now we can define a type to use for every PanoramaVariable.
+// We should make sure that any given code is only applicable to one of these.
+/// @see image_variables.h
+
+/// @todo This could be n, but it is a string, not a double.
+typedef PTOVariableConverterNoOp PTOVariableConverterForFilename;
+typedef PTOVariableConverterNoOp PTOVariableConverterForSize;
+typedef PTOVariableConverterSingle<'f','\0', '\0', SrcPanoImage::Projection> PTOVariableConverterForProjection;
+typedef PTOVariableConverterSingle<'v'> PTOVariableConverterForHFOV;
+
+typedef PTOVariableConverterNoOp PTOVariableConverterForResponseType;
+typedef PTOVariableConverterVectorChar<'R', float, 5> PTOVariableConverterForEMoRParams;
+typedef PTOVariableConverterSingle<'E', 'e', 'v'> PTOVariableConverterForExposureValue;
+typedef PTOVariableConverterSingle<'g'> PTOVariableConverterForGamma ;
+typedef PTOVariableConverterSingle<'E', 'r'> PTOVariableConverterForWhiteBalanceRed;
+typedef PTOVariableConverterSingle<'E', 'b'> PTOVariableConverterForWhiteBalanceBlue;
+
+typedef PTOVariableConverterSingle<'r'> PTOVariableConverterForRoll;
+typedef PTOVariableConverterSingle<'p'> PTOVariableConverterForPitch;
+typedef PTOVariableConverterSingle<'y'> PTOVariableConverterForYaw;
+
+typedef PTOVariableConverterVector<double, 3> PTOVariableConverterForRadialDistortion;
+typedef PTOVariableConverterNoOp PTOVariableConverterForRadialDistortionRed;
+typedef PTOVariableConverterNoOp PTOVariableConverterForRadialDistortionBlue;
+typedef PTOVariableConverterFDiff2D<'d', 'e'> PTOVariableConverterForRadialDistortionCenterShift;
+typedef PTOVariableConverterFDiff2D<'g', 't'> PTOVariableConverterForShear;
+
+typedef PTOVariableConverterNoOp PTOVariableConverterForCropMode;
+/// @todo This could be S, but it is 4 integers in the form a,b,c,d -hence not a double.
+typedef PTOVariableConverterNoOp PTOVariableConverterForCropRect;
+typedef PTOVariableConverterNoOp PTOVariableConverterForAutoCenterCrop;
+
+/// @todo This could be Vf, but it is a string, not a double.
+typedef PTOVariableConverterNoOp PTOVariableConverterForFlatfieldFilename;
+typedef PTOVariableConverterSingle<'V', 'm', '\0', int> PTOVariableConverterForVigCorrMode;
+typedef PTOVariableConverterVectorChar<'V', double, 4> PTOVariableConverterForRadialVigCorrCoeff;
+typedef PTOVariableConverterFDiff2D<'V','V', 'x','y'> PTOVariableConverterForRadialVigCorrCenterShift;
+
+typedef PTOVariableConverterNoOp PTOVariableConverterForExifModel;
+typedef PTOVariableConverterNoOp PTOVariableConverterForExifMake;
+typedef PTOVariableConverterNoOp PTOVariableConverterForExifCropFactor;
+typedef PTOVariableConverterNoOp PTOVariableConverterForExifFocalLength;
+typedef PTOVariableConverterNoOp PTOVariableConverterForExifOrientation;
+typedef PTOVariableConverterNoOp PTOVariableConverterForExifAperture;
+typedef PTOVariableConverterNoOp PTOVariableConverterForExifISO;
+typedef PTOVariableConverterNoOp PTOVariableConverterForExifDistance;
+
+typedef PTOVariableConverterNoOp PTOVariableConverterForFeatherWidth;
+typedef PTOVariableConverterNoOp PTOVariableConverterForMorph;
+typedef PTOVariableConverterNoOp PTOVariableConverterForActive;
+typedef PTOVariableConverterNoOp PTOVariableConverterForLensNr;
+}
+
+#endif
Modified: hugin/branches/gsoc2009_layout/src/hugin_base/panodata/SrcPanoImage.cpp
===================================================================
--- hugin/branches/gsoc2009_layout/src/hugin_base/panodata/SrcPanoImage.cpp 2009-06-25 20:17:08 UTC (rev 3966)
+++ hugin/branches/gsoc2009_layout/src/hugin_base/panodata/SrcPanoImage.cpp 2009-06-25 22:34:07 UTC (rev 3967)
@@ -46,6 +46,8 @@
#define log2(x) (log(x) / M_LN2)
#endif /* __FreeBSD__ */
+#include "ImageVariableTranslate.h"
+
namespace HuginBase {
using namespace hugin_utils;
@@ -108,7 +110,7 @@
std::vector<double> RadialVigCorrCoeff_default(4, 0.0);
RadialVigCorrCoeff_default[0] = 1;
-#define image_variable( name, type, default_value, pto_code ) m_##name.setData(default_value);
+#define image_variable( name, type, default_value ) m_##name.setData(default_value);
#include "image_variables.h"
#undef image_variable
}
@@ -174,8 +176,9 @@
bool BaseSrcPanoImage::operator==(const BaseSrcPanoImage & other) const
{
+ DEBUG_TRACE("");
return (
-#define image_variable( name, type, default_value, pto_code ) \
+#define image_variable( name, type, default_value ) \
m_##name.getData() == other.m_##name.getData() &&
#include "image_variables.h"
#undef image_variable
@@ -184,80 +187,34 @@
}
// convinience functions to extract a set of variables
-double SrcPanoImage::getVar(const std::string & name) const
+double SrcPanoImage::getVar(const std::string & code) const
{
- assert(name.size() > 0);
- // TODO: support all variables
- if (name == "Eev")
- return m_ExposureValue.getData();
- else if (name == "Er")
- return m_WhiteBalanceRed.getData();
- else if (name == "Eb")
- return m_WhiteBalanceBlue.getData();
- else if (name == "Ra")
- return m_EMoRParams.getData()[0];
- else if (name[0] == 'R')
- {
- assert(name.size() == 2);
- int i = name[1] - 'a';
- return m_EMoRParams.getData()[i];
- } else if (name[0] == 'V')
- {
- int i = name[1] - 'a';
- if (i > 0 && i < 4) {
- return m_RadialVigCorrCoeff.getData()[i];
- } else {
- if (name[1] == 'x') {
- return m_RadialVigCorrCenterShift.getData().x;
- } else if (name[1] == 'y') {
- return m_RadialVigCorrCenterShift.getData().y;
- }
- }
- } else {
- assert(0 || "Unknown variable in getVar()");
+ DEBUG_TRACE("");
+ assert(code.size() > 0);
+#define image_variable( name, type, default_value ) \
+ if (PTOVariableConverterFor##name::checkApplicability(code)) \
+ return PTOVariableConverterFor##name::getValueFromVariable(code, m_##name );\
+ else
+#include "image_variables.h"
+#undef image_variable
+ {// this is for the final else.
+ DEBUG_ERROR("Unknown variable " << code);
}
return 0;
}
-void SrcPanoImage::setVar(const std::string & name, double val)
+void SrcPanoImage::setVar(const std::string & code, double val)
{
- assert(name.size() > 0);
- // TODO: support all variables
- if (name == "Eev")
- m_ExposureValue.setData(val);
- else if (name == "Er")
- m_WhiteBalanceRed.setData(val);
- else if (name == "Eb")
- m_WhiteBalanceBlue.setData(val);
- else if (name[0] == 'R')
- {
- assert(name.size() == 2);
- int i = name[1] - 'a';
- std::vector<float> temp = m_EMoRParams.getData();
- temp[i] = val;
- m_EMoRParams.setData(temp);
- } else if (name[0] == 'V')
- {
- int i = name[1] - 'a';
- if (i >= 0 && i < 4) {
- std::vector<double> temp = m_RadialVigCorrCoeff.getData();
- temp[i] = val;
- m_RadialVigCorrCoeff.setData(temp);
- } else {
- if (name[1] == 'x') {
- hugin_utils::FDiff2D temp = m_RadialVigCorrCenterShift.getData();
- temp.x = val;
- m_RadialVigCorrCenterShift.setData(temp);
- } else if (name[1] == 'y') {
- hugin_utils::FDiff2D temp = m_RadialVigCorrCenterShift.getData();
- temp.y = val;
- m_RadialVigCorrCenterShift.setData(temp);
- } else {
- DEBUG_ERROR("Unknown variable " << name);
- }
- }
- } else {
- DEBUG_ERROR("Unknown variable " << name);
+ DEBUG_TRACE("");
+ assert(code.size() > 0);
+#define image_variable( name, type, default_value ) \
+ if (PTOVariableConverterFor##name::checkApplicability(code)) \
+ {PTOVariableConverterFor##name::setValueFromVariable(code, m_##name, val);}\
+ else
+#include "image_variables.h"
+#undef image_variable
+ {// this is for the final else.
+ DEBUG_ERROR("Unknown variable " << code);
}
}
@@ -267,43 +224,14 @@
// fill variable map with details about this image.
// position
- using namespace std;
+ DEBUG_TRACE("");
VariableMap vars;
-
- vars.insert(make_pair("v", Variable("v", getHFOV())));
- vars.insert(make_pair("r", Variable("r", getRoll())));
- vars.insert(make_pair("p", Variable("p", getPitch())));
- vars.insert(make_pair("y", Variable("y", getYaw())));
- // distortion
- vars.insert(make_pair("a", Variable("a", getRadialDistortion()[0])));
- vars.insert(make_pair("b", Variable("b", getRadialDistortion()[1])));
- vars.insert(make_pair("c", Variable("c", getRadialDistortion()[2])));
- vars.insert(make_pair("d", Variable("d", getRadialDistortionCenterShift().x)));
- vars.insert(make_pair("e", Variable("e", getRadialDistortionCenterShift().y)));
- vars.insert(make_pair("g", Variable("g", getShear().x)));
- vars.insert(make_pair("t", Variable("t", getShear().y)));
+#define image_variable( name, type, default_value ) \
+ PTOVariableConverterFor##name::addToVariableMap(m_##name, vars);
+#include "image_variables.h"
+#undef image_variable
- // vignetting correction
- vars.insert(make_pair("Va", Variable("Va", getRadialVigCorrCoeff()[0])));
- vars.insert(make_pair("Vb", Variable("Vb", getRadialVigCorrCoeff()[1])));
- vars.insert(make_pair("Vc", Variable("Vc", getRadialVigCorrCoeff()[2])));
- vars.insert(make_pair("Vd", Variable("Vd", getRadialVigCorrCoeff()[3])));
- vars.insert(make_pair("Vx", Variable("Vx", getRadialVigCorrCenterShift().x)));
- vars.insert(make_pair("Vy", Variable("Vy", getRadialVigCorrCenterShift().y)));
-
- // exposure and white balance
- vars.insert(make_pair("Eev", Variable("Eev", getExposureValue())));
- vars.insert(make_pair("Er", Variable("Er", getWhiteBalanceRed())));
- vars.insert(make_pair("Eb", Variable("Eb", getWhiteBalanceBlue())));
-
- // camera response parameters
- vars.insert(make_pair("Ra", Variable("Ra", getEMoRParams()[0])));
- vars.insert(make_pair("Rb", Variable("Rb", getEMoRParams()[1])));
- vars.insert(make_pair("Rc", Variable("Rc", getEMoRParams()[2])));
- vars.insert(make_pair("Rd", Variable("Rd", getEMoRParams()[3])));
- vars.insert(make_pair("Re", Variable("Re", getEMoRParams()[4])));
-
return vars;
}
Modified: hugin/branches/gsoc2009_layout/src/hugin_base/panodata/SrcPanoImage.h
===================================================================
--- hugin/branches/gsoc2009_layout/src/hugin_base/panodata/SrcPanoImage.h 2009-06-25 20:17:08 UTC (rev 3966)
+++ hugin/branches/gsoc2009_layout/src/hugin_base/panodata/SrcPanoImage.h 2009-06-25 22:34:07 UTC (rev 3967)
@@ -108,13 +108,13 @@
// property accessors
public:
// get[variable name] functions
-#define image_variable( name, type, default_value, pto_code ) \
+#define image_variable( name, type, default_value ) \
type get##name() const { return m_##name.getData(); }
#include "image_variables.h"
#undef image_variable
// set[variable name] functions
-#define image_variable( name, type, default_value, pto_code ) \
+#define image_variable( name, type, default_value ) \
void set##name(type data) { m_##name.setData(data); }
#include "image_variables.h"
#undef image_variable
@@ -124,7 +124,7 @@
void setDefaults();
// the image variables m_[variable name]
-#define image_variable( name, type, default_value, pto_code ) \
+#define image_variable( name, type, default_value ) \
ImageVariable<type> m_##name;
#include "image_variables.h"
#undef image_variable
@@ -258,7 +258,7 @@
* will be shared between the images. Afterwards, changing the variable with
* set[variable name] on either image also sets the other image.
*/
-#define image_variable( name, type, default_value, pto_code ) \
+#define image_variable( name, type, default_value ) \
void link##name (SrcPanoImage * target) \
{ m_##name.linkWith(&(target->m_##name)); }
#include "image_variables.h"
@@ -268,7 +268,7 @@
* Unlinking a variable makes it unique to this image. Then changing it will
* not affect the other images.
*/
-#define image_variable( name, type, default_value, pto_code ) \
+#define image_variable( name, type, default_value ) \
void unlink##name () \
{ m_##name.removeLinks(); }
#include "image_variables.h"
Modified: hugin/branches/gsoc2009_layout/src/hugin_base/panodata/image_variables.h
===================================================================
--- hugin/branches/gsoc2009_layout/src/hugin_base/panodata/image_variables.h 2009-06-25 20:17:08 UTC (rev 3966)
+++ hugin/branches/gsoc2009_layout/src/hugin_base/panodata/image_variables.h 2009-06-25 22:34:07 UTC (rev 3967)
@@ -42,51 +42,69 @@
* -# the name of the variable
* -# the type of the variable
* -# the default value
- * -# the code for the variable in the pto file format.
*
- * @todo I might need to rething the last argument, there is a lot of vectors
- * with multiple pto format codes.
+ * @par
+ * There is some non automatic stuff in ImageVariableTranslate.h that will need
+ * changing if this list changes. That file handles the translation to and from
+ * PTO file format style variables.
+ * @see ImageVariableTranslate.h
*/
-image_variable( Filename, std::string, "", "n" )
-image_variable( Size, vigra::Size2D , vigra::Size2D(0,0), NO_CODE )
-image_variable( Projection, Projection, RECTILINEAR, "f" )
-image_variable( HFOV, double, 50.0, "v" )
+/* Hmmm... I'ld like commas in template arguments, but < and > aren't real
+ * brackets so the template arguments will be interprated as separate macro
+ * arguments instead.
+ * Solution: Have an object in ImageVariableTranslate.h which handles all the
+ * pto conversion code. We can generate the code in SrcPanoImg.h automatically
+ * as ImageVariableTranslate.h typedefs PTOVariableConverterFor[name] for each
+ * variable.
+ * So we don't have a parameter that specifies the codes to use in a PTO file.
+ */
-image_variable( ResponseType, ResponseType, RESPONSE_EMOR, "Vm" )
-/// @todo this
-image_variable( EMoRParams, std::vector<float>, std::vector<float>(5, 0), NO_CODE )
-image_variable( ExposureValue, double, 1.0, "Eev" )
-image_variable( Gamma, double, 1.0, "g" )
-image_variable( WhiteBalanceRed, double, 1.0, "Er" )
-image_variable( WhiteBalanceBlue, double, 1.0, "Eb" )
+// file variables
+image_variable( Filename, std::string, "" )
+image_variable( Size, vigra::Size2D , vigra::Size2D(0,0) )
+// projection variables
+image_variable( Projection, Projection, RECTILINEAR )
+image_variable( HFOV, double, 50.0 )
+// colour response variables
+image_variable( ResponseType, ResponseType, RESPONSE_EMOR )
+image_variable( EMoRParams, std::vector<float>, std::vector<float>(5, 0.0) )
+image_variable( ExposureValue, double, 1.0 )
+image_variable( Gamma, double, 1.0 )
+image_variable( WhiteBalanceRed, double, 1.0 )
+image_variable( WhiteBalanceBlue, double, 1.0 )
+
// orientation in degrees
-image_variable( Roll, double , 0.0, "r" )
-image_variable( Pitch, double , 0.0, "p" )
-image_variable( Yaw, double, 0.0, "y" )
+image_variable( Roll, double , 0.0 )
+image_variable( Pitch, double , 0.0 )
+image_variable( Yaw, double, 0.0 )
// radial lens distortion
-image_variable( RadialDistortion, std::vector<double>, distortion_default, NO_CODE )
+image_variable( RadialDistortion, std::vector<double>, distortion_default )
+
// radial lens distortion (red, blue channel), for TCA correction
-image_variable( RadialDistortionRed, std::vector<double>, distortion_default, NO_CODE )
-image_variable( RadialDistortionBlue, std::vector<double>, distortion_default, NO_CODE )
+image_variable( RadialDistortionRed, std::vector<double>, distortion_default )
+image_variable( RadialDistortionBlue, std::vector<double>, distortion_default )
+
// Center shift
-image_variable( RadialDistortionCenterShift, hugin_utils::FDiff2D, hugin_utils::FDiff2D(0.0, 0.0), NO_CODE )
+image_variable( RadialDistortionCenterShift, hugin_utils::FDiff2D, hugin_utils::FDiff2D(0.0, 0.0) )
+
// shear
-image_variable( Shear, hugin_utils::FDiff2D, hugin_utils::FDiff2D(0, 0), NO_CODE )
+image_variable( Shear, hugin_utils::FDiff2D, hugin_utils::FDiff2D(0, 0) )
// crop description
-image_variable( CropMode, CropMode, NO_CROP, NO_CODE )
-image_variable( CropRect, vigra::Rect2D, vigra::Rect2D(0, 0, 0, 0), NO_CODE )
-image_variable( AutoCenterCrop, bool, true, NO_CODE )
+image_variable( CropMode, CropMode, NO_CROP )
+image_variable( CropRect, vigra::Rect2D, vigra::Rect2D(0, 0, 0, 0) )
+image_variable( AutoCenterCrop, bool, true )
// vignetting correction
-image_variable( VigCorrMode, int, VIGCORR_RADIAL|VIGCORR_DIV, "Vm" )
+image_variable( VigCorrMode, int, VIGCORR_RADIAL|VIGCORR_DIV )
+
// coefficients for vignetting correction (even degrees: 0,2,4,6, ...)
-image_variable( FlatfieldFilename, std::string, "", "p" )
-image_variable( RadialVigCorrCoeff, std::vector<double>, RadialVigCorrCoeff_default, NO_CODE )
-image_variable( RadialVigCorrCenterShift, hugin_utils::FDiff2D, hugin_utils::FDiff2D(0.0, 0.0), NO_CODE )
+image_variable( FlatfieldFilename, std::string, "" )
+image_variable( RadialVigCorrCoeff, std::vector<double>, RadialVigCorrCoeff_default )
+image_variable( RadialVigCorrCenterShift, hugin_utils::FDiff2D, hugin_utils::FDiff2D(0.0, 0.0) )
// linear pixel transform
// (doesn't seem to be used, removing with #if 0)
@@ -96,26 +114,26 @@
#endif
// store camera information from exif tags...
-image_variable( ExifModel, std::string, "", NO_CODE )
-image_variable( ExifMake, std::string, "", NO_CODE )
-image_variable( ExifCropFactor, double, 0, NO_CODE )
-image_variable( ExifFocalLength, double, 0, NO_CODE )
-image_variable( ExifOrientation, double, 0, NO_CODE )
-image_variable( ExifAperture, double, 0, NO_CODE )
-image_variable( ExifISO, double, 0, NO_CODE )
-image_variable( ExifDistance, double, 0, NO_CODE )
+image_variable( ExifModel, std::string, "" )
+image_variable( ExifMake, std::string, "" )
+image_variable( ExifCropFactor, double, 0 )
+image_variable( ExifFocalLength, double, 0 )
+image_variable( ExifOrientation, double, 0 )
+image_variable( ExifAperture, double, 0 )
+image_variable( ExifISO, double, 0 )
+image_variable( ExifDistance, double, 0 )
//
// panotools options
//
// width of feather for stitching.
-image_variable( FeatherWidth, unsigned int, 10, NO_CODE )
+image_variable( FeatherWidth, unsigned int, 10 )
// Morph-to-fit using control points.
-image_variable( Morph, bool, false, NO_CODE )
+image_variable( Morph, bool, false )
// If the image is selected to be used in the preview and for optimisation.
-image_variable( Active, bool, true, NO_CODE )
+image_variable( Active, bool, true )
/// @todo replace everything that uses LensNr.
-image_variable( LensNr, unsigned int, 0, NO_CODE )
+image_variable( LensNr, unsigned int, 0 )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|