27 GtkItemFactoryEntry GtkStatsMonitor::menu_entries[] = {
    28   { (gchar *)
"/Options", 
nullptr, 
nullptr, 0, (gchar *)
"<Branch>" },
    29   { (gchar *)
"/Options/Units", 
nullptr, 
nullptr, 0, (gchar *)
"<Branch>" },
    30   { (gchar *)
"/Options/Units/ms", 
nullptr, (vc *)&handle_menu_command, MI_time_ms, (gchar *)
"<RadioItem>" },
    31   { (gchar *)
"/Options/Units/Hz", 
nullptr, (vc *)&handle_menu_command, MI_time_hz, (gchar *)
"/Options/Units/ms" },
    32   { (gchar *)
"/Speed", 
nullptr, 
nullptr, 0, (gchar *)
"<Branch>" },
    33   { (gchar *)
"/Speed/1", 
nullptr, (vc *)&handle_menu_command, MI_speed_1, (gchar *)
"<RadioItem>" },
    34   { (gchar *)
"/Speed/2", 
nullptr, (vc *)&handle_menu_command, MI_speed_2, (gchar *)
"/Speed/1" },
    35   { (gchar *)
"/Speed/3", 
nullptr, (vc *)&handle_menu_command, MI_speed_3, (gchar *)
"/Speed/1" },
    36   { (gchar *)
"/Speed/6", 
nullptr, (vc *)&handle_menu_command, MI_speed_6, (gchar *)
"/Speed/1" },
    37   { (gchar *)
"/Speed/12", 
nullptr, (vc *)&handle_menu_command, MI_speed_12, (gchar *)
"/Speed/1" },
    38   { (gchar *)
"/Speed/sep", 
nullptr, 
nullptr, 0, (gchar *)
"<Separator>" },
    39   { (gchar *)
"/Speed/pause", 
nullptr, (vc *)&handle_menu_command, MI_pause, (gchar *)
"<CheckItem>" },
    42 int GtkStatsMonitor::num_menu_entries = 
sizeof(menu_entries) / 
sizeof(GtkItemFactoryEntry);
    50   _item_factory = 
nullptr;
   105                 int server_major, 
int server_minor) {
   106   std::ostringstream str;
   107   str << 
"Unable to honor connection attempt from "   109       << 
": unsupported PStats version "   110       << client_major << 
"." << client_minor;
   112   if (server_minor == 0) {
   113     str << 
" (server understands version " << server_major
   114         << 
"." << server_minor << 
" only).";
   116     str << 
" (server understands versions " << server_major
   117         << 
".0 through " << server_major << 
"." << server_minor << 
").";
   120   std::string message = str.str();
   122     gtk_message_dialog_new(GTK_WINDOW(main_window),
   123                            GTK_DIALOG_DESTROY_WITH_PARENT,
   126                            "%s", message.c_str());
   127   gtk_dialog_run(GTK_DIALOG(dialog));
   128   gtk_widget_destroy(dialog);
   141   for (gi = _graphs.begin(); gi != _graphs.end(); ++gi) {
   147   ChartMenus::iterator mi;
   148   for (mi = _chart_menus.begin(); mi != _chart_menus.end(); ++mi) {
   163   GtkWidget *menu_bar = gtk_item_factory_get_widget(_item_factory, 
"<PStats>");
   166   _chart_menus.push_back(chart_menu);
   178   for (gi = _graphs.begin(); gi != _graphs.end(); ++gi) {
   180     graph->
new_data(thread_index, frame_number);
   204   ChartMenus::iterator mi;
   205   for (mi = _chart_menus.begin(); mi != _chart_menus.end(); ++mi) {
   206     (*mi)->check_update();
   212   if (frame_rate != 0.0f) {
   214     sprintf(buffer, 
"%0.1f ms / %0.1f Hz", 1000.0f / frame_rate, frame_rate);
   216     gtk_label_set_text(GTK_LABEL(_frame_rate_label), buffer);
   235   for (gi = _graphs.begin(); gi != _graphs.end(); ++gi) {
   282   std::pair<Menus::iterator, bool> result = _menus.insert(menu_def);
   283   Menus::iterator mi = result.first;
   289   return &new_menu_def;
   299   _time_units = unit_mask;
   303   for (gi = _graphs.begin(); gi != _graphs.end(); ++gi) {
   315   _scroll_speed = scroll_speed;
   319   for (gi = _graphs.begin(); gi != _graphs.end(); ++gi) {
   334   for (gi = _graphs.begin(); gi != _graphs.end(); ++gi) {
   343 void GtkStatsMonitor::
   345   _graphs.insert(graph);
   351 void GtkStatsMonitor::
   353   Graphs::iterator gi = _graphs.find(graph);
   354   if (gi != _graphs.end()) {
   363 void GtkStatsMonitor::
   365   if (_window != 
nullptr) {
   369   _window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   371   g_signal_connect(G_OBJECT(_window), 
"delete_event",
   372        G_CALLBACK(window_delete_event), 
this);
   373   g_signal_connect(G_OBJECT(_window), 
"destroy",
   374        G_CALLBACK(window_destroy), 
this);
   377   gtk_window_set_title(GTK_WINDOW(_window), _window_title.c_str());
   379   gtk_window_set_default_size(GTK_WINDOW(_window), 500, 360);
   382   GtkAccelGroup *accel_group = gtk_accel_group_new();
   384     gtk_item_factory_new(GTK_TYPE_MENU_BAR, 
"<PStats>", accel_group);
   385   gtk_item_factory_create_items(_item_factory, num_menu_entries, menu_entries,
   387   gtk_window_add_accel_group(GTK_WINDOW(_window), accel_group);
   388   GtkWidget *menu_bar = gtk_item_factory_get_widget(_item_factory, 
"<PStats>");
   389   _next_chart_index = 2;
   391   setup_frame_rate_label();
   393   ChartMenus::iterator mi;
   394   for (mi = _chart_menus.begin(); mi != _chart_menus.end(); ++mi) {
   395     (*mi)->add_to_menu_bar(menu_bar, _next_chart_index);
   400   GtkWidget *main_vbox = gtk_vbox_new(FALSE, 1);
   401   gtk_container_add(GTK_CONTAINER(_window), main_vbox);
   402   gtk_box_pack_start(GTK_BOX(main_vbox), menu_bar, FALSE, TRUE, 0);
   404   gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(_item_factory, 
"/Speed/3")),
   408   gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(_item_factory, 
"/Options/Units/ms")),
   412   gtk_widget_show_all(_window);
   413   gtk_widget_show(_window);
   421 void GtkStatsMonitor::
   424   for (gi = _graphs.begin(); gi != _graphs.end(); ++gi) {
   429   ChartMenus::iterator mi;
   430   for (mi = _chart_menus.begin(); mi != _chart_menus.end(); ++mi) {
   433   _chart_menus.clear();
   435   if (_window != 
nullptr) {
   436     gtk_widget_destroy(_window);
   440 #ifdef DEVELOP_GTKSTATS   449 gboolean GtkStatsMonitor::
   450 window_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) {
   459 void GtkStatsMonitor::
   460 window_destroy(GtkWidget *widget, gpointer data) {
   471 void GtkStatsMonitor::
   472 setup_frame_rate_label() {
   473   GtkWidget *menu_bar = gtk_item_factory_get_widget(_item_factory, 
"<PStats>");
   475   _frame_rate_menu_item = gtk_menu_item_new();
   476   _frame_rate_label = gtk_label_new(
"");
   477   gtk_container_add(GTK_CONTAINER(_frame_rate_menu_item), _frame_rate_label);
   479   gtk_widget_show(_frame_rate_menu_item);
   480   gtk_widget_show(_frame_rate_label);
   481   gtk_menu_item_right_justify(GTK_MENU_ITEM(_frame_rate_menu_item));
   483   gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), _frame_rate_menu_item);
   489 void GtkStatsMonitor::
   490 handle_menu_command(gpointer callback_data, guint menu_id, GtkWidget *widget) {
   497     self->set_time_units(PStatGraph::GBU_ms);
   501     self->set_time_units(PStatGraph::GBU_hz);
   505     self->set_scroll_speed(1);
   509     self->set_scroll_speed(2);
   513     self->set_scroll_speed(3);
   517     self->set_scroll_speed(6);
   521     self->set_scroll_speed(12);
   525     self->set_pause(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)));
 PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A window that draws a strip chart, given a view.
virtual void new_thread(int thread_index)
Called whenever a new Thread definition is received from 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 ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
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.
The class that owns the main loop, waiting for client connections.
void close()
Closes the client connection if it is active.
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.
std::string get_client_hostname() const
Returns the hostname of the client we're connected to, if known.
virtual void new_collector(int collector_index)
Called whenever a new Collector definition is received from the client.
A window that draws a piano-roll style chart, which shows the collectors explicitly stopping and star...
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...
virtual std::string get_monitor_name()
Should be redefined to return a descriptive name for the type of PStatsMonitor this is.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
double get_frame_rate() const
Computes the average frame rate over the past pstats_average_time seconds, by counting up the number ...
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 ...
std::string get_client_progname() const
Returns the program name of the client we're connected to, if known.
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 ...
A collection of FrameData structures for recently-received frames within a particular thread.
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.
const PStatThreadData * get_thread_data(int index) const
Returns the data associated with the indicated thread.
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 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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void new_data(int thread_index, int frame_number)
Called as each frame's data is made available.
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...
GtkWidget * get_window() const
Returns the window handle to the monitor'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...
const PStatClientData * get_client_data() const
Returns the client data associated with this monitor.
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.