source: osgVisual/include/draw2D/visual_debug_hud.h @ 42

Last change on this file since 42 was 32, checked in by Torben Dannhauer, 15 years ago

Adding first version of osgVisual!!

File size: 3.7 KB
RevLine 
[32]1#pragma once
2/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 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{
40public:
41        /**
42         * \brief Empty Constructor.
43         *
44         */ 
45        visual_debug_hud(void);
46
47        /**
48         * \brief Empty Destructor.
49         *
50         */ 
51        ~visual_debug_hud(void);
52
53        /**
54         * \brief This function initializes the HUD.
55         *
56         * @param viewer_ : Pointer to the viewer instance to get screen size and screen width.
57         * @param rootNode_ : Pointer to the rootnode of the Scene, which should be a CSN
58         * @return : True if initialization was successful.
59         */ 
60        bool init(osgViewer::Viewer *viewer_, osg::CoordinateSystemNode* rootNode_ );
61
62        void shutdown();
63
64private:
65        /**
66         * \brief This function contains the code to display in the HUD.
67         *
68         *
69         * @return Pointer to the Geode which contains the HUD content.
70         */ 
71        osg::ref_ptr<osg::Geode> addContent();
72
73        /**
74         * This variable contains the width of the rendering screen during the initialization of this node.
75         */ 
76        int screen_width;
77
78        /**
79         * This variable contains the height of the rendering screen during the initialization of this node.
80         */ 
81        int screen_height;
82
83
84
85        class HudUpdateCallback : public osg::NodeCallback
86        {
87        public:
88                /**
89                 * \brief Constructor
90                 *
91                 * @param csn_ : Pointer to the Coordinate System Node. Necessary to extract lat, lon and height of the camera position.
92                 * @param sceneCamera_ : Pointer to the scene camera (undistorted camera, type PRE_RENDER)
93                 * @param sky_ : Pointer to the sky system.
94                 */ 
95                HudUpdateCallback(osg::CoordinateSystemNode* csn_, osg::Camera* sceneCamera_)
96                        : csn(csn_), sceneCamera(sceneCamera_) {};
97
98                /**
99                 * \brief This function is executed as callback during traversal. It updates values to display.
100                 *
101                 */ 
102                virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
103        private:
104                /**
105                 * Referenced pointer to the Coordinate System Node. Necessary to extract lat, lon and height of the camera position.
106                 */ 
107                osg::ref_ptr<osg::CoordinateSystemNode> csn;
108               
109                /**
110                 * Referenced pointer to the scene camera (undistorted camera, type PRE_RENDER)
111                 */ 
112                osg::ref_ptr<osg::Camera> sceneCamera;
113
114        };      // Nested class END
115
116        /**
117         * Referenced Pointer to the updatecallback, which is installed at this node.
118         */ 
119        osg::ref_ptr<HudUpdateCallback> updateCallback;
120
121        bool isInitialized;
122
123        osg::ref_ptr<osgText::Text> textLat, textLon, textAlt, textHat, textHot;
124
125        // Friend classes
126        friend class HudUpdateCallback; // Damit der Callback auf alle Member zugreifen kann wie wenn er in der Klasse sitzen würde.
127}; 
128
129}       // END NAMESPACE
Note: See TracBrowser for help on using the repository browser.