Commit 5d7de821 authored by Mario Hlawitschka's avatar Mario Hlawitschka
Browse files

[MERGE] merged my changes into current branch

[STYLE] changed some code to comply with the OW style guide
parents c1ef7835 3a11913e
......@@ -1419,7 +1419,7 @@ HIDE_UNDOC_RELATIONS = NO
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
HAVE_DOT = NO
HAVE_DOT = YES
# By default doxygen will write a font called FreeSans.ttf to the output
# directory and reference it in all dot files that doxygen generates. This
......
......@@ -6,11 +6,3 @@ The complete credit,copyright and ownership belongs to the
liberation-fonts project. See license.txt and COPYING as well as
AUTHORS for details.
arial.ttf:
==========
Due to a bug in OpenSceneGraph, we had to add some fonts here.
Especially arial.ttf. It is needed by the OSG Stat Display, where
the font filename cannot be changed. The file arial.ttf is a copy
of liberationSans-Bold.ttf. Sorry for that. Maybe this is fixed
some day.
......@@ -96,7 +96,7 @@ ADD_CUSTOM_TARGET( core_devdoc
# copy our own resources
IF( NOT OW_PACKAGE_NOCOPY_COREFONTS )
SETUP_RESOURCES( "core" "CORE" )
SETUP_GLOBAL_RESOURCES( "core" "CORE" )
ELSE()
# This is a hack which is quite debian specific. We do this here to avoid font duplicates since the ttf-liberation fonts are already
# available on Debian. If you need to modify this for another packaging thingy, please let me know (ebaum@informatik.uni-leipzig.d). We then
......@@ -106,8 +106,6 @@ ELSE()
COMPONENT "CORE" )
INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E make_directory \${CMAKE_INSTALL_PREFIX}/share/openwalnut/fonts )"
COMPONENT "CORE" )
INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink /usr/share/fonts/truetype/ttf-liberation/LiberationMono-Bold.ttf \${CMAKE_INSTALL_PREFIX}/share/openwalnut/fonts/arial.ttf )"
COMPONENT "CORE" )
INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink /usr/share/fonts/truetype/ttf-liberation/LiberationMono-Bold.ttf \${CMAKE_INSTALL_PREFIX}/share/openwalnut/fonts/Bold.ttf )"
COMPONENT "CORE" )
INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink /usr/share/fonts/truetype/ttf-liberation/LiberationMono-Italic.ttf \${CMAKE_INSTALL_PREFIX}/share/openwalnut/fonts/Italic.ttf )"
......
......@@ -25,6 +25,7 @@
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <boost/tokenizer.hpp>
......@@ -53,9 +54,10 @@ boost::shared_ptr< WPathHelper > WPathHelper::getPathHelper()
return m_instance;
}
void WPathHelper::setAppPath( boost::filesystem::path appPath )
void WPathHelper::setBasePaths( boost::filesystem::path appPath, boost::filesystem::path homePath )
{
m_appPath = appPath;
m_homePath = homePath;
m_sharePath = m_appPath / "../share/openwalnut";
m_docPath = m_appPath / "../share/doc";
m_configPath = m_appPath / "../share/openwalnut";
......@@ -94,6 +96,11 @@ boost::filesystem::path WPathHelper::getModulePath()
return getPathHelper()->m_modulePath;
}
boost::filesystem::path WPathHelper::getHomePath()
{
return getPathHelper()->m_homePath;
}
boost::filesystem::path WPathHelper::getLibPath()
{
return getPathHelper()->m_libPath;
......@@ -120,6 +127,7 @@ std::vector< boost::filesystem::path > WPathHelper::getAllModulePaths()
std::vector< boost::filesystem::path > paths;
// the first element always is the global search path
paths.push_back( getModulePath() );
paths.push_back( getHomePath() / "modules" );
// the environment variable stores the additional paths
std::string additionalPaths( getenv( "OW_MODULE_PATH" ) ? getenv( "OW_MODULE_PATH" ) : "" );
......@@ -133,6 +141,29 @@ std::vector< boost::filesystem::path > WPathHelper::getAllModulePaths()
paths.push_back( boost::filesystem::path( *it ) );
}
// add the additional paths
for( std::vector< boost::filesystem::path >::const_iterator it = getPathHelper()->m_additionalModulePaths.begin();
it != getPathHelper()->m_additionalModulePaths.end();
++it )
{
if( !std::count( paths.begin(), paths.end(), *it ) )
{
paths.push_back( *it );
}
}
return paths;
}
void WPathHelper::addAdditionalModulePath( const boost::filesystem::path& path )
{
if( !std::count( m_additionalModulePaths.begin(), m_additionalModulePaths.end(), path ) )
{
m_additionalModulePaths.push_back( path );
}
}
const std::vector< boost::filesystem::path >& WPathHelper::getAdditionalModulePaths() const
{
return m_additionalModulePaths;
}
......@@ -57,11 +57,13 @@ public:
static boost::shared_ptr< WPathHelper > getPathHelper();
/**
* Set the current application path. This should be called only once.
* Set the current application path. This should be called only once. The home path hereby is NOT the users home. It is an directory, where
* OW can write user specific data. A good default here is to specify USERHOME/.OpenWalnut for example.
*
* \param appPath the application path
* \param homePath the OW home path
*/
void setAppPath( boost::filesystem::path appPath );
void setBasePaths( boost::filesystem::path appPath, boost::filesystem::path homePath );
/**
* The path where the binary file resides in. This is for example /usr/bin.
......@@ -127,13 +129,37 @@ public:
static boost::filesystem::path getModulePath();
/**
* This returns a list of search paths for modules. This list is defined by the environment variable "OW_MODULE_PATH". All of these
* The path to the OW dir in the user's home. This will not be the home dir directly. It is something like $HOME/.OpenWalnut.
*
* \return OW home path
*/
static boost::filesystem::path getHomePath();
/**
* This returns a list of search paths for modules. This list is defined by the environment variable "OW_MODULE_PATH" and the list of additional
* module paths. All of these
* directories CAN contain modules. On startup, they get searched in the specified order.
*
* \return list of search paths for modules
*/
static std::vector< boost::filesystem::path > getAllModulePaths();
/**
* This method adds the given path to the list of module paths. This way, arbitrary paths can be specified to search for modules. Each path
* is searched recursively.
*
* \param path the path to add.
*/
void addAdditionalModulePath( const boost::filesystem::path& path );
/**
* Returns the list of paths added using addAdditionalModulePath. This does NOT contain the paths in OW_MODULE_PATH. Use getAllModulePaths
* for this.
*
* \return the list of additional paths
*/
const std::vector< boost::filesystem::path >& getAdditionalModulePaths() const;
/**
* The path to the OW libs. You normally should not need this.
*
......@@ -202,6 +228,17 @@ private:
*/
boost::filesystem::path m_libPath;
/**
* The path of a user specific OW directory.
*/
boost::filesystem::path m_homePath;
/**
* A list of additional paths to search for modules. This does not contain the paths in the environment variable OW_MODULE_PATH. This method
* is not thread-safe. You should only use it before the module factory loads the modules.
*/
std::vector< boost::filesystem::path > m_additionalModulePaths;
/**
* Singleton instance of WPathHelper.
*/
......
......@@ -36,7 +36,7 @@ struct WRecursiveTensorEvaluation;
/**
* Multiplies gradient components and divides by multiplicities.
*
* This essentailly calls WRecursiveTensorEvaluation< ... >::evaluate() N times.
* This essentailly calls WRecursiveTensorEvaluation< ... >s evaluate function N times.
*
* If IterEnd equals boost::mpl::bool_< false >, iteration is aborted.
*/
......
......@@ -95,6 +95,8 @@ public:
* \note If the gradient is not normalized, the result is undefined.
*
* Thanks to CHeine for the idea for this algorithm.
*
* \return The function value on the sphere for this tensor and the given gradient.
*/
Data_T evaluateSphericalFunction( WValue< Data_T > const& gradient ) const;
......@@ -108,6 +110,8 @@ public:
* \note If the gradient is not normalized, the result is undefined.
*
* Thanks to CHeine for the idea for this algorithm.
*
* \return The function value on the sphere for this tensor and the given gradient.
*/
Data_T evaluateSphericalFunction( WVector3d const& gradient ) const;
......
......@@ -33,7 +33,8 @@
*/
typedef enum
{
GE_RELOADSHADERS // when a shader reload is requested
GE_RELOADSHADERS, // when a shader reload is requested
GE_STARTUPCOMPLETE // when the first view was correctly initialized
}
GE_SIGNAL;
......
......@@ -56,15 +56,6 @@ WGraphicsEngine::WGraphicsEngine():
{
WLogger::getLogger()->addLogMessage( "Initializing Graphics Engine", "GE", LL_INFO );
// NOTE: the osgViewer::StatsHandler uses a hard coded font filename. :-(. Fortunately OSG allows us to modify the search path using
// environment variables:
#ifndef _WIN32
setenv( "OSGFILEPATH", WPathHelper::getFontPath().file_string().c_str(), 1 );
#else
std::string envStr = std::string( "OSGFILEPATH=" ) + WPathHelper::getFontPath().file_string();
putenv( envStr.c_str() );
#endif
#ifndef __APPLE__
// initialize OSG render window
m_viewer = osg::ref_ptr<osgViewer::CompositeViewer>( new osgViewer::CompositeViewer() );
......@@ -238,6 +229,8 @@ boost::signals2::connection WGraphicsEngine::subscribeSignal( GE_SIGNAL signal,
{
case GE_RELOADSHADERS:
return m_reloadShadersSignal.connect( notifier );
case GE_STARTUPCOMPLETE:
return m_startThreadingCondition.subscribeSignal( notifier );
default:
std::ostringstream s;
s << "Could not subscribe to unknown signal.";
......
......@@ -88,11 +88,12 @@ public:
* \return the created triangle mesh
*/
template< typename T >
boost::shared_ptr< WTriangleMesh > generateSurface( size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ,
const WMatrix< double >& mat,
const std::vector< T >* vals,
double isoValue,
boost::shared_ptr<WProgressCombiner> mainProgress = boost::shared_ptr < WProgressCombiner >() );
boost::shared_ptr< WTriangleMesh > generateSurface( size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ,
const WMatrix< double >& mat,
const std::vector< T >* vals,
double isoValue,
boost::shared_ptr<WProgressCombiner> mainProgress
= boost::shared_ptr < WProgressCombiner >() );
/**
* Generate the triangles for the surface on the given dataSet (inGrid, vals). The texture coordinates in the resulting mesh are relative to
......@@ -108,11 +109,12 @@ public:
*
* \return the created triangle mesh
*/
boost::shared_ptr< WTriangleMesh > genSurfaceOneValue( size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ,
const WMatrix< double >& mat,
const std::vector< size_t >* vals,
size_t isoValue,
boost::shared_ptr<WProgressCombiner> progress = boost::shared_ptr < WProgressCombiner >() );
boost::shared_ptr< WTriangleMesh > genSurfaceOneValue( size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ,
const WMatrix< double >& mat,
const std::vector< size_t >* vals,
size_t isoValue,
boost::shared_ptr<WProgressCombiner> progress
= boost::shared_ptr < WProgressCombiner >() );
protected:
private:
......
......@@ -206,6 +206,109 @@ float blinnPhongIlluminationIntensity( in vec3 normal )
return blinnPhongIlluminationIntensity( wge_DefaultLightIntensity, normal );
}
/**
* Function to calculate lighting intensity for a matte (non-specular) Phong illumination.
*
* \param ambient materials ambient color
* \param diffuse materials diffuse color
* \param lightColor the light color
* \param ambientLight the ambient light color
* \param normalDir the normal
* \param viewDir viewing direction
* \param lightDir light direction
*
* \return the color.
*/
vec4 mattePhongIllumination( vec3 ambient, vec3 diffuse,
vec3 lightColor, vec3 ambientLight,
vec3 normalDir, vec3 viewDir, vec3 lightDir )
{
vec3 H = normalize( lightDir + viewDir );
// compute ambient term
vec3 ambientV = ambient * ambientLight;
// compute diffuse term
float diffuseLight = max( dot( lightDir, normalDir ), 0.0 );
vec3 diffuseV = diffuse * diffuseLight;
return vec4( ambientV + diffuseV * lightColor, 1.0 );
}
/**
* Function to calculate lighting intensity for a matte (non-specular) Phong illumination.
* It is basically the same as blinnPhongIllumination function above. But it is faster if you just need
* the intensity.
*
* \param ambient materials ambient intensity
* \param diffuse materials diffuse intensity
* \param specular materials specular intensity
* \param shininess material shininess
* \param lightIntensity the light intensity
* \param ambientIntensity the ambient light intensity
* \param normalDir the normal
* \param viewDir viewing direction
* \param lightDir light direction
*
* \return the light intensity.
*/
float mattePhongIlluminationIntensity( float ambient, float diffuse,
float lightIntensity, float ambientIntensity,
vec3 normalDir, vec3 viewDir, vec3 lightDir )
{
vec3 H = normalize( lightDir + viewDir );
// compute ambient term
float ambientV = ambient * ambientIntensity;
// compute diffuse term
float diffuseLight = max( dot( lightDir, normalDir ), 0.0 );
float diffuseV = diffuse * diffuseLight;
return ambientV + diffuseV * lightIntensity;
}
/**
* Function to calculate lighting intensity for a matte (non-specular) Phong illumination.
* Any specular or shininess given with the parameters will be ignored.
* It is basically the same as blinnPhongIllumination function above. But it is faster if you just need
* the intensity.
*
* \param parameter the wge_LightIntensityParameter defining material and light
* \param normal the normal. Needs to be normalized.
*
* \return lighting intensity.
*/
float mattePhongIlluminationIntensity( in wge_LightIntensityParameter parameter, in vec3 normal )
{
return mattePhongIlluminationIntensity(
parameter.materialAmbient,
parameter.materialDiffuse,
parameter.lightDiffuse,
parameter.lightAmbient,
normal,
parameter.viewDirection,
parameter.lightPosition
);
}
/**
* Function to calculate lighting intensity for a matte (non-specular) Phong illumination.
* It is basically the same as blinnPhongIllumination function above. But it is faster if you just need
* the intensity. This uses the wge_DefaultLightIntensity without the specular and shininess.
*
* \param normal the normal. Must be normalized beforehand
*
* \return the light intensity
*/
float mattePhongIlluminationIntensity( in vec3 normal )
{
wge_LightIntensityParameter noSpecular = wge_DefaultLightIntensity;
noSpecular.materialShinines = 0.0;
noSpecular.materialSpecular = 0.0;
return mattePhongIlluminationIntensity( noSpecular, normal );
}
/**
* This illumination technique is from "Jens Krüger and Rüdiger Westermann - EFFICIENT STIPPLE RENDERING". It is a non-linear illumination model
* which only handles ambient and diffuse components. The parameter alpha determines how much the diffuse light should depend on the orientation
......
......@@ -24,6 +24,17 @@
#include "WCustomWidget.h"
WCustomWidget::WCustomWidget( std::string title ):
m_title( title )
{
}
WCustomWidget::~WCustomWidget()
{
}
std::string WCustomWidget::getTitle() const
{
return m_title;
}
......@@ -25,11 +25,14 @@
#ifndef WCUSTOMWIDGET_H
#define WCUSTOMWIDGET_H
#include <string>
#include <boost/shared_ptr.hpp>
#include <osg/ref_ptr>
#include "../graphicsEngine/WGEViewer.h"
class WGEGroupNode;
/**
......@@ -38,6 +41,23 @@ class WGEGroupNode;
class WCustomWidget
{
public:
/**
* Abbreviation for a shared pointer on a instance of this class.
*/
typedef boost::shared_ptr< WCustomWidget > SPtr;
/**
* Abbreviation for a const shared pointer on a instance of this class.
*/
typedef boost::shared_ptr< const WCustomWidget > ConstSPtr;
/**
* Constructor. Create a custom widget instance.
*
* \param title the title of the widget
*/
explicit WCustomWidget( std::string title );
/**
* Destructor
*/
......@@ -57,8 +77,20 @@ public:
*/
virtual boost::shared_ptr< WGEViewer > getViewer() const = 0;
/**
* Get the title of the widget.
*
* \return title as string
*/
virtual std::string getTitle() const;
protected:
private:
/**
* The widget's title string.
*/
std::string m_title;
};
#endif // WCUSTOMWIDGET_H
......@@ -82,23 +82,37 @@ public:
virtual int run() = 0;
/**
* Instruct the MainWindow to open a new custom widget.
* Instruct to open a new custom widget. The specified condition should be the shutdown condition of the module, as the function returns only
* if the widget was created. To ensure that the creation is aborted properly if the module shuts down in the meantime, this condition is
* used.
*
* \note this function blocks until the widget was created. Check the resulting pointer for NULL.
*
* \param title the title of the widget
* \param projectionMode the kind of projection which should be used
* \param shutdownCondition condition to wait for the shutdown of a module
* \param shutdownCondition a condition enforcing abort of widget creation.
*
* \return the created widget
*/
virtual boost::shared_ptr< WCustomWidget > openCustomWidget( std::string title, WGECamera::ProjectionMode projectionMode,
boost::shared_ptr< WCondition > shutdownCondition ) = 0;
virtual WCustomWidget::SPtr openCustomWidget(
std::string title,
WGECamera::ProjectionMode projectionMode,
boost::shared_ptr< WCondition > shutdownCondition ) = 0;
/**
* Instruct the MainWindow to close a custom widget.
* Instruct to close a custom widget.
*
* \param title The title of the widget
*/
virtual void closeCustomWidget( std::string title ) = 0;
/**
* Instruct to close the custom widget.
*
* \param widget the widget to close again.
*/
virtual void closeCustomWidget( WCustomWidget::SPtr widget ) = 0;
protected:
/**
* Flag determining whether the GUI is properly initialized.
......
......@@ -492,6 +492,27 @@ WModuleContainer::ModuleSharedContainerType::ReadTicket WModuleContainer::getMod
return m_modules.getReadTicket();
}
WModuleContainer::ModuleVectorType WModuleContainer::getModules( std::string name ) const
{
// get the list of all first.
WModuleContainer::ModuleSharedContainerType::ReadTicket lock = getModules();
// put results in here
WModuleContainer::ModuleVectorType result;
// handle each module
for( ModuleConstIterator listIter = lock->get().begin(); listIter != lock->get().end(); ++listIter )
{
// check name
if( name == ( *listIter )->getName() )
{
result.push_back( ( *listIter ) );
}
}
return result;
}
WCombinerTypes::WCompatiblesList WModuleContainer::getPossibleConnections( boost::shared_ptr< WModule > module )
{
WCombinerTypes::WCompatiblesList complist;
......
......@@ -61,6 +61,11 @@ public:
// the following typedefs are for convenience; to help accessing the container in a thread safe way.
/**
* A vector of modules
*/
typedef std::vector< boost::shared_ptr< WModule > > ModuleVectorType;
/**
* For shortening: a type defining a shared vector of WModule pointers.
*/
......@@ -257,13 +262,23 @@ public:
DataModuleListType getDataModules();
/**
* Method returns a read ticket allowing read-access to the list of modules.
* Method returns a read ticket allowing read-access to the list of modules inside the container.
* \note If done, ensure the ticket gets destroyed.
*
* \return the read ticket.
*/
ModuleSharedContainerType::ReadTicket getModules() const;
/**
* Queries the container to find all modules with a given name. This can be useful to check for existence of certain modules inside the
* container.
*
* \param name name of the modules to find
*
* \return the vector of modules. Empty if nothing was found.
*/
ModuleVectorType getModules( std::string name ) const;
/**
* This method creates a list of combiner instances, for each possible connection that can be made between the specified module and the
* module currently inside the container. It might be possible that a module which is contained in the returned list is not associated
......
......@@ -30,6 +30,8 @@
#include <osg/MatrixTransform>
#include <osg/Material>
#include <osg/StateAttribute>
#include <osg/Texture2D>
#include <osgDB/ReadFile>
#include <osg/Vec3>
#include <osg/Geometry>
......@@ -86,12 +88,14 @@ void WMCoordinateHUD::properties()
// list of alternatives:
m_possibleSelections = boost::shared_ptr< WItemSelection >( new WItemSelection() );
m_possibleSelections->addItem( "colored axis", "colorfull coordinate axis", option_1_xpm );
m_possibleSelections->addItem( "colored axis", "colorful coordinate axis", option_1_xpm );
m_possibleSelections->addItem( "b/w axis", "black & white coordinate axis", option_2_xpm );
m_possibleSelections->addItem( "colored cube", "colorfull coordinate cube", option_3_xpm );
m_possibleSelections->addItem( "colored cube", "colorful coordinate cube", option_3_xpm );
m_possibleSelections->addItem( "colored cube, medical labeling", "colorful coordinate cube with medical labeling", option_3_xpm );
m_possibleSelections->addItem( "colored cube, technical labeling", "colorful coordinate cube with technical labeling", option_3_xpm );
m_aSingleSelection = m_properties->addProperty( "HUD structure",
"Which look should the coordinateHUD have?", m_possibleSelections->getSelector( 2 ),
"Which look should the coordinateHUD have?", m_possibleSelections->getSelector( 3 ),
m_propCondition );
WPropertyHelper::PC_SELECTONLYONE::addTo( m_aSingleSelection );
......@@ -109,6 +113,8 @@ void WMCoordinateHUD::moduleMain()
m_rootNode = new WGEManagedGroupNode( m_active );