DebugGraph.h (3781B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. 23 24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. 25 26 =========================================================================== 27 */ 28 #ifndef __DEBUGGRAPH_H__ 29 #define __DEBUGGRAPH_H__ 30 31 /* 32 ================================================================================================ 33 Contains the DebugGraph declaration. 34 ================================================================================================ 35 */ 36 37 /* 38 ================================================ 39 The *Debug Graph, idDebugGraph, contains graphing functionality common to many debug tools. 40 ================================================ 41 */ 42 class idDebugGraph { 43 public: 44 idDebugGraph( int numItems = 0 ); 45 46 void Enable( bool b ) { enable = b; } 47 48 // create a graph with the specified number of bars 49 void Init( int numBars ); 50 51 void AddGridLine( float value, const idVec4 & color ); 52 53 // sets a bar value, pass -1 to append an element 54 void SetValue( int b, float value, const idVec4 & color ); 55 float GetValue( int b ) { return bars[b].value; } 56 57 // sets a bar label 58 void SetLabel( int b, const char * text ); 59 60 enum fillMode_t { 61 GRAPH_LINE, // only draw a single top line for each bar 62 GRAPH_FILL, // fill the entire bar from the bottom (or left) 63 GRAPH_FILL_REVERSE, // fill the entire bar from the top (or right) 64 }; 65 void SetFillMode( fillMode_t m ) { mode = m; } 66 67 // render the graph sideways? 68 void SetSideways( bool s ) { sideways = s; } 69 70 // the background color is what's drawn between bars and in the empty space 71 void SetBackgroundColor( const idVec4 & color ) { bgColor = color; } 72 void SetLabelColor( const idVec4 & color ) { fontColor = color; } 73 74 // the border specifies the amount of space between bars as well as the amount of space around the entire graph 75 void SetBorder( float b ) { border = b; } 76 77 // set the screen position for the graph 78 void SetPosition( float x, float y, float w, float h ) { position.Set( x, y, w, h ); } 79 80 void Render( idRenderSystem * gui ); 81 82 private: 83 const class idMaterial * white; 84 const class idMaterial * font; 85 86 idVec4 bgColor; 87 idVec4 fontColor; 88 fillMode_t mode; 89 bool sideways; 90 float border; 91 idVec4 position; 92 bool enable; 93 94 struct graphPlot_t { 95 float value; 96 idVec4 color; 97 }; 98 idList< graphPlot_t > bars; 99 idList< graphPlot_t > grid; 100 idList< idStr > labels; 101 }; 102 103 #endif