Commit 6463cb9c authored by finetjul's avatar finetjul
Browse files

ENH: Merge Slicer4 branch on trunk rev12438 -> rev13314

git-svn-id: http://svn.slicer.org/Slicer4/trunk@13315 3bd1e089-480b-0410-8dfb-8563597acbee
parent a7c2523b
/*=========================================================================
Program: Slicer
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for 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 "CLIModule4TestCLP.h"
// STD includes
#include <iostream>
#include <fstream>
// Use an anonymous namespace to keep class types and function names
// from colliding when module is used as shared object module. Every
// thing should be in an anonymous namespace except for the module
// entry point, e.g. main()
//
namespace
{
bool outputResult(int result, const std::string& outputFile)
{
std::ofstream myfile;
myfile.open(outputFile.c_str());
if (!myfile.is_open())
{
std::cerr << "Failed to open file:" << outputFile << std::endl;
return false;
}
myfile << result << "\n";
myfile.close();
return true;
}
} // end of anonymous namespace
int main(int argc, char * argv[])
{
PARSE_ARGS;
int result = 0;
if (OperationType == std::string("Addition"))
{
result = InputValue1 + InputValue2;
}
else if (OperationType == std::string("Multiplication"))
{
result = InputValue1 * InputValue2;
}
else
{
std::cerr << "Unknown OperationType:" << OperationType << std::endl;
return EXIT_FAILURE;
}
if (!outputResult(result, OutputFile))
{
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
<?xml version="1.0" encoding="utf-8"?>
<executable>
<category>Testing</category>
<title>Command Line Module Test</title>
<description>
Command line module used to test the automatic UI generator.\n
</description>
<version>0.0.1</version>
<documentation-url></documentation-url>
<license></license>
<contributor>Jean-Christophe Fillion-Robin</contributor>
<acknowledgements>
</acknowledgements>
<parameters>
<label>Test Settings</label>
<integer>
<name>InputValue1</name>
<label>Input Value 1</label>
<longflag>--inputvalue1</longflag>
<description>Input value 1</description>
<default>1</default>
</integer>
<integer>
<name>InputValue2</name>
<label>Input Value 2</label>
<longflag>--inputvalue2</longflag>
<description>Input value 2</description>
<default>1</default>
</integer>
<string-enumeration>
<name>OperationType</name>
<label>Operation Type</label>
<description>What kind of operation to perform: Addition or multiplication</description>
<longflag>--operationtype</longflag>
<default>Addition</default>
<element>Addition</element>
<element>Multiplication</element>
</string-enumeration>
<file fileExtensions="">
<name>OutputFile</name>
<label>Output File</label>
<channel>output</channel>
<index>0</index>
<description>Output file</description>
</file>
</parameters>
</executable>
......@@ -19,6 +19,23 @@ include(${VTK_USE_FILE})
include_directories( ${SlicerBaseCLI_BINARY_DIR} ${SlicerBaseCLI_SOURCE_DIR} )
link_directories(${SlicerBaseCLI_BINARY_DIR})
#####################
if(BUILD_TESTING)
set (CLP CLIModule4Test)
set ( ${CLP}_SOURCE ${CLP}.cxx)
generateclp(${CLP}_SOURCE ${CLP}.xml ${Slicer3_SOURCE_DIR}/Resources/ITKLogo.h)
add_library(${CLP}Lib SHARED ${${CLP}_SOURCE})
set_target_properties (${CLP}Lib PROPERTIES COMPILE_FLAGS "-Dmain=ModuleEntryPoint")
slicer3_set_plugins_output_path(${CLP}Lib)
target_link_libraries (${CLP}Lib)
add_executable(${CLP} ${CLI_SOURCE_DIR}/Templates/CommandLineSharedLibraryWrapper.cxx)
slicer3_set_plugins_output_path(${CLP})
target_link_libraries (${CLP} ${CLP}Lib)
endif()
#####################
set (CLP DiffusionTensorTest)
......
......@@ -495,6 +495,6 @@ INSTALL(TARGETS SlicerQT${SlicerQT_EXE_SUFFIX}
# --------------------------------------------------------------------------
# Testing
#
# if(Slicer3_BUILD_TESTING)
# ADD_SUBDIRECTORY(Testing)
# endif(Slicer3_BUILD_TESTING)
IF(Slicer3_BUILD_TESTING)
ADD_SUBDIRECTORY(Testing)
ENDIF(Slicer3_BUILD_TESTING)
......@@ -22,7 +22,7 @@
<number>0</number>
</property>
<item>
<widget class="qVTKRenderView" name="VTKRenderView"/>
<widget class="ctkVTKRenderView" name="VTKRenderView"/>
</item>
</layout>
</widget>
......@@ -152,7 +152,7 @@
<widget class="qSlicerModulePanel" name="ModulePanel"/>
</item>
<item>
<widget class="qCTKCollapsibleButton" name="SliceControlsCollapsibleWidget">
<widget class="ctkCollapsibleButton" name="SliceControlsCollapsibleWidget">
<property name="text">
<string>Manipulate Slice Views</string>
</property>
......@@ -163,7 +163,7 @@
</widget>
</item>
<item>
<widget class="qCTKCollapsibleButton" name="View3DControlsCollapsibleWidget">
<widget class="ctkCollapsibleButton" name="View3DControlsCollapsibleWidget">
<property name="text">
<string>Manipulate 3D View</string>
</property>
......@@ -470,9 +470,9 @@
</widget>
<customwidgets>
<customwidget>
<class>qCTKCollapsibleButton</class>
<class>ctkCollapsibleButton</class>
<extends>QWidget</extends>
<header>qCTKCollapsibleButton.h</header>
<header>ctkCollapsibleButton.h</header>
<container>1</container>
</customwidget>
<customwidget>
......@@ -487,9 +487,9 @@
<header>qSlicerModulePanel.h</header>
</customwidget>
<customwidget>
<class>qVTKRenderView</class>
<class>ctkVTKRenderView</class>
<extends>QWidget</extends>
<header>qVTKRenderView.h</header>
<header>ctkVTKRenderView.h</header>
</customwidget>
</customwidgets>
<resources>
......
SET(KIT SlicerQT)
SET(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "DEBUG_LEAKS_ENABLE_EXIT_ERROR();" )
CREATE_TEST_SOURCELIST(Tests ${KIT}CxxTests.cxx
qSlicerModuleFactoryManagerTest1.cxx
EXTRA_INCLUDE TestingMacros.h
)
SET (TestsToRun ${Tests})
REMOVE (TestsToRun ${KIT}CxxTests.cxx)
SET(LIBRARY_NAME qSlicerQT)
ADD_EXECUTABLE(${KIT}CxxTests ${Tests})
TARGET_LINK_LIBRARIES(${KIT}CxxTests ${LIBRARY_NAME})
SET( KIT_TESTS ${CXX_TEST_PATH}/${KIT}CxxTests)
IF(WIN32)
SET(KIT_TESTS ${CXX_TEST_PATH}/${CMAKE_BUILD_TYPE}/${KIT}CxxTests)
ENDIF(WIN32)
MACRO( SIMPLE_TEST TESTNAME )
ADD_TEST( ${TESTNAME} ${LAUNCH_EXE} ${KIT_TESTS} ${TESTNAME} )
ENDMACRO( SIMPLE_TEST )
#
# Add Tests
#
# ADD_TEST( qSlicerCoreApplicationTest1
# ${LAUNCH_EXE}
# ${QTCore_TESTS} qSlicerCoreApplicationTest1
# ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/SlicerQT )
SIMPLE_TEST( qSlicerModuleFactoryManagerTest1 )
/*=auto=========================================================================
Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
See Doc/copyright/copyright.txt
or http://www.slicer.org/copyright/copyright.txt for details.
Program: 3D Slicer
=========================================================================auto=*/
// QT includes
#include <QString>
#include <QStringList>
// SlicerQt includes
#include <qSlicerModuleFactoryManager.h>
#include <qSlicerCoreModuleFactory.h>
// STD includes
#include <cstdlib>
#include <iostream>
#include "TestingMacros.h"
int qSlicerModuleFactoryManagerTest1(int, char * [] )
{
qSlicerModuleFactoryManager moduleFactoryManager;
// Register factories
moduleFactoryManager.registerFactory("qSlicerCoreModuleFactory", new qSlicerCoreModuleFactory());
// Register core modules
moduleFactoryManager.registerModules("qSlicerCoreModuleFactory");
QString moduleName = "qSlicerTransformsModule";
if (!moduleFactoryManager.moduleTitle( moduleName ).isEmpty())
{
moduleFactoryManager.printAdditionalInfo();
std::cerr << __LINE__ << " - Error: Registered module " << qPrintable(moduleName)
<< " can't have a valid title yet."
<< " Titles get set after the module get instantiated." << std::endl;
return EXIT_FAILURE;
}
qSlicerAbstractModule * abstractModule = moduleFactoryManager.instantiateModule( moduleName );
if( abstractModule == NULL )
{
moduleFactoryManager.printAdditionalInfo();
std::cerr << __LINE__ << " - Error in instantiateModule()" << std::endl;
return EXIT_FAILURE;
}
QString moduleTitle = moduleFactoryManager.moduleTitle( moduleName );
QString moduleName1 = moduleFactoryManager.moduleName( moduleTitle );
if( moduleName1 != moduleName )
{
moduleFactoryManager.printAdditionalInfo();
std::cerr << __LINE__ << " - Error in moduleTitle() or moduleName()" << std::endl
<< "moduleTitle = " << qPrintable( moduleTitle ) << std::endl
<< "moduleName = " << qPrintable( moduleName ) << std::endl
<< "moduleName1 = " << qPrintable( moduleName1 ) << std::endl;
return EXIT_FAILURE;
}
QString moduleTitle1 = moduleFactoryManager.moduleTitle( moduleName );
if( moduleTitle1 != moduleTitle )
{
moduleFactoryManager.printAdditionalInfo();
std::cerr << __LINE__ << " - Error in getModuleTitle()" << std::endl
<< "moduleTitle = " << qPrintable( moduleTitle ) << std::endl
<< "moduleTitle1 = " << qPrintable( moduleTitle1 ) << std::endl;
return EXIT_FAILURE;
}
QString moduleTitle2 = abstractModule->title();
if( moduleTitle2 != moduleTitle )
{
moduleFactoryManager.printAdditionalInfo();
std::cerr << __LINE__ << " - Error in title():" << qPrintable(moduleTitle2) << std::endl
<< "moduleTitle = " << qPrintable( moduleTitle ) << std::endl
<< "moduleTitle2 = " << qPrintable( moduleTitle2 ) << std::endl;
return EXIT_FAILURE;
}
moduleFactoryManager.uninstantiateModule( moduleName );
// Instantiate again
abstractModule = moduleFactoryManager.instantiateModule( moduleName );
if( abstractModule == NULL )
{
moduleFactoryManager.printAdditionalInfo();
std::cerr << __LINE__ << " - Error in instantiateModule()" << std::endl;
return EXIT_FAILURE;
}
moduleFactoryManager.uninstantiateAll();
return EXIT_SUCCESS;
}
#include "qSlicerMainWindow.h"
// Qt includes
#include <QDebug>
// SlicerQt includes
#include "qSlicerMainWindow.h"
#include "ui_qSlicerMainWindow.h"
// SlicerQT includes
#include "qSlicerApplication.h"
#include "qSlicerModulePanel.h"
#include "qSlicerModuleManager.h"
#include "qSlicerMainWindowCore.h"
#include "qSlicerModuleSelectorWidget.h"
// QT includes
#include <QDebug>
//-----------------------------------------------------------------------------
class qSlicerMainWindowPrivate: public qCTKPrivate<qSlicerMainWindow>, public Ui_qSlicerMainWindow
class qSlicerMainWindowPrivate: public ctkPrivate<qSlicerMainWindow>, public Ui_qSlicerMainWindow
{
public:
QCTK_DECLARE_PUBLIC(qSlicerMainWindow);
CTK_DECLARE_PUBLIC(qSlicerMainWindow);
qSlicerMainWindowPrivate()
{
this->Core = 0;
......@@ -30,8 +28,8 @@ public:
//-----------------------------------------------------------------------------
qSlicerMainWindow::qSlicerMainWindow(QWidget *_parent):Superclass(_parent)
{
QCTK_INIT_PRIVATE(qSlicerMainWindow);
QCTK_D(qSlicerMainWindow);
CTK_INIT_PRIVATE(qSlicerMainWindow);
CTK_D(qSlicerMainWindow);
d->setupUi(this);
// Main window core helps to coordinate various widgets and panels
......@@ -41,16 +39,16 @@ qSlicerMainWindow::qSlicerMainWindow(QWidget *_parent):Superclass(_parent)
}
//-----------------------------------------------------------------------------
QCTK_GET_CXX(qSlicerMainWindow, qSlicerMainWindowCore*, core, Core);
CTK_GET_CXX(qSlicerMainWindow, qSlicerMainWindowCore*, core, Core);
//-----------------------------------------------------------------------------
QCTK_GET_CXX(qSlicerMainWindow, QToolBar*, moduleToolBar, ModuleToolBar);
CTK_GET_CXX(qSlicerMainWindow, QToolBar*, moduleToolBar, ModuleToolBar);
//-----------------------------------------------------------------------------
QCTK_GET_CXX(qSlicerMainWindow, qSlicerModulePanel*, modulePanel, ModulePanel);
CTK_GET_CXX(qSlicerMainWindow, qSlicerModulePanel*, modulePanel, ModulePanel);
//-----------------------------------------------------------------------------
QCTK_GET_CXX(qSlicerMainWindow, qSlicerModuleSelectorWidget*, moduleSelector, ModuleSelector);
CTK_GET_CXX(qSlicerMainWindow, qSlicerModuleSelectorWidget*, moduleSelector, ModuleSelector);
//-----------------------------------------------------------------------------
// Helper macro allowing to connect the MainWindow action with the corresponding
......@@ -64,12 +62,15 @@ QCTK_GET_CXX(qSlicerMainWindow, qSlicerModuleSelectorWidget*, moduleSelector, Mo
//-----------------------------------------------------------------------------
void qSlicerMainWindow::setupMenuActions()
{
QCTK_D(qSlicerMainWindow);
CTK_D(qSlicerMainWindow);
this->connect(
d->actionFileExit, SIGNAL(triggered()),
qSlicerApplication::instance(), SLOT(quit()));
qSlicerMainWindow_connect(FileAddData);
qSlicerMainWindow_connect(FileImportScene);
qSlicerMainWindow_connect(FileLoadScene);
qSlicerMainWindow_connect(EditRedo);
qSlicerMainWindow_connect(EditUndo);
qSlicerMainWindow_connect(WindowPythonInteractor);
......@@ -84,7 +85,7 @@ void qSlicerMainWindow::setupMenuActions()
//-----------------------------------------------------------------------------
void qSlicerMainWindowPrivate::setupUi(QMainWindow * mainWindow)
{
QCTK_P(qSlicerMainWindow);
CTK_P(qSlicerMainWindow);
this->Ui_qSlicerMainWindow::setupUi(mainWindow);
......
#ifndef __qSlicerMainWindow_h
#define __qSlicerMainWindow_h
// QT includes
// Qt includes
#include <QMainWindow>
// qCTK includes
#include <qCTKPimpl.h>
// CTK includes
#include <ctkPimpl.h>
#include "qSlicerQTExport.h"
......@@ -46,7 +46,7 @@ protected:
void setupMenuActions();
private:
QCTK_DECLARE_PRIVATE(qSlicerMainWindow);
CTK_DECLARE_PRIVATE(qSlicerMainWindow);
};
#endif
// QT includes
// Qt includes
#include <QSignalMapper>
#include <QToolBar>
#include <QAction>
#include <QDebug>
// qCTK includes
#include <qCTKPythonShell.h>
#include "vtkSlicerConfigure.h" // For Slicer3_USE_PYTHONQT
// MRML includes
#include <vtkMRMLScene.h>
// CTK includes
#ifdef Slicer3_USE_PYTHONQT
#include <ctkPythonShell.h>
#endif
// SlicerQT includes
// SlicerQt includes
#include "qSlicerMainWindowCore.h"
#include "qSlicerMainWindowCore_p.h"
#include "qSlicerApplication.h"
......@@ -19,9 +20,13 @@
#include "qSlicerAbstractModule.h"
#include "qSlicerAbstractModuleWidget.h"
#include "qSlicerModuleManager.h"
#include "qSlicerIOManager.h"
#ifdef Slicer3_USE_PYTHONQT
#include "qSlicerPythonManager.h"
#endif
#include "vtkSlicerConfigure.h" // For Slicer3_USE_PYTHONQT
// MRML includes
#include <vtkMRMLScene.h>
//---------------------------------------------------------------------------
// qSlicerMainWindowCorePrivate methods
......@@ -32,14 +37,14 @@ qSlicerMainWindowCorePrivate::qSlicerMainWindowCorePrivate()
this->PythonShell = 0;
this->ShowModuleActionMapper = new QSignalMapper(this);
this->ToolBarModuleList << "Measurements" << "Transforms" << "Volumes";
this->ToolBarModuleList << "Measurements" << "MRMLTree" << "Transforms" << "Volumes";
}
//---------------------------------------------------------------------------
void qSlicerMainWindowCorePrivate::onModuleLoaded(qSlicerAbstractModule* module)
{
Q_ASSERT(module);
QCTK_P(qSlicerMainWindowCore);
CTK_P(qSlicerMainWindowCore);
qSlicerAbstractModuleWidget* moduleWidget = module->widgetRepresentation();
Q_ASSERT(moduleWidget);
......@@ -65,7 +70,7 @@ void qSlicerMainWindowCorePrivate::onModuleLoaded(qSlicerAbstractModule* module)
void qSlicerMainWindowCorePrivate::onModuleAboutToBeUnloaded(qSlicerAbstractModule* module)
{
Q_ASSERT(module);
QCTK_P(qSlicerMainWindowCore);
CTK_P(qSlicerMainWindowCore);
qSlicerAbstractModuleWidget* moduleWidget = module->widgetRepresentation();
Q_ASSERT(moduleWidget);
......@@ -83,8 +88,8 @@ void qSlicerMainWindowCorePrivate::onModuleAboutToBeUnloaded(qSlicerAbstractModu
//-----------------------------------------------------------------------------
qSlicerMainWindowCore::qSlicerMainWindowCore(qSlicerMainWindow* _parent):Superclass(_parent)
{
QCTK_INIT_PRIVATE(qSlicerMainWindowCore);
QCTK_D(qSlicerMainWindowCore);
CTK_INIT_PRIVATE(qSlicerMainWindowCore);
CTK_D(qSlicerMainWindowCore);
d->ParentWidget = _parent;
......@@ -106,7 +111,26 @@ qSlicerMainWindowCore::qSlicerMainWindowCore(qSlicerMainWindow* _parent):Supercl
}
//-----------------------------------------------------------------------------
QCTK_GET_CXX(qSlicerMainWindowCore, qSlicerMainWindow*, widget, ParentWidget);
CTK_GET_CXX(qSlicerMainWindowCore, qSlicerMainWindow*, widget, ParentWidget);
//---------------------------------------------------------------------------
void qSlicerMainWindowCore::onFileAddDataActionTriggered()
{
qSlicerApplication::application()->ioManager()->openLoadDataDialog();
}
//---------------------------------------------------------------------------
void qSlicerMainWindowCore::onFileImportSceneActionTriggered()
{
qSlicerApplication::application()->ioManager()->openImportSceneDialog();
}
//---------------------------------------------------------------------------
void qSlicerMainWindowCore::onFileLoadSceneActionTriggered()
{
qSlicerApplication::application()->ioManager()->openLoadSceneDialog();
}
//---------------------------------------------------------------------------
void qSlicerMainWindowCore::onEditUndoActionTriggered()
......@@ -124,11 +148,11 @@ void qSlicerMainWindowCore::onEditRedoActionTriggered()
void qSlicerMainWindowCore::onWindowPythonInteractorActionTriggered()
{
#ifdef Slicer3_USE_PYTHONQT
QCTK_D(qSlicerMainWindowCore);
CTK_D(qSlicerMainWindowCore);
if (!d->PythonShell)
{
Q_ASSERT(qSlicerApplication::application()->pythonManager());
d->PythonShell = new qCTKPythonShell(qSlicerApplication::application()->pythonManager()/*, d->ParentWidget*/);
d->PythonShell = new ctkPythonShell(qSlicerApplication::application()->pythonManager()/*, d->ParentWidget*/);
d->PythonShell->setAttribute(Qt::WA_QuitOnClose, false);
d->PythonShell->resize(600, 280);
}
......
#ifndef __qSlicerMainWindowCore_h
#define __qSlicerMainWindowCore_h
// QT includes
// Qt includes
#include <QObject>
// qCTK includes
#include <qCTKPimpl.h>
// CTK includes
#include <ctkPimpl.h>
#include "qSlicerQTExport.h"
......@@ -21,8 +21,11 @@ public:
qSlicerMainWindowCore(qSlicerMainWindow *parent);
public slots:
// Description:
// Handle actions
///
/// Handle actions - See qSlicerMainWindow::setupMenuActions
void onFileAddDataActionTriggered();
void onFileImportSceneActionTriggered();
void onFileLoadSceneActionTriggered();