Commit b753cf6d authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[MERGE]

parents 4ce9d6d1 c35293b0
......@@ -2,6 +2,7 @@
syntax: glob
*~
*.swp
# switch to regexp syntax.
syntax: regexp
......@@ -25,4 +26,4 @@ syntax: regexp
syntax: glob
.settings
syntax: glob
Release
\ No newline at end of file
Release
......@@ -32,7 +32,7 @@ ENDIF( CMAKE_BUILD_TYPE STREQUAL "Static" )
# To see which boost libs we currently use, you may run the following command
# in the trunk/src directory on a linux box to make some investigations:
# grep -i include `find . -type f` | grep boost | awk '{print $2}' | sort | uniq
FIND_PACKAGE( Boost REQUIRED program_options thread system filesystem date_time )
FIND_PACKAGE( Boost REQUIRED program_options thread filesystem date_time system signals )
ASSERT_GE_VERSION( "Boost" "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}" 1.36.0 )
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
......@@ -101,7 +101,7 @@ IF( NOT CMAKE_BUILD_TYPE STREQUAL "Static" )
TARGET_LINK_LIBRARIES( walnut kernel dataHandler gui guiqt4 common ${Boost_LIBRARIES} )
ELSE( NOT CMAKE_BUILD_TYPE STREQUAL "Static" )
FILE( GLOB_RECURSE ALL_SRC ${PROJECT_SOURCE_DIR}/*.cpp )
FILE( GLOB_RECURSE ALL_SRC ${PROJECT_SOURCE_DIR}/*.[c,h]pp )
FILE( GLOB NIFTI_SRC "dataHandler/io/nifti/*.c" )
ADD_DEFINITIONS( -DHAVE_ZLIB )
......@@ -162,13 +162,13 @@ ADD_CUSTOM_TARGET( tags DEPENDS ctags DEPENDS cscope )
# Checks style guide lines via the BrainLint tool against all source code files
# The output is colored when variable CMAKE_COLOR_MAKEFILE is set to ON,
# noncolored if it is set to OFF
FILE( GLOB_RECURSE STYLE_CPP ${PROJECT_SOURCE_DIR}/*.cpp )
FILE( GLOB_RECURSE STYLE_CPP ${PROJECT_SOURCE_DIR}/*.[c,h]pp )
FILE( GLOB_RECURSE STYLE_H ${PROJECT_SOURCE_DIR}/*.h )
# Set dirs to exclude from stylecheck
SET( EXCLUDE_DIRS "/dataHandler/io/nifti/;/dataHandler/io/biosig/;/dataHandler/io/biosig/XMLParser/" )
FOREACH( dirname ${EXCLUDE_DIRS} )
FILE( GLOB EXCLUDE_H ${PROJECT_SOURCE_DIR}${dirname}*.h )
FILE( GLOB EXCLUDE_CPP ${PROJECT_SOURCE_DIR}${dirname}*.cpp )
FILE( GLOB EXCLUDE_CPP ${PROJECT_SOURCE_DIR}${dirname}*.[c,h]pp )
FOREACH( fname ${EXCLUDE_H} )
LIST( REMOVE_ITEM STYLE_H ${fname} )
......
......@@ -29,7 +29,7 @@
#include "common/WLogger.h"
#include "gui/WGUI.h"
#include "gui/qt4/WMainApplication.h"
#include "gui/qt4/WQt4Gui.h"
#include "kernel/WKernel.h"
......@@ -56,7 +56,7 @@ int main( int argc, char* argv[] )
WSegmentationFault::installSignalHandler();
// initialize GUI
boost::shared_ptr< WGUI > gui = boost::shared_ptr< WGUI >( new WMainApplication() );
boost::shared_ptr< WGUI > gui = boost::shared_ptr< WGUI >( new WQt4Gui() );
// init logger
WLogger logger;
......
FILE( GLOB COMMON_SRC "*.cpp" "*.hpp" )
FILE( GLOB COMMON_SRC "*.[c,h]pp" )
ADD_LIBRARY( common SHARED ${COMMON_SRC} )
TARGET_LINK_LIBRARIES( common ${Boost_LIBRARIES} )
......
......@@ -38,13 +38,22 @@
#include "WException.h"
/**
* initialize static member.
*/
bool WException::noBacktrace = false;
WException::WException( const std::string& msg ): exception()
{
// initialize members
m_msg = msg;
// print stacktrace and message
std::cerr << "Exception thrown! Callstack's backtrace:" << std::endl << getBacktrace() << std::endl;
// no backtrace?
if ( !noBacktrace )
{
std::cerr << "Exception thrown! Callstack's backtrace:" << std::endl << getBacktrace() << std::endl;
}
}
......@@ -156,3 +165,8 @@ std::string WException::getBacktrace() const
return o.str();
}
void WException::disableBacktrace()
{
noBacktrace = true;
}
......@@ -72,6 +72,12 @@ public:
*/
std::string getBacktrace() const;
/**
* Function disables backtraces. Please note that the backtrace can not be reactivated to avoid people from dis/enabling them
* at will.
*/
static void disableBacktrace();
protected:
/**
* Message given during throw.
......@@ -84,6 +90,10 @@ protected:
*/
std::list< std::string > m_trace;
/**
* True if the backtrace should NOT be printed.
*/
static bool noBacktrace;
private:
};
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WTHREADEDRUNNER_TEST_H
#define WTHREADEDRUNNER_TEST_H
#include <iostream>
#include <cxxtest/TestSuite.h>
#include "../WThreadedRunner.h"
/**
* Class implementing a simple worker thread, since proper testing of WThreadedRunner itself is not usable.
*/
class WThreadedRunnerImpl: public WThreadedRunner
{
friend class WThreadedRunnerTest;
protected:
/**
* Function that has to be overwritten for execution. It gets executed in a separate thread after run()
* has been called.
*/
virtual void threadMain()
{
// Since the modules run in a separate thread: such loops are possible
while ( !m_FinishRequested )
{
// do fancy stuff
sleep( 1 );
}
}
};
/**
* Tests the WThreadedRunner class.
*/
class WThreadedRunnerTest : public CxxTest::TestSuite
{
public:
/**
* Ensure that nothing is thrown when an instance is created.
*/
void testInstantiation( void )
{
TS_ASSERT_THROWS_NOTHING( WThreadedRunnerImpl() );
}
/**
* Ensure that nothing is thrown when going to sleep.
*/
void testSleep( void )
{
WThreadedRunnerImpl t;
TS_ASSERT_THROWS_NOTHING( t.sleep( 1 ) );
}
/**
* Ensure that nothing is thrown when running thread.
*/
void testRun( void )
{
WThreadedRunnerImpl t;
TS_ASSERT_THROWS_NOTHING( t.run() );
TS_ASSERT_THROWS_NOTHING( t.wait( true ) );
}
};
#endif // WTHREADEDRUNNER_TEST_H
ADD_SUBDIRECTORY( io )
ADD_SUBDIRECTORY( exceptions )
FILE( GLOB DATAHANDLER_SRC "*.cpp" "*.hpp" )
FILE( GLOB DATAHANDLER_EXCEPTIONS_SRC "exceptions/*.cpp" )
FILE( GLOB DATAHANDLER_LOADERS_SRC "io/WLoader*.cpp" )
FILE( GLOB DATAHANDLER_SRC "*.[c,h]pp" )
FILE( GLOB DATAHANDLER_EXCEPTIONS_SRC "exceptions/*.[c,h]pp" )
FILE( GLOB DATAHANDLER_LOADERS_SRC "io/WLoader*.[c,h]pp" )
ADD_LIBRARY( dataHandler SHARED ${DATAHANDLER_SRC} ${DATAHANDLER_EXCEPTIONS_SRC} ${DATAHANDLER_LOADERS_SRC} )
TARGET_LINK_LIBRARIES( dataHandler common math ${Boost_LIBRARIES} niftiio biosig)
......
......@@ -3,7 +3,7 @@ ADD_SUBDIRECTORY( test )
ADD_SUBDIRECTORY( nifti )
ADD_SUBDIRECTORY( biosig )
FILE( GLOB DATAHANDLER_LOADERS_SRC "WLoader*.cpp" "*.hpp" )
FILE( GLOB DATAHANDLER_LOADERS_SRC "WLoader*.[c,h]pp" )
# Unit tests
IF( CXXTEST_FOUND )
......
......@@ -75,7 +75,7 @@ void WLoaderNIfTI::operator()()
unsigned int nbTens = columns * rows * frames;
unsigned int nbValues = nbTens * vDim;
nifti_image_infodump( header );
// nifti_image_infodump( header );
switch( header->datatype )
{
......
# Package dependencies:
ADD_SUBDIRECTORY( exceptions )
FILE( GLOB GE_EXCEPTIONS_SRC "exceptions/*.cpp" )
FILE( GLOB GE_SRC "*.cpp" )
FILE( GLOB GE_EXCEPTIONS_SRC "exceptions/*.[c,h]pp" )
FILE( GLOB GE_SRC "*.[c,h]pp" )
ADD_LIBRARY( ge SHARED ${GE_SRC} ${GE_EXCEPTIONS_SRC} )
TARGET_LINK_LIBRARIES( ge common ${OPENGL_gl_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES} )
......
ADD_SUBDIRECTORY( qt4 )
FILE( GLOB GUI_SRC "*.cpp" )
FILE( GLOB GUI_SRC "*.[c,h]pp" )
ADD_LIBRARY( gui SHARED ${GUI_SRC} )
TARGET_LINK_LIBRARIES( gui common )
......
......@@ -25,7 +25,11 @@
#ifndef WGUI_H
#define WGUI_H
#include <string>
#include <vector>
#include "../common/WThreadedRunner.h"
#include "qt4/signalslib.hpp"
/**
* This class prescribes the interface to the GUI.
......@@ -39,8 +43,29 @@ public:
* Default destructor.
*/
virtual ~WGUI();
virtual bool isInitalized() = 0;
/**
*
*/
virtual boost::signal0 < void >* addDatasetToBrowser( std::string name, int subjectId ) = 0;
/**
* getter functions for all signals provided by the gui
*/
virtual boost::signal1< void, std::vector< std::string > >* getLoadButtonSignal() = 0;
virtual boost::signal1< void, int >* getAxialSliderSignal() = 0;
virtual boost::signal1< void, int >* getCoronalSliderSignal() = 0;
virtual boost::signal1< void, int >* getSagittalSliderSignal() = 0;
virtual boost::signal1< void, bool >* getAxialButtonSignal() = 0;
virtual boost::signal1< void, bool >* getCoronalButtonSignal() = 0;
virtual boost::signal1< void, bool >* getSagittalButtonSignal() = 0;
protected:
bool m_isInitialized;
};
/**
* \defgroup gui GUI
*
......
......@@ -31,5 +31,8 @@
#include "disc.xpm"
#include "fileopen.xpm"
#include "quit.xpm"
#include "axial.xpm"
#include "cor.xpm"
#include "sag.xpm"
#endif // WICONS_H
......@@ -11,13 +11,18 @@ SET( QT_LIBS ${QT_QTCORE_LIBRARY}
# add here all classes that inherit from QObject
SET(GUI_QT4_MOC_HDRS
WMainWindow.h
WMainWindow.h
WQtNavGLWidget.h
datasetbrowser/WQtDatasetBrowser.h
datasetbrowser/WQtDSBWidget.h
datasetbrowser/WQtNumberEdit.h
datasetbrowser/WQtTreeWidget.h
)
QT4_WRAP_CPP(GUI_QT4_MOC_SRCS ${GUI_QT4_MOC_HDRS} )
FILE(GLOB GUI_QT4_SRC "*.cpp")
FILE(GLOB GUI_QT4_SRC "*.[c,h]pp" "datasetbrowser/*cpp" )
ADD_LIBRARY( guiqt4 SHARED ${GUI_QT4_SRC} ${GUI_QT4_MOC_SRCS} )
TARGET_LINK_LIBRARIES( guiqt4 common gui ge kernel ${QT_LIBS} )
TARGET_LINK_LIBRARIES( guiqt4 common gui ge kernel ${QT_LIBS} ${Boost_LIBRARIES} )
......@@ -25,111 +25,94 @@
#include <iostream>
#include <string>
#include <vector>
#include <QtGui/QApplication>
#include <QtGui/QDockWidget>
#include <QtGui/QFileDialog>
#include <QtGui/QSlider>
#include <QtGui/QVBoxLayout>
#include "WMainWindow.h"
#include "WQtGLWidget.h"
#include "WQtRibbonMenu.h"
#include "WQtDatasetBrowser.h"
#include "../../kernel/WKernel.h"
#include "WQtNavGLWidget.h"
#include "../icons/logoIcon.xpm"
WMainWindow::~WMainWindow()
WMainWindow::WMainWindow()
{
// clean up list with views
m_glWidgets.clear();
}
void WMainWindow::connectSlots( QMainWindow *MainWindow )
WMainWindow::~WMainWindow()
{
QObject::connect( m_toolBar->getQuitButton(), SIGNAL( pressed() ), MainWindow, SLOT( close() ) );
QObject::connect( m_toolBar->getLoadButton(), SIGNAL( pressed() ), this, SLOT( load() ) );
QMetaObject::connectSlotsByName( MainWindow );
// clean up list with views
m_glWidgets.clear();
}
void WMainWindow::setupGUI( QMainWindow *MainWindow )
void WMainWindow::setupGUI( QMainWindow *mainWindow )
{
m_mainWindowIcon.addPixmap( QPixmap( logoIcon_xpm ) );
if( MainWindow->objectName().isEmpty() )
if( mainWindow->objectName().isEmpty() )
{
MainWindow->setObjectName( QString::fromUtf8( "MainWindow" ) );
mainWindow->setObjectName( QString::fromUtf8( "MainWindow" ) );
}
MainWindow->resize( 946, 632 );
MainWindow->setWindowIcon( m_mainWindowIcon );
mainWindow->resize( 946, 632 );
mainWindow->setWindowIcon( m_mainWindowIcon );
m_centralwidget = new QWidget( MainWindow );
m_centralwidget = new QWidget( mainWindow );
m_centralwidget->setObjectName( QString::fromUtf8( "centralwidget" ) );
MainWindow->setCentralWidget( m_centralwidget );
mainWindow->setCentralWidget( m_centralwidget );
m_toolBar = new WQtRibbonMenu( MainWindow );
MainWindow->addToolBar( Qt::TopToolBarArea, m_toolBar );
m_toolBar = new WQtRibbonMenu( mainWindow );
mainWindow->addToolBar( Qt::TopToolBarArea, m_toolBar );
boost::shared_ptr<WQtGLWidget> widget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( MainWindow ) );
boost::shared_ptr<WQtGLWidget> widget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( mainWindow ) );
m_glWidgets.push_back( widget );
MainWindow->setCentralWidget( widget.get() );
mainWindow->setCentralWidget( widget.get() );
// initially 3 views
addNavigationGLWidget( MainWindow, QString( "axial" ) );
addNavigationGLWidget( MainWindow, QString( "coronal" ) );
addNavigationGLWidget( MainWindow, QString( "sagittal" ) );
m_navAxial = new WQtNavGLWidget( "axial", 160 );
m_glWidgets.push_back( m_navAxial->getGLWidget() );
mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navAxial );
m_navCoronal = new WQtNavGLWidget( "coronal", 200 );
m_glWidgets.push_back( m_navCoronal->getGLWidget() );
mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navCoronal );
m_navSagittal = new WQtNavGLWidget( "sagittal", 160 );
m_glWidgets.push_back( m_navSagittal->getGLWidget() );
mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navSagittal );
m_datasetBrowser = new WQtDatasetBrowser();
MainWindow->addDockWidget( Qt::RightDockWidgetArea, m_datasetBrowser );
mainWindow->addDockWidget( Qt::RightDockWidgetArea, m_datasetBrowser );
m_datasetBrowser->addSubject( "subject1" );
m_datasetBrowser->addDataset( 0, "mr188_t1" );
m_datasetBrowser->addDataset( 0, "mr188_evec" );
MainWindow->setWindowTitle( QApplication::translate( "MainWindow",
"OpenWalnut", 0, QApplication::UnicodeUTF8 ) );
mainWindow->setWindowTitle( QApplication::translate( "MainWindow", "OpenWalnut", 0, QApplication::UnicodeUTF8 ) );
connectSlots( MainWindow );
connect( m_toolBar->getQuitButton(), SIGNAL( pressed() ), mainWindow, SLOT( close() ) );
connect( m_toolBar->getLoadButton(), SIGNAL( pressed() ), this, SLOT( openLoadDialog() ) );
connect( m_toolBar->getAxiButton(), SIGNAL( toggled( bool ) ), this, SLOT( toggleAxial( bool ) ) );
connect( m_toolBar->getCorButton(), SIGNAL( toggled( bool ) ), this, SLOT( toggleCoronal( bool ) ) );
connect( m_toolBar->getSagButton(), SIGNAL( toggled( bool ) ), this, SLOT( toggleSagittal( bool ) ) );
}
QSlider* WMainWindow::addNavigationGLWidget( QMainWindow *MainWindow, QString title )
WQtDatasetBrowser* WMainWindow::getDatasetBrowser()
{
QDockWidget *dockWidget = new QDockWidget( title );
dockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
dockWidget->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
QSlider *slider = new QSlider( Qt::Horizontal );
QWidget* panel = new QWidget( dockWidget );
QVBoxLayout* layout = new QVBoxLayout();
boost::shared_ptr<WQtGLWidget> widget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( panel ) );
// TODO(all): add some way to remove QtGLWidgets on destruction to delete QtGLWidget
m_glWidgets.push_back( widget );
layout->addWidget( widget.get() );
layout->addWidget( slider );
panel->setLayout( layout );
dockWidget->setWidget( panel );
MainWindow->addDockWidget( Qt::LeftDockWidgetArea, dockWidget );
return slider;
return m_datasetBrowser;
}
WQtRibbonMenu* WMainWindow::getToolBar()
{
return m_toolBar;
}
void WMainWindow::load()
void WMainWindow::openLoadDialog()
{
std::cout << "test output: load function" << std::endl;
QFileDialog fd;
fd.setFileMode( QFileDialog::ExistingFiles );
......@@ -153,12 +136,59 @@ void WMainWindow::load()
{
stdFileNames.push_back( ( *constIterator ).toLocal8Bit().constData() );
}
m_loaderSignal( stdFileNames );
}
WKernel::getRunningKernel()->doLoadDataSets( stdFileNames );
void WMainWindow::toggleAxial( bool check )
{
m_axiSignal( check );
}
void WMainWindow::toggleCoronal( bool check )
{
m_corSignal( check );
}
WQtDatasetBrowser* WMainWindow::getDatasetBrowser()
void WMainWindow::toggleSagittal( bool check )
{
return m_datasetBrowser;
m_sagSignal( check );
}
boost::signal1< void, std::vector< std::string > >* WMainWindow::getLoaderSignal()
{
return &m_loaderSignal;
}
boost::signal1< void, bool >* WMainWindow::getAxiSignal()
{
return &m_axiSignal;
}
boost::signal1< void, bool >* WMainWindow::getCorSignal()
{
return &m_corSignal;
}
boost::signal1< void, bool >* WMainWindow::getSagSignal()
{
return &m_sagSignal;
}
WQtNavGLWidget* WMainWindow::getNavAxial()
{
return m_navAxial;
}
WQtNavGLWidget* WMainWindow::getNavCoronal()
{
return m_navCoronal;
}
WQtNavGLWidget* WMainWindow::getNavSagittal()
{
return m_navSagittal;
}
......@@ -26,28 +26,24 @@
#define WMAINWINDOW_H
#include <list>
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QIcon>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QSlider>
#include <QtGui/QStatusBar>
#include <QtGui/QToolBar>
#include <QtGui/QWidget>
#include "../WGUI.h"
#include "signalslib.hpp"
#include "WQtNavGLWidget.h"
#include "WQtRibbonMenu.h"
#include "datasetbrowser/WQtDatasetBrowser.h"
// forward declarations
class WQtGLWidget;
class WQtDatasetBrowser;
class WQtRibbonMenu;
/**
* This class contains the main window and the layout
......@@ -59,6 +55,7 @@ class WMainWindow : public QObject
Q_OBJECT
public:
explicit WMainWindow();
/**
* Set up all widgets menus an buttons in the main window.
......@@ -71,37 +68,56 @@ public:
virtual ~WMainWindow();
/**
*
* returns a pointer to the dataset browser object
*/
WQtDatasetBrowser* getDatasetBrowser();