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
28class 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 */
39public:
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);
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
75protected:
76 class ColorData {
77 public:
78 unsigned short _collector_index;
79 unsigned short _i;
80 double _net_value;
81 };
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
112private:
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
120protected:
121 int _thread_index;
122
123private:
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
This is an abstract base class for several different kinds of graphs that have a few things in common...
Definition pStatGraph.h:33
This is an abstract class that presents the interface to any number of different front-ends for the s...
This is an abstract class that presents the interface for drawing a basic strip-chart,...
std::string get_title_text()
Returns the text suitable for the title label on the top line.
void set_scroll_mode(bool scroll_mode)
Changes the scroll_mode flag.
bool is_title_unknown() const
Returns true if get_title_text() has never yet returned an answer, false if it has.
double get_horizontal_scale() const
Returns the amount of total time the width of the horizontal axis represents.
double get_vertical_scale() const
Returns total value the height of the vertical axis represents.
int height_to_pixel(double value) const
Converts a value (i.e.
void set_auto_vertical_scale()
Sets the vertical scale to make all the data visible.
void set_average_mode(bool average_mode)
Changes the average_mode flag.
void set_horizontal_scale(double time_width)
Changes the amount of time the width of the horizontal axis represents.
bool get_scroll_mode() const
Returns the current state of the scroll_mode flag.
void update()
Updates the chart with the latest data.
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...
std::string get_total_text()
Returns the text suitable for the total label above the graph.
void set_collector_index(int collector_index)
Changes the collector represented by this strip chart.
double pixel_to_timestamp(int x) const
Converts a horizontal pixel offset to a timestamp.
void set_default_vertical_scale()
Sets the vertical scale according to the suggested scale of the base collector, if any,...
void new_data(int frame_number)
Indicates that new data has become available.
int timestamp_to_pixel(double time) const
Converts a timestamp to a horizontal pixel offset.
bool get_average_mode() const
Returns the current state of the average_mode flag.
PStatView & get_view() const
Returns the View this chart represents.
double pixel_to_height(int y) const
Converts a vertical pixel offset to a value (a "height" in the strip chart).
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.
int get_collector_index() const
Returns the particular collector whose data this strip chart reflects.
void set_vertical_scale(double value_height)
Changes the value the height of the vertical axis represents.
A View boils down the frame data to a linear list of times spent in a number of different Collectors,...
Definition pStatView.h:31
This is our own Panda specialization on the default STL map.
Definition pmap.h:49
This is our own Panda specialization on the default STL vector.
Definition pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.