Commit 513d094e authored by jcfr's avatar jcfr
Browse files

BUG: QtSlicer - Remove macro...

BUG: QtSlicer - Remove macro qSlicerGetModuleTitleDefinitionMacro/qSlicerGetModuleTitleDeclrationMacro and add the virtual method moduleTitle. In vtkSlicerApplication, rename method InitializeQtModule to InitializeQtCoreModule and add method InitializeQtCoreModules. Update QTModules and add the QtPlugin declaration. Update the appropriate header and cmake files in order to install the Qt loadable modules into a separate directory named 'QTLoadableModules'

git-svn-id: http://svn.slicer.org/Slicer4/trunk@10843 3bd1e089-480b-0410-8dfb-8563597acbee
parent 903171fb
......@@ -18,6 +18,7 @@
#ifdef Slicer3_USE_QT
#include "qSlicerApplication.h"
// #include "vtkSlicerEmptyModuleGUI.h"
#include <QDebug>
#endif
#include "vtkOpenGLRenderWindow.h"
......@@ -848,9 +849,9 @@ int Slicer3_main(int& argc, char *argv[])
scene->SetRootDirectory(root.c_str());
vtkMRMLScene::SetActiveScene( scene );
slicerApp->SetMRMLScene( scene );
#ifdef Slicer3_USE_QT
#ifdef Slicer3_USE_QT
qSlicerApplication::application()->setMRMLScene( scene );
#endif
#endif
// Create the application Logic object,
// Create the application GUI object
......@@ -1016,6 +1017,27 @@ int Slicer3_main(int& argc, char *argv[])
// installation or build tree) to the user paths
modulePaths = userModulePaths + PathSep + defaultModulePaths;
#ifdef Slicer3_USE_QT
std::string qtModulePaths;
std::string defaultQTModulePaths;
// On Win32, *both* paths have to be there, since scripts are installed
// in the install location, and exec/libs are *automatically* installed
// in intDir.
defaultQTModulePaths = slicerHome + "/" + Slicer3_INSTALL_QTLOADABLEMODULES_LIB_DIR;
if (hasIntDir)
{
defaultQTModulePaths = defaultQTModulePaths + PathSep +
slicerHome + "/" + Slicer3_INSTALL_QTLOADABLEMODULES_LIB_DIR + "/" + intDir;
}
// add the default modules directory (based on the slicer
// installation or build tree) to the user paths
qtModulePaths = userModulePaths + PathSep + defaultQTModulePaths;
cout << "qtModulePaths:" << qtModulePaths << endl;
#endif
// =================== vvv
// TODO: this is moved to the launcher since setting it at run
// time has no effect on dlopen
......@@ -1447,8 +1469,7 @@ int Slicer3_main(int& argc, char *argv[])
// slicerApp->AddModuleGUI ( emptyModuleGUI );
// --- Qt Transforms module
slicerApp->InitializeQtModule("qSlicerTransformsModule");
slicerApp->InitializeQtModule("qSlicerCameraModule");
slicerApp->InitializeQtCoreModules();
#endif
// --- First scene needs a crosshair to be added manually
......
......@@ -2425,7 +2425,15 @@ vtkKWColorPickerDialog* vtkSlicerApplication::GetColorPickerDialog()
//----------------------------------------------------------------------------
#ifdef Slicer3_USE_QT
void vtkSlicerApplication::InitializeQtModule(const char* moduleName)
//----------------------------------------------------------------------------
void vtkSlicerApplication::InitializeQtCoreModules()
{
this->InitializeQtCoreModule("qSlicerTransformsModule");
this->InitializeQtCoreModule("qSlicerCameraModule");
}
//----------------------------------------------------------------------------
void vtkSlicerApplication::InitializeQtCoreModule(const char* moduleName)
{
QString splashMsg = "Initializing %1 Module...";
this->SplashMessage(splashMsg.arg(qSlicerModuleManager::instance()->moduleTitle(moduleName)).toAscii());
......
......@@ -72,9 +72,15 @@ class VTK_SLICER_BASE_GUI_EXPORT vtkSlicerApplication : public vtkKWApplication
#ifdef Slicer3_USE_QT
// Description:
// Initialize a qt Module given its name
// Initialize qt core Modules
//BTX
void InitializeQtModule(const char* moduleName);
void InitializeQtCoreModules();
//ETX
// Description:
// Initialize a qt core Module given its name
//BTX
void InitializeQtCoreModule(const char* moduleName);
//ETX
#endif
......
......@@ -5,8 +5,6 @@
#include "qSlicerBaseGUIQTWin32Header.h"
class vtkMRMLScene;
class Q_SLICER_BASE_GUIQT_EXPORT qSlicerAbstractCoreModule : public qSlicerAbstractModule
{
Q_OBJECT
......
......@@ -5,8 +5,6 @@
#include "qSlicerBaseGUIQTWin32Header.h"
class vtkMRMLScene;
class Q_SLICER_BASE_GUIQT_EXPORT qSlicerAbstractLoadableModule : public qSlicerAbstractModule
{
Q_OBJECT
......@@ -29,4 +27,7 @@ private:
qInternal* Internal;
};
Q_DECLARE_INTERFACE(qSlicerAbstractLoadableModule,
"org.slicer.QTModules.qSlicerAbstractLoadableModule/1.0")
#endif
......@@ -5,21 +5,6 @@
#include "qSlicerBaseGUIQTWin32Header.h"
// Macro allowing to declare:
// - the static method 'moduleTitle()'
// - the member 'ModuleTitle'
#define qSlicerGetModuleTitleDeclarationMacro() \
public: \
static const QString moduleTitle(); \
static QString ModuleTitle;
// Macro allowing to define
// - the static method 'moduleTitle()'
// - the associated module title
#define qSlicerGetModuleTitleDefinitionMacro(_CLASSTYPE, _TITLE) \
const QString _CLASSTYPE::moduleTitle(){ return _CLASSTYPE::ModuleTitle; } \
QString _CLASSTYPE::ModuleTitle = _TITLE;
class Q_SLICER_BASE_GUIQT_EXPORT qSlicerAbstractModule : public qSlicerWidget
{
Q_OBJECT
......@@ -31,6 +16,8 @@ public:
virtual ~qSlicerAbstractModule();
virtual void printAdditionalInfo();
virtual QString moduleTitle() = 0;
// Description:
virtual QString moduleName();
......
......@@ -6,9 +6,6 @@
#include <vector>
//-----------------------------------------------------------------------------
qSlicerGetModuleTitleDefinitionMacro(qSlicerCameraModule, "Cameras");
//-----------------------------------------------------------------------------
class qSlicerCameraModule::qInternal : public Ui::qSlicerCameraModule
{
......@@ -41,6 +38,12 @@ void qSlicerCameraModule::printAdditionalInfo()
this->Superclass::printAdditionalInfo();
}
//-----------------------------------------------------------------------------
QString qSlicerCameraModule::moduleTitle()
{
return "Cameras";
}
//-----------------------------------------------------------------------------
QString qSlicerCameraModule::helpText()
{
......
......@@ -19,7 +19,7 @@ public:
virtual void printAdditionalInfo();
qSlicerGetModuleTitleDeclarationMacro();
virtual QString moduleTitle();
// Return help/about text
virtual QString helpText();
......
......@@ -21,6 +21,7 @@ public:
}
QHash<QString, QString> MapTitleToName;
QHash<QString, QString> MapNameToTitle;
QString SearchPath;
};
//-----------------------------------------------------------------------------
......@@ -69,19 +70,30 @@ void qSlicerModuleFactory::printAdditionalInfo()
template<typename ClassType>
void qSlicerModuleFactory::registerModule(/*const QString& moduleTitle*/)
{
const QString moduleTitle = ClassType::moduleTitle();
// Extract title from class name
QString className = ClassType::staticMetaObject.className();
const QString moduleTitle = className.replace("qSlicer","").replace("Module","");
qDebug() << "qSlicerModuleFactory::registerModule title:" << moduleTitle;
// A given module should be registered only one time
Q_ASSERT(!this->Internal->MapTitleToName.contains(moduleTitle));
if (this->Internal->MapTitleToName.contains(moduleTitle))
{
return;
}
QString moduleName = ClassType::staticMetaObject.className();
Q_ASSERT(!this->Internal->MapNameToTitle.contains(moduleName));
if (this->Internal->MapNameToTitle.contains(moduleName))
{
return;
}
this->registerQObject<ClassType>();
// Keep track of the relation Title -> moduleName
this->Internal->MapTitleToName[moduleTitle] = moduleName;
// Keep track of the relation moduleName -> Title
this->Internal->MapNameToTitle[moduleName] = moduleTitle;
}
......@@ -136,3 +148,9 @@ qSlicerAbstractModule* qSlicerModuleFactory::createModule(const QString& moduleN
qDebug() << module << " - title:" << moduleTitle;
return module;
}
//-----------------------------------------------------------------------------
void qSlicerModuleFactory::setLoadableModuleSearchPath(const QString& searchPath)
{
this->Internal->SearchPath = searchPath;
}
......@@ -28,6 +28,10 @@ public:
// Description:
// Instanciate a module given its name
qSlicerAbstractModule* createModule(const QString& moduleName);
// Description:
// Set path where the loadable modules are located
void setLoadableModuleSearchPath(const QString& searchPath);
protected:
......
......@@ -16,7 +16,7 @@ public:
{
}
QHash<QString, qSlicerAbstractModule*> ModuleList;
QHash<QString, qSlicerAbstractModule*> ModuleList; // Store Pair<ModuleName, ModuleObject>
qSlicerModuleFactory ModuleFactory;
};
......
......@@ -14,9 +14,6 @@
#include <QButtonGroup>
#include <QDebug>
//-----------------------------------------------------------------------------
qSlicerGetModuleTitleDefinitionMacro(qSlicerTransformsModule, "Transforms");
//-----------------------------------------------------------------------------
class qSlicerTransformsModule::qInternal : public Ui::qSlicerTransformsModule
{
......@@ -105,6 +102,12 @@ void qSlicerTransformsModule::printAdditionalInfo()
this->Superclass::printAdditionalInfo();
}
//-----------------------------------------------------------------------------
QString qSlicerTransformsModule::moduleTitle()
{
return "Transforms";
}
//-----------------------------------------------------------------------------
QString qSlicerTransformsModule::helpText()
{
......
......@@ -20,11 +20,11 @@ public:
virtual void printAdditionalInfo();
qSlicerGetModuleTitleDeclarationMacro();
virtual QString moduleTitle();
// Return help/about text
virtual QString helpText();
virtual QString aboutText();
virtual QString aboutText();
protected slots:
void onCoordinateReferenceButtonPressed(int id);
......
......@@ -58,7 +58,7 @@ MACRO(Slicer3_build_qtmodule)
${headers}
"${CMAKE_CURRENT_BINARY_DIR}/qSlicerQTModules${QTMODULE_NAME}Configure.h"
"${CMAKE_CURRENT_BINARY_DIR}/qSlicerQTModules${QTMODULE_NAME}Win32Header.h"
DESTINATION ${Slicer3_INSTALL_MODULES_INCLUDE_DIR}/${PROJECT_NAME} COMPONENT Development
DESTINATION ${Slicer3_INSTALL_QTLOADABLEMODULES_INCLUDE_DIR}/${PROJECT_NAME} COMPONENT Development
)
#file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/Resources/*.h")
......@@ -74,7 +74,7 @@ MACRO(Slicer3_build_qtmodule)
QT4_WRAP_CPP(QTMODULE_SRCS ${QTMODULE_MOC_SRCS})
QT4_WRAP_UI(QTMODULE_UI_CXX ${QTMODULE_UI_SRCS})
IF (${QTMODULE_NO_RESOURCES} EQUAL FALSE)
QT4_ADD_RESOURCES(qSlicerModule_QRC_SRCS Resources/qSlicer${QTMODULE_NAME}Module.qrc)
QT4_ADD_RESOURCES(QTMODULE_QRC_SRCS Resources/qSlicer${QTMODULE_NAME}Module.qrc)
ENDIF(${QTMODULE_NO_RESOURCES} EQUAL FALSE)
SET_SOURCE_FILES_PROPERTIES(
......@@ -105,8 +105,18 @@ MACRO(Slicer3_build_qtmodule)
${QTMODULE_QRC_SRCS}
#${qSlicerModule_TCL_SRCS}
)
slicer3_set_modules_output_path(${lib_name})
# Set qt loadable modules output path
SET_TARGET_PROPERTIES(${lib_name}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/${Slicer3_INSTALL_QTLOADABLEMODULES_BIN_DIR}"
LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/${Slicer3_INSTALL_QTLOADABLEMODULES_LIB_DIR}"
ARCHIVE_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/${Slicer3_INSTALL_QTLOADABLEMODULES_LIB_DIR}"
)
TARGET_LINK_LIBRARIES(${lib_name}
${Slicer3_Libs_LIBRARIES}
${Slicer3_Base_LIBRARIES}
......@@ -125,7 +135,12 @@ MACRO(Slicer3_build_qtmodule)
)
ENDIF(Slicer3_LIBRARY_PROPERTIES)
slicer3_install_modules(${lib_name})
# Install qt loadable modules
INSTALL(TARGETS ${lib_name}
RUNTIME DESTINATION ${Slicer3_INSTALL_QTLOADABLEMODULES_BIN_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${Slicer3_INSTALL_QTLOADABLEMODULES_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${Slicer3_INSTALL_QTLOADABLEMODULES_LIB_DIR} COMPONENT Development
)
ENDMACRO(Slicer3_build_qtmodule)
......
......@@ -109,6 +109,7 @@ BUILD_EXAMPLES:BOOL=@BUILD_EXAMPLES@
Slicer3_BUILD_CLI:BOOL=@Slicer3_BUILD_CLI@
Slicer3_BUILD_MODULES:BOOL=@Slicer3_BUILD_MODULES@
Slicer3_BUILD_QTLOADABLEMODULES:BOOL=@Slicer3_BUILD_QTLOADABLEMODULES@
Slicer3_BUILD_WIN32_CONSOLE:BOOL=@Slicer3_BUILD_WIN32_CONSOLE@
Slicer3_USE_BatchMake:BOOL=@Slicer3_USE_BatchMake@
Slicer3_USE_IGSTK:BOOL=@Slicer3_USE_IGSTK@
......
......@@ -296,6 +296,20 @@ set(LoadableModule_DIR ${Slicer3_BINARY_DIR}/Libs/LoadableModule)
set(vtkITK_DIR ${Slicer3_BINARY_DIR}/Libs/vtkITK)
set(TCLAP_DIR ${Slicer3_BINARY_DIR}/Libs/tclap)
#-----------------------------------------------------------------------------
# Qt Loadable Modules
#
IF(Slicer3_USE_QT)
OPTION(Slicer3_BUILD_QTLOADABLEMODULES "Build Slicer3 QT Loadable Modules" ON)
IF(Slicer3_BUILD_QTLOADABLEMODULES)
ADD_DEFINITIONS(-DSlicer3_BUILD_QTLOADABLEMODULES)
set(Slicer3_INSTALL_QTLOADABLEMODULES_BIN_DIR "${Slicer3_INSTALL_LIB_DIR}/QTLoadableModules")
set(Slicer3_INSTALL_QTLOADABLEMODULES_LIB_DIR "${Slicer3_INSTALL_LIB_DIR}/QTLoadableModules")
set(Slicer3_INSTALL_QTLOADABLEMODULES_INCLUDE_DIR "${Slicer3_INSTALL_INCLUDE_DIR}/QTLoadableModules")
set(Slicer3_INSTALL_QTLOADABLEMODULES_SHARE_DIR "${Slicer3_INSTALL_SHARE_DIR}/QTLoadableModules")
ENDIF(Slicer3_BUILD_QTLOADABLEMODULES)
ENDIF(Slicer3_USE_QT)
# --------------------------------------------------------------------------
# Configure and install headers
......@@ -354,14 +368,11 @@ else(Slicer3_BUILD_MODULES)
endif(Slicer3_BUILD_MODULES)
#-----------------------------------------------------------------------------
# Qt Modules
# Qt Loadable Modules
#
IF(Slicer3_USE_QT)
OPTION(Slicer3_BUILD_QTMODULES "Build Slicer3 QT Modules" ON)
IF(Slicer3_BUILD_QTMODULES)
add_subdirectory(QTModules)
ENDIF(Slicer3_BUILD_QTMODULES)
ENDIF(Slicer3_USE_QT)
IF(Slicer3_USE_QT AND Slicer3_BUILD_QTLOADABLEMODULES)
add_subdirectory(QTModules)
ENDIF(Slicer3_USE_QT AND Slicer3_BUILD_QTLOADABLEMODULES)
#-----------------------------------------------------------------------------
# Applications need to be built after Modules to capture the TractTracing in
......
......@@ -4,9 +4,6 @@
#include <QDebug>
//-----------------------------------------------------------------------------
qSlicerGetModuleTitleDefinitionMacro(qSlicerMeasurementsModule, "Measurements");
//-----------------------------------------------------------------------------
class qSlicerMeasurementsModule::qInternal : public Ui::qSlicerMeasurementsModule
{
......@@ -34,3 +31,9 @@ void qSlicerMeasurementsModule::printAdditionalInfo()
{
this->Superclass::printAdditionalInfo();
}
//-----------------------------------------------------------------------------
QString qSlicerMeasurementsModule::moduleTitle()
{
return "Measurements";
}
......@@ -9,6 +9,7 @@ class Q_SLICER_QTMODULES_MEASUREMENTS_EXPORT qSlicerMeasurementsModule :
public qSlicerAbstractLoadableModule
{
Q_OBJECT
Q_INTERFACES(qSlicerAbstractLoadableModule)
public:
......@@ -18,7 +19,7 @@ public:
virtual void printAdditionalInfo();
qSlicerGetModuleTitleDeclarationMacro();
virtual QString moduleTitle();
private:
class qInternal;
......
......@@ -4,9 +4,6 @@
#include <QDebug>
//-----------------------------------------------------------------------------
qSlicerGetModuleTitleDefinitionMacro(qSlicerVolumesModule, "Volumes");
//-----------------------------------------------------------------------------
class qSlicerVolumesModule::qInternal: public Ui::qSlicerVolumesModule
{
......@@ -34,3 +31,9 @@ void qSlicerVolumesModule::printAdditionalInfo()
{
this->Superclass::printAdditionalInfo();
}
//-----------------------------------------------------------------------------
QString qSlicerVolumesModule::moduleTitle()
{
return "Volumes";
}
......@@ -9,6 +9,7 @@ class Q_SLICER_QTMODULES_VOLUMES_EXPORT qSlicerVolumesModule :
public qSlicerAbstractLoadableModule
{
Q_OBJECT
Q_INTERFACES(qSlicerAbstractLoadableModule)
public:
......@@ -18,7 +19,7 @@ public:
virtual void printAdditionalInfo();
qSlicerGetModuleTitleDeclarationMacro();
virtual QString moduleTitle();
private:
class qInternal;
......
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