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