Commit a42f4f7a authored by Julien Malik's avatar Julien Malik

ENH: add more parameter types, and begin a more complex example

parent b73c219b
......@@ -21,9 +21,24 @@
#include <string>
#include "otbMacro.h"
#include "itkObject.h"
#include "otbWrapperParameterGroup.h"
#include "itkObjectFactory.h"
#include "otbWrapperParameterGroup.h"
// include all parameters type for easy use when defining the application
#include "otbWrapperChoiceParameter.h"
#include "otbWrapperDirectoryParameter.h"
#include "otbWrapperEmptyParameter.h"
#include "otbWrapperFilenameParameter.h"
#include "otbWrapperInputComplexImageParameter.h"
#include "otbWrapperInputImageParameter.h"
#include "otbWrapperInputVectorDataParameter.h"
#include "otbWrapperNumericalParameter.h"
#include "otbWrapperOutputImageParameter.h"
#include "otbWrapperOutputVectorDataParameter.h"
#include "otbWrapperRadiusParameter.h"
#include "otbWrapperStringParameter.h"
namespace otb
{
namespace Wrapper
......@@ -88,14 +103,13 @@ protected:
virtual ~Application();
protected:
private:
virtual void DoCreateParameters() = 0;
virtual void DoUpdateParameters() = 0;
virtual void DoExecute() = 0;
private:
Application(const Application &); //purposely not implemented
void operator =(const Application&); //purposely not implemented
......
......@@ -107,13 +107,9 @@ protected:
{}
/** Destructor */
~ChoiceParameter()
virtual ~ChoiceParameter()
{}
private:
ChoiceParameter(const ChoiceParameter &); //purposely not implemented
void operator =(const ChoiceParameter&); //purposely not implemented
typedef std::pair<std::string, Parameter::Pointer> Choice;
typedef std::vector<Choice> ChoiceList;
......@@ -121,6 +117,10 @@ private:
unsigned int m_CurrentChoice;
private:
ChoiceParameter(const ChoiceParameter &); //purposely not implemented
void operator =(const ChoiceParameter&); //purposely not implemented
}; // End class Parameter
} // End namespace Wrapper
......
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbWrapperDirectoryParameter_h
#define __otbWrapperDirectoryParameter_h
#include <string>
#include "otbWrapperParameter.h"
namespace otb
{
namespace Wrapper
{
/** \class DirectoryParameter
* \brief This class represent a string parameter for the wrapper framework
*/
class DirectoryParameter
: public Parameter
{
public:
/** Standard class typedef */
typedef DirectoryParameter Self;
typedef Parameter Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Defining ::New() static method */
itkNewMacro(Self);
/** RTTI support */
itkTypeMacro(DirectoryParameter, Parameter);
/** Set any value */
virtual void SetAnyValue(boost::any v)
{
// Perform any cast
m_Value = boost::any_cast<std::string>(v);
// Call Modified();
this->Modified();
}
/** Return any value */
virtual boost::any GetAnyValue()
{
return boost::any(m_Value);
}
/** Set the value */
itkSetMacro(Value,std::string);
/** Get the value */
itkGetMacro(Value,std::string);
protected:
/** Constructor */
DirectoryParameter()
{}
/** Destructor */
virtual ~DirectoryParameter()
{}
std::string m_Value;
private:
DirectoryParameter(const DirectoryParameter &); //purposely not implemented
void operator =(const DirectoryParameter&); //purposely not implemented
}; // End class Parameter
} // End namespace Wrapper
} // End namespace otb
#endif
......@@ -73,15 +73,15 @@ protected:
{}
/** Destructor */
~EmptyParameter()
virtual ~EmptyParameter()
{}
bool m_Value;
private:
EmptyParameter(const EmptyParameter &); //purposely not implemented
void operator =(const EmptyParameter&); //purposely not implemented
bool m_Value;
}; // End class Parameter
} // End namespace Wrapper
......
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbWrapperFilenameParameter_h
#define __otbWrapperFilenameParameter_h
#include <string>
#include "otbWrapperParameter.h"
namespace otb
{
namespace Wrapper
{
/** \class FilenameParameter
* \brief This class represent a string parameter for the wrapper framework
*/
class FilenameParameter
: public Parameter
{
public:
/** Standard class typedef */
typedef FilenameParameter Self;
typedef Parameter Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Defining ::New() static method */
itkNewMacro(Self);
/** RTTI support */
itkTypeMacro(FilenameParameter, Parameter);
/** Set any value */
virtual void SetAnyValue(boost::any v)
{
// Perform any cast
m_Value = boost::any_cast<std::string>(v);
// Call Modified();
this->Modified();
}
/** Return any value */
virtual boost::any GetAnyValue()
{
return boost::any(m_Value);
}
/** Set the value */
itkSetMacro(Value,std::string);
/** Get the value */
itkGetMacro(Value,std::string);
protected:
/** Constructor */
FilenameParameter()
{}
/** Destructor */
virtual ~FilenameParameter()
{}
std::string m_Value;
private:
FilenameParameter(const FilenameParameter &); //purposely not implemented
void operator =(const FilenameParameter&); //purposely not implemented
}; // End class Parameter
} // End namespace Wrapper
} // End namespace otb
#endif
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbWrapperInputComplexImageParameter_h
#define __otbWrapperInputComplexImageParameter_h
#include "otbVectorImage.h"
#include "otbWrapperParameter.h"
namespace otb
{
namespace Wrapper
{
/** \class InputComplexImageParameter
* \brief This class represents a InputComplexImage parameter
*/
class ITK_EXPORT InputComplexImageParameter : public Parameter
{
public:
/** Standard class typedef */
typedef InputComplexImageParameter Self;
typedef Parameter Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Defining ::New() static method */
itkNewMacro(Self);
/** RTTI support */
itkTypeMacro(InputComplexImageParameter,Parameter);
typedef float PixelType;
typedef otb::VectorImage<PixelType, 2> VectorImageType;
/** Set the value */
itkSetObjectMacro(Image, VectorImageType);
/** Get the value */
itkGetObjectMacro(Image, VectorImageType);
protected:
/** Constructor */
InputComplexImageParameter()
{
this->SetName("Input Image");
this->SetKey("in");
}
/** Destructor */
virtual ~InputComplexImageParameter()
{}
VectorImageType::Pointer m_Image;
private:
InputComplexImageParameter(const Parameter &); //purposely not implemented
void operator =(const Parameter&); //purposely not implemented
}; // End class InputComplexImage Parameter
} // End namespace Wrapper
} // End namespace otb
#endif
......@@ -19,6 +19,8 @@
#define __otbWrapperInputImageParameter_h
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
#include "otbWrapperParameter.h"
namespace otb
......@@ -53,21 +55,40 @@ public:
/** Get the value */
itkGetObjectMacro(Image, VectorImageType);
/** Set value from filename */
void SetFromFileName(const std::string& filename)
{
typedef otb::ImageFileReader<VectorImageType> ImageFileReaderType;
ImageFileReaderType::Pointer reader = ImageFileReaderType::New();
reader->SetFileName(filename);
reader->UpdateOutputInformation();
m_Image = reader->GetOutput();
}
/** Return any value */
virtual boost::any GetAnyValue()
{
return boost::any(m_Image);
}
protected:
/** Constructor */
InputImageParameter()
{}
{
this->SetName("Input Image");
this->SetKey("in");
}
/** Destructor */
virtual ~InputImageParameter()
{}
VectorImageType::Pointer m_Image;
private:
InputImageParameter(const Parameter &); //purposely not implemented
void operator =(const Parameter&); //purposely not implemented
VectorImageType::Pointer m_Image;
}; // End class InputImage Parameter
} // End namespace Wrapper
......
......@@ -54,21 +54,30 @@ public:
/** Get the value */
itkGetObjectMacro(VectorData, VectorDataType);
/** Return any value */
virtual boost::any GetAnyValue()
{
return boost::any(m_VectorData);
}
protected:
/** Constructor */
InputVectorDataParameter()
{}
{
this->SetName("Input Vector Data");
this->SetKey("ivd");
}
/** Destructor */
virtual ~InputVectorDataParameter()
{}
VectorDataType::Pointer m_VectorData;
private:
InputVectorDataParameter(const Parameter &); //purposely not implemented
void operator =(const Parameter&); //purposely not implemented
VectorDataType::Pointer m_VectorData;
};
} // End namespace Wrapper
......
......@@ -106,10 +106,6 @@ protected:
virtual ~NumericalParameter()
{}
private:
NumericalParameter(const Parameter &); //purposely not implemented
void operator =(const Parameter&); //purposely not implemented
/** Value */
ScalarType m_Value;
......@@ -122,6 +118,10 @@ private:
/** Maximum value */
ScalarType m_MaximumValue;
private:
NumericalParameter(const Parameter &); //purposely not implemented
void operator =(const Parameter&); //purposely not implemented
}; // End class Numerical Parameter
// Helper typedef for float
......
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbWrapperOutputImageParameter_h
#define __otbWrapperOutputImageParameter_h
#include "otbVectorImage.h"
#include "otbWrapperParameter.h"
namespace otb
{
namespace Wrapper
{
/** \class OutputImageParameter
* \brief This class represents a OutputImage parameter
*/
class ITK_EXPORT OutputImageParameter : public Parameter
{
public:
/** Standard class typedef */
typedef OutputImageParameter Self;
typedef Parameter Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Defining ::New() static method */
itkNewMacro(Self);
/** RTTI support */
itkTypeMacro(OutputImageParameter,Parameter);
typedef float PixelType;
typedef otb::VectorImage<PixelType, 2> VectorImageType;
/** Set the value */
itkSetObjectMacro(Image, VectorImageType);
/** Get the value */
itkGetObjectMacro(Image, VectorImageType);
/** Return any value */
virtual boost::any GetAnyValue()
{
return boost::any(m_Image);
}
protected:
/** Constructor */
OutputImageParameter()
{
this->SetName("Output Image");
this->SetKey("out");
}
/** Destructor */
virtual ~OutputImageParameter()
{}
VectorImageType::Pointer m_Image;
private:
OutputImageParameter(const Parameter &); //purposely not implemented
void operator =(const Parameter&); //purposely not implemented
}; // End class OutputImage Parameter
} // End namespace Wrapper
} // End namespace otb
#endif
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbWrapperOutputVectorDataParameter_h
#define __otbWrapperOutputVectorDataParameter_h
#include "otbVectorData.h"
#include "otbWrapperParameter.h"
namespace otb
{
namespace Wrapper
{
/** \class OutputVectorDataParameter
* \brief This class represents a OutputVectorData parameter
*/
class ITK_EXPORT OutputVectorDataParameter : public Parameter
{
public:
/** Standard class typedef */
typedef OutputVectorDataParameter Self;
typedef Parameter Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Defining ::New() static method */
itkNewMacro(Self);
/** RTTI support */
itkTypeMacro(OutputVectorDataParameter,Parameter);
typedef double CoordinatePrecisionType;
typedef double ValuePrecisionType;
typedef otb::VectorData<CoordinatePrecisionType, 2, ValuePrecisionType> VectorDataType;
/** Set the value */
itkSetObjectMacro(VectorData, VectorDataType);
/** Get the value */
itkGetObjectMacro(VectorData, VectorDataType);
/** Return any value */
virtual boost::any GetAnyValue()
{
return boost::any(m_VectorData);
}
protected:
/** Constructor */
OutputVectorDataParameter()
{
this->SetName("Output Vector Data");
this->SetKey("outvd");
}
/** Destructor */
virtual ~OutputVectorDataParameter()
{}
VectorDataType::Pointer m_VectorData;
private:
OutputVectorDataParameter(const Parameter &); //purposely not implemented
void operator =(const Parameter&); //purposely not implemented
};
} // End namespace Wrapper
} // End namespace otb
#endif
......@@ -138,10 +138,6 @@ protected:
virtual ~Parameter()
{}
private:
Parameter(const Parameter &); //purposely not implemented
void operator =(const Parameter&); //purposely not implemented
/** Name of the parameter */
std::string m_Name;
......@@ -157,6 +153,10 @@ private:
/** Default value behaviour */
DefaultValueMode m_DefaultValueMode;
private:
Parameter(const Parameter &); //purposely not implemented
void operator =(const Parameter&); //purposely not implemented
}; // End class Parameter
} // End namespace Wrapper
......
......@@ -67,12 +67,12 @@ protected:
virtual ~ParameterGroup()
{}
std::vector<Parameter::Pointer> m_ParameterList;
private:
ParameterGroup(const ParameterGroup &); //purposely not implemented
void operator =(const ParameterGroup&); //purposely not implemented
std::vector<Parameter::Pointer> m_ParameterList;
};
}
......
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.