Commit 0bfc9d65 authored by Stéphane Albert's avatar Stéphane Albert

ENH: Remove Code/Application/Monteverdi2 obsolete code.

parent ef68d764
#############################################################################
# Input files.
set( Monteverdi_Catalogue_SOURCES
mvdApplication.cxx
mvdMainWindow.cxx
mvdPreferencesDialog.cxx
)
# Headers for classes with Q_OBJECT macro (needs to go to Qt moc)
set( Monteverdi_Catalogue_HEADERS_MOC
mvdApplication.h
mvdMainWindow.h
mvdPreferencesDialog.h
)
# Qt designer UI files
set( Monteverdi_Catalogue_FORMS
mvdMainWindow.ui
mvdPreferencesDialog.ui
)
# Qt resources included in executable
set( Monteverdi_Catalogue_RESOURCES
mvdMainWindow.qrc
)
# General include directories.
include_directories(
${QWT_INCLUDE_DIRS}
#
${Monteverdi_BINARY_DIR}
#
${Monteverdi_SOURCE_DIR}/Code/Common
#
${Monteverdi_SOURCE_DIR}/Code/Application/Monteverdi
${Monteverdi_BINARY_DIR}/Code/Application/Monteverdi
#
${Monteverdi_SOURCE_DIR}/Data/Icons
)
#############################################################################
# Qt4 wrapped files.
qt4_wrap_cpp( Monteverdi_Catalogue_SRC_MOC ${Monteverdi_Catalogue_HEADERS_MOC} )
qt4_wrap_ui( Monteverdi_Catalogue_FORMS_HEADERS ${Monteverdi_Catalogue_FORMS} )
qt4_add_resources( Monteverdi_Catalogue_RESOURCES_RCC ${Monteverdi_Catalogue_RESOURCES} )
#############################################################################
# Sources files to translate.
add_to_qt4_i18n_sources(
main.cxx
${Monteverdi_Catalogue_SOURCES}
${Monteverdi_Catalogue_HEADERS_MOC}
${Monteverdi_Catalogue_FORMS}
)
if (WIN32)
# Windows Resource file need to have the full path to icon
# if the .ico is not in the current dir
set( Monteverdi_Catalogue_WIN32_ICON ${Monteverdi_SOURCE_DIR}/Data/Icons/monteverdi.ico)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/mvdWin32.rc.in
${CMAKE_CURRENT_BINARY_DIR}/mvdWin32.rc
@ONLY
)
if (MINGW)
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
endif()
# The RC file to be added to source list
set( Monteverdi_Catalogue_WIN32_RC_FILE ${CMAKE_CURRENT_BINARY_DIR}/mvdWin32.rc )
endif()
#############################################################################
# Monteverdi_Catalogue library
# STATIC so that the monteverdi executable does not depend on another shared lib
# The library is also used in tests, waiting for a better test strategy
# The library is not installed
add_library( Monteverdi_Catalogue
STATIC
${Monteverdi_Catalogue_SOURCES}
${Monteverdi_Catalogue_FORMS_HEADERS}
${Monteverdi_Catalogue_SRC_MOC}
)
target_link_libraries( Monteverdi_Catalogue
Monteverdi_Gui
)
if (OTBQtWidget_LOADED)
target_link_libraries( Monteverdi_Catalogue
Monteverdi_ApplicationsWrapper
)
endif()
# monteverdi executable
create_monteverdi_application(NAME monteverdi
SOURCES main.cxx ${Monteverdi_Catalogue_WIN32_RC_FILE} ${Monteverdi_Catalogue_RESOURCES_RCC}
LINK_LIBRARIES Monteverdi_Catalogue ${QT_QTMAIN_LIBRARY}
OUTPUT_NAME ${MONTEVERDI_OUTPUT_NAME}
COMPONENT_NAME Monteverdi
)
/*=========================================================================
Program: Monteverdi
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi 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.
=========================================================================*/
//
// Configuration include.
//// Included at first position before any other ones.
#include "ConfigureMonteverdi.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
#include <QPixmap>
#include <QSplashScreen>
//
// System includes (sorted by alphabetic order)
#include <exception>
//
// ITK includes (sorted by alphabetic order)
#include "itksys/SystemTools.hxx"
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
#include "mvdApplication.h"
#include "mvdMainWindow.h"
enum ERROR_CODE
{
ERROR_CODE_I18N = -1,
ERROR_CODE_CACHE_DIR = -2,
ERROR_CODE_DATABASE = -3,
ERROR_CODE_GL_VERSION = -4,
};
/*****************************************************************************/
/* FUNCTIONS DECLARATION */
/*****************************************************************************/
/* MAIN */
int
main( int argc, char* argv[] )
{
QApplication qtApp( argc, argv );
//
// 0. Splash-screen.
#if !defined( _DEBUG )
QPixmap pixmap(QLatin1String( ":/images/application_splash" ));
QSplashScreen splash(pixmap);
splash.show();
qtApp.processEvents();//This is used to accept a click on the screen so that user can cancel the screen
#endif
//
// 1. Initialize application and sync settings.
//
// Coverity-14835
// {
mvd::Application * application = NULL;
try
{
application = new mvd::Application( &qtApp );
assert( application!=NULL );
application->Initialize();
}
catch( std::exception & exc )
{
QMessageBox::StandardButton button =
QMessageBox::question(
NULL,
QCoreApplication::translate(
PROJECT_NAME,
"Question!"
),
QCoreApplication::translate(
PROJECT_NAME,
"The following exception has been caught while initializing the software:\n\n"
"%1\n\n"
"The application may not function as expected. Do you want to continue?"
)
.arg( exc.what() ),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::Yes
);
if( button==QMessageBox::No )
return ERROR_CODE_I18N;
}
// }
// Coverity-14835
//
// 2. Initialize main-window (UI).
mvd::MainWindow mainWindow;
mainWindow.Initialize();
//
// 3. Initialize cache directory.
try
{
mainWindow.SetupCacheDir();
}
catch( std::exception& exc )
{
QMessageBox::critical(
&mainWindow,
QCoreApplication::translate(
PROJECT_NAME,
"Critical error!"
),
QCoreApplication::translate(
PROJECT_NAME,
"Error while creating cache repository.\n\n"
"%1\n\n"
"Application will exit!"
)
.arg( exc.what() )
);
return ERROR_CODE_CACHE_DIR;
}
//
// 4. Initialize database.
try
{
mvd::CountType nb = application->OpenDatabase();
if( nb>0 )
{
QMessageBox::StandardButton button =
QMessageBox::warning(
&mainWindow,
QCoreApplication::translate(
PROJECT_NAME,
"Warning!"
),
QCoreApplication::translate(
PROJECT_NAME,
"There are %1 outdated dataset(s) in cache-directory.\n\n"
"Please remove cache-directory '%2' and restart Monteverdi\n\n"
"Do you want to delete cache-directory '%2' before quitting Monteverdi?"
).arg( nb ).arg( application->GetCacheDir().path() ),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::Yes
);
if( button==QMessageBox::Yes )
{
if( application->GetCacheDir()==QDir::home() )
{
// throw std::runtime_error(
// mvd::ToStdString(
// QCoreApplication::translate(
// "Monteverdi",
// "Tryed to remove home dir."
// )
// )
// );
QMessageBox::critical(
&mainWindow,
QCoreApplication::translate(
PROJECT_NAME,
"Critical error!"
),
QCoreApplication::translate(
PROJECT_NAME,
"Your Monteverdi cache-directory is set to your home directory '%1'. Deletion of cache-directory is aborted to avoid unrecoverable loss of all your account data.\n\nIt is generally a bad idea to set Monteverdi cache-directory to your home directory. Please choose another sub-directory.\n\nApplication will now exit."
)
.arg( application->GetCacheDir().path() ),
QMessageBox::Ok
);
}
else
{
itksys::SystemTools::RemoveADirectory(
QFile::encodeName( application->GetCacheDir().path() ).constData()
);
}
}
return ERROR_CODE_DATABASE;
}
}
catch( std::exception& exc )
{
QMessageBox::critical(
&mainWindow,
QCoreApplication::translate(
PROJECT_NAME,
"Critical error!"
),
QCoreApplication::translate(
PROJECT_NAME,
"Failed to open Monteverdi database.\n\nApplication will now exit!\n\n%2\n\nPlease, remove your Monteverdi cache-directory."
)
.arg( exc.what() ),
QMessageBox::Ok
);
return ERROR_CODE_DATABASE;
}
//
// 5. Show window.
#if defined( _DEBUG )
// Usefull when developping/debugging to avoid overlapping other windows.
mainWindow.show();
#else
splash.finish(&mainWindow);
// TODO: Correctly manage main-window state via application settings.
mainWindow.showMaximized();
#endif
//
// 6. Check OpenGL capabilities
if( !mainWindow.CheckGLCapabilities() )
return ERROR_CODE_GL_VERSION;
//
// 7. Let's go: run the application and return exit code.
int result = QCoreApplication::instance()->exec();
application->CloseDatabase();
// Coverity-14835
// {
delete application;
application = NULL;
// }
// Coverity-14835
return result;
}
/*****************************************************************************/
/* FUNCTIONS IMPLEMENTATION */
/*****************************************************************************/
/*=========================================================================
Program: Monteverdi
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi 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 "mvdApplication.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
#include "Core/mvdDatabaseModel.h"
//
#ifdef OTB_USE_QT4
#include "ApplicationsWrapper/mvdOTBApplicationsModel.h"
#endif
//
// Class implementation.
namespace mvd
{
/*
TRANSLATOR mvd::Application
Necessary for lupdate to be aware of C++ namespaces.
Context comment for translator.
*/
/*****************************************************************************/
/* CONSTANTS */
/*****************************************************************************/
/* STATIC IMPLEMENTATION SECTION */
/*****************************************************************************/
/* CLASS IMPLEMENTATION SECTION */
/*******************************************************************************/
Application
::Application( QApplication* qtApp ) :
I18nApplication( qtApp ),
m_OTBApplicationsModel( NULL )
{
}
/*******************************************************************************/
Application
::~Application()
{
}
/*******************************************************************************/
CountType
Application
::OpenDatabase()
{
DatabaseModel* databaseModel = new DatabaseModel( this );
DatabaseModel::BuildContext context;
databaseModel->BuildModel( &context );
SetModel( databaseModel );
return context.m_NbOutdatedDatasetModels;
}
/*******************************************************************************/
void
Application
::CloseDatabase()
{
// Delete model and release resources.
SetModel( NULL );
}
/*******************************************************************************/
void
Application
::OpenApplicationsBrowser()
{
#ifdef OTB_USE_QT4
m_OTBApplicationsModel = new OTBApplicationsModel( this );
m_OTBApplicationsModel->BuildModel();
#endif
}
/*******************************************************************************/
void
Application
::virtual_InitializeCore()
{
I18nApplication::virtual_InitializeCore();
setObjectName( "Application" );
InitializeCore(
PROJECT_NAME, Monteverdi_VERSION_STRING,
"OrfeoToolBox", "orfeo-toolbox.org"
);
//
// create the OTBApplications model
OpenApplicationsBrowser();
}
/*******************************************************************************/
/* SLOTS */
} // end namespace 'mvd'
/*=========================================================================
Program: Monteverdi
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi 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 __mvdApplication_h
#define __mvdApplication_h
//
// Configuration include.
//// Included at first position before any other ones.
#include "ConfigureMonteverdi.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)
//
// Monteverdi includes (sorted by alphabetic order)
#include "Gui/mvdI18nApplication.h"
/*****************************************************************************/
/* PRE-DECLARATION SECTION */
//
// External classes pre-declaration.
namespace
{
}
namespace mvd
{
class OTBApplicationsModel;
//
// Class declaration.
/*****************************************************************************/
/* CLASS DEFINITION SECTION */
/** \class Application
*
*/
class Monteverdi_EXPORT Application
: public I18nApplication
{
/*-[ QOBJECT SECTION ]-----------------------------------------------------*/
Q_OBJECT;
/*-[ PUBLIC SECTION ]------------------------------------------------------*/
//
// Public constants/types.
public:
//
// Public methods.
public:
/**
* \brief Constructor.
*
* \param qtApp The parent Qt application (\see I18nApplication).
*/
Application( QApplication* qtApp );
/** \brief Destructor. */
virtual ~Application();
/**
* \return The number of outdated dataset-models present in the
* cache-directory.
*/
CountType OpenDatabase();
/**
*/
void CloseDatabase();
/**
* \brief Get the OTB application model.
*/