source: osgVisual/trunk/include/draw2D/visual_debug_hud.h @ 312

Last change on this file since 312 was 221, checked in by Torben Dannhauer, 14 years ago

Updated copyright NOTICE
(No code changes)

File size: 3.7 KB
Line 
1#pragma once
2/* -*-c++-*- osgVisual - Copyright (C) 2009-2011 Torben Dannhauer
3 *
4 * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under
5 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
6 * (at your option) any later version.  The full license is in LICENSE file
7 * included with this distribution, and on the openscenegraph.org website.
8 *
9 * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
10 * You have to aquire licenses for all used proprietary modules.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * OpenSceneGraph Public License for more details.
16*/
17
18#include <sstream>
19#include <iostream>
20#include <iomanip>
21
22#include <osg/NodeCallback>
23
24#include <visual_draw2D.h>
25#include <visual_util.h>
26
27
28namespace osgVisual
29{
30
31/**
32 * \brief This class prints debug information about LAT, LON, HAT, HOT on screen.
33 *
34 *
35 * @author Torben Dannhauer
36 * @date  Jan 2010
37 */ 
38class visual_debug_hud : public osg::Geode
39{
40        #include <leakDetection.h>
41public:
42        /**
43         * \brief Empty Constructor.
44         *
45         */ 
46        visual_debug_hud(void);
47
48        /**
49         * \brief Empty Destructor.
50         *
51         */ 
52        ~visual_debug_hud(void);
53
54        /**
55         * \brief This function initializes the HUD.
56         *
57         * @param viewer_ : Pointer to the viewer instance to get screen size and screen width.
58         * @param rootNode_ : Pointer to the rootnode of the Scene, which should be a CSN
59         * @return : True if initialization was successful.
60         */ 
61        bool init(osgViewer::Viewer *viewer_, osg::CoordinateSystemNode* rootNode_ );
62
63        void shutdown();
64
65private:
66        /**
67         * \brief This function contains the code to display in the HUD.
68         *
69         *
70         * @return Pointer to the Geode which contains the HUD content.
71         */ 
72        osg::ref_ptr<osg::Geode> addContent();
73
74        /**
75         * This variable contains the width of the rendering screen during the initialization of this node.
76         */ 
77        int screen_width;
78
79        /**
80         * This variable contains the height of the rendering screen during the initialization of this node.
81         */ 
82        int screen_height;
83
84
85
86        class HudUpdateCallback : public osg::NodeCallback
87        {
88        public:
89                /**
90                 * \brief Constructor
91                 *
92                 * @param csn_ : Pointer to the Coordinate System Node. Necessary to extract lat, lon and height of the camera position.
93                 * @param sceneCamera_ : Pointer to the scene camera (undistorted camera, type PRE_RENDER)
94                 * @param sky_ : Pointer to the sky system.
95                 */ 
96                HudUpdateCallback(osg::CoordinateSystemNode* csn_, osg::Camera* sceneCamera_)
97                        : csn(csn_), sceneCamera(sceneCamera_) {};
98
99                /**
100                 * \brief This function is executed as callback during traversal. It updates values to display.
101                 *
102                 */ 
103                virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
104        private:
105                /**
106                 * Referenced pointer to the Coordinate System Node. Necessary to extract lat, lon and height of the camera position.
107                 */ 
108                osg::ref_ptr<osg::CoordinateSystemNode> csn;
109               
110                /**
111                 * Referenced pointer to the scene camera (undistorted camera, type PRE_RENDER)
112                 */ 
113                osg::ref_ptr<osg::Camera> sceneCamera;
114
115        };      // Nested class END
116
117        /**
118         * Referenced Pointer to the updatecallback, which is installed at this node.
119         */ 
120        osg::ref_ptr<HudUpdateCallback> updateCallback;
121
122        bool isInitialized;
123
124        osg::ref_ptr<osgText::Text> textLat, textLon, textAlt, textHat, textHot;
125
126        // Friend classes
127        friend class HudUpdateCallback; // Damit der Callback auf alle Member zugreifen kann wie wenn er in der Klasse sitzen würde.
128}; 
129
130}       // END NAMESPACE
Note: See TracBrowser for help on using the repository browser.