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

[CHANGE] - removed own stathandler again as we use environment varibales now...

[CHANGE] - removed own stathandler again as we use environment varibales now to help OSG find fonts at OUR location.
parent b5dd590a
......@@ -2,11 +2,10 @@
ADD_SUBDIRECTORY( exceptions )
FILE( GLOB GE_EXCEPTIONS_SRC "exceptions/*.cpp" "exceptions/*.h" )
FILE( GLOB GE_EXT_SRC "ext/OpenSceneGraph/*.cpp" "ext/OpenSceneGraph/*.h" )
FILE( GLOB GE_ALGORITHMS_SRC "algorithms/*.cpp" "algorithms/*.h" )
FILE( GLOB GE_SRC "*.cpp" "*.h" )
ADD_LIBRARY( OWge ${GE_SRC} ${GE_EXCEPTIONS_SRC} ${GE_ALGORITHMS_SRC} ${GE_EXT_SRC} )
ADD_LIBRARY( OWge ${GE_SRC} ${GE_EXCEPTIONS_SRC} ${GE_ALGORITHMS_SRC} )
TARGET_LINK_LIBRARIES( OWge OWcommon ${OPENGL_gl_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES} )
# Unit tests
......
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include <stdlib.h>
#include <string>
#include <boost/filesystem.hpp>
......@@ -54,6 +56,9 @@ boost::shared_ptr< WGEResourceManager > WGEResourceManager::getResourceManager()
std::string WGEResourceManager::getDefaultFont()
{
// NOTE: as osgVoewer::StatsHandler uses hard coded font names, we need to ensure that our default font also is available as file "arial.ttf"
// in the fonts subdirectory. So, if you change the default font here please also ensure arial.ttf points to/is the same as the new default
// font.
return m_boldFont;
}
......@@ -74,9 +79,9 @@ std::string WGEResourceManager::getBoldFont()
void WGEResourceManager::setFontPath( std::string path )
{
// NOTE: the osgViewer::StatsHandler uses a hard coded font filename. :-(. To keep the look equal we use the same font as
// 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"
// NOTE: the osgViewer::StatsHandler uses a hard coded font filename. :-(. Fortunately OSG allows us to modify the search path using
// environment variables:
setenv( "OSGFILEPATH", path.c_str(), 1 );
namespace fs = boost::filesystem;
fs::path fontPath = path;
......
......@@ -41,7 +41,6 @@
#include <osgDB/ReadFile>
#include "exceptions/WGEInitFailed.h"
#include "ext/OpenSceneGraph/WGEStatsHandler.h"
#include "WGE2DManipulator.h"
#include "WGEZoomTrackballManipulator.h"
#include "WPickHandler.h"
......@@ -82,7 +81,7 @@ WGEViewer::WGEViewer( std::string name, int x, int y,
}
// add the stats handler
m_View->addEventHandler( new WGEStatsHandler );
m_View->addEventHandler( new osgViewer::StatsHandler );
}
catch( ... )
{
......
This diff is collapsed.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library 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
* OpenSceneGraph Public License for more details.
*/
#ifndef WGESTATSHANDLER_H
#define WGESTATSHANDLER_H
#include <osg/AnimationPath>
#include <osgText/Text>
#include <osgGA/GUIEventHandler>
#include <osgGA/AnimationPathManipulator>
#include <osgViewer/GraphicsWindow>
#include <osgViewer/Viewer>
#include <osgDB/fstream>
/**
* This class is an event handler managing render statistics. It basically is the osgViewer::StatsHandler but uses our font directory scheme.
*/
class WGEStatsHandler : public osgGA::GUIEventHandler
{
public:
WGEStatsHandler();
enum StatsType
{
NO_STATS = 0,
FRAME_RATE = 1,
VIEWER_STATS = 2,
CAMERA_SCENE_STATS = 3,
VIEWER_SCENE_STATS = 4,
LAST = 5
};
void setKeyEventTogglesOnScreenStats(int key) { _keyEventTogglesOnScreenStats = key; }
int getKeyEventTogglesOnScreenStats() const { return _keyEventTogglesOnScreenStats; }
void setKeyEventPrintsOutStats(int key) { _keyEventPrintsOutStats = key; }
int getKeyEventPrintsOutStats() const { return _keyEventPrintsOutStats; }
double getBlockMultiplier() const { return _blockMultiplier; }
void reset();
osg::Camera* getCamera() { return _camera.get(); }
const osg::Camera* getCamera() const { return _camera.get(); }
virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
/** Get the keyboard and mouse usage of this manipulator.*/
virtual void getUsage(osg::ApplicationUsage& usage) const;
protected:
void setUpHUDCamera(osgViewer::ViewerBase* viewer);
osg::Geometry* createBackgroundRectangle(const osg::Vec3& pos, const float width, const float height, osg::Vec4& color);
osg::Geometry* createGeometry(const osg::Vec3& pos, float height, const osg::Vec4& colour, unsigned int numBlocks);
osg::Geometry* createFrameMarkers(const osg::Vec3& pos, float height, const osg::Vec4& colour, unsigned int numBlocks);
osg::Geometry* createTick(const osg::Vec3& pos, float height, const osg::Vec4& colour, unsigned int numTicks);
osg::Node* createCameraTimeStats(const std::string& font, osg::Vec3& pos, float startBlocks, bool acquireGPUStats, float characterSize, osg::Stats* viewerStats, osg::Camera* camera);
void setUpScene(osgViewer::ViewerBase* viewer);
void updateThreadingModelText();
int _keyEventTogglesOnScreenStats;
int _keyEventPrintsOutStats;
int _statsType;
bool _initialized;
osg::ref_ptr<osg::Camera> _camera;
osg::ref_ptr<osg::Switch> _switch;
osgViewer::ViewerBase::ThreadingModel _threadingModel;
osg::ref_ptr<osgText::Text> _threadingModelText;
unsigned int _frameRateChildNum;
unsigned int _viewerChildNum;
unsigned int _cameraSceneChildNum;
unsigned int _viewerSceneChildNum;
unsigned int _numBlocks;
double _blockMultiplier;
float _statsWidth;
float _statsHeight;
};
#endif // WGESTATSHANDLER_H
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