DebugGraph.h 3.7 KB

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