Commit 9a7d16ca authored by Otmane Lahlou's avatar Otmane Lahlou

ENH: add class to launch applications (WIP)

parent ed721cd7
......@@ -16,6 +16,7 @@ set( Common_Core_SOURCES
mvdSystemError.cxx
mvdTypes.cxx
mvdVectorImageModel.cxx
mvdApplicationLauncher.cxx
)
#############################################################################
......@@ -36,6 +37,7 @@ set( Common_Core_HEADERS_MOC
mvdSystemError.h
mvdTypes.h
mvdVectorImageModel.h
mvdApplicationLauncher.h
)
#############################################################################
......@@ -46,6 +48,8 @@ include_directories(
${Monteverdi2_SOURCE_DIR}/Code/Common
#
${Monteverdi2_BINARY_DIR}/Code/Common
#
${OTB_SOURCE_DIR}/Code/Wrappers/QtWidget
)
#############################################################################
......@@ -69,6 +73,8 @@ add_library(Monteverdi2_Core
#############################################################################
target_link_libraries(Monteverdi2_Core
OTBIO
OTBApplicationEngine
OTBWrapperQtWidget
Qt4::QtCore
Qt4::QtXml
)
......
/*=========================================================================
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 "mvdApplicationLauncher.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 "otbWrapperApplicationRegistry.h"
#include "otbWrapperApplication.h"
#include "otbWrapperQtWidgetView.h"
//
// Monteverdi includes (sorted by alphabetic order)
#include "Core/mvdAlgorithm.h"
namespace mvd
{
/*
TRANSLATOR mvd::ApplicationLauncher
Necessary for lupdate to be aware of C++ namespaces.
Context comment for translator.
*/
/*****************************************************************************/
/* CONSTANTS */
/*****************************************************************************/
/* STATIC IMPLEMENTATION SECTION */
/*****************************************************************************/
/* CLASS IMPLEMENTATION SECTION */
/*******************************************************************************/
ApplicationLauncher
::ApplicationLauncher( QObject* parent ) :
QObject( parent )
{
}
/*******************************************************************************/
ApplicationLauncher
::~ApplicationLauncher()
{
}
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
void
ApplicationLauncher
::OnApplicationToLaunchSelected(const QString& appname)
{
// Create module
otb::Wrapper::Application::Pointer app
= otb::Wrapper::ApplicationRegistry::CreateApplication( ToStdString (appname) );
if ( app.IsNull() )
{
std::cerr << "Could not Load application " << ToStdString( appname ) << std::endl;
}
else
{
// MainWidget : that contains the view and any other widget
// (progress, logs...)
QMainWindow* mainWindow = new QMainWindow();
mainWindow->setWindowIcon(QIcon( ":/otb_small.png" ));
mainWindow->setWindowTitle(QString(app->GetDocName()).append(" - ").append(OTB_VERSION_STRING));
// Create GUI based on module
otb::Wrapper::QtWidgetView* gui = new otb::Wrapper::QtWidgetView(app);
gui->CreateGui();
// Connect the View "Quit" signal, to the mainWindow close slot
QObject::connect(gui, SIGNAL(QuitSignal()), mainWindow, SLOT(close()));
// build the main window, central widget is the plugin view, other
// are docked widget (progress, logs...)
mainWindow->setCentralWidget(gui);
// Show the main window
mainWindow->show();
}
}
} // end namespace 'mvd'
/*=========================================================================
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 __mvdApplicationLauncher_h
#define __mvdApplicationLauncher_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)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
/*****************************************************************************/
/* PRE-DECLARATION SECTION */
//
// External classes pre-declaration.
namespace
{
}
namespace mvd
{
//
// Internal classes pre-declaration.
/*****************************************************************************/
/* CLASS DEFINITION SECTION */
/**
* \class ApplicationLauncher
*
* \brief WIP.
*/
class Monteverdi2_EXPORT ApplicationLauncher :
public QObject
{
/*-[ QOBJECT SECTION ]-----------------------------------------------------*/
Q_OBJECT;
/*-[ PUBLIC SECTION ]------------------------------------------------------*/
//
// Public methods.
public:
/** \brief Constructor. */
ApplicationLauncher( QObject* parent =NULL );
/** \brief Destructor. */
virtual ~ApplicationLauncher();
/*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/
//
// Public SLOTS.
public slots:
void OnApplicationToLaunchSelected(const QString& appname);
/*-[ SIGNALS SECTION ]-----------------------------------------------------*/
//
// Signals.
signals:
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
//
// Protected methods.
protected:
//
// Protected attributes.
protected:
/*-[ PRIVATE SECTION ]-----------------------------------------------------*/
//
// Private methods.
private:
//
// Private attributes.
private:
/*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
//
// Slots.
private slots:
};
} // end namespace 'mvd'.
/*****************************************************************************/
/* INLINE 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)
//
// Monteverdi includes (sorted by alphabetic order)
namespace mvd
{
} // end namespace 'mvd'
#endif // __mvdApplicationLauncher_h
......@@ -159,6 +159,7 @@ ApplicationsToolBox
//
// TODO : add algorithm icon
//secItem->setIcon(0, QIcon( ":" ));
}
++itApps;
......@@ -207,7 +208,7 @@ void
ApplicationsToolBox
::ExecuteAlgorithm( const QString& appName )
{
std::cout <<"ApplicationsToolBox::ExecuteAlgorithm - "<< ToStdString( appName )<< "- WIP."<< std::endl;
emit ApplicationToLaunchSelected(appName);
}
/*******************************************************************************/
......
......@@ -111,6 +111,7 @@ public slots:
//
// Signals.
signals:
void ApplicationToLaunchSelected(const QString &);
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
......
......@@ -16,6 +16,7 @@ include_directories(
${Monteverdi2_SOURCE_DIR}/Code/Application/Viewer
${Monteverdi2_SOURCE_DIR}/Code/Common
${Monteverdi2_SOURCE_DIR}/Code/Common/Gui
${Monteverdi2_SOURCE_DIR}/Code/Common/Core
${Monteverdi2_BINARY_DIR}/Code/Common/Core
)
......
......@@ -30,6 +30,7 @@
// Monteverdi includes (sorted by alphabetic order)
#include "mvdApplicationsToolBox.h"
#include "mvdApplicationsBrowser.h"
#include "mvdApplicationLauncher.h"
int mvdFillToolBoxWidgetTreeTest(int argc, char* argv[])
{
......@@ -61,6 +62,25 @@ int mvdFillToolBoxWidgetTreeTest(int argc, char* argv[])
// get the tags/algs map container in the widget
browser->SearchAvailableApplicationsTags();
//
// instanciate Application launcher
mvd::ApplicationLauncher * launcher = new mvd::ApplicationLauncher();
//
// connections
QObject::connect(appToolBox,
SIGNAL( ApplicationToLaunchSelected(const QString& ) ),
launcher,
SLOT( OnApplicationToLaunchSelected(const QString& ) )
);
// add quit
// QObject::connect(appToolBox,
// SIGNAL( (const QString& ) ),
// launcher,
// SLOT( OnQuit() )
// );
//
// show the application for a while
appToolBox->show();
......
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