Panda3D

Loading...
Searching...
No Matches
pStatStripChart.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 pStatStripChart.h
10 * @author drose
11 * @date 2000-07-15
12 */
13
14#ifndef PSTATSTRIPCHART_H
15#define PSTATSTRIPCHART_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 PStatView;
29
30/**
31 * This is an abstract class that presents the interface for drawing a basic
32 * strip-chart, showing the relative value over an interval of time for
33 * several different collectors, differentiated by bands of color.
34 *
35 * This class just manages all the strip-chart logic; the actual nuts and
36 * bolts of drawing pixels is left to a user-derived class.
37 */
38 class PStatStripChart : public PStatGraph {
39 public:
40 PStatStripChart(PStatMonitor *monitor, PStatView &view,
41 int thread_index, int collector_index, int xsize, int ysize);
42 virtual ~PStatStripChart();
43
44 void new_data(int frame_number);
45 void update();
46 bool first_data() const;
47
48 INLINE PStatView &get_view() const;
49 INLINE int get_collector_index() const;
50 void set_collector_index(int collector_index);
51
52 INLINE void set_horizontal_scale(double time_width);
53 INLINE double get_horizontal_scale() const;
54 INLINE void set_vertical_scale(double value_height);
55 void set_default_vertical_scale();
56 void set_auto_vertical_scale();
57 INLINE double get_vertical_scale() const;
58
59 INLINE void set_scroll_mode(bool scroll_mode);
60 INLINE bool get_scroll_mode() const;
61
62 INLINE void set_average_mode(bool average_mode);
63 INLINE bool get_average_mode() const;
64
65 int get_collector_under_pixel(int xpoint, int ypoint);
66 INLINE int timestamp_to_pixel(double time) const;
67 INLINE double pixel_to_timestamp(int x) const;
68 INLINE int height_to_pixel(double value) const;
69 INLINE double pixel_to_height(int y) const;
70
71 INLINE bool is_title_unknown() const;
72 std::string get_title_text();
73 std::string get_total_text();
74
75 protected:
76 class ColorData {
77 public:
78 unsigned short _collector_index;
79 unsigned short _i;
80 double _net_value;
81 };
82 typedef pvector<ColorData> FrameData;
83 typedef pmap<int, FrameData> Data;
84
85 static void accumulate_frame_data(FrameData &fdata,
86 const FrameData &additional, double weight);
87 static void scale_frame_data(FrameData &fdata, double factor);
88
89 const FrameData &get_frame_data(int frame_number);
90 void compute_average_pixel_data(PStatStripChart::FrameData &result,
91 int &then_i, int &now_i, double now);
92 double get_net_value(int frame_number) const;
93 double get_average_net_value() const;
94
95 void changed_size(int xsize, int ysize);
96 void force_redraw();
97 void force_reset();
98 virtual void update_labels();
99 virtual void normal_guide_bars();
100
101 virtual void clear_region();
102 virtual void copy_region(int start_x, int end_x, int dest_x);
103 virtual void begin_draw(int from_x, int to_x);
104 virtual void draw_slice(int x, int w, const FrameData &fdata);
105 virtual void draw_empty(int x, int w);
106 virtual void draw_cursor(int x);
107 virtual void end_draw(int from_x, int to_x);
108 virtual void idle();
109
110 INLINE bool is_label_used(int collector_index) const;
111
112 private:
113 void draw_frames(int first_frame, int last_frame);
114 void draw_pixels(int first_pixel, int last_pixel);
115
116 void clear_label_usage();
117 void dec_label_usage(const FrameData &fdata);
118 void inc_label_usage(const FrameData &fdata);
119
120 protected:
121 int _thread_index;
122
123 private:
124 PStatView &_view;
125 int _collector_index;
126 bool _scroll_mode;
127 bool _average_mode;
128
129 Data _data;
130
131 int _next_frame;
132 bool _first_data;
133 int _cursor_pixel;
134
135 int _level_index;
136
137 double _time_width;
138 double _start_time;
139 double _value_height;
140 bool _title_unknown;
141
142 typedef vector_int LabelUsage;
143 LabelUsage _label_usage;
144};
145
146#include "pStatStripChart.I"
147
148#endif
PStatMonitor
This is an abstract class that presents the interface to any number of different front-ends for the s...
Definition pStatMonitor.h:39
PStatStripChart::get_title_text
std::string get_title_text()
Returns the text suitable for the title label on the top line.
Definition pStatStripChart.cxx:255
PStatStripChart::set_scroll_mode
void set_scroll_mode(bool scroll_mode)
Changes the scroll_mode flag.
Definition pStatStripChart.I:82
PStatStripChart::is_title_unknown
bool is_title_unknown() const
Returns true if get_title_text() has never yet returned an answer, false if it has.
Definition pStatStripChart.I:164
PStatStripChart::get_horizontal_scale
double get_horizontal_scale() const
Returns the amount of total time the width of the horizontal axis represents.
Definition pStatStripChart.I:51
PStatStripChart::get_vertical_scale
double get_vertical_scale() const
Returns total value the height of the vertical axis represents.
Definition pStatStripChart.I:72
PStatStripChart::height_to_pixel
int height_to_pixel(double value) const
Converts a value (i.e.
Definition pStatStripChart.I:146
PStatStripChart::set_auto_vertical_scale
void set_auto_vertical_scale()
Sets the vertical scale to make all the data visible.
Definition pStatStripChart.cxx:170
PStatStripChart::set_average_mode
void set_average_mode(bool average_mode)
Changes the average_mode flag.
Definition pStatStripChart.I:107
PStatStripChart::set_horizontal_scale
void set_horizontal_scale(double time_width)
Changes the amount of time the width of the horizontal axis represents.
Definition pStatStripChart.I:35
PStatStripChart::get_scroll_mode
bool get_scroll_mode() const
Returns the current state of the scroll_mode flag.
Definition pStatStripChart.I:96
PStatStripChart::update
void update()
Updates the chart with the latest data.
Definition pStatStripChart.cxx:84
PStatStripChart::get_collector_under_pixel
int get_collector_under_pixel(int xpoint, int ypoint)
Return the collector index associated with the particular band of color at the indicated pixel locati...
Definition pStatStripChart.cxx:201
PStatStripChart::get_total_text
std::string get_total_text()
Returns the text suitable for the total label above the graph.
Definition pStatStripChart.cxx:290
PStatStripChart::set_collector_index
void set_collector_index(int collector_index)
Changes the collector represented by this strip chart.
Definition pStatStripChart.cxx:136
PStatStripChart::pixel_to_timestamp
double pixel_to_timestamp(int x) const
Converts a horizontal pixel offset to a timestamp.
Definition pStatStripChart.I:137
PStatStripChart::set_default_vertical_scale
void set_default_vertical_scale()
Sets the vertical scale according to the suggested scale of the base collector, if any,...
Definition pStatStripChart.cxx:152
PStatStripChart::new_data
void new_data(int frame_number)
Indicates that new data has become available.
Definition pStatStripChart.cxx:73
PStatStripChart::timestamp_to_pixel
int timestamp_to_pixel(double time) const
Converts a timestamp to a horizontal pixel offset.
Definition pStatStripChart.I:129
PStatStripChart::get_average_mode
bool get_average_mode() const
Returns the current state of the average_mode flag.
Definition pStatStripChart.I:121
PStatStripChart::get_view
PStatView & get_view() const
Returns the View this chart represents.
Definition pStatStripChart.I:18
PStatStripChart::pixel_to_height
double pixel_to_height(int y) const
Converts a vertical pixel offset to a value (a "height" in the strip chart).
Definition pStatStripChart.I:155
PStatStripChart::first_data
bool first_data() const
Returns true if the chart has seen its first data appear on it, false if it is still a virgin chart.
Definition pStatStripChart.cxx:127
PStatStripChart::get_collector_index
int get_collector_index() const
Returns the particular collector whose data this strip chart reflects.
Definition pStatStripChart.I:26
PStatStripChart::set_vertical_scale
void set_vertical_scale(double value_height)
Changes the value the height of the vertical axis represents.
Definition pStatStripChart.I:60
PStatView
A View boils down the frame data to a linear list of times spent in a number of different Collectors,...
Definition pStatView.h:31
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatClientData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatGraph.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatMonitor.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatStripChart.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandatoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
vector_int.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.