00001 // Filename: pStatPianoRoll.h 00002 // Created by: drose (18Jul00) 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 PSTATPIANOROLL_H 00020 #define PSTATPIANOROLL_H 00021 00022 #include <pandatoolbase.h> 00023 00024 #include "pStatGraph.h" 00025 #include "pStatMonitor.h" 00026 #include "pStatClientData.h" 00027 00028 #include <luse.h> 00029 #include <vector_int.h> 00030 00031 #include "pmap.h" 00032 00033 class PStatFrameData; 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Class : PStatPianoRoll 00037 // Description : This is an abstract class that presents the interface 00038 // for drawing a piano-roll type chart: it shows the 00039 // time spent in each of a number of collectors as a 00040 // horizontal bar of color, with time as the horizontal 00041 // axis. 00042 // 00043 // This class just manages all the piano-roll logic; the 00044 // actual nuts and bolts of drawing pixels is left to a 00045 // user-derived class. 00046 //////////////////////////////////////////////////////////////////// 00047 class PStatPianoRoll : public PStatGraph { 00048 public: 00049 PStatPianoRoll(PStatMonitor *monitor, int thread_index, 00050 int xsize, int ysize); 00051 virtual ~PStatPianoRoll(); 00052 00053 void update(); 00054 00055 INLINE void set_horizontal_scale(float time_width); 00056 INLINE float get_horizontal_scale() const; 00057 00058 INLINE int timestamp_to_pixel(float time) const; 00059 INLINE float pixel_to_timestamp(int x) const; 00060 00061 protected: 00062 void changed_size(int xsize, int ysize); 00063 void force_redraw(); 00064 virtual void normal_guide_bars(); 00065 00066 virtual void begin_draw(); 00067 virtual void begin_row(int row); 00068 virtual void draw_bar(int row, int from_x, int to_x); 00069 virtual void end_row(int row); 00070 virtual void end_draw(); 00071 virtual void idle(); 00072 00073 private: 00074 void compute_page(const PStatFrameData &frame_data); 00075 00076 int _thread_index; 00077 00078 float _time_width; 00079 float _start_time; 00080 00081 class ColorBar { 00082 public: 00083 float _start; 00084 float _end; 00085 }; 00086 typedef pvector<ColorBar> ColorBars; 00087 00088 class BarBuilder { 00089 public: 00090 BarBuilder(); 00091 void clear(); 00092 void add_data_point(float time); 00093 void finish(float time); 00094 00095 bool _is_new; 00096 ColorBars _color_bars; 00097 }; 00098 00099 typedef pmap<int, BarBuilder> PageData; 00100 PageData _page_data; 00101 int _current_frame; 00102 }; 00103 00104 #include "pStatPianoRoll.I" 00105 00106 #endif