Skip to content
Snippets Groups Projects
Commit 8e013ff9 authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Adding a factory for int parameters

parent 0768fb2b
Branches
Tags
No related merge requests found
/*=========================================================================
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;
}
/*=========================================================================
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment