diff --git a/Code/Core/otbWrapperChoiceParameter.h b/Code/Core/otbWrapperChoiceParameter.h index b78d37d62a649dfdde13c796f3dd6845680f8df0..212164245a042659bb0a10994ef56be896ad2a69 100644 --- a/Code/Core/otbWrapperChoiceParameter.h +++ b/Code/Core/otbWrapperChoiceParameter.h @@ -37,7 +37,7 @@ class ChoiceParameter public: /** Standard class typedef */ typedef ChoiceParameter Self; - typedef itk::LightObject Superclass; + typedef Parameter Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -50,9 +50,36 @@ public: /** Add a value to the choice */ void AddChoice( std::string key, Parameter::Pointer param ) { - m_ChoiceMap[key] = param; + m_ChoiceList.push_back(std::make_pair(key, param)); } + Parameter::Pointer GetChoice( int i ) + { + return m_ChoiceList[i].second; + } + + unsigned int GetNbChoice( void ) + { + return m_ChoiceList.size(); + } + + /** Set any value */ + virtual void SetAnyValue(boost::any v) + { + // Perform any cast + m_CurrentChoice = boost::any_cast<bool>(v); + + // Call Modified(); + this->Modified(); + } + + /** Return any value */ + virtual boost::any GetAnyValue() + { + return boost::any(m_CurrentChoice); + } + + protected: /** Constructor */ ChoiceParameter() @@ -66,10 +93,12 @@ private: ChoiceParameter(const ChoiceParameter &); //purposely not implemented void operator =(const ChoiceParameter&); //purposely not implemented - typedef std::map<std::string, Parameter::Pointer> ChoiceMap; - ChoiceMap m_ChoiceMap; + typedef std::pair<std::string, Parameter::Pointer> Choice; + typedef std::vector<Choice> ChoiceList; + ChoiceList m_ChoiceList; + unsigned int m_CurrentChoice; }; // End class Parameter diff --git a/Code/Core/otbWrapperEmptyParameter.h b/Code/Core/otbWrapperEmptyParameter.h index 2a209b5c8784b5eb6589d35b969df24342b71b51..6a38ffd9a89e5efa329c065fedfb38b51140a45c 100644 --- a/Code/Core/otbWrapperEmptyParameter.h +++ b/Code/Core/otbWrapperEmptyParameter.h @@ -34,7 +34,7 @@ class EmptyParameter public: /** Standard class typedef */ typedef EmptyParameter Self; - typedef itk::LightObject Superclass; + typedef Parameter Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -44,6 +44,23 @@ public: /** RTTI support */ itkTypeMacro(EmptyParameter, Parameter); + /** Set any value */ + virtual void SetAnyValue(boost::any v) + { + // Perform any cast + m_Value = boost::any_cast<bool>(v); + + // Call Modified(); + this->Modified(); + } + + /** Return any value */ + virtual boost::any GetAnyValue() + { + return boost::any(m_Value); + } + + protected: /** Constructor */ EmptyParameter() @@ -57,6 +74,8 @@ private: EmptyParameter(const EmptyParameter &); //purposely not implemented void operator =(const EmptyParameter&); //purposely not implemented + bool m_Value; + }; // End class Parameter } // End namespace Wrapper diff --git a/Code/Core/otbWrapperInputImageParameter.h b/Code/Core/otbWrapperInputImageParameter.h new file mode 100644 index 0000000000000000000000000000000000000000..beeed86249fbbb00c2609bce7ccdba6c7c874c31 --- /dev/null +++ b/Code/Core/otbWrapperInputImageParameter.h @@ -0,0 +1,64 @@ +/*========================================================================= + + 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 __otbWrapperInputImageParameter_h +#define __otbWrapperInputImageParameter_h + +#include "otbWrapperParameter.h" + +namespace otb +{ +namespace Wrapper +{ +/** \class InputImageParameter + * \brief This class represents a InputImage parameter + */ + +class ITK_EXPORT InputImageParameter : public Parameter +{ +public: + /** Standard class typedef */ + typedef InputImageParameter Self; + typedef Parameter Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Defining ::New() static method */ + itkNewMacro(Self); + + /** RTTI support */ + itkTypeMacro(InputImageParameter,Parameter); + +protected: + /** Constructor */ + InputImageParameter() + {} + + /** Destructor */ + virtual ~InputImageParameter() + {} + +private: + InputImageParameter(const Parameter &); //purposely not implemented + void operator =(const Parameter&); //purposely not implemented + +}; // End class InputImage Parameter + +} // End namespace Wrapper +} // End namespace otb + +#endif diff --git a/Code/Core/otbWrapperNumericalParameter.h b/Code/Core/otbWrapperNumericalParameter.h index 35ee4caa68ee302e34b26c10b5ecfa091182d34a..8ac50d640744ca53eea0b6faa3744f862d89d72f 100644 --- a/Code/Core/otbWrapperNumericalParameter.h +++ b/Code/Core/otbWrapperNumericalParameter.h @@ -34,7 +34,7 @@ class ITK_EXPORT NumericalParameter : public Parameter public: /** Standard class typedef */ typedef NumericalParameter Self; - typedef itk::LightObject Superclass; + typedef Parameter Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -42,7 +42,7 @@ public: itkNewMacro(Self); /** RTTI support */ - itkTypeMacro(NumericalParameter,otb::Wrapper::Parameter); + itkTypeMacro(NumericalParameter,Parameter); /** Typedef of the scalar type */ typedef T ScalarType; diff --git a/Code/Core/otbWrapperStringParameter.h b/Code/Core/otbWrapperStringParameter.h index 7a4fb1c99f05cb7777c8923d6111059ff5101f12..7d5e0891a5a8918cd5a534c783d544b3343c9654 100644 --- a/Code/Core/otbWrapperStringParameter.h +++ b/Code/Core/otbWrapperStringParameter.h @@ -34,7 +34,7 @@ class StringParameter public: /** Standard class typedef */ typedef StringParameter Self; - typedef itk::LightObject Superclass; + typedef Parameter Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -44,6 +44,21 @@ public: /** RTTI support */ itkTypeMacro(StringParameter, 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); + } protected: /** Constructor */ diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameterFactory.cxx b/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameterFactory.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0e506e6669c8685f47464706058c777b22a0189d --- /dev/null +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameterFactory.cxx @@ -0,0 +1,69 @@ +/*========================================================================= + + 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. + +=========================================================================*/ + +#include "otbWrapperQtWidgetChoiceParameterFactory.h" +#include "otbWrapperChoiceParameter.h" + + +namespace otb +{ + +namespace Wrapper +{ + +QtWidgetChoiceParameterFactory::QtWidgetChoiceParameterFactory() +{ +} + +QtWidgetChoiceParameterFactory::~QtWidgetChoiceParameterFactory() +{ +} + +QWidget * QtWidgetChoiceParameterFactory::CreateQtWidget(Parameter * param) +{ + // Try to cast to choice parameter + ChoiceParameter * choiceParam = dynamic_cast<ChoiceParameter *>(param); + + // Check if dynamic cast succeeds + if(!choiceParam) + { + return 0; + } + + // Set up input text edit + QHBoxLayout *hLayout = new QHBoxLayout; + hLayout->setSpacing(0); + hLayout->setContentsMargins(0,0,0,0); + + QComboBox* combobox = new QComboBox; + combobox->setToolTip(choiceParam->GetDescription()); + + + for (unsigned int i = 0; i < choiceParam->GetNbChoice(); ++i) + { + combobox->addItem( "test", QVariant("test") ); + } + + hLayout->addWidget(combobox); + QGroupBox *paramHGroup = new QGroupBox; + paramHGroup->setLayout(hLayout); + return paramHGroup; + +} +} +} diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameterFactory.h b/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameterFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..7211a431fc6d1ddf2014c1824b648bc273257229 --- /dev/null +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameterFactory.h @@ -0,0 +1,59 @@ +/*========================================================================= + + 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 __otbWrapperQtWidgetChoiceParameterFactory_h +#define __otbWrapperQtWidgetChoiceParameterFactory_h + +#include "otbWrapperChoiceParameter.h" +#include "otbWrapperQtWidgetParameterFactory.h" + +namespace otb +{ +namespace Wrapper +{ + +class QtWidgetChoiceParameterFactory +: public QtWidgetParameterFactory +{ +public: + /** Standard class typedef */ + typedef QtWidgetChoiceParameterFactory Self; + typedef QtWidgetParameterFactory Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Defining ::New() static method */ + itkNewMacro(Self); + + /** RTTI support */ + itkTypeMacro(QtWidgetChoiceParameterFactory,otb::Wrapper::QtWidgetParameterFactory); + + /** Create the appropriate ImageIO depending on the particulars of the file. */ + static QWidget * CreateQtWidget(Parameter * param); + +protected: + QtWidgetChoiceParameterFactory(); + virtual ~QtWidgetChoiceParameterFactory(); + +private: + QtWidgetChoiceParameterFactory(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented +}; +} +} + +#endif diff --git a/Testing/CMakeLists.txt b/Testing/CMakeLists.txt index 823a4a6de944cf7d0cc353359640421b8fb8d45e..1eeced66817c7845e07d3bfe36ac72480fb5c273 100644 --- a/Testing/CMakeLists.txt +++ b/Testing/CMakeLists.txt @@ -38,7 +38,12 @@ ADD_TEST(owTvNumericalParameter ${OTB_WRAPPER_TESTS} "mykey" "my description" ) - + +# Input Image parameter class test +ADD_TEST(owTuInputImageParameter ${OTB_WRAPPER_TESTS} + otbWrapperInputImageParameterNew + ) + # Application class test ADD_TEST(owTuApplication ${OTB_WRAPPER_TESTS} otbWrapperApplicationNew @@ -60,6 +65,7 @@ otbWrapperNumericalParameterTest.cxx otbWrapperEmptyParameterTest.cxx otbWrapperApplicationTest.cxx otbWrapperParameterListTest.cxx +otbWrapperInputImageParameterTest.cxx ) ADD_EXECUTABLE(otbWrapperTests ${Wrapper_SRCS}) diff --git a/Testing/otbWrapperInputImageParameterTest.cxx b/Testing/otbWrapperInputImageParameterTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..194c4f2cea7707be881c59117dd76db0a6623e24 --- /dev/null +++ b/Testing/otbWrapperInputImageParameterTest.cxx @@ -0,0 +1,30 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "otbWrapperInputImageParameter.h" + +int otbWrapperInputImageParameterNew(int argc, char* argv[]) +{ + typedef otb::Wrapper::InputImageParameter InputImageParameterType; + InputImageParameterType::Pointer parameter = InputImageParameterType::New(); + + return EXIT_SUCCESS; +} diff --git a/Testing/otbWrapperTests.cxx b/Testing/otbWrapperTests.cxx index 80a054292bd458cd6e228e1663027bddb4e754f9..92203eca4d873d74234296b4f3e900e04c0ce6ce 100644 --- a/Testing/otbWrapperTests.cxx +++ b/Testing/otbWrapperTests.cxx @@ -33,4 +33,5 @@ void RegisterTests() REGISTER_TEST(otbWrapperEmptyParameterNew); REGISTER_TEST(otbWrapperApplicationNew); REGISTER_TEST(otbWrapperParameterListNew); + REGISTER_TEST(otbWrapperInputImageParameterNew); }