Commit c4ac1d03 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[MERGE]

parents dbb2f9a7 e19b3678
......@@ -91,6 +91,97 @@ osg::Vec4 WColor::getOSGColor() const
return osg::Vec4( m_red, m_green, m_blue, m_alpha );
}
void WColor::setRGB( double r, double g, double b )
{
setRed( r );
setGreen( g );
setBlue( b );
}
// This function is taken from VTK 5.4.2. Since its BSD licensed the license
// notice follows below. It is not taken from FAnToM since it seems more self
// documenting.
//
// /*=========================================================================
//
// Program: Visualization Toolkit
// Module: $RCSfile: vtkMath.cxx,v $
//
// Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// All rights reserved.
// See Copyright.txt or http://www.kitware.com/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 notice for more information.
//
// =========================================================================
// Copyright 2005 Sandia Corporation.
// Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the
// U.S. Government. Redistribution and use in source and binary forms, with
// or without modification, are permitted provided that this Notice and any
// statement of authorship are reproduced on all copies.
//
// Contact: pppebay@sandia.gov,dcthomp@sandia.gov,
//
// =========================================================================*/
void WColor::setHSV( double h, double s, double v )
{
const double onethird = 1.0 / 3.0;
const double onesixth = 1.0 / 6.0;
const double twothird = 2.0 / 3.0;
const double fivesixth = 5.0 / 6.0;
double r = 0.0;
double g = 0.0;
double b = 0.0;
// compute RGB from HSV
if( h > onesixth && h <= onethird ) // green/red
{
g = 1.0;
r = ( onethird - h ) / onesixth;
b = 0.0;
}
else if( h > onethird && h <= 0.5 ) // green/blue
{
g = 1.0;
b = ( h - onethird ) / onesixth;
r = 0.0;
}
else if( h > 0.5 && h <= twothird ) // blue/green
{
b = 1.0;
g = ( twothird - h ) / onesixth;
r = 0.0;
}
else if( h > twothird && h <= fivesixth ) // blue/red
{
b = 1.0;
r = ( h - twothird ) / onesixth;
g = 0.0;
}
else if( h > fivesixth && h <= 1.0) // red/blue
{
r = 1.0;
b = ( 1.0 - h ) / onesixth;
g = 0.0;
}
else // red/green
{
r = 1.0;
g = h / onesixth;
b = 0.0;
}
// add Saturation to the equation.
r = ( s * r + ( 1.0 - s ) ) * v;
g = ( s * g + ( 1.0 - s ) ) * v;
b = ( s * b + ( 1.0 - s ) ) * v;
setRGB( r, g, b );
}
std::ostream& operator<<( std::ostream& out, const WColor& c )
{
float r = c.getRed();
......
......@@ -92,6 +92,16 @@ public:
*/
osg::Vec4 getOSGColor() const;
/**
* Reset this color via a given HSV color.
*/
void setHSV( double h, double s, double v );
/**
* Reset all channels at once.
*/
void setRGB( double r, double g, double b );
protected:
private:
float m_red;
......
......@@ -67,6 +67,32 @@ public:
TS_ASSERT_EQUALS( c.getBlue(), 0.25 );
TS_ASSERT_EQUALS( c.getAlpha(), 0.0 );
}
/**
* Red in HSV is ( 0, 1, 1 ) and in RGB ( 1, 0, 0 )
* Green in HSV is ( 0.3, 1, 1 ) and in RGB ( 0, 1, 0 )
* and checks some dark green
*/
void testResetHSV( void )
{
WColor c;
c.setHSV( 0, 1, 1 );
TS_ASSERT_DELTA( c.getRed(), 1, 0.00001 );
TS_ASSERT_DELTA( c.getGreen(), 0, 0.00001 );
TS_ASSERT_DELTA( c.getBlue(), 0, 0.00001 );
c.setHSV( 1, 1, 1 ); // this is also red
TS_ASSERT_DELTA( c.getRed(), 1, 0.00001 );
TS_ASSERT_DELTA( c.getGreen(), 0, 0.00001 );
TS_ASSERT_DELTA( c.getBlue(), 0, 0.00001 );
c.setHSV( 1.0 / 3.0, 1, 1 );
TS_ASSERT_DELTA( c.getRed(), 0, 0.00001 );
TS_ASSERT_DELTA( c.getGreen(), 1, 0.00001 );
TS_ASSERT_DELTA( c.getBlue(), 0, 0.00001 );
c.setHSV( 0.3, 0.3, 0.3 ); // dark green
TS_ASSERT_DELTA( c.getRed(), 0.2280, 0.0001 );
TS_ASSERT_DELTA( c.getGreen(), 0.3, 0.0001 );
TS_ASSERT_DELTA( c.getBlue(), 0.2099, 0.0001 );
}
};
#endif // WCOLOR_TEST_H
......@@ -58,17 +58,20 @@ public:
/**
* Get the pointer to the i'th WSubject. The return type is const since we
* want to ensure that each subject cannot modified after retrival.
* \param subjectId the number of the subject to be retrieved.
*/
boost::shared_ptr< WSubject > getSubject( const unsigned int subjectId ) const;
/**
* Returns a to the i'th WSubject. The return type is const since we
* want to ensure that each subject cannot modified after retrival.
* \param subjectId the number of the subject to be retrieved.
*/
boost::shared_ptr< WSubject > operator[]( size_t subjectId ) const;
/**
* Insert a new WSubject referenced by a pointer.
* \param newSubject a pointer to the subject that will be added
*/
void addSubject( boost::shared_ptr< WSubject > newSubject );
......
......@@ -62,7 +62,10 @@ public:
boost::shared_ptr< WGrid > getGrid() const;
/**
*
* Get the value stored at a certain grid position of the data set
* \param x index in x direction
* \param y index in y direction
* \param z index in z direction
*/
template < typename T > T getValueAt( int x, int y, int z )
{
......
......@@ -36,24 +36,31 @@
// TODO(wiebel): use this szuff or remove it
#include "../math/WPosition.h"
typedef double WDummyType;
/**
* An incomplete implementation to store information about electrodes of EEG data
*/
class WEEGElectrodeObject
{
public:
protected:
private:
wmath::WPosition m_position;
wmath::WPosition m_position; //!< Position of the electrode in space
// TODO(wiebel): The following is suggested in the
// eemagine design document
// WColor color;
};
/**
* An incomplete dummy implementation to store information about segments of EEG data
*/
class WEEGSegementInfo
{
public:
protected:
private:
WDummyType m_startSample;
WDummyType m_endSample;
WDummyType m_segmentStartDate;
WDummyType m_startSample; //!< Dummy variable of not yet completely implemented class
WDummyType m_endSample; //!< Dummy variable of not yet completely implemented class
WDummyType m_segmentStartDate; //!< Dummy variable of not yet completely implemented class
};
//================================================
......
......@@ -198,19 +198,19 @@ public:
protected:
private:
wmath::WPosition m_origin;
wmath::WPosition m_origin; //!< Origin of the grid.
unsigned int m_nbPosX;
unsigned int m_nbPosY;
unsigned int m_nbPosZ;
unsigned int m_nbPosX; //!< Number of positions in x direction
unsigned int m_nbPosY; //!< Number of positions in y direction
unsigned int m_nbPosZ; //!< Number of positions in z direction
wmath::WVector3D m_directionX;
wmath::WVector3D m_directionY;
wmath::WVector3D m_directionZ;
wmath::WVector3D m_directionX; //!< Direction of the x axis
wmath::WVector3D m_directionY; //!< Direction of the y axis
wmath::WVector3D m_directionZ; //!< Direction of the z axis
double m_offsetX;
double m_offsetY;
double m_offsetZ;
double m_offsetX; //!< Offset between samples along x axis
double m_offsetY; //!< Offset between samples along y axis
double m_offsetZ; //!< Offset between samples along z axis
/**
* Matrix storing the transformation of the grid. This is redundant.
......@@ -219,7 +219,7 @@ private:
*/
wmath::WMatrix<double> m_matrix;
wmath::WMatrix<double> m_matrixInverse;
wmath::WMatrix<double> m_matrixInverse; //!< Inverse of m_matrix
};
#endif // WGRIDREGULAR3D_H
......@@ -61,12 +61,14 @@ public:
/**
* Get the pointer to the i'th WDataSet. The return type is const since we
* want to ensure that each DataSet cannot modified after retrival.
* \param dataSetId the number of the data set to retrieve
*/
boost::shared_ptr< WDataSet > getDataSet( const unsigned int dataSetId ) const;
/**
* Returns a shared_ptr to the i'th WSubject. The return type is const since we
* want to ensure that a subject cannot be modified after retrieval.
* \param dataSetId the number of the data set to retrieve
*/
boost::shared_ptr< const WDataSet > operator[]( const unsigned int dataSetId ) const;
......
......@@ -48,6 +48,10 @@ public:
/**
* Constructs a value set with values of type T. Sets order and dimension
* to allow to interprete the values as tensors of a certain order and dimension.
* \param order tensor order of values stored in the value set
* \param dimension tensor dimension of values stored in the value set
* \param data the vector holding the raw data
* \param inDataType indicator teeling us which dataType comes in
*/
WValueSet( size_t order, size_t dimension, const std::vector< T > data, dataType inDataType )
: WValueSetBase( order, dimension, inDataType ),
......@@ -86,6 +90,7 @@ public:
}
/**
* \param i id of the scalar to retrieve
* \return The i-th value if the value set is of scalar type.
*/
virtual T getScalar( size_t i ) const
......
......@@ -29,6 +29,9 @@
#include <algorithm>
#include <cassert>
#include <string>
#include <boost/filesystem.hpp>
/**
* Namespaces for several tools we may need while doing IO
......@@ -81,6 +84,14 @@ namespace wiotools
array[i] = switchByteOrder< T >( array[i] );
}
}
} // end of namespace
/**
* \return filename suffix
*/
inline std::string getSuffix( std::string name )
{
boost::filesystem::path p( name );
return p.extension();
}
} // end of namespace
#endif // WIOTOOLS_HPP
......@@ -57,14 +57,14 @@ public:
protected:
private:
void fillSegment( std::vector<std::vector<double> >* segment, biosig_data_type* data );
/**
* Header of file
* Fill the data into the segment doing the needed conversions.
*/
HDRTYPE* hd;
size_t m_columns;
size_t m_rows;
void fillSegment( std::vector<std::vector<double> >* segment, biosig_data_type* data );
HDRTYPE* hd; //!< Header of file
size_t m_columns; //!< columns of the storage in the file
size_t m_rows; //!< rows of the storage in the file
};
#endif // WLOADERBIOSIG_H
......@@ -51,7 +51,10 @@ public:
*/
virtual boost::shared_ptr< WDataSet > load();
void operator()();
/**
* Function that is automatically executed as new thread.
*/
void operator()();
protected:
private:
......
......@@ -31,10 +31,13 @@
#include "../WSubject.h"
#include "../exceptions/WDHNoSuchDataSet.h"
/**
* Test important functionality of WDataHandler class
*/
class WDataHandlerTest : public CxxTest::TestSuite
{
public:
boost::shared_ptr< WSubject > dummySubject;
boost::shared_ptr< WSubject > dummySubject; //!< Dummy used for in the tests
/**
* Constructs unit test environment.
......
......@@ -34,11 +34,14 @@
#include "../WGrid.h"
#include "../WDataHandlerEnums.h"
/**
* Test important functionality of WDataSetSingle class
*/
class WDataSetSingleTest : public CxxTest::TestSuite
{
public:
boost::shared_ptr< WGrid > gridDummy;
boost::shared_ptr< WValueSetBase > valueSetDummy;
boost::shared_ptr< WGrid > gridDummy; //!< Dummy grid used in the tests.
boost::shared_ptr< WValueSetBase > valueSetDummy; //!< Dummy value set used in the tests.
/**
* Constructs unit test environment.
......
......@@ -29,6 +29,9 @@
#include <cxxtest/TestSuite.h>
#include "../WDataSet.h"
/**
* Test important functionality of WDataSet class
*/
class WDataSetTest : public CxxTest::TestSuite
{
public:
......
......@@ -29,6 +29,9 @@
#include <cxxtest/TestSuite.h>
#include "../WEEG.h"
/**
* Test important functionality of WEEG class
*/
class WEEGTest : public CxxTest::TestSuite
{
public:
......
......@@ -40,11 +40,18 @@ using wmath::WMatrix;
namespace CxxTest
{
CXXTEST_TEMPLATE_INSTANTIATION
/**
* Allows usable output of WVector3D in tests
*/
class ValueTraits<WVector3D>
{
std::string _s;
std::string _s; //!< The string representing the WVector
public:
/**
* Constructor for class allowing usable output of WVector3D in tests
* \param m the WVector to print
*/
explicit ValueTraits( const WVector3D &m )
{
std::stringstream tmp;
......@@ -52,6 +59,10 @@ public:
tmp << "WVector3D( " << m[0] << " " << m[1] << " " << m[2] << " )";
_s = tmp.str();
}
/**
* Get the string corresponding to the WVector
*/
const char *asString() const
{
return _s.c_str();
......@@ -346,7 +357,7 @@ public:
}
private:
double m_delta;
double m_delta; //!< Maximum amount to values are allowed to differ.
};
#endif // WGRIDREGULAR3D_TEST_H
......@@ -38,6 +38,9 @@
class DummyLoader : public WLoader
{
public:
/**
* Constructor of Dummy class for testing of WLoader
*/
explicit DummyLoader( std::string fileName, boost::shared_ptr< WDataHandler > dataHandler )
: WLoader( fileName, dataHandler )
{
......
......@@ -28,6 +28,9 @@
#include <cxxtest/TestSuite.h>
#include "../WRecording.h"
/**
* Test important functionality of WRecording class
*/
class WRecordingTest : public CxxTest::TestSuite
{
public:
......
......@@ -44,6 +44,9 @@ public:
{
}
/**
* Constructor of Dummy class for testing
*/
explicit Dummy( char dimension )
: WValueSetBase( 0, dimension, W_DT_INT8 )
{
......
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