Panda3D
 All Classes Functions Variables Enumerations
gtkStatsGraph.h
1 // Filename: gtkStatsGraph.h
2 // Created by: drose (16Jan06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef GTKSTATSGRAPH_H
16 #define GTKSTATSGRAPH_H
17 
18 #include "pandatoolbase.h"
19 #include "gtkStatsLabelStack.h"
20 #include "pmap.h"
21 
22 #include <gtk/gtk.h>
23 
24 class GtkStatsMonitor;
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : GtkStatsGraph
28 // Description : This is just an abstract base class to provide a
29 // common pointer type for the various kinds of graphs
30 // that may be created for a GtkStatsMonitor.
31 ////////////////////////////////////////////////////////////////////
33 public:
34  // What is the user adjusting by dragging the mouse in a window?
35  enum DragMode {
36  DM_none,
37  DM_scale,
38  DM_guide_bar,
39  DM_new_guide_bar,
40  DM_sizing,
41  };
42 
43 public:
45  virtual ~GtkStatsGraph();
46 
47  virtual void new_collector(int collector_index);
48  virtual void new_data(int thread_index, int frame_number);
49  virtual void force_redraw();
50  virtual void changed_graph_size(int graph_xsize, int graph_ysize);
51 
52  virtual void set_time_units(int unit_mask);
53  virtual void set_scroll_speed(double scroll_speed);
54  void set_pause(bool pause);
55 
57  virtual void clicked_label(int collector_index);
58 
59 protected:
60  void close();
61  GdkGC *get_collector_gc(int collector_index);
62 
63  virtual void additional_graph_window_paint();
64  virtual DragMode consider_drag_start(int graph_x, int graph_y);
65  virtual void set_drag_mode(DragMode drag_mode);
66 
67  virtual gboolean handle_button_press(GtkWidget *widget, int graph_x, int graph_y,
68  bool double_click);
69  virtual gboolean handle_button_release(GtkWidget *widget, int graph_x, int graph_y);
70  virtual gboolean handle_motion(GtkWidget *widget, int graph_x, int graph_y);
71 
72 protected:
73  // Table of GC's for our various collectors.
75  Brushes _brushes;
76 
77  GtkStatsMonitor *_monitor;
78  GtkWidget *_parent_window;
79  GtkWidget *_window;
80  GtkWidget *_graph_window;
81  GtkWidget *_graph_hbox;
82  GtkWidget *_graph_vbox;
83  GtkWidget *_hpaned;
84  GtkWidget *_scale_area;
85  GtkStatsLabelStack _label_stack;
86 
87  GdkCursor *_hand_cursor;
88 
89  GdkPixmap *_pixmap;
90  GdkGC *_pixmap_gc;
91  int _pixmap_xsize, _pixmap_ysize;
92 
93  /*
94  COLORREF _dark_color;
95  COLORREF _light_color;
96  COLORREF _user_guide_bar_color;
97  HPEN _dark_pen;
98  HPEN _light_pen;
99  HPEN _user_guide_bar_pen;
100  */
101 
102  DragMode _drag_mode;
103  DragMode _potential_drag_mode;
104  int _drag_start_x, _drag_start_y;
105  double _drag_scale_start;
106  int _drag_guide_bar;
107 
108  bool _pause;
109 
110  static const GdkColor rgb_white;
111  static const GdkColor rgb_light_gray;
112  static const GdkColor rgb_dark_gray;
113  static const GdkColor rgb_black;
114  static const GdkColor rgb_user_guide_bar;
115 
116 private:
117  void setup_pixmap(int xsize, int ysize);
118  void release_pixmap();
119 
120  static gboolean window_delete_event(GtkWidget *widget, GdkEvent *event,
121  gpointer data);
122  static void window_destroy(GtkWidget *widget, gpointer data);
123  static gboolean graph_expose_callback(GtkWidget *widget,
124  GdkEventExpose *event, gpointer data);
125  static gboolean configure_graph_callback(GtkWidget *widget,
126  GdkEventConfigure *event, gpointer data);
127 
128 protected:
129  static gboolean button_press_event_callback(GtkWidget *widget,
130  GdkEventButton *event,
131  gpointer data);
132  static gboolean button_release_event_callback(GtkWidget *widget,
133  GdkEventButton *event,
134  gpointer data);
135  static gboolean motion_notify_event_callback(GtkWidget *widget,
136  GdkEventMotion *event,
137  gpointer data);
138 };
139 
140 #endif
141 
virtual void new_data(int thread_index, int frame_number)
Called whenever new data arrives.
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.
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:32
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.