diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetInputVectorDataParameter.cxx b/Code/Wrappers/QtWidget/otbWrapperQtWidgetInputVectorDataParameter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3fa568e4d76152bff00cd77a9c389827d41a996a --- /dev/null +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetInputVectorDataParameter.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 "otbWrapperQtWidgetInputVectorDataParameter.h" + +namespace otb +{ +namespace Wrapper +{ + +QtWidgetInputVectorDataParameter::QtWidgetInputVectorDataParameter(InputVectorDataParameter* param, QtWidgetModel* m) +: QtWidgetParameterBase(param, m), + m_InputVectorDataParam(param) +{ +} + +QtWidgetInputVectorDataParameter::~QtWidgetInputVectorDataParameter() +{ +} + +void QtWidgetInputVectorDataParameter::DoUpdateGUI() +{ + +} + +void QtWidgetInputVectorDataParameter::DoCreateWidget() +{ + // Set up input text edit + m_HLayout = new QHBoxLayout; + m_HLayout->setSpacing(0); + m_HLayout->setContentsMargins(0, 0, 0, 0); + m_Input = new QLineEdit; + m_Input->setToolTip( m_InputVectorDataParam->GetDescription() ); + connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) ); + connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) ); + + m_HLayout->addWidget(m_Input); + + // Set up input text edit + m_Button = new QPushButton; + m_Button->setText("..."); + m_Button->setToolTip("Select file..."); + m_Button->setMaximumWidth(m_Button->width()); + connect( m_Button, SIGNAL(clicked()), this, SLOT(SelectFile()) ); + m_HLayout->addWidget(m_Button); + + this->setLayout(m_HLayout); +} + +void QtWidgetInputVectorDataParameter::SelectFile() +{ + QFileDialog fileDialog; + fileDialog.setConfirmOverwrite(true); + fileDialog.setFileMode(QFileDialog::ExistingFile); + fileDialog.setNameFilter("Vector data files (*)"); + + if (fileDialog.exec()) + { + if ( this->SetFileName(fileDialog.selectedFiles().at(0)) == false ) + m_Input->setText(fileDialog.selectedFiles().at(0)); + } +} + +void QtWidgetInputVectorDataParameter::SetFileName(const QString& value) +{ + // save value + if(m_InputVectorDataParam->SetFromFileName(value.toStdString()) == false ) + { + // notify of value change + QString key( QString::fromStdString(m_InputVectorDataParam->GetKey()) ); + emit ParameterChanged(key); + } +} + +} +} diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetInputVectorDataParameter.h b/Code/Wrappers/QtWidget/otbWrapperQtWidgetInputVectorDataParameter.h new file mode 100644 index 0000000000000000000000000000000000000000..149b011e743f86cded44a44ac30255e092c2697e --- /dev/null +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetInputVectorDataParameter.h @@ -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. + +=========================================================================*/ +#ifndef __otbWrapperQtWidgetInputVectorDataParameter_h +#define __otbWrapperQtWidgetInputVectorDataParameter_h + +#include <QtGui> +#include "otbWrapperInputVectorDataParameter.h" +#include "otbWrapperQtWidgetParameterBase.h" + + +namespace otb +{ +namespace Wrapper +{ + +/** \class + * \brief + */ +class QtWidgetInputVectorDataParameter : public QtWidgetParameterBase +{ + Q_OBJECT +public: + QtWidgetInputVectorDataParameter(InputVectorDataParameter*, QtWidgetModel*); + virtual ~QtWidgetInputVectorDataParameter(); + +protected slots: + void SetFileName( const QString& value ); + void SelectFile(); + +private: + QtWidgetInputVectorDataParameter(const QtWidgetInputVectorDataParameter&); //purposely not implemented + void operator=(const QtWidgetInputVectorDataParameter&); //purposely not implemented + + virtual void DoCreateWidget(); + + virtual void DoUpdateGUI(); + + + InputVectorDataParameter::Pointer m_InputVectorDataParam; + + QHBoxLayout * m_HLayout; + QLineEdit* m_Input; + QPushButton * m_Button; +}; + + +} +} + +#endif