Commit 176c991d authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - we are now using an own version of osgViewer::StatsHanlder allowing...

[CHANGE] - we are now using an own version of osgViewer::StatsHanlder allowing us to move fonts to an arbitrary place. Original Licence included.
parent 6ca2d2e2
......@@ -2,10 +2,11 @@
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} )
ADD_LIBRARY( OWge ${GE_SRC} ${GE_EXCEPTIONS_SRC} ${GE_ALGORITHMS_SRC} ${GE_EXT_SRC} )
TARGET_LINK_LIBRARIES( OWge OWcommon ${OPENGL_gl_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES} )
# Unit tests
......
......@@ -41,6 +41,7 @@
#include <osgDB/ReadFile>
#include "exceptions/WGEInitFailed.h"
#include "ext/OpenSceneGraph/WGEStatsHandler.h"
#include "WGE2DManipulator.h"
#include "WGEZoomTrackballManipulator.h"
#include "WPickHandler.h"
......@@ -81,7 +82,7 @@ WGEViewer::WGEViewer( std::string name, int x, int y,
}
// add the stats handler
m_View->addEventHandler( new osgViewer::StatsHandler );
m_View->addEventHandler( new WGEStatsHandler );
}
catch( ... )
{
......
This diff is collapsed.
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
......@@ -8,7 +8,3 @@ FOREACH( fname ${ALL_GE_FONTS} )
configure_file( ${fname} ${CMAKE_BINARY_DIR}/bin/${SHARED_FILES_RELATIVE}/fonts/ COPYONLY)
ENDFOREACH( fname )
# this is kind of a hack as the osgViewer::StatsHandler does not allow us to change the font path -> copy the file he needs to the destination he
# needs
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/fonts)
configure_file( ${OW_SOURCE_DIR}/graphicsEngine/fonts/arial.ttf ${CMAKE_BINARY_DIR}/bin/fonts/ COPYONLY)
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