Skip to content
Snippets Groups Projects
Commit 559a8725 authored by Julien Malik's avatar Julien Malik
Browse files

ENH: on the road for first version

parent 46bf74c1
Branches
Tags
No related merge requests found
Showing
with 810 additions and 86 deletions
......@@ -41,14 +41,8 @@ IF(WIN32)
ENDIF(WIN32)
# Link to the Orfeo ToolBox
FIND_PACKAGE(OTB PATHS /usr/lib/otb)
IF(OTB_FOUND)
INCLUDE(${OTB_USE_FILE})
ELSE(OTB_FOUND)
MESSAGE(FATAL_ERROR
"OTB not found. Please set OTB_DIR")
ENDIF(OTB_FOUND)
FIND_PACKAGE(OTB REQUIRED PATHS /usr/lib/otb )
INCLUDE(${OTB_USE_FILE})
OPTION(OTB_USE_QT "Generate Qt wrappers for Applications" ON)
......
......@@ -17,7 +17,6 @@
=========================================================================*/
#include "otbWrapperApplication.h"
namespace otb
{
namespace Wrapper
......@@ -28,7 +27,24 @@ Application::Application(): m_Name(""), m_Description("")
}
Application::~Application()
{}
{
}
void Application::Init()
{
m_ParameterList = ParameterGroup::New();
this->DoCreateParameters();
}
void Application::UpdateParameters()
{
this->DoUpdateParameters();
}
void Application::Execute()
{
this->DoExecute();
}
}
}
......
......@@ -21,9 +21,24 @@
#include <string>
#include "otbMacro.h"
#include "itkObject.h"
#include "otbWrapperParameterList.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
......@@ -61,23 +76,13 @@ public:
/** Get the parameter description */
itkGetStringMacro(Description);
void Init()
{
m_ParameterList = ParameterList::New();
this->DoCreateParameters();
}
void Init();
void UpdateParameters()
{
this->DoUpdateParameters();
}
void UpdateParameters();
void Execute()
{
this->DoExecute();
}
void Execute();
ParameterList* GetParameterList()
ParameterGroup* GetParameterList()
{
return m_ParameterList;
}
......@@ -88,20 +93,19 @@ 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
std::string m_Name;
std::string m_Description;
ParameterList::Pointer m_ParameterList;
ParameterGroup::Pointer m_ParameterList;
}; //end class
......
......@@ -19,6 +19,7 @@
#define __otbWrapperChoiceParameter_h
#include "otbWrapperParameter.h"
#include "otbWrapperParameterGroup.h"
namespace otb
{
......@@ -48,19 +49,39 @@ public:
itkTypeMacro(ChoiceParameter, Parameter);
/** Add a value to the choice */
void AddChoice( std::string key, Parameter::Pointer param )
void AddChoice( std::string key, std::string name, Parameter* param )
{
m_ChoiceList.push_back(std::make_pair(key, param));
ParameterGroup* paramAsGroup = dynamic_cast<ParameterGroup*>(param);
if ( paramAsGroup != 0 )
{
Choice choice;
choice.m_Key = key;
choice.m_Name = name;
choice.m_AssociatedParameter = paramAsGroup;
m_ChoiceList.push_back(choice);
}
else
{
// wrap in group first
ParameterGroup::Pointer group = ParameterGroup::New();
group->AddParameter(param);
AddChoice(key, name, group.GetPointer());
}
}
std::string GetChoiceKey( int i )
{
return m_ChoiceList[i].first;
return m_ChoiceList[i].m_Key;
}
Parameter::Pointer GetChoiceAssociatedParameter( int i )
std::string GetChoiceName( int i )
{
return m_ChoiceList[i].second;
return m_ChoiceList[i].m_Name;
}
ParameterGroup::Pointer GetChoiceAssociatedParameter( int i )
{
return m_ChoiceList[i].m_AssociatedParameter;
}
unsigned int GetNbChoices( void )
......@@ -73,7 +94,6 @@ public:
{
// Perform any cast
m_CurrentChoice = v;
// Call Modified();
this->Modified();
}
......@@ -88,7 +108,14 @@ public:
virtual void SetAnyValue(boost::any v)
{
// Perform any cast
m_CurrentChoice = boost::any_cast<unsigned int>(v);
unsigned int val = boost::any_cast<unsigned int>(v);
if ( val >= GetNbChoices() )
{
itkExceptionMacro(<< "Invalid choice value : " << val)
}
m_CurrentChoice = val;
// Call Modified();
this->Modified();
......@@ -104,23 +131,31 @@ public:
protected:
/** Constructor */
ChoiceParameter()
: m_CurrentChoice(0)
{}
/** Destructor */
~ChoiceParameter()
virtual ~ChoiceParameter()
{}
private:
ChoiceParameter(const ChoiceParameter &); //purposely not implemented
void operator =(const ChoiceParameter&); //purposely not implemented
struct Choice
{
Choice() {}
typedef std::pair<std::string, Parameter::Pointer> Choice;
std::string m_Key;
std::string m_Name;
ParameterGroup::Pointer m_AssociatedParameter;
};
typedef std::vector<Choice> ChoiceList;
ChoiceList m_ChoiceList;
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
......@@ -18,6 +18,9 @@
#ifndef __otbWrapperInputImageParameter_h
#define __otbWrapperInputImageParameter_h
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
#include "otbWrapperParameter.h"
namespace otb
......@@ -43,15 +46,47 @@ public:
/** RTTI support */
itkTypeMacro(InputImageParameter,Parameter);
typedef float PixelType;
typedef otb::VectorImage<PixelType, 2> VectorImageType;
/** Set the value */
itkSetObjectMacro(Image, VectorImageType);
/** 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_Reader = reader;
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;
itk::ProcessObject::Pointer m_Reader;
private:
InputImageParameter(const Parameter &); //purposely not implemented
void operator =(const Parameter&); //purposely not implemented
......
/*=========================================================================
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 __otbWrapperInputVectorDataParameter_h
#define __otbWrapperInputVectorDataParameter_h
#include "otbVectorData.h"
#include "otbWrapperParameter.h"
namespace otb
{
namespace Wrapper
{
/** \class InputVectorDataParameter
* \brief This class represents a InputVectorData parameter
*/
class ITK_EXPORT InputVectorDataParameter : public Parameter
{
public:
/** Standard class typedef */
typedef InputVectorDataParameter Self;
typedef Parameter Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Defining ::New() static method */
itkNewMacro(Self);
/** RTTI support */
itkTypeMacro(InputVectorDataParameter,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 */
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
};
} // End namespace Wrapper
} // End namespace otb
#endif
......@@ -57,7 +57,7 @@ public:
virtual void SetAnyValue(boost::any v)
{
// Perform any cast
m_Value=boost::any_cast<T>(v);
m_Value = boost::any_cast<T>(v);
// Call Modified();
this->Modified();
......@@ -97,19 +97,15 @@ protected:
/** Constructor */
NumericalParameter()
: m_Value(itk::NumericTraits<T>::Zero),
m_DefaultValue(itk::NumericTraits<T>::Zero),
m_MinimumValue(itk::NumericTraits<T>::min()),
m_MaximumValue(itk::NumericTraits<T>::max())
m_DefaultValue(itk::NumericTraits<T>::Zero),
m_MinimumValue(itk::NumericTraits<T>::min()),
m_MaximumValue(itk::NumericTraits<T>::max())
{}
/** Destructor */
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);
}
/** Return any value */
void SetValue(VectorImageType* image)
{
m_Image = image;
}
/** Return any value */
VectorImageType* GetValue( void )
{
return m_Image;
}
itkSetStringMacro(FileName);
itkGetStringMacro(FileName);
protected:
/** Constructor */
OutputImageParameter()
{
this->SetName("Output Image");
this->SetKey("out");
}
/** Destructor */
virtual ~OutputImageParameter()
{}
VectorImageType::Pointer m_Image;
std::string m_FileName;
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
......
......@@ -15,8 +15,8 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbWrapperParameterList_h
#define __otbWrapperParameterList_h
#ifndef __otbWrapperParameterGroup_h
#define __otbWrapperParameterGroup_h
#include "itkObject.h"
#include "otbWrapperParameter.h"
......@@ -28,13 +28,13 @@ namespace Wrapper
{
/**
* \class WrapperParameterList
* \class Group
*/
class ITK_EXPORT ParameterList
class ITK_EXPORT ParameterGroup
: public Parameter
{
public:
typedef ParameterList Self;
typedef ParameterGroup Self;
typedef Parameter Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
......@@ -61,18 +61,18 @@ public:
}
protected:
ParameterList()
ParameterGroup()
{}
virtual ~ParameterList()
virtual ~ParameterGroup()
{}
private:
ParameterList(const ParameterList &); //purposely not implemented
void operator =(const ParameterList&); //purposely not implemented
std::vector<Parameter::Pointer> m_ParameterList;
private:
ParameterGroup(const ParameterGroup &); //purposely not implemented
void operator =(const ParameterGroup&); //purposely not implemented
};
}
......
/*=========================================================================
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 __otbWrapperRadiusParameter_h
#define __otbWrapperRadiusParameter_h
#include "otbWrapperNumericalParameter.h"
namespace otb
{
namespace Wrapper
{
/** \class StringParameter
* \brief This class represent a radius parameter for the wrapper framework
*/
class RadiusParameter
: public NumericalParameter<int>
{
public:
/** Standard class typedef */
typedef RadiusParameter Self;
typedef Parameter Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Defining ::New() static method */
itkNewMacro(Self);
/** RTTI support */
itkTypeMacro(RadiusParameter, Parameter);
protected:
/** Constructor */
RadiusParameter()
{
this->SetName("Radius");
this->SetKey("r");
}
/** Destructor */
virtual ~RadiusParameter()
{}
private:
RadiusParameter(const RadiusParameter &); //purposely not implemented
void operator =(const RadiusParameter&); //purposely not implemented
};
} // End namespace Wrapper
} // End namespace otb
#endif
......@@ -18,6 +18,7 @@
#ifndef __otbWrapperStringParameter_h
#define __otbWrapperStringParameter_h
#include <string>
#include "otbWrapperParameter.h"
namespace otb
......@@ -75,12 +76,12 @@ protected:
virtual ~StringParameter()
{}
std::string m_Value;
private:
StringParameter(const StringParameter &); //purposely not implemented
void operator =(const StringParameter&); //purposely not implemented
std::string m_Value;
}; // End class Parameter
} // End namespace Wrapper
......
......@@ -7,6 +7,8 @@ SET( WrappersQtWidget_MOC_HDR
otbWrapperQtWidgetIntParameter.h
otbWrapperQtWidgetStringParameter.h
otbWrapperQtWidgetChoiceParameter.h
otbWrapperQtWidgetInputImageParameter.h
otbWrapperQtWidgetOutputImageParameter.h
otbWrapperQtWidgetParameterGroup.h
otbWrapperQtWidgetParameterLabel.h
otbWrapperQtWidgetParameterBase.h
......
......@@ -17,6 +17,9 @@
=========================================================================*/
#include "otbWrapperQtWidgetChoiceParameter.h"
#include "otbWrapperQtWidgetParameterLabel.h"
#include "otbWrapperQtWidgetParameterFactory.h"
namespace otb
{
namespace Wrapper
......@@ -26,42 +29,62 @@ QtWidgetChoiceParameter::QtWidgetChoiceParameter(ChoiceParameter* param, QtWidge
: QtWidgetParameterBase(m),
m_ChoiceParam(param)
{
this->CreateWidget();
}
QtWidgetChoiceParameter::~QtWidgetChoiceParameter()
{
}
void QtWidgetChoiceParameter::DoUpdateGUI()
{
// Update the combobox value
unsigned int value = m_ChoiceParam->GetValue( );
m_ComboBox->setCurrentIndex(value);
// Update the choice subparameters
WidgetListIteratorType it = m_WidgetList.begin();
for (it = m_WidgetList.begin(); it != m_WidgetList.end(); ++it)
{
(*it)->UpdateGUI();
}
}
void QtWidgetChoiceParameter::CreateWidget()
void QtWidgetChoiceParameter::DoCreateWidget()
{
// Set up input text edit
QHBoxLayout *hLayout = new QHBoxLayout;
hLayout->setSpacing(0);
hLayout->setContentsMargins(0,0,0,0);
m_ComboBox = new QComboBox;
m_ComboBox->setToolTip(m_ChoiceParam->GetDescription());
QComboBox* combobox = new QComboBox;
combobox->setToolTip(m_ChoiceParam->GetDescription());
m_StackWidget = new QStackedWidget;
for (unsigned int i = 0; i < m_ChoiceParam->GetNbChoices(); ++i)
{
QString key = QString::fromStdString( m_ChoiceParam->GetChoiceKey(i) );
combobox->addItem( key, QVariant(key) );
QString key = QString::fromStdString( m_ChoiceParam->GetChoiceName(i) );
m_ComboBox->addItem( key, QVariant(key) );
ParameterGroup::Pointer param = m_ChoiceParam->GetChoiceAssociatedParameter(i);
if (param.IsNotNull())
{
QtWidgetParameterBase* widget = QtWidgetParameterFactory::CreateQtWidget( param, GetModel() );
m_StackWidget->addWidget(widget);
m_WidgetList.push_back(widget);
}
}
connect( combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(SetValue(int)) );
connect( m_ComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(SetValue(int)) );
connect( m_ComboBox, SIGNAL(currentIndexChanged(int)), m_StackWidget, SLOT(setCurrentIndex(int)) );
hLayout->addWidget(combobox);
this->setLayout(hLayout);
m_VLayout = new QVBoxLayout;
m_VLayout->addWidget(m_ComboBox);
m_VLayout->addWidget(m_StackWidget);
m_VLayout->addStretch();
this->setLayout(m_VLayout);
}
void QtWidgetChoiceParameter::SetValue(int value)
{
std::cout << "QtWidgetChoiceParameter::SetValue " << value << std::endl;
m_ChoiceParam->SetValue( value );
}
}
}
......@@ -20,6 +20,7 @@
#include <QtGui>
#include "otbWrapperChoiceParameter.h"
#include "otbWrapperParameterGroup.h"
#include "otbWrapperQtWidgetParameterBase.h"
namespace otb
......@@ -44,11 +45,24 @@ private:
QtWidgetChoiceParameter(const QtWidgetChoiceParameter&); //purposely not implemented
void operator=(const QtWidgetChoiceParameter&); //purposely not implemented
void CreateWidget();
virtual void DoCreateWidget();
virtual void DoUpdateGUI();
ChoiceParameter::Pointer m_ChoiceParam;
};
QHBoxLayout* m_MainHLayout;
QComboBox* m_ComboBox;
QStackedWidget* m_StackWidget;
QVBoxLayout* m_VLayout;
QGroupBox* m_VLayoutGroup;
typedef std::vector<QtWidgetParameterBase*> WidgetListType;
typedef WidgetListType::iterator WidgetListIteratorType;
WidgetListType m_WidgetList;
};
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment