Panda3D
|
00001 // Filename: gtkStatsMonitor.h 00002 // Created by: drose (16Jan06) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef GTKSTATSMONITOR_H 00016 #define GTKSTATSMONITOR_H 00017 00018 #include "pandatoolbase.h" 00019 00020 #include "gtkStatsGraph.h" 00021 #include "pStatMonitor.h" 00022 #include "pointerTo.h" 00023 #include "pset.h" 00024 #include "pvector.h" 00025 #include "pmap.h" 00026 00027 #include <gtk/gtk.h> 00028 00029 class GtkStatsServer; 00030 class GtkStatsChartMenu; 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Class : GtkStatsMonitor 00034 // Description : This class represents a connection to a PStatsClient 00035 // and manages the data exchange with the client. 00036 //////////////////////////////////////////////////////////////////// 00037 class GtkStatsMonitor : public PStatMonitor { 00038 public: 00039 class MenuDef { 00040 public: 00041 INLINE MenuDef(int thread_index, int collector_index, bool show_level); 00042 INLINE bool operator < (const MenuDef &other) const; 00043 00044 int _thread_index; 00045 int _collector_index; 00046 bool _show_level; 00047 GtkStatsMonitor *_monitor; 00048 }; 00049 00050 GtkStatsMonitor(GtkStatsServer *server); 00051 virtual ~GtkStatsMonitor(); 00052 00053 virtual string get_monitor_name(); 00054 00055 virtual void initialized(); 00056 virtual void got_hello(); 00057 virtual void got_bad_version(int client_major, int client_minor, 00058 int server_major, int server_minor); 00059 virtual void new_collector(int collector_index); 00060 virtual void new_thread(int thread_index); 00061 virtual void new_data(int thread_index, int frame_number); 00062 virtual void lost_connection(); 00063 virtual void idle(); 00064 virtual bool has_idle(); 00065 00066 virtual void user_guide_bars_changed(); 00067 00068 GtkWidget *get_window() const; 00069 void open_strip_chart(int thread_index, int collector_index, bool show_level); 00070 void open_piano_roll(int thread_index); 00071 00072 const MenuDef *add_menu(const MenuDef &menu_def); 00073 00074 void set_time_units(int unit_mask); 00075 void set_scroll_speed(double scroll_speed); 00076 void set_pause(bool pause); 00077 00078 private: 00079 void add_graph(GtkStatsGraph *graph); 00080 void remove_graph(GtkStatsGraph *graph); 00081 00082 void create_window(); 00083 void shutdown(); 00084 static gboolean window_delete_event(GtkWidget *widget, GdkEvent *event, 00085 gpointer data); 00086 static void window_destroy(GtkWidget *widget, gpointer data); 00087 void setup_frame_rate_label(); 00088 00089 static void handle_menu_command(gpointer callback_data, guint menu_id, GtkWidget *widget); 00090 00091 typedef pset<GtkStatsGraph *> Graphs; 00092 Graphs _graphs; 00093 00094 typedef pvector<GtkStatsChartMenu *> ChartMenus; 00095 ChartMenus _chart_menus; 00096 00097 typedef pset<MenuDef> Menus; 00098 Menus _menus; 00099 00100 GtkWidget *_window; 00101 GtkItemFactory *_item_factory; 00102 int _next_chart_index; 00103 GtkWidget *_frame_rate_menu_item; 00104 GtkWidget *_frame_rate_label; 00105 string _window_title; 00106 int _time_units; 00107 double _scroll_speed; 00108 bool _pause; 00109 00110 static GtkItemFactoryEntry menu_entries[]; 00111 static int num_menu_entries; 00112 00113 friend class GtkStatsGraph; 00114 }; 00115 00116 #include "gtkStatsMonitor.I" 00117 00118 #endif