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

[ADD] - added simple module that provides its given input to the data handler for texture mapping.

parent 487bf611
......@@ -30,6 +30,7 @@ ADD_SUBDIRECTORY( splineSurface )
ADD_SUBDIRECTORY( subtractDataSetScalar )
ADD_SUBDIRECTORY( surfaceParameterAnimator )
ADD_SUBDIRECTORY( vectorOperator )
ADD_SUBDIRECTORY( textureMapper )
IF( Teem_FOUND )
IF( OSSIM_FOUND AND OW_USE_OSSIM )
......
FILE( GLOB_RECURSE MODULES_SRC "*.cpp" "*.h" )
# Grab module name and setup target directories
GET_FILENAME_COMPONENT( MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME )
SET( MODULE_TARGET_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/modules/${MODULE_NAME} )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( MODULE_DIRNAME ${MODULE_NAME} )
SET( MODULE_NAME "OWmodule_${MODULE_NAME}" ) # prefix all module names with "OWmodule_" to separate them from other libs
# Build module lib
ADD_LIBRARY( ${MODULE_NAME} SHARED ${MODULES_SRC} )
TARGET_LINK_LIBRARIES( ${MODULE_NAME} OWkernel )
IF(MSVC_IDE)
SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES PREFIX "../")
ENDIF(MSVC_IDE)
# Copy local shaders to module target directory
IF( OW_COPY_SHADERS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/shaders ) # copy shaders only if the user wants it
ADD_CUSTOM_TARGET( ${MODULE_NAME}_CopyShaders
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/shaders ${MODULE_TARGET_DIR}/shaders/
COMMENT "Copy shaders of ${MODULE_NAME}"
)
ADD_DEPENDENCIES( ${MODULE_NAME} ${MODULE_NAME}_CopyShaders )
ENDIF()
# Build unit tests
IF( OW_COMPILE_TESTS )
# This ensures that the test is copied to the module directory
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
CXXTEST_ADD_TESTS_FROM_LIST( "${MODULES_SRC}"
"OWkernel;${MODULE_NAME}"
)
# Copy fixtures if they exist
IF( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures )
ADD_CUSTOM_TARGET( ${MODULE_NAME}_CopyFixtures
# as the "test" target runs in CMakes temporary build dir, the fixtures need to be placed there too.
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures ${CMAKE_BINARY_DIR}/modules/${MODULE_DIRNAME}/fixtures/
COMMENT "Copy fixtures of ${MODULE_NAME}"
)
ADD_DEPENDENCIES( ${MODULE_NAME} ${MODULE_NAME}_CopyFixtures )
ENDIF( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures )
ENDIF( OW_COMPILE_TESTS )
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// 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 <string>
#include "../../dataHandler/WDataTexture3D.h"
#include "../../kernel/WKernel.h"
#include "WMTextureMapper.xpm"
#include "WMTextureMapper.h"
// This line is needed by the module loader to actually find your module.
W_LOADABLE_MODULE( WMTextureMapper )
WMTextureMapper::WMTextureMapper() :
WModule()
{
// initialize
}
WMTextureMapper::~WMTextureMapper()
{
// cleanup
removeConnectors();
}
boost::shared_ptr< WModule > WMTextureMapper::factory() const
{
return boost::shared_ptr< WModule >( new WMTextureMapper() );
}
const char** WMTextureMapper::getXPMIcon() const
{
return WMTextureMapper_xpm;
}
const std::string WMTextureMapper::getName() const
{
return "Texture Mapper";
}
const std::string WMTextureMapper::getDescription() const
{
return "Can use the input as a texture that can be mapped to the navslices and so on.";
}
void WMTextureMapper::connectors()
{
m_input = WModuleInputData< WDataSetSingle >::createAndAdd( shared_from_this(), "input", "Input to apply as texture." );
// call WModules initialization
WModule::connectors();
}
void WMTextureMapper::properties()
{
m_propCondition = boost::shared_ptr< WCondition >( new WCondition() );
WModule::properties();
}
void WMTextureMapper::moduleMain()
{
// let the main loop awake if the data changes or the properties changed.
m_moduleState.setResetable( true, true );
m_moduleState.add( m_input->getDataChangedCondition() );
m_moduleState.add( m_propCondition );
// signal ready state
ready();
// loop until the module container requests the module to quit
while( !m_shutdownFlag() )
{
// Now, the moduleState variable comes into play. The module can wait for the condition, which gets fired whenever the input receives data
// or an property changes. The main loop now waits until something happens.
debugLog() << "Waiting ...";
m_moduleState.wait();
// woke up since the module is requested to finish
if( m_shutdownFlag() )
{
break;
}
// has the data changed?
if( m_input->handledUpdate() )
{
boost::shared_ptr< WDataSetSingle > dataSet = m_input->getData();
// valid data?
if( dataSet )
{
}
}
}
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// 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 WMTEXTUREMAPPER_h
#define WMTEXTUREMAPPER_h
#include <string>
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleInputData.h"
#include "../../dataHandler/WDataSetSingle.h"
/**
* This module simply registers the given dataset to the texture handling mechanism. This allows all outputs to be shown as a texture.
*
* \ingroup modules
*/
class WMTextureMapper: public WModule
{
public:
/**
* Standard constructor.
*/
WMTextureMapper();
/**
* Destructor.
*/
~WMTextureMapper();
/**
* Gives back the name of this module.
* \return the module's name.
*/
virtual const std::string getName() const;
/**
* Gives back a description of this module.
* \return description of module.
*/
virtual const std::string getDescription() const;
/**
* Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
* should never be initialized or modified in some other way. A simple new instance is required.
*
* \return the prototype used to create every module in OpenWalnut.
*/
virtual boost::shared_ptr< WModule > factory() const;
/**
* Get the icon for this module in XPM format.
*/
virtual const char** getXPMIcon() const;
protected:
/**
* Entry point after loading the module. Runs in separate thread.
*/
virtual void moduleMain();
/**
* Initialize the connectors this module is using.
*/
virtual void connectors();
/**
* Initialize the properties for this module.
*/
virtual void properties();
private:
/**
* A condition used to notify about changes in several properties.
*/
boost::shared_ptr< WCondition > m_propCondition;
boost::shared_ptr< WModuleInputData< WDataSetSingle > > m_input; //!< Input connector required by this module.
};
#endif // WMTEXTUREMAPPER_h
/* XPM */
static char const * WMTextureMapper_xpm[] = {
"32 32 2 1",
" c None",
". c #000000",
" ",
" ",
" ",
" ",
" .. ",
" .. ",
" .. . ",
" .. . . . ",
" .. . . . ",
" ............ ... ",
" ............ ... ",
" .. . . . ",
" .. . . . ",
" .. . ",
" .. ",
" .. .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" ... ",
" .. ",
" .. ",
" .. ",
" ..... ... ",
" ..... .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" ",
" "};
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