Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/pstatserver/pStatGraph.h

Go to the documentation of this file.
00001 // Filename: pStatGraph.h
00002 // Created by:  drose (19Jul00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef PSTATGRAPH_H
00020 #define PSTATGRAPH_H
00021 
00022 #include <pandatoolbase.h>
00023 
00024 #include "pStatMonitor.h"
00025 #include "pStatClientData.h"
00026 
00027 #include <luse.h>
00028 #include <vector_int.h>
00029 
00030 #include "pmap.h"
00031 
00032 class PStatView;
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //       Class : PStatGraph
00036 // Description : This is an abstract base class for several different
00037 //               kinds of graphs that have a few things in common,
00038 //               like labels and guide bars.
00039 ////////////////////////////////////////////////////////////////////
00040 class PStatGraph {
00041 public:
00042   PStatGraph(PStatMonitor *monitor, int xsize, int ysize);
00043   virtual ~PStatGraph();
00044 
00045   INLINE PStatMonitor *get_monitor() const;
00046 
00047   INLINE int get_num_labels() const;
00048   INLINE int get_label_collector(int n) const;
00049   INLINE string get_label_name(int n) const;
00050   INLINE RGBColorf get_label_color(int n) const;
00051 
00052   INLINE void set_target_frame_rate(float frame_rate);
00053   INLINE float get_target_frame_rate() const;
00054 
00055   INLINE int get_xsize() const;
00056   INLINE int get_ysize() const;
00057 
00058   class GuideBar {
00059   public:
00060     GuideBar(float height, const string &label, bool is_target);
00061     GuideBar(const GuideBar &copy);
00062 
00063     float _height;
00064     string _label;
00065     bool _is_target;
00066   };
00067 
00068   enum GuideBarUnits {
00069     GBU_hz         = 0x0001,
00070     GBU_ms         = 0x0002,
00071     GBU_named      = 0x0004,
00072     GBU_show_units = 0x0008,
00073   };
00074 
00075   int get_num_guide_bars() const;
00076   const GuideBar &get_guide_bar(int n) const;
00077 
00078   INLINE void set_guide_bar_units(int unit_mask);
00079   INLINE int get_guide_bar_units() const;
00080   INLINE void set_guide_bar_unit_name(const string &unit_name);
00081   INLINE const string &get_guide_bar_unit_name() const;
00082 
00083   static string format_number(float value);
00084   static string format_number(float value, int guide_bar_units,
00085                               const string &unit_name = string());
00086 
00087 protected:
00088   virtual void normal_guide_bars()=0;
00089   void update_guide_bars(int num_bars, float scale);
00090   GuideBar make_guide_bar(float value) const;
00091 
00092   bool _labels_changed;
00093   bool _guide_bars_changed;
00094 
00095   PT(PStatMonitor) _monitor;
00096 
00097   float _target_frame_rate;
00098 
00099   int _xsize;
00100   int _ysize;
00101 
00102   // Table of the collectors that should be drawn as labels, in order
00103   // from bottom to top.
00104   typedef vector_int Labels;
00105   Labels _labels;
00106 
00107   typedef pvector<GuideBar> GuideBars;
00108   GuideBars _guide_bars;
00109   int _guide_bar_units;
00110   string _unit_name;
00111 };
00112 
00113 #include "pStatGraph.I"
00114 
00115 #endif

Generated on Fri May 2 03:21:34 2003 for Panda-Tool by doxygen1.3