Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
52c03052
Commit
52c03052
authored
Dec 09, 2009
by
schurade
Browse files
Merge with 27859cd196294dd78293ecddf497ee2103d110df
parents
f5fc51f7
e5a3a088
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
263 additions
and
18 deletions
+263
-18
src/common/WColor.h
src/common/WColor.h
+12
-5
src/common/WLogger.h
src/common/WLogger.h
+161
-0
src/common/WStatusReport.h
src/common/WStatusReport.h
+7
-4
src/dataHandler/io/WIOTools.hpp
src/dataHandler/io/WIOTools.hpp
+14
-1
src/dataHandler/io/WReader.h
src/dataHandler/io/WReader.h
+1
-0
src/dataHandler/io/WReaderLookUpTableVTK.h
src/dataHandler/io/WReaderLookUpTableVTK.h
+4
-0
src/dataHandler/io/WWriter.h
src/dataHandler/io/WWriter.h
+2
-0
src/gui/CMakeLists.txt
src/gui/CMakeLists.txt
+1
-1
src/kernel/WModule.cpp
src/kernel/WModule.cpp
+19
-0
src/kernel/WModule.h
src/kernel/WModule.h
+11
-2
src/math/WLine.h
src/math/WLine.h
+9
-1
src/math/fiberSimilarity/WZhangMetric.h
src/math/fiberSimilarity/WZhangMetric.h
+6
-0
src/modules/fiberClustering/WDXtLookUpTable.h
src/modules/fiberClustering/WDXtLookUpTable.h
+2
-0
src/modules/fiberClustering/WMFiberClustering.cpp
src/modules/fiberClustering/WMFiberClustering.cpp
+9
-2
src/utils/WColorUtils.h
src/utils/WColorUtils.h
+3
-0
tools/brainlint.py
tools/brainlint.py
+2
-2
No files found.
src/common/WColor.h
View file @
52c03052
...
...
@@ -25,9 +25,9 @@
#ifndef WCOLOR_H
#define WCOLOR_H
#include <cassert>
#include <istream>
#include <ostream>
#include <cassert>
#include <string>
#include <vector>
...
...
@@ -104,13 +104,20 @@ public:
protected:
private:
float
m_red
;
float
m_green
;
float
m_blue
;
float
m_alpha
;
float
m_red
;
//!< Red channel
float
m_green
;
//!< Green channel
float
m_blue
;
//!< Blue channel
float
m_alpha
;
//!< Alpha channel
};
/**
* Write a color in string represensation to the given output stream.
*/
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
WColor
&
c
);
/**
* Write a color in string represensation to the given input stream.
*/
std
::
istream
&
operator
>>
(
std
::
istream
&
in
,
WColor
&
c
);
#endif // WCOLOR_H
src/common/WLogger.h
View file @
52c03052
...
...
@@ -27,6 +27,7 @@
#include <queue>
#include <string>
#include <sstream>
#include <vector>
#include <boost/shared_ptr.hpp>
...
...
@@ -209,4 +210,164 @@ private:
std
::
string
m_defaultFileFormat
;
};
/**
* This namespace collects several convinient access points such as wlog::err
* for logging with streams to our WLogger.
*/
namespace
wlog
{
/**
* Resource class for streamed logging.
*/
class
WStreamedLogger
{
public:
/**
* Creates new streamed logger instance. Logging is deferred until
* destruction of this instance.
*
* \param source Source from which the log message originates
* \param level The LogLevel of the message
*/
WStreamedLogger
(
const
std
::
string
&
source
,
LogLevel
level
);
/**
* Appends something loggable (to std::string castable) to the log.
*/
template
<
typename
T
>
WStreamedLogger
operator
<<
(
const
T
&
loggable
);
// alias for std::endl etc. type
typedef
std
::
basic_ostream
<
char
,
std
::
char_traits
<
char
>
>
OutStreamType
;
typedef
OutStreamType
&
(
*
StreamManipulatorFunctor
)(
OutStreamType
&
);
/**
* This is totally crazy man! Don't get dizzy on that, watch out and
* ask a C++ guru next to your side, which is probably named Christian
* or have a look on that: http://stackoverflow.com/questions/1134388/stdendl-is-of-unknown-type-when-overloading-operator
*
* Allow std::endl to be streamed into log messages.
*
* \param manip Function pointer e.g. std::endl, std::flush, std::ends
* \return The streamed logger for further use
*/
WStreamedLogger
operator
<<
(
StreamManipulatorFunctor
manip
);
protected:
private:
/**
* Actually implementing the streaming functionality.
*/
class
Buffer
{
public:
// NOLINT inner classes may have also lables
/**
* Constructs a new stream for logging.
*
* \param source String identifying the source of the message
* \param level LogLevel of the message
*/
Buffer
(
const
std
::
string
&
source
,
LogLevel
level
);
/**
* Commits the logging expression to our WLogger
*/
virtual
~
Buffer
();
std
::
ostringstream
m_logString
;
//!< queuing up parts of the log message
LogLevel
m_level
;
//!< Default logging level for this stream
std
::
string
m_source
;
//!< The source of the logging message
};
/**
* Forbid assignment
*
* \param rhs The instance which SHOULD be copied over
*/
WStreamedLogger
&
operator
=
(
const
WStreamedLogger
&
rhs
);
boost
::
shared_ptr
<
Buffer
>
m_buffer
;
//!< Collects the message parts.
};
inline
WStreamedLogger
::
WStreamedLogger
(
const
std
::
string
&
source
,
LogLevel
level
)
:
m_buffer
(
new
Buffer
(
source
,
level
)
)
{
}
template
<
typename
T
>
inline
WStreamedLogger
WStreamedLogger
::
operator
<<
(
const
T
&
loggable
)
{
m_buffer
->
m_logString
<<
loggable
;
return
*
this
;
}
inline
WStreamedLogger
WStreamedLogger
::
operator
<<
(
StreamManipulatorFunctor
manip
)
{
manip
(
m_buffer
->
m_logString
);
return
*
this
;
}
inline
WStreamedLogger
::
Buffer
::~
Buffer
()
{
WLogger
::
getLogger
()
->
addLogMessage
(
m_logString
.
str
(),
m_source
,
m_level
);
}
inline
WStreamedLogger
::
Buffer
::
Buffer
(
const
std
::
string
&
source
,
LogLevel
level
)
:
m_logString
(),
m_level
(
level
),
m_source
(
source
)
{
}
/**
* Convinient function for logging messages to our WLogger but not for
* public use outside of this module.
*
* \param source Indicate the source where this log message origins.
* \param level The LogLevel of this message
*/
inline
WStreamedLogger
_wlog
(
const
std
::
string
&
source
,
LogLevel
level
)
{
return
WStreamedLogger
(
source
,
level
);
}
/**
* Logging an error message.
*
* \param source Indicate the source where this log message origins.
*/
inline
WStreamedLogger
error
(
const
std
::
string
&
source
)
{
return
_wlog
(
source
,
LL_ERROR
);
}
/**
* Loggin a warning message.
*
* \param source Indicate the source where this log message origins.
*/
inline
WStreamedLogger
warn
(
const
std
::
string
&
source
)
{
return
_wlog
(
source
,
LL_WARNING
);
}
/**
* Loggin an information message.
*
* \param source Indicate the source where this log message origins.
*/
inline
WStreamedLogger
info
(
const
std
::
string
&
source
)
{
return
_wlog
(
source
,
LL_INFO
);
}
/**
* Loggin a debug message.
*
* \param source Indicate the source where this log message origins.
*/
inline
WStreamedLogger
debug
(
const
std
::
string
&
source
)
{
return
_wlog
(
source
,
LL_DEBUG
);
}
}
// end of namespace log
#endif // WLOGGER_H
src/common/WStatusReport.h
View file @
52c03052
...
...
@@ -38,6 +38,8 @@ public:
/**
* Constructs a new status reporter with the number of total steps
* which it should reach to reach the 100 percent.
*
* \param totalSteps Number of total steps which symbolize 100 percent.
*/
explicit
WStatusReport
(
unsigned
int
totalSteps
);
...
...
@@ -65,14 +67,16 @@ public:
/**
* Increments the finished work by the number of the given steps.
*
* \param numSteps Number of steps to increment
* \return The progress()
*/
double
operator
+=
(
unsigned
int
numSteps
);
/**
* Generates a string which represents the progress in terms of
* characters. When reaching 100 percent finally finalNumOfSymbols are
* returned.
* Generates a string which represents the progress as bar of chars.
*
* \param symbol The char used for the progressbar indication
* \param finalNumOfSymbols How many symbols represent the 100 percent
*/
std
::
string
stringBar
(
char
symbol
=
'#'
,
unsigned
int
finalNumOfSymbols
=
50
)
const
;
...
...
@@ -82,5 +86,4 @@ private:
unsigned
int
m_finishedSteps
;
//!< indicates the work done so far
};
#endif // WSTATUSREPORT_H
src/dataHandler/io/WIOTools.hpp
View file @
52c03052
...
...
@@ -56,6 +56,8 @@ namespace wiotools
/**
* Transforms a value of type T into the opposite byte order.
*
* \param value The value where byte swapping should be applied to
*/
template
<
class
T
>
T
switchByteOrder
(
const
T
value
)
{
...
...
@@ -77,6 +79,10 @@ namespace wiotools
/**
* Transform a whole array of elements (of type T and size of sizeof(T))
* into opposite byte order.
*
* \param array Array containing the data
* \param arraySize The number of elements which is not the number of
* bytes but e.g. the number of floats
*/
template
<
class
T
>
void
switchByteOrderOfArray
(
T
*
array
,
const
size_t
arraySize
)
{
...
...
@@ -87,6 +93,7 @@ namespace wiotools
}
/**
* \param name File name to get the extension or suffix from.
* \return filename suffix
*/
inline
std
::
string
getSuffix
(
std
::
string
name
)
...
...
@@ -96,17 +103,23 @@ namespace wiotools
/**
* Checks if a given path already exists or not
*
* \param path Path to be checked on existence
*/
inline
bool
fileExists
(
std
::
string
path
)
{
return
boost
::
filesystem
::
exists
(
boost
::
filesystem
::
path
(
path
)
);
}
/**
* Generate a file name with full path for a temp file. Watch out on all
* platforms!
*/
inline
std
::
string
tempFileName
()
{
// REGARDING THE COMPILER WARNING
// 1. mkstemp is only available for POSIX systems
// 2. the warning generated here is due to a race condition
// 2.
reason:
the warning generated here is due to a race condition
// while tmpnam invents the fileName it may be created by another process
// 3. file names like "/tmp/pansen" or "C:\pansen" are platform dependent
return
std
::
string
(
std
::
tmpnam
(
NULL
)
);
...
...
src/dataHandler/io/WReader.h
View file @
52c03052
...
...
@@ -47,6 +47,7 @@ public:
/**
* Reset the file name and checks if it exists.
*
* \param fname file name
* \throws WDHNoSuchFile
*/
void
setFileName
(
std
::
string
fname
)
throw
(
WDHNoSuchFile
);
...
...
src/dataHandler/io/WReaderLookUpTableVTK.h
View file @
52c03052
...
...
@@ -41,11 +41,15 @@ public:
/**
* Creates a reader object for look up tables. On parameter documention
* take a look into the WReader base class.
*
* \param fname file name
*/
explicit
WReaderLookUpTableVTK
(
std
::
string
fname
);
/**
* Perform reading from the file.
*
* \param table vector where to place the elements of the table
*/
void
readTable
(
boost
::
shared_ptr
<
std
::
vector
<
double
>
>
table
)
const
;
...
...
src/dataHandler/io/WWriter.h
View file @
52c03052
...
...
@@ -47,6 +47,8 @@ public:
/**
* Reset file name and checks if the file already exists in case of
* non overwriting is specified.
*
* \param fname file name
*/
void
setFileName
(
std
::
string
fname
);
...
...
src/gui/CMakeLists.txt
View file @
52c03052
...
...
@@ -8,6 +8,6 @@ TARGET_LINK_LIBRARIES( gui common )
# Unit tests
IF
(
CXXTEST_FOUND
)
CXXTEST_ADD_TESTS_FROM_LIST
(
"
${
GUI_SRC
}
"
"
"
# no libs for linking required
"
common"
)
ENDIF
(
CXXTEST_FOUND
)
src/kernel/WModule.cpp
View file @
52c03052
...
...
@@ -286,3 +286,22 @@ void WModule::threadMain()
}
}
wlog
::
WStreamedLogger
WModule
::
logInfo
()
const
{
return
wlog
::
info
(
getName
()
);
}
wlog
::
WStreamedLogger
WModule
::
logError
()
const
{
return
wlog
::
error
(
getName
()
);
}
wlog
::
WStreamedLogger
WModule
::
logDebug
()
const
{
return
wlog
::
debug
(
getName
()
);
}
wlog
::
WStreamedLogger
WModule
::
logWarn
()
const
{
return
wlog
::
warn
(
getName
()
);
}
src/kernel/WModule.h
View file @
52c03052
...
...
@@ -34,8 +34,6 @@
#include <boost/signals2/signal.hpp>
#include <boost/function.hpp>
#include "../common/WThreadedRunner.h"
#include "../common/WFlag.hpp"
#include "WModuleConnectorSignals.h"
#include "WModuleSignals.h"
...
...
@@ -43,7 +41,10 @@
#include "../dataHandler/WDataSetSingle.h"
#include "../dataHandler/WValueSet.hpp"
#include "../common/WFlag.hpp"
#include "../common/WLogger.h"
#include "../common/WProperties.h"
#include "../common/WThreadedRunner.h"
class
WModuleConnector
;
class
WModuleInputConnector
;
...
...
@@ -301,6 +302,14 @@ protected:
*/
void
ready
();
wlog
::
WStreamedLogger
logInfo
()
const
;
wlog
::
WStreamedLogger
logDebug
()
const
;
wlog
::
WStreamedLogger
logWarn
()
const
;
wlog
::
WStreamedLogger
logError
()
const
;
// **************************************************************************************************************************
//
// Members
...
...
src/math/WLine.h
View file @
52c03052
...
...
@@ -46,15 +46,19 @@ friend class ::WLineTest;
public:
/**
* Constructs a new line with the given points in the given order
*
* \param points The points this line consists of
*/
explicit
WLine
(
const
std
::
vector
<
WPosition
>
&
points
);
/**
* \param rhs Right hand side operand
* \return true if both lines have a same point vector
*/
bool
operator
==
(
const
WLine
&
rhs
)
const
;
/**
* \param rhs Right hand side operand
* \return false if both lines have a same point vector
*/
bool
operator
!=
(
const
WLine
&
rhs
)
const
;
...
...
@@ -65,6 +69,7 @@ public:
size_t
size
()
const
;
/**
* \param index Index for the i'th point of this line
* \return Const reference to the i'th position. This is const since
* we want an read only access.
*/
...
...
@@ -73,12 +78,15 @@ public:
/**
* Gives a meaningful representation of this object to the given
* output stream.
*
* \param os The outputstream
* \param rhs Right hand side operand
*/
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
WLine
&
rhs
);
protected:
private:
std
::
vector
<
WPosition
>
m_points
;
std
::
vector
<
WPosition
>
m_points
;
//!< stores the points of this line
};
inline
size_t
WLine
::
size
()
const
...
...
src/math/fiberSimilarity/WZhangMetric.h
View file @
52c03052
...
...
@@ -40,11 +40,17 @@ public:
/**
* Constructs new algorithm with its threshold for minimal square
* distances.
*
* \param thresholdSquare Threshold upto which the distances should be
* ignored given as square for reasons of performance.
*/
explicit
WZhangMetric
(
double
thresholdSquare
);
/**
* Resets the threshold for minimal point distances used in computation.
*
* \param thresholdSquare Threshold upto which the distances should be
* ignored given as square for reasons of performance.
*/
void
setThreshold
(
double
thresholdSquare
);
...
...
src/modules/fiberClustering/WDXtLookUpTable.h
View file @
52c03052
...
...
@@ -69,6 +69,8 @@ public:
/**
* Resets the internal data (e.g. loaded from file).
*
* \param data Vector containing the new elements
*/
void
setData
(
const
std
::
vector
<
double
>
&
data
);
...
...
src/modules/fiberClustering/WMFiberClustering.cpp
View file @
52c03052
...
...
@@ -26,6 +26,7 @@
#include <iomanip>
#include <iostream>
#include <list>
#include <sstream>
#include <string>
#include <vector>
...
...
@@ -106,6 +107,7 @@ void WMFiberClustering::checkDLtLookUpTable()
{
try
{
logDebug
()
<<
"trying to read table from /tmp/pansen.dist"
<<
std
::
endl
;
// TODO(math): replace this hard coded path when properties are available
WReaderLookUpTableVTK
r
(
"/tmp/pansen.dist"
);
using
boost
::
shared_ptr
;
...
...
@@ -132,6 +134,10 @@ void WMFiberClustering::checkDLtLookUpTable()
{
if
(
m_fibs
->
size
()
!=
m_lastFibsSize
)
{
wlog
::
debug
(
"WMFiberClustering"
)
<<
"considered old table as invalid"
<<
std
::
endl
<<
"current loaded fibers: "
<<
m_fibs
->
size
()
<<
std
::
endl
<<
"old fibers: "
<<
m_lastFibsSize
<<
std
::
endl
;
// throw away old invalid table
m_dLtTable
.
reset
();
m_dLtTableExists
=
false
;
...
...
@@ -196,8 +202,9 @@ void WMFiberClustering::cluster()
}
}
}
std
::
cout
<<
"
\r
"
<<
std
::
fixed
<<
std
::
setprecision
(
2
);
std
::
cout
<<
(
++
st
).
progress
()
<<
" "
<<
st
.
stringBar
()
<<
std
::
flush
;
std
::
stringstream
ss
;
ss
<<
"
\r
"
<<
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
(
++
st
).
progress
()
<<
" "
<<
st
.
stringBar
()
<<
std
::
flush
;
std
::
cout
<<
ss
.
str
();
}
std
::
cout
<<
std
::
endl
;
m_dLtTableExists
=
true
;
...
...
src/utils/WColorUtils.h
View file @
52c03052
...
...
@@ -35,6 +35,9 @@ namespace color_utils
{
/**
* Transforms a direction given via two points into a RGB color.
*
* \param pos1 First point
* \param pos2 Second point
*/
WColor
getRGBAColorFromDirection
(
const
wmath
::
WPosition
&
pos1
,
const
wmath
::
WPosition
&
pos2
);
}
...
...
tools/brainlint.py
View file @
52c03052
...
...
@@ -192,9 +192,9 @@ _CPP_HEADERS = frozenset([
'cstdio'
,
'cstdlib'
,
'cstring'
,
'ctime'
,
'cwchar'
,
'cwctype'
,
'defalloc.h'
,
'deque.h'
,
'editbuf.h'
,
'exception'
,
'fstream'
,
'fstream.h'
,
'hashtable.h'
,
'heap.h'
,
'indstream.h'
,
'iomanip'
,
'iomanip.h'
,
'ios'
,
'iosfwd'
,
'iostream'
,
'iostream.h'
,
'istream.h'
,
'iomanip.h'
,
'ios'
,
'iosfwd'
,
'iostream'
,
'iostream.h'
,
'istream'
,
'istream.h'
,
'iterator.h'
,
'limits'
,
'map.h'
,
'multimap.h'
,
'multiset.h'
,
'numeric'
,
'ostream.h'
,
'parsestream.h'
,
'pfstream.h'
,
'PlotFile.h'
,
'numeric'
,
'ostream'
,
'ostream.h'
,
'parsestream.h'
,
'pfstream.h'
,
'PlotFile.h'
,
'procbuf.h'
,
'pthread_alloc.h'
,
'rope'
,
'rope.h'
,
'ropeimpl.h'
,
'SFile.h'
,
'slist'
,
'slist.h'
,
'stack.h'
,
'stdexcept'
,
'stdiostream.h'
,
'streambuf.h'
,
'stream.h'
,
'strfile.h'
,
'string'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment