diff --git a/Code/Wrappers/QtWidget/CMakeLists.txt b/Code/Wrappers/QtWidget/CMakeLists.txt index 70aa6eda14cf509686d1686beea109e740d5da6f..517f938eb89062493ef74561690d1233cec8453b 100644 --- a/Code/Wrappers/QtWidget/CMakeLists.txt +++ b/Code/Wrappers/QtWidget/CMakeLists.txt @@ -27,6 +27,7 @@ set( WrappersQtWidget_MOC_HDR otbQtLogOutput.h otbWrapperQtWidgetDirectoryParameter.h otbWrapperQtWidgetSimpleProgressReport.h + otbWrapperQtWidgetRAMParameter.h ) QT4_WRAP_CPP(WrappersQtWidget_MOC_SRC ${WrappersQtWidget_MOC_HDR}) diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetRAMParameter.cxx b/Code/Wrappers/QtWidget/otbWrapperQtWidgetRAMParameter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..590fb2a4da1e704b4148e47450890de3a501fd62 --- /dev/null +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetRAMParameter.cxx @@ -0,0 +1,90 @@ +/*========================================================================= + + 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 "otbWrapperQtWidgetRAMParameter.h" + +namespace otb +{ +namespace Wrapper +{ + +QtWidgetRAMParameter::QtWidgetRAMParameter(RAMParameter* param, QtWidgetModel* m) +: QtWidgetParameterBase(param, m), + m_RAMParam(param) +{ +} + +QtWidgetRAMParameter::~QtWidgetRAMParameter() +{ +} + +void QtWidgetRAMParameter::DoCreateWidget() +{ + // Set up input text edit + m_QHBoxLayout = new QHBoxLayout; + m_QHBoxLayout->setSpacing(0); + m_QHBoxLayout->setContentsMargins(0, 0, 0, 0); + + m_QSpinBox = new QSpinBox; +// m_QSpinBox->setRange(m_RAMParam->GetMinimumValue(), m_RAMParam->GetMaximumValue()); + m_QSpinBox->setToolTip(m_RAMParam->GetDescription()); + + connect( m_QSpinBox, SIGNAL(valueChanged(int)), this, SLOT(SetValue(int)) ); + connect( m_QSpinBox, SIGNAL(valueChanged(int)), GetModel(), SLOT(NotifyUpdate()) ); + connect( GetModel(), SIGNAL(UpdateGui()), this, SLOT(UpdateGUI() ) ); + + m_QHBoxLayout->addWidget(m_QSpinBox); + m_QHBoxLayout->addStretch(); + + this->setLayout(m_QHBoxLayout); +} + +void QtWidgetRAMParameter::DoUpdateGUI() +{ +// // Update the valid range if updated +// m_QSpinBox->setRange((int)(m_RAMParam->GetMinimumValue()), +// (int)(m_RAMParam->GetMaximumValue())); + + bool signalsBlocked = m_QSpinBox->blockSignals( true ); + + if (m_RAMParam->HasValue()) + { + m_QSpinBox->setValue(static_cast<int>(m_RAMParam->GetValue())); + } + m_QSpinBox->blockSignals( signalsBlocked ); + + QFont font = m_QSpinBox->font(); + if (m_RAMParam->HasUserValue()) + { + font.setBold(true); + } + else + { + font.setBold(false); + } + m_QSpinBox->setFont(font); +} + +void QtWidgetRAMParameter::SetValue(int value) +{ + m_RAMParam->SetValue(static_cast<unsigned int>(value)); + m_RAMParam->SetUserValue(true); + m_RAMParam->SetAutomaticValue(false); +} + +} +} diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetRAMParameter.h b/Code/Wrappers/QtWidget/otbWrapperQtWidgetRAMParameter.h new file mode 100644 index 0000000000000000000000000000000000000000..8101af90a4a57cb2f756343dcfe73871c983e204 --- /dev/null +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetRAMParameter.h @@ -0,0 +1,62 @@ +/*========================================================================= + + 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 __otbWrapperQtWidgetRAMParameter_h +#define __otbWrapperQtWidgetRAMParameter_h + +#include <QtGui> +#include "otbWrapperRAMParameter.h" +#include "otbWrapperQtWidgetParameterBase.h" + + +namespace otb +{ +namespace Wrapper +{ + +/** \class + * \brief + */ +class QtWidgetRAMParameter : public QtWidgetParameterBase +{ + Q_OBJECT +public: + QtWidgetRAMParameter(RAMParameter*, QtWidgetModel*); + virtual ~QtWidgetRAMParameter(); + +protected slots: + void SetValue( int value ); + +private: + QtWidgetRAMParameter(const QtWidgetRAMParameter&); //purposely not implemented + void operator=(const QtWidgetRAMParameter&); //purposely not implemented + + virtual void DoCreateWidget(); + + virtual void DoUpdateGUI(); + + QHBoxLayout * m_QHBoxLayout; + QSpinBox * m_QSpinBox; + + RAMParameter::Pointer m_RAMParam; +}; + + +} +} + +#endif