Pārlūkot izejas kodu

universally persistent user guide bars

David Rose 22 gadi atpakaļ
vecāks
revīzija
8c0744fb3a

+ 4 - 3
pandatool/src/gtk-stats/gtkStatsMonitor.cxx

@@ -20,9 +20,10 @@
 #include "gtkStatsWindow.h"
 #include "gtkStatsStripWindow.h"
 #include "gtkStatsBadVersionWindow.h"
+#include "gtkStatsServer.h"
 
-#include <luse.h>
-#include <pStatCollectorDef.h>
+#include "luse.h"
+#include "pStatCollectorDef.h"
 
 #include <gdk--.h>
 
@@ -32,7 +33,7 @@
 //  Description:
 ////////////////////////////////////////////////////////////////////
 GtkStatsMonitor::
-GtkStatsMonitor() {
+GtkStatsMonitor(GtkStatsServer *server) : PStatMonitor(server) {
   _destructing = false;
   _new_collector = false;
 }

+ 3 - 3
pandatool/src/gtk-stats/gtkStatsMonitor.h

@@ -21,12 +21,12 @@
 
 #include "pandatoolbase.h"
 
-#include <pStatMonitor.h>
+#include "pStatMonitor.h"
 #include "pointerTo.h"
 
 #include "pset.h"
 
-
+class GtkStatsServer;
 class GtkStatsWindow;
 class Gdk_Color;
 
@@ -36,7 +36,7 @@ class Gdk_Color;
 ////////////////////////////////////////////////////////////////////
 class GtkStatsMonitor : public PStatMonitor {
 public:
-  GtkStatsMonitor();
+  GtkStatsMonitor(GtkStatsServer *server);
   ~GtkStatsMonitor();
 
   PT(PStatMonitor) close_all_windows();

+ 1 - 1
pandatool/src/gtk-stats/gtkStatsServer.cxx

@@ -27,5 +27,5 @@
 ////////////////////////////////////////////////////////////////////
 PStatMonitor *GtkStatsServer::
 make_monitor() {
-  return new GtkStatsMonitor;
+  return new GtkStatsMonitor(this);
 }

+ 1 - 1
pandatool/src/gtk-stats/gtkStatsServer.h

@@ -21,7 +21,7 @@
 
 #include "pandatoolbase.h"
 
-#include <pStatServer.h>
+#include "pStatServer.h"
 
 
 ////////////////////////////////////////////////////////////////////

+ 0 - 1
pandatool/src/pstatserver/pStatGraph.I

@@ -130,7 +130,6 @@ set_guide_bar_units(int guide_bar_units) {
   if (_guide_bar_units != guide_bar_units) {
     _guide_bar_units = guide_bar_units;
     normal_guide_bars();
-    user_guide_bar_labels();
   }
 }
 

+ 16 - 55
pandatool/src/pstatserver/pStatGraph.cxx

@@ -17,11 +17,11 @@
 ////////////////////////////////////////////////////////////////////
 
 #include "pStatGraph.h"
-
-#include <pStatFrameData.h>
-#include <pStatCollectorDef.h>
-#include <string_utils.h>
-#include <config_pstats.h>
+#include "pStatServer.h"
+#include "pStatFrameData.h"
+#include "pStatCollectorDef.h"
+#include "string_utils.h"
+#include "config_pstats.h"
 
 #include <stdio.h>  // for sprintf
 
@@ -118,7 +118,7 @@ get_guide_bar(int n) const {
 ////////////////////////////////////////////////////////////////////
 int PStatGraph::
 get_num_user_guide_bars() const {
-  return _user_guide_bars.size();
+  return _monitor->get_server()->get_num_user_guide_bars();
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -126,13 +126,10 @@ get_num_user_guide_bars() const {
 //       Access: Public
 //  Description: Returns the nth user-defined guide bar.
 ////////////////////////////////////////////////////////////////////
-const PStatGraph::GuideBar &PStatGraph::
+PStatGraph::GuideBar PStatGraph::
 get_user_guide_bar(int n) const {
-#ifndef NDEBUG
-  static GuideBar bogus_bar(0.0, "bogus", GBS_user);
-  nassertr(n >= 0 && n < (int)_user_guide_bars.size(), bogus_bar);
-#endif
-  return _user_guide_bars[n];
+  float height = _monitor->get_server()->get_user_guide_bar_height(n);
+  return make_guide_bar(height, GBS_user);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -142,10 +139,7 @@ get_user_guide_bar(int n) const {
 ////////////////////////////////////////////////////////////////////
 void PStatGraph::
 move_user_guide_bar(int n, float height) {
-  nassertv(n >= 0 && n < (int)_user_guide_bars.size());
-  string label = format_number(height, _guide_bar_units, _unit_name);
-  _user_guide_bars[n]._height = height;
-  _user_guide_bars[n]._label = label;
+  _monitor->get_server()->move_user_guide_bar(n, height);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -156,12 +150,7 @@ move_user_guide_bar(int n, float height) {
 ////////////////////////////////////////////////////////////////////
 int PStatGraph::
 add_user_guide_bar(float height) {
-  int n = (int)_user_guide_bars.size();
-  GuideBar bar = make_guide_bar(height);
-  bar._style = GBS_user;
-  _user_guide_bars.push_back(bar);
-
-  return n;
+  return _monitor->get_server()->add_user_guide_bar(height);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -173,8 +162,7 @@ add_user_guide_bar(float height) {
 ////////////////////////////////////////////////////////////////////
 void PStatGraph::
 remove_user_guide_bar(int n) {
-  nassertv(n >= 0 && n < (int)_user_guide_bars.size());
-  _user_guide_bars.erase(_user_guide_bars.begin() + n);
+  _monitor->get_server()->remove_user_guide_bar(n);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -186,17 +174,7 @@ remove_user_guide_bar(int n) {
 ////////////////////////////////////////////////////////////////////
 int PStatGraph::
 find_user_guide_bar(float from_height, float to_height) const {
-  GuideBars::const_iterator gbi;
-  for (gbi = _user_guide_bars.begin();
-       gbi != _user_guide_bars.end();
-       ++gbi) {
-    const GuideBar &bar = (*gbi);
-    if (bar._height >= from_height && bar._height <= to_height) {
-      return (int)(gbi - _user_guide_bars.begin());
-    }
-  }
-
-  return -1;
+  return _monitor->get_server()->find_user_guide_bar(from_height, to_height);
 }
 
 
@@ -311,22 +289,6 @@ update_guide_bars(int num_bars, float scale) {
   _guide_bars_changed = true;
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: PStatGraph::user_guide_bar_labels
-//       Access: Protected
-//  Description: Rederives the labels for the user-defined guide bars.
-////////////////////////////////////////////////////////////////////
-void PStatGraph::
-user_guide_bar_labels() {
-  GuideBars::iterator gbi;
-  for (gbi = _user_guide_bars.begin();
-       gbi != _user_guide_bars.end();
-       ++gbi) {
-    GuideBar &bar = (*gbi);
-    bar._label = format_number(bar._height, _guide_bar_units, _unit_name);
-  }
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: PStatGraph::make_guide_bar
 //       Access: Protected
@@ -334,12 +296,11 @@ user_guide_bar_labels() {
 //               level units.
 ////////////////////////////////////////////////////////////////////
 PStatGraph::GuideBar PStatGraph::
-make_guide_bar(float value) const {
+make_guide_bar(float value, PStatGraph::GuideBarStyle style) const {
   string label = format_number(value, _guide_bar_units, _unit_name);
 
-  GuideBarStyle style = GBS_normal;
-
-  if ((_guide_bar_units & GBU_named) == 0) {
+  if ((style == GBS_normal) &&
+      (_guide_bar_units & GBU_named) == 0) {
     // If it's a time unit, check to see if it matches our target
     // frame rate.
     float hz = 1.0 / value;

+ 2 - 4
pandatool/src/pstatserver/pStatGraph.h

@@ -82,7 +82,7 @@ public:
   const GuideBar &get_guide_bar(int n) const;
 
   int get_num_user_guide_bars() const;
-  const GuideBar &get_user_guide_bar(int n) const;
+  GuideBar get_user_guide_bar(int n) const;
   void move_user_guide_bar(int n, float height);
   int add_user_guide_bar(float height);
   void remove_user_guide_bar(int n);
@@ -100,8 +100,7 @@ public:
 protected:
   virtual void normal_guide_bars()=0;
   void update_guide_bars(int num_bars, float scale);
-  void user_guide_bar_labels();
-  GuideBar make_guide_bar(float value) const;
+  GuideBar make_guide_bar(float value, GuideBarStyle style = GBS_normal) const;
 
   bool _labels_changed;
   bool _guide_bars_changed;
@@ -120,7 +119,6 @@ protected:
 
   typedef pvector<GuideBar> GuideBars;
   GuideBars _guide_bars;
-  GuideBars _user_guide_bars;
   int _guide_bar_units;
   string _unit_name;
 };

+ 10 - 0
pandatool/src/pstatserver/pStatMonitor.I

@@ -17,6 +17,16 @@
 ////////////////////////////////////////////////////////////////////
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: PStatMonitor::get_server
+//       Access: Public
+//  Description: Returns the server that owns this monitor.
+////////////////////////////////////////////////////////////////////
+INLINE PStatServer *PStatMonitor::
+get_server() {
+  return _server;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: PStatMonitor::get_client_data
 //       Access: Public

+ 10 - 1
pandatool/src/pstatserver/pStatMonitor.cxx

@@ -27,7 +27,7 @@
 //  Description:
 ////////////////////////////////////////////////////////////////////
 PStatMonitor::
-PStatMonitor() {
+PStatMonitor(PStatServer *server) : _server(server) {
   _client_known = false;
 }
 
@@ -334,3 +334,12 @@ bool PStatMonitor::
 is_thread_safe() {
   return false;
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: PStatMonitor::user_guide_bars_changed
+//       Access: Public, Virtual
+//  Description: Called when the user guide bars have been changed.
+////////////////////////////////////////////////////////////////////
+void PStatMonitor::
+user_guide_bars_changed() {
+}

+ 7 - 1
pandatool/src/pstatserver/pStatMonitor.h

@@ -31,6 +31,7 @@
 #include "pmap.h"
 
 class PStatCollectorDef;
+class PStatServer;
 
 ////////////////////////////////////////////////////////////////////
 //       Class : PStatMonitor
@@ -47,7 +48,7 @@ class PStatMonitor : public ReferenceCount {
 public:
   // The following functions are primarily for use by internal classes
   // to set up the monitor.
-  PStatMonitor();
+  PStatMonitor(PStatServer *server);
   virtual ~PStatMonitor();
 
   void hello_from(const string &hostname, const string &progname);
@@ -62,6 +63,7 @@ public:
   bool is_alive() const;
   void close();
 
+  INLINE PStatServer *get_server();
   INLINE const PStatClientData *get_client_data() const;
   INLINE string get_collector_name(int collector_index);
   const RGBColorf &get_collector_color(int collector_index);
@@ -93,6 +95,10 @@ public:
 
   virtual bool is_thread_safe();
 
+  virtual void user_guide_bars_changed();
+
+protected:
+  PStatServer *_server;
 
 private:
   PT(PStatClientData) _client_data;

+ 10 - 0
pandatool/src/pstatserver/pStatReader.cxx

@@ -126,6 +126,16 @@ idle() {
   _monitor->idle();
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: PStatReader::get_monitor
+//       Access: Public
+//  Description: Returns the monitor that this reader serves.
+////////////////////////////////////////////////////////////////////
+PStatMonitor *PStatReader::
+get_monitor() {
+  return _monitor;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: PStatReader::get_hostname
 //       Access: Private

+ 2 - 0
pandatool/src/pstatserver/pStatReader.h

@@ -56,6 +56,8 @@ public:
   void lost_connection();
   void idle();
 
+  PStatMonitor *get_monitor();
+
 private:
   string get_hostname();
   void send_hello();

+ 98 - 0
pandatool/src/pstatserver/pStatServer.cxx

@@ -210,6 +210,104 @@ release_udp_port(int port) {
   _available_udp_ports.push_back(port);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: PStatServer::get_num_user_guide_bars
+//       Access: Public
+//  Description: Returns the current number of user-defined guide
+//               bars.
+////////////////////////////////////////////////////////////////////
+int PStatServer::
+get_num_user_guide_bars() const {
+  return _user_guide_bars.size();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PStatServer::get_user_guide_bar_height
+//       Access: Public
+//  Description: Returns the height of the nth user-defined guide bar.
+////////////////////////////////////////////////////////////////////
+float PStatServer::
+get_user_guide_bar_height(int n) const {
+  nassertr(n >= 0 && n < (int)_user_guide_bars.size(), 0.0f);
+  return _user_guide_bars[n];
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PStatServer::move_user_guide_bar
+//       Access: Public
+//  Description: Adjusts the height of the nth user-defined guide bar.
+////////////////////////////////////////////////////////////////////
+void PStatServer::
+move_user_guide_bar(int n, float height) {
+  nassertv(n >= 0 && n < (int)_user_guide_bars.size());
+  _user_guide_bars[n] = height;
+  user_guide_bars_changed();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PStatServer::add_user_guide_bar
+//       Access: Public
+//  Description: Creates a new user guide bar and returns its index
+//               number.
+////////////////////////////////////////////////////////////////////
+int PStatServer::
+add_user_guide_bar(float height) {
+  int n = (int)_user_guide_bars.size();
+  _user_guide_bars.push_back(height);
+  user_guide_bars_changed();
+
+  return n;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PStatServer::remove_user_guide_bar
+//       Access: Public
+//  Description: Removes the user guide bar with the indicated index
+//               number.  All subsequent index numbers are adjusted
+//               down one.
+////////////////////////////////////////////////////////////////////
+void PStatServer::
+remove_user_guide_bar(int n) {
+  nassertv(n >= 0 && n < (int)_user_guide_bars.size());
+  _user_guide_bars.erase(_user_guide_bars.begin() + n);
+  user_guide_bars_changed();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PStatServer::find_user_guide_bar
+//       Access: Public
+//  Description: Returns the index number of the first user guide bar
+//               found whose height is within the indicated range, or
+//               -1 if no user guide bars fall within the range.
+////////////////////////////////////////////////////////////////////
+int PStatServer::
+find_user_guide_bar(float from_height, float to_height) const {
+  GuideBars::const_iterator gbi;
+  for (gbi = _user_guide_bars.begin();
+       gbi != _user_guide_bars.end();
+       ++gbi) {
+    float height = (*gbi);
+    if (height >= from_height && height <= to_height) {
+      return (int)(gbi - _user_guide_bars.begin());
+    }
+  }
+
+  return -1;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PStatServer::user_guide_bars_changed
+//       Access: Priate
+//  Description: Called when the user guide bars have been changed.
+////////////////////////////////////////////////////////////////////
+void PStatServer::
+user_guide_bars_changed() {
+  Readers::iterator ri;
+  for (ri = _readers.begin(); ri != _readers.end(); ++ri) {
+    (*ri).second->get_monitor()->user_guide_bars_changed();
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: PStatServer::is_thread_safe
 //       Access: Public

+ 13 - 3
pandatool/src/pstatserver/pStatServer.h

@@ -20,11 +20,9 @@
 #define PSTATSERVER_H
 
 #include "pandatoolbase.h"
-
 #include "pStatListener.h"
-
 #include "connectionManager.h"
-
+#include "vector_float.h"
 #include "pmap.h"
 #include "pdeque.h"
 
@@ -61,6 +59,13 @@ public:
   int get_udp_port();
   void release_udp_port(int port);
 
+  int get_num_user_guide_bars() const;
+  float get_user_guide_bar_height(int n) const;
+  void move_user_guide_bar(int n, float height);
+  int add_user_guide_bar(float height);
+  void remove_user_guide_bar(int n);
+  int find_user_guide_bar(float from_height, float to_height) const;
+
   virtual bool is_thread_safe();
 
 protected:
@@ -68,6 +73,8 @@ protected:
                                 PRErrorCode errcode);
 
 private:
+  void user_guide_bars_changed();
+
   PStatListener *_listener;
 
   typedef pmap<PT(Connection), PStatReader *> Readers;
@@ -79,6 +86,9 @@ private:
   typedef pdeque<int> Ports;
   Ports _available_udp_ports;
   int _next_udp_port;
+
+  typedef vector_float GuideBars;
+  GuideBars _user_guide_bars;
 };
 
 #endif

+ 3 - 2
pandatool/src/text-stats/textMonitor.cxx

@@ -17,8 +17,9 @@
 ////////////////////////////////////////////////////////////////////
 
 #include "textMonitor.h"
+#include "textStats.h"
 
-#include <indent.h>
+#include "indent.h"
 
 ////////////////////////////////////////////////////////////////////
 //     Function: TextMonitor::Constructor
@@ -26,7 +27,7 @@
 //  Description:
 ////////////////////////////////////////////////////////////////////
 TextMonitor::
-TextMonitor() {
+TextMonitor(TextStats *server) : PStatMonitor(server) {
 }
 
 ////////////////////////////////////////////////////////////////////

+ 3 - 2
pandatool/src/text-stats/textMonitor.h

@@ -20,8 +20,9 @@
 #define TEXTMONITOR_H
 
 #include "pandatoolbase.h"
+#include "pStatMonitor.h"
 
-#include <pStatMonitor.h>
+class TextStats;
 
 ////////////////////////////////////////////////////////////////////
 //       Class : TextMonitor
@@ -30,7 +31,7 @@
 ////////////////////////////////////////////////////////////////////
 class TextMonitor : public PStatMonitor {
 public:
-  TextMonitor();
+  TextMonitor(TextStats *server);
 
   virtual string get_monitor_name();
 

+ 1 - 1
pandatool/src/text-stats/textStats.cxx

@@ -61,7 +61,7 @@ TextStats() {
 ////////////////////////////////////////////////////////////////////
 PStatMonitor *TextStats::
 make_monitor() {
-  return new TextMonitor;
+  return new TextMonitor(this);
 }
 
 

+ 6 - 26
pandatool/src/win-stats/winStatsGraph.cxx

@@ -153,34 +153,14 @@ set_time_units(int unit_mask) {
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: WinStatsGraph::move_user_guide_bar
-//       Access: Public, Virtual
-//  Description: Adjusts the height of the nth user-defined guide bar.
-////////////////////////////////////////////////////////////////////
-void WinStatsGraph::
-move_user_guide_bar(int n, float height) {
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: WinStatsGraph::add_user_guide_bar
-//       Access: Public, Virtual
-//  Description: Creates a new user guide bar and returns its index
-//               number.
-////////////////////////////////////////////////////////////////////
-int WinStatsGraph::
-add_user_guide_bar(float height) {
-  return -1;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: WinStatsGraph::remove_user_guide_bar
-//       Access: Public, Virtual
-//  Description: Removes the user guide bar with the indicated index
-//               number.  All subsequent index numbers are adjusted
-//               down one.
+//     Function: WinStatsGraph::user_guide_bars_changed
+//       Access: Public
+//  Description: Called when the user guide bars have been changed.
 ////////////////////////////////////////////////////////////////////
 void WinStatsGraph::
-remove_user_guide_bar(int n) {
+user_guide_bars_changed() {
+  InvalidateRect(_window, NULL, TRUE);
+  InvalidateRect(_graph_window, NULL, TRUE);
 }
 
 ////////////////////////////////////////////////////////////////////

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

@@ -57,10 +57,7 @@ public:
   virtual void changed_graph_size(int graph_xsize, int graph_ysize);
 
   virtual void set_time_units(int unit_mask);
-
-  virtual void move_user_guide_bar(int n, float height);
-  virtual int add_user_guide_bar(float height);
-  virtual void remove_user_guide_bar(int n);
+  void user_guide_bars_changed();
 
 protected:
   void close();

+ 16 - 58
pandatool/src/win-stats/winStatsMonitor.cxx

@@ -17,6 +17,7 @@
 ////////////////////////////////////////////////////////////////////
 
 #include "winStatsMonitor.h"
+#include "winStatsServer.h"
 #include "winStatsStripChart.h"
 #include "winStatsPianoRoll.h"
 #include "winStatsChartMenu.h"
@@ -34,7 +35,7 @@ const char * const WinStatsMonitor::_window_class_name = "monitor";
 //  Description:
 ////////////////////////////////////////////////////////////////////
 WinStatsMonitor::
-WinStatsMonitor() {
+WinStatsMonitor(WinStatsServer *server) : PStatMonitor(server) {
   _window = 0;
   _menu_bar = 0;
   _options_menu = 0;
@@ -254,6 +255,20 @@ has_idle() {
   return true;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: WinStatsMonitor::user_guide_bars_changed
+//       Access: Public, Virtual
+//  Description: Called when the user guide bars have been changed.
+////////////////////////////////////////////////////////////////////
+void WinStatsMonitor::
+user_guide_bars_changed() {
+  Graphs::iterator gi;
+  for (gi = _graphs.begin(); gi != _graphs.end(); ++gi) {
+    WinStatsGraph *graph = (*gi);
+    graph->user_guide_bars_changed();
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: WinStatsMonitor::get_window
 //       Access: Public
@@ -365,63 +380,6 @@ set_time_units(int unit_mask) {
   SetMenuItemInfo(_options_menu, MI_time_hz, FALSE, &mii);
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: WinStatsMonitor::move_user_guide_bar
-//       Access: Public
-//  Description: Adjusts the height of the nth user-defined guide bar
-//               for all graphs that share the indicated thread.
-////////////////////////////////////////////////////////////////////
-void WinStatsMonitor::
-move_user_guide_bar(int thread_index, int n, float height) {
-  Graphs::iterator gi;
-  for (gi = _graphs.begin(); gi != _graphs.end(); ++gi) {
-    WinStatsGraph *graph = (*gi);
-    if (graph->get_thread_index() == thread_index) {
-      graph->move_user_guide_bar(n, height);
-    }
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: WinStatsMonitor::add_user_guide_bar
-//       Access: Public
-//  Description: Creates a new user guide bar and returns its index
-//               number for all graphs that share the indicated
-//               thread.
-////////////////////////////////////////////////////////////////////
-int WinStatsMonitor::
-add_user_guide_bar(int thread_index, float height) {
-  int result = -1;
-
-  Graphs::iterator gi;
-  for (gi = _graphs.begin(); gi != _graphs.end(); ++gi) {
-    WinStatsGraph *graph = (*gi);
-    if (graph->get_thread_index() == thread_index) {
-      result = graph->add_user_guide_bar(height);
-    }
-  }
-
-  return result;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: WinStatsMonitor::remove_user_guide_bar
-//       Access: Public
-//  Description: Removes the user guide bar with the indicated index
-//               number, for all graphs that share the indicated
-//               thread.
-////////////////////////////////////////////////////////////////////
-void WinStatsMonitor::
-remove_user_guide_bar(int thread_index, int n) {
-  Graphs::iterator gi;
-  for (gi = _graphs.begin(); gi != _graphs.end(); ++gi) {
-    WinStatsGraph *graph = (*gi);
-    if (graph->get_thread_index() == thread_index) {
-      graph->remove_user_guide_bar(n);
-    }
-  }
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: WinStatsMonitor::add_graph
 //       Access: Private

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

@@ -30,6 +30,7 @@
 
 #include <windows.h>
 
+class WinStatsServer;
 class WinStatsChartMenu;
 
 ////////////////////////////////////////////////////////////////////
@@ -48,7 +49,7 @@ public:
     int _collector_index;
   };
 
-  WinStatsMonitor();
+  WinStatsMonitor(WinStatsServer *server);
   virtual ~WinStatsMonitor();
 
   virtual string get_monitor_name();
@@ -64,6 +65,8 @@ public:
   virtual void idle();
   virtual bool has_idle();
 
+  virtual void user_guide_bars_changed();
+
   HWND get_window() const;
   void open_strip_chart(int thread_index, int collector_index);
   void open_piano_roll(int thread_index);
@@ -72,10 +75,6 @@ public:
   int get_menu_id(const MenuDef &menu_def);
 
   void set_time_units(int unit_mask);
-
-  void move_user_guide_bar(int thread_index, int n, float height);
-  int add_user_guide_bar(int thread_index, float height);
-  void remove_user_guide_bar(int thread_index, int n);
   
 private:
   void add_graph(WinStatsGraph *graph);

+ 6 - 57
pandatool/src/win-stats/winStatsPianoRoll.cxx

@@ -133,56 +133,6 @@ set_horizontal_scale(float time_width) {
   InvalidateRect(_window, &rect, TRUE);
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: WinStatsPianoRoll::move_user_guide_bar
-//       Access: Public, Virtual
-//  Description: Adjusts the height of the nth user-defined guide bar.
-////////////////////////////////////////////////////////////////////
-void WinStatsPianoRoll::
-move_user_guide_bar(int n, float height) {
-  RECT rect;
-  GetClientRect(_window, &rect);
-  rect.bottom = _top_margin;
-  InvalidateRect(_window, &rect, TRUE);
-
-  InvalidateRect(_graph_window, NULL, TRUE);
-
-  PStatPianoRoll::move_user_guide_bar(n, height);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: WinStatsPianoRoll::add_user_guide_bar
-//       Access: Public, Virtual
-//  Description: Creates a new user guide bar and returns its index
-//               number.
-////////////////////////////////////////////////////////////////////
-int WinStatsPianoRoll::
-add_user_guide_bar(float height) {
-  RECT rect;
-  GetClientRect(_window, &rect);
-  rect.bottom = _top_margin;
-  InvalidateRect(_window, &rect, TRUE);
-
-  return PStatPianoRoll::add_user_guide_bar(height);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: WinStatsPianoRoll::remove_user_guide_bar
-//       Access: Public, Virtual
-//  Description: Removes the user guide bar with the indicated index
-//               number.  All subsequent index numbers are adjusted
-//               down one.
-////////////////////////////////////////////////////////////////////
-void WinStatsPianoRoll::
-remove_user_guide_bar(int n) {
-  RECT rect;
-  GetClientRect(_window, &rect);
-  rect.bottom = _top_margin;
-  InvalidateRect(_window, &rect, TRUE);
-
-  return PStatPianoRoll::remove_user_guide_bar(n);
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: WinStatsPianoRoll::clear_region
 //       Access: Protected
@@ -318,14 +268,13 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
       PN_int16 x = LOWORD(lparam);
       if (x >= 0 && x < get_xsize()) {
         _drag_mode = DM_guide_bar;
-        _drag_guide_bar = 
-          WinStatsGraph::_monitor->add_user_guide_bar(WinStatsGraph::_thread_index, pixel_to_height(x));
+        _drag_guide_bar = add_user_guide_bar(pixel_to_height(x));
         return 0;
       }
 
     } else if (_drag_mode == DM_guide_bar) {
       PN_int16 x = LOWORD(lparam);
-      WinStatsGraph::_monitor->move_user_guide_bar(WinStatsGraph::_thread_index, _drag_guide_bar, pixel_to_height(x));
+      move_user_guide_bar(_drag_guide_bar, pixel_to_height(x));
       return 0;
     }
     break;
@@ -339,9 +288,9 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
     } else if (_drag_mode == DM_guide_bar) {
       PN_int16 x = LOWORD(lparam);
       if (x < 0 || x >= get_xsize()) {
-        WinStatsGraph::_monitor->remove_user_guide_bar(WinStatsGraph::_thread_index, _drag_guide_bar);
+        remove_user_guide_bar(_drag_guide_bar);
       } else {
-        WinStatsGraph::_monitor->move_user_guide_bar(WinStatsGraph::_thread_index, _drag_guide_bar, pixel_to_height(x));
+        move_user_guide_bar(_drag_guide_bar, pixel_to_height(x));
       }
       _drag_mode = DM_none;
       ReleaseCapture();
@@ -508,8 +457,8 @@ draw_guide_label(HDC hdc, int y, const PStatGraph::GuideBar &bar) {
   GetTextExtentPoint32(hdc, label.data(), label.length(), &size);
 
   if (bar._style != GBS_user) {
-    float from_height = pixel_to_height(x - size.cx / 2 - 1);
-    float to_height = pixel_to_height(x + size.cx / 2 + 1);
+    float from_height = pixel_to_height(x - size.cx);
+    float to_height = pixel_to_height(x + size.cx);
     if (find_user_guide_bar(from_height, to_height) >= 0) {
       // Omit the label: there's a user-defined guide bar in the same space.
       return;

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

@@ -47,10 +47,6 @@ public:
   virtual void set_time_units(int unit_mask);
   void set_horizontal_scale(float time_width);
 
-  virtual void move_user_guide_bar(int n, float height);
-  virtual int add_user_guide_bar(float height);
-  virtual void remove_user_guide_bar(int n);
-
 protected:
   void clear_region();
   virtual void begin_draw();

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

@@ -26,5 +26,5 @@
 ////////////////////////////////////////////////////////////////////
 PStatMonitor *WinStatsServer::
 make_monitor() {
-  return new WinStatsMonitor;
+  return new WinStatsMonitor(this);
 }

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

@@ -154,56 +154,6 @@ set_vertical_scale(float value_height) {
   InvalidateRect(_window, &rect, TRUE);
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: WinStatsStripChart::move_user_guide_bar
-//       Access: Public, Virtual
-//  Description: Adjusts the height of the nth user-defined guide bar.
-////////////////////////////////////////////////////////////////////
-void WinStatsStripChart::
-move_user_guide_bar(int n, float height) {
-  RECT rect;
-  GetClientRect(_window, &rect);
-  rect.left = _right_margin;
-  InvalidateRect(_window, &rect, TRUE);
-
-  InvalidateRect(_graph_window, NULL, TRUE);
-
-  PStatStripChart::move_user_guide_bar(n, height);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: WinStatsStripChart::add_user_guide_bar
-//       Access: Public, Virtual
-//  Description: Creates a new user guide bar and returns its index
-//               number.
-////////////////////////////////////////////////////////////////////
-int WinStatsStripChart::
-add_user_guide_bar(float height) {
-  RECT rect;
-  GetClientRect(_window, &rect);
-  rect.left = _right_margin;
-  InvalidateRect(_window, &rect, TRUE);
-
-  return PStatStripChart::add_user_guide_bar(height);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: WinStatsStripChart::remove_user_guide_bar
-//       Access: Public, Virtual
-//  Description: Removes the user guide bar with the indicated index
-//               number.  All subsequent index numbers are adjusted
-//               down one.
-////////////////////////////////////////////////////////////////////
-void WinStatsStripChart::
-remove_user_guide_bar(int n) {
-  RECT rect;
-  GetClientRect(_window, &rect);
-  rect.left = _right_margin;
-  InvalidateRect(_window, &rect, TRUE);
-
-  return PStatStripChart::remove_user_guide_bar(n);
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: WinStatsStripChart::update_labels
 //       Access: Protected, Virtual
@@ -406,14 +356,13 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
       PN_int16 y = HIWORD(lparam);
       if (y >= 0 && y < get_ysize()) {
         _drag_mode = DM_guide_bar;
-        _drag_guide_bar = 
-          WinStatsGraph::_monitor->add_user_guide_bar(_thread_index, pixel_to_height(y));
+        _drag_guide_bar = add_user_guide_bar(pixel_to_height(y));
         return 0;
       }
 
     } else if (_drag_mode == DM_guide_bar) {
       PN_int16 y = HIWORD(lparam);
-      WinStatsGraph::_monitor->move_user_guide_bar(_thread_index, _drag_guide_bar, pixel_to_height(y));
+      move_user_guide_bar(_drag_guide_bar, pixel_to_height(y));
       return 0;
     }
     break;
@@ -427,9 +376,9 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
     } else if (_drag_mode == DM_guide_bar) {
       PN_int16 y = HIWORD(lparam);
       if (y < 0 || y >= get_ysize()) {
-        WinStatsGraph::_monitor->remove_user_guide_bar(_thread_index, _drag_guide_bar);
+        remove_user_guide_bar(_drag_guide_bar);
       } else {
-        WinStatsGraph::_monitor->move_user_guide_bar(_thread_index, _drag_guide_bar, pixel_to_height(y));
+        move_user_guide_bar(_drag_guide_bar, pixel_to_height(y));
       }
       _drag_mode = DM_none;
       ReleaseCapture();
@@ -589,8 +538,8 @@ draw_guide_label(HDC hdc, int x, const PStatGraph::GuideBar &bar, int last_y) {
   GetTextExtentPoint32(hdc, label.data(), label.length(), &size);
 
   if (bar._style != GBS_user) {
-    float from_height = pixel_to_height(y + size.cy / 2 + 1);
-    float to_height = pixel_to_height(y - size.cy / 2 - 1);
+    float from_height = pixel_to_height(y + size.cy);
+    float to_height = pixel_to_height(y - size.cy);
     if (find_user_guide_bar(from_height, to_height) >= 0) {
       // Omit the label: there's a user-defined guide bar in the same space.
       return last_y;

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

@@ -47,10 +47,6 @@ public:
   virtual void set_time_units(int unit_mask);
   void set_vertical_scale(float value_height);
 
-  virtual void move_user_guide_bar(int n, float height);
-  virtual int add_user_guide_bar(float height);
-  virtual void remove_user_guide_bar(int n);
-
 protected:
   virtual void update_labels();