Commit f5d89d9f authored by Alexander Wiebel's avatar Alexander Wiebel

[FIX] removed dependency from graphicsEngine to kernel

parent f0ab15e9
......@@ -14,5 +14,5 @@ TARGET_LINK_LIBRARIES( ge common ${OPENGL_gl_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES
# Unit tests
IF( OW_COMPILE_TESTS )
CXXTEST_ADD_TESTS_FROM_LIST( "${GE_SRC}" "ge;kernel" )
CXXTEST_ADD_TESTS_FROM_LIST( "${GE_SRC}" "ge;math" )
ENDIF( OW_COMPILE_TESTS )
\ No newline at end of file
......@@ -26,9 +26,8 @@
#include <boost/filesystem.hpp>
#include "../kernel/WKernel.h"
#include "WGEResourceManager.h"
#include "WGraphicsEngine.h"
// resource manager instance as singleton
boost::shared_ptr< WGEResourceManager > WGEResourceManager::m_instance = boost::shared_ptr< WGEResourceManager >();
......@@ -39,13 +38,8 @@ WGEResourceManager::WGEResourceManager()
// default font. Since Arial is underlying some weird licence we simply link/copy a font from the liberation package
// (https://fedorahosted.org/liberation-fonts/) to "arial.ttf"
// initialize members
//m_regularFont = WKernel::getAppPath() + "/fonts/LiberationMono-Regular.ttf";
//m_boldFont = WKernel::getAppPath() + "/fonts/LiberationMono-Bold.ttf";
//m_italicFont = WKernel::getAppPath() + "/fonts/LiberationMono-Italic.ttf";
namespace fs = boost::filesystem;
fs::path fontPath = fs::path( WKernel::getAppPath() ) / "fonts";
fs::path fontPath = WGraphicsEngine::getGraphicsEngine()->getFontPath();
m_regularFont = fs::path( fontPath / "LiberationMono-Regular.ttf" ).file_string();
m_boldFont = fs::path( fontPath / "LiberationMono-Bold.ttf" ).file_string();
m_italicFont = fs::path( fontPath / "LiberationMono-Italic.ttf" ).file_string();
......
......@@ -44,7 +44,6 @@
#include "WGE2DManipulator.h"
#include "WGEZoomTrackballManipulator.h"
#include "WPickHandler.h"
#include "../kernel/WKernel.h"
#include "WGEViewer.h"
......
......@@ -40,13 +40,13 @@
#include <osgViewer/View>
#include "../common/WThreadedRunner.h"
#include "../common/WColor.h"
#include "WGEGraphicsWindow.h"
#include "WGECamera.h"
#include "WPickHandler.h"
class WColor;
/**
* Class for managing one view to the scene. This includes viewport, camera and graphics context.
......
......@@ -39,7 +39,6 @@
#include "../common/WColor.h"
#include "../common/WLogger.h"
#include "../kernel/WKernel.h"
#include "../math/WPosition.h"
#include "WGEViewer.h"
#include "WGraphicsEngine.h"
......@@ -58,6 +57,7 @@ WGraphicsEngine::WGraphicsEngine():
m_rootNode = new WGEScene();
m_shaderPath = "";
m_fontPath = "";
// initialize OSG render window
m_viewer = osg::ref_ptr<osgViewer::CompositeViewer>( new osgViewer::CompositeViewer() );
......@@ -109,6 +109,16 @@ void WGraphicsEngine::setShaderPath( std::string path )
m_shaderPath = path;
}
std::string WGraphicsEngine::getFontPath() const
{
return m_fontPath;
}
void WGraphicsEngine::setFontPath( std::string path )
{
m_fontPath = path;
}
boost::shared_ptr<WGEViewer> WGraphicsEngine::createViewer( std::string name, osg::ref_ptr<WindowData> wdata, int x, int y,
int width, int height, WGECamera::ProjectionMode projectionMode,
WColor bgColor )
......
......@@ -43,6 +43,7 @@
#include <osgViewer/Viewer>
#include "../common/WThreadedRunner.h"
#include "../common/WColor.h"
#include "../math/WPosition.h"
#include "WGEGraphicsWindow.h"
#include "WGEScene.h"
......@@ -88,6 +89,20 @@ public:
*/
void setShaderPath( std::string path );
/**
* Return the path where the fonts are expected to be located.
*
* \return font path
*/
std::string getFontPath() const;
/**
* Sets the font path.
*
* \param path path to fonts.
*/
void setFontPath( std::string path );
/**
* Creates a new viewer. Does basic initialization and sets the default scene.
*
......@@ -169,6 +184,8 @@ protected:
*/
std::string m_shaderPath;
std::string m_fontPath; //!< Path where the fonts are expected.
/**
* OpenSceneGraph composite viewer. Contains all created osgViewer::Views.
*/
......
......@@ -28,7 +28,7 @@
#include <osg/LightModel>
#include "WROIBox.h"
#include "../kernel/WKernel.h"
#include "WGraphicsEngine.h"
size_t WROIBox::maxBoxId = 0;
......@@ -117,9 +117,9 @@ WROIBox::WROIBox( wmath::WPosition minPos, wmath::WPosition maxPos ) :
m_maxPos = maxPos;
// connect updateGFX with picking
WKernel* kernel = WKernel::getRunningKernel();
assert( kernel );
boost::shared_ptr< WGEViewer > viewer = kernel->getGraphicsEngine()->getViewerByName( "main" );
boost::shared_ptr< WGraphicsEngine > ge = WGraphicsEngine::getGraphicsEngine();
assert( ge );
boost::shared_ptr< WGEViewer > viewer = ge->getViewerByName( "main" );
assert( viewer );
m_pickHandler = viewer->getPickHandler();
m_pickHandler->getPickSignal()->connect( boost::bind( &WROIBox::updateGFX, this, _1 ) );
......@@ -166,7 +166,8 @@ WROIBox::WROIBox( wmath::WPosition minPos, wmath::WPosition maxPos ) :
lightModel->setTwoSided( true );
state->setAttributeAndModes( lightModel.get(), osg::StateAttribute::ON );
state->setMode( GL_BLEND, osg::StateAttribute::ON );
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->addChild( m_geode );
assert( WGraphicsEngine::getGraphicsEngine() );
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( m_geode );
}
wmath::WPosition WROIBox::getMinPos() const
......
......@@ -47,7 +47,6 @@ public:
// WLogger logger;
// boost::shared_ptr< WGUI > gui = boost::shared_ptr< WGUI >( new WQt4Gui( 0, 0 ) );
// boost::shared_ptr< WGraphicsEngine > ge = boost::shared_ptr< WGraphicsEngine >( new WGraphicsEngine );
// WKernel kernel( ge, gui );
// TS_ASSERT_THROWS_NOTHING( WROIBox( minPos, maxPos ) );
}
};
......
......@@ -65,7 +65,7 @@ std::string WKernel::m_shaderPath = std::string();
/**
* Define app path.
*/
std::string WKernel::m_AppPath = std::string();
std::string WKernel::m_appPath = std::string();
WKernel::WKernel( boost::shared_ptr< WGraphicsEngine > ge, boost::shared_ptr< WGUI > gui ):
WThreadedRunner()
......@@ -102,7 +102,8 @@ void WKernel::init()
"Root module container in Kernel." ) );
// initialize graphics engine, or, at least set some stuff
m_graphicsEngine->setShaderPath( WKernel::m_shaderPath );
m_graphicsEngine->setShaderPath( m_shaderPath );
m_graphicsEngine->setShaderPath( m_appPath + "/fonts/" );
// load all modules
m_moduleFactory->load();
......@@ -180,12 +181,12 @@ void WKernel::threadMain()
void WKernel::findAppPath()
{
// only get the path if not already done
if ( m_AppPath != "" )
if ( m_appPath != "" )
{
return;
}
if ( m_AppPath != "" )
if ( m_appPath != "" )
{
return;
}
......@@ -194,8 +195,8 @@ void WKernel::findAppPath()
namespace fs = boost::filesystem;
fs::path currentDir( fs::initial_path<fs::path>() );
m_AppPath = currentDir.file_string();
// std::cout << "Set app path to " << m_AppPath << std::endl;
m_appPath = currentDir.file_string();
// std::cout << "Set app path to " << m_appPath << std::endl;
m_shaderPath = fs::path( currentDir / "shaders" ).file_string();
// std::cout << "Set shader path to " << m_shaderPath << std::endl;
......@@ -224,7 +225,7 @@ boost::shared_ptr< WModule > WKernel::applyModule( boost::shared_ptr< WModule >
std::string WKernel::getAppPath()
{
findAppPath();
return WKernel::m_AppPath;
return WKernel::m_appPath;
}
std::string WKernel::getShaderPath()
......
......@@ -194,7 +194,7 @@ private:
/**
* the location of the openwalnut executable
*/
static std::string m_AppPath;
static std::string m_appPath;
/**
* the location of the openwalnut executable
......
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