Commit a393625f authored by Stefan Philips's avatar Stefan Philips
parents e6eda76a 32e268bd
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2017 OpenWalnut Community, Hochschule Worms
// 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/>.
//
//---------------------------------------------------------------------------
#include "../../common/math/linearAlgebra/WPosition.h"
#include "../../common/WTransferable.h"
#include "WSinglePosition.h"
// The prototype as singleton. Created during first getPrototype() call
boost::shared_ptr< WPrototyped > WSinglePosition::m_prototype = boost::shared_ptr< WPrototyped >();
WSinglePosition::WSinglePosition()
: WTransferable(),
WPosition()
{
}
WSinglePosition::WSinglePosition( const WPosition& position )
: WTransferable(),
WPosition( position )
{
}
WSinglePosition::~WSinglePosition()
{
}
boost::shared_ptr< WPrototyped > WSinglePosition::getPrototype()
{
if( !m_prototype )
{
m_prototype = boost::shared_ptr< WPrototyped >( new WSinglePosition() );
}
return m_prototype;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2017 OpenWalnut Community, Hochschule Worms
// 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 WSINGLEPOSITION_H
#define WSINGLEPOSITION_H
#include <string>
#include "../../common/math/linearAlgebra/WPosition.h"
#include "../../common/WTransferable.h"
/**
* Represents a single position that is transferable between modules by connectors.
*/
class WSinglePosition: public WTransferable, public WPosition // NOLINT
{
public:
/**
* Shared pointer abbreviation.
*/
typedef boost::shared_ptr< WSinglePosition > SPtr;
/**
* Const shared pointer abbreviation.
*/
typedef boost::shared_ptr< const WSinglePosition > ConstSPtr;
/**
* Copies the specified \ref WPosition instance.
*
* \param position the instance to clone.
*/
explicit WSinglePosition( const WPosition& position );
/**
* Constructs an empty position.
*/
WSinglePosition();
/**
* Destructs.
*/
virtual ~WSinglePosition();
/**
* The name of this transferable. This is useful information for the users.
*
* \return the name.
*/
virtual const std::string getName() const;
/**
*
* The description of this transferable. This is useful information for the users.
*
* \return A description
*/
virtual const std::string getDescription() const;
/**
* Returns a prototype instantiated with the true type of the deriving class.
*
* \return the prototype.
*/
static boost::shared_ptr< WPrototyped > getPrototype();
protected:
/**
* Prototype for this dataset
*/
static boost::shared_ptr< WPrototyped > m_prototype;
};
inline const std::string WSinglePosition::getName() const
{
return "SinglePosition";
}
inline const std::string WSinglePosition::getDescription() const
{
return "A single 3D position that can be used for module connectors.";
}
#endif // WSINGLEPOSITION_H
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
* *
* \return reference to the (i,j) element of the table * \return reference to the (i,j) element of the table
*/ */
T& operator()( size_t i, size_t j ) throw( WOutOfBounds ); T& operator()( size_t i, size_t j );
/** /**
* Const version of the element access. * Const version of the element access.
...@@ -91,7 +91,7 @@ public: ...@@ -91,7 +91,7 @@ public:
* *
* \return Const reference to the (i,j) element of the table * \return Const reference to the (i,j) element of the table
*/ */
const T& operator()( size_t i, size_t j ) const throw( WOutOfBounds ); const T& operator()( size_t i, size_t j ) const;
/** /**
* Returns the number of elements stored in this matrix. * Returns the number of elements stored in this matrix.
...@@ -117,7 +117,7 @@ public: ...@@ -117,7 +117,7 @@ public:
* *
* \param data new data in row major arrangement * \param data new data in row major arrangement
*/ */
void setData( const std::vector< T > &data ) throw( WOutOfBounds ); void setData( const std::vector< T > &data );
/** /**
* Renders the matrix to a full nxn matrix, where the main diagonal is set to 0.0 and the m(i,j) == m(j,i). * Renders the matrix to a full nxn matrix, where the main diagonal is set to 0.0 and the m(i,j) == m(j,i).
...@@ -153,7 +153,7 @@ inline WMatrixSym< T >::WMatrixSym() ...@@ -153,7 +153,7 @@ inline WMatrixSym< T >::WMatrixSym()
} }
template< typename T > template< typename T >
inline const T& WMatrixSym< T >::operator()( size_t i, size_t j ) const throw( WOutOfBounds ) inline const T& WMatrixSym< T >::operator()( size_t i, size_t j ) const
{ {
if( i == j || i >= m_n || j >= m_n ) if( i == j || i >= m_n || j >= m_n )
{ {
...@@ -170,7 +170,7 @@ inline const T& WMatrixSym< T >::operator()( size_t i, size_t j ) const throw( W ...@@ -170,7 +170,7 @@ inline const T& WMatrixSym< T >::operator()( size_t i, size_t j ) const throw( W
template< typename T > template< typename T >
inline T& WMatrixSym< T >::operator()( size_t i, size_t j ) throw( WOutOfBounds ) inline T& WMatrixSym< T >::operator()( size_t i, size_t j )
{ {
if( i == j || i >= m_n || j >= m_n ) if( i == j || i >= m_n || j >= m_n )
{ {
...@@ -313,7 +313,7 @@ inline const typename std::vector< T >& WMatrixSym< T >::getData() const ...@@ -313,7 +313,7 @@ inline const typename std::vector< T >& WMatrixSym< T >::getData() const
} }
template< typename T > template< typename T >
inline void WMatrixSym< T >::setData( const std::vector< T > &data ) throw( WOutOfBounds ) inline void WMatrixSym< T >::setData( const std::vector< T > &data )
{ {
if( m_n * ( m_n - 1 ) / 2 != data.size() ) if( m_n * ( m_n - 1 ) / 2 != data.size() )
{ {
......
...@@ -1000,7 +1000,7 @@ public: ...@@ -1000,7 +1000,7 @@ public:
* *
* \throw WOutOfBounds if the specified index is invalid * \throw WOutOfBounds if the specified index is invalid
*/ */
ValueT& at( size_t row, size_t col ) throw( WOutOfBounds ) ValueT& at( size_t row, size_t col )
{ {
if( ( row >= Rows ) || ( col >= Cols ) ) if( ( row >= Rows ) || ( col >= Cols ) )
{ {
...@@ -1023,7 +1023,7 @@ public: ...@@ -1023,7 +1023,7 @@ public:
* *
* \throw WOutOfBounds if the specified index is invalid * \throw WOutOfBounds if the specified index is invalid
*/ */
const ValueT& at( size_t row, size_t col ) const throw( WOutOfBounds ) const ValueT& at( size_t row, size_t col ) const
{ {
if( ( row >= Rows ) || ( col >= Cols ) ) if( ( row >= Rows ) || ( col >= Cols ) )
{ {
......
...@@ -60,9 +60,9 @@ public: ...@@ -60,9 +60,9 @@ public:
/** /**
* Another helper class derived from WPrototyped. Used to check against \ref SomePrototypeClass1. * Another helper class derived from \ref SomePrototypeClass1. Used to check against \ref SomePrototypeClass1.
*/ */
class SomePrototypeClass2: public WPrototyped class SomePrototypeClass2: public SomePrototypeClass1
{ {
public: public:
/** /**
...@@ -86,6 +86,33 @@ public: ...@@ -86,6 +86,33 @@ public:
}; };
}; };
/**
* Another helper class derived from WPrototyped. Used to check against \ref SomePrototypeClass1.
*/
class SomePrototypeClass3: public WPrototyped
{
public:
/**
* Gets the name of this prototype.
*
* \return the name.
*/
virtual const std::string getName() const
{
return "test3";
};
/**
* Gets the description for this prototype.
*
* \return the description
*/
virtual const std::string getDescription() const
{
return "test3";
};
};
/** /**
* Test WPrototyped * Test WPrototyped
*/ */
...@@ -99,22 +126,30 @@ public: ...@@ -99,22 +126,30 @@ public:
{ {
SomePrototypeClass1 a; SomePrototypeClass1 a;
SomePrototypeClass2 b; SomePrototypeClass2 b;
SomePrototypeClass3 c;
// check the type checking mechanism in WPrototyped // check the type checking mechanism in WPrototyped
// these should be true // these should be true
TS_ASSERT( a.isA< WPrototyped >() );
TS_ASSERT( a.isA< SomePrototypeClass1 >() ); TS_ASSERT( a.isA< SomePrototypeClass1 >() );
TS_ASSERT( b.isA< WPrototyped >() );
TS_ASSERT( b.isA< SomePrototypeClass2 >() ); TS_ASSERT( b.isA< SomePrototypeClass2 >() );
TS_ASSERT( b.isA< SomePrototypeClass1 >() );
// The following lines would cause a warning
// "nonnull argument 'this' compared to NULL"
// because they would be always true,
// thus they are commented out.
//TS_ASSERT( a.isA< WPrototyped >() );
//TS_ASSERT( b.isA< WPrototyped >() );
//TS_ASSERT( c.isA< WPrototyped >() );
// check against other types not in polymorphic relation to each other (except the base class) // check against other types not in polymorphic relation to each other (except the base class)
TS_ASSERT( !a.isA< SomePrototypeClass2 >() ); TS_ASSERT( !a.isA< SomePrototypeClass2 >() );
TS_ASSERT( !b.isA< SomePrototypeClass1 >() ); TS_ASSERT( !a.isA< SomePrototypeClass3 >() );
TS_ASSERT( !b.isA< SomePrototypeClass3 >() );
TS_ASSERT( !c.isA< SomePrototypeClass1 >() );
TS_ASSERT( !c.isA< SomePrototypeClass2 >() );
} }
}; };
#endif // WPROTOTYPED_TEST_H #endif // WPROTOTYPED_TEST_H
...@@ -82,7 +82,7 @@ std::string WEEGChannelInfo::getLabel() const ...@@ -82,7 +82,7 @@ std::string WEEGChannelInfo::getLabel() const
return m_label; return m_label;
} }
WPosition WEEGChannelInfo::getPosition() const throw( WDHException ) WPosition WEEGChannelInfo::getPosition() const
{ {
if( m_hasPosition ) if( m_hasPosition )
{ {
......
...@@ -78,7 +78,7 @@ public: ...@@ -78,7 +78,7 @@ public:
* *
* \return position * \return position
*/ */
WPosition getPosition() const throw( WDHException ); WPosition getPosition() const;
protected: protected:
private: private:
......
...@@ -40,7 +40,7 @@ WEEGPositionsLibrary::WEEGPositionsLibrary( const std::map< std::string, WPositi ...@@ -40,7 +40,7 @@ WEEGPositionsLibrary::WEEGPositionsLibrary( const std::map< std::string, WPositi
} }
} }
WPosition WEEGPositionsLibrary::getPosition( std::string label ) const throw( WOutOfBounds ) WPosition WEEGPositionsLibrary::getPosition( std::string label ) const
{ {
std::map< std::string, WPosition >::const_iterator iter = m_positions.find( string_utils::toUpper( label ) ); std::map< std::string, WPosition >::const_iterator iter = m_positions.find( string_utils::toUpper( label ) );
......
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
* \param label label of the electrode * \param label label of the electrode
* \return position of the electrode * \return position of the electrode
*/ */
WPosition getPosition( std::string label ) const throw( WOutOfBounds ); WPosition getPosition( std::string label ) const;
protected: protected:
private: private:
......
...@@ -28,17 +28,17 @@ ...@@ -28,17 +28,17 @@
#include "../exceptions/WDHNoSuchFile.h" #include "../exceptions/WDHNoSuchFile.h"
#include "WReader.h" #include "WReader.h"
WReader::WReader( std::string fname ) throw( WDHNoSuchFile ) WReader::WReader( std::string fname )
{ {
setFilename( fname ); // not in constructor list since fileExcsits check setFilename( fname ); // not in constructor list since fileExcsits check
} }
void WReader::setFileName( std::string fname ) throw( WDHNoSuchFile ) void WReader::setFileName( std::string fname )
{ {
setFilename( fname ); setFilename( fname );
} }
void WReader::setFilename( std::string fname ) throw( WDHNoSuchFile ) void WReader::setFilename( std::string fname )
{ {
m_fname = fname; m_fname = fname;
if( !fileExists( m_fname ) ) if( !fileExists( m_fname ) )
......
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
* \param fname path to file which should be loaded * \param fname path to file which should be loaded
* \throws WDHNoSuchFile * \throws WDHNoSuchFile
*/ */
explicit WReader( std::string fname ) throw( WDHNoSuchFile ); explicit WReader( std::string fname );
/** /**
* Reset the file name and checks if it exists. * Reset the file name and checks if it exists.
...@@ -54,7 +54,7 @@ public: ...@@ -54,7 +54,7 @@ public:
* \throws WDHNoSuchFile * \throws WDHNoSuchFile
* \deprecated use setFilename instead. * \deprecated use setFilename instead.
*/ */
OW_API_DEPRECATED void setFileName( std::string fname ) throw( WDHNoSuchFile ); OW_API_DEPRECATED void setFileName( std::string fname );
/** /**
* Reset the file name and checks if it exists. * Reset the file name and checks if it exists.
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
* \param fname file name * \param fname file name
* \throws WDHNoSuchFile * \throws WDHNoSuchFile
*/ */
void setFilename( std::string fname ) throw( WDHNoSuchFile ); void setFilename( std::string fname );
protected: protected:
std::string m_fname; //!< Absolute path of the file to read from std::string m_fname; //!< Absolute path of the file to read from
......
...@@ -93,6 +93,7 @@ WGEViewer::WGEViewer( std::string name, osg::ref_ptr<osg::Referenced> wdata, int ...@@ -93,6 +93,7 @@ WGEViewer::WGEViewer( std::string name, osg::ref_ptr<osg::Referenced> wdata, int
m_View->addEventHandler( m_pickHandler ); m_View->addEventHandler( m_pickHandler );
if( name != std::string( "Main View" ) ) if( name != std::string( "Main View" ) )
break; break;
/* FALLTHRU */
case( WGECamera::PERSPECTIVE ): case( WGECamera::PERSPECTIVE ):
// camera manipulator // camera manipulator
m_View->setCameraManipulator( new WGEZoomTrackballManipulator() ); m_View->setCameraManipulator( new WGEZoomTrackballManipulator() );
......
...@@ -118,6 +118,7 @@ bool WPickHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAda ...@@ -118,6 +118,7 @@ bool WPickHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAda
break; break;
case osgGA::GUIEventAdapter::SCROLL_DOWN: case osgGA::GUIEventAdapter::SCROLL_DOWN:
m_scrollWheel--; m_scrollWheel--;
break;
case osgGA::GUIEventAdapter::SCROLL_2D: case osgGA::GUIEventAdapter::SCROLL_2D:
// FIXME: the osg doc tells us nothing about this value, but is seems to be always 120 or -120 // FIXME: the osg doc tells us nothing about this value, but is seems to be always 120 or -120
if( ea.getScrollingDeltaY() > 0 ) if( ea.getScrollingDeltaY() > 0 )
......
...@@ -33,6 +33,7 @@ extern "C" ...@@ -33,6 +33,7 @@ extern "C"
#include <cstddef> #include <cstddef>
#include <cstdio> #include <cstdio>
#include <iostream>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -84,9 +85,7 @@ WPagerEEGLibeep::~WPagerEEGLibeep() ...@@ -84,9 +85,7 @@ WPagerEEGLibeep::~WPagerEEGLibeep()
int status = eep_fclose( m_eeg ); int status = eep_fclose( m_eeg );
if( status != CNTERR_NONE ) if( status != CNTERR_NONE )
{ {
std::ostringstream stream; std::cout << getFilename() << " could not be closed. Libeep status code: " << status << std::endl;
stream << getFilename() << " could not be closed. Libeep status code: " << status;
throw WDHIOFailure( stream.str() );
} }
} }
...@@ -189,4 +188,3 @@ std::string WPagerEEGLibeep::getChannelLabel( std::size_t channelID ) const ...@@ -189,4 +188,3 @@ std::string WPagerEEGLibeep::getChannelLabel( std::size_t channelID ) const
} }
#endif // WEEP_ENABLED #endif // WEEP_ENABLED
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "WReaderEEG.h" #include "WReaderEEG.h"
WReaderEEG::WReaderEEG( std::string fileName ) throw( WDHIOFailure ) WReaderEEG::WReaderEEG( std::string fileName )
: WReader( fileName ) : WReader( fileName )
{ {
} }
......
...@@ -45,7 +45,7 @@ protected: ...@@ -45,7 +45,7 @@ protected:
* \param fileName Path to be loaded * \param fileName Path to be loaded
* \throw WDHIOFailure in case of an error * \throw WDHIOFailure in case of an error
*/ */
explicit WReaderEEG( std::string fileName ) throw( WDHIOFailure ); explicit WReaderEEG( std::string fileName );
/** /**
* Load electrode positions from ELC file with same name * Load electrode positions from ELC file with same name
......
...@@ -112,6 +112,7 @@ boost::shared_ptr< WDataSet > WReaderVTK::read() ...@@ -112,6 +112,7 @@ boost::shared_ptr< WDataSet > WReaderVTK::read()
break; break;
case TENSORS: case TENSORS:
ds = boost::shared_ptr< WDataSet >( new WDataSetDTI( values, grid ) ); ds = boost::shared_ptr< WDataSet >( new WDataSetDTI( values, grid ) );
break;
case ARRAYS: case ARRAYS:
if( values->dimension() > 6 ) if( values->dimension() > 6 )
{ {
......
...@@ -55,7 +55,7 @@ WEEGEvent::WEEGEvent( double time, ...@@ -55,7 +55,7 @@ WEEGEvent::WEEGEvent( double time,
osg::ref_ptr< WGEGroupNode > parentNode, osg::ref_ptr< WGEGroupNode > parentNode,
bool snapToDipole, bool snapToDipole,
bool proofOfConcept, bool proofOfConcept,
boost::shared_ptr< WDataSetDipoles > dipoles ) throw( WOutOfBounds ) boost::shared_ptr< WDataSetDipoles > dipoles )
: m_time( time ), : m_time( time ),
m_parentNode( parentNode ) m_parentNode( parentNode )
{ {
......
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
osg::ref_ptr< WGEGroupNode > parentNode, osg::ref_ptr< WGEGroupNode > parentNode,
bool snapToDipole, bool snapToDipole,
bool proofOfConcept, bool proofOfConcept,
boost::shared_ptr< WDataSetDipoles > dipoles ) throw( WOutOfBounds ); boost::shared_ptr< WDataSetDipoles > dipoles );