Commit 541dec3f authored by Otmane Lahlou's avatar Otmane Lahlou

ENH: fork needed classes from OTB

parent a863039e
......@@ -6,6 +6,10 @@ set( Common_ApplicationsWrapper_SOURCES
mvdApplicationsBrowser.cxx
mvdApplicationLauncher.cxx
mvdWrapperQtWidgetInputImageParameter.cxx
mvdWrapperQtWidgetParameterFactory.cxx
mvdWrapperQtWidgetView.cxx
mvdWrapperQtWidgetParameterGroup.cxx
mvdWrapperQtWidgetChoiceParameter.cxx
)
#############################################################################
......@@ -16,6 +20,10 @@ set( Common_ApplicationsWrapper_HEADERS_MOC
mvdApplicationsBrowser.h
mvdApplicationLauncher.h
mvdWrapperQtWidgetInputImageParameter.h
mvdWrapperQtWidgetParameterFactory.h
mvdWrapperQtWidgetView.h
mvdWrapperQtWidgetParameterGroup.h
mvdWrapperQtWidgetChoiceParameter.h
)
#############################################################################
......@@ -52,11 +60,9 @@ add_library(Monteverdi2_ApplicationsWrapper
#############################################################################
target_link_libraries(Monteverdi2_ApplicationsWrapper
#Monteverdi2_Core
OTBApplicationEngine
OTBWrapperQtWidget
${OPENGL_LIBRARIES}
#Qt4::QtCore
Qt4::QtGui
Qt4::QtOpenGL
)
......
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more 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 "mvdWrapperQtWidgetChoiceParameter.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
#include "otbWrapperQtWidgetParameterLabel.h"
//
// Monteverdi includes (sorted by alphabetic order)
#include "mvdWrapperQtWidgetParameterFactory.h"
namespace mvd
{
namespace Wrapper
{
QtWidgetChoiceParameter::QtWidgetChoiceParameter(otb::Wrapper::ChoiceParameter* param,
otb::Wrapper::QtWidgetModel* m)
: otb::Wrapper::QtWidgetParameterBase(param, m),
m_ChoiceParam(param)
{
}
QtWidgetChoiceParameter::~QtWidgetChoiceParameter()
{
}
void QtWidgetChoiceParameter::DoUpdateGUI()
{
// Update the combobox value
unsigned int value = m_ChoiceParam->GetValue( );
m_ComboBox->setCurrentIndex(value);
// Update the choice subparameters
WidgetListIteratorType it = m_WidgetList.begin();
for (it = m_WidgetList.begin(); it != m_WidgetList.end(); ++it)
{
(*it)->UpdateGUI();
}
}
void QtWidgetChoiceParameter::DoCreateWidget()
{
m_ComboBox = new QComboBox;
m_ComboBox->setToolTip(m_ChoiceParam->GetDescription());
m_StackWidget = new QStackedWidget;
for (unsigned int i = 0; i < m_ChoiceParam->GetNbChoices(); ++i)
{
QString key = m_ChoiceParam->GetChoiceName(i).c_str();
m_ComboBox->addItem( key, QVariant(key) );
otb::Wrapper::ParameterGroup::Pointer param = m_ChoiceParam->GetChoiceParameterGroupByIndex(i);
if (param.IsNotNull())
{
otb::Wrapper::QtWidgetParameterBase* widget
= QtWidgetParameterFactory::CreateQtWidget( param, GetModel() );
m_StackWidget->addWidget(widget);
m_WidgetList.push_back(widget);
}
}
connect( m_ComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(SetValue(int)) );
connect( m_ComboBox, SIGNAL(currentIndexChanged(int)), m_StackWidget, SLOT(setCurrentIndex(int)) );
connect( m_ComboBox, SIGNAL(currentIndexChanged(int)), GetModel(), SLOT(NotifyUpdate()) );
m_VLayout = new QVBoxLayout;
m_VLayout->addWidget(m_ComboBox);
if (!m_WidgetList.empty())
{
m_VLayout->addWidget(m_StackWidget);
}
m_VLayout->addStretch();
this->setLayout(m_VLayout);
}
void QtWidgetChoiceParameter::SetValue(int value)
{
m_ChoiceParam->SetValue( value );
}
}
}
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more 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 __mvdWrapperQtWidgetChoiceParameter_h
#define __mvdWrapperQtWidgetChoiceParameter_h
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
#include <QtCore>
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
#include "otbWrapperChoiceParameter.h"
#include "otbWrapperParameterGroup.h"
#include "otbWrapperQtWidgetParameterBase.h"
//
// Monteverdi includes (sorted by alphabetic order)
/*****************************************************************************/
/* PRE-DECLARATION SECTION */
//
// External classes pre-declaration.
namespace
{
}
namespace mvd
{
namespace Wrapper
{
/** \class
* \brief
*/
class QtWidgetChoiceParameter : public otb::Wrapper::QtWidgetParameterBase
{
/*-[ QOBJECT SECTION ]-----------------------------------------------------*/
Q_OBJECT
/*-[ PUBLIC SECTION ]------------------------------------------------------*/
//
// Public methods.
public:
/** \brief Constructor. */
QtWidgetChoiceParameter(otb::Wrapper::ChoiceParameter*, otb::Wrapper::QtWidgetModel*);
/** \brief Destructor. */
virtual ~QtWidgetChoiceParameter();
protected slots:
void SetValue( int value );
private:
QtWidgetChoiceParameter(const QtWidgetChoiceParameter&); //purposely not implemented
void operator=(const QtWidgetChoiceParameter&); //purposely not implemented
virtual void DoCreateWidget();
virtual void DoUpdateGUI();
otb::Wrapper::ChoiceParameter::Pointer m_ChoiceParam;
QHBoxLayout* m_MainHLayout;
QComboBox* m_ComboBox;
QStackedWidget* m_StackWidget;
QVBoxLayout* m_VLayout;
QGroupBox* m_VLayoutGroup;
typedef std::vector<otb::Wrapper::QtWidgetParameterBase*> WidgetListType;
typedef WidgetListType::iterator WidgetListIteratorType;
WidgetListType m_WidgetList;
};
}
}
#endif
......@@ -71,12 +71,12 @@ QtWidgetInputImageParameter::QtWidgetInputImageParameter(otb::Wrapper::InputImag
//
//
m_HLayout = new QHBoxLayout;
m_Button = new QPushButton;
m_Input = new QLabel;
m_Button = new QPushButton();
m_Input = new QLabel(this);
//
// set accept drops in QLabel
m_Input->setAcceptDrops( true );
// set accept drops in the widget
setAcceptDrops( true );
}
/*******************************************************************************/
......@@ -92,10 +92,12 @@ void QtWidgetInputImageParameter::DoUpdateGUI()
/*******************************************************************************/
void QtWidgetInputImageParameter::DoCreateWidget()
{
// Set up input QLabel
m_Input->setToolTip( m_InputImageParam->GetDescription() );
m_Input->setFrameShape(QFrame::Box);
// TODO : QLabel does not have signals
// TODO : QLabel does not have signals, remove connections
//connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) );
//connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(),
//SLOT(NotifyUpdate()) );
......@@ -119,13 +121,41 @@ void QtWidgetInputImageParameter::DoCreateWidget()
void
QtWidgetInputImageParameter::dragEnterEvent( QDragEnterEvent * event )
{
return;
//
// accepts all the proposed actions : checking will be done
// dragMoveEvent method
event->acceptProposedAction();
}
/*******************************************************************************/
void
QtWidgetInputImageParameter::dragMoveEvent(QDragMoveEvent *event)
{
// if (event->mimeData()->hasFormat("text/plain")
//
// if the mouse is within the QLabel geometry : allow drops
if ( event->answerRect().intersects( m_Input->geometry() ) )
{
event->acceptProposedAction();
}
else
{
event->ignore();
}
}
/*******************************************************************************/
void QtWidgetInputImageParameter::dropEvent(QDropEvent *event)
{
return ;
//
// TODO : need to define the mimeData format
// TODO : the data to drop will be defined in the DataSet TreeWidget
//
// get the text form the mimeData stored in the event : path
// to the image in the dataset
std::cout << "QtWidgetInputImageParameter::dropEvent ACCEPTED ...."<< std::endl;
}
/*******************************************************************************/
......
......@@ -16,8 +16,8 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbWrapperQtWidgetInputImageParameter_h
#define __otbWrapperQtWidgetInputImageParameter_h
#ifndef __mvdWrapperQtWidgetInputImageParameter_h
#define __mvdWrapperQtWidgetInputImageParameter_h
//
// Configuration include.
......@@ -89,8 +89,9 @@ public:
/** \brief drag and drop events reimplementation */
void dragEnterEvent( QDragEnterEvent * event );
void dropEvent(QDropEvent *event);
void dropEvent( QDropEvent *event );
void dragMoveEvent(QDragMoveEvent *event);
protected slots:
bool SetFileName( const QString& value );
void SelectFile();
......
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more 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 "mvdWrapperQtWidgetParameterFactory.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
#include "otbWrapperParameter.h"
#include "otbWrapperQtWidgetModel.h"
#include "otbWrapperQtWidgetParameterBase.h"
#include "otbWrapperQtWidgetEmptyParameter.h"
#include "otbWrapperQtWidgetIntParameter.h"
#include "otbWrapperQtWidgetFloatParameter.h"
#include "otbWrapperQtWidgetStringParameter.h"
#include "otbWrapperQtWidgetStringListParameter.h"
#include "otbWrapperQtWidgetListViewParameter.h"
#include "otbWrapperQtWidgetComplexInputImageParameter.h"
#include "otbWrapperQtWidgetComplexOutputImageParameter.h"
#include "otbWrapperQtWidgetInputImageListParameter.h"
#include "otbWrapperQtWidgetOutputImageParameter.h"
#include "otbWrapperQtWidgetOutputVectorDataParameter.h"
#include "otbWrapperQtWidgetInputFilenameParameter.h"
#include "otbWrapperQtWidgetOutputFilenameParameter.h"
#include "otbWrapperQtWidgetDirectoryParameter.h"
#include "otbWrapperQtWidgetInputVectorDataListParameter.h"
#include "otbWrapperQtWidgetInputVectorDataParameter.h"
#include "otbWrapperQtWidgetRAMParameter.h"
//
// Monteverdi includes (sorted by alphabetic order)
#include "mvdWrapperQtWidgetChoiceParameter.h"
#include "mvdWrapperQtWidgetInputImageParameter.h"
#include "mvdWrapperQtWidgetParameterGroup.h"
namespace mvd
{
namespace Wrapper
{
/*
TRANSLATOR mvd::ApplicationLauncher
Necessary for lupdate to be aware of C++ namespaces.
Context comment for translator.
*/
/*****************************************************************************/
/* CONSTANTS */
/*****************************************************************************/
/* STATIC IMPLEMENTATION SECTION */
/*****************************************************************************/
/* CLASS IMPLEMENTATION SECTION */
/*******************************************************************************/
template <class TParameterType, class TQtWidget>
class QtWidgetParameterGenericFactory
{
public:
static bool CanCreate( otb::Wrapper::Parameter* param )
{
return dynamic_cast<TParameterType *>(param) != 0;
}
static otb::Wrapper::QtWidgetParameterBase* Create( otb::Wrapper::Parameter* param,
otb::Wrapper::QtWidgetModel* model )
{
otb::Wrapper::QtWidgetParameterBase* widget = 0;
TParameterType* specificParam = dynamic_cast<TParameterType *>(param);
if (specificParam)
{
widget = new TQtWidget(specificParam, model);
}
return widget;
}
};
/*******************************************************************************/
QtWidgetParameterFactory::QtWidgetParameterFactory()
{
}
/*******************************************************************************/
QtWidgetParameterFactory::~QtWidgetParameterFactory()
{
}
/*******************************************************************************/
otb::Wrapper::QtWidgetParameterBase*
QtWidgetParameterFactory::CreateQtWidget( otb::Wrapper::Parameter* param,
otb::Wrapper::QtWidgetModel* model )
{
otb::Wrapper::QtWidgetParameterBase* widget = 0;
#define CREATEWIDGET( ParameterType, WidgetType ) \
else if ( mvd::Wrapper::QtWidgetParameterGenericFactory<ParameterType, WidgetType>::CanCreate(param) ) \
{ \
widget = mvd::Wrapper::QtWidgetParameterGenericFactory<ParameterType, WidgetType>::Create(param, model); \
}
if (0) {}
CREATEWIDGET(otb::Wrapper::EmptyParameter,
otb::Wrapper::QtWidgetEmptyParameter)
CREATEWIDGET(otb::Wrapper::IntParameter,
otb::Wrapper::QtWidgetIntParameter)
CREATEWIDGET(otb::Wrapper::FloatParameter,
otb::Wrapper::QtWidgetFloatParameter)
CREATEWIDGET(otb::Wrapper::InputFilenameParameter,
otb::Wrapper::QtWidgetInputFilenameParameter)
CREATEWIDGET(otb::Wrapper::OutputFilenameParameter,
otb::Wrapper::QtWidgetOutputFilenameParameter)
CREATEWIDGET(otb::Wrapper::DirectoryParameter,
otb::Wrapper::QtWidgetDirectoryParameter)
CREATEWIDGET(otb::Wrapper::StringParameter,
otb::Wrapper::QtWidgetStringParameter)
CREATEWIDGET(otb::Wrapper::StringListParameter,
otb::Wrapper::QtWidgetStringListParameter)
CREATEWIDGET(otb::Wrapper::ChoiceParameter,
mvd::Wrapper::QtWidgetChoiceParameter)
CREATEWIDGET(otb::Wrapper::ListViewParameter,
otb::Wrapper::QtWidgetListViewParameter)
CREATEWIDGET(otb::Wrapper::InputImageParameter,
mvd::Wrapper::QtWidgetInputImageParameter)
CREATEWIDGET(otb::Wrapper::ComplexInputImageParameter,
otb::Wrapper::QtWidgetComplexInputImageParameter)
CREATEWIDGET(otb::Wrapper::ComplexOutputImageParameter,
otb::Wrapper::QtWidgetComplexOutputImageParameter)
CREATEWIDGET(otb::Wrapper::InputImageListParameter,
otb::Wrapper::QtWidgetInputImageListParameter)
CREATEWIDGET(otb::Wrapper::InputVectorDataListParameter,
otb::Wrapper::QtWidgetInputVectorDataListParameter)
CREATEWIDGET(otb::Wrapper::InputVectorDataParameter,
otb::Wrapper::QtWidgetInputVectorDataParameter)
CREATEWIDGET(otb::Wrapper::OutputImageParameter,
otb::Wrapper::QtWidgetOutputImageParameter)
CREATEWIDGET(otb::Wrapper::OutputVectorDataParameter,
otb::Wrapper::QtWidgetOutputVectorDataParameter)
CREATEWIDGET(otb::Wrapper::EmptyParameter,
otb::Wrapper::QtWidgetEmptyParameter)
CREATEWIDGET(otb::Wrapper::ParameterGroup,
mvd::Wrapper::QtWidgetParameterGroup)
CREATEWIDGET(otb::Wrapper::RAMParameter,
otb::Wrapper::QtWidgetRAMParameter)
#undef CREATEWIDGET
if (widget)
{
widget->CreateWidget();
widget->UpdateGUI();
}
return widget;
}
}
}
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more 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 __mvdWrapperQtWidgetFactory_h
#define __mvdWrapperQtWidgetFactory_h
//
// Configuration include.
//// Included at first position before any other ones.
#include "ConfigureMonteverdi2.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
#include <QtCore>
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
#include "itkObject.h"
#include "itkObjectFactory.h"
//
// OTB includes (sorted by alphabetic order)
#include "otbWrapperQtWidgetParameterBase.h"
//
// Monteverdi includes (sorted by alphabetic order)