Panda3D
winStatsMonitor.h
1 // Filename: winStatsMonitor.h
2 // Created by: drose (02Dec03)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef WINSTATSMONITOR_H
16 #define WINSTATSMONITOR_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "winStatsGraph.h"
21 #include "pStatMonitor.h"
22 #include "pointerTo.h"
23 #include "pset.h"
24 #include "pvector.h"
25 #include "pmap.h"
26 
27 #include <windows.h>
28 
29 class WinStatsServer;
30 class WinStatsChartMenu;
31 
32 ////////////////////////////////////////////////////////////////////
33 // Class : WinStatsMonitor
34 // Description : This class represents a connection to a PStatsClient
35 // and manages the data exchange with the client.
36 ////////////////////////////////////////////////////////////////////
37 class WinStatsMonitor : public PStatMonitor {
38 public:
39  class MenuDef {
40  public:
41  INLINE MenuDef(int thread_index, int collector_index, bool show_level);
42  INLINE bool operator < (const MenuDef &other) const;
43 
44  int _thread_index;
45  int _collector_index;
46  bool _show_level;
47  };
48 
50  virtual ~WinStatsMonitor();
51 
52  virtual string get_monitor_name();
53 
54  virtual void initialized();
55  virtual void got_hello();
56  virtual void got_bad_version(int client_major, int client_minor,
57  int server_major, int server_minor);
58  virtual void new_collector(int collector_index);
59  virtual void new_thread(int thread_index);
60  virtual void new_data(int thread_index, int frame_number);
61  virtual void lost_connection();
62  virtual void idle();
63  virtual bool has_idle();
64 
65  virtual void user_guide_bars_changed();
66 
67  HWND get_window() const;
68  void open_strip_chart(int thread_index, int collector_index, bool show_level);
69  void open_piano_roll(int thread_index);
70 
71  const MenuDef &lookup_menu(int menu_id) const;
72  int get_menu_id(const MenuDef &menu_def);
73 
74  void set_time_units(int unit_mask);
75  void set_scroll_speed(double scroll_speed);
76  void set_pause(bool pause);
77 
78 private:
79  void add_graph(WinStatsGraph *graph);
80  void remove_graph(WinStatsGraph *graph);
81 
82  void create_window();
83  void setup_options_menu();
84  void setup_speed_menu();
85  void setup_frame_rate_label();
86  static void register_window_class(HINSTANCE application);
87 
88  static LONG WINAPI static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
89  LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
90  void handle_menu_command(int menu_id);
91 
93  Graphs _graphs;
94 
96  ChartMenus _chart_menus;
97 
98  typedef pvector<MenuDef> MenuById;
100  MenuById _menu_by_id;
101  MenuByDef _menu_by_def;
102 
103  HWND _window;
104  HMENU _menu_bar;
105  HMENU _options_menu;
106  HMENU _speed_menu;
107  string _window_title;
108  int _time_units;
109  double _scroll_speed;
110  bool _pause;
111 
112  static bool _window_class_registered;
113  static const char * const _window_class_name;
114 
115  friend class WinStatsGraph;
116 };
117 
118 #include "winStatsMonitor.I"
119 
120 #endif
virtual string get_monitor_name()
Should be redefined to return a descriptive name for the type of PStatsMonitor this is...
The class that owns the main loop, waiting for client connections.
void set_time_units(int unit_mask)
Called when the user selects a new time units from the monitor pulldown menu, this should adjust the ...
virtual void new_thread(int thread_index)
Called whenever a new Thread definition is received from the client.
virtual void new_data(int thread_index, int frame_number)
Called as each frame&#39;s data is made available.
void open_strip_chart(int thread_index, int collector_index, bool show_level)
Opens a new strip chart showing the indicated data.
virtual void lost_connection()
Called whenever the connection to the client has been lost.
virtual bool has_idle()
Should be redefined to return true if you want to redefine idle() and expect it to be called...
void set_scroll_speed(double scroll_speed)
Called when the user selects a new scroll speed from the monitor pulldown menu, this should adjust th...
This is an abstract class that presents the interface to any number of different front-ends for the s...
Definition: pStatMonitor.h:43
This is just an abstract base class to provide a common pointer type for the various kinds of graphs ...
Definition: winStatsGraph.h:32
virtual void got_bad_version(int client_major, int client_minor, int server_major, int server_minor)
Like got_hello(), this is called when the "hello" message has been received from the client...
void set_pause(bool pause)
Called when the user selects a pause on or pause off option from the menu.
virtual void initialized()
Called after the monitor has been fully set up.
A pulldown menu of charts available for a particular thread.
virtual void new_collector(int collector_index)
Called whenever a new Collector definition is received from the client.
This class represents a connection to a PStatsClient and manages the data exchange with the client...
virtual void idle()
If has_idle() returns true, this will be called periodically to allow the monitor to update its displ...
const MenuDef & lookup_menu(int menu_id) const
Returns the MenuDef properties associated with the indicated menu ID.
int get_menu_id(const MenuDef &menu_def)
Returns the menu ID that is reserved for the indicated MenuDef properties.
void open_piano_roll(int thread_index)
Opens a new piano roll showing the indicated data.
virtual void user_guide_bars_changed()
Called when the user guide bars have been changed.
HWND get_window() const
Returns the window handle to the monitor&#39;s window.
virtual void got_hello()
Called when the "hello" message has been received from the client.