From 8e013ff92e3baeef233ac6b55ffe5606d8f8fd60 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@orfeo-toolbox.org> Date: Mon, 28 Mar 2011 17:06:39 +0200 Subject: [PATCH] ENH: Adding a factory for int parameters --- .../otbWrapperQtWidgetIntParameterFactory.cxx | 63 +++++++++++++++++++ .../otbWrapperQtWidgetIntParameterFactory.h | 59 +++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 Code/Wrappers/QtWidget/otbWrapperQtWidgetIntParameterFactory.cxx create mode 100644 Code/Wrappers/QtWidget/otbWrapperQtWidgetIntParameterFactory.h diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetIntParameterFactory.cxx b/Code/Wrappers/QtWidget/otbWrapperQtWidgetIntParameterFactory.cxx new file mode 100644 index 0000000000..d455ae79d2 --- /dev/null +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetIntParameterFactory.cxx @@ -0,0 +1,63 @@ +/*========================================================================= + + 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 "otbWrapperQtWidgetIntParameterFactory.h" +#include "otbWrapperNumericalParameter.h" + + +namespace otb +{ + +namespace Wrapper +{ + +QtWidgetIntParameterFactory::QtWidgetIntParameterFactory() +{} + +QtWidgetIntParameterFactory::~QtWidgetIntParameterFactory() +{} + +static QWidget * QtWidgetIntParameterFactory::CreateQtWidget(Parameter * param) +{ + // Try to cast to int parameter + IntParameter * intParam = dynamic_cast<IntParameter *>(param); + + // Check if dynamic cast succeeds + if(param.IsNull()) + { + return 0; + } + + // Set up input text edit + QHBoxLayout *hLayout = new QHBoxLayout; + hLayout->setSpacing(0); + hLayout->setContentsMargins(0,0,0,0); + + QSpinBox* input = new QSpinBox; + input->setRange(intParam->GetMinimumValue(), intParam->GetMaximumValue()); + input->setToolTip(intParam->GetDescription().c_str()); + + QString optionID(intParam->GetName().c_str()); + + hLayout->addWidget(input); + hLayout->addStretch(); + + QGroupBox *paramHGroup = new QGroupBox; + paramHGroup->setLayout(hLayout); + return paramHGroup; +} diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetIntParameterFactory.h b/Code/Wrappers/QtWidget/otbWrapperQtWidgetIntParameterFactory.h new file mode 100644 index 0000000000..77016685bd --- /dev/null +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetIntParameterFactory.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 __otbWrapperQtWidgetIntParameterFactory_h +#define __otbWrapperQtWidgetIntParameterFactory_h + +#include "otbWrapperNumericalParameter.h" +#include "otbWrapperQtWidgetParameterFactory.h" + +namespace otb +{ +namespace Wrapper +{ + +class QtWidgetIntParameterFactory +: public QtWidgetParameterFactory +{ +public: + /** Standard class typedef */ + typedef QtWidgetIntParameterFactory Self; + typedef QtWidgetParameterFactory Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Defining ::New() static method */ + itkNewMacro(Self); + + /** RTTI support */ + itkTypeMacro(QtWidgetIntParameterFactory,otb::Wrapper::QtWidgetParameterFactory); + + /** Create the appropriate ImageIO depending on the particulars of the file. */ + static QWidget * CreateQtWidget(Parameter * param); + +protected: + QtWidgetIntParameterFactory(); + ~QtWidgetIntParameterFactory(); + +private: + QtWidgeIntParameterFactory(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented +}; +} +} + +#endif -- GitLab