From a2255bfd3dc91ae1ae242634589f4843cb372651 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@orfeo-toolbox.org> Date: Mon, 28 Mar 2011 17:26:49 +0200 Subject: [PATCH] ENH: Adding factory for float params --- ...tbWrapperQtWidgetFloatParameterFactory.cxx | 65 +++++++++++++++++++ .../otbWrapperQtWidgetFloatParameterFactory.h | 59 +++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 Code/Wrappers/QtWidget/otbWrapperQtWidgetFloatParameterFactory.cxx create mode 100644 Code/Wrappers/QtWidget/otbWrapperQtWidgetFloatParameterFactory.h diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetFloatParameterFactory.cxx b/Code/Wrappers/QtWidget/otbWrapperQtWidgetFloatParameterFactory.cxx new file mode 100644 index 0000000000..902a82bc93 --- /dev/null +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetFloatParameterFactory.cxx @@ -0,0 +1,65 @@ +/*========================================================================= + + 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 "otbWrapperQtWidgetFloatParameterFactory.h" +#include "otbWrapperNumericalParameter.h" + + +namespace otb +{ + +namespace Wrapper +{ + +QtWidgetFloatParameterFactory::QtWidgetFloatParameterFactory() +{} + +QtWidgetFloatParameterFactory::~QtWidgetFloatParameterFactory() +{} + +QWidget * QtWidgetFloatParameterFactory::CreateQtWidget(Parameter * param) +{ + // Try to cast to int parameter + FloatParameter * floatParam = dynamic_cast<FloatParameter *>(param); + + // Check if dynamic cast succeeds + if(!param) + { + return 0; + } + + // Set up input text edit + QHBoxLayout *hLayout = new QHBoxLayout; + hLayout->setSpacing(0); + hLayout->setContentsMargins(0,0,0,0); + + QDoubleSpinBox* input = new QDoubleSpinBox; + input->setDecimals(5); + input->setRange(floatParam->GetMinimumValue(), floatParam->GetMaximumValue()); + input->setToolTip(floatParam->GetDescription()); + + QString optionID(floatParam->GetName()); + hLayout->addWidget(input); + hLayout->addStretch(); + + QGroupBox *paramHGroup = new QGroupBox; + paramHGroup->setLayout(hLayout); + return paramHGroup; +} +} +} diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetFloatParameterFactory.h b/Code/Wrappers/QtWidget/otbWrapperQtWidgetFloatParameterFactory.h new file mode 100644 index 0000000000..23b30d5a32 --- /dev/null +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetFloatParameterFactory.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 __otbWrapperQtWidgetFloatParameterFactory_h +#define __otbWrapperQtWidgetFloatParameterFactory_h + +#include "otbWrapperNumericalParameter.h" +#include "otbWrapperQtWidgetParameterFactory.h" + +namespace otb +{ +namespace Wrapper +{ + +class QtWidgetFloatParameterFactory +: public QtWidgetParameterFactory +{ +public: + /** Standard class typedef */ + typedef QtWidgetFloatParameterFactory Self; + typedef QtWidgetParameterFactory Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Defining ::New() static method */ + itkNewMacro(Self); + + /** RTTI support */ + itkTypeMacro(QtWidgetFloatParameterFactory,otb::Wrapper::QtWidgetParameterFactory); + + /** Create the appropriate ImageIO depending on the particulars of the file. */ + static QWidget * CreateQtWidget(Parameter * param); + +protected: + QtWidgetFloatParameterFactory(); + ~QtWidgetFloatParameterFactory(); + +private: + QtWidgetFloatParameterFactory(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented +}; +} +} + +#endif -- GitLab