Commit 9b5f51d0 authored by Cyrille Valladeau's avatar Cyrille Valladeau

Qt Input image list in progress

parent ec6e4e52
......@@ -81,6 +81,22 @@ public:
this->Modified();
}
/** Set one specific stored image filename. */
void SetNthFileName( const unsigned int id, const std::string & filename )
{
if( m_ReaderList->Size()<id )
{
itkExceptionMacro(<< "No image "<<id<<". Only "<<m_ReaderList->Size()<<" images available.");
}
ImageFileReaderType::Pointer reader = ImageFileReaderType::New();
reader->SetFileName(filename);
reader->UpdateOutputInformation();
m_ReaderList->SetNthElement(id, reader);
m_ImageList->SetNthElement(id, reader->GetOutput());
}
/** Get the stored image filename list */
std::vector<std::string> GetFileNameList() const
{
......
......@@ -8,6 +8,7 @@ set( WrappersQtWidget_MOC_HDR
otbWrapperQtWidgetStringParameter.h
otbWrapperQtWidgetChoiceParameter.h
otbWrapperQtWidgetInputImageParameter.h
otbWrapperQtWidgetInputImageListParameter.h
otbWrapperQtWidgetOutputImageParameter.h
otbWrapperQtWidgetParameterGroup.h
otbWrapperQtWidgetParameterLabel.h
......@@ -16,8 +17,9 @@ set( WrappersQtWidget_MOC_HDR
otbWrapperQtWidgetView.h
otbWrapperQtWidgetProgressReport.h
otbWrapperQtWidgetListViewParameter.h
otbQtFileSelectionWidget.h
itkQtProgressBar.h
)
)
QT4_WRAP_CPP(WrappersQtWidget_MOC_SRC ${WrappersQtWidget_MOC_HDR})
......
/*=========================================================================
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 "otbQtFileSelectionWidget.h"
namespace otb
{
namespace Wrapper
{
QtFileSelectionWidget::QtFileSelectionWidget()
: QWidget(), m_Index(0), m_AsValue(false)
{
m_InputList = InputImageListParameter::New();
this->DoCreateWidget();
}
QtFileSelectionWidget::QtFileSelectionWidget( InputImageListParameter * il )
: QWidget(), m_Index(0), m_AsValue(false)
{
m_InputList = il;
this->DoCreateWidget();
}
QtFileSelectionWidget::~QtFileSelectionWidget()
{
}
void QtFileSelectionWidget::DoUpdateGUI()
{
}
void QtFileSelectionWidget::DoCreateWidget()
{
unsigned int sp = 2;
// Set up input text edit
m_HLayout = new QHBoxLayout;
m_HLayout->setSpacing(sp);
m_HLayout->setContentsMargins(sp, sp, sp, sp);
m_Checkbox = new QCheckBox();
m_HLayout->addWidget(m_Checkbox);
m_Input = new QLineEdit;
//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 QtFileSelectionWidget::SelectFile()
{
std::cout<<this<<std::endl;
QFileDialog fileDialog;
fileDialog.setConfirmOverwrite(true);
fileDialog.setFileMode(QFileDialog::ExistingFile);
fileDialog.setNameFilter("Raster files (*)");
if (fileDialog.exec())
{
//this->SetFileName(fileDialog.selectedFiles().at(0));
QString filemane(fileDialog.selectedFiles().at(0));
m_Input->setText(filemane);
if( m_AsValue == false )
{
m_InputList->AddFromFileName(filemane.toStdString());
m_Index = m_InputList->GetImageList()->Size()-1;
m_AsValue = true;
}
else
{
m_InputList->SetNthFileName( m_Index, filemane.toStdString());
}
}
}
/*
void QtFileSelectionWidget::SetFileName(const QString& value)
{
// save value
m_InputImageParam->SetFromFileName(value.toStdString());
// notify of value change
QString key( QString::fromStdString(m_InputImageParam->GetKey()) );
emit ParameterChanged(key);
}
*/
}
}
/*=========================================================================
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 __otbQtFileSelectionWidget_h
#define __otbQtFileSelectionWidget_h
#include <QtGui>
#include "otbWrapperInputImageListParameter.h"
#include "otbWrapperQtWidgetParameterBase.h"
namespace otb
{
namespace Wrapper
{
/** \class
* \brief
*/
class QtFileSelectionWidget : public QWidget
{
Q_OBJECT
public:
QtFileSelectionWidget();
QtFileSelectionWidget( InputImageListParameter * il );
virtual ~QtFileSelectionWidget();
InputImageListParameter * GetInputList()
{
return m_InputList;
}
void SetInputList(InputImageListParameter * il)
{
m_InputList = il;
}
unsigned int GetIndex()
{
return m_Index;
}
protected slots:
//void SetFileName( const QString& value );
void SelectFile();
private:
QtFileSelectionWidget(const QtFileSelectionWidget&); //purposely not implemented
void operator=(const QtFileSelectionWidget&); //purposely not implemented
virtual void DoCreateWidget();
virtual void DoUpdateGUI();
QHBoxLayout * m_HLayout;
QLineEdit* m_Input;
QPushButton * m_Button;
QCheckBox * m_Checkbox;
InputImageListParameter::Pointer m_InputList;
unsigned int m_Index;
bool m_AsValue;
};
}
}
#endif
/*=========================================================================
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 "otbWrapperQtWidgetInputImageListParameter.h"
#include "otbQtFileSelectionWidget.h"
namespace otb
{
namespace Wrapper
{
QtWidgetInputImageListParameter::QtWidgetInputImageListParameter(InputImageListParameter* param, QtWidgetModel* m)
: QtWidgetParameterBase(m),
m_InputImageListParam(param)/*,
m_FileSelectionList()*/
{
}
QtWidgetInputImageListParameter::~QtWidgetInputImageListParameter()
{
}
void QtWidgetInputImageListParameter::DoUpdateGUI()
{
}
void QtWidgetInputImageListParameter::DoCreateWidget()
{
//m_FileSelectionList.clear();
const unsigned int sp = 2;
// Global layout
m_HLayout = new QHBoxLayout;
m_HLayout->setSpacing(sp);
m_HLayout->setContentsMargins(sp, sp, sp, sp);
// Button layout
m_ButtonLayout = new QVBoxLayout;
m_ButtonLayout->setSpacing(sp);
m_ButtonLayout->setContentsMargins(sp, sp, sp, sp);
m_AddSupLayout = new QHBoxLayout;
m_AddSupLayout->setSpacing(sp);
m_AddSupLayout->setContentsMargins(sp, sp, sp, sp);
m_UpDownLayout = new QHBoxLayout;
m_UpDownLayout->setSpacing(sp);
m_UpDownLayout->setContentsMargins(sp, sp, sp, sp);
// Add file button
m_AddButton = new QPushButton;
m_AddButton->setText("+");
m_AddButton->setToolTip("Add a file selector...");
m_AddButton->setMaximumWidth(m_AddButton->width());
connect( m_AddButton, SIGNAL(clicked()), this, SLOT(AddFile()) );
m_AddSupLayout->addWidget(m_AddButton);
// Supress file button
m_SupButton = new QPushButton;
m_SupButton->setText("-");
m_SupButton->setToolTip("Supress the selected file...");
m_SupButton->setMaximumWidth(m_SupButton->width());
connect( m_SupButton, SIGNAL(clicked()), this, SLOT(SupressFile()) );
m_AddSupLayout->addWidget(m_SupButton);
m_ButtonLayout->addLayout(m_AddSupLayout);
// Up file edit
m_UpButton = new QPushButton;
m_UpButton->setText("Up");
m_UpButton->setToolTip("Up the selected file in the list...");
m_UpButton->setMaximumWidth(m_UpButton->width());
connect( m_UpButton, SIGNAL(clicked()), this, SLOT(UpFile()) );
m_UpDownLayout->addWidget(m_UpButton);
// Down file edit
m_DownButton = new QPushButton;
m_DownButton->setText("Down");
m_DownButton->setToolTip("Down the selected file in the list...");
m_DownButton->setMaximumWidth(m_DownButton->width());
connect( m_DownButton, SIGNAL(clicked()), this, SLOT(DownFile()) );
m_UpDownLayout->addWidget(m_DownButton);
m_ButtonLayout->addLayout(m_UpDownLayout);
// Erase file edit
m_EraseButton = new QPushButton;
m_EraseButton->setText("Erase");
m_EraseButton->setToolTip("Erase the selected file of the list...");
m_EraseButton->setMaximumWidth(m_EraseButton->width());
connect( m_EraseButton, SIGNAL(clicked()), this, SLOT(EraseFile()) );
m_ButtonLayout->addWidget(m_EraseButton);
m_FileLayout = new QVBoxLayout();
/*
QtFileSelectionWidget * fileSelection = new QtFileSelectionWidget();
m_FileLayout->addWidget( fileSelection );
QtFileSelectionWidget * fileSelection1 = new QtFileSelectionWidget();
m_FileLayout->addWidget( fileSelection1 );
QtFileSelectionWidget * fileSelection2 = new QtFileSelectionWidget();
m_FileLayout->addWidget( fileSelection2 );
QtFileSelectionWidget * fileSelection3 = new QtFileSelectionWidget();
m_FileLayout->addWidget( fileSelection3 );
QtFileSelectionWidget * fileSelection4 = new QtFileSelectionWidget();
m_FileLayout->addWidget( fileSelection4 );
QtFileSelectionWidget * fileSelection5 = new QtFileSelectionWidget();
m_FileLayout->addWidget( fileSelection5 );
QtFileSelectionWidget * fileSelection6 = new QtFileSelectionWidget();
m_FileLayout->addWidget( fileSelection6 );
*/
QLineEdit * fileSelection = new QLineEdit();
m_FileLayout->addWidget( fileSelection );
QGroupBox *mainGroup = new QGroupBox();
mainGroup->setLayout(m_FileLayout);
m_Scroll = new QScrollArea();
//m_Scroll->setLayout(m_FileLayout);
m_Scroll->setWidget(mainGroup);
m_Scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);//ScrollBarAlwaysOn);
m_Scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);//ScrollBarAlwaysOn);
QVBoxLayout *scrollLayout = new QVBoxLayout();
scrollLayout->addWidget(m_Scroll);
//m_HLayout->addWidget(m_Scroll);
m_HLayout->addLayout(scrollLayout);
m_HLayout->addLayout(m_ButtonLayout);
m_HLayout->addStretch();
this->setLayout(m_HLayout);
}
void QtWidgetInputImageListParameter::SelectFile()
{
QFileDialog fileDialog;
fileDialog.setConfirmOverwrite(true);
fileDialog.setFileMode(QFileDialog::ExistingFile);
fileDialog.setNameFilter("Raster files (*)");
if (fileDialog.exec())
{
//this->SetFileName(fileDialog.selectedFiles().at(0));
//m_Input->setText(fileDialog.selectedFiles().at(0));
}
}
void
QtWidgetInputImageListParameter::UpFile()
{
std::cout<<"upupup"<<std::endl;
}
void
QtWidgetInputImageListParameter::DownFile()
{
std::cout<<"downdowndown"<<std::endl;
}
void
QtWidgetInputImageListParameter::AddFile()
{
//QtFileSelectionWidget * fileSelection = new
//QtFileSelectionWidget();
QLineEdit * fileSelection = new QLineEdit();
//std::cout<< fileSelection->height()<<std::endl;
//fileSelection->setMinimumHeight( 20 );//fileSelection->height() / 2 );
//std::cout<<fileSelection->minimumHeight()<<std::endl;
m_FileLayout->addWidget( fileSelection );
m_FileLayout->update();
m_Scroll->update();
m_HLayout->update();
this->update();
}
void
QtWidgetInputImageListParameter::SupressFile()
{
std::cout<<"supsupsup"<<std::endl;
}
void
QtWidgetInputImageListParameter::EraseFile()
{
//m_HLayout->removeItem( m_FileLayout );
m_HLayout->removeWidget( m_Scroll );
m_HLayout->update();
m_FileLayout = new QVBoxLayout();
//QtFileSelectionWidget * fileSelection = new QtFileSelectionWidget();
QLineEdit * fileSelection = new QLineEdit();
m_FileLayout->addWidget( fileSelection );
QGroupBox *mainGroup = new QGroupBox();
mainGroup->setLayout(m_FileLayout);
m_Scroll = new QScrollArea();
//m_Scroll->setLayout(m_FileLayout);
m_Scroll->setWidget(mainGroup);
m_Scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);//ScrollBarAlwaysOn);
m_Scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);//ScrollBarAlwaysOn)
/*
m_Scroll = new QScrollArea();
m_Scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);//AsNeeded);
m_Scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
m_Scroll->setLayout(m_FileLayout);
*/
m_HLayout->insertWidget(0, m_Scroll);
m_HLayout->update();
//m_HLayout->takeAt(2) = m_Scroll;
std::cout<<"cleancleanclean"<<std::endl;
}
/*
void QtWidgetInputImageListParameter::SetFileName(const QString& value)
{
// save value
m_InputImageParam->SetFromFileName(value.toStdString());
// notify of value change
QString key( QString::fromStdString(m_InputImageParam->GetKey()) );
emit ParameterChanged(key);
}
*/
}
}
/*=========================================================================
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 __otbWrapperQtWidgetInputImageListParameter_h
#define __otbWrapperQtWidgetInputImageListParameter_h
#include <QtGui>
#include "otbWrapperInputImageListParameter.h"
#include "otbWrapperQtWidgetParameterBase.h"
namespace otb
{
namespace Wrapper
{
/** \class
* \brief
*/
class QtWidgetInputImageListParameter : public QtWidgetParameterBase
{
Q_OBJECT
public:
QtWidgetInputImageListParameter(InputImageListParameter*, QtWidgetModel*);
virtual ~QtWidgetInputImageListParameter();
protected slots:
//void SetFileName( const QString& value );
virtual void SelectFile();
virtual void UpFile();
virtual void DownFile();
virtual void AddFile();
virtual void SupressFile();
virtual void EraseFile();
private:
QtWidgetInputImageListParameter(const QtWidgetInputImageListParameter&); //purposely not implemented
void operator=(const QtWidgetInputImageListParameter&); //purposely not implemented
virtual void DoCreateWidget();
virtual void DoUpdateGUI();
InputImageListParameter::Pointer m_InputImageListParam;
QHBoxLayout * m_HLayout;
QVBoxLayout * m_FileLayout;
QVBoxLayout * m_ButtonLayout;
QHBoxLayout * m_AddSupLayout;
QHBoxLayout * m_UpDownLayout;
QPushButton * m_SupButton;
QPushButton * m_AddButton;
QPushButton * m_EraseButton;
QPushButton * m_UpButton;
QPushButton * m_DownButton;
QScrollArea * m_Scroll;
//std::vector<QtFileSelectionWidget *> m_FileSelectionList;
};
}
}
#endif
......@@ -70,7 +70,7 @@ void QtWidgetInputImageParameter::SelectFile()
if (fileDialog.exec())
{
//this->SetFileName(fileDialog.selectedFiles().at(0));
this->SetFileName(fileDialog.selectedFiles().at(0));
m_Input->setText(fileDialog.selectedFiles().at(0));
}
}
......
......@@ -50,6 +50,7 @@ private:
virtual void DoUpdateGUI();
InputImageParameter::Pointer m_InputImageParam;
QHBoxLayout * m_HLayout;
......
......@@ -29,6 +29,7 @@
#include "otbWrapperQtWidgetChoiceParameter.h"
#include "otbWrapperQtWidgetListViewParameter.h"
#include "otbWrapperQtWidgetInputImageParameter.h"
#include "otbWrapperQtWidgetInputImageListParameter.h"
#include "otbWrapperQtWidgetOutputImageParameter.h"
#include "otbWrapperQtWidgetParameterGroup.h"
......@@ -80,16 +81,17 @@ QtWidgetParameterFactory::CreateQtWidget( Parameter* param, QtWidgetModel* model
}
if (0) {}
CREATEWIDGET(EmptyParameter, QtWidgetEmptyParameter)
CREATEWIDGET(IntParameter, QtWidgetIntParameter)
CREATEWIDGET(FloatParameter, QtWidgetFloatParameter)
CREATEWIDGET(StringParameter, QtWidgetStringParameter)
CREATEWIDGET(ChoiceParameter, QtWidgetChoiceParameter)
CREATEWIDGET(ListViewParameter, QtWidgetListViewParameter)
CREATEWIDGET(InputImageParameter, QtWidgetInputImageParameter)
CREATEWIDGET(OutputImageParameter, QtWidgetOutputImageParameter)
CREATEWIDGET(EmptyParameter, QtWidgetEmptyParameter)
CREATEWIDGET(ParameterGroup, QtWidgetParameterGroup)
CREATEWIDGET(EmptyParameter, QtWidgetEmptyParameter)
CREATEWIDGET(IntParameter, QtWidgetIntParameter)
CREATEWIDGET(FloatParameter, QtWidgetFloatParameter)
CREATEWIDGET(StringParameter, QtWidgetStringParameter)
CREATEWIDGET(ChoiceParameter, QtWidgetChoiceParameter)
CREATEWIDGET(ListViewParameter, QtWidgetListViewParameter)
CREATEWIDGET(InputImageParameter, QtWidgetInputImageParameter)
CREATEWIDGET(InputImageListParameter, QtWidgetInputImageListParameter)
CREATEWIDGET(OutputImageParameter, QtWidgetOutputImageParameter)
CREATEWIDGET(EmptyParameter, QtWidgetEmptyParameter)
CREATEWIDGET(ParameterGroup, QtWidgetParameterGroup)
#undef CREATEWIDGET
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment