Panda3D
pStatPianoRoll.h
1 // Filename: pStatPianoRoll.h
2 // Created by: drose (18Jul00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef PSTATPIANOROLL_H
16 #define PSTATPIANOROLL_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "pStatGraph.h"
21 #include "pStatMonitor.h"
22 #include "pStatClientData.h"
23 
24 #include "luse.h"
25 #include "vector_int.h"
26 
27 #include "pmap.h"
28 
29 class PStatFrameData;
30 
31 ////////////////////////////////////////////////////////////////////
32 // Class : PStatPianoRoll
33 // Description : This is an abstract class that presents the interface
34 // for drawing a piano-roll type chart: it shows the
35 // time spent in each of a number of collectors as a
36 // horizontal bar of color, with time as the horizontal
37 // axis.
38 //
39 // This class just manages all the piano-roll logic; the
40 // actual nuts and bolts of drawing pixels is left to a
41 // user-derived class.
42 ////////////////////////////////////////////////////////////////////
43 class PStatPianoRoll : public PStatGraph {
44 public:
45  PStatPianoRoll(PStatMonitor *monitor, int thread_index,
46  int xsize, int ysize);
47  virtual ~PStatPianoRoll();
48 
49  void update();
50 
51  INLINE void set_horizontal_scale(double time_width);
52  INLINE double get_horizontal_scale() const;
53 
54  INLINE int timestamp_to_pixel(double time) const;
55  INLINE double pixel_to_timestamp(int x) const;
56  INLINE int height_to_pixel(double value) const;
57  INLINE double pixel_to_height(int y) const;
58 
59 protected:
60  void changed_size(int xsize, int ysize);
61  void force_redraw();
62  virtual void normal_guide_bars();
63 
64  virtual void begin_draw();
65  virtual void begin_row(int row);
66  virtual void draw_bar(int row, int from_x, int to_x);
67  virtual void end_row(int row);
68  virtual void end_draw();
69  virtual void idle();
70 
71 private:
72  void compute_page(const PStatFrameData &frame_data);
73 
74 protected:
75  int _thread_index;
76 
77 private:
78  double _time_width;
79  double _start_time;
80 
81  class ColorBar {
82  public:
83  double _start;
84  double _end;
85  };
87 
88  class BarBuilder {
89  public:
90  BarBuilder();
91  void clear();
92  void add_data_point(double time, bool is_start);
93  void finish(double time);
94 
95  bool _is_new;
96  ColorBars _color_bars;
97  };
98 
100  PageData _page_data;
101  int _current_frame;
102 };
103 
104 #include "pStatPianoRoll.I"
105 
106 #endif
int timestamp_to_pixel(double time) const
Converts a timestamp to a horizontal pixel offset.
double get_horizontal_scale() const
Returns the amount of total time the width of the horizontal axis represents.
This is an abstract class that presents the interface for drawing a piano-roll type chart: it shows t...
This is an abstract base class for several different kinds of graphs that have a few things in common...
Definition: pStatGraph.h:36
void update()
Updates the chart with the latest data.
This is an abstract class that presents the interface to any number of different front-ends for the s...
Definition: pStatMonitor.h:43
int height_to_pixel(double value) const
Converts a value (i.e.
Contains the raw timing and level data for a single frame.
double pixel_to_timestamp(int x) const
Converts a horizontal pixel offset to a timestamp.
void set_horizontal_scale(double time_width)
Changes the amount of time the width of the horizontal axis represents.
double pixel_to_height(int y) const
Converts a horizontal pixel offset to a value (a "height" in the strip chart).