Panda3D
gtkStatsGraph.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 gtkStatsGraph.h
10  * @author drose
11  * @date 2006-01-16
12  */
13 
14 #ifndef GTKSTATSGRAPH_H
15 #define GTKSTATSGRAPH_H
16 
17 #include "pandatoolbase.h"
18 #include "gtkStatsLabelStack.h"
19 #include "pmap.h"
20 
21 #include <gtk/gtk.h>
22 
23 class GtkStatsMonitor;
24 
25 /**
26  * This is just an abstract base class to provide a common pointer type for
27  * the various kinds of graphs that may be created for a GtkStatsMonitor.
28  */
30 public:
31  // What is the user adjusting by dragging the mouse in a window?
32  enum DragMode {
33  DM_none,
34  DM_scale,
35  DM_guide_bar,
36  DM_new_guide_bar,
37  DM_sizing,
38  };
39 
40 public:
42  virtual ~GtkStatsGraph();
43 
44  virtual void new_collector(int collector_index);
45  virtual void new_data(int thread_index, int frame_number);
46  virtual void force_redraw();
47  virtual void changed_graph_size(int graph_xsize, int graph_ysize);
48 
49  virtual void set_time_units(int unit_mask);
50  virtual void set_scroll_speed(double scroll_speed);
51  void set_pause(bool pause);
52 
54  virtual void clicked_label(int collector_index);
55 
56 protected:
57  void close();
58  GdkGC *get_collector_gc(int collector_index);
59 
60  virtual void additional_graph_window_paint();
61  virtual DragMode consider_drag_start(int graph_x, int graph_y);
62  virtual void set_drag_mode(DragMode drag_mode);
63 
64  virtual gboolean handle_button_press(GtkWidget *widget, int graph_x, int graph_y,
65  bool double_click);
66  virtual gboolean handle_button_release(GtkWidget *widget, int graph_x, int graph_y);
67  virtual gboolean handle_motion(GtkWidget *widget, int graph_x, int graph_y);
68 
69 protected:
70  // Table of GC's for our various collectors.
72  Brushes _brushes;
73 
74  GtkStatsMonitor *_monitor;
75  GtkWidget *_parent_window;
76  GtkWidget *_window;
77  GtkWidget *_graph_window;
78  GtkWidget *_graph_hbox;
79  GtkWidget *_graph_vbox;
80  GtkWidget *_hpaned;
81  GtkWidget *_scale_area;
82  GtkStatsLabelStack _label_stack;
83 
84  GdkCursor *_hand_cursor;
85 
86  GdkPixmap *_pixmap;
87  GdkGC *_pixmap_gc;
88  int _pixmap_xsize, _pixmap_ysize;
89 
90  /*
91  COLORREF _dark_color;
92  COLORREF _light_color;
93  COLORREF _user_guide_bar_color;
94  HPEN _dark_pen;
95  HPEN _light_pen;
96  HPEN _user_guide_bar_pen;
97  */
98 
99  DragMode _drag_mode;
100  DragMode _potential_drag_mode;
101  int _drag_start_x, _drag_start_y;
102  double _drag_scale_start;
103  int _drag_guide_bar;
104 
105  bool _pause;
106 
107  static const GdkColor rgb_white;
108  static const GdkColor rgb_light_gray;
109  static const GdkColor rgb_dark_gray;
110  static const GdkColor rgb_black;
111  static const GdkColor rgb_user_guide_bar;
112 
113 private:
114  void setup_pixmap(int xsize, int ysize);
115  void release_pixmap();
116 
117  static gboolean window_delete_event(GtkWidget *widget, GdkEvent *event,
118  gpointer data);
119  static void window_destroy(GtkWidget *widget, gpointer data);
120  static gboolean graph_expose_callback(GtkWidget *widget,
121  GdkEventExpose *event, gpointer data);
122  static gboolean configure_graph_callback(GtkWidget *widget,
123  GdkEventConfigure *event, gpointer data);
124 
125 protected:
126  static gboolean button_press_event_callback(GtkWidget *widget,
127  GdkEventButton *event,
128  gpointer data);
129  static gboolean button_release_event_callback(GtkWidget *widget,
130  GdkEventButton *event,
131  gpointer data);
132  static gboolean motion_notify_event_callback(GtkWidget *widget,
133  GdkEventMotion *event,
134  gpointer data);
135 };
136 
137 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void new_data(int thread_index, int frame_number)
Called whenever new data arrives.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void user_guide_bars_changed()
Called when the user guide bars have been changed.
void set_pause(bool pause)
Changes the pause flag for the graph.
virtual void new_collector(int collector_index)
Called whenever a new Collector definition is received from the client.
virtual void force_redraw()
Called when it is necessary to redraw the entire graph.
virtual void clicked_label(int collector_index)
Called when the user single-clicks on a label.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A widget that contains a stack of labels from bottom to top.
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...
This is just an abstract base class to provide a common pointer type for the various kinds of graphs ...
Definition: gtkStatsGraph.h:29
This class represents a connection to a PStatsClient and manages the data exchange with the client.
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 changed_graph_size(int graph_xsize, int graph_ysize)
Called when the user has resized the window, forcing a resize of the graph.