Commit 5d24e076 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[MERGE]

parents b2240655 e99f353d
......@@ -14,3 +14,4 @@ mam04cvr@studserv.uni-leipzig.de Cornelius_Mueller
hlawitschka@ucdavis.edu Mario_Hlawitschka
mai02igw@informatik.uni-leipzig.de Robin_Ledig
mai02ifw@informatik.uni-leipzig.de Robin_Ledig
mai02igw@studserv.uni-leipzig.de Robin_Ledig
......@@ -4,20 +4,22 @@
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.lineSplit" value="80"/>
<setting id="org.eclipse.cdt.core.formatter.lineSplit" value="130"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_exception_specification" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
......@@ -30,7 +32,7 @@
<setting id="org.eclipse.cdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_enumerator_list" value="48"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_declarator_list" value="16"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch" value="insert"/>
......@@ -41,7 +43,7 @@
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_method_declaration" value="next_line"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while" value="insert"/>
......@@ -68,23 +70,23 @@
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.continuation_indentation" value="2"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.continuation_indentation" value="4"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_expression_list" value="0"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_conditional_expression" value="80"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer" value="4"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="insert"/>
......@@ -97,10 +99,12 @@
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_exception_specification" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration" value="80"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_exception_specification" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
......@@ -115,8 +119,8 @@
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.tabulation.char" value="tab"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.tabulation.char" value="space"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_block_in_case" value="next_line"/>
......@@ -136,7 +140,7 @@
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch" value="do not insert"/>
......@@ -146,6 +150,6 @@
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments" value="insert"/>
</profile>
</profiles>
......@@ -61,9 +61,7 @@ const std::string WMDistanceMap::getName() const
const std::string WMDistanceMap::getDescription() const
{
return "This description has to be improved when the module is completed."
" By now lets say the following: Computes a smoothed version of the dataset"
" and a distance map on it. Finally it renders this distance map using MarchinCubes";
return "Computes a smoothed version of the dataset and a distance map on it.";
}
void WMDistanceMap::moduleMain()
......
......@@ -38,9 +38,11 @@
WMDistanceMapIsosurface::WMDistanceMapIsosurface():
WModuleContainer( "Distance Map Isosurface",
"This description has to be improved when the module is completed."
" By now lets say the following: Computes a smoothed version of the dataset"
" and a distance map on it. Finally it renders this distance map using MarchinCubes" )
"Computes a smoothed version of the dataset"
" and a distance map on it. Finally it renders"
"this distance map using an isosurface. This isosurface"
" can be textured with values from scalar data sets in order to display"
"the structures at the given distance." )
{
// WARNING: initializing connectors inside the constructor will lead to an exception.
// NOTE: Do not use the module factory inside this constructor. This will cause a dead lock as the module factory is locked
......
......@@ -96,10 +96,20 @@ void WMFiberDisplay::moduleMain()
}
m_dataset = m_fiberInput->getData();
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->removeChild( m_osgNode.get() );
WKernel::getRunningKernel()->getRoiManager()->addFiberDataset( m_dataset );
create();
infoLog() << "Fiber dataset for display with: " << m_dataset->size() << " fibers loaded.";
if( m_dataset->size() != 0 ) // incase of an empty fiber dataset nothing is to display
{
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->removeChild( m_osgNode.get() );
WKernel::getRunningKernel()->getRoiManager()->addFiberDataset( m_dataset );
create();
}
else
{
warnLog() << "Nothing to display for an empty fiber dataset";
}
}
}
}
......
......@@ -41,7 +41,7 @@
#include "WMGaussFiltering.h"
#include "gaussfiltering.xpm"
WMGaussFiltering::WMGaussFiltering():
WMGaussFiltering::WMGaussFiltering() :
WModule()
{
// WARNING: initializing connectors inside the constructor will lead to an exception.
......@@ -54,9 +54,9 @@ WMGaussFiltering::~WMGaussFiltering()
removeConnectors();
}
boost::shared_ptr< WModule > WMGaussFiltering::factory() const
boost::shared_ptr<WModule> WMGaussFiltering::factory() const
{
return boost::shared_ptr< WModule >( new WMGaussFiltering() );
return boost::shared_ptr<WModule>( new WMGaussFiltering() );
}
const char** WMGaussFiltering::getXPMIcon() const
......@@ -74,51 +74,61 @@ const std::string WMGaussFiltering::getDescription() const
return "Runs a discretized Gauss filter as mask over a simple scalar field.";
}
size_t getId( size_t xDim, size_t yDim, size_t /*zDim*/, size_t x, size_t y, size_t z )
size_t getId( size_t xDim, size_t yDim, size_t /*zDim*/, size_t x, size_t y,
size_t z )
{
return z * xDim * yDim + y * xDim + x;
}
template< typename T > double WMGaussFiltering::filterAtPosition( boost::shared_ptr< WValueSet< T > > vals,
size_t nX, size_t nY, size_t nZ, size_t x, size_t y, size_t z )
double mask( size_t i, size_t j, size_t k )
{
assert( i < 3 );
assert( j < 3 );
assert( k < 3 );
double maskEntries[3][3][3] = { // NOLINT
{ { 0, 1, 0 }, { 1, 2, 1 }, { 0, 1, 0 } }, // NOLINT
{ { 1, 2, 1 }, { 2, 4, 2 }, { 1, 2, 1 } }, // NOLINT
{ { 0, 1, 0 }, { 1, 2, 1 }, { 0, 1, 0 } } }; // NOLINT
return maskEntries[i][j][k];
}
template<typename T> double WMGaussFiltering::filterAtPosition(
boost::shared_ptr<WValueSet<T> > vals, size_t nX, size_t nY, size_t nZ,
size_t x, size_t y, size_t z )
{
double filtered = 0;
filtered += 2 * vals->getScalar( getId( nX, nY, nZ, x , y , z - 1 ) );
filtered += 1 * vals->getScalar( getId( nX, nY, nZ, x + 1, y , z - 1 ) );
filtered += 1 * vals->getScalar( getId( nX, nY, nZ, x - 1, y , z - 1 ) );
filtered += 1 * vals->getScalar( getId( nX, nY, nZ, x , y + 1, z - 1 ) );
filtered += 1 * vals->getScalar( getId( nX, nY, nZ, x , y - 1, z - 1 ) );
filtered += 1 * vals->getScalar( getId( nX, nY, nZ, x - 1, y - 1, z ) );
filtered += 2 * vals->getScalar( getId( nX, nY, nZ, x , y - 1, z ) );
filtered += 1 * vals->getScalar( getId( nX, nY, nZ, x + 1, y - 1, z ) );
filtered += 2 * vals->getScalar( getId( nX, nY, nZ, x - 1, y , z ) );
filtered += 4 * vals->getScalar( getId( nX, nY, nZ, x , y , z ) );
filtered += 2 * vals->getScalar( getId( nX, nY, nZ, x + 1, y , z ) );
filtered += 1 * vals->getScalar( getId( nX, nY, nZ, x - 1, y + 1, z ) );
filtered += 2 * vals->getScalar( getId( nX, nY, nZ, x , y + 1, z ) );
filtered += 1 * vals->getScalar( getId( nX, nY, nZ, x + 1, y + 1, z ) );
filtered += 2 * vals->getScalar( getId( nX, nY, nZ, x , y , z ) );
filtered += 1 * vals->getScalar( getId( nX, nY, nZ, x + 1, y , z ) );
filtered += 1 * vals->getScalar( getId( nX, nY, nZ, x - 1, y , z ) );
filtered += 1 * vals->getScalar( getId( nX, nY, nZ, x , y + 1, z ) );
filtered += 1 * vals->getScalar( getId( nX, nY, nZ, x , y - 1, z ) );
filtered /= 28.;
double maskSum = 0;
size_t filterSize = 3;
for( size_t k = 0; k < filterSize; ++k )
{
for( size_t j = 0; j < filterSize; ++j )
{
for( size_t i = 0; i < filterSize; ++i )
{
filtered += mask( i, j, k ) * vals->getScalar( getId( nX, nY,
nZ, x - 1 + i, y - 1 + j, z - 1 + k ) );
maskSum += mask( i, j, k );
}
}
}
filtered /= maskSum;
return filtered;
}
template< typename T > std::vector< double > WMGaussFiltering::filterField( boost::shared_ptr< WValueSet< T > > vals )
template<typename T> std::vector<double> WMGaussFiltering::filterField(
boost::shared_ptr<WValueSet<T> > vals )
{
boost::shared_ptr< WGridRegular3D > grid = boost::shared_dynamic_cast< WGridRegular3D >( m_dataSet->getGrid() );
boost::shared_ptr<WGridRegular3D> grid = boost::shared_dynamic_cast<
WGridRegular3D>( m_dataSet->getGrid() );
assert( grid );
size_t nX = grid->getNbCoordsX();
size_t nY = grid->getNbCoordsY();
size_t nZ = grid->getNbCoordsZ();
std::vector< double > newVals( nX * nY * nZ, 0. );
std::vector<double> newVals( nX * nY * nZ, 0. );
boost::shared_ptr< WProgress > progress = boost::shared_ptr< WProgress >( new WProgress( "Gauss Filtering", nZ ) );
boost::shared_ptr<WProgress> progress = boost::shared_ptr<WProgress>(
new WProgress( "Gauss Filtering", nZ ) );
m_progress->addSubProgress( progress );
for( size_t z = 1; z < nZ - 1; z++ )
{
......@@ -127,7 +137,8 @@ template< typename T > std::vector< double > WMGaussFiltering::filterField( boos
{
for( size_t x = 1; x < nX - 1; x++ )
{
newVals[getId( nX, nY, nZ, x, y, z )] = filterAtPosition( vals, nX, nY, nZ, x, y, z );
newVals[getId( nX, nY, nZ, x, y, z )] = filterAtPosition( vals,
nX, nY, nZ, x, y, z );
}
}
}
......@@ -145,12 +156,12 @@ void WMGaussFiltering::moduleMain()
ready();
// loop until the module container requests the module to quit
while ( !m_shutdownFlag() )
while( !m_shutdownFlag() )
{
sleep( 3 ); // TODO(wiebel): remove this
// acquire data from the input connector
m_dataSet = m_input->getData();
if ( !m_dataSet )
if( !m_dataSet )
{
// ok, the output has not yet sent data
// NOTE: see comment at the end of this while loop for m_moduleState
......@@ -160,45 +171,45 @@ void WMGaussFiltering::moduleMain()
}
assert( m_dataSet );
std::vector< double > newVals;
std::vector<double> newVals;
switch( (*m_dataSet).getValueSet()->getDataType() )
{
case W_DT_UNSIGNED_CHAR:
{
boost::shared_ptr< WValueSet< unsigned char > > vals;
vals = boost::shared_dynamic_cast< WValueSet< unsigned char > >( ( *m_dataSet ).getValueSet() );
boost::shared_ptr<WValueSet<unsigned char> > vals;
vals = boost::shared_dynamic_cast<WValueSet<unsigned char> >( ( *m_dataSet ).getValueSet() );
assert( vals );
newVals = filterField( vals );
break;
}
case W_DT_INT16:
{
boost::shared_ptr< WValueSet< int16_t > > vals;
vals = boost::shared_dynamic_cast< WValueSet< int16_t > >( ( *m_dataSet ).getValueSet() );
boost::shared_ptr<WValueSet<int16_t> > vals;
vals = boost::shared_dynamic_cast<WValueSet<int16_t> >( ( *m_dataSet ).getValueSet() );
assert( vals );
newVals = filterField( vals );
}
case W_DT_SIGNED_INT:
{
boost::shared_ptr< WValueSet< int32_t > > vals;
vals = boost::shared_dynamic_cast< WValueSet< int32_t > >( ( *m_dataSet ).getValueSet() );
boost::shared_ptr<WValueSet<int32_t> > vals;
vals = boost::shared_dynamic_cast<WValueSet<int32_t> >( ( *m_dataSet ).getValueSet() );
assert( vals );
newVals = filterField( vals );
break;
}
case W_DT_FLOAT:
{
boost::shared_ptr< WValueSet< float > > vals;
vals = boost::shared_dynamic_cast< WValueSet< float > >( ( *m_dataSet ).getValueSet() );
boost::shared_ptr<WValueSet<float> > vals;
vals = boost::shared_dynamic_cast<WValueSet<float> >( ( *m_dataSet ).getValueSet() );
assert( vals );
newVals = filterField( vals );
break;
}
case W_DT_DOUBLE:
{
boost::shared_ptr< WValueSet< double > > vals;
vals = boost::shared_dynamic_cast< WValueSet< double > >( ( *m_dataSet ).getValueSet() );
boost::shared_ptr<WValueSet<double> > vals;
vals = boost::shared_dynamic_cast<WValueSet<double> >( ( *m_dataSet ).getValueSet() );
assert( vals );
newVals = filterField( vals );
break;
......@@ -207,11 +218,12 @@ void WMGaussFiltering::moduleMain()
assert( false && "Unknow data type in Gauss Filtering module" );
}
boost::shared_ptr<WValueSet<double> > valueSet;
valueSet = boost::shared_ptr<WValueSet<double> >(
new WValueSet<double> ( 0, 1, newVals, W_DT_DOUBLE ) );
boost::shared_ptr< WValueSet< double > > valueSet;
valueSet = boost::shared_ptr< WValueSet< double > >( new WValueSet< double >( 0, 1, newVals, W_DT_DOUBLE ) );
m_dataSet = boost::shared_ptr< WDataSetSingle >( new WDataSetSingle( valueSet, m_dataSet->getGrid() ) );
m_dataSet = boost::shared_ptr<WDataSetSingle>( new WDataSetSingle(
valueSet, m_dataSet->getGrid() ) );
m_output->updateData( m_dataSet );
// this waits for m_moduleState to fire. By default, this is only the m_shutdownFlag condition.
......@@ -223,18 +235,17 @@ void WMGaussFiltering::moduleMain()
void WMGaussFiltering::connectors()
{
// initialize connectors
m_input = boost::shared_ptr< WModuleInputData < WDataSetSingle > >(
new WModuleInputData< WDataSetSingle >( shared_from_this(),
"in", "The dataset to filter" )
);
m_input = boost::shared_ptr<WModuleInputData<WDataSetSingle> >(
new WModuleInputData<WDataSetSingle> ( shared_from_this(), "in",
"The dataset to filter" ) );
// add it to the list of connectors. Please note, that a connector NOT added via addConnector will not work as expected.
addConnector( m_input );
// initialize connectors
m_output= boost::shared_ptr< WModuleOutputData< WDataSetSingle > >( new WModuleOutputData< WDataSetSingle >(
shared_from_this(), "out", "The filtered data set." )
);
m_output = boost::shared_ptr<WModuleOutputData<WDataSetSingle> >(
new WModuleOutputData<WDataSetSingle> ( shared_from_this(), "out",
"The filtered data set." ) );
// add it to the list of connectors. Please note, that a connector NOT added via addConnector will not work as expected.
addConnector( m_output );
......@@ -245,7 +256,7 @@ void WMGaussFiltering::connectors()
void WMGaussFiltering::properties()
{
// ( m_properties->addInt( "Filter Size", 1 ) )->connect( boost::bind( &WMGaussFiltering::slotPropertyChanged, this, _1 ) );
// ( m_properties->addInt( "Filter Size", 1 ) )->connect( boost::bind( &WMGaussFiltering::slotPropertyChanged, this, _1 ) );
}
void WMGaussFiltering::slotPropertyChanged( std::string propertyName )
......
......@@ -34,6 +34,7 @@
#include "../../common/WColor.h"
#include "WMTemplate.h"
#include "template.xpm"
WMTemplate::WMTemplate():
WModule()
......@@ -81,6 +82,17 @@ boost::shared_ptr< WModule > WMTemplate::factory() const
return boost::shared_ptr< WModule >( new WMTemplate() );
}
const char** WMTemplate::getXPMIcon() const
{
// The template_xpm char array comes from the template.xpm file as included above.
// Such char arrays, i.e. files, can be easily created using an image manipulation program
// like GIMP. Be aware that the xpm file is a simple header file. Thus it contains real
// code. This code can be manipulated by hand. Unfortunately, you really have to fix the
// xpm files produced by gimp. You need to make the char array const in order to prevent
// compiler warnings or even errors.
return template_xpm;
}
const std::string WMTemplate::getName() const
{
// Specify your module name here. This name must be UNIQUE!
......
......@@ -72,6 +72,11 @@ public:
*/
virtual boost::shared_ptr< WModule > factory() const;
/**
* Get the icon for this module in XPM format.
*/
virtual const char** getXPMIcon() const;
protected:
/**
......
/* XPM */
static const char * template_xpm[] = {
"16 16 2 1",
" c None",
". c #000000",
" ",
" ",
" .......... ",
" .......... ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" "};
......@@ -41,7 +41,7 @@
#include "../../dataHandler/io/nifti/nifti1_io.h"
#include "WMWriteNIfTI.h"
WMWriteNIfTI::WMWriteNIfTI():
WMWriteNIfTI::WMWriteNIfTI() :
WModule()
{
// WARNING: initializing connectors inside the constructor will lead to an exception.
......@@ -62,32 +62,13 @@ boost::shared_ptr< WModule > WMWriteNIfTI::factory() const
const char** WMWriteNIfTI::getXPMIcon() const
{
static const char * disc_xpm[] =
{
"16 16 7 1",
" c None",
". c #000080",
"+ c #000000",
"@ c #FFFF00",
"# c #E0E0E0",
"$ c #FFFFFF",
"% c #C0C0C0",
"..+++++++++++..+",
"..@@@@@@@@@@@..+",
"..###########..+",
"..$$$$$$$$$$$..+",
"..###########..+",
"..$$$$$$$$$$$..+",
"..###########..+",
"..$$$$$$$$$$$..+",
"...............+",
"....%%%%%%%....+",
"....%..%%%%....+",
"....%..%%%%....+",
"....%..%%%%....+",
"....%..%%%%....+",
"+...%%%%%%%....+",
"++++++++++++++++"
};
{
"16 16 7 1", " c None", ". c #000080", "+ c #000000", "@ c #FFFF00", "# c #E0E0E0",
"$ c #FFFFFF", "% c #C0C0C0", "..+++++++++++..+", "..@@@@@@@@@@@..+", "..###########..+",
"..$$$$$$$$$$$..+", "..###########..+", "..$$$$$$$$$$$..+", "..###########..+", "..$$$$$$$$$$$..+",
"...............+", "....%%%%%%%....+", "....%..%%%%....+", "....%..%%%%....+", "....%..%%%%....+",
"....%..%%%%....+", "+...%%%%%%%....+", "++++++++++++++++"
};
return disc_xpm;
}
......@@ -111,11 +92,11 @@ void WMWriteNIfTI::moduleMain()
ready();
// loop until the module container requests the module to quit
while ( !m_shutdownFlag() )
while( !m_shutdownFlag() )
{
// acquire data from the input connector
m_dataSet = m_input->getData();
if ( !m_dataSet )
if( !m_dataSet )
{
// ok, the output has not yet sent data
// NOTE: see comment at the end of this while loop for m_moduleState
......@@ -133,10 +114,8 @@ void WMWriteNIfTI::moduleMain()
void WMWriteNIfTI::connectors()
{
// initialize connectors
m_input = boost::shared_ptr< WModuleInputData < WDataSetSingle > >(
new WModuleInputData< WDataSetSingle >( shared_from_this(),
"in", "The dataset to filter" )
);
m_input = boost::shared_ptr< WModuleInputData< WDataSetSingle > >( new WModuleInputData< WDataSetSingle > (
shared_from_this(), "in", "The dataset to filter" ) );
// add it to the list of connectors. Please note, that a connector NOT added via addConnector will not work as expected.
addConnector( m_input );
......@@ -147,12 +126,27 @@ void WMWriteNIfTI::connectors()
void WMWriteNIfTI::properties()
{
m_filename = m_properties2->addProperty( "Filename", "Filename where to write the nifty file to.", WKernel::getAppPathObject() );
m_filename = m_properties2->addProperty( "Filename", "Filename where to write the nifty file to.",
WKernel::getAppPathObject() );
// bind a custom callback, triggered whenever the filename changes
m_filename->getCondition()->subscribeSignal( boost::bind( &WMWriteNIfTI::writeToFile, this ) );
}
template< typename T > void WMWriteNIfTI::castData( void*& returnData )
{
boost::shared_ptr< WValueSetBase > valsB = ( *m_dataSet ).getValueSet();
boost::shared_ptr< WValueSet< T > > vals = boost::shared_dynamic_cast< WValueSet< T > >( ( *m_dataSet ).getValueSet() );
assert( vals && "Seems that value set type is not yet supported." );
T* data = new T[vals->size()];
for( unsigned int i = 0; i < vals->size(); ++i )
{
data[i] = static_cast< T > ( vals->getScalar( i ) );
}
returnData = static_cast< void* > ( data );
}
void WMWriteNIfTI::writeToFile()
{
infoLog() << "Writing Data to " << m_filename->get().file_string();
......@@ -161,10 +155,7 @@ void WMWriteNIfTI::writeToFile()
boost::shared_ptr< WGridRegular3D > grid = boost::shared_dynamic_cast< WGridRegular3D >( m_dataSet->getGrid() );
assert( grid && "Seems that grid is of wrong type." );
boost::shared_ptr< WValueSet< uint8_t > > vals = boost::shared_dynamic_cast< WValueSet< uint8_t > >( ( *m_dataSet ).getValueSet() );