Panda3D
gtkStatsMonitor.h
1 // Filename: gtkStatsMonitor.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 GTKSTATSMONITOR_H
16 #define GTKSTATSMONITOR_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "gtkStatsGraph.h"
21 #include "pStatMonitor.h"
22 #include "pointerTo.h"
23 #include "pset.h"
24 #include "pvector.h"
25 #include "pmap.h"
26 
27 #include <gtk/gtk.h>
28 
29 class GtkStatsServer;
30 class GtkStatsChartMenu;
31 
32 ////////////////////////////////////////////////////////////////////
33 // Class : GtkStatsMonitor
34 // Description : This class represents a connection to a PStatsClient
35 // and manages the data exchange with the client.
36 ////////////////////////////////////////////////////////////////////
37 class GtkStatsMonitor : public PStatMonitor {
38 public:
39  class MenuDef {
40  public:
41  INLINE MenuDef(int thread_index, int collector_index, bool show_level);
42  INLINE bool operator < (const MenuDef &other) const;
43 
44  int _thread_index;
45  int _collector_index;
46  bool _show_level;
47  GtkStatsMonitor *_monitor;
48  };
49 
51  virtual ~GtkStatsMonitor();
52 
53  virtual string get_monitor_name();
54 
55  virtual void initialized();
56  virtual void got_hello();
57  virtual void got_bad_version(int client_major, int client_minor,
58  int server_major, int server_minor);
59  virtual void new_collector(int collector_index);
60  virtual void new_thread(int thread_index);
61  virtual void new_data(int thread_index, int frame_number);
62  virtual void lost_connection();
63  virtual void idle();
64  virtual bool has_idle();
65 
66  virtual void user_guide_bars_changed();
67 
68  GtkWidget *get_window() const;
69  void open_strip_chart(int thread_index, int collector_index, bool show_level);
70  void open_piano_roll(int thread_index);
71 
72  const MenuDef *add_menu(const MenuDef &menu_def);
73 
74  void set_time_units(int unit_mask);
75  void set_scroll_speed(double scroll_speed);
76  void set_pause(bool pause);
77 
78 private:
79  void add_graph(GtkStatsGraph *graph);
80  void remove_graph(GtkStatsGraph *graph);
81 
82  void create_window();
83  void shutdown();
84  static gboolean window_delete_event(GtkWidget *widget, GdkEvent *event,
85  gpointer data);
86  static void window_destroy(GtkWidget *widget, gpointer data);
87  void setup_frame_rate_label();
88 
89  static void handle_menu_command(gpointer callback_data, guint menu_id, GtkWidget *widget);
90 
92  Graphs _graphs;
93 
95  ChartMenus _chart_menus;
96 
97  typedef pset<MenuDef> Menus;
98  Menus _menus;
99 
100  GtkWidget *_window;
101  GtkItemFactory *_item_factory;
102  int _next_chart_index;
103  GtkWidget *_frame_rate_menu_item;
104  GtkWidget *_frame_rate_label;
105  string _window_title;
106  int _time_units;
107  double _scroll_speed;
108  bool _pause;
109 
110  static GtkItemFactoryEntry menu_entries[];
111  static int num_menu_entries;
112 
113  friend class GtkStatsGraph;
114 };
115 
116 #include "gtkStatsMonitor.I"
117 
118 #endif
virtual void new_thread(int thread_index)
Called whenever a new Thread definition is received from the client.
virtual void got_hello()
Called when the "hello" message has been received from the client.
void open_piano_roll(int thread_index)
Opens a new piano roll showing the indicated data.
The class that owns the main loop, waiting for client connections.
virtual string get_monitor_name()
Should be redefined to return a descriptive name for the type of PStatsMonitor this is...
virtual void got_bad_version(int client_major, int client_minor, int server_major, int server_minor)
Like got_hello(), this is called when the "hello" message has been received from the client...
virtual void user_guide_bars_changed()
Called when the user guide bars have been changed.
This is an abstract class that presents the interface to any number of different front-ends for the s...
Definition: pStatMonitor.h:43
A pulldown menu of charts available for a particular thread.
This is just an abstract base class to provide a common pointer type for the various kinds of graphs ...
Definition: gtkStatsGraph.h:32
const MenuDef * add_menu(const MenuDef &menu_def)
Adds a new MenuDef to the monitor, or returns an existing one if there is already one just like it...
This class represents a connection to a PStatsClient and manages the data exchange with the client...
void open_strip_chart(int thread_index, int collector_index, bool show_level)
Opens a new strip chart showing the indicated data.
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 initialized()
Called after the monitor has been fully set up.
virtual void new_data(int thread_index, int frame_number)
Called as each frame&#39;s data is made available.
GtkWidget * get_window() const
Returns the window handle to the monitor&#39;s window.
virtual void lost_connection()
Called whenever the connection to the client has been lost.
virtual bool has_idle()
Should be redefined to return true if you want to redefine idle() and expect it to be called...
virtual void idle()
If has_idle() returns true, this will be called periodically to allow the monitor to update its displ...
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...
virtual void new_collector(int collector_index)
Called whenever a new Collector definition is received from the client.
void set_pause(bool pause)
Called when the user selects a pause on or pause off option from the menu.