瀏覽代碼

fix level charts

David Rose 22 年之前
父節點
當前提交
c4c6b8c928

+ 7 - 8
pandatool/src/pstatserver/pStatStripChart.cxx

@@ -49,7 +49,7 @@ PStatStripChart(PStatMonitor *monitor, PStatView &view,
   _value_height = 1.0/10.0;
   _value_height = 1.0/10.0;
   _start_time = 0.0;
   _start_time = 0.0;
 
 
-  _level_index = 0;
+  _level_index = -1;
   _title_unknown = true;
   _title_unknown = true;
 
 
   const PStatClientData *client_data = _monitor->get_client_data();
   const PStatClientData *client_data = _monitor->get_client_data();
@@ -258,20 +258,18 @@ get_title_text() {
   string text;
   string text;
 
 
   _title_unknown = false;
   _title_unknown = false;
-  bool _show_level = false;
   int _thread_index = 0;
   int _thread_index = 0;
 
 
   const PStatClientData *client_data = _monitor->get_client_data();
   const PStatClientData *client_data = _monitor->get_client_data();
   if (client_data->has_collector(_collector_index)) {
   if (client_data->has_collector(_collector_index)) {
+    text = client_data->get_collector_fullname(_collector_index);
     const PStatCollectorDef &def = client_data->get_collector_def(_collector_index);
     const PStatCollectorDef &def = client_data->get_collector_def(_collector_index);
-    if (_show_level) {
-      if (def._level_units.empty()) {
-        text = def._name;
-      } else {
-        text = def._name + " (" + def._level_units + ")";
+    if (_view.get_show_level()) {
+      if (!def._level_units.empty()) {
+        text += " (" + def._level_units + ")";
       }
       }
     } else {
     } else {
-      text = def._name + " time";
+      text += " time";
     }
     }
   } else {
   } else {
     _title_unknown = true;
     _title_unknown = true;
@@ -573,6 +571,7 @@ update_labels() {
   _labels.clear();
   _labels.clear();
 
 
   int num_children = level->get_num_children();
   int num_children = level->get_num_children();
+  cerr << "num_children = " << num_children << "\n";
   for (int i = 0; i < num_children; i++) {
   for (int i = 0; i < num_children; i++) {
     const PStatViewLevel *child = level->get_child(i);
     const PStatViewLevel *child = level->get_child(i);
     int collector = child->get_collector();
     int collector = child->get_collector();

+ 11 - 0
pandatool/src/pstatserver/pStatView.I

@@ -69,6 +69,17 @@ set_to_time(float time) {
   set_to_frame(_thread_data->get_frame_at_time(time));
   set_to_frame(_thread_data->get_frame_at_time(time));
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: PStatView::get_show_level
+//       Access: Public
+//  Description: Returns true if we are showing level data, false if
+//               time data.
+////////////////////////////////////////////////////////////////////
+INLINE bool PStatView::
+get_show_level() const {
+  return _show_level;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PStatView::get_level_index
 //     Function: PStatView::get_level_index
 //       Access: Public
 //       Access: Public

+ 2 - 1
pandatool/src/pstatserver/pStatView.h

@@ -58,7 +58,8 @@ public:
 
 
   bool has_level(int collector) const;
   bool has_level(int collector) const;
   PStatViewLevel *get_level(int collector);
   PStatViewLevel *get_level(int collector);
-
+ 
+  INLINE bool get_show_level() const;
   INLINE int get_level_index() const;
   INLINE int get_level_index() const;
 
 
 private:
 private:

+ 6 - 6
pandatool/src/win-stats/winStatsChartMenu.cxx

@@ -115,7 +115,7 @@ do_update() {
   // Now rebuild the menu with the new set of entries.
   // Now rebuild the menu with the new set of entries.
 
 
   // The menu item(s) for the thread's frame time goes first.
   // The menu item(s) for the thread's frame time goes first.
-  add_view(_menu, view.get_top_level());
+  add_view(_menu, view.get_top_level(), false);
 
 
   bool needs_separator = true;
   bool needs_separator = true;
   MENUITEMINFO mii;
   MENUITEMINFO mii;
@@ -141,7 +141,7 @@ do_update() {
       }
       }
 
 
       PStatView &level_view = _monitor->get_level_view(collector, _thread_index);
       PStatView &level_view = _monitor->get_level_view(collector, _thread_index);
-      add_view(_menu, level_view.get_top_level());
+      add_view(_menu, level_view.get_top_level(), true);
     }
     }
   }
   }
 
 
@@ -150,7 +150,7 @@ do_update() {
   mii.fType = MFT_SEPARATOR; 
   mii.fType = MFT_SEPARATOR; 
   InsertMenuItem(_menu, GetMenuItemCount(_menu), TRUE, &mii);
   InsertMenuItem(_menu, GetMenuItemCount(_menu), TRUE, &mii);
 
 
-  WinStatsMonitor::MenuDef menu_def(_thread_index, -1);
+  WinStatsMonitor::MenuDef menu_def(_thread_index, -1, false);
   int menu_id = _monitor->get_menu_id(menu_def);
   int menu_id = _monitor->get_menu_id(menu_def);
 
 
   mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID; 
   mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID; 
@@ -167,13 +167,13 @@ do_update() {
 //               indicated view and its children.
 //               indicated view and its children.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void WinStatsChartMenu::
 void WinStatsChartMenu::
-add_view(HMENU parent_menu, const PStatViewLevel *view_level) {
+add_view(HMENU parent_menu, const PStatViewLevel *view_level, bool show_level) {
   int collector = view_level->get_collector();
   int collector = view_level->get_collector();
 
 
   const PStatClientData *client_data = _monitor->get_client_data();
   const PStatClientData *client_data = _monitor->get_client_data();
   string collector_name = client_data->get_collector_name(collector);
   string collector_name = client_data->get_collector_name(collector);
 
 
-  WinStatsMonitor::MenuDef menu_def(_thread_index, collector);
+  WinStatsMonitor::MenuDef menu_def(_thread_index, collector, show_level);
   int menu_id = _monitor->get_menu_id(menu_def);
   int menu_id = _monitor->get_menu_id(menu_def);
 
 
   MENUITEMINFO mii;
   MENUITEMINFO mii;
@@ -203,7 +203,7 @@ add_view(HMENU parent_menu, const PStatViewLevel *view_level) {
     // we want to be visually consistent with the graphs, which list
     // we want to be visually consistent with the graphs, which list
     // these labels from the bottom up.
     // these labels from the bottom up.
     for (int c = num_children - 1; c >= 0; c--) {
     for (int c = num_children - 1; c >= 0; c--) {
-      add_view(submenu, view_level->get_child(c));
+      add_view(submenu, view_level->get_child(c), show_level);
     }
     }
   }
   }
 }
 }

+ 2 - 1
pandatool/src/win-stats/winStatsChartMenu.h

@@ -44,7 +44,8 @@ public:
   void do_update();
   void do_update();
 
 
 private:
 private:
-  void add_view(HMENU parent_menu, const PStatViewLevel *view_level);
+  void add_view(HMENU parent_menu, const PStatViewLevel *view_level,
+                bool show_level);
 
 
   WinStatsMonitor *_monitor;
   WinStatsMonitor *_monitor;
   int _thread_index;
   int _thread_index;

+ 7 - 3
pandatool/src/win-stats/winStatsMonitor.I

@@ -23,9 +23,10 @@
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 WinStatsMonitor::MenuDef::
 WinStatsMonitor::MenuDef::
-MenuDef(int thread_index, int collector_index) :
+MenuDef(int thread_index, int collector_index, bool show_level) :
   _thread_index(thread_index),
   _thread_index(thread_index),
-  _collector_index(collector_index)
+  _collector_index(collector_index),
+  _show_level(show_level)
 {
 {
 }
 }
 
 
@@ -39,5 +40,8 @@ operator < (const MenuDef &other) const {
   if (_thread_index != other._thread_index) {
   if (_thread_index != other._thread_index) {
     return _thread_index < other._thread_index;
     return _thread_index < other._thread_index;
   }
   }
-  return _collector_index < other._collector_index;
+  if (_collector_index != other._collector_index) {
+    return _collector_index < other._collector_index;
+  }
+  return (int)_show_level < (int)other._show_level;
 }
 }

+ 6 - 5
pandatool/src/win-stats/winStatsMonitor.cxx

@@ -112,7 +112,7 @@ initialized() {
 void WinStatsMonitor::
 void WinStatsMonitor::
 got_hello() {
 got_hello() {
   create_window();
   create_window();
-  open_strip_chart(0, 0);
+  open_strip_chart(0, 0, false);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -289,9 +289,9 @@ get_window() const {
 //  Description: Opens a new strip chart showing the indicated data.
 //  Description: Opens a new strip chart showing the indicated data.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void WinStatsMonitor::
 void WinStatsMonitor::
-open_strip_chart(int thread_index, int collector_index) {
+open_strip_chart(int thread_index, int collector_index, bool show_level) {
   WinStatsStripChart *graph = 
   WinStatsStripChart *graph = 
-    new WinStatsStripChart(this, thread_index, collector_index);
+    new WinStatsStripChart(this, thread_index, collector_index, show_level);
   add_graph(graph);
   add_graph(graph);
 
 
   graph->set_time_units(_time_units);
   graph->set_time_units(_time_units);
@@ -323,7 +323,7 @@ open_piano_roll(int thread_index) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 const WinStatsMonitor::MenuDef &WinStatsMonitor::
 const WinStatsMonitor::MenuDef &WinStatsMonitor::
 lookup_menu(int menu_id) const {
 lookup_menu(int menu_id) const {
-  static MenuDef invalid(0, 0);
+  static MenuDef invalid(0, 0, false);
   int menu_index = menu_id - MI_new_chart;
   int menu_index = menu_id - MI_new_chart;
   nassertr(menu_index >= 0 && menu_index < (int)_menu_by_id.size(), invalid);
   nassertr(menu_index >= 0 && menu_index < (int)_menu_by_id.size(), invalid);
   return _menu_by_id[menu_index];
   return _menu_by_id[menu_index];
@@ -778,7 +778,8 @@ handle_menu_command(int menu_id) {
       if (menu_def._collector_index < 0) {
       if (menu_def._collector_index < 0) {
         open_piano_roll(menu_def._thread_index);
         open_piano_roll(menu_def._thread_index);
       } else {
       } else {
-        open_strip_chart(menu_def._thread_index, menu_def._collector_index);
+        open_strip_chart(menu_def._thread_index, menu_def._collector_index,
+                         menu_def._show_level);
       }
       }
     }
     }
   }
   }

+ 3 - 2
pandatool/src/win-stats/winStatsMonitor.h

@@ -42,11 +42,12 @@ class WinStatsMonitor : public PStatMonitor {
 public:
 public:
   class MenuDef {
   class MenuDef {
   public:
   public:
-    INLINE MenuDef(int thread_index, int collector_index);
+    INLINE MenuDef(int thread_index, int collector_index, bool show_level);
     INLINE bool operator < (const MenuDef &other) const;
     INLINE bool operator < (const MenuDef &other) const;
 
 
     int _thread_index;
     int _thread_index;
     int _collector_index;
     int _collector_index;
+    bool _show_level;
   };
   };
 
 
   WinStatsMonitor(WinStatsServer *server);
   WinStatsMonitor(WinStatsServer *server);
@@ -68,7 +69,7 @@ public:
   virtual void user_guide_bars_changed();
   virtual void user_guide_bars_changed();
 
 
   HWND get_window() const;
   HWND get_window() const;
-  void open_strip_chart(int thread_index, int collector_index);
+  void open_strip_chart(int thread_index, int collector_index, bool show_level);
   void open_piano_roll(int thread_index);
   void open_piano_roll(int thread_index);
 
 
   const MenuDef &lookup_menu(int menu_id) const;
   const MenuDef &lookup_menu(int menu_id) const;

+ 1 - 1
pandatool/src/win-stats/winStatsPianoRoll.cxx

@@ -127,7 +127,7 @@ set_time_units(int unit_mask) {
 void WinStatsPianoRoll::
 void WinStatsPianoRoll::
 clicked_label(int collector_index) {
 clicked_label(int collector_index) {
   if (collector_index >= 0) {
   if (collector_index >= 0) {
-    WinStatsGraph::_monitor->open_strip_chart(WinStatsGraph::_thread_index, collector_index);
+    WinStatsGraph::_monitor->open_strip_chart(WinStatsGraph::_thread_index, collector_index, false);
   }
   }
 }
 }
 
 

+ 14 - 6
pandatool/src/win-stats/winStatsStripChart.cxx

@@ -33,8 +33,10 @@ const char * const WinStatsStripChart::_window_class_name = "strip";
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 WinStatsStripChart::
 WinStatsStripChart::
 WinStatsStripChart(WinStatsMonitor *monitor, int thread_index,
 WinStatsStripChart(WinStatsMonitor *monitor, int thread_index,
-                   int collector_index) :
-  PStatStripChart(monitor, monitor->get_view(thread_index), collector_index, 
+                   int collector_index, bool show_level) :
+  PStatStripChart(monitor, 
+                  show_level ? monitor->get_level_view(collector_index, thread_index) : monitor->get_view(thread_index), 
+                  collector_index, 
                   default_strip_chart_width,
                   default_strip_chart_width,
                   default_strip_chart_height),
                   default_strip_chart_height),
   WinStatsGraph(monitor, thread_index)
   WinStatsGraph(monitor, thread_index)
@@ -45,9 +47,11 @@ WinStatsStripChart(WinStatsMonitor *monitor, int thread_index,
   _right_margin = 32;
   _right_margin = 32;
   _top_margin = 16;
   _top_margin = 16;
   _bottom_margin = 8;
   _bottom_margin = 8;
-
-  // Let's show the units on the guide bar labels.  There's room.
-  set_guide_bar_units(get_guide_bar_units() | GBU_show_units);
+  
+  if (!show_level || (get_guide_bar_units() & GBU_named) != 0) {
+    // Let's show the units on the guide bar labels.  There's room.
+    set_guide_bar_units(get_guide_bar_units() | GBU_show_units);
+  }
 
 
   create_window();
   create_window();
   clear_region();
   clear_region();
@@ -188,7 +192,11 @@ clicked_label(int collector_index) {
     if (client_data->has_collector(collector_index)) {
     if (client_data->has_collector(collector_index)) {
       const PStatCollectorDef &def =
       const PStatCollectorDef &def =
         client_data->get_collector_def(collector_index);
         client_data->get_collector_def(collector_index);
-      set_collector_index(def._parent_index);
+      if (def._parent_index == 0 && get_view().get_show_level()) {
+        // Unless the parent is "Frame", and we're not a time collector.
+      } else {
+        set_collector_index(def._parent_index);
+      }
     }
     }
 
 
   } else {
   } else {

+ 1 - 1
pandatool/src/win-stats/winStatsStripChart.h

@@ -36,7 +36,7 @@ class WinStatsMonitor;
 class WinStatsStripChart : public PStatStripChart, public WinStatsGraph {
 class WinStatsStripChart : public PStatStripChart, public WinStatsGraph {
 public:
 public:
   WinStatsStripChart(WinStatsMonitor *monitor,
   WinStatsStripChart(WinStatsMonitor *monitor,
-                     int thread_index, int collector_index);
+                     int thread_index, int collector_index, bool show_level);
   virtual ~WinStatsStripChart();
   virtual ~WinStatsStripChart();
 
 
   virtual void new_collector(int collector_index);
   virtual void new_collector(int collector_index);