Commit 907bf2f2 authored by promayon's avatar promayon
Browse files

NEW smaller Application initialization (3 lines are now enough to start a...

NEW smaller Application initialization (3 lines are now enough to start a CamiTK application, see imp/main.cpp!)
FIXED clean wizard CMakeLists.txt

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@90 ec899d31-69d1-42ba-9299-647d76f65fb3
parent c8e1776d
......@@ -28,13 +28,14 @@ $CAMITK_LICENCE_END$
// -- Core stuff
#include <Application.h>
using namespace camitk;
int main(int argc, char *argv[]) {
camitk::Application a(argc, argv);
a.init(true);
// init the camitk application context
Application a(argc, argv);
ImpMainWindow imp;
a.setMainWindow(&imp);
// set the ImpMainWindow as the main window
a.setMainWindow(new ImpMainWindow());
return a.exec();
}
......
application_extension(NEEDS_XSD
NEEDS_XERCESC
NEEDS_TOOL coreschema)
# specific section in order to use the XML module of Qt
if(APPLICATION_WIZARD)
# Find Qt4 specific for the wizard because it needs the XML lib
# by default only QtCore and QtGui modules are enabled
# We need to do a specific Find Qt4
# for the wizard because it needs the XML module of Qt.
# By default in CamiTK, only QtCore and QtGui modules are enabled
# other modules must be enabled like this:
set (QT_USE_QT3SUPPORT OFF)
set (QT_USE_QTWEBKIT ON)
......@@ -32,114 +31,3 @@ if(APPLICATION_WIZARD)
target_link_libraries(application-wizard ${QT_LIBRARIES})
endif()
if (FALSE)
project(applicationwizard)
cmake_minimum_required(VERSION 2.6)
# dependencies
find_package(XSD REQUIRED)
find_package(XercesC REQUIRED)
# the name of the C++ library generated by the XML Schema
set(SCHEMA_NAME "coreschema")
# Find Qt4
# by default only QtCore and QtGui modules are enabled
# other modules must be enabled like this:
set (QT_USE_QT3SUPPORT OFF)
set (QT_USE_QTWEBKIT ON)
set (QT_USE_QTXML ON)
set (QT_USE_QTXMLPATTERNS ON)
if (WIN32)
set (QT_USE_QTMAIN ON)
endif (WIN32)
find_package(Qt4 REQUIRED)
if(QT_USE_FILE)
INCLUDE(${QT_USE_FILE})
else(QT_USE_FILE)
set(QT_LIBRARIES ${QT_QT_LIBRARY})
endif(QT_USE_FILE)
ADD_DEFINITIONS(
-DQT_GUI_LIB
-DQT_CORE_LIB
-DQT_GUI_LIBS
-DQT_CORE_LIB
)
set(wizard_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CAMITK_INCLUDE_DIR}/${SCHEMA_NAME}
${XSD_INCLUDE_DIR}
)
include_directories(${wizard_INCLUDE_DIR})
macro(gather_headers_and_sources Name)
# gather all possible C++ and Qt sources
if (${ARGC} EQUAL 1)
file(GLOB_RECURSE HEADERS *.h)
file(GLOB_RECURSE SRCS *.cpp)
file(GLOB_RECURSE File_UI *.ui)
file(GLOB_RECURSE File_QRC *.qrc)
else()
# if an optional parameter is used, gather everything from BaseDirectory
file(GLOB_RECURSE HEADERS ${ARGV1}/*.h )
file(GLOB_RECURSE SRCS ${ARGV1}/*.cpp )
file(GLOB_RECURSE File_UI ${ARGV1}/*.ui )
file(GLOB_RECURSE File_QRC ${ARGV1}/*.qrc )
endif()
# manage Qt ui
qt4_wrap_ui (UI ${File_UI})
# manage Qt resources
qt4_add_resources(QRC ${File_QRC})
# find Q_OBJECT derived class
foreach(HEADER ${HEADERS})
file(READ ${HEADER} stream)
if(stream MATCHES "Q_OBJECT")
set(MOC_SOURCES ${MOC_SOURCES} ${HEADER})
endif(stream MATCHES "Q_OBJECT")
endforeach(HEADER)
# manage Qt inherited sources
qt4_wrap_cpp(QT_SRCS ${MOC_SOURCES})
# name all headers
set (${Name}_HEADERS
${HEADERS}
${UI}
${QRC}
)
# name all sources
set (${Name}_SOURCES
${HEADERS}
${UI}
${QRC}
${SRCS}
${QT_SRCS}
)
endmacro ()
gather_headers_and_sources(wizard)
add_executable(wizard ${wizard_SOURCES})
target_link_libraries(wizard ${SCHEMA_NAME} ${XERCESC_LIBRARY} ${QT_LIBRARIES})
add_dependencies(wizard ${SCHEMA_NAME})
# installation
install(TARGETS wizard
RUNTIME DESTINATION bin
COMPONENT wizard
)
endif()
......@@ -49,10 +49,27 @@ MainWindow * Application::mainWindow = NULL;
QSettings Application::settings(QSettings::IniFormat, QSettings::UserScope, "TIMC-IMAG", QString(Core::version).remove(QChar(' ')));
// ----------------- constructor --------------------
Application::Application(int & theArgc, char ** theArgv): QApplication(theArgc, theArgv) {
Application::Application(int & theArgc, char ** theArgv, bool autoloadExtensions): QApplication(theArgc, theArgv) {
argc = theArgc;
argv = theArgv;
mainWindow = NULL;
initIcons(); // sometimes needed to get the icon when compiled in static mode
// recommanded (see exec() comment in QApplication
connect(this, SIGNAL(aboutToQuit()), SLOT(quitting()));
// init log file if needed
#ifdef LOG_IN_FILE
Log::openLogFile();
#endif
// once the log and the redirection is setup, only now one can try to load the extensions
if (autoloadExtensions) {
ExtensionsManager::autoloadExtensions();
ActionManager::autoloadActions();
}
}
// ----------------- destructor --------------------
......@@ -71,25 +88,6 @@ void Application::quitting() {
}
// ----------------- init --------------------
void Application::init(bool autoloadExtension) {
initIcons(); // sometimes needed to get the icon when compiled in static mode
// recommanded (see exec() comment in QApplication
connect(this, SIGNAL(aboutToQuit()), SLOT(quitting()));
// init log file if needed
#ifdef LOG_IN_FILE
Log::openLogFile();
#endif
// once the log and the redirection is setup, only now one can try to load the extensions
if (autoloadExtension) {
ExtensionsManager::autoloadExtensions();
ActionManager::autoloadActions();
}
}
// ----------------- setMainWindow --------------------
void Application::setMainWindow(MainWindow* mw) {
if (!mw)
......
......@@ -43,24 +43,22 @@ class CAMITK_API Application : public QApplication {
Q_OBJECT
public:
/** default constructor, parameters comes from the command line see QApplication API documentation.
*/
Application(int & argc, char ** argv);
/// destructor
virtual ~Application();
/** You need to call this method in order to initialize the application.
* This method inits the CamiTK context:
/**
* Initializes the window system and constructs a CamiTK application object with argc command line arguments in argv.
* default constructor, the first and second parameters comes from the command line (see QApplication API documentation).
* This constructor inits all the CamiTK context:
* - log file
* - application wide settings
* - autoload (or not) of the extension
* - autoload (or not, depending on the last parameter) of the extension
*
* Note that you have to call init before doing anything!
*
* @param autoloadExtension if true, all the plugins are loaded
*/
void init(bool autoloadExtension = true);
Application(int & argc, char ** argv, bool autoloadExtension = true);
/// destructor
virtual ~Application();
/** set the main window
* You need to call this method in order to use a customized CamiTK MainWindow instead
......
Supports Markdown
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