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