Browse Source

add speed menu

David Rose 22 years ago
parent
commit
c02ef8f956

+ 11 - 0
pandatool/src/win-stats/winStatsGraph.cxx

@@ -152,6 +152,17 @@ void WinStatsGraph::
 set_time_units(int unit_mask) {
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: WinStatsGraph::set_scroll_speed
+//       Access: Public
+//  Description: Called when the user selects a new scroll speed from
+//               the moniotr pulldown menu, this should adjust the
+//               speed for the graph to the indicated value.
+////////////////////////////////////////////////////////////////////
+void WinStatsGraph::
+set_scroll_speed(float scroll_speed) {
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: WinStatsGraph::user_guide_bars_changed
 //       Access: Public

+ 1 - 0
pandatool/src/win-stats/winStatsGraph.h

@@ -57,6 +57,7 @@ public:
   virtual void changed_graph_size(int graph_xsize, int graph_ysize);
 
   virtual void set_time_units(int unit_mask);
+  virtual void set_scroll_speed(float scroll_speed);
   void user_guide_bars_changed();
 
 protected:

+ 5 - 0
pandatool/src/win-stats/winStatsMenuId.h

@@ -31,6 +31,11 @@ enum WinStatsMenuId {
   MI_time_ms,
   MI_time_hz,
   MI_frame_rate_label,
+  MI_speed_1,
+  MI_speed_2,
+  MI_speed_3,
+  MI_speed_6,
+  MI_speed_12,
 
   // This one is last and represents the beginning of the range for
   // the various "new chart" menu options.

+ 129 - 4
pandatool/src/win-stats/winStatsMonitor.cxx

@@ -39,7 +39,10 @@ WinStatsMonitor(WinStatsServer *server) : PStatMonitor(server) {
   _window = 0;
   _menu_bar = 0;
   _options_menu = 0;
-  _time_units = PStatGraph::GBU_ms;
+
+  // This is filled in later when the menu is created.
+  _time_units = 0;
+  _scroll_speed = 0.0;
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -291,6 +294,7 @@ open_strip_chart(int thread_index, int collector_index) {
   add_graph(graph);
 
   graph->set_time_units(_time_units);
+  graph->set_scroll_speed(_scroll_speed);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -304,6 +308,7 @@ open_piano_roll(int thread_index) {
   add_graph(graph);
 
   graph->set_time_units(_time_units);
+  graph->set_scroll_speed(_scroll_speed);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -380,6 +385,51 @@ set_time_units(int unit_mask) {
   SetMenuItemInfo(_options_menu, MI_time_hz, FALSE, &mii);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: WinStatsMonitor::set_scroll_speed
+//       Access: Public
+//  Description: Called when the user selects a new scroll speed from
+//               the monitor pulldown menu, this should adjust the
+//               speeds for all graphs to the indicated value.
+////////////////////////////////////////////////////////////////////
+void WinStatsMonitor::
+set_scroll_speed(float scroll_speed) {
+  _scroll_speed = scroll_speed;
+
+  // First, change all of the open graphs appropriately.
+  Graphs::iterator gi;
+  for (gi = _graphs.begin(); gi != _graphs.end(); ++gi) {
+    WinStatsGraph *graph = (*gi);
+    graph->set_scroll_speed(_scroll_speed);
+  }
+
+  // Now change the checkmark on the pulldown menu.
+  MENUITEMINFO mii;
+  memset(&mii, 0, sizeof(mii));
+  mii.cbSize = sizeof(mii);
+  mii.fMask = MIIM_STATE;
+
+  mii.fState = IS_THRESHOLD_EQUAL(_scroll_speed, 1.0, 0.1) ?
+    MFS_CHECKED : MFS_UNCHECKED;
+  SetMenuItemInfo(_speed_menu, MI_speed_1, FALSE, &mii);
+
+  mii.fState = IS_THRESHOLD_EQUAL(_scroll_speed, 2.0, 0.1) ?
+    MFS_CHECKED : MFS_UNCHECKED;
+  SetMenuItemInfo(_speed_menu, MI_speed_2, FALSE, &mii);
+
+  mii.fState = IS_THRESHOLD_EQUAL(_scroll_speed, 3.0, 0.1) ?
+    MFS_CHECKED : MFS_UNCHECKED;
+  SetMenuItemInfo(_speed_menu, MI_speed_3, FALSE, &mii);
+
+  mii.fState = IS_THRESHOLD_EQUAL(_scroll_speed, 6.0, 0.1) ?
+    MFS_CHECKED : MFS_UNCHECKED;
+  SetMenuItemInfo(_speed_menu, MI_speed_6, FALSE, &mii);
+
+  mii.fState = IS_THRESHOLD_EQUAL(_scroll_speed, 12.0, 0.1) ?
+    MFS_CHECKED : MFS_UNCHECKED;
+  SetMenuItemInfo(_speed_menu, MI_speed_12, FALSE, &mii);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: WinStatsMonitor::add_graph
 //       Access: Private
@@ -422,6 +472,7 @@ create_window() {
   _menu_bar = CreateMenu();
 
   setup_options_menu();
+  setup_speed_menu();
   setup_frame_rate_label();
 
   ChartMenus::iterator mi;
@@ -466,7 +517,12 @@ setup_options_menu() {
   mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_SUBMENU;
   mii.fType = MFT_STRING; 
   mii.hSubMenu = _options_menu;
-  mii.dwTypeData = "Options"; 
+
+  // One day, when there is more than one option here, we will
+  // actually present this to the user as the "Options" menu.  For
+  // now, the only option we have is time units.
+  //mii.dwTypeData = "Options"; 
+  mii.dwTypeData = "Units"; 
   InsertMenuItem(_menu_bar, GetMenuItemCount(_menu_bar), TRUE, &mii);
 
   
@@ -474,15 +530,64 @@ setup_options_menu() {
   mii.fType = MFT_STRING | MFT_RADIOCHECK; 
   mii.hbmpChecked = NULL;
   mii.hbmpUnchecked = NULL;
-  mii.fState = MFS_CHECKED;
+  mii.fState = MFS_UNCHECKED;
   mii.wID = MI_time_ms;
   mii.dwTypeData = "ms";
   InsertMenuItem(_options_menu, GetMenuItemCount(_options_menu), TRUE, &mii);
 
-  mii.fState = MFS_UNCHECKED;
   mii.wID = MI_time_hz;
   mii.dwTypeData = "Hz";
   InsertMenuItem(_options_menu, GetMenuItemCount(_options_menu), TRUE, &mii);
+
+  set_time_units(PStatGraph::GBU_ms);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WinStatsMonitor::setup_speed_menu
+//       Access: Private
+//  Description: Creates the "Speed" pulldown menu.
+////////////////////////////////////////////////////////////////////
+void WinStatsMonitor::
+setup_speed_menu() {
+  _speed_menu = CreatePopupMenu();
+
+  MENUITEMINFO mii;
+  memset(&mii, 0, sizeof(mii));
+  mii.cbSize = sizeof(mii);
+
+  mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_SUBMENU;
+  mii.fType = MFT_STRING; 
+  mii.hSubMenu = _speed_menu;
+  mii.dwTypeData = "Speed"; 
+  InsertMenuItem(_menu_bar, GetMenuItemCount(_menu_bar), TRUE, &mii);
+
+  
+  mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_CHECKMARKS | MIIM_STATE;
+  mii.fType = MFT_STRING | MFT_RADIOCHECK; 
+  mii.hbmpChecked = NULL;
+  mii.hbmpUnchecked = NULL;
+  mii.fState = MFS_UNCHECKED;
+  mii.wID = MI_speed_1;
+  mii.dwTypeData = "1";
+  InsertMenuItem(_speed_menu, GetMenuItemCount(_speed_menu), TRUE, &mii);
+
+  mii.wID = MI_speed_2;
+  mii.dwTypeData = "2";
+  InsertMenuItem(_speed_menu, GetMenuItemCount(_speed_menu), TRUE, &mii);
+
+  mii.wID = MI_speed_3;
+  mii.dwTypeData = "3";
+  InsertMenuItem(_speed_menu, GetMenuItemCount(_speed_menu), TRUE, &mii);
+
+  mii.wID = MI_speed_6;
+  mii.dwTypeData = "6";
+  InsertMenuItem(_speed_menu, GetMenuItemCount(_speed_menu), TRUE, &mii);
+
+  mii.wID = MI_speed_12;
+  mii.dwTypeData = "12";
+  InsertMenuItem(_speed_menu, GetMenuItemCount(_speed_menu), TRUE, &mii);
+
+  set_scroll_speed(3);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -602,6 +707,26 @@ handle_menu_command(int menu_id) {
     set_time_units(PStatGraph::GBU_hz);
     break;
 
+  case MI_speed_1:
+    set_scroll_speed(1);
+    break;
+
+  case MI_speed_2:
+    set_scroll_speed(2);
+    break;
+
+  case MI_speed_3:
+    set_scroll_speed(3);
+    break;
+
+  case MI_speed_6:
+    set_scroll_speed(6);
+    break;
+
+  case MI_speed_12:
+    set_scroll_speed(12);
+    break;
+
   default:
     if (menu_id >= MI_new_chart) {
       const MenuDef &menu_def = lookup_menu(menu_id);

+ 4 - 0
pandatool/src/win-stats/winStatsMonitor.h

@@ -75,6 +75,7 @@ public:
   int get_menu_id(const MenuDef &menu_def);
 
   void set_time_units(int unit_mask);
+  void set_scroll_speed(float scroll_speed);
   
 private:
   void add_graph(WinStatsGraph *graph);
@@ -82,6 +83,7 @@ private:
 
   void create_window();
   void setup_options_menu();
+  void setup_speed_menu();
   void setup_frame_rate_label();
   static void register_window_class(HINSTANCE application);
 
@@ -103,8 +105,10 @@ private:
   HWND _window;
   HMENU _menu_bar;
   HMENU _options_menu;
+  HMENU _speed_menu;
   string _window_title;
   int _time_units;
+  float _scroll_speed;
 
   static bool _window_class_registered;
   static const char * const _window_class_name;

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

@@ -138,6 +138,20 @@ set_time_units(int unit_mask) {
   }
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: WinStatsStripChart::set_scroll_speed
+//       Access: Public
+//  Description: Called when the user selects a new scroll speed from
+//               the moniotr pulldown menu, this should adjust the
+//               speed for the graph to the indicated value.
+////////////////////////////////////////////////////////////////////
+void WinStatsStripChart::
+set_scroll_speed(float scroll_speed) {
+  if (scroll_speed != 0.0f) {
+    set_horizontal_scale(60.0f / scroll_speed);
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: WinStatsStripChart::set_vertical_scale
 //       Access: Public

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

@@ -45,6 +45,7 @@ public:
   virtual void changed_graph_size(int graph_xsize, int graph_ysize);
 
   virtual void set_time_units(int unit_mask);
+  virtual void set_scroll_speed(float scroll_speed);
   void set_vertical_scale(float value_height);
 
 protected: