Panda3D
|
00001 // Filename: pStatPianoRoll.h 00002 // Created by: drose (18Jul00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef PSTATPIANOROLL_H 00016 #define PSTATPIANOROLL_H 00017 00018 #include "pandatoolbase.h" 00019 00020 #include "pStatGraph.h" 00021 #include "pStatMonitor.h" 00022 #include "pStatClientData.h" 00023 00024 #include "luse.h" 00025 #include "vector_int.h" 00026 00027 #include "pmap.h" 00028 00029 class PStatFrameData; 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Class : PStatPianoRoll 00033 // Description : This is an abstract class that presents the interface 00034 // for drawing a piano-roll type chart: it shows the 00035 // time spent in each of a number of collectors as a 00036 // horizontal bar of color, with time as the horizontal 00037 // axis. 00038 // 00039 // This class just manages all the piano-roll logic; the 00040 // actual nuts and bolts of drawing pixels is left to a 00041 // user-derived class. 00042 //////////////////////////////////////////////////////////////////// 00043 class PStatPianoRoll : public PStatGraph { 00044 public: 00045 PStatPianoRoll(PStatMonitor *monitor, int thread_index, 00046 int xsize, int ysize); 00047 virtual ~PStatPianoRoll(); 00048 00049 void update(); 00050 00051 INLINE void set_horizontal_scale(double time_width); 00052 INLINE double get_horizontal_scale() const; 00053 00054 INLINE int timestamp_to_pixel(double time) const; 00055 INLINE double pixel_to_timestamp(int x) const; 00056 INLINE int height_to_pixel(double value) const; 00057 INLINE double pixel_to_height(int y) const; 00058 00059 protected: 00060 void changed_size(int xsize, int ysize); 00061 void force_redraw(); 00062 virtual void normal_guide_bars(); 00063 00064 virtual void begin_draw(); 00065 virtual void begin_row(int row); 00066 virtual void draw_bar(int row, int from_x, int to_x); 00067 virtual void end_row(int row); 00068 virtual void end_draw(); 00069 virtual void idle(); 00070 00071 private: 00072 void compute_page(const PStatFrameData &frame_data); 00073 00074 protected: 00075 int _thread_index; 00076 00077 private: 00078 double _time_width; 00079 double _start_time; 00080 00081 class ColorBar { 00082 public: 00083 double _start; 00084 double _end; 00085 }; 00086 typedef pvector<ColorBar> ColorBars; 00087 00088 class BarBuilder { 00089 public: 00090 BarBuilder(); 00091 void clear(); 00092 void add_data_point(double time, bool is_start); 00093 void finish(double 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