Commit c41f4290 authored by Franziska Jacob's avatar Franziska Jacob

Init Modul TransferCalcToolbox

parents
[Dolphin]
ShowPreview=true
Timestamp=2012,4,23,20,0,34
Version=2
[Settings]
ShowDotFiles=true
[Dolphin]
Timestamp=2012,4,24,1,31,55
Version=2
ViewMode=2
You are free to copy, modify and re-distribute these files as you like.
* This is an example of how to create your own module toolbox
for OpenWalnut (http://www.openwalnut.org).
* You should have a look at our WIKI for further details under
http://www.openwalnut.org/projects/openwalnut/wiki/Module_ExternalDevelopment
* It basically creates one library with two modules in it.
You can use this example as your basic development setup
and extend it as you need.
* Please contact us if you have trouble or if you have added
platform support to the OpenWalnut.cmake script. We
appreciate your help!
Happy coding!
- The OpenWalnut Team -
# OW Version File. This file specifies the version. The line VERSION=X.Y.Z is
# used and parsed. This file has to be here everytime. The VERSION needs to be
# set properly or CMake will fail.
#
# SYNTAX: The version string always is 1.2.3 with an optional postfix of "+hg1234".
# This is useful if building is done by scripts. If you want to automatically
# add the correct HG revision, use only +hgX without number.
#
# IMPORTANT: If you modify the file, cmake re-creates the version header. But
# it is not able to set all library version. Please re-run cmake if
# you change something here.
#
# NOTE: do not add a space after #. The current CMake script will fail.
# Examples:
#VERSION=1.2.0
#VERSION=1.2.0+hgX -> replaces the X with the current revision number
#VERSUIB=1.2.0+hg1234 -> here, revision number was set by the build scripts for example.
VERSION=0.1.0+hgX
just to avoid removal of empty directories
This diff is collapsed.
<doxygenlayout version="1.0">
<!-- Navigation index tabs for HTML output -->
<navindex>
<tab type="mainpage" visible="yes" title=""/>
<tab type="pages" visible="yes" title=""/>
<tab type="modules" visible="yes" title="Groups"/>
<tab type="namespaces" visible="yes" title="">
<tab type="namespaces" visible="yes" title=""/>
<tab type="namespacemembers" visible="yes" title=""/>
</tab>
<tab type="classes" visible="yes" title="">
<tab type="classes" visible="yes" title=""/>
<tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
<tab type="hierarchy" visible="yes" title=""/>
<tab type="classmembers" visible="yes" title=""/>
</tab>
<tab type="files" visible="yes" title="">
<tab type="files" visible="yes" title=""/>
<tab type="globals" visible="yes" title=""/>
</tab>
<tab type="dirs" visible="yes" title=""/>
<tab type="examples" visible="yes" title=""/>
</navindex>
<!-- Layout definition for a class page -->
<class>
<briefdescription visible="yes"/>
<includes visible="$SHOW_INCLUDE_FILES"/>
<inheritancegraph visible="$CLASS_GRAPH"/>
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
<allmemberslink visible="yes"/>
<memberdecl>
<nestedclasses visible="yes" title=""/>
<publictypes title=""/>
<publicslots title=""/>
<signals title=""/>
<publicmethods title=""/>
<publicstaticmethods title=""/>
<publicattributes title=""/>
<publicstaticattributes title=""/>
<protectedtypes title=""/>
<protectedslots title=""/>
<protectedmethods title=""/>
<protectedstaticmethods title=""/>
<protectedattributes title=""/>
<protectedstaticattributes title=""/>
<packagetypes title=""/>
<packagemethods title=""/>
<packagestaticmethods title=""/>
<packageattributes title=""/>
<packagestaticattributes title=""/>
<properties title=""/>
<events title=""/>
<privatetypes title=""/>
<privateslots title=""/>
<privatemethods title=""/>
<privatestaticmethods title=""/>
<privateattributes title=""/>
<privatestaticattributes title=""/>
<friends title=""/>
<related title="" subtitle=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<typedefs title=""/>
<enums title=""/>
<constructors title=""/>
<functions title=""/>
<related title=""/>
<variables title=""/>
<properties title=""/>
<events title=""/>
</memberdef>
<usedfiles visible="$SHOW_USED_FILES"/>
<authorsection visible="yes"/>
</class>
<!-- Layout definition for a namespace page -->
<namespace>
<briefdescription visible="yes"/>
<memberdecl>
<nestednamespaces visible="yes" title=""/>
<classes visible="yes" title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
</memberdef>
<authorsection visible="yes"/>
</namespace>
<!-- Layout definition for a file page -->
<file>
<briefdescription visible="yes"/>
<includes visible="$SHOW_INCLUDE_FILES"/>
<includegraph visible="$INCLUDE_GRAPH"/>
<includedbygraph visible="$INCLUDED_BY_GRAPH"/>
<sourcelink visible="yes"/>
<memberdecl>
<classes visible="yes" title=""/>
<namespaces visible="yes" title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
</memberdef>
<authorsection/>
</file>
<!-- Layout definition for a group page -->
<group>
<briefdescription visible="yes"/>
<groupgraph visible="$GROUP_GRAPHS"/>
<memberdecl>
<classes visible="yes" title=""/>
<namespaces visible="yes" title=""/>
<dirs visible="yes" title=""/>
<nestedgroups visible="yes" title=""/>
<files visible="yes" title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<enumvalues title=""/>
<functions title=""/>
<variables title=""/>
<signals title=""/>
<publicslots title=""/>
<protectedslots title=""/>
<privateslots title=""/>
<events title=""/>
<properties title=""/>
<friends title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<pagedocs/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<enumvalues title=""/>
<functions title=""/>
<variables title=""/>
<signals title=""/>
<publicslots title=""/>
<protectedslots title=""/>
<privateslots title=""/>
<events title=""/>
<properties title=""/>
<friends title=""/>
</memberdef>
<authorsection visible="yes"/>
</group>
<!-- Layout definition for a directory page -->
<directory>
<briefdescription visible="yes"/>
<directorygraph visible="yes"/>
<memberdecl>
<dirs visible="yes"/>
<files visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
</directory>
</doxygenlayout>
#---------------------------------------------------------------------------
#
# 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/>.
#
#---------------------------------------------------------------------------
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# General CMake Setup
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT( TransferCalcToolbox )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Include the OpenWalnut build system.
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# where to find our utils and cmake modules?
SET( OW_TOOLS_DIR ${PROJECT_SOURCE_DIR}/../tools )
# append search path for FindModules:
LIST( APPEND CMAKE_MODULE_PATH ${OW_TOOLS_DIR}/cmake )
# These scripts contains all the needed tools to setup the build:
# * Compiler Setup
# * Common OpenWalnut Options
# * Third-party Dependencies Setup
# * Unit Testing Setup if found
# * Doxygen Setup if found
INCLUDE( OpenWalnut )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Setup your additional dependencies and tools
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# IMPORTANT: NEVER add any commands bore the line INCLUDE( OpenWalnut ). This might cause problems!
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Setup all modules
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Here, you can add your own targets, call ADD_MODULE provided by OpenWalnut or a combination of it. When using ADD_MODULE or SETUP_MODULE, the
# OpenWalnut CMake scripts manages proper resource handling, test compilation and similar. You should use it whenever possible. More details on
# how to develop external modules, have a look at http://www.openwalnut.org. You can have a look at OpenWalnut.cmake if you want to modify
# the default behaviour.
# Please see the documentation of SETUP_MODULE as it shows how to add custom dependencies (third-party libs)
SETUP_MODULE(
${PROJECT_NAME} # use project name as module(-toolbox) name
"." # where to find the sources
"" # no additonal dependencies
"" # no sources to exclude
)
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Additional Setup
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Add the files under ../resources/MyGlobalResources as additional, global resources
# The first parameter is the directory name, the second parameter is the component name. This is used during installation to identify to which
# install component this belongs. The name is arbitrary but must be unique.
#
# NOTE: The first parameter of SETUP_MODULE is not allowed as component name here because SETUP_MODULE already registers this component. Simply
# append some string.
SETUP_GLOBAL_RESOURCES( "MyGlobalResources" ${PROJECT_NAME}_Global )
#include <boost/shared_ptr.hpp>
#include <core/kernel/WModule.h>
#include "transferCalc/WMTransferCalc.h"
#include "WToolkit.h"
// This file's purpose is to provide a list of modules as entry point for OpenWalnut's module loader.
// Add your modules here. If you miss this step, OpenWalnut will not be able to load your modules.
extern "C" void WLoadModule( WModuleList& m ) // NOLINT
{
m.push_back( boost::shared_ptr< WModule >( new WMTransferCalc ) );
}
#ifndef WTOOLKIT_H
#define WTOOLKIT_H
// nothing to do here. Have a look at WToolkit.cpp for registration of all the modules inside the toolbox.
#endif // WTOOLKIT_H
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------
// Some rules to the inclusion of headers:
// * Ordering:
// * C Headers
// * C++ Standard headers
// * External Lib headers (like OSG or Boost headers)
// * headers of other classes inside OpenWalnut
// * your own header file
#include <string>
#include <osg/ShapeDrawable>
#include <osg/Group>
#include <osg/Geode>
#include <osg/Material>
#include <osg/StateAttribute>
#include "core/kernel/WKernel.h"
#include "core/common/WColor.h"
#include "core/common/WPathHelper.h"
#include "core/common/WPropertyHelper.h"
#include "core/graphicsEngine/WGEUtils.h"
#include "core/graphicsEngine/WGERequirement.h"
#include "WMTransferCalc.xpm"
#include "WMTransferCalc.h"
// This line is needed by the module loader to actually find your module. You need to add this to your module too. Do NOT add a ";" here.
// W_LOADABLE_MODULE( WMTransferCalc )
WMTransferCalc::WMTransferCalc():
WModule()
{
// In the constructor, you can initialize your members and all this stuff. You must not initialize connectors or properties here! You also
// should avoid doing computationally expensive stuff, since every module has its own thread which is intended to be used for such calculations.
// Please keep in mind, that every member initialized here is also initialized in the prototype, which may be a problem if the member is large,
// and therefore, wasting a lot of memory in your module's prototype instance.
}
WMTransferCalc::~WMTransferCalc()
{
// Cleanup!
}
boost::shared_ptr< WModule > WMTransferCalc::factory() const
{
return boost::shared_ptr< WModule >( new WMTransferCalc() );
}
const char** WMTransferCalc::getXPMIcon() const
{
return WMTransferCalc_xpm;
}
const std::string WMTransferCalc::getName() const
{
return "Show as Orbs";
}
const std::string WMTransferCalc::getDescription() const
{
return "Displays the given data with an orb per voxel if the value of the voxel equals a given iso-range.";
}
void WMTransferCalc::connectors()
{
m_inputData = WModuleInputData< WDataSetScalar >::createAndAdd( shared_from_this(), "givenData", "Data which will be checked for displaying." );
// call WModules initialization
WModule::connectors();
}
void WMTransferCalc::properties()
{
m_propCondition = boost::shared_ptr< WCondition >( new WCondition() );
m_isoValue = m_properties->addProperty( "ISO-Value", "Iso value to be rendered.", 100.0, m_propCondition );
m_epsilon = m_properties->addProperty( "Epsilon", "Epsilon value to define the iso range.", 1.0, m_propCondition );
m_color = m_properties->addProperty( "Color", "Color of the orbs.", WColor( 1.0, 0.0, 0.0, 1.0 ), m_propCondition );
WModule::properties();
}
void WMTransferCalc::requirements()
{
m_requirements.push_back( new WGERequirement() );
}
void WMTransferCalc::moduleMain()
{
debugLog() << "moduleMain started...";
m_moduleState.setResetable( true, true );
m_moduleState.add( m_inputData->getDataChangedCondition() );
m_moduleState.add( m_propCondition );
ready();
debugLog() << "Module is now ready.";
m_rootNode = new WGEManagedGroupNode( m_active );
//m_rootNode->addUpdateCallback( new TranslateCallback( this ) );
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( m_rootNode );
debugLog() << "Entering main loop";
while( !m_shutdownFlag() )
{
debugLog() << "Waiting ...";
m_moduleState.wait();
// woke up since the module is requested to finish
if( m_shutdownFlag() )
{
debugLog() << "Closing module...";
break;
}
bool dataUpdated = m_inputData->updated();
boost::shared_ptr< WDataSetScalar > dataSet = m_inputData->getData();
bool dataValid = ( dataSet );
if( !dataValid )
{
debugLog() << "Data changed. No valid data anymore. Cleaning up.";
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
}
bool propsChanged = m_isoValue->changed() || m_epsilon->changed(); // || m_color->changed();
if( ( propsChanged || dataUpdated ) && dataValid )
{
debugLog() << "Received Data or Data changed.";
double min = dataSet->getMin();
double max = dataSet->getMax();
m_isoValue->setMin( min );
m_isoValue->setMax( max );
m_isoValue->setRecommendedValue( min + ( 0.5 * max ) );
// m_epsilon->setMin( 0 );
// m_epsilon->setMax( 0.1 * (max - min) );
m_epsilon->setRecommendedValue( 0.005 * (max - min) );
double eps = m_epsilon->get( true );
double iso = m_isoValue->get( true );
debugLog() << "Given epsilon: " << eps;
debugLog() << "Given iso value: " << iso;
osg::ref_ptr< osg::Geode > newGeode = new osg::Geode();
size_t s = dataSet->getValueSet()->rawSize();
debugLog() << "Raw size of ValueSet: " << s ;
double currentVal;
int count = 0;
boost::shared_ptr< WProgress > prog = boost::shared_ptr< WProgress >( new WProgress( "Going through data.", s ) );
m_progress->addSubProgress( prog );
osg::ref_ptr< osg::ShapeDrawable > orb = new osg::ShapeDrawable ();
// First, grab the grid
boost::shared_ptr< WGridRegular3D > grid = boost::shared_dynamic_cast< WGridRegular3D >( dataSet->getGrid() );
if( !grid )
{
errorLog() << "The dataset does not provide a regular grid. Ignoring dataset.";
continue;
}
for( size_t i = 0; i < s ; i++ )
{
++*prog;
currentVal = dataSet->getValueAt( i );
if( (iso-eps) <= currentVal && currentVal <= (iso+eps) )
{
count++;
newGeode->addDrawable(
new osg::ShapeDrawable( new osg::Sphere( grid->getPosition( i ).as< osg::Vec3d >() , 0.5f ) ) );
if( count == 5000 ) break;
}
}
debugLog() << "Found: " << count;
m_rootNode->remove( m_geode );
m_geode = newGeode;
m_geode->addUpdateCallback( new SafeUpdateCallback( this ) );
m_rootNode->insert( m_geode );
prog->finish();
}
}
}
void WMTransferCalc::SafeUpdateCallback::operator()( osg::Node* node, osg::NodeVisitor* nv )
{
// One note about m_aColor: As you might have notices, changing one of the properties, which recreate the OSG node, causes the material to be
// gray again. This is simply caused by m_aColor->changed() is still false! To resolve this problem, use some m_osgNeedsUpdate boolean which
// gets set in your thread main and checked here or, as done in this module, by checking whether the callback is called the first time.
if( m_module->m_color->changed() || m_initialUpdate )
{
// Set the diffuse color and material:
osg::ref_ptr< osg::Material > mat = new osg::Material();
mat->setDiffuse( osg::Material::FRONT, m_module->m_color->get( true ) );
node->getOrCreateStateSet()->setAttribute( mat, osg::StateAttribute::ON );
}
traverse( node, nv );
}
\ No newline at end of file
//---------------------------------------------------------------------------
//
// 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