ソースを参照

implement averaging (smoothing)

David Rose 21 年 前
コミット
89006b755f

+ 18 - 1
pandatool/src/gtk-stats/gtkStatsStripWindow.cxx

@@ -27,6 +27,7 @@
 
 
 using Gtk::Menu_Helpers::MenuElem;
+using Gtk::Menu_Helpers::CheckMenuElem;
 using Gtk::Menu_Helpers::SeparatorElem;
 
 ////////////////////////////////////////////////////////////////////
@@ -45,6 +46,7 @@ GtkStatsStripWindow(GtkStatsMonitor *monitor, int thread_index,
 {
   _title_unknown = false;
   _setup_scale_menu = false;
+  _smooth = false;
 
   setup_menu();
   layout_window(chart_xsize, chart_ysize);
@@ -173,8 +175,11 @@ setup_menu() {
 
   _menu->items().push_back(MenuElem("Speed", *manage(speed_menu)));
 
-
   _scale_menu = new Gtk::Menu;
+  _scale_menu->items().push_back
+    (CheckMenuElem("Smooth",
+                   slot(this, &GtkStatsStripWindow::menu_smooth)));
+  _scale_menu->items().push_back(SeparatorElem());
   _scale_menu->items().push_back
     (MenuElem("Auto scale",
               slot(this, &GtkStatsStripWindow::menu_auto_vscale)));
@@ -296,6 +301,18 @@ menu_vscale(float max_height) {
   _chart->set_vertical_scale(max_height);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: GtkStatsStripWindow::menu_smooth
+//       Access: Protected
+//  Description: Toggles the "smooth" state of the check menu.
+////////////////////////////////////////////////////////////////////
+void GtkStatsStripWindow::
+menu_smooth() {
+  _smooth = !_smooth;
+
+  _chart->set_average_mode(_smooth);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: GtkStatsStripWindow::menu_auto_vscale
 //       Access: Protected

+ 3 - 0
pandatool/src/gtk-stats/gtkStatsStripWindow.h

@@ -47,6 +47,7 @@ protected:
   virtual void menu_new_window();
   void menu_hscale(float wpm);
   void menu_vscale(float max_height);
+  void menu_smooth();
   void menu_auto_vscale();
   void menu_show_levels(int collector_index);
   void open_subchart(int collector_index);
@@ -68,6 +69,8 @@ private:
 
   Gtk::Menu *_scale_menu;
   Gtk::Menu *_levels_menu;
+
+  bool _smooth;
 };