23 _thread_index(thread_index)
25 _menu = gtk_menu_new();
26 gtk_widget_show(_menu);
34 ~GtkStatsChartMenu() {
51 std::string thread_name;
52 if (_thread_index == 0) {
54 thread_name =
"Graphs";
59 GtkWidget *menu_item = gtk_menu_item_new_with_label(thread_name.c_str());
60 gtk_widget_show(menu_item);
61 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), _menu);
63 gtk_menu_shell_insert(GTK_MENU_SHELL(menu_bar), menu_item, position);
87 gtk_container_foreach(GTK_CONTAINER(_menu), remove_menu_child, _menu);
94 bool needs_separator =
true;
99 for (
int tc = 0; tc < num_toplevel_collectors; tc++) {
106 if (needs_separator) {
107 GtkWidget *sep = gtk_separator_menu_item_new();
108 gtk_widget_show(sep);
109 gtk_menu_shell_append(GTK_MENU_SHELL(_menu), sep);
111 needs_separator =
false;
120 GtkWidget *sep = gtk_separator_menu_item_new();
121 gtk_widget_show(sep);
122 gtk_menu_shell_append(GTK_MENU_SHELL(_menu), sep);
127 GtkWidget *menu_item = gtk_menu_item_new_with_label(
"Piano Roll");
128 gtk_widget_show(menu_item);
129 gtk_menu_shell_append(GTK_MENU_SHELL(_menu), menu_item);
131 g_signal_connect_swapped(G_OBJECT(menu_item),
"activate",
132 G_CALLBACK(handle_menu), (
void *)(
const void *)menu_def);
139 void GtkStatsChartMenu::
140 add_view(GtkWidget *parent_menu,
const PStatViewLevel *view_level,
150 GtkWidget *menu_item = gtk_menu_item_new_with_label(collector_name.c_str());
151 gtk_widget_show(menu_item);
152 gtk_menu_shell_append(GTK_MENU_SHELL(parent_menu), menu_item);
154 g_signal_connect_swapped(G_OBJECT(menu_item),
"activate",
155 G_CALLBACK(handle_menu), (
void *)(
const void *)menu_def);
158 if (num_children > 1) {
161 std::string submenu_name = collector_name +
" components";
163 GtkWidget *submenu_item = gtk_menu_item_new_with_label(submenu_name.c_str());
164 gtk_widget_show(submenu_item);
165 gtk_menu_shell_append(GTK_MENU_SHELL(parent_menu), submenu_item);
167 GtkWidget *submenu = gtk_menu_new();
168 gtk_widget_show(submenu);
169 gtk_menu_item_set_submenu(GTK_MENU_ITEM(submenu_item), submenu);
174 for (
int c = num_children - 1; c >= 0; c--) {
175 add_view(submenu, view_level->
get_child(c), show_level);
183 void GtkStatsChartMenu::
184 handle_menu(gpointer data) {
188 if (monitor ==
nullptr) {
192 if (menu_def->_collector_index < 0) {
196 menu_def->_collector_index,
197 menu_def->_show_level);
204 void GtkStatsChartMenu::
205 remove_menu_child(GtkWidget *widget, gpointer data) {
206 GtkWidget *menu = (GtkWidget *)data;
207 gtk_container_remove(GTK_CONTAINER(menu), widget);
const PStatViewLevel * get_top_level()
Returns a pointer to the level that corresponds to the Collector we've constrained to.
int get_toplevel_collector(int index) const
Returns the collector index of the nth toplevel collector.
void open_piano_roll(int thread_index)
Opens a new piano roll showing the indicated data.
PStatView & get_level_view(int collector_index, int thread_index)
Returns a view on the level value (as opposed to elapsed time) for the given collector over the given...
const PStatViewLevel * get_child(int n) const
Returns the nth child of this Level/Collector.
The data associated with a particular client, but not with any one particular frame or thread: the li...
std::string get_collector_name(int index) const
Returns the name of the indicated collector.
This is a single level value, or band of color, within a View.
bool has_collector(int index) const
Returns true if the indicated collector has been defined by the client already, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A View boils down the frame data to a linear list of times spent in a number of different Collectors,...
PStatView & get_view(int thread_index)
Returns a view on the given thread index.
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.
int get_collector() const
Returns the Collector index associated with this level.
int get_level_index() const
Returns an index number that can be used to determine when the set of known levels has changed.
const PStatClientData * get_client_data() const
Returns the client data associated with this monitor.
int get_num_children() const
Returns the number of children of this Level/Collector.
int get_num_toplevel_collectors() const
Returns the total number of collectors that are toplevel collectors.
std::string get_thread_name(int index) const
Returns the name of the indicated thread.
bool get_collector_has_level(int index, int thread_index) const
Returns whether the given collector has level data (and consequently, whether it should appear on the...