Commit 91238e56 authored by schurade's avatar schurade

Merge with bb9f50f3a66ed68cfd1662bc6dd8bce06d47b876

parents 9d2d2695 192980c6
......@@ -24,6 +24,9 @@ syntax: regexp
^src/tags
^src/cscope.out
# files geneterated by build system
^src/version.h
# local vim rc
^lvimrc
......
......@@ -7,6 +7,8 @@
## An example could be
# default=HUD
#whiteList =Isosurface,Bounding Box, Direct Volume Rendering,Distance Map Isosurface,Gauss Filtering,HUD,Vector Plot,Write NIfTI # A list of modules that will be provided through the GUI. If the list is empty all available modules are provided.
# path = /some/directory # this is useful to define the path where OpenWalnut searches modules for loading. It can be relative to the bin
# directory.
[qt4gui]
####################################################################
......
......@@ -13,6 +13,8 @@ allowOnlyOneFiberDataSet = yes # This will prevent you from accidently loading m
## A list of modules that will be provided through the GUI.
## If the list is empty all available modules are provided.
whiteList = Isosurface,Bounding Box,Isosurface Raytracer,Distance Map Isosurface,Gauss Filtering,HUD,Vector Plot,Write NIfTI,Mesh Reader,Triangle Mesh Renderer,Arbitrary Rois,LIC,Voxelizer,Superquadric Glyphs
# path = /some/directory # this is useful to define the path where OpenWalnut searches modules for loading. It can be relative to the bin
# directory.
[qt4gui]
####################################################################
......
#!/bin/sh
# get path of this script
BINDIR=`dirname "$0"`
# assume that this script is in the bin dir
# go there to ensure walnuts working directory is set correctly
cd "$BINDIR"
#run walnut
echo "OpenWalnut built from: $(cat ./revision)"
./walnut-bin $@
......@@ -12,7 +12,6 @@ echo run $@ > $PARAM_FILENAME
cd "$BINDIR"
# run walnut
echo "OpenWalnut built from: $(cat ./revision)"
gdb ./walnut-bin -command=$PARAM_FILENAME
gdb ./walnut -command=$PARAM_FILENAME
rm $PARAM_FILENAME
......@@ -12,6 +12,5 @@ PARAMS="$*"
echo "Parameters: $PARAMS"
# run walnut
echo "OpenWalnut built from: $(cat ./revision)"
kdbg -a "$PARAMS" walnut-bin
kdbg -a "$PARAMS" walnut
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT( OpenWalnut )
# append search path for FindModules:
#------------------------------------
LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../tools/CMakeModules )
......@@ -13,6 +12,7 @@ INCLUDE( ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/Utils.cmake )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib )
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib )
SET( SHARED_FILES_RELATIVE "../share/${CMAKE_PROJECT_NAME}" CACHE INTERNAL "Relative path to bin/ denoting the destination for shaders and cfg files." ) # this path us the relative path to bin/ used for all shared files like shaders and config file
# CMAKE automatism to select static vs. shared building:
#-------------------------------------------------------
......@@ -139,23 +139,34 @@ ADD_SUBDIRECTORY( gui )
ADD_SUBDIRECTORY( kernel )
ADD_SUBDIRECTORY( common )
ADD_SUBDIRECTORY( modules )
ADD_EXECUTABLE( walnut-bin OpenWalnut.cpp )
TARGET_LINK_LIBRARIES( walnut-bin kernel dataHandler gui guiqt4 common ge ${Boost_LIBRARIES} )
#-------------------------------------------------------------------------------------------------------------
# Writes information about the revision of the current code to the file version.h which then gets included by OpenWalnut.cpp
add_custom_command( OUTPUT ${PROJECT_SOURCE_DIR}/version.h
MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/../.hg/dirstate
COMMAND hg parents --template '\#define W_VERSION \"{node|short} {rev} {branches} {tags}\"' > ${PROJECT_SOURCE_DIR}/version.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Creating version.h"
)
# finally, build walnut
ADD_EXECUTABLE( walnut OpenWalnut.cpp version.h )
TARGET_LINK_LIBRARIES( walnut OWkernel OWdataHandler OWgui OWguiqt4 OWcommon OWge ${Boost_LIBRARIES} )
#---------- Shaders -------------
option( OW_COPY_SHADERS "This enables copying shaders with every make call." ON )
if( OW_COPY_SHADERS )
add_custom_target( shaderDirectoryConfiguration
ALL
COMMAND ${CMAKE_COMMAND} -D OW_SOURCE_DIR:STRING=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/UpdateShaders.cmake
COMMENT "Put all shaders to the right place or update them if they are already there."
COMMAND ${CMAKE_COMMAND} -D OW_SOURCE_DIR:STRING=${PROJECT_SOURCE_DIR} -D SHARED_FILES_RELATIVE:PATH=${SHARED_FILES_RELATIVE} -P ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/UpdateShaders.cmake
COMMENT "Put all global shaders to the right place or update them if they are already there."
)
endif( OW_COPY_SHADERS )
#---------- fonts -------------
add_custom_target( fontsDirectoryConfiguration
ALL
COMMAND ${CMAKE_COMMAND} -D OW_SOURCE_DIR:STRING=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/CopyFonts.cmake
COMMAND ${CMAKE_COMMAND} -D OW_SOURCE_DIR:STRING=${PROJECT_SOURCE_DIR} -D SHARED_FILES_RELATIVE:PATH=${SHARED_FILES_RELATIVE} -P ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/CopyFonts.cmake
COMMENT "Put all fonts to the right place."
)
......@@ -175,9 +186,9 @@ ELSE()
ENDIF()
#---------- walnut.cfg file -------------
IF( NOT EXISTS ${PROJECT_BINARY_DIR}/bin/walnut.cfg )
CONFIGURE_FILE( ${PROJECT_SOURCE_DIR}/../doc/user/walnut.cfg.mpi ${PROJECT_BINARY_DIR}/bin/walnut.cfg COPYONLY )
MESSAGE( STATUS "Copied ${PROJECT_SOURCE_DIR}/../doc/user/walnut.cfg.mpi to ${PROJECT_BINARY_DIR}/bin/walnut.cfg" )
IF( NOT EXISTS ${PROJECT_BINARY_DIR}/bin/${SHARED_FILES_RELATIVE}/walnut.cfg )
CONFIGURE_FILE( ${PROJECT_SOURCE_DIR}/../doc/user/walnut.cfg.mpi ${PROJECT_BINARY_DIR}/bin/${SHARED_FILES_RELATIVE}/walnut.cfg COPYONLY )
MESSAGE( STATUS "Copied ${PROJECT_SOURCE_DIR}/../doc/user/walnut.cfg.mpi to ${PROJECT_BINARY_DIR}/bin/${SHARED_FILES_RELATIVE}/walnut.cfg" )
ENDIF()
# Special targets:
......@@ -241,6 +252,7 @@ FOREACH( dirname ${EXCLUDE_DIRS} )
LIST( REMOVE_ITEM STYLE_CPP ${fname} )
ENDFOREACH( fname )
ENDFOREACH( dirname )
LIST( REMOVE_ITEM STYLE_H ${PROJECT_SOURCE_DIR}/version.h )
IF( CMAKE_COLOR_MAKEFILE )
SET( STYLECHECK_OPTIONS "--color" )
......@@ -265,14 +277,6 @@ ADD_CUSTOM_TARGET( stylecheck
COMMENT "Check if code complies to CodingStandard"
)
#-------------------------------------------------------------------------------------------------------------
# Writes information about the revision of the current code to a file
ADD_CUSTOM_TARGET( identify
ALL
COMMAND hg identify --cwd ${PROJECT_SOURCE_DIR} -n -i -b -t > ${PROJECT_BINARY_DIR}/bin/revision
COMMENT "Write information about the revision of the current code to a file"
)
#-------------------------------------------------------------------------------------------------------------
# Prints the verbose output of the test runners, so you may identify the source of error early, if any
ADD_CUSTOM_TARGET( vtest
......@@ -287,29 +291,6 @@ ADD_CUSTOM_TARGET( cicheck
COMMENT "Checks if all is well to commit"
)
#-------------------------------------------------------------------------------------------------------------
# Copies fixtures used for tests to the binary directory (where they are expected).
IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
ADD_CUSTOM_TARGET( fixtures
ALL
COMMAND cp -rf ${PROJECT_SOURCE_DIR}/dataHandler/test/fixtures ${PROJECT_BINARY_DIR}/dataHandler/
COMMAND cp -rf ${PROJECT_SOURCE_DIR}/dataHandler/io/test/fixtures ${PROJECT_BINARY_DIR}/dataHandler/io
# TODO(wiebel): we need to find a way to do this automatically
COMMAND cp -rf ${PROJECT_SOURCE_DIR}/modules/marchingCubes/test/fixtures ${PROJECT_BINARY_DIR}/modules/marchingCubes
COMMENT "Copy fixtures to the right place."
)
ELSE()
ADD_CUSTOM_TARGET( fixtures
ALL
COMMAND ${CMAKE_COMMAND} -D OW_SOURCE_DIR:STRING=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/FixturesWin.cmake
COMMENT "Copy fixtures to the right place."
)
ENDIF()
#-------------------------------------------------------------------------------------------------------------
# Makes many special make targets in combination. Default number of cores is 1.
SET( NUM_CORES_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../tools/numCores )
......
......@@ -29,6 +29,8 @@
#include "gui/qt4/WQt4Gui.h"
#include "version.h" // this header gets created by our build system.
/**
* \mainpage OpenWalnut Inline Documentation
* \par
......@@ -43,7 +45,8 @@
*/
int main( int argc, char** argv )
{
std::cout << "OpenWalnut ( http://www.openwalnut.org )\n"
std::cout << "OpenWalnut ( http://www.openwalnut.org )" << std::endl <<
"Build from: " << W_VERSION << std::endl << std::endl <<
"Copyright (C) 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS\n"
"For more information see http://www.openwalnut.org/copying\n"
"This program comes with ABSOLUTELY NO WARRANTY.\n"
......
......@@ -7,14 +7,19 @@ ADD_SUBDIRECTORY( datastructures )
ADD_SUBDIRECTORY( constraints )
ADD_SUBDIRECTORY( math )
ADD_LIBRARY( common ${COMMON_SRC} ${COMMON_DATASTRUCTURES_SRC} ${COMMON_EXCEPTIONS_SRC} ${MATH_SRC} ${FIBERSIMILARITY_SRC} )
TARGET_LINK_LIBRARIES( common ${Boost_LIBRARIES} )
ADD_LIBRARY( OWcommon ${COMMON_SRC} ${COMMON_DATASTRUCTURES_SRC} ${COMMON_EXCEPTIONS_SRC} ${MATH_SRC} ${FIBERSIMILARITY_SRC} )
TARGET_LINK_LIBRARIES( OWcommon ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
# Set the prefix and suffix of dynamically loadable modules to match
# CMAKEs naming of them. The quotes are necessary so the shell doesn't mess
# with these defines.
add_definitions( '-DW_LIB_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}"' )
add_definitions( '-DW_LIB_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"' )
# Unit tests
IF( OW_COMPILE_TESTS )
CXXTEST_ADD_TESTS_FROM_LIST( "${COMMON_SRC}"
"common"
"OWcommon"
"WSegmentationFault.cpp" # can't test seg-faults ;-)
"WTransferable.cpp" # its an empty class
"WPropertyBase.cpp" # its an abstract class. Its small functionality is tested in WPropertyVariable_test.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/>.
//
//---------------------------------------------------------------------------
#include <string>
#include <vector>
#include <boost/tokenizer.hpp>
#include "WPreferences.h"
#include "WPathHelper.h"
// path helper instance as singleton
boost::shared_ptr< WPathHelper > WPathHelper::m_instance = boost::shared_ptr< WPathHelper >();
WPathHelper::WPathHelper()
{
// initialize members
}
WPathHelper::~WPathHelper()
{
// cleanup
}
boost::shared_ptr< WPathHelper > WPathHelper::getPathHelper()
{
if ( !m_instance )
{
m_instance = boost::shared_ptr< WPathHelper >( new WPathHelper() );
}
return m_instance;
}
void WPathHelper::setAppPath( boost::filesystem::path appPath )
{
m_appPath = appPath;
m_sharePath = m_appPath / "../share/OpenWalnut";
m_libPath = m_appPath / "../lib";
m_modulePath = m_libPath / "modules";
}
boost::filesystem::path WPathHelper::getAppPath()
{
return getPathHelper()->m_appPath;
}
boost::filesystem::path WPathHelper::getConfigFile()
{
// TODO(ebaum): we should prefer a user config file in ~.walnut.cfg in future. This needs to be platform independent of course.
return getPathHelper()->m_sharePath / "walnut.cfg";
}
boost::filesystem::path WPathHelper::getFontPath()
{
return getPathHelper()->m_sharePath / "fonts";
}
boost::filesystem::path WPathHelper::getShaderPath()
{
return getPathHelper()->m_sharePath / "shaders";
}
WPathHelper::Fonts WPathHelper::getAllFonts()
{
Fonts fonts;
fonts.Regular = getFontPath() / "LiberationMono-Regular.ttf";
fonts.Bold = getFontPath() / "LiberationMono-Bold.ttf";
fonts.Italic = getFontPath() / "LiberationMono-Italic.ttf";
fonts.Default = fonts.Bold;
return fonts;
}
boost::filesystem::path WPathHelper::getModulePath()
{
return getPathHelper()->m_modulePath;
}
boost::filesystem::path WPathHelper::getLibPath()
{
return getPathHelper()->m_libPath;
}
boost::filesystem::path WPathHelper::getSharePath()
{
return getPathHelper()->m_sharePath;
}
std::vector< boost::filesystem::path > WPathHelper::getAllModulePaths()
{
// the list of paths
std::vector< boost::filesystem::path > paths;
// the first element always is the global search path
paths.push_back( getModulePath() );
std::string additionalPaths = "";
if ( !WPreferences::getPreference< std::string >( "modules.path", &additionalPaths ) )
{
// no config option found.
return paths;
}
// separate list of additional paths:
typedef boost::tokenizer< boost::char_separator< char > > tokenizer;
boost::char_separator< char > sep( ";" );
tokenizer tok( additionalPaths, sep );
for ( tokenizer::iterator it = tok.begin(); it != tok.end(); ++it )
{
paths.push_back( boost::filesystem::path( *it ) );
}
return paths;
}
//---------------------------------------------------------------------------
//
// 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 WPATHHELPER_H
#define WPATHHELPER_H
#include <vector>
#include <boost/filesystem.hpp>
#include <boost/shared_ptr.hpp>
/**
* Singleton class helping to find files and paths. It is a useful to to search for resources and the central place to "hardcode" relative paths.
* It contains global paths only. Modules have their OWN local paths.
*/
class WPathHelper
{
public:
/**
* Default constructor.
*/
WPathHelper();
/**
* Destructor.
*/
virtual ~WPathHelper();
/**
* Returns instance of the path helper. If it does not exists, it will be created.
*
* \return the running path helper instance.
*/
static boost::shared_ptr< WPathHelper > getPathHelper();
/**
* Set the current application path. This should be called only once.
*
* \param appPath the application path
*/
void setAppPath( boost::filesystem::path appPath );
/**
* The path where the binary file resides in. This is for example /usr/bin.
*
* \return the application path.
*/
static boost::filesystem::path getAppPath();
/**
* The path of the configuration file walnut.cfg. Always use this file to parse configurations.
*
* \return the config file.
*/
static boost::filesystem::path getConfigFile();
/**
* The path where font files reside in.
*
* \return the font path.
*/
static boost::filesystem::path getFontPath();
/**
* Paths to all known fonts.
*/
typedef struct
{
/**
* The default font to use in most cases.
*/
boost::filesystem::path Default;
/**
* The Regular font (not bold, not italic)
*/
boost::filesystem::path Regular;
/**
* Italic font.
*/
boost::filesystem::path Italic;
/**
* Bold font.
*/
boost::filesystem::path Bold;
}
Fonts;
/**
* The paths to all fonts supported.
*
* \return the file paths to all fonts
*/
static Fonts getAllFonts();
/**
* The path to the global shaders. Modules usually have their own local shader directory.
*
* \return global shader path.
*/
static boost::filesystem::path getShaderPath();
/**
* The path to the globally installed modules. This does not respect any environment variables or config options! Use this only to search
* global modules. To get a list of all module search paths, including user defined ones, use getAllModulePaths().
*
* \return path to globally installed modules.
*/
static boost::filesystem::path getModulePath();
/**
* This returns a list of search paths for modules. This list is defined by the "modules.path" - option in walnut.cfg. 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();
/**
* The path to the OW libs. You normally should not need this.
*
* \return the path to the libs.
*/
static boost::filesystem::path getLibPath();
/**
* The path where shared files reside in.
*
* \return the shared files path.
*/
static boost::filesystem::path getSharePath();
protected:
private:
/**
* Application path. NOT the path of the binary. The binary path is m_appPath+"/walnut".
*/
boost::filesystem::path m_appPath;
/**
* The path where all the shared files reside in.
*/
boost::filesystem::path m_sharePath;
/**
* The path to the globally installed modules.
*/
boost::filesystem::path m_modulePath;
/**
* The path to the OW libs.
*/
boost::filesystem::path m_libPath;
/**
* Singleton instance of WPathHelper.
*/
static boost::shared_ptr< WPathHelper > m_instance;
};
#endif // WPATHHELPER_H
......@@ -24,4 +24,5 @@
#include "WPreferences.h"
boost::filesystem::path WPreferences::m_preferenceFile = boost::filesystem::path( "walnut.cfg" );
WProperties WPreferences::m_preferences( "Preferences" );
......@@ -29,9 +29,10 @@
#include <iostream>
#include <fstream>
#include <boost/filesystem.hpp>
#include <boost/program_options.hpp>
#include "../common/WIOTools.h"
#include "WIOTools.h"
#include "WProperties.h"
#include "WLogger.h"
......@@ -48,9 +49,25 @@ public:
* \return True if value could be found, false otherwise.
*/
template< typename T> static bool getPreference( std::string prefName, T* retVal );
/**
* Sets the configuration file globally.
*
* \param cfg the config file to use.
*/