Panda3D
gtkStatsStripChart.cxx
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 gtkStatsStripChart.cxx
10  * @author drose
11  * @date 2006-01-16
12  */
13 
14 #include "gtkStatsStripChart.h"
15 #include "gtkStatsMonitor.h"
16 #include "pStatCollectorDef.h"
17 #include "numeric_types.h"
18 
19 static const int default_strip_chart_width = 400;
20 static const int default_strip_chart_height = 100;
21 
22 /**
23  *
24  */
25 GtkStatsStripChart::
26 GtkStatsStripChart(GtkStatsMonitor *monitor, int thread_index,
27  int collector_index, bool show_level) :
28  PStatStripChart(monitor,
29  show_level ? monitor->get_level_view(collector_index, thread_index) : monitor->get_view(thread_index),
30  thread_index,
31  collector_index,
32  default_strip_chart_width,
33  default_strip_chart_height),
34  GtkStatsGraph(monitor)
35 {
36  _brush_origin = 0;
37 
38  if (show_level) {
39  // If it's a level-type graph, show the appropriate units.
40  if (_unit_name.empty()) {
41  set_guide_bar_units(GBU_named);
42  } else {
43  set_guide_bar_units(GBU_named | GBU_show_units);
44  }
45 
46  } else {
47  // If it's a time-type graph, show the msHz units.
48  set_guide_bar_units(get_guide_bar_units() | GBU_show_units);
49  }
50 
51  // Put some stuff on top of the graph.
52  _top_hbox = gtk_hbox_new(FALSE, 0);
53  gtk_box_pack_start(GTK_BOX(_graph_vbox), _top_hbox,
54  FALSE, FALSE, 0);
55 
56  _smooth_check_box = gtk_check_button_new_with_label("Smooth");
57  g_signal_connect(G_OBJECT(_smooth_check_box), "toggled",
58  G_CALLBACK(toggled_callback), this);
59 
60  _total_label = gtk_label_new("");
61  gtk_box_pack_start(GTK_BOX(_top_hbox), _smooth_check_box,
62  FALSE, FALSE, 0);
63  gtk_box_pack_end(GTK_BOX(_top_hbox), _total_label,
64  FALSE, FALSE, 0);
65 
66  // Add a DrawingArea widget to the right of the graph, to display all of the
67  // scale units.
68  _scale_area = gtk_drawing_area_new();
69  g_signal_connect(G_OBJECT(_scale_area), "expose_event",
70  G_CALLBACK(expose_event_callback), this);
71  gtk_box_pack_start(GTK_BOX(_graph_hbox), _scale_area,
72  FALSE, FALSE, 0);
73  gtk_widget_set_size_request(_scale_area, 40, 0);
74 
75 
76  gtk_widget_set_size_request(_graph_window, default_strip_chart_width,
77  default_strip_chart_height);
78 
79  gtk_widget_show_all(_window);
80  gtk_widget_show(_window);
81 
82  // Allow the window to be resized as small as the user likes. We have to do
83  // this after the window has been shown; otherwise, it will affect the
84  // window's initial size.
85  gtk_widget_set_size_request(_window, 0, 0);
86 
87  clear_region();
88 }
89 
90 /**
91  *
92  */
93 GtkStatsStripChart::
94 ~GtkStatsStripChart() {
95 }
96 
97 /**
98  * Called whenever a new Collector definition is received from the client.
99  */
101 new_collector(int collector_index) {
102  GtkStatsGraph::new_collector(collector_index);
103 }
104 
105 /**
106  * Called as each frame's data is made available. There is no gurantee the
107  * frames will arrive in order, or that all of them will arrive at all. The
108  * monitor should be prepared to accept frames received out-of-order or
109  * missing.
110  */
112 new_data(int thread_index, int frame_number) {
113  if (is_title_unknown()) {
114  std::string window_title = get_title_text();
115  if (!is_title_unknown()) {
116  gtk_window_set_title(GTK_WINDOW(_window), window_title.c_str());
117  }
118  }
119 
120  if (!_pause) {
121  update();
122 
123  std::string text = format_number(get_average_net_value(), get_guide_bar_units(), get_guide_bar_unit_name());
124  if (_net_value_text != text) {
125  _net_value_text = text;
126  gtk_label_set_text(GTK_LABEL(_total_label), _net_value_text.c_str());
127  }
128  }
129 }
130 
131 /**
132  * Called when it is necessary to redraw the entire graph.
133  */
136  PStatStripChart::force_redraw();
137 }
138 
139 /**
140  * Called when the user has resized the window, forcing a resize of the graph.
141  */
143 changed_graph_size(int graph_xsize, int graph_ysize) {
144  PStatStripChart::changed_size(graph_xsize, graph_ysize);
145 }
146 
147 /**
148  * Called when the user selects a new time units from the monitor pulldown
149  * menu, this should adjust the units for the graph to the indicated mask if
150  * it is a time-based graph.
151  */
153 set_time_units(int unit_mask) {
154  int old_unit_mask = get_guide_bar_units();
155  if ((old_unit_mask & (GBU_hz | GBU_ms)) != 0) {
156  unit_mask = unit_mask & (GBU_hz | GBU_ms);
157  unit_mask |= (old_unit_mask & GBU_show_units);
158  set_guide_bar_units(unit_mask);
159 
160  gtk_widget_queue_draw(_scale_area);
161  }
162 }
163 
164 /**
165  * Called when the user selects a new scroll speed from the monitor pulldown
166  * menu, this should adjust the speed for the graph to the indicated value.
167  */
169 set_scroll_speed(double scroll_speed) {
170  // The speed factor indicates chart widths per minute.
171  if (scroll_speed != 0.0f) {
172  set_horizontal_scale(60.0f / scroll_speed);
173  }
174 }
175 
176 /**
177  * Called when the user single-clicks on a label.
178  */
180 clicked_label(int collector_index) {
181  if (collector_index < 0) {
182  // Clicking on whitespace in the graph is the same as clicking on the top
183  // label.
184  collector_index = get_collector_index();
185  }
186 
187  if (collector_index == get_collector_index() && collector_index != 0) {
188  // Clicking on the top label means to go up to the parent level.
189  const PStatClientData *client_data =
190  GtkStatsGraph::_monitor->get_client_data();
191  if (client_data->has_collector(collector_index)) {
192  const PStatCollectorDef &def =
193  client_data->get_collector_def(collector_index);
194  if (def._parent_index == 0 && get_view().get_show_level()) {
195  // Unless the parent is "Frame", and we're not a time collector.
196  } else {
197  set_collector_index(def._parent_index);
198  }
199  }
200 
201  } else {
202  // Clicking on any other label means to focus on that.
203  set_collector_index(collector_index);
204  }
205 }
206 
207 /**
208  * Changes the value the height of the vertical axis represents. This may
209  * force a redraw.
210  */
212 set_vertical_scale(double value_height) {
214 
215  gtk_widget_queue_draw(_graph_window);
216  gtk_widget_queue_draw(_scale_area);
217 }
218 
219 /**
220  * Resets the list of labels.
221  */
222 void GtkStatsStripChart::
223 update_labels() {
224  PStatStripChart::update_labels();
225 
226  _label_stack.clear_labels();
227  for (int i = 0; i < get_num_labels(); i++) {
228  _label_stack.add_label(GtkStatsGraph::_monitor, this, _thread_index,
229  get_label_collector(i), false);
230  }
231  _labels_changed = false;
232 }
233 
234 /**
235  * Erases the chart area.
236  */
237 void GtkStatsStripChart::
238 clear_region() {
239  gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_white);
240  gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, 0, 0,
241  get_xsize(), get_ysize());
242 }
243 
244 /**
245  * Should be overridden by the user class to copy a region of the chart from
246  * one part of the chart to another. This is used to implement scrolling.
247  */
248 void GtkStatsStripChart::
249 copy_region(int start_x, int end_x, int dest_x) {
250  gdk_draw_drawable(_pixmap, _pixmap_gc, _pixmap,
251  start_x, 0, dest_x, 0,
252  end_x - start_x, get_ysize());
253 
254  // Also shift the brush origin over, so we still get proper dithering.
255  _brush_origin += (dest_x - start_x);
256  // SetBrushOrgEx(_bitmap_dc, _brush_origin, 0, NULL);
257 
258  GdkRectangle rect = {
259  dest_x, 0, end_x - start_x, get_ysize()
260  };
261  gdk_window_invalidate_rect(_graph_window->window, &rect, FALSE);
262 }
263 
264 /**
265  * Draws a single vertical slice of the strip chart, at the given pixel
266  * position, and corresponding to the indicated level data.
267  */
268 void GtkStatsStripChart::
269 draw_slice(int x, int w, const PStatStripChart::FrameData &fdata) {
270  // Start by clearing the band first.
271  gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_white);
272  gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, x, 0,
273  w + 1, get_ysize());
274 
275  double overall_time = 0.0;
276  int y = get_ysize();
277 
278  FrameData::const_iterator fi;
279  for (fi = fdata.begin(); fi != fdata.end(); ++fi) {
280  const ColorData &cd = (*fi);
281  overall_time += cd._net_value;
282  GdkGC *gc = get_collector_gc(cd._collector_index);
283 
284  if (overall_time > get_vertical_scale()) {
285  // Off the top. Go ahead and clamp it by hand, in case it's so far off
286  // the top we'd overflow the 16-bit pixel value.
287  gdk_draw_rectangle(_pixmap, gc, TRUE, x, 0, w, y);
288  // And we can consider ourselves done now.
289  return;
290  }
291 
292  int top_y = height_to_pixel(overall_time);
293  gdk_draw_rectangle(_pixmap, gc, TRUE, x, top_y, w, y - top_y);
294  y = top_y;
295  }
296 }
297 
298 /**
299  * Draws a single vertical slice of background color.
300  */
301 void GtkStatsStripChart::
302 draw_empty(int x, int w) {
303  gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_white);
304  gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, x, 0,
305  w + 1, get_ysize());
306 }
307 
308 /**
309  * Draws a single vertical slice of foreground color.
310  */
311 void GtkStatsStripChart::
312 draw_cursor(int x) {
313  gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_black);
314  gdk_draw_line(_pixmap, _pixmap_gc, x, 0, x, get_ysize());
315 }
316 
317 /**
318  * Should be overridden by the user class. This hook will be called after
319  * drawing a series of color bars in the strip chart; it gives the pixel range
320  * that was just redrawn.
321  */
322 void GtkStatsStripChart::
323 end_draw(int from_x, int to_x) {
324  // Draw in the guide bars.
325  int num_guide_bars = get_num_guide_bars();
326  for (int i = 0; i < num_guide_bars; i++) {
327  draw_guide_bar(_pixmap, from_x, to_x, get_guide_bar(i));
328  }
329 
330  GdkRectangle rect = {
331  from_x, 0, to_x - from_x + 1, get_ysize()
332  };
333  gdk_window_invalidate_rect(_graph_window->window, &rect, FALSE);
334 }
335 
336 /**
337  * This is called during the servicing of expose_event; it gives a derived
338  * class opportunity to do some further painting into the graph window.
339  */
340 void GtkStatsStripChart::
341 additional_graph_window_paint() {
342  int num_user_guide_bars = get_num_user_guide_bars();
343  for (int i = 0; i < num_user_guide_bars; i++) {
344  draw_guide_bar(_graph_window->window, 0, get_xsize(), get_user_guide_bar(i));
345  }
346 }
347 
348 /**
349  * Based on the mouse position within the graph window, look for draggable
350  * things the mouse might be hovering over and return the appropriate DragMode
351  * enum or DM_none if nothing is indicated.
352  */
353 GtkStatsGraph::DragMode GtkStatsStripChart::
354 consider_drag_start(int graph_x, int graph_y) {
355  if (graph_x >= 0 && graph_x < get_xsize()) {
356  if (graph_y >= 0 && graph_y < get_ysize()) {
357  // See if the mouse is over a user-defined guide bar.
358  int y = graph_y;
359  double from_height = pixel_to_height(y + 2);
360  double to_height = pixel_to_height(y - 2);
361  _drag_guide_bar = find_user_guide_bar(from_height, to_height);
362  if (_drag_guide_bar >= 0) {
363  return DM_guide_bar;
364  }
365 
366  } else {
367  // The mouse is above or below the graph; maybe create a new guide bar.
368  return DM_new_guide_bar;
369  }
370  }
371 
372  return GtkStatsGraph::consider_drag_start(graph_x, graph_y);
373 }
374 
375 /**
376  * This should be called whenever the drag mode needs to change state. It
377  * provides hooks for a derived class to do something special.
378  */
379 void GtkStatsStripChart::
380 set_drag_mode(GtkStatsGraph::DragMode drag_mode) {
381  GtkStatsGraph::set_drag_mode(drag_mode);
382 
383  switch (_drag_mode) {
384  case DM_scale:
385  case DM_sizing:
386  // Disable smoothing for these expensive operations.
387  set_average_mode(false);
388  break;
389 
390  default:
391  // Restore smoothing according to the current setting of the check box.
392  bool active =
393  gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_smooth_check_box));
394  set_average_mode(active);
395  break;
396  }
397 }
398 
399 /**
400  * Called when the mouse button is depressed within the graph window.
401  */
402 gboolean GtkStatsStripChart::
403 handle_button_press(GtkWidget *widget, int graph_x, int graph_y,
404  bool double_click) {
405  if (double_click) {
406  // Double-clicking on a color bar in the graph is the same as double-
407  // clicking on the corresponding label.
408  clicked_label(get_collector_under_pixel(graph_x, graph_y));
409  return TRUE;
410  }
411 
412  if (_potential_drag_mode == DM_none) {
413  set_drag_mode(DM_scale);
414  _drag_scale_start = pixel_to_height(graph_y);
415  // SetCapture(_graph_window);
416  return TRUE;
417 
418  } else if (_potential_drag_mode == DM_guide_bar && _drag_guide_bar >= 0) {
419  set_drag_mode(DM_guide_bar);
420  _drag_start_y = graph_y;
421  // SetCapture(_graph_window);
422  return TRUE;
423  }
424 
425  return GtkStatsGraph::handle_button_press(widget, graph_x, graph_y,
426  double_click);
427 }
428 
429 /**
430  * Called when the mouse button is released within the graph window.
431  */
432 gboolean GtkStatsStripChart::
433 handle_button_release(GtkWidget *widget, int graph_x, int graph_y) {
434  if (_drag_mode == DM_scale) {
435  set_drag_mode(DM_none);
436  // ReleaseCapture();
437  return handle_motion(widget, graph_x, graph_y);
438 
439  } else if (_drag_mode == DM_guide_bar) {
440  if (graph_y < 0 || graph_y >= get_ysize()) {
441  remove_user_guide_bar(_drag_guide_bar);
442  } else {
443  move_user_guide_bar(_drag_guide_bar, pixel_to_height(graph_y));
444  }
445  set_drag_mode(DM_none);
446  // ReleaseCapture();
447  return handle_motion(widget, graph_x, graph_y);
448  }
449 
450  return GtkStatsGraph::handle_button_release(widget, graph_x, graph_y);
451 }
452 
453 /**
454  * Called when the mouse is moved within the graph window.
455  */
456 gboolean GtkStatsStripChart::
457 handle_motion(GtkWidget *widget, int graph_x, int graph_y) {
458  if (_drag_mode == DM_none && _potential_drag_mode == DM_none) {
459  // When the mouse is over a color bar, highlight it.
460  _label_stack.highlight_label(get_collector_under_pixel(graph_x, graph_y));
461 
462  /*
463  // Now we want to get a WM_MOUSELEAVE when the mouse leaves the graph
464  // window.
465  TRACKMOUSEEVENT tme = {
466  sizeof(TRACKMOUSEEVENT),
467  TME_LEAVE,
468  _graph_window,
469  0
470  };
471  TrackMouseEvent(&tme);
472  */
473 
474  } else {
475  // If the mouse is in some drag mode, stop highlighting.
476  _label_stack.highlight_label(-1);
477  }
478 
479  if (_drag_mode == DM_scale) {
480  double ratio = 1.0f - ((double)graph_y / (double)get_ysize());
481  if (ratio > 0.0f) {
482  set_vertical_scale(_drag_scale_start / ratio);
483  }
484  return TRUE;
485 
486  } else if (_drag_mode == DM_new_guide_bar) {
487  // We haven't created the new guide bar yet; we won't until the mouse
488  // comes within the graph's region.
489  if (graph_y >= 0 && graph_y < get_ysize()) {
490  set_drag_mode(DM_guide_bar);
491  _drag_guide_bar = add_user_guide_bar(pixel_to_height(graph_y));
492  return TRUE;
493  }
494 
495  } else if (_drag_mode == DM_guide_bar) {
496  move_user_guide_bar(_drag_guide_bar, pixel_to_height(graph_y));
497  return TRUE;
498  }
499 
500  return GtkStatsGraph::handle_motion(widget, graph_x, graph_y);
501 }
502 
503 /**
504  * Draws the line for the indicated guide bar on the graph.
505  */
506 void GtkStatsStripChart::
507 draw_guide_bar(GdkDrawable *surface, int from_x, int to_x,
508  const PStatGraph::GuideBar &bar) {
509  int y = height_to_pixel(bar._height);
510 
511  if (y > 0) {
512  // Only draw it if it's not too close to the top.
513  switch (bar._style) {
514  case GBS_target:
515  gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_light_gray);
516  break;
517 
518  case GBS_user:
519  gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_user_guide_bar);
520  break;
521 
522  case GBS_normal:
523  gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_dark_gray);
524  break;
525  }
526  gdk_draw_line(surface, _pixmap_gc, from_x, y, to_x, y);
527  }
528 }
529 
530 /**
531  * This is called during the servicing of expose_event.
532  */
533 void GtkStatsStripChart::
534 draw_guide_labels() {
535  // Draw in the labels for the guide bars.
536  int last_y = -100;
537 
538  int i;
539  int num_guide_bars = get_num_guide_bars();
540  for (i = 0; i < num_guide_bars; i++) {
541  last_y = draw_guide_label(get_guide_bar(i), last_y);
542  }
543 
544  GuideBar top_value = make_guide_bar(get_vertical_scale());
545  draw_guide_label(top_value, last_y);
546 
547  last_y = -100;
548  int num_user_guide_bars = get_num_user_guide_bars();
549  for (i = 0; i < num_user_guide_bars; i++) {
550  last_y = draw_guide_label(get_user_guide_bar(i), last_y);
551  }
552 }
553 
554 /**
555  * Draws the text for the indicated guide bar label to the right of the graph,
556  * unless it would overlap with the indicated last label, whose top pixel
557  * value is given. Returns the top pixel value of the new label.
558  */
559 int GtkStatsStripChart::
560 draw_guide_label(const PStatGraph::GuideBar &bar, int last_y) {
561  GdkGC *gc = gdk_gc_new(_scale_area->window);
562 
563  switch (bar._style) {
564  case GBS_target:
565  gdk_gc_set_rgb_fg_color(gc, &rgb_light_gray);
566  break;
567 
568  case GBS_user:
569  gdk_gc_set_rgb_fg_color(gc, &rgb_user_guide_bar);
570  break;
571 
572  case GBS_normal:
573  gdk_gc_set_rgb_fg_color(gc, &rgb_dark_gray);
574  break;
575  }
576 
577  int y = height_to_pixel(bar._height);
578  const std::string &label = bar._label;
579 
580  PangoLayout *layout = gtk_widget_create_pango_layout(_window, label.c_str());
581  int width, height;
582  pango_layout_get_pixel_size(layout, &width, &height);
583 
584  if (bar._style != GBS_user) {
585  double from_height = pixel_to_height(y + height);
586  double to_height = pixel_to_height(y - height);
587  if (find_user_guide_bar(from_height, to_height) >= 0) {
588  // Omit the label: there's a user-defined guide bar in the same space.
589  g_object_unref(layout);
590  g_object_unref(gc);
591  return last_y;
592  }
593  }
594 
595  if (y >= 0 && y < get_ysize()) {
596  // Now convert our y to a coordinate within our drawing area.
597  int junk_x;
598 
599  // The y coordinate comes from the graph_window.
600  gtk_widget_translate_coordinates(_graph_window, _scale_area,
601  0, y,
602  &junk_x, &y);
603 
604  int this_y = y - height / 2;
605  if (last_y < this_y || last_y > this_y + height) {
606  gdk_draw_layout(_scale_area->window, gc, 0, this_y, layout);
607  last_y = this_y;
608  }
609  }
610 
611  g_object_unref(layout);
612  g_object_unref(gc);
613  return last_y;
614 }
615 
616 /**
617  * Called when the smooth check box is toggled.
618  */
619 void GtkStatsStripChart::
620 toggled_callback(GtkToggleButton *button, gpointer data) {
621  GtkStatsStripChart *self = (GtkStatsStripChart *)data;
622 
623  bool active = gtk_toggle_button_get_active(button);
624  self->set_average_mode(active);
625 }
626 
627 /**
628  * Draws in the scale labels.
629  */
630 gboolean GtkStatsStripChart::
631 expose_event_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
632  GtkStatsStripChart *self = (GtkStatsStripChart *)data;
633  self->draw_guide_labels();
634 
635  return TRUE;
636 }
void set_horizontal_scale(double time_width)
Changes the amount of time the width of the horizontal axis represents.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_xsize() const
Returns the width of the chart in pixels.
Definition: pStatGraph.I:82
A window that draws a strip chart, given a view.
int get_guide_bar_units() const
Returns the units that are displayed for the guide bar labels.
Definition: pStatGraph.I:111
void set_guide_bar_units(int unit_mask)
Sets the units that are displayed for the guide bar labels.
Definition: pStatGraph.I:99
int get_ysize() const
Returns the height of the chart in pixels.
Definition: pStatGraph.I:90
int get_num_labels() const
Returns the number of labels to be drawn for this chart.
Definition: pStatGraph.I:26
void move_user_guide_bar(int n, double height)
Adjusts the height of the nth user-defined guide bar.
Definition: pStatGraph.cxx:117
The data associated with a particular client, but not with any one particular frame or thread: the li...
void set_vertical_scale(double value_height)
Changes the value the height of the vertical axis represents.
int find_user_guide_bar(double from_height, double to_height) const
Returns the index number of the first user guide bar found whose height is within the indicated range...
Definition: pStatGraph.cxx:144
const PStatCollectorDef & get_collector_def(int index) const
Returns the nth collector definition.
virtual void new_collector(int collector_index)
Called whenever a new Collector definition is received from the client.
double pixel_to_height(int y) const
Converts a vertical pixel offset to a value (a "height" in the strip chart).
This is an abstract class that presents the interface for drawing a basic strip-chart,...
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...
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
virtual void new_collector(int collector_index)
Called whenever a new Collector definition is received from the client.
int get_collector_index() const
Returns the particular collector whose data this strip chart reflects.
bool has_collector(int index) const
Returns true if the indicated collector has been defined by the client already, false otherwise.
const GuideBar & get_guide_bar(int n) const
Returns the nth horizontal guide bar.
Definition: pStatGraph.cxx:87
PStatView & get_view() const
Returns the View this chart represents.
void update()
Updates the chart with the latest data.
int height_to_pixel(double value) const
Converts a value (i.e.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void set_time_units(int unit_mask)
Called when the user selects a new time units from the monitor pulldown menu, this should adjust the ...
virtual void new_data(int thread_index, int frame_number)
Called as each frame's data is made available.
This is just an abstract base class to provide a common pointer type for the various kinds of graphs ...
Definition: gtkStatsGraph.h:29
int get_label_collector(int n) const
Returns the collector index associated with the nth label.
Definition: pStatGraph.I:34
int get_num_guide_bars() const
Returns the number of horizontal guide bars that should be drawn, based on the indicated target frame...
Definition: pStatGraph.cxx:75
const std::string & get_guide_bar_unit_name() const
Returns the name of the units to be used for the guide bars if the units type is set to GBU_named | G...
Definition: pStatGraph.I:129
virtual void clicked_label(int collector_index)
Called when the user single-clicks on a label.
This class represents a connection to a PStatsClient and manages the data exchange with the client.
bool is_title_unknown() const
Returns true if get_title_text() has never yet returned an answer, false if it has.
void set_average_mode(bool average_mode)
Changes the average_mode flag.
void set_collector_index(int collector_index)
Changes the collector represented by this strip chart.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void force_redraw()
Called when it is necessary to redraw the entire graph.
virtual void set_scroll_speed(double scroll_speed)
Called when the user selects a new scroll speed from the monitor pulldown menu, this should adjust th...
double get_vertical_scale() const
Returns total value the height of the vertical axis represents.
virtual void changed_graph_size(int graph_xsize, int graph_ysize)
Called when the user has resized the window, forcing a resize of the graph.
const PStatClientData * get_client_data() const
Returns the client data associated with this monitor.
Definition: pStatMonitor.I:26
int add_user_guide_bar(double height)
Creates a new user guide bar and returns its index number.
Definition: pStatGraph.cxx:125
Defines the details about the Collectors: the name, the suggested color, etc.
static std::string format_number(double value)
Returns a string representing the value nicely formatted for its range.
Definition: pStatGraph.cxx:153
GuideBar get_user_guide_bar(int n) const
Returns the nth user-defined guide bar.
Definition: pStatGraph.cxx:108
void set_vertical_scale(double value_height)
Changes the value the height of the vertical axis represents.
int get_num_user_guide_bars() const
Returns the current number of user-defined guide bars.
Definition: pStatGraph.cxx:100
std::string get_title_text()
Returns the text suitable for the title label on the top line.
void remove_user_guide_bar(int n)
Removes the user guide bar with the indicated index number.
Definition: pStatGraph.cxx:134