Commit 1463301d authored by schurade's avatar schurade

[ADD] make the load button work and add loaded datasets to the internal data structure

parent 2c72da10
......@@ -24,6 +24,9 @@ ENDIF( CMAKE_HOST_SYSTEM MATCHES Windows )
# Package dependencies:
### BOOST ###
SET( Boost_USE_MULTITHREAD ON )
IF ( CMAKE_BUILD_TYPE STREQUAL "Static" )
SET( Boost_USE_STATIC_LIBS ON )
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 -and -not -name '*svn*'` | grep boost | awk '{print $2}' | sort | uniq
......@@ -100,7 +103,7 @@ IF ( NOT CMAKE_BUILD_TYPE STREQUAL "Static" )
ADD_SUBDIRECTORY( kernel )
ADD_SUBDIRECTORY( common )
ADD_EXECUTABLE( walnut OpenWalnut.cpp utils/WOptionHandler.cpp )
TARGET_LINK_LIBRARIES( walnut kernel guiqt4 common ${Boost_LIBRARIES} ${OPENTHREADS_LIBRARY} )
TARGET_LINK_LIBRARIES( walnut kernel dataHandler guiqt4 common ${Boost_LIBRARIES} ${OPENTHREADS_LIBRARY} )
ELSE ( NOT CMAKE_BUILD_TYPE STREQUAL "Static" )
FILE( GLOB_RECURSE ALL_SRC ${PROJECT_SOURCE_DIR}/*.cpp )
......
......@@ -21,9 +21,18 @@
//
//---------------------------------------------------------------------------
#include <string>
#include <vector>
#include "WDataHandler.h"
#include "WDataSet.h"
#include "exceptions/WNoSuchDataSetException.h"
#include "WLoaderManager.h"
WDataHandler::WDataHandler()
{
}
boost::shared_ptr< const WDataSet > WDataHandler::getDataSet( const unsigned int dataSetId ) const
{
......@@ -32,19 +41,24 @@ boost::shared_ptr< const WDataSet > WDataHandler::getDataSet( const unsigned int
return m_dataSets.at(dataSetId);
}
void WDataHandler::addDataSet( boost::shared_ptr< WDataSet > newDataSet )
{
m_dataSets.push_back( newDataSet );
}
unsigned int WDataHandler::getNumberOfDataSets() const
{
return m_dataSets.size();
}
void WDataHandler::loadDataSets( std::vector< std::string > fileNames )
{
WLoaderManager lm;
for ( size_t i = 0 ; i < fileNames.size() ; ++i)
{
lm.load( fileNames[i], ( boost::shared_ptr<WDataHandler> )this );
}
}
......@@ -24,6 +24,7 @@
#ifndef WDATAHANDLER_H
#define WDATAHANDLER_H
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
......@@ -42,6 +43,11 @@ class WDataHandler
friend class WDataHandlerTest;
public:
/**
*
*/
WDataHandler();
/**
* Get the pointer to the i'th DataSet. The return type is const since we
* want to ensure that each DataSet cannot modified after retrival.
......@@ -58,6 +64,11 @@ public:
*/
unsigned int getNumberOfDataSets() const;
/**
*
*/
void loadDataSets( std::vector< std::string > fileNames );
protected:
private:
......
......@@ -38,8 +38,7 @@ std::string getSuffix( std::string name )
return name.substr( position + 1 );
}
void WLoaderManager::load( std::string fileName,
boost::shared_ptr< WDataHandler > dataHandler )
void WLoaderManager::load( std::string fileName, boost::shared_ptr< WDataHandler > dataHandler )
{
std::string suffix = getSuffix( fileName );
......
......@@ -22,12 +22,16 @@
//---------------------------------------------------------------------------
#include <iostream>
#include <string>
#include <vector>
#include <QtGui/QDockWidget>
#include <QtGui/QFileDialog>
#include "WMainWindow.h"
#include "WQtGLWidget.h"
#include "WQtPipelineBrowser.h"
#include "../../kernel/WKernel.h"
#include "../icons/WIcons.h"
......@@ -176,4 +180,23 @@ void WMainWindow::setEnabled( bool /* enable */ )
void WMainWindow::load()
{
std::cout << "test output: load function" << std::endl;
QFileDialog fd;
fd.setFileMode( QFileDialog::ExistingFiles );
fd.setNameFilter( tr( "Niftii ( *.nii *.nii.gz )" ) );
fd.setViewMode( QFileDialog::Detail );
QStringList fileNames;
if ( fd.exec() )
{
fileNames = fd.selectedFiles();
}
std::vector< std::string >stdFileNames;
QStringList::const_iterator constIterator;
for ( constIterator = fileNames.constBegin(); constIterator != fileNames.constEnd(); ++constIterator )
{
stdFileNames.push_back( ( *constIterator ).toLocal8Bit().constData() );
}
WKernel::getRunningKernel()->doLoadDataSets( stdFileNames );
}
......@@ -23,6 +23,8 @@
#include <iostream>
#include <list>
#include <string>
#include <vector>
#include <boost/thread/xtime.hpp>
......@@ -78,6 +80,12 @@ boost::shared_ptr<WGraphicsEngine> WKernel::getGraphicsEngine() const
return m_GraphicsEngine;
}
boost::shared_ptr<WDataHandler> WKernel::getDataHandler() const
{
return m_DataHandler;
}
int WKernel::getArgumentCount() const
{
return m_ArgC;
......@@ -154,6 +162,9 @@ void WKernel::init()
// initialize GUI
// TODO(all): clean up this option handler mess
m_Gui = boost::shared_ptr<WMainApplication>( new WMainApplication() );
// initialize Datahandler
m_DataHandler = boost::shared_ptr<WDataHandler>( new WDataHandler() );
}
bool WKernel::isFinishRequested() const
......@@ -161,3 +172,8 @@ bool WKernel::isFinishRequested() const
return m_FinishRequested;
}
void WKernel::doLoadDataSets( std::vector< std::string > fileNames )
{
m_DataHandler->loadDataSets( fileNames );
}
......@@ -25,12 +25,15 @@
#define WKERNEL_H
#include <list>
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
#include "WModule.h"
#include "../graphicsEngine/WGraphicsEngine.h"
#include "../gui/qt4/WMainApplication.h"
#include "../dataHandler/WDataHandler.h"
/**
* \par Description:
......@@ -78,6 +81,14 @@ public:
*/
boost::shared_ptr<WGraphicsEngine> getGraphicsEngine() const;
/**
* \par Description
* Returns pointer to the DataHandler.
*
* \return the dh instance.
*/
boost::shared_ptr<WDataHandler> getDataHandler() const;
/**
* \par Description
* Returns pointer to the currently running kernel.
......@@ -110,6 +121,11 @@ public:
*/
bool isFinishRequested() const;
/**
*
*/
void doLoadDataSets( std::vector< std::string > fileNames );
protected:
/**
......@@ -130,6 +146,12 @@ protected:
*/
boost::shared_ptr<WMainApplication> m_Gui;
/**
* \par Description
* The Datahandler.
*/
boost::shared_ptr<WDataHandler> m_DataHandler;
private:
/**
* \par Description
......
......@@ -5,7 +5,6 @@ TARGET_LINK_LIBRARIES( utils ${Boost_PROGRAM_OPTIONS_LIBRARY} guiqt4)
# Unit tests
IF( CXXTEST_FOUND )
CXXTEST_ADD_TESTS_FROM_LIST( "${UTILS_SRC}"
"utils;guiqt4;${Boost_LIBRARIES}"
CXXTEST_ADD_TESTS_FROM_LIST( "${UTILS_SRC}" "utils;guiqt4;dataHandler;${Boost_LIBRARIES}"
)
ENDIF( CXXTEST_FOUND )
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